Skip to content

Commit 8e14c06

Browse files
committed
UBERF-9747
Signed-off-by: Andrey Sobolev <[email protected]>
1 parent 47c61d1 commit 8e14c06

File tree

150 files changed

+2274
-1732
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

150 files changed

+2274
-1732
lines changed

.vscode/launch.json

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,8 @@
103103
"UPLOAD_URL": "/files",
104104
"AI_BOT_URL": "http://localhost:4010",
105105
"STATS_URL": "http://huly.local:4900",
106-
"QUEUE_CONFIG": "localhost:19092"
106+
"QUEUE_CONFIG": "localhost:19092",
107+
"RATE_LIMIT_MAX": "25000"
107108
},
108109
"runtimeArgs": ["--nolazy", "-r", "ts-node/register"],
109110
"runtimeVersion": "20",
@@ -120,9 +121,9 @@
120121
"args": ["src/__start.ts"],
121122
"env": {
122123
"FULLTEXT_URL": "http://localhost:4710",
123-
// "DB_URL": "mongodb://localhost:27018",
124+
"DB_URL": "mongodb://localhost:27018",
124125
// "DB_URL": "postgresql://postgres:example@localhost:5432",
125-
"DB_URL": "postgresql://[email protected]:26258/defaultdb?sslmode=disable",
126+
// "DB_URL": "postgresql://[email protected]:26258/defaultdb?sslmode=disable",
126127
// "GREEN_URL": "http://huly.local:6767?token=secret",
127128
"SERVER_PORT": "3334",
128129
"METRICS_CONSOLE": "false",
@@ -183,7 +184,7 @@
183184
"request": "launch",
184185
"args": ["src/__start.ts"],
185186
"env": {
186-
"MONGO_URL": "mongodb://localhost:27017",
187+
// "MONGO_URL": "mongodb://localhost:27017",
187188
// "DB_URL": "mongodb://localhost:27017",
188189
"DB_URL": "postgresql://[email protected]:26257/defaultdb?sslmode=disable",
189190
"SERVER_SECRET": "secret",
@@ -217,12 +218,13 @@
217218
"args": ["src/__start.ts"],
218219
"env": {
219220
// "MONGO_URL": "mongodb://localhost:27018",
220-
// "DB_URL": "mongodb://localhost:27018",
221+
"DB_URL": "mongodb://localhost:27018",
221222
// "DB_URL": "postgresql://postgres:example@localhost:5432",
222-
"DB_URL": "postgresql://[email protected]:26258/defaultdb?sslmode=disable",
223+
// "DB_URL": "postgresql://[email protected]:26258/defaultdb?sslmode=disable",
223224
"SERVER_SECRET": "secret",
224-
"REGION_INFO": "|Mongo;pg|Postgres;cockroach|CockroachDB",
225-
"TRANSACTOR_URL": "ws://transactor:3334;ws://localhost:3334",
225+
"QUEUE_CONFIG": "huly.local:19092",
226+
"REGION_INFO": "|America;europe|Europe",
227+
"TRANSACTOR_URL": "ws://huly.local:3334;ws://huly.local:3334,ws://huly.local:3335;ws://huly.local:3335;europe",
226228
"ACCOUNTS_URL": "http://localhost:3003",
227229
"ACCOUNT_PORT": "3003",
228230
"FRONT_URL": "http://localhost:8083",

common/config/rush/command-line.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
*/
55
{
66
"$schema": "https://developer.microsoft.com/json-schemas/rush/v5/command-line.schema.json",
7-
87
"phases": [
98
{
109
"name": "_phase:build",

common/scripts/rush_docker.sh

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
export RUSH_ALLOW_UNSUPPORTED_NODEJS=1
2+
rush docker:build -p 20 \
3+
--to @hcengineering/pod-server --to @hcengineering/pod-front --to @hcengineering/prod --to @hcengineering/pod-account --to @hcengineering/pod-workspace --to @hcengineering/pod-collaborator --to @hcengineering/tool --to @hcengineering/pod-print --to @hcengineering/pod-sign --to @hcengineering/pod-analytics-collector --to @hcengineering/rekoni-service --to @hcengineering/pod-ai-bot --to @hcengineering/import-tool --to @hcengineering/pod-stats --to @hcengineering/pod-fulltext --to @hcengineering/pod-love --to @hcengineering/pod-mail --to @hcengineering/pod-datalake --to @hcengineering/pod-inbound-mail --to @hcengineering/pod-export --to @hcengineering/pod-msg2file

dev/doc-import-tool/src/import.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ export default async function importExtractedFile (
4747

4848
try {
4949
console.log(`Connected to ${transactorUrl}`)
50-
const txops = new TxOperations(connection, core.account.System)
50+
const txops = new TxOperations(connection, core.account.System, workspaceId)
5151

5252
try {
5353
const docId = await createDocument(txops, extractedFile, config)

dev/import-tool/src/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ export function importTool (): void {
9595

9696
console.log('Connecting to Transactor URL: ', selectedWs.endpoint)
9797
const connection = await createClient(selectedWs.endpoint, selectedWs.token)
98-
const client = new TxOperations(connection, socialId)
98+
const client = new TxOperations(connection, socialId, selectedWs.workspace)
9999
const fileUploader = new FrontFileUploader(
100100
getFrontUrl(),
101101
selectedWs.workspace,

dev/prod/src/platform.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ import { uploaderId } from '@hcengineering/uploader'
6868
import { mediaId } from '@hcengineering/media'
6969
import recorder, { recorderId } from '@hcengineering/recorder'
7070
import { viewId } from '@hcengineering/view'
71-
import workbench, { workbenchId } from '@hcengineering/workbench'
71+
import workbench, { workbenchId, workbenchAppsId } from '@hcengineering/workbench'
7272
import { mailId } from '@hcengineering/mail'
7373
import { chatId } from '@hcengineering/chat'
7474
import github, { githubId } from '@hcengineering/github'
@@ -148,6 +148,7 @@ import { preferenceId } from '@hcengineering/preference'
148148
import { uiId } from '@hcengineering/ui/src/plugin'
149149
import { configureAnalytics } from './analytics'
150150

151+
151152
export interface Config {
152153
ACCOUNTS_URL: string
153154
UPLOAD_URL: string
@@ -487,6 +488,7 @@ export async function configurePlatform() {
487488
uiPlugin.metadata.Routes,
488489
new Map([
489490
[workbenchId, workbench.component.WorkbenchApp],
491+
[workbenchAppsId, workbench.component.WorkbenchApps],
490492
[loginId, login.component.LoginApp],
491493
[onboardId, onboard.component.OnboardApp],
492494
[githubId, github.component.ConnectApp],

dev/tool/src/benchmark.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -410,7 +410,7 @@ export function benchmarkWorker (): void {
410410

411411
if (msg.options.mode === 'find-all') {
412412
const benchmarkPersonId = (core.account.System + '_benchmark') as PersonId
413-
const opt = new TxOperations(connection, benchmarkPersonId)
413+
const opt = new TxOperations(connection, benchmarkPersonId, msg.workspaceId)
414414
parentPort?.postMessage({
415415
type: 'operate',
416416
workId: msg.workId
@@ -551,7 +551,7 @@ export async function stressBenchmark (transactor: string, mode: StressBenchmark
551551
export async function testFindAll (endpoint: string, workspace: WorkspaceUuid, account: PersonUuid): Promise<void> {
552552
const connection = await connect(endpoint, workspace, account)
553553
try {
554-
const client = new TxOperations(connection, core.account.System)
554+
const client = new TxOperations(connection, core.account.System, workspace)
555555
const start = platformNow()
556556
const res = await client.findAll(
557557
recruit.class.Applicant,
@@ -576,7 +576,7 @@ export async function generateWorkspaceData (
576576
email: string
577577
): Promise<void> {
578578
const connection = await connect(endpoint, workspace)
579-
const client = new TxOperations(connection, core.account.System)
579+
const client = new TxOperations(connection, core.account.System, workspace)
580580
try {
581581
const emailSocialString = buildSocialIdString({ type: SocialIdType.EMAIL, value: email })
582582
const person = await getPersonBySocialKey(client, emailSocialString)

dev/tool/src/clean.ts

Lines changed: 19 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -86,11 +86,10 @@ export async function cleanWorkspace (
8686
opt: { recruit: boolean, tracker: boolean, removedTx: boolean }
8787
): Promise<void> {
8888
const connection = (await connect(transactorUrl, workspaceId, undefined, {
89-
mode: 'backup',
90-
model: 'upgrade'
89+
mode: 'backup'
9190
})) as unknown as CoreClient & BackupClient
9291
try {
93-
const ops = new TxOperations(connection, core.account.System)
92+
const ops = new TxOperations(connection, core.account.System, workspaceId)
9493

9594
const hierarchy = ops.getHierarchy()
9695

@@ -164,6 +163,7 @@ export async function cleanWorkspace (
164163
client.close()
165164
}
166165
} catch (err: any) {
166+
// TODO: Add force-close
167167
console.trace(err)
168168
} finally {
169169
await connection.close()
@@ -232,8 +232,7 @@ export async function cleanRemovedTransactions (workspaceId: WorkspaceUuid, tran
232232

233233
export async function optimizeModel (workspaceId: WorkspaceUuid, transactorUrl: string): Promise<void> {
234234
const connection = (await connect(transactorUrl, workspaceId, undefined, {
235-
mode: 'backup',
236-
model: 'upgrade'
235+
mode: 'backup'
237236
})) as unknown as CoreClient & BackupClient
238237
try {
239238
let count = 0
@@ -298,6 +297,8 @@ export async function optimizeModel (workspaceId: WorkspaceUuid, transactorUrl:
298297
} catch (err: any) {
299298
console.trace(err)
300299
} finally {
300+
// TODO: Add force-close
301+
await connection.sendForceClose()
301302
await connection.close()
302303
}
303304
}
@@ -307,7 +308,7 @@ export async function cleanArchivedSpaces (workspaceId: WorkspaceUuid, transacto
307308
})) as unknown as CoreClient & BackupClient
308309
try {
309310
const count = 0
310-
const ops = new TxOperations(connection, core.account.System)
311+
const ops = new TxOperations(connection, core.account.System, workspaceId)
311312
while (true) {
312313
const spaces = await connection.findAll(core.class.Space, { archived: true }, { limit: 1000 })
313314
if (spaces.length === 0) {
@@ -475,7 +476,7 @@ export async function fixSkills (
475476
// fix skills with + and -
476477
if (step === '3') {
477478
console.log('STEP 3')
478-
const ops = new TxOperations(connection, core.account.System)
479+
const ops = new TxOperations(connection, core.account.System, workspaceId)
479480
const regex = /\S+(?:[-+]\S+)+/g
480481
const tagsToClean = (await connection.findAll(tags.class.TagElement, {
481482
category: {
@@ -532,7 +533,7 @@ export async function fixSkills (
532533
}
533534
})) as TagElement[]
534535
goodTags = goodTags.sort((a, b) => b.title.length - a.title.length).filter((t) => t.title.length > 2)
535-
const ops = new TxOperations(connection, core.account.System)
536+
const ops = new TxOperations(connection, core.account.System, workspaceId)
536537
const tagsToClean = (await connection.findAll(tags.class.TagElement, {
537538
category: {
538539
$in: ['recruit:category:Other', 'document:category:Other', 'tracker:category:Other'] as Ref<TagCategory>[]
@@ -669,8 +670,7 @@ export async function restoreRecruitingTaskTypes (
669670
transactorUrl: string
670671
): Promise<void> {
671672
const connection = (await connect(transactorUrl, workspaceId, undefined, {
672-
mode: 'backup',
673-
model: 'upgrade'
673+
mode: 'backup'
674674
})) as unknown as CoreClient & BackupClient
675675
const client = getMongoClient(mongoUrl)
676676
try {
@@ -772,6 +772,7 @@ export async function restoreRecruitingTaskTypes (
772772
statusCategories.sort(compareCategories)
773773

774774
const createTxNew: TxCreateDoc<TaskType> = {
775+
_uuid: workspaceId,
775776
_id: generateId(),
776777
_class: core.class.TxCreateDoc,
777778
space: core.space.Tx,
@@ -822,7 +823,9 @@ export async function restoreRecruitingTaskTypes (
822823
} catch (err: any) {
823824
console.trace(err)
824825
} finally {
826+
// TODO: Add force-close
825827
client.close()
828+
await connection.sendForceClose()
826829
await connection.close()
827830
}
828831
}
@@ -833,8 +836,7 @@ export async function restoreHrTaskTypesFromUpdates (
833836
transactorUrl: string
834837
): Promise<void> {
835838
const connection = (await connect(transactorUrl, workspaceId, undefined, {
836-
mode: 'backup',
837-
model: 'upgrade'
839+
mode: 'backup'
838840
})) as unknown as CoreClient & BackupClient
839841
const client = getMongoClient(mongoUrl)
840842
try {
@@ -927,6 +929,7 @@ export async function restoreHrTaskTypesFromUpdates (
927929
const ofClassClass = hierarchy.getClass(recruit.class.Applicant)
928930

929931
await db.collection<TxCreateDoc<Doc>>(DOMAIN_TX).insertOne({
932+
_uuid: workspaceId,
930933
_id: generateId(),
931934
_class: core.class.TxCreateDoc,
932935
space: core.space.Tx,
@@ -946,6 +949,7 @@ export async function restoreHrTaskTypesFromUpdates (
946949
})
947950

948951
createTaskTypeTx = {
952+
_uuid: workspaceId,
949953
_id: generateId(),
950954
_class: core.class.TxCreateDoc,
951955
space: core.space.Tx,
@@ -980,6 +984,7 @@ export async function restoreHrTaskTypesFromUpdates (
980984
const ofClassClass = hierarchy.getClass(recruit.class.Vacancy)
981985

982986
await db.collection<TxCreateDoc<Doc>>(DOMAIN_TX).insertOne({
987+
_uuid: workspaceId,
983988
_id: generateId(),
984989
_class: core.class.TxCreateDoc,
985990
space: core.space.Tx,
@@ -999,6 +1004,7 @@ export async function restoreHrTaskTypesFromUpdates (
9991004
})
10001005

10011006
const createProjectTypeTx: TxCreateDoc<ProjectType> = {
1007+
_uuid: workspaceId,
10021008
_id: generateId(),
10031009
_class: core.class.TxCreateDoc,
10041010
space: core.space.Tx,
@@ -1031,6 +1037,7 @@ export async function restoreHrTaskTypesFromUpdates (
10311037
console.trace(err)
10321038
} finally {
10331039
client.close()
1040+
await connection.sendForceClose()
10341041
await connection.close()
10351042
}
10361043
}

dev/tool/src/configuration.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ export async function changeConfiguration (
4141
}
4242
const enable = (cmd.enable ?? '').trim().split(',')
4343
console.log('enable', enable)
44-
const ops = new TxFactory(core.account.ConfigUser)
44+
const ops = new TxFactory(core.account.ConfigUser, workspaceId)
4545
if (enable.length > 0) {
4646
const p = config.filter((it) => enable.includes(it.pluginId) || enable.includes('*'))
4747
for (const pp of p) {

dev/tool/src/db.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ async function moveWorkspace (
9696
const token = generateToken(systemAccountUuid, wsId, { service: 'tool' })
9797
const endpoint = await getTransactorEndpoint(token, 'external')
9898
const connection = (await connect(endpoint, wsId, undefined, {
99-
model: 'upgrade'
99+
mode: 'backup'
100100
})) as unknown as Client & BackupClient
101101
for (const collection of collections) {
102102
const domain = translateDomain(collection.collectionName)

dev/tool/src/index.ts

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ import {
3636
} from '@hcengineering/server-backup'
3737
import serverClientPlugin, { getAccountClient } from '@hcengineering/server-client'
3838
import {
39+
createBackupPipeline,
3940
registerAdapterFactory,
4041
registerDestroyFactory,
4142
registerServerPlugins,
@@ -84,8 +85,12 @@ import {
8485
shutdownPostgres
8586
} from '@hcengineering/postgres'
8687
import {
88+
createDummyStorageAdapter,
8789
QueueTopic,
8890
workspaceEvents,
91+
wrapPipeline,
92+
type Pipeline,
93+
type PipelineFactory,
8994
type QueueWorkspaceMessage,
9095
type StorageAdapter
9196
} from '@hcengineering/server-core'
@@ -1155,6 +1160,16 @@ export function devTool (
11551160

11561161
const workspaceStorage: StorageAdapter | undefined =
11571162
storageConfig !== undefined ? buildStorageFromConfig(storageConfig) : undefined
1163+
1164+
const { dbUrl, txes } = prepareTools()
1165+
1166+
const pipelineFactory: PipelineFactory = createBackupPipeline(toolCtx, dbUrl, txes, {
1167+
externalStorage: workspaceStorage ?? createDummyStorageAdapter(),
1168+
usePassedCtx: true
1169+
})
1170+
1171+
let pipeline: Pipeline | undefined
1172+
11581173
await restore(toolCtx, await getWorkspaceTransactorEndpoint(workspace), wsIds, storage, {
11591174
date: parseInt(date ?? '-1'),
11601175
merge: cmd.merge,
@@ -1163,7 +1178,13 @@ export function devTool (
11631178
include: cmd.include === '*' ? undefined : new Set(cmd.include.split(';')),
11641179
skip: new Set(cmd.skip.split(';')),
11651180
storageAdapter: workspaceStorage,
1166-
historyFile: cmd.historyFile
1181+
historyFile: cmd.historyFile,
1182+
getConnection: async () => {
1183+
if (pipeline === undefined) {
1184+
pipeline = await pipelineFactory(toolCtx, wsIds, () => {}, null, null)
1185+
}
1186+
return wrapPipeline(toolCtx, pipeline, wsIds)
1187+
}
11671188
})
11681189
const queue = getPlatformQueue('tool', ws.region)
11691190
const wsProducer = queue.getProducer<QueueWorkspaceMessage>(toolCtx, QueueTopic.Workspace)

models/board/src/migration.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
//
1515

1616
import { boardId, type Card } from '@hcengineering/board'
17-
import { TxOperations } from '@hcengineering/core'
17+
import { type TxOperations } from '@hcengineering/core'
1818
import {
1919
createOrUpdate,
2020
tryMigrate,
@@ -96,8 +96,7 @@ export const boardOperation: MigrateOperation = {
9696
{
9797
state: 'board0001',
9898
func: async (client) => {
99-
const ops = new TxOperations(client, core.account.System)
100-
await createDefaults(ops)
99+
await createDefaults(client)
101100
}
102101
}
103102
])

0 commit comments

Comments
 (0)