Skip to content

Commit

Permalink
uberf-8425: fix formatting
Browse files Browse the repository at this point in the history
Signed-off-by: Alexey Zinoviev <[email protected]>

Signed-off-by: Alexey Zinoviev <[email protected]>
  • Loading branch information
lexiv0re committed Jan 14, 2025
1 parent 7016ff5 commit 511156c
Show file tree
Hide file tree
Showing 87 changed files with 631 additions and 485 deletions.
2 changes: 1 addition & 1 deletion packages/importer/src/huly/unified.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 { type Attachment } from '@hcengineering/attachment'
import contact, { Employee, type Person } from '@hcengineering/contact'
import { type Class, type Doc, generateId, type Ref, type Space, type TxOperations } from '@hcengineering/core'
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<script lang="ts">
/* eslint-disable @typescript-eslint/no-unused-vars */
import { type Drawing } from '@hcengineering/attachment'
import core, { DateRangeMode } from '@hcengineering/core'
import { DatePresenter, IconScribble } from '@hcengineering/ui'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
// limitations under the License.
-->
<script lang="ts">
/* eslint-disable @typescript-eslint/no-unused-vars */
import { Analytics } from '@hcengineering/analytics'
import { Channel, Person, getName } from '@hcengineering/contact'
import core, {
Expand Down
2 changes: 1 addition & 1 deletion plugins/contact-resources/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.
//

/* eslint-disable @typescript-eslint/no-unused-vars */
import {
getGravatarUrl,
getName,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,7 @@
createDocumentTemplate
} from '@hcengineering/controlled-documents'
import { getCurrentEmployee } from '@hcengineering/contact'
import {
type AttachedData,
type Class,
type Data,
type Ref,
type Mixin,
generateId
} from '@hcengineering/core'
import { type AttachedData, type Class, type Data, type Ref, type Mixin, generateId } from '@hcengineering/core'
import { MessageBox, getClient } from '@hcengineering/presentation'
import {
AnySvelteComponent,
Expand Down
1 change: 1 addition & 0 deletions plugins/drive-resources/src/components/GridItem.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
// limitations under the License.
-->
<script lang="ts">
/* eslint-disable @typescript-eslint/no-unused-vars */
import core, { type WithLookup } from '@hcengineering/core'
import { type Resource } from '@hcengineering/drive'
import { getClient } from '@hcengineering/presentation'
Expand Down
1 change: 1 addition & 0 deletions plugins/gmail-resources/src/components/Chats.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
// limitations under the License.
-->
<script lang="ts">
/* eslint-disable @typescript-eslint/no-unused-vars */
import { Channel, Contact } from '@hcengineering/contact'
import { employeeByIdStore } from '@hcengineering/contact-resources'
import { Ref, SortingOrder } from '@hcengineering/core'
Expand Down
12 changes: 7 additions & 5 deletions plugins/gmail-resources/src/components/Main.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
// limitations under the License.
-->
<script lang="ts">
/* eslint-disable @typescript-eslint/no-unused-vars */
import contact, { Channel, Contact, getName } from '@hcengineering/contact'
import { employeeByIdStore } from '@hcengineering/contact-resources'
import { Ref } from '@hcengineering/core'
Expand Down Expand Up @@ -48,8 +49,8 @@
let currentMessage: SharedMessage | undefined = undefined
let newMessage: boolean = false
let allIntegrations: Integration[] = []
let integrations: Integration[] = []
const allIntegrations: Integration[] = []
const integrations: Integration[] = []
let selectedIntegration: Integration | undefined = undefined
channel && inboxClient.forceReadDoc(channel._id, channel._class)
Expand Down Expand Up @@ -95,10 +96,11 @@
$: templateProvider && selectedIntegration && templateProvider.set(setting.class.Integration, selectedIntegration)
// TODO: FIXME
settingsQuery.query(setting.class.Integration, { type: gmail.integrationType.Gmail }, (res) => {
allIntegrations = res.filter((p) => !p.disabled && p.value !== '')
integrations = allIntegrations.filter((p) => p.createdBy === me || p.shared?.includes(me))
selectedIntegration = integrations.find((p) => p.createdBy === me) ?? integrations[0]
// allIntegrations = res.filter((p) => !p.disabled && p.value !== '')
// integrations = allIntegrations.filter((p) => p.createdBy === me || p.shared?.includes(me))
// selectedIntegration = integrations.find((p) => p.createdBy === me) ?? integrations[0]
})
// TODO: FIXME
Expand Down
5 changes: 3 additions & 2 deletions plugins/setting-resources/src/utils.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
// import contact, { type Employee, getFirstName, getLastName } from '@hcengineering/contact'
// import { employeeByIdStore } from '@hcengineering/contact-resources'
/* eslint-disable @typescript-eslint/no-unused-vars */
import contact, { type Employee, getFirstName, getLastName } from '@hcengineering/contact'
import { employeeByIdStore } from '@hcengineering/contact-resources'
import { type Class, type Doc, type Hierarchy, type Ref } from '@hcengineering/core'
import { getMetadata } from '@hcengineering/platform'
import login from '@hcengineering/login'
Expand Down
1 change: 1 addition & 0 deletions plugins/telegram-resources/src/components/Chat.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
// limitations under the License.
-->
<script lang="ts">
/* eslint-disable @typescript-eslint/no-unused-vars */
import attachment from '@hcengineering/attachment'
import { AttachmentRefInput } from '@hcengineering/attachment-resources'
import contact, { Channel, Contact, Person, getName as getContactName } from '@hcengineering/contact'
Expand Down
33 changes: 19 additions & 14 deletions server-plugins/contact-resources/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -99,17 +99,17 @@ export async function OnSocialIdentityCreate (_txes: Tx[], control: TriggerContr
if (ctx._class !== core.class.TxCreateDoc) continue

const socialId = TxProcessor.createDoc2Doc(ctx)
const employee = (await control.findAll(control.ctx, contact.mixin.Employee, { _id: socialId.attachedTo as Ref<Employee> }))[0]
const employee = (
await control.findAll(control.ctx, contact.mixin.Employee, { _id: socialId.attachedTo as Ref<Employee> })
)[0]
if (employee === undefined || !employee.active) continue
const socialString = buildSocialIdString(socialId)
const txes = await createPersonSpace(
socialString,
employee._id,
control
)
const txes = await createPersonSpace(socialString, employee._id, control)
result.push(...txes)

const socialIds = await control.findAll(control.ctx, contact.class.SocialIdentity, { attachedTo: socialId.attachedTo })
const socialIds = await control.findAll(control.ctx, contact.class.SocialIdentity, {
attachedTo: socialId.attachedTo
})
if (socialIds.every((si) => si._id !== socialId._id)) {
socialIds.push(socialId)
}
Expand All @@ -135,18 +135,17 @@ export async function OnEmployeeCreate (_txes: Tx[], control: TriggerControl): P
for (const tx of _txes) {
const mixinTx = tx as TxMixin<Person, Employee>
if (mixinTx.attributes.active !== true) continue
const socialIds = await control.findAll(control.ctx, contact.class.SocialIdentity, { attachedTo: mixinTx.objectId, attachedToClass: contact.class.Person })
const socialIds = await control.findAll(control.ctx, contact.class.SocialIdentity, {
attachedTo: mixinTx.objectId,
attachedToClass: contact.class.Person
})
const socialStrings = socialIds.map(buildSocialIdString)
if (socialStrings.length === 0) continue

const socialId = pickPrimarySocialId(socialStrings)
const spaces = await control.findAll(control.ctx, core.class.Space, { autoJoin: true })

const txes = await createPersonSpace(
socialId,
mixinTx.objectId,
control
)
const txes = await createPersonSpace(socialId, mixinTx.objectId, control)
result.push(...txes)

for (const space of spaces) {
Expand Down Expand Up @@ -321,7 +320,13 @@ export async function getCurrentEmployeeEmail (control: TriggerControl, context:
const person = await getTriggerCurrentPerson(control)
if (person === undefined) return ''

const emailSocialId = (await control.findAll(control.ctx, contact.class.SocialIdentity, { attachedTo: person._id, attachedToClass: contact.class.Person, type: SocialIdType.EMAIL }))[0]
const emailSocialId = (
await control.findAll(control.ctx, contact.class.SocialIdentity, {
attachedTo: person._id,
attachedToClass: contact.class.Person,
type: SocialIdType.EMAIL
})
)[0]
if (emailSocialId === undefined) return ''

return emailSocialId.value
Expand Down
64 changes: 51 additions & 13 deletions server-plugins/contact/src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,19 +25,33 @@ export async function getTriggerCurrentPerson (control: TriggerControl): Promise
return undefined
}

const person = (await control.findAll(control.ctx, contact.class.Person, { _id: socialIdentity.attachedTo, _class: socialIdentity.attachedToClass }))[0]
const person = (
await control.findAll(control.ctx, contact.class.Person, {
_id: socialIdentity.attachedTo,
_class: socialIdentity.attachedToClass
})
)[0]

return person
}

export async function getSocialStrings (control: TriggerControl, person: Ref<Person>): Promise<PersonId[]> {
const socialIdentities = await control.findAll(control.ctx, contact.class.SocialIdentity, { attachedTo: person, attachedToClass: contact.class.Person })
const socialIdentities = await control.findAll(control.ctx, contact.class.SocialIdentity, {
attachedTo: person,
attachedToClass: contact.class.Person
})

return socialIdentities.map((s) => s.key)
}

export async function getSocialStringsByPersons (control: TriggerControl, persons: Ref<Person>[]): Promise<Record<Ref<Person>, PersonId[]>> {
const socialIdentities = await control.findAll(control.ctx, contact.class.SocialIdentity, { attachedTo: { $in: persons }, attachedToClass: contact.class.Person })
export async function getSocialStringsByPersons (
control: TriggerControl,
persons: Ref<Person>[]
): Promise<Record<Ref<Person>, PersonId[]>> {
const socialIdentities = await control.findAll(control.ctx, contact.class.SocialIdentity, {
attachedTo: { $in: persons },
attachedToClass: contact.class.Person
})

return socialIdentities.reduce<Record<Ref<Person>, PersonId[]>>((acc, s) => {
if (acc[s.attachedTo] === undefined) {
Expand All @@ -50,9 +64,15 @@ export async function getSocialStringsByPersons (control: TriggerControl, person
}, {})
}

export async function getAllSocialStringsByPersonId (control: TriggerControl, personIds: PersonId[]): Promise<PersonId[]> {
export async function getAllSocialStringsByPersonId (
control: TriggerControl,
personIds: PersonId[]
): Promise<PersonId[]> {
const socialIdentities = await control.findAll(control.ctx, contact.class.SocialIdentity, { key: { $in: personIds } })
const allSocialIdentities = await control.findAll(control.ctx, contact.class.SocialIdentity, { attachedTo: { $in: socialIdentities.map((sid) => sid.attachedTo) }, attachedToClass: contact.class.Person })
const allSocialIdentities = await control.findAll(control.ctx, contact.class.SocialIdentity, {
attachedTo: { $in: socialIdentities.map((sid) => sid.attachedTo) },
attachedToClass: contact.class.Person
})

return allSocialIdentities.map((sid) => sid.key)
}
Expand All @@ -66,14 +86,21 @@ export async function getPerson (control: TriggerControl, personId: PersonId): P

export async function getPersons (control: TriggerControl, personIds: PersonId[]): Promise<Person[]> {
const socialIds = await control.findAll(control.ctx, contact.class.SocialIdentity, { key: { $in: personIds } })
const persons = await control.findAll(control.ctx, contact.class.Person, { _id: { $in: socialIds.map((s) => s.attachedTo) } })
const persons = await control.findAll(control.ctx, contact.class.Person, {
_id: { $in: socialIds.map((s) => s.attachedTo) }
})

return persons
}

export async function getPersonsBySocialIds (control: TriggerControl, personIds: PersonId[]): Promise<Record<string, Person>> {
export async function getPersonsBySocialIds (
control: TriggerControl,
personIds: PersonId[]
): Promise<Record<string, Person>> {
const socialIds = await control.findAll(control.ctx, contact.class.SocialIdentity, { key: { $in: personIds } })
const persons = toIdMap(await control.findAll(control.ctx, contact.class.Person, { _id: { $in: socialIds.map((s) => s.attachedTo) } }))
const persons = toIdMap(
await control.findAll(control.ctx, contact.class.Person, { _id: { $in: socialIds.map((s) => s.attachedTo) } })
)

return socialIds.reduce<Record<string, Person>>((acc, s) => {
const person = persons.get(s.attachedTo)
Expand All @@ -89,21 +116,32 @@ export async function getPersonsBySocialIds (control: TriggerControl, personIds:

export async function getEmployee (control: TriggerControl, personId: PersonId): Promise<Employee | undefined> {
const socialId = (await control.findAll(control.ctx, contact.class.SocialIdentity, { key: personId }))[0]
const employee = (await control.findAll(control.ctx, contact.mixin.Employee, { _id: socialId.attachedTo as Ref<Employee> }))[0]
const employee = (
await control.findAll(control.ctx, contact.mixin.Employee, { _id: socialId.attachedTo as Ref<Employee> })
)[0]

return employee
}

export async function getEmployees (control: TriggerControl, personIds: PersonId[]): Promise<Employee[]> {
const socialIds = await control.findAll(control.ctx, contact.class.SocialIdentity, { key: { $in: personIds } })
const employees = await control.findAll(control.ctx, contact.mixin.Employee, { _id: { $in: socialIds.map((s) => s.attachedTo as Ref<Employee>) } })
const employees = await control.findAll(control.ctx, contact.mixin.Employee, {
_id: { $in: socialIds.map((s) => s.attachedTo as Ref<Employee>) }
})

return employees
}

export async function getEmployeesBySocialIds (control: TriggerControl, personIds: PersonId[]): Promise<Record<string, Employee | undefined>> {
export async function getEmployeesBySocialIds (
control: TriggerControl,
personIds: PersonId[]
): Promise<Record<string, Employee | undefined>> {
const socialIds = await control.findAll(control.ctx, contact.class.SocialIdentity, { key: { $in: personIds } })
const employees = toIdMap(await control.findAll(control.ctx, contact.mixin.Employee, { _id: { $in: socialIds.map((s) => s.attachedTo as Ref<Employee>) } }))
const employees = toIdMap(
await control.findAll(control.ctx, contact.mixin.Employee, {
_id: { $in: socialIds.map((s) => s.attachedTo as Ref<Employee>) }
})
)

return socialIds.reduce<Record<string, Employee | undefined>>((acc, s) => {
acc[s.key] = employees.get(s.attachedTo as Ref<Employee>)
Expand Down
4 changes: 3 additions & 1 deletion server-plugins/controlled-documents-resources/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,9 @@ export async function OnSocialIdentityCreate (_txes: Tx[], control: TriggerContr
const account = control.ctx.contextData.account
if (account.role !== AccountRole.Owner) return []

const defaultSpace = (await control.findAll(control.ctx, documents.class.OrgSpace, { _id: documents.space.QualityDocuments }))[0]
const defaultSpace = (
await control.findAll(control.ctx, documents.class.OrgSpace, { _id: documents.space.QualityDocuments })
)[0]

if (defaultSpace === undefined) return []

Expand Down
2 changes: 1 addition & 1 deletion server-plugins/gmail-resources/src/index.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 contact, { Channel, formatName, Person } from '@hcengineering/contact'
import {
PersonId,
Expand Down
32 changes: 7 additions & 25 deletions server-plugins/hr-resources/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,7 @@ import core, {
TxUpdateDoc
} from '@hcengineering/core'
import gmail from '@hcengineering/gmail'
import hr, {
Department,
fromTzDate,
PublicHoliday,
Request,
Staff,
tzDateEqual
} from '@hcengineering/hr'
import hr, { Department, fromTzDate, PublicHoliday, Request, Staff, tzDateEqual } from '@hcengineering/hr'
import notification, { NotificationType } from '@hcengineering/notification'
import { translate } from '@hcengineering/platform'
import { TriggerControl } from '@hcengineering/server-core'
Expand Down Expand Up @@ -113,7 +106,8 @@ function getTxes (
$push: { members: emp }
})
)
).flat()
)
.flat()
if (removed === undefined) return pushTxes
const pullTxes = removed
.map((dep) =>
Expand All @@ -122,7 +116,8 @@ function getTxes (
$pull: { members: emp }
})
)
).flat()
)
.flat()
return [...pullTxes, ...pushTxes]
}

Expand Down Expand Up @@ -155,25 +150,12 @@ export async function OnDepartmentStaff (txes: Tx[], control: TriggerControl): P
const push = (await buildHierarchy(departmentId, control)).map((p) => p._id)

if (lastDepartment === undefined) {
result.push(
...getTxes(
control.txFactory,
[employee],
push
)
)
result.push(...getTxes(control.txFactory, [employee], push))
} else {
let removed = (await buildHierarchy(lastDepartment, control)).map((p) => p._id)
const added = exlude(removed, push)
removed = exlude(push, removed)
result.push(
...getTxes(
control.txFactory,
[employee],
added,
removed
)
)
result.push(...getTxes(control.txFactory, [employee], added, removed))
}
}
}
Expand Down
Loading

0 comments on commit 511156c

Please sign in to comment.