Skip to content

Commit

Permalink
Fix auth for notion import. Fix readme (#6720)
Browse files Browse the repository at this point in the history
  • Loading branch information
akhismat committed Sep 25, 2024
1 parent ea0819e commit 9ab1cab
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 28 deletions.
13 changes: 3 additions & 10 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,19 +8,12 @@
"name": "Debug notion import",
"type": "node",
"request": "launch",
// "args": ["src/__start.ts", "import-notion-to-teamspace", "/home/anna/work/notion/natalya/Export-fad9ecb4-a1a5-4623-920d-df32dd423743", "-ws", "w-user1-ws1-66d8018b-ce1e0c3164-006bb0", "-ts", "notion"],
"args": ["src/__start.ts", "import-notion", "/home/anna/work/notion/natalya/Export-fad9ecb4-a1a5-4623-920d-df32dd423743", "-ws", "w-user1-ws1-66d8018b-ce1e0c3164-006bb0"],
"args": ["src/__start.ts", "import-notion-to-teamspace", "/home/anna/work/notion/natalya/Export-fad9ecb4-a1a5-4623-920d-df32dd423743", "-ws", "notion-test", "-u", "user1", "-pw", "1234", "-ts", "natalya"],
// "args": ["src/__start.ts", "import-notion-with-teamspaces", "/home/anna/work/notion/natalya/Export-fad9ecb4-a1a5-4623-920d-df32dd423743", "-ws", "ws1", "-u", "user1", "-pw", "1234"],
"env": {
"SERVER_SECRET": "secret",
"MINIO_ACCESS_KEY": "minioadmin",
"MINIO_SECRET_KEY": "minioadmin",
"MINIO_ENDPOINT": "localhost",
"TRANSACTOR_URL": "ws://localhost:3333",
"MONGO_URL": "mongodb://localhost:27017",
"FRONT_URL": "http://localhost:8087",
"ACCOUNTS_URL": "http://localhost:3000",
"TELEGRAM_DATABASE": "telegram-service",
"ELASTIC_URL": "http://localhost:9200",
"REKONI_URL": "http://localhost:4004"
},
"runtimeVersion": "20",
"runtimeArgs": ["--nolazy", "-r", "ts-node/register"],
Expand Down
15 changes: 10 additions & 5 deletions dev/tool/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,28 +50,33 @@ rushx run-local import-notion-to-teamspace /home/john/extracted-notion-docs \
--teamspace imported
```

#### For clouds:
#### For cloud deployment:
##### Here is an example for those who's using huly.app cloud:
To import Notion workspace with teamspaces
1. Go to the root folder of the extracted archive with exported data.
2. Run import command as follow:

* To import Notion workspace with teamspaces
```
docker run \
-e SERVER_SECRET="" \
-e ACCOUNTS_URL="https://account.huly.app" \
-e FRONT_URL="https://huly.app" \
-v $(pwd):/data \
hardcoreeng/tool:latest \
-- bundle.js import-notion-with-teamspaces /tmp/notion-docs \
-- bundle.js import-notion-with-teamspaces /data \
--user [email protected] \
--password 4321qwe \
--workspace ws1
```
To import Notion workspace without teamspaces or a page with subpages.
* To import Notion workspace without teamspaces or a page with subpages.
```
docker run \
-e SERVER_SECRET="" \
-e ACCOUNTS_URL="https://account.huly.app" \
-e FRONT_URL="https://huly.app" \
-v $(pwd):/data \
hardcoreeng/tool:latest \
-- bundle.js import-notion-to-teamspace /tmp/notion-docs \
-- bundle.js import-notion-to-teamspace /data \
--user [email protected] \
--password 4321qwe \
--workspace ws1 \
Expand Down
21 changes: 8 additions & 13 deletions dev/tool/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ import serverClientPlugin, {
} from '@hcengineering/server-client'
import { getServerPipeline } from '@hcengineering/server-pipeline'
import serverToken, { decodeToken, generateToken } from '@hcengineering/server-token'
import toolPlugin, { connect, FileModelLogger } from '@hcengineering/server-tool'
import toolPlugin, { FileModelLogger } from '@hcengineering/server-tool'
import { createWorkspace, upgradeWorkspace } from '@hcengineering/workspace-service'
import path from 'path'

Expand All @@ -75,7 +75,6 @@ import core, {
systemAccountEmail,
TxOperations,
versionToString,
type Client as CoreClient,
type Data,
type Doc,
type Ref,
Expand Down Expand Up @@ -297,17 +296,13 @@ export function devTool (
}
}

const connection = (await connect(
selectedWs.endpoint,
{
name: selectedWs.workspaceId
},
undefined,
{
mode: 'backup'
}
)) as unknown as CoreClient
const client = new TxOperations(connection, core.account.System)
const connection = await createClient(selectedWs.endpoint, selectedWs.token)
const acc = connection.getModel().getAccountByEmail(user)
if (acc === undefined) {
console.log('Account not found for email: ', user)
return
}
const client = new TxOperations(connection, acc._id)
await importNotion(client, uploader(selectedWs.token), dir, teamspace)
await connection.close()
}
Expand Down

0 comments on commit 9ab1cab

Please sign in to comment.