mirror of
https://github.com/hcengineering/platform.git
synced 2026-10-01 14:05:05 +02:00
UBERF-4725 Migrate collaborative content (#5717)
Signed-off-by: Alexander Onnikov <Alexander.Onnikov@xored.com>
This commit is contained in:
@@ -15,7 +15,7 @@
|
||||
"build:watch": "compile",
|
||||
"_phase:bundle": "rushx bundle",
|
||||
"bundle": "mkdir -p bundle && node esbuild.js",
|
||||
"run-local": "cross-env SERVER_SECRET=secret MONGO_URL=mongodb://localhost:27017 COLLABORATOR_URL=ws://localhost:3078 COLLABORATOR_API_URL=http://localhost:3078 STORAGE_CONFIG=minio|minio?accessKey=minioadmin&secretKey=minioadmin PRODUCT_ID=ezqms node --nolazy -r ts-node/register ./src/__start.ts",
|
||||
"run-local": "cross-env SERVER_SECRET=secret MONGO_URL=mongodb://localhost:27017 COLLABORATOR_URL=ws://localhost:3078 STORAGE_CONFIG=minio|minio?accessKey=minioadmin&secretKey=minioadmin PRODUCT_ID=ezqms node --nolazy -r ts-node/register ./src/__start.ts",
|
||||
"run": "cross-env node -r ts-node/register --max-old-space-size=8000 ./src/__start.ts",
|
||||
"format": "format src",
|
||||
"test": "jest --passWithNoTests --silent",
|
||||
|
||||
@@ -8,7 +8,7 @@ import { HtmlConversionBackend } from './convert/convert'
|
||||
export interface Config {
|
||||
doc: string
|
||||
token: string
|
||||
collaboratorApiURL: string
|
||||
collaboratorURL: string
|
||||
uploadURL: string
|
||||
workspaceId: WorkspaceId
|
||||
owner: Ref<Employee>
|
||||
|
||||
@@ -21,7 +21,7 @@ import core, {
|
||||
Ref,
|
||||
TxOperations,
|
||||
generateId,
|
||||
getCollaborativeDoc,
|
||||
makeCollaborativeDoc,
|
||||
systemAccountEmail,
|
||||
type Blob
|
||||
} from '@hcengineering/core'
|
||||
@@ -100,7 +100,7 @@ async function createDocument (
|
||||
abstract: '',
|
||||
effectiveDate: 0,
|
||||
reviewInterval: DEFAULT_PERIODIC_REVIEW_INTERVAL,
|
||||
content: getCollaborativeDoc(generateId()),
|
||||
content: makeCollaborativeDoc(generateId()),
|
||||
snapshots: 0,
|
||||
plannedEffectiveDate: 0
|
||||
}
|
||||
@@ -168,7 +168,7 @@ async function createTemplateIfNotExist (
|
||||
approvers: [],
|
||||
coAuthors: [],
|
||||
changeControl: ccRecordId,
|
||||
content: getCollaborativeDoc(generateId()),
|
||||
content: makeCollaborativeDoc(generateId()),
|
||||
snapshots: 0,
|
||||
plannedEffectiveDate: 0
|
||||
}
|
||||
@@ -208,8 +208,8 @@ async function createSections (
|
||||
throw new Error(`Invalid document: ${JSON.stringify(doc)}`)
|
||||
}
|
||||
|
||||
const { collaboratorApiURL, token, workspaceId } = config
|
||||
const collaborator = getCollaboratorClient(txops.getHierarchy(), workspaceId, token, collaboratorApiURL)
|
||||
const { collaboratorURL, token, workspaceId } = config
|
||||
const collaborator = getCollaboratorClient(workspaceId, token, collaboratorURL)
|
||||
|
||||
console.log('Creating document content')
|
||||
|
||||
@@ -229,7 +229,7 @@ async function createSections (
|
||||
content += `<h1>${section.title}</h1>${section.content}`
|
||||
}
|
||||
|
||||
await collaborator.updateContent(collabId, 'content', content)
|
||||
await collaborator.updateContent(collabId, { content })
|
||||
} finally {
|
||||
// do nothing
|
||||
}
|
||||
|
||||
@@ -44,8 +44,8 @@ export function docImportTool (): void {
|
||||
process.exit(1)
|
||||
}
|
||||
|
||||
const collaboratorApiUrl = process.env.COLLABORATOR_API_URL
|
||||
if (collaboratorApiUrl === undefined) {
|
||||
const collaboratorUrl = process.env.COLLABORATOR_URL
|
||||
if (collaboratorUrl === undefined) {
|
||||
console.error('please provide collaborator url')
|
||||
process.exit(1)
|
||||
}
|
||||
@@ -104,7 +104,7 @@ export function docImportTool (): void {
|
||||
space: cmd.space,
|
||||
uploadURL: uploadUrl,
|
||||
storageAdapter,
|
||||
collaboratorApiURL: collaboratorApiUrl,
|
||||
collaboratorURL: collaboratorUrl,
|
||||
token: generateToken(systemAccountEmail, workspaceId)
|
||||
}
|
||||
|
||||
|
||||
@@ -106,7 +106,6 @@ services:
|
||||
- TELEGRAM_URL=http://localhost:8086
|
||||
- REKONI_URL=http://localhost:4004
|
||||
- COLLABORATOR_URL=ws://localhost:3078
|
||||
- COLLABORATOR_API_URL=http://localhost:3078
|
||||
- STORAGE_CONFIG=${STORAGE_CONFIG}
|
||||
- GITHUB_URL=http://localhost:3500
|
||||
- PRINT_URL=http://localhost:4005
|
||||
|
||||
@@ -93,7 +93,6 @@ services:
|
||||
- TELEGRAM_URL=http://localhost:8086
|
||||
- REKONI_URL=http://localhost:4004
|
||||
- COLLABORATOR_URL=ws://localhost:3078
|
||||
- COLLABORATOR_API_URL=http://localhost:3078
|
||||
- STORAGE_CONFIG=${STORAGE_CONFIG}
|
||||
- GITHUB_URL=http://localhost:3500
|
||||
- PRINT_URL=http://localhost:4005
|
||||
|
||||
+1
-2
@@ -5,9 +5,8 @@ FRONT_URL=http://localhost:8080
|
||||
REKONI_URL=http://localhost:4004
|
||||
|
||||
COLLABORATOR_URL=ws://locahost:3078
|
||||
COLLABORATOR_API_URL=http://locahost:3078
|
||||
|
||||
PRINT_URL=http://localhost:4005
|
||||
SIGN_URL=http://localhost:4006
|
||||
|
||||
ANALYTICS_COLLECTOR_URL=http://localhost:4007
|
||||
ANALYTICS_COLLECTOR_URL=http://localhost:4007
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
{
|
||||
"ACCOUNTS_URL":"http://localhost:3000",
|
||||
"COLLABORATOR_URL": "ws://localhost:3078",
|
||||
"COLLABORATOR_API_URL": "http://localhost:3078",
|
||||
"UPLOAD_URL":"/files",
|
||||
"REKONI_URL": "http://localhost:4004",
|
||||
"PRINT_URL": "http://localhost:4005",
|
||||
|
||||
@@ -6,6 +6,5 @@
|
||||
"GMAIL_URL": "https://gmail.hc.engineering",
|
||||
"CALENDAR_URL": "https://calendar.hc.engineering",
|
||||
"REKONI_URL": "https://rekoni.hc.engineering",
|
||||
"COLLABORATOR_URL": "wss://collaborator.hc.engineering",
|
||||
"COLLABORATOR_API_URL": "https://collaborator.hc.engineering"
|
||||
"COLLABORATOR_URL": "wss://collaborator.hc.engineering"
|
||||
}
|
||||
@@ -1,7 +1,6 @@
|
||||
{
|
||||
"ACCOUNTS_URL":"/account",
|
||||
"COLLABORATOR_URL": "ws://localhost:3078",
|
||||
"COLLABORATOR_API_URL": "http://localhost:3078",
|
||||
"UPLOAD_URL":"/files",
|
||||
"TELEGRAM_URL": "http://localhost:8086",
|
||||
"GMAIL_URL": "http://localhost:8088",
|
||||
|
||||
@@ -124,7 +124,6 @@ export interface Config {
|
||||
MODEL_VERSION: string
|
||||
VERSION: string
|
||||
COLLABORATOR_URL: string
|
||||
COLLABORATOR_API_URL: string
|
||||
REKONI_URL: string
|
||||
TELEGRAM_URL: string
|
||||
GMAIL_URL: string
|
||||
@@ -288,7 +287,6 @@ export async function configurePlatform() {
|
||||
setMetadata(presentation.metadata.FilesURL, config.FILES_URL)
|
||||
setMetadata(presentation.metadata.UploadURL, config.UPLOAD_URL)
|
||||
setMetadata(presentation.metadata.CollaboratorUrl, config.COLLABORATOR_URL)
|
||||
setMetadata(presentation.metadata.CollaboratorApiUrl, config.COLLABORATOR_API_URL)
|
||||
|
||||
setMetadata(presentation.metadata.FrontUrl, config.FRONT_URL)
|
||||
setMetadata(presentation.metadata.PreviewConfig, parsePreviewConfig(config.PREVIEW_CONFIG))
|
||||
|
||||
@@ -1214,10 +1214,6 @@ async function updateId (
|
||||
const markup = (contentDoc as any)[attrName] as Markup
|
||||
const newMarkup = markup.replaceAll(doc._id, newId)
|
||||
await update(h, db, contentDoc, { [attrName]: newMarkup })
|
||||
} else if (attr.type._class === core.class.TypeCollaborativeMarkup) {
|
||||
const markup = (contentDoc as any)[attrName]
|
||||
const newMarkup = markup.replaceAll(doc._id, newId)
|
||||
await update(h, db, contentDoc, { [attrName]: newMarkup })
|
||||
} else if (attr.type._class === core.class.TypeCollaborativeDoc) {
|
||||
const collaborativeDoc = (contentDoc as any)[attr.name] as CollaborativeDoc
|
||||
await updateYDoc(ctx, collaborativeDoc, storage, workspaceId, contentDoc, newId, doc)
|
||||
|
||||
@@ -7,7 +7,7 @@ import core, {
|
||||
type MeasureContext,
|
||||
type Ref,
|
||||
type WorkspaceId,
|
||||
getCollaborativeDocId
|
||||
makeCollaborativeDoc
|
||||
} from '@hcengineering/core'
|
||||
import { getMongoClient, getWorkspaceDB } from '@hcengineering/mongo'
|
||||
import { type StorageAdapter } from '@hcengineering/server-core'
|
||||
@@ -39,10 +39,7 @@ export async function fixJsonMarkup (
|
||||
|
||||
const attributes = hierarchy.getAllAttributes(_class)
|
||||
const filtered = Array.from(attributes.values()).filter((attribute) => {
|
||||
return (
|
||||
hierarchy.isDerived(attribute.type._class, core.class.TypeMarkup) ||
|
||||
hierarchy.isDerived(attribute.type._class, core.class.TypeCollaborativeMarkup)
|
||||
)
|
||||
return hierarchy.isDerived(attribute.type._class, core.class.TypeMarkup)
|
||||
})
|
||||
if (filtered.length === 0) continue
|
||||
|
||||
@@ -88,7 +85,7 @@ async function processFixJsonMarkupFor (
|
||||
}
|
||||
if (res !== value) {
|
||||
update[attribute.name] = res
|
||||
remove.push(getCollaborativeDocId(doc._id, attribute.name))
|
||||
remove.push(makeCollaborativeDoc(doc._id, attribute.name))
|
||||
}
|
||||
}
|
||||
} catch {}
|
||||
|
||||
Reference in New Issue
Block a user