Skip to content

Commit

Permalink
uberf-8425: fix some lint issues
Browse files Browse the repository at this point in the history
Signed-off-by: Alexey Zinoviev <[email protected]>
  • Loading branch information
lexiv0re committed Dec 28, 2024
1 parent 54bb493 commit 2101f98
Show file tree
Hide file tree
Showing 81 changed files with 581 additions and 432 deletions.
40 changes: 27 additions & 13 deletions dev/tool/src/benchmark.ts
Original file line number Diff line number Diff line change
Expand Up @@ -374,7 +374,7 @@ export function benchmarkWorker (): void {
connection = await connect(msg.transactorUrl, msg.workspaceId, msg.email)

if (msg.options.mode === 'find-all') {
const benchmarkPersonId: PersonId = (core.account.System + '_benchmark')
const benchmarkPersonId: PersonId = core.account.System + '_benchmark'
const opt = new TxOperations(connection, benchmarkPersonId)
parentPort?.postMessage({
type: 'operate',
Expand Down Expand Up @@ -584,12 +584,19 @@ export async function generateEmployee (client: TxOperations): Promise<PersonId>

const socialString = buildSocialIdString({ type: SocialIdType.HULY, value: personUuid })

await client.addCollection(contact.class.SocialIdentity, contact.space.Contacts, personId, contact.class.Person, 'socialIds', {
type: SocialIdType.HULY,
value: personUuid,
key: socialString,
confirmed: true
})
await client.addCollection(
contact.class.SocialIdentity,
contact.space.Contacts,
personId,
contact.class.Person,
'socialIds',
{
type: SocialIdType.HULY,
value: personUuid,
key: socialString,
confirmed: true
}
)

return socialString
}
Expand Down Expand Up @@ -623,12 +630,19 @@ async function generateVacancy (client: TxOperations, members: PersonId[]): Prom
personUuid
})
const socialString = buildSocialIdString({ type: SocialIdType.HULY, value: personUuid })
await client.addCollection(contact.class.SocialIdentity, contact.space.Contacts, personId, contact.class.Person, 'socialIds', {
type: SocialIdType.HULY,
value: personUuid,
key: socialString,
confirmed: true
})
await client.addCollection(
contact.class.SocialIdentity,
contact.space.Contacts,
personId,
contact.class.Person,
'socialIds',
{
type: SocialIdType.HULY,
value: personUuid,
key: socialString,
confirmed: true
}
)
await client.createMixin(personId, contact.class.Person, contact.space.Contacts, recruit.mixin.Candidate, {})
// generate applicants
await client.addCollection(recruit.class.Applicant, _id, personId, recruit.mixin.Candidate, 'applications', {
Expand Down
2 changes: 1 addition & 1 deletion dev/tool/src/clean.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.
//

/* eslint-disable @typescript-eslint/no-unused-vars */
import { getAccountDB } from '@hcengineering/account'
import calendar from '@hcengineering/calendar'
import chunter, { type ChatMessage } from '@hcengineering/chunter'
Expand Down
11 changes: 3 additions & 8 deletions dev/tool/src/db.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
import {
type AccountDB,
type Workspace,
getAccount,
getWorkspaceById
} from '@hcengineering/account'
/* eslint-disable @typescript-eslint/no-unused-vars */
import { type AccountDB, type Workspace, getAccount, getWorkspaceById } from '@hcengineering/account'
import {
systemAccountUuid,
type BackupClient,
Expand Down Expand Up @@ -89,8 +85,7 @@ async function moveWorkspace (
continue
}
const cursor = collection.find()
const current =
await pgClient`SELECT _id FROM ${pgClient(domain)} WHERE "workspaceId" = ${ws.uuid}`
const current = await pgClient`SELECT _id FROM ${pgClient(domain)} WHERE "workspaceId" = ${ws.uuid}`
const currentIds = new Set(current.map((r) => r._id))
console.log('move domain', domain)
const docs: Doc[] = []
Expand Down
67 changes: 36 additions & 31 deletions dev/tool/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.
//
/* eslint-disable @typescript-eslint/no-unused-vars */
import accountPlugin, {
assignWorkspace,
confirmEmail,
Expand Down Expand Up @@ -348,39 +349,43 @@ export function devTool (
.option('-i, --init <ws>', 'Init from workspace')
.option('-r, --region <region>', 'Region')
.option('-b, --branding <key>', 'Branding key')
.action(
async (
name,
cmd: { account: string, init?: string, branding?: string, region?: string }
) => {
const { txes, version, migrateOperations } = prepareTools()
await withAccountDatabase(async (db) => {
const measureCtx = new MeasureMetricsContext('create-workspace', {})
const brandingObj =
cmd.branding !== undefined || cmd.init !== undefined ? { key: cmd.branding, initWorkspace: cmd.init } : null
const res = await createWorkspaceRecord(
measureCtx,
db,
brandingObj,
name,
cmd.account,
cmd.region,
'manual-creation'
)
const wsInfo = await getWorkspaceInfoWithStatusById(db, res.workspaceUuid)

if (wsInfo == null) {
throw new Error(`Created workspace record ${res.workspaceUuid} not found`)
}
const coreWsInfo = flattenStatus(wsInfo)
.action(async (name, cmd: { account: string, init?: string, branding?: string, region?: string }) => {
const { txes, version, migrateOperations } = prepareTools()
await withAccountDatabase(async (db) => {
const measureCtx = new MeasureMetricsContext('create-workspace', {})
const brandingObj =
cmd.branding !== undefined || cmd.init !== undefined ? { key: cmd.branding, initWorkspace: cmd.init } : null
const res = await createWorkspaceRecord(
measureCtx,
db,
brandingObj,
name,
cmd.account,
cmd.region,
'manual-creation'
)
const wsInfo = await getWorkspaceInfoWithStatusById(db, res.workspaceUuid)

await createWorkspace(measureCtx, version, brandingObj, coreWsInfo, txes, migrateOperations, undefined, true)
await updateWorkspaceInfo(measureCtx, db, brandingObj, getToolToken(), res.workspaceUuid, 'create-done', version, 100)
if (wsInfo == null) {
throw new Error(`Created workspace record ${res.workspaceUuid} not found`)
}
const coreWsInfo = flattenStatus(wsInfo)

console.log('create-workspace done')
})
}
)
await createWorkspace(measureCtx, version, brandingObj, coreWsInfo, txes, migrateOperations, undefined, true)
await updateWorkspaceInfo(
measureCtx,
db,
brandingObj,
getToolToken(),
res.workspaceUuid,
'create-done',
version,
100
)

console.log('create-workspace done')
})
})

program
.command('set-user-role <email> <workspace> <role>')
Expand Down
5 changes: 4 additions & 1 deletion dev/tool/src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,9 @@ export function getToolToken (workspace?: string): string {
return generateToken(systemAccountUuid, workspace, { service: 'tool' })
}

export async function getWorkspaceTransactorEndpoint (workspace: WorkspaceUuid, type: 'external' | 'internal' = 'external'): Promise<string> {
export async function getWorkspaceTransactorEndpoint (
workspace: WorkspaceUuid,
type: 'external' | 'internal' = 'external'
): Promise<string> {
return await getTransactorEndpoint(getToolToken(workspace), type)
}
14 changes: 11 additions & 3 deletions models/activity/src/migration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,15 @@

import { type ActivityMessage, type DocUpdateMessage, type Reaction } from '@hcengineering/activity'
import contact from '@hcengineering/contact'
import core, { type Class, type Doc, type Domain, groupByArray, MeasureMetricsContext, type Ref, type Space } from '@hcengineering/core'
import core, {
type Class,
type Doc,
type Domain,
groupByArray,
MeasureMetricsContext,
type Ref,
type Space
} from '@hcengineering/core'
import {
type MigrateOperation,
type MigrateUpdate,
Expand Down Expand Up @@ -187,7 +195,7 @@ async function migrateAccountsToSocialIds (client: MigrationClient): Promise<voi
const ctx = new MeasureMetricsContext('activity migrateAccountsToSocialIds', {})
const socialIdByAccount = await getSocialIdByOldAccount(client)

ctx.info('processing activity reactions ', { })
ctx.info('processing activity reactions ', {})
const iterator = await client.traverse(DOMAIN_ACTIVITY, { _class: activity.class.Reaction })

try {
Expand Down Expand Up @@ -224,7 +232,7 @@ async function migrateAccountsToSocialIds (client: MigrationClient): Promise<voi
} finally {
await iterator.close()
}
ctx.info('finished processing activity reactions ', { })
ctx.info('finished processing activity reactions ', {})
}

export const activityOperation: MigrateOperation = {
Expand Down
4 changes: 1 addition & 3 deletions models/ai-bot/src/migration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,7 @@ import { aiBotId } from '@hcengineering/ai-bot'

export const aiBotOperation: MigrateOperation = {
async migrate (client: MigrationClient): Promise<void> {
await tryMigrate(client, aiBotId, [

])
await tryMigrate(client, aiBotId, [])
},
async upgrade (state: Map<string, Set<string>>, client: () => Promise<MigrationUpgradeClient>): Promise<void> {}
}
4 changes: 2 additions & 2 deletions models/analytics-collector/src/migration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ async function removeOnboardingChannels (client: MigrationClient): Promise<void>
async function migrateAccountsToSocialIds (client: MigrationClient): Promise<void> {
const ctx = new MeasureMetricsContext('analytics collector migrateAccountsToSocialIds', {})

ctx.info('processing analytics collector onboarding channels ', { })
ctx.info('processing analytics collector onboarding channels ', {})
const iterator = await client.traverse(DOMAIN_SPACE, { _class: analyticsCollector.class.OnboardingChannel })

try {
Expand Down Expand Up @@ -83,7 +83,7 @@ async function migrateAccountsToSocialIds (client: MigrationClient): Promise<voi
} finally {
await iterator.close()
}
ctx.info('finished processing analytics collector onboarding channels ', { })
ctx.info('finished processing analytics collector onboarding channels ', {})
}

export const analyticsCollectorOperation: MigrateOperation = {
Expand Down
7 changes: 6 additions & 1 deletion models/chunter/src/migration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,12 @@ import {
} from '@hcengineering/model'
import activity, { migrateMessagesSpace, DOMAIN_ACTIVITY } from '@hcengineering/model-activity'
import notification from '@hcengineering/notification'
import { getAllEmployeesPrimarySocialStrings, pickPrimarySocialId, getSocialStringsByEmployee, includesAny, type Person } from '@hcengineering/contact'
import {
getAllEmployeesPrimarySocialStrings,
pickPrimarySocialId,
getSocialStringsByEmployee,
includesAny
} from '@hcengineering/contact'
import { DOMAIN_DOC_NOTIFY, DOMAIN_NOTIFICATION } from '@hcengineering/model-notification'
import { type DocUpdateMessage } from '@hcengineering/activity'

Expand Down
4 changes: 3 additions & 1 deletion models/contact/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,9 @@ export class TContact extends TDoc implements Contact {
@Prop(CollectionType(contact.class.Channel), contact.string.ContactInfo)
channels?: number

@Prop(CollectionType(attachment.class.Attachment), attachment.string.Attachments, { shortLabel: attachment.string.Files })
@Prop(CollectionType(attachment.class.Attachment), attachment.string.Attachments, {
shortLabel: attachment.string.Files
})
attachments?: number

@Prop(CollectionType(chunter.class.ChatMessage), chunter.string.Comments)
Expand Down
6 changes: 4 additions & 2 deletions models/contact/src/migration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -87,9 +87,11 @@ async function migrateAvatars (client: MigrationClient): Promise<void> {

async function createSocialIdentities (client: MigrationClient): Promise<void> {
const ctx = new MeasureMetricsContext('createSocialIdentities', {})
ctx.info('processing person accounts ', { })
ctx.info('processing person accounts ', {})

const personAccountsTxes: any[] = await client.find<TxCUD<Doc>>(DOMAIN_MODEL_TX, { objectClass: 'contact:class:PersonAccount' as Ref<Class<Doc>> })
const personAccountsTxes: any[] = await client.find<TxCUD<Doc>>(DOMAIN_MODEL_TX, {
objectClass: 'contact:class:PersonAccount' as Ref<Class<Doc>>
})
const personAccounts = getAccountsFromTxes(personAccountsTxes)

for (const pAcc of personAccounts) {
Expand Down
1 change: 0 additions & 1 deletion models/controlled-documents/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,6 @@ import {
TypeNumber,
TypeRef,
TypeString,
TypePersonId,
UX,
TypeCollaborativeDoc,
TypeMarkup,
Expand Down
10 changes: 1 addition & 9 deletions models/core/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,15 +71,7 @@ import {
TVersion
} from './core'
import { definePermissions } from './permissions'
import {
TPermission,
TRole,
TSpace,
TSpaceType,
TSpaceTypeDescriptor,
TSystemSpace,
TTypedSpace
} from './security'
import { TPermission, TRole, TSpace, TSpaceType, TSpaceTypeDescriptor, TSystemSpace, TTypedSpace } from './security'
import { defineSpaceType } from './spaceType'
import { TDomainStatusPlaceholder, TStatus, TStatusCategory } from './status'
import { TUserStatus } from './transient'
Expand Down
12 changes: 8 additions & 4 deletions models/core/src/migration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -303,12 +303,16 @@ export function getAccountsFromTxes (accTxes: TxCUD<Doc>[]): any {
return acc
}, {})

return Object.values(byAccounts).map((txes) => TxProcessor.buildDoc2Doc(txes)).filter((it) => it !== undefined)
return Object.values(byAccounts)
.map((txes) => TxProcessor.buildDoc2Doc(txes))
.filter((it) => it !== undefined)
}

export async function getSocialIdByOldAccount (client: MigrationClient): Promise<Record<string, PersonId>> {
const systemAccounts = [core.account.System, core.account.ConfigUser]
const accountsTxes: TxCUD<Doc>[] = await client.find<TxCUD<Doc>>(DOMAIN_MODEL_TX, { objectClass: { $in: ['core:class:Account', 'contact:class:PersonAccount'] as Ref<Class<Doc>>[] } })
const accountsTxes: TxCUD<Doc>[] = await client.find<TxCUD<Doc>>(DOMAIN_MODEL_TX, {
objectClass: { $in: ['core:class:Account', 'contact:class:PersonAccount'] as Ref<Class<Doc>>[] }
})
const accounts = getAccountsFromTxes(accountsTxes)

const socialIdByAccount: Record<string, PersonId> = {}
Expand Down Expand Up @@ -391,7 +395,7 @@ async function migrateAccountsToSocialIds (client: MigrationClient): Promise<voi
}
}

ctx.info('processing spaces members, owners and roles assignment', { })
ctx.info('processing spaces members, owners and roles assignment', {})
let processedSpaces = 0
const spacesIterator = await client.traverse(DOMAIN_SPACE, {})

Expand Down Expand Up @@ -452,7 +456,7 @@ async function migrateAccountsToSocialIds (client: MigrationClient): Promise<voi
await spacesIterator.close()
}

ctx.info('processing space types members', { })
ctx.info('processing space types members', {})
let updatedSpaceTypes = 0
for (const spaceType of spaceTypes) {
if (spaceType.members === undefined || spaceType.members.length === 0) continue
Expand Down
11 changes: 10 additions & 1 deletion models/document/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,16 @@
//

import activity from '@hcengineering/activity'
import type { Class, CollectionSize, MarkupBlobRef, Domain, Rank, Ref, Role, RolesAssignment } from '@hcengineering/core'
import type {
Class,
CollectionSize,
MarkupBlobRef,
Domain,
Rank,
Ref,
Role,
RolesAssignment
} from '@hcengineering/core'
import { PersonId, AccountRole, IndexKind } from '@hcengineering/core'
import {
type Document,
Expand Down
7 changes: 4 additions & 3 deletions models/document/src/migration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -299,7 +299,7 @@ async function migrateAccountsToSocialIds (client: MigrationClient): Promise<voi
const ctx = new MeasureMetricsContext('document migrateAccountsToSocialIds', {})
const socialIdByAccount = await getSocialIdByOldAccount(client)

ctx.info('processing document lockedBy ', { })
ctx.info('processing document lockedBy ', {})
const iterator = await client.traverse(DOMAIN_DOCUMENT, { _class: document.class.Document })

try {
Expand All @@ -314,7 +314,8 @@ async function migrateAccountsToSocialIds (client: MigrationClient): Promise<voi

for (const doc of docs) {
const document = doc as Document
const newLockedBy = document.lockedBy != null ? (socialIdByAccount[document.lockedBy] ?? document.lockedBy) : document.lockedBy
const newLockedBy =
document.lockedBy != null ? socialIdByAccount[document.lockedBy] ?? document.lockedBy : document.lockedBy

if (newLockedBy === document.lockedBy) continue

Expand All @@ -336,7 +337,7 @@ async function migrateAccountsToSocialIds (client: MigrationClient): Promise<voi
} finally {
await iterator.close()
}
ctx.info('finished processing document lockedBy ', { })
ctx.info('finished processing document lockedBy ', {})
}

async function removeOldClasses (client: MigrationClient): Promise<void> {
Expand Down
Loading

0 comments on commit 2101f98

Please sign in to comment.