Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion dev/doc-import-tool/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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 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 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",
Expand Down
2 changes: 1 addition & 1 deletion dev/tool/src/__start.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,4 +84,4 @@ function prepareTools (): {

console.log(`tools git_version: ${process.env.GIT_REVISION ?? ''} model_version: ${process.env.MODEL_VERSION ?? ''}`)

devTool(prepareTools, process.env.PRODUCT_ID ?? '')
devTool(prepareTools)
2 changes: 1 addition & 1 deletion dev/tool/src/benchmark.ts
Original file line number Diff line number Diff line change
Expand Up @@ -481,7 +481,7 @@ export async function stressBenchmark (transactor: string, mode: StressBenchmark
try {
counter++
console.log('Attempt', counter)
const token = generateToken(generateId(), { name: generateId(), productId: '' })
const token = generateToken(generateId(), { name: generateId() })
await rate.add(async () => {
try {
const ws = new WebSocket(concatLink(transactor, token))
Expand Down
7 changes: 3 additions & 4 deletions dev/tool/src/clean.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1056,7 +1056,6 @@ export async function removeDuplicateIds (
ctx: MeasureContext,
mongodbUri: string,
storageAdapter: StorageAdapter,
productId: string,
accountsUrl: string,
initWorkspacesStr: string
): Promise<void> {
Expand All @@ -1066,13 +1065,13 @@ export async function removeDuplicateIds (
// disable spaces while change hardocded ids
const skippedDomains: string[] = [DOMAIN_DOC_INDEX_STATE, DOMAIN_BENCHMARK, DOMAIN_TX, DOMAIN_SPACE]
try {
const workspaces = await listWorkspacesRaw(_client.db(ACCOUNT_DB), productId)
const workspaces = await listWorkspacesRaw(_client.db(ACCOUNT_DB))
workspaces.sort((a, b) => b.lastVisit - a.lastVisit)
const initWorkspaces = initWorkspacesStr.split(';')
const initWS = workspaces.filter((p) => initWorkspaces.includes(p.workspace))
const ids = new Map<string, RelatedDocument[]>()
for (const workspace of initWS) {
const workspaceId = getWorkspaceId(workspace.workspace, productId)
const workspaceId = getWorkspaceId(workspace.workspace)
const db = getWorkspaceDB(_client, workspaceId)

const txex = await db.collection(DOMAIN_TX).find<TxCUD<Doc>>({}).toArray()
Expand Down Expand Up @@ -1125,7 +1124,7 @@ export async function removeDuplicateIds (
if (initWorkspaces.includes(workspace.workspace)) continue

ctx.info(`Processing workspace ${workspace.workspaceName ?? workspace.workspace}`)
const workspaceId = getWorkspaceId(workspace.workspace, productId)
const workspaceId = getWorkspaceId(workspace.workspace)
const db = getWorkspaceDB(_client, workspaceId)
const check = await db.collection(DOMAIN_MIGRATION).findOne({ state, plugin: workspace.workspace })
if (check != null) continue
Expand Down
172 changes: 73 additions & 99 deletions dev/tool/src/index.ts

Large diffs are not rendered by default.

3 changes: 1 addition & 2 deletions dev/tool/src/openai.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,9 @@ import { connect } from '@hcengineering/server-tool'
export async function openAIConfig (
transactorUrl: string,
workspace: string,
productId: string,
opt: { endpoint: string, token: string, enabled: boolean, tokenLimit: number, embeddings: boolean }
): Promise<void> {
const connection = await connect(transactorUrl, getWorkspaceId(workspace, productId), '#configurator@hc.engineering')
const connection = await connect(transactorUrl, getWorkspaceId(workspace), '#configurator@hc.engineering')
try {
const ops = new TxOperations(connection, core.account.System)

Expand Down
13 changes: 5 additions & 8 deletions dev/tool/src/renameAccount.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import { type Db } from 'mongodb'
export async function renameAccount (
ctx: MeasureContext,
db: Db,
productId: string,
accountsUrl: string,
oldEmail: string,
newEmail: string
Expand All @@ -26,13 +25,12 @@ export async function renameAccount (

await changeEmail(ctx, db, account, newEmail)

await fixWorkspaceEmails(account, db, productId, accountsUrl, oldEmail, newEmail)
await fixWorkspaceEmails(account, db, accountsUrl, oldEmail, newEmail)
}

export async function fixAccountEmails (
ctx: MeasureContext,
db: Db,
productId: string,
transactorUrl: string,
oldEmail: string,
newEmail: string
Expand All @@ -42,26 +40,25 @@ export async function fixAccountEmails (
throw new Error("Account does'n exists")
}

await fixWorkspaceEmails(account, db, productId, transactorUrl, oldEmail, newEmail)
await fixWorkspaceEmails(account, db, transactorUrl, oldEmail, newEmail)
}
async function fixWorkspaceEmails (
account: Account,
db: Db,
productId: string,
accountsUrl: string,
oldEmail: string,
newEmail: string
): Promise<void> {
const accountWorkspaces = account.workspaces.map((it) => it.toString())
// We need to update all workspaces
const workspaces = await listWorkspacesPure(db, productId)
const workspaces = await listWorkspacesPure(db)
for (const ws of workspaces) {
if (!accountWorkspaces.includes(ws._id.toString())) {
continue
}
console.log('checking workspace', ws.workspaceName, ws.workspace)

const wsid = getWorkspaceId(ws.workspace, productId)
const wsid = getWorkspaceId(ws.workspace)
const endpoint = await getTransactorEndpoint(generateToken(systemAccountEmail, wsid))

// Let's connect and update account information.
Expand All @@ -75,7 +72,7 @@ async function fixEmailInWorkspace (
oldEmail: string,
newEmail: string
): Promise<void> {
const connection = await connect(transactorUrl, { name: ws.workspace, productId: ws.productId }, undefined, {
const connection = await connect(transactorUrl, { name: ws.workspace }, undefined, {
mode: 'backup',
model: 'upgrade', // Required for force all clients reload after operation will be complete.
admin: 'true'
Expand Down
1 change: 0 additions & 1 deletion packages/core/src/classes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -654,7 +654,6 @@ export interface DomainIndexConfiguration extends Doc {

export interface BaseWorkspaceInfo {
workspace: string // An uniq workspace name, Database names
productId: string
disabled?: boolean
version?: Data<Version>
branding?: string
Expand Down
3 changes: 1 addition & 2 deletions packages/core/src/component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -162,8 +162,7 @@ export default plugin(coreId, {
},
status: {
ObjectNotFound: '' as StatusCode<{ _id: Ref<Doc> }>,
ItemNotFound: '' as StatusCode<{ _id: Ref<Doc>, _localId: string }>,
InvalidProduct: '' as StatusCode<{ productId: string }>
ItemNotFound: '' as StatusCode<{ _id: Ref<Doc>, _localId: string }>
},
version: {
Model: '' as Ref<Version>
Expand Down
13 changes: 6 additions & 7 deletions packages/core/src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,6 @@ export function toFindResult<T extends Doc> (docs: T[], total?: number, lookupMa
*/
export interface WorkspaceId {
name: string
productId: string
}

/**
Expand All @@ -136,20 +135,20 @@ export interface WorkspaceIdWithUrl extends WorkspaceId {
/**
* @public
*
* Combine workspace with productId, if not equal ''
* Previously was combining workspace with productId, if not equal ''
* Now just returning workspace as is. Keeping it to simplify further refactoring of ws id.
*/
export function getWorkspaceId (workspace: string, productId: string = ''): WorkspaceId {
export function getWorkspaceId (workspace: string): WorkspaceId {
return {
name: workspace,
productId
name: workspace
}
}

/**
* @public
*/
export function toWorkspaceString (id: WorkspaceId, sep = '@'): string {
return id.name + (id.productId === '' ? '' : sep + id.productId)
export function toWorkspaceString (id: WorkspaceId): string {
return id.name
}

const attributesPrefix = 'attributes.'
Expand Down
1 change: 0 additions & 1 deletion packages/platform/lang/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
"WorkspaceRateLimit": "Server is busy, Please wait a bit and try again",
"AccountAlreadyConfirmed": "Account already confirmed",
"WorkspaceAlreadyExists": "Workspace already exists",
"ProductIdMismatch": "Product Mismatch",
"InvalidOtp": "Invalid code"
}
}
1 change: 0 additions & 1 deletion packages/platform/lang/es.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
"WorkspaceRateLimit": "El servidor está ocupado. Espere un momento e inténtelo de nuevo",
"AccountAlreadyConfirmed": "La cuenta ya está confirmada",
"WorkspaceAlreadyExists": "El espacio de trabajo ya existe",
"ProductIdMismatch": "Desajuste de producto",
"InvalidOtp": "Código no válido"
}
}
1 change: 0 additions & 1 deletion packages/platform/lang/fr.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
"WorkspaceRateLimit": "Le serveur est occupé, veuillez patienter un moment et réessayer",
"AccountAlreadyConfirmed": "Compte déjà confirmé",
"WorkspaceAlreadyExists": "L'espace de travail existe déjà",
"ProductIdMismatch": "Incompatibilité de produit",
"InvalidOtp": "Code invalide"
}
}
1 change: 0 additions & 1 deletion packages/platform/lang/pt.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
"WorkspaceRateLimit": "O servidor está ocupado. Por favor, espere um pouco e tente novamente",
"AccountAlreadyConfirmed": "Conta já confirmada",
"WorkspaceAlreadyExists": "Espaço de trabalho já existe",
"ProductIdMismatch": "Discrepância de produto",
"InvalidOtp": "Código inválido"
}
}
1 change: 0 additions & 1 deletion packages/platform/lang/ru.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
"WorkspaceRateLimit": "Сервер перегружен, пожалуйста, подождите",
"AccountAlreadyConfirmed": "Аккаунт уже подтвержден",
"WorkspaceAlreadyExists": "Рабочее пространство уже существует",
"ProductIdMismatch": "Продукт не соответствует",
"InvalidOtp": "Неверный код"
}
}
1 change: 0 additions & 1 deletion packages/platform/lang/zh.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
"WorkspaceRateLimit": "服务器繁忙,请稍后再试",
"AccountAlreadyConfirmed": "账户已确认",
"WorkspaceAlreadyExists": "工作区已存在",
"ProductIdMismatch": "产品不匹配",
"InvalidOtp": "无效的代码"
}
}
1 change: 0 additions & 1 deletion packages/platform/src/platform.ts
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,6 @@ export default plugin(platformId, {
AccountAlreadyConfirmed: '' as StatusCode<{ account: string }>,
WorkspaceAlreadyExists: '' as StatusCode<{ workspace: string }>,
WorkspaceRateLimit: '' as StatusCode<{ workspace: string }>,
ProductIdMismatch: '' as StatusCode<{ productId: string }>,
InvalidOtp: '' as StatusCode
},
metadata: {
Expand Down
4 changes: 2 additions & 2 deletions packages/storage/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ export interface StorageAdapter {
make: (ctx: MeasureContext, workspaceId: WorkspaceId) => Promise<void>
delete: (ctx: MeasureContext, workspaceId: WorkspaceId) => Promise<void>

listBuckets: (ctx: MeasureContext, productId: string) => Promise<BucketInfo[]>
listBuckets: (ctx: MeasureContext) => Promise<BucketInfo[]>
remove: (ctx: MeasureContext, workspaceId: WorkspaceId, objectNames: string[]) => Promise<void>
listStream: (ctx: MeasureContext, workspaceId: WorkspaceId, prefix?: string) => Promise<BlobStorageIterator>
stat: (ctx: MeasureContext, workspaceId: WorkspaceId, objectName: string) => Promise<Blob | undefined>
Expand Down Expand Up @@ -104,7 +104,7 @@ export class DummyStorageAdapter implements StorageAdapter, StorageAdapterEx {
}
}

async listBuckets (ctx: MeasureContext, productId: string): Promise<BucketInfo[]> {
async listBuckets (ctx: MeasureContext): Promise<BucketInfo[]> {
return []
}

Expand Down
2 changes: 1 addition & 1 deletion pods/account/src/__start.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,6 @@ const intTimer = setInterval(() => {

const brandingPath = process.env.BRANDING_PATH

serveAccount(metricsContext, getModelVersion(), txes, migrateOperations, '', loadBrandingMap(brandingPath), () => {
serveAccount(metricsContext, getModelVersion(), txes, migrateOperations, loadBrandingMap(brandingPath), () => {
clearInterval(intTimer)
})
19 changes: 4 additions & 15 deletions pods/authProviders/src/github.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ export function registerGithub (
router: Router<any, any>,
accountsUrl: string,
db: Db,
productId: string,
frontUrl: string,
brandings: BrandingMap
): string | undefined {
Expand Down Expand Up @@ -71,21 +70,11 @@ export function registerGithub (
const state = safeParseAuthState(ctx.query?.state)
const branding = getBranding(brandings, state?.branding)
if (state.inviteId != null && state.inviteId !== '') {
loginInfo = await joinWithProvider(
measureCtx,
db,
productId,
null,
email,
first,
last,
state.inviteId as any,
{
githubId: ctx.state.user.id
}
)
loginInfo = await joinWithProvider(measureCtx, db, null, email, first, last, state.inviteId as any, {
githubId: ctx.state.user.id
})
} else {
loginInfo = await loginWithProvider(measureCtx, db, productId, null, email, first, last, {
loginInfo = await loginWithProvider(measureCtx, db, null, email, first, last, {
githubId: ctx.state.user.id
})
}
Expand Down
14 changes: 2 additions & 12 deletions pods/authProviders/src/google.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ export function registerGoogle (
router: Router<any, any>,
accountsUrl: string,
db: Db,
productId: string,
frontUrl: string,
brandings: BrandingMap
): string | undefined {
Expand Down Expand Up @@ -76,18 +75,9 @@ export function registerGoogle (
const state = safeParseAuthState(ctx.query?.state)
const branding = getBranding(brandings, state?.branding)
if (state.inviteId != null && state.inviteId !== '') {
loginInfo = await joinWithProvider(
measureCtx,
db,
productId,
null,
email,
first,
last,
state.inviteId as any
)
loginInfo = await joinWithProvider(measureCtx, db, null, email, first, last, state.inviteId as any)
} else {
loginInfo = await loginWithProvider(measureCtx, db, productId, null, email, first, last)
loginInfo = await loginWithProvider(measureCtx, db, null, email, first, last)
}

const origin = concatLink(branding?.front ?? frontUrl, '/login/auth')
Expand Down
6 changes: 2 additions & 4 deletions pods/authProviders/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ export type AuthProvider = (
router: Router<any, any>,
accountsUrl: string,
db: Db,
productId: string,
frontUrl: string,
brandings: BrandingMap
) => string | undefined
Expand All @@ -26,7 +25,6 @@ export function registerProviders (
app: Koa<Koa.DefaultState, Koa.DefaultContext>,
router: Router<any, any>,
db: Db,
productId: string,
serverSecret: string,
frontUrl: string | undefined,
brandings: BrandingMap
Expand Down Expand Up @@ -59,12 +57,12 @@ export function registerProviders (
})
})

registerToken(ctx, passport, router, accountsUrl, db, productId, frontUrl, brandings)
registerToken(ctx, passport, router, accountsUrl, db, frontUrl, brandings)

const res: string[] = []
const providers: AuthProvider[] = [registerGoogle, registerGithub]
for (const provider of providers) {
const value = provider(ctx, passport, router, accountsUrl, db, productId, frontUrl, brandings)
const value = provider(ctx, passport, router, accountsUrl, db, frontUrl, brandings)
if (value !== undefined) res.push(value)
}

Expand Down
3 changes: 1 addition & 2 deletions pods/authProviders/src/token.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ export function registerToken (
router: Router<any, any>,
accountsUrl: string,
db: Db,
productId: string,
frontUrl: string,
brandings: BrandingMap
): string | undefined {
Expand All @@ -22,7 +21,7 @@ export function registerToken (
new CustomStrategy(function (req: any, done: any) {
const token = req.body.token ?? req.query.token

getAccountInfoByToken(measureCtx, db, productId, null, token)
getAccountInfoByToken(measureCtx, db, null, token)
.then((user: any) => done(null, user))
.catch((err: any) => done(err))
})
Expand Down
1 change: 0 additions & 1 deletion pods/server/src/__start.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,6 @@ const shutdown = start(config.url, {
serverFactory,
indexParallel: 2,
indexProcessing: 500,
productId: '',
brandingMap: loadBrandingMap(config.brandingPath),
accountsUrl: config.accountsUrl,
enableCompression: config.enableCompression
Expand Down
Loading