Skip to content

Commit 591db55

Browse files
committed
UBERF-9747
Signed-off-by: Andrey Sobolev <[email protected]>
1 parent 4bf8176 commit 591db55

File tree

192 files changed

+5248
-2598
lines changed

Some content is hidden

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

192 files changed

+5248
-2598
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": "3335",
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/docker-compose.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -302,6 +302,7 @@ services:
302302
environment:
303303
- QUEUE_CONFIG=${QUEUE_CONFIG}
304304
- REGION=
305+
- ENDPOINT=ws://huly.local:3333
305306
- SERVER_PORT=3333
306307
- SERVER_SECRET=secret
307308
- ENABLE_COMPRESSION=true
@@ -338,6 +339,7 @@ services:
338339
- QUEUE_CONFIG=${QUEUE_CONFIG}
339340
- SERVER_PORT=3332
340341
- REGION=cockroach
342+
- ENDPOINT=ws://huly.local:3332
341343
- SERVER_SECRET=secret
342344
- ENABLE_COMPRESSION=true
343345
- FULLTEXT_URL=http://huly.local:4702

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
@@ -67,7 +67,7 @@ import { uploaderId } from '@hcengineering/uploader'
6767
import { mediaId } from '@hcengineering/media'
6868
import recorder, { recorderId } from '@hcengineering/recorder'
6969
import { viewId } from '@hcengineering/view'
70-
import workbench, { workbenchId } from '@hcengineering/workbench'
70+
import workbench, { workbenchId, workbenchAppsId } from '@hcengineering/workbench'
7171
import { mailId } from '@hcengineering/mail'
7272
import { chatId } from '@hcengineering/chat'
7373
import github, { githubId } from '@hcengineering/github'
@@ -147,6 +147,7 @@ import { preferenceId } from '@hcengineering/preference'
147147
import { uiId } from '@hcengineering/ui/src/plugin'
148148
import { configureAnalytics } from './analytics'
149149

150+
150151
export interface Config {
151152
ACCOUNTS_URL: string
152153
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
@@ -403,7 +403,7 @@ export function benchmarkWorker (): void {
403403

404404
if (msg.options.mode === 'find-all') {
405405
const benchmarkPersonId = (core.account.System + '_benchmark') as PersonId
406-
const opt = new TxOperations(connection, benchmarkPersonId)
406+
const opt = new TxOperations(connection, benchmarkPersonId, msg.workspaceId)
407407
parentPort?.postMessage({
408408
type: 'operate',
409409
workId: msg.workId
@@ -544,7 +544,7 @@ export async function stressBenchmark (transactor: string, mode: StressBenchmark
544544
export async function testFindAll (endpoint: string, workspace: WorkspaceUuid, account: PersonUuid): Promise<void> {
545545
const connection = await connect(endpoint, workspace, account)
546546
try {
547-
const client = new TxOperations(connection, core.account.System)
547+
const client = new TxOperations(connection, core.account.System, workspace)
548548
const start = platformNow()
549549
const res = await client.findAll(
550550
recruit.class.Applicant,
@@ -569,7 +569,7 @@ export async function generateWorkspaceData (
569569
email: string
570570
): Promise<void> {
571571
const connection = await connect(endpoint, workspace)
572-
const client = new TxOperations(connection, core.account.System)
572+
const client = new TxOperations(connection, core.account.System, workspace)
573573
try {
574574
const emailSocialString = buildSocialIdString({ type: SocialIdType.EMAIL, value: email })
575575
const person = await getPersonBySocialKey(client, emailSocialString)

dev/tool/src/clean.ts

Lines changed: 25 additions & 17 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()
@@ -214,6 +214,7 @@ export async function cleanRemovedTransactions (workspaceId: WorkspaceUuid, tran
214214
objectId: { $in: removedDocs.map((it) => it.objectId) }
215215
})
216216
await connection.clean(
217+
workspaceId,
217218
DOMAIN_TX,
218219
toRemove.map((it) => it._id)
219220
)
@@ -232,8 +233,7 @@ export async function cleanRemovedTransactions (workspaceId: WorkspaceUuid, tran
232233

233234
export async function optimizeModel (workspaceId: WorkspaceUuid, transactorUrl: string): Promise<void> {
234235
const connection = (await connect(transactorUrl, workspaceId, undefined, {
235-
mode: 'backup',
236-
model: 'upgrade'
236+
mode: 'backup'
237237
})) as unknown as CoreClient & BackupClient
238238
try {
239239
let count = 0
@@ -289,7 +289,7 @@ export async function optimizeModel (workspaceId: WorkspaceUuid, transactorUrl:
289289
}
290290
}
291291

292-
await connection.clean(DOMAIN_TX, toRemove)
292+
await connection.clean(workspaceId, DOMAIN_TX, toRemove)
293293

294294
count += toRemove.length
295295
console.log('processed', count)
@@ -298,6 +298,8 @@ export async function optimizeModel (workspaceId: WorkspaceUuid, transactorUrl:
298298
} catch (err: any) {
299299
console.trace(err)
300300
} finally {
301+
// TODO: Add force-close
302+
await connection.sendForceClose(workspaceId)
301303
await connection.close()
302304
}
303305
}
@@ -307,7 +309,7 @@ export async function cleanArchivedSpaces (workspaceId: WorkspaceUuid, transacto
307309
})) as unknown as CoreClient & BackupClient
308310
try {
309311
const count = 0
310-
const ops = new TxOperations(connection, core.account.System)
312+
const ops = new TxOperations(connection, core.account.System, workspaceId)
311313
while (true) {
312314
const spaces = await connection.findAll(core.class.Space, { archived: true }, { limit: 1000 })
313315
if (spaces.length === 0) {
@@ -370,7 +372,7 @@ export async function fixCommentDoubleIdCreate (workspaceId: WorkspaceUuid, tran
370372
// We have found duplicate one, let's rename it.
371373
const doc = TxProcessor.createDoc2Doc<ChatMessage>(c as unknown as TxCreateDoc<ChatMessage>)
372374
if (doc.message !== '' && doc.message.trim() !== '<p></p>') {
373-
await connection.clean(DOMAIN_TX, [c._id])
375+
await connection.clean(workspaceId, DOMAIN_TX, [c._id])
374376
if (oldValue.get(cid) === doc.message.trim()) {
375377
console.log('delete tx', cid, doc.message)
376378
} else {
@@ -379,9 +381,9 @@ export async function fixCommentDoubleIdCreate (workspaceId: WorkspaceUuid, tran
379381
// Remove previous transaction.
380382
c.objectId = generateId()
381383
doc._id = c.objectId as Ref<ChatMessage>
382-
await connection.upload(DOMAIN_TX, [c])
384+
await connection.upload(workspaceId, DOMAIN_TX, [c])
383385
// Also we need to create snapsot
384-
await connection.upload(DOMAIN_ACTIVITY, [doc])
386+
await connection.upload(workspaceId, DOMAIN_ACTIVITY, [doc])
385387
}
386388
}
387389
}
@@ -475,7 +477,7 @@ export async function fixSkills (
475477
// fix skills with + and -
476478
if (step === '3') {
477479
console.log('STEP 3')
478-
const ops = new TxOperations(connection, core.account.System)
480+
const ops = new TxOperations(connection, core.account.System, workspaceId)
479481
const regex = /\S+(?:[-+]\S+)+/g
480482
const tagsToClean = (await connection.findAll(tags.class.TagElement, {
481483
category: {
@@ -532,7 +534,7 @@ export async function fixSkills (
532534
}
533535
})) as TagElement[]
534536
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)
537+
const ops = new TxOperations(connection, core.account.System, workspaceId)
536538
const tagsToClean = (await connection.findAll(tags.class.TagElement, {
537539
category: {
538540
$in: ['recruit:category:Other', 'document:category:Other', 'tracker:category:Other'] as Ref<TagCategory>[]
@@ -669,8 +671,7 @@ export async function restoreRecruitingTaskTypes (
669671
transactorUrl: string
670672
): Promise<void> {
671673
const connection = (await connect(transactorUrl, workspaceId, undefined, {
672-
mode: 'backup',
673-
model: 'upgrade'
674+
mode: 'backup'
674675
})) as unknown as CoreClient & BackupClient
675676
const client = getMongoClient(mongoUrl)
676677
try {
@@ -772,6 +773,7 @@ export async function restoreRecruitingTaskTypes (
772773
statusCategories.sort(compareCategories)
773774

774775
const createTxNew: TxCreateDoc<TaskType> = {
776+
_uuid: workspaceId,
775777
_id: generateId(),
776778
_class: core.class.TxCreateDoc,
777779
space: core.space.Tx,
@@ -822,7 +824,9 @@ export async function restoreRecruitingTaskTypes (
822824
} catch (err: any) {
823825
console.trace(err)
824826
} finally {
827+
// TODO: Add force-close
825828
client.close()
829+
await connection.sendForceClose(workspaceId)
826830
await connection.close()
827831
}
828832
}
@@ -833,8 +837,7 @@ export async function restoreHrTaskTypesFromUpdates (
833837
transactorUrl: string
834838
): Promise<void> {
835839
const connection = (await connect(transactorUrl, workspaceId, undefined, {
836-
mode: 'backup',
837-
model: 'upgrade'
840+
mode: 'backup'
838841
})) as unknown as CoreClient & BackupClient
839842
const client = getMongoClient(mongoUrl)
840843
try {
@@ -927,6 +930,7 @@ export async function restoreHrTaskTypesFromUpdates (
927930
const ofClassClass = hierarchy.getClass(recruit.class.Applicant)
928931

929932
await db.collection<TxCreateDoc<Doc>>(DOMAIN_TX).insertOne({
933+
_uuid: workspaceId,
930934
_id: generateId(),
931935
_class: core.class.TxCreateDoc,
932936
space: core.space.Tx,
@@ -946,6 +950,7 @@ export async function restoreHrTaskTypesFromUpdates (
946950
})
947951

948952
createTaskTypeTx = {
953+
_uuid: workspaceId,
949954
_id: generateId(),
950955
_class: core.class.TxCreateDoc,
951956
space: core.space.Tx,
@@ -980,6 +985,7 @@ export async function restoreHrTaskTypesFromUpdates (
980985
const ofClassClass = hierarchy.getClass(recruit.class.Vacancy)
981986

982987
await db.collection<TxCreateDoc<Doc>>(DOMAIN_TX).insertOne({
988+
_uuid: workspaceId,
983989
_id: generateId(),
984990
_class: core.class.TxCreateDoc,
985991
space: core.space.Tx,
@@ -999,6 +1005,7 @@ export async function restoreHrTaskTypesFromUpdates (
9991005
})
10001006

10011007
const createProjectTypeTx: TxCreateDoc<ProjectType> = {
1008+
_uuid: workspaceId,
10021009
_id: generateId(),
10031010
_class: core.class.TxCreateDoc,
10041011
space: core.space.Tx,
@@ -1031,6 +1038,7 @@ export async function restoreHrTaskTypesFromUpdates (
10311038
console.trace(err)
10321039
} finally {
10331040
client.close()
1041+
await connection.sendForceClose(workspaceId)
10341042
await connection.close()
10351043
}
10361044
}
@@ -1127,7 +1135,7 @@ export async function removeDuplicateIds (
11271135
// await updateId(ctx, wsClient, db, storageAdapter, wsDataId, doc)
11281136
// }
11291137
// }
1130-
// await wsClient.sendForceClose()
1138+
// await wsClient.sendForceClose(workspaceId)
11311139
// await wsClient.close()
11321140
// await db.collection<MigrationState>(DOMAIN_MIGRATION).insertOne({
11331141
// _id: generateId(),

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) {

0 commit comments

Comments
 (0)