@things-factory/organization 10.1.232 → 10.1.234
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist-client/component/approval-line-edit.d.ts +9 -0
- package/dist-client/component/approval-line-edit.js +8 -0
- package/dist-client/component/approval-line-edit.js.map +1 -1
- package/dist-client/component/approval-line-items-editor.js +2 -2
- package/dist-client/component/approval-line-items-editor.js.map +1 -1
- package/dist-client/component/approval-line-templates-manager.js +2 -1
- package/dist-client/component/approval-line-templates-manager.js.map +1 -1
- package/dist-client/component/assignees-editor.js +2 -1
- package/dist-client/component/assignees-editor.js.map +1 -1
- package/dist-client/component/recipients-editor.js +2 -1
- package/dist-client/component/recipients-editor.js.map +1 -1
- package/dist-client/tsconfig.tsbuildinfo +1 -1
- package/dist-server/ai-entry/organization-entry-rules.js +3 -3
- package/dist-server/ai-entry/organization-entry-rules.js.map +1 -1
- package/dist-server/service/approval-line/approval-line-mutation.js +7 -5
- package/dist-server/service/approval-line/approval-line-mutation.js.map +1 -1
- package/dist-server/service/department/department-mutation.js +2 -1
- package/dist-server/service/department/department-mutation.js.map +1 -1
- package/dist-server/service/department/department-parent.js +3 -2
- package/dist-server/service/department/department-parent.js.map +1 -1
- package/dist-server/service/domain-reference.d.ts +1 -1
- package/dist-server/service/domain-reference.js +2 -2
- package/dist-server/service/domain-reference.js.map +1 -1
- package/dist-server/service/employee/employee-control-no.d.ts +12 -0
- package/dist-server/service/employee/employee-control-no.js +27 -0
- package/dist-server/service/employee/employee-control-no.js.map +1 -0
- package/dist-server/service/employee/employee-day.js +4 -1
- package/dist-server/service/employee/employee-day.js.map +1 -1
- package/dist-server/service/employee/employee-mutation.js +12 -3
- package/dist-server/service/employee/employee-mutation.js.map +1 -1
- package/dist-server/service/employee-profile/employee-profile-query.js +3 -2
- package/dist-server/service/employee-profile/employee-profile-query.js.map +1 -1
- package/dist-server/tsconfig.tsbuildinfo +1 -1
- package/package.json +7 -7
- package/tests/assignees-editor-no-role.test.ts +2 -2
- package/tests/refusals-in-korean.test.ts +48 -0
- package/translations/en.json +13 -1
- package/translations/es.json +13 -1
- package/translations/ja.json +13 -1
- package/translations/ko.json +13 -1
- package/translations/ms.json +13 -1
- package/translations/zh.json +13 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"employee-mutation.js","sourceRoot":"","sources":["../../../server/service/employee/employee-mutation.ts"],"names":[],"mappings":";;;;AAAA,+CAAsE;AACtE,qCAA4B;AAE5B,iDAAqD;AAErD,qEAA0F;AAC1F,qDAAiD;AAEjD,yCAAqC;AACrC,mDAA4D;AAC5D,yDAAqD;AACrD,iDAAyC;AACzC,yDAAuD;AACvD,0DAAqE;AAErE,yGAI2D;AAGpD,IAAM,gBAAgB,GAAtB,MAAM,gBAAgB;IAOrB,AAAN,KAAK,CAAC,cAAc,CAAkB,QAAqB,EAAS,OAAwB;QAC1F,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,EAAE,EAAE,GAAG,OAAO,CAAC,KAAK,CAAA;QAC1C,IAAA,qCAAkB,EAAC,CAAC,QAAe,CAAC,CAAC,CAAA;QAErC,MAAM,UAAU,GAAG,MAAM,IAAA,oCAAiB,EACxC,IAAA,qBAAa,EAAC,mBAAQ,EAAE,EAAE,CAAC,EAC3B,YAAY,IAAI,QAAQ,CAAC,CAAC,CAAC,QAAQ,CAAC,UAAU,CAAC,CAAC,CAAC,SAAS,EAC1D,MAAM,EACN,YAAY,CACb,CAAA;QAED,MAAM,UAAU,GAAG,MAAM,IAAA,oCAAiB,EACxC,IAAA,qBAAa,EAAC,uBAAU,EAAE,EAAE,CAAC,EAC7B,YAAY,IAAI,QAAQ,CAAC,CAAC,CAAC,QAAQ,CAAC,UAAU,CAAC,CAAC,CAAC,SAAS,EAC1D,MAAM,EACN,YAAY,CACb,CAAA;QAED,MAAM,aAAa,GAAG,MAAM,IAAA,+BAAY,EAAC,MAAM,IAAI,QAAQ,CAAC,CAAC,CAAC,QAAQ,CAAC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AAE,CAAC,OAAO,EAAE;QAC5B,WAAW,EACT,8HAA8H;KACjI,CAAC;IAEC,mBAAA,IAAA,kBAAG,EAAC,YAAY,EAAE,EAAE,WAAW,EAAE,aAAa,EAAE,CAAC,CAAA;IACjD,mBAAA,IAAA,kBAAG,GAAE,CAAA;;;;oEAGP;2BA5YU,gBAAgB;IAD5B,IAAA,uBAAQ,EAAC,mBAAQ,CAAC;GACN,gBAAgB,CA6Y5B","sourcesContent":["import { Resolver, Mutation, Arg, Ctx, Directive } from 'type-graphql'\nimport { In } from 'typeorm'\n\nimport { getRepository } from '@things-factory/shell'\nimport { User } from '@things-factory/auth-base'\nimport { createAttachment, deleteAttachmentsByRef } from '@things-factory/attachment-base'\nimport { Contact } from '@things-factory/contact'\n\nimport { Employee } from './employee'\nimport { NewEmployee, EmployeePatch } from './employee-type'\nimport { Department } from '../department/department'\nimport { withDays } from './employee-day'\nimport { refusePrivateWrite } from './employee-private'\nimport { referenceInDomain, userInDomain } from '../domain-reference'\n\nimport {\n onDeleteEmployeeAsSystemUser,\n onUpdateEmployeeAsSystemUser,\n registerEmployeeAsSystemUser\n} from '../../controllers/register-employee-as-system-user'\n\n@Resolver(Employee)\nexport class EmployeeMutation {\n @Directive('@transaction')\n @Directive('@privilege(category: \"employee\", privilege: \"mutation\", domainOwnerGranted: true)')\n @Mutation(returns => Employee, {\n description:\n 'Creates a new employee record with the provided details. Optionally associates the employee with a supervisor, department, and system user. If a photo is provided, it will be attached to the employee record.'\n })\n async createEmployee(@Arg('employee') employee: NewEmployee, @Ctx() context: ResolverContext): Promise<Employee> {\n const { domain, user, tx } = context.state\n refusePrivateWrite([employee as any])\n\n const supervisor = await referenceInDomain(\n getRepository(Employee, tx),\n 'supervisor' in employee ? employee.supervisor : undefined,\n domain,\n 'supervisor'\n )\n\n const department = await referenceInDomain(\n getRepository(Department, tx),\n 'department' in employee ? employee.department : undefined,\n domain,\n 'department'\n )\n\n const connectedUser = await userInDomain('user' in employee ? employee.user : undefined, domain, tx)\n\n const result = await getRepository(Employee, tx).save({\n ...withDays(employee),\n supervisor,\n department,\n user: connectedUser,\n domain,\n creator: user,\n updater: user\n })\n\n if (employee.photo) {\n await createAttachment(\n null,\n {\n attachment: {\n file: employee.photo,\n refType: Employee.name,\n refBy: result.id\n }\n },\n context\n )\n }\n\n return result\n }\n\n /** An employee's pay account - HR-payroll's, so its own door and privilege (ADR-0139). Empty text clears a field. */\n @Directive('@transaction')\n @Directive('@privilege(category: \"employee-private\", privilege: \"mutation\", domainOwnerGranted: false)')\n @Mutation(returns => Employee, { description: \"Sets an employee's pay account - the bank and the account number their pay goes to\" })\n async updateEmployeePayAccount(\n @Arg('id') id: string,\n @Arg('bankName', { nullable: true }) bankName: string,\n @Arg('bankAccount', { nullable: true }) bankAccount: string,\n @Ctx() context: ResolverContext\n ): Promise<Employee> {\n const { domain, user, tx } = context.state\n const repository = getRepository(Employee, tx)\n const employee = await repository.findOne({ where: { domain: { id: domain.id }, id } })\n if (!employee) throw new Error(`There is no employee ${id}.`)\n return await repository.save({ ...employee, bankName: bankName || null, bankAccount: bankAccount || null, updater: user } as any)\n }\n\n @Directive('@transaction')\n @Directive('@privilege(category: \"employee\", privilege: \"mutation\", domainOwnerGranted: true)')\n @Mutation(returns => Employee, {\n description:\n 'Updates the details of an existing employee identified by the given ID. Optionally updates the supervisor, department, system user, and photo associated with the employee.'\n })\n async updateEmployee(\n @Arg('id') id: string,\n @Arg('patch') patch: EmployeePatch,\n @Ctx() context: ResolverContext\n ): Promise<Employee> {\n const { domain, user, tx } = context.state\n refusePrivateWrite([patch as any])\n\n const supervisor = await referenceInDomain(\n getRepository(Employee, tx),\n 'supervisor' in patch ? patch.supervisor : undefined,\n domain,\n 'supervisor'\n )\n\n const department = await referenceInDomain(\n getRepository(Department, tx),\n 'department' in patch ? patch.department : undefined,\n domain,\n 'department'\n )\n\n const connectedUser = await userInDomain('user' in patch ? patch.user : undefined, domain, tx)\n\n const repository = getRepository(Employee, tx)\n const employee = await repository.findOne({\n where: { domain: { id: domain.id }, id }\n })\n\n await onUpdateEmployeeAsSystemUser(patch, context)\n\n const result = await repository.save({\n ...employee,\n ...withDays(patch),\n supervisor,\n department,\n user: connectedUser,\n updater: user\n })\n\n if (patch.photo) {\n await deleteAttachmentsByRef(null, { refBys: [result.id] }, context)\n await createAttachment(\n null,\n {\n attachment: {\n file: patch.photo,\n refType: Employee.name,\n refBy: result.id\n }\n },\n context\n )\n }\n\n return result\n }\n\n @Directive('@transaction')\n @Directive('@privilege(category: \"employee\", privilege: \"mutation\", domainOwnerGranted: true)')\n @Mutation(returns => [Employee], {\n description:\n 'Updates or creates multiple employee records based on the provided patches. New employees are created if the \"cuFlag\" is \"+\", and existing employees are updated if the \"cuFlag\" is \"M\".'\n })\n async updateMultipleEmployee(\n @Arg('patches', type => [EmployeePatch]) patches: EmployeePatch[],\n @Ctx() context: ResolverContext\n ): Promise<Employee[]> {\n const { domain, user, tx } = context.state\n refusePrivateWrite(patches as any[])\n\n let results = []\n const _createRecords = patches.filter((patch: any) => patch.cuFlag.toUpperCase() === '+')\n const _updateRecords = patches.filter((patch: any) => patch.cuFlag.toUpperCase() === 'M')\n const employeeRepo = getRepository(Employee, tx)\n\n if (_createRecords.length > 0) {\n for (let i = 0; i < _createRecords.length; i++) {\n const newRecord = _createRecords[i]\n\n const supervisor = await referenceInDomain(\n getRepository(Employee, tx),\n 'supervisor' in newRecord ? newRecord.supervisor : undefined,\n domain,\n 'supervisor'\n )\n\n const department = await referenceInDomain(\n getRepository(Department, tx),\n 'department' in newRecord ? newRecord.department : undefined,\n domain,\n 'department'\n )\n\n const connectedUser = await userInDomain('user' in newRecord ? newRecord.user : undefined, domain, tx)\n\n const result = await employeeRepo.save({\n ...withDays(newRecord),\n supervisor,\n department,\n user: connectedUser,\n domain,\n creator: user,\n updater: user\n })\n\n if (newRecord.photo) {\n await createAttachment(\n null,\n {\n attachment: {\n file: newRecord.photo,\n refType: Employee.name,\n refBy: result.id\n }\n },\n context\n )\n }\n\n results.push({ ...result, cuFlag: '+' })\n }\n }\n\n if (_updateRecords.length > 0) {\n for (let i = 0; i < _updateRecords.length; i++) {\n const updateRecord = _updateRecords[i]\n\n const supervisor = await referenceInDomain(\n getRepository(Employee, tx),\n 'supervisor' in updateRecord ? updateRecord.supervisor : undefined,\n domain,\n 'supervisor'\n )\n\n const department = await referenceInDomain(\n getRepository(Department, tx),\n 'department' in updateRecord ? updateRecord.department : undefined,\n domain,\n 'department'\n )\n\n const connectedUser = await userInDomain('user' in updateRecord ? updateRecord.user : undefined, domain, tx)\n\n const employee = await employeeRepo.findOne({\n where: { domain: { id: domain.id }, id: updateRecord.id }\n })\n\n if (!employee) {\n throw new Error(`failed to find employee to update: ${updateRecord.id}`)\n }\n\n await onUpdateEmployeeAsSystemUser(updateRecord, context)\n\n const result = await employeeRepo.save({\n ...employee,\n ...withDays(updateRecord),\n supervisor,\n department,\n user: connectedUser,\n updater: user\n })\n\n if (updateRecord.photo) {\n await deleteAttachmentsByRef(null, { refBys: [result.id] }, context)\n await createAttachment(\n null,\n {\n attachment: {\n file: updateRecord.photo,\n refType: Employee.name,\n refBy: result.id\n }\n },\n context\n )\n }\n\n results.push({ ...result, cuFlag: 'M' })\n }\n }\n\n return results\n }\n\n @Directive('@transaction')\n @Directive('@privilege(category: \"employee\", privilege: \"mutation\", domainOwnerGranted: true)')\n @Mutation(returns => Boolean, {\n description:\n 'Deletes an employee record identified by the given ID. Also deletes any attachments associated with the employee.'\n })\n async deleteEmployee(@Arg('id') id: string, @Ctx() context: ResolverContext): Promise<boolean> {\n const { domain, tx } = context.state\n\n await onDeleteEmployeeAsSystemUser(id, context)\n await getRepository(Employee, tx).delete({ domain: { id: domain.id }, id })\n await deleteAttachmentsByRef(null, { refBys: [id] }, context)\n\n return true\n }\n\n @Directive('@transaction')\n @Directive('@privilege(category: \"employee\", privilege: \"mutation\", domainOwnerGranted: true)')\n @Mutation(returns => Boolean, {\n description:\n 'Deletes multiple employee records identified by the given IDs. Also deletes any attachments associated with each employee.'\n })\n async deleteEmployees(\n @Arg('ids', type => [String]) ids: string[],\n @Ctx() context: ResolverContext\n ): Promise<boolean> {\n const { domain, tx } = context.state\n\n for (let id of ids) {\n await onDeleteEmployeeAsSystemUser(id, context)\n }\n\n await getRepository(Employee, tx).delete({\n domain: { id: domain.id },\n id: In(ids)\n })\n\n await deleteAttachmentsByRef(null, { refBys: ids }, context)\n\n return true\n }\n\n @Directive('@transaction')\n @Directive('@privilege(category: \"employee\", privilege: \"mutation\", domainOwnerGranted: true)')\n @Mutation(returns => Boolean, {\n description:\n 'Imports multiple employee records into the system. Each employee record must be provided in the EmployeePatch format.'\n })\n async importEmployees(\n @Arg('employees', type => [EmployeePatch]) employees: EmployeePatch[],\n @Ctx() context: ResolverContext\n ): Promise<boolean> {\n const { domain, tx } = context.state\n refusePrivateWrite(employees as any[])\n\n await Promise.all(\n employees.map(async (employee: EmployeePatch) => {\n const createdEmployee: Employee = await getRepository(Employee, tx).save({ domain, ...withDays(employee) })\n })\n )\n\n return true\n }\n\n @Directive('@transaction')\n @Directive('@privilege(category: \"employee\", privilege: \"mutation\", domainOwnerGranted: true)')\n @Mutation(returns => Employee, {\n description:\n 'Attaches an existing contact to an employee. The contact is identified by its ID and the employee is identified by their ID.'\n })\n async attachContact(\n @Arg('id') id: string,\n @Arg('contactId') contactId: string,\n @Ctx() context: ResolverContext\n ): Promise<Employee> {\n const { domain, user, tx } = context.state\n\n const employeeRepository = getRepository(Employee, tx)\n const employee = await employeeRepository.findOne({\n where: { domain: { id: domain.id }, id }\n })\n\n const contactRepository = getRepository(Contact, tx)\n const contact = await contactRepository.findOne({\n where: { domain: { id: domain.id }, id: contactId }\n })\n\n if (!contact) {\n throw Error(`Contact not found with given contactId(${contactId}).`)\n }\n\n const result = await employeeRepository.save({\n ...employee,\n name: contact.name,\n contact: { id: contactId },\n updater: user\n })\n\n return result\n }\n\n @Directive('@transaction')\n @Directive('@privilege(category: \"employee\", privilege: \"mutation\", domainOwnerGranted: true)')\n @Mutation(returns => Employee, {\n description: 'Detaches an existing contact from an employee. The employee is identified by their ID.'\n })\n async detachContact(@Arg('id') id: string, @Ctx() context: ResolverContext): Promise<Employee> {\n const { domain, user, tx } = context.state\n\n const repository = getRepository(Employee, tx)\n const employee = await repository.findOne({\n where: { domain: { id: domain.id }, id }\n })\n\n const result = await repository.save({\n ...employee,\n contact: null,\n updater: user\n })\n\n return result\n }\n\n @Directive('@transaction')\n @Directive('@privilege(category: \"user\", privilege: \"mutation\", domainOwnerGranted: true)')\n @Mutation(returns => Boolean, {\n description:\n 'Registers an existing employee as a system user, granting them access to the system. The employee is identified by their ID.'\n })\n async registerEmployeeAsSystemUser(\n @Arg('employeeId', { description: 'Employee Id' }) employeeId: string,\n @Ctx() context: ResolverContext\n ): Promise<boolean> {\n return !!(await registerEmployeeAsSystemUser(employeeId, context))\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"employee-mutation.js","sourceRoot":"","sources":["../../../server/service/employee/employee-mutation.ts"],"names":[],"mappings":";;;;AAAA,+CAAqF;AACrF,qCAA4B;AAE5B,iDAA6E;AAE7E,qEAA0F;AAC1F,qDAAiD;AAEjD,yCAAqC;AACrC,mDAA4D;AAC5D,yDAAqD;AACrD,iDAAyC;AACzC,+DAA6D;AAC7D,yDAAuD;AACvD,0DAAqE;AAErE,yGAI2D;AAIpD,IAAM,gBAAgB,GAAtB,MAAM,gBAAgB;IAOrB,AAAN,KAAK,CAAC,cAAc,CAAkB,QAAqB,EAAS,OAAwB;QAC1F,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,EAAE,EAAE,GAAG,OAAO,CAAC,KAAK,CAAA;QAC1C,IAAA,qCAAkB,EAAC,CAAC,QAAe,CAAC,CAAC,CAAA;QACrC,MAAM,IAAA,2CAAqB,EAAC,EAAE,EAAE,MAAM,EAAE,CAAC,EAAE,SAAS,EAAE,QAAQ,CAAC,SAAS,IAAI,IAAI,EAAE,CAAC,CAAC,CAAA;QAEpF,MAAM,UA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AAA;;;;qDAehD;AAQK;IANL,IAAA,wBAAS,EAAC,cAAc,CAAC;IACzB,IAAA,wBAAS,EAAC,+EAA+E,CAAC;IAC1F,IAAA,uBAAQ,EAAC,OAAO,CAAC,EAAE,CAAC,OAAO,EAAE;QAC5B,WAAW,EACT,8HAA8H;KACjI,CAAC;IAEC,mBAAA,IAAA,kBAAG,EAAC,YAAY,EAAE,EAAE,WAAW,EAAE,aAAa,EAAE,CAAC,CAAA;IACjD,mBAAA,IAAA,kBAAG,GAAE,CAAA;;;;oEAGP;2BAnZU,gBAAgB;IAF5B,IAAA,uBAAQ,EAAC,mBAAQ,CAAC;IAClB,IAAA,4BAAa,EAAC,qBAAa,CAAC;GAChB,gBAAgB,CAoZ5B","sourcesContent":["import { Resolver, Mutation, Arg, Ctx, Directive, UseMiddleware } from 'type-graphql'\nimport { In } from 'typeorm'\n\nimport { getRepository, Refusal, SpeakRefusals } from '@things-factory/shell'\nimport { User } from '@things-factory/auth-base'\nimport { createAttachment, deleteAttachmentsByRef } from '@things-factory/attachment-base'\nimport { Contact } from '@things-factory/contact'\n\nimport { Employee } from './employee'\nimport { NewEmployee, EmployeePatch } from './employee-type'\nimport { Department } from '../department/department'\nimport { withDays } from './employee-day'\nimport { refuseTakenControlNos } from './employee-control-no'\nimport { refusePrivateWrite } from './employee-private'\nimport { referenceInDomain, userInDomain } from '../domain-reference'\n\nimport {\n onDeleteEmployeeAsSystemUser,\n onUpdateEmployeeAsSystemUser,\n registerEmployeeAsSystemUser\n} from '../../controllers/register-employee-as-system-user'\n\n@Resolver(Employee)\n@UseMiddleware(SpeakRefusals)\nexport class EmployeeMutation {\n @Directive('@transaction')\n @Directive('@privilege(category: \"employee\", privilege: \"mutation\", domainOwnerGranted: true)')\n @Mutation(returns => Employee, {\n description:\n 'Creates a new employee record with the provided details. Optionally associates the employee with a supervisor, department, and system user. If a photo is provided, it will be attached to the employee record.'\n })\n async createEmployee(@Arg('employee') employee: NewEmployee, @Ctx() context: ResolverContext): Promise<Employee> {\n const { domain, user, tx } = context.state\n refusePrivateWrite([employee as any])\n await refuseTakenControlNos(tx, domain, [{ controlNo: employee.controlNo ?? null }])\n\n const supervisor = await referenceInDomain(\n getRepository(Employee, tx),\n 'supervisor' in employee ? employee.supervisor : undefined,\n domain,\n 'supervisor'\n )\n\n const department = await referenceInDomain(\n getRepository(Department, tx),\n 'department' in employee ? employee.department : undefined,\n domain,\n 'department'\n )\n\n const connectedUser = await userInDomain('user' in employee ? employee.user : undefined, domain, tx)\n\n const result = await getRepository(Employee, tx).save({\n ...withDays(employee),\n supervisor,\n department,\n user: connectedUser,\n domain,\n creator: user,\n updater: user\n })\n\n if (employee.photo) {\n await createAttachment(\n null,\n {\n attachment: {\n file: employee.photo,\n refType: Employee.name,\n refBy: result.id\n }\n },\n context\n )\n }\n\n return result\n }\n\n /** An employee's pay account - HR-payroll's, so its own door and privilege (ADR-0139). Empty text clears a field. */\n @Directive('@transaction')\n @Directive('@privilege(category: \"employee-private\", privilege: \"mutation\", domainOwnerGranted: false)')\n @Mutation(returns => Employee, { description: \"Sets an employee's pay account - the bank and the account number their pay goes to\" })\n async updateEmployeePayAccount(\n @Arg('id') id: string,\n @Arg('bankName', { nullable: true }) bankName: string,\n @Arg('bankAccount', { nullable: true }) bankAccount: string,\n @Ctx() context: ResolverContext\n ): Promise<Employee> {\n const { domain, user, tx } = context.state\n const repository = getRepository(Employee, tx)\n const employee = await repository.findOne({ where: { domain: { id: domain.id }, id } })\n if (!employee) throw new Refusal('employee-not-found', {}, `There is no employee ${id}.`)\n return await repository.save({ ...employee, bankName: bankName || null, bankAccount: bankAccount || null, updater: user } as any)\n }\n\n @Directive('@transaction')\n @Directive('@privilege(category: \"employee\", privilege: \"mutation\", domainOwnerGranted: true)')\n @Mutation(returns => Employee, {\n description:\n 'Updates the details of an existing employee identified by the given ID. Optionally updates the supervisor, department, system user, and photo associated with the employee.'\n })\n async updateEmployee(\n @Arg('id') id: string,\n @Arg('patch') patch: EmployeePatch,\n @Ctx() context: ResolverContext\n ): Promise<Employee> {\n const { domain, user, tx } = context.state\n refusePrivateWrite([patch as any])\n await refuseTakenControlNos(tx, domain, [{ id, controlNo: patch.controlNo }])\n\n const supervisor = await referenceInDomain(\n getRepository(Employee, tx),\n 'supervisor' in patch ? patch.supervisor : undefined,\n domain,\n 'supervisor'\n )\n\n const department = await referenceInDomain(\n getRepository(Department, tx),\n 'department' in patch ? patch.department : undefined,\n domain,\n 'department'\n )\n\n const connectedUser = await userInDomain('user' in patch ? patch.user : undefined, domain, tx)\n\n const repository = getRepository(Employee, tx)\n const employee = await repository.findOne({\n where: { domain: { id: domain.id }, id }\n })\n\n await onUpdateEmployeeAsSystemUser(patch, context)\n\n const result = await repository.save({\n ...employee,\n ...withDays(patch),\n supervisor,\n department,\n user: connectedUser,\n updater: user\n })\n\n if (patch.photo) {\n await deleteAttachmentsByRef(null, { refBys: [result.id] }, context)\n await createAttachment(\n null,\n {\n attachment: {\n file: patch.photo,\n refType: Employee.name,\n refBy: result.id\n }\n },\n context\n )\n }\n\n return result\n }\n\n @Directive('@transaction')\n @Directive('@privilege(category: \"employee\", privilege: \"mutation\", domainOwnerGranted: true)')\n @Mutation(returns => [Employee], {\n description:\n 'Updates or creates multiple employee records based on the provided patches. New employees are created if the \"cuFlag\" is \"+\", and existing employees are updated if the \"cuFlag\" is \"M\".'\n })\n async updateMultipleEmployee(\n @Arg('patches', type => [EmployeePatch]) patches: EmployeePatch[],\n @Ctx() context: ResolverContext\n ): Promise<Employee[]> {\n const { domain, user, tx } = context.state\n refusePrivateWrite(patches as any[])\n\n let results = []\n const _createRecords = patches.filter((patch: any) => patch.cuFlag.toUpperCase() === '+')\n const _updateRecords = patches.filter((patch: any) => patch.cuFlag.toUpperCase() === 'M')\n const employeeRepo = getRepository(Employee, tx)\n await refuseTakenControlNos(tx, domain, [\n ..._createRecords.map(record => ({ controlNo: record.controlNo ?? null })),\n ..._updateRecords.map(record => ({ id: record.id, controlNo: record.controlNo }))\n ])\n\n if (_createRecords.length > 0) {\n for (let i = 0; i < _createRecords.length; i++) {\n const newRecord = _createRecords[i]\n\n const supervisor = await referenceInDomain(\n getRepository(Employee, tx),\n 'supervisor' in newRecord ? newRecord.supervisor : undefined,\n domain,\n 'supervisor'\n )\n\n const department = await referenceInDomain(\n getRepository(Department, tx),\n 'department' in newRecord ? newRecord.department : undefined,\n domain,\n 'department'\n )\n\n const connectedUser = await userInDomain('user' in newRecord ? newRecord.user : undefined, domain, tx)\n\n const result = await employeeRepo.save({\n ...withDays(newRecord),\n supervisor,\n department,\n user: connectedUser,\n domain,\n creator: user,\n updater: user\n })\n\n if (newRecord.photo) {\n await createAttachment(\n null,\n {\n attachment: {\n file: newRecord.photo,\n refType: Employee.name,\n refBy: result.id\n }\n },\n context\n )\n }\n\n results.push({ ...result, cuFlag: '+' })\n }\n }\n\n if (_updateRecords.length > 0) {\n for (let i = 0; i < _updateRecords.length; i++) {\n const updateRecord = _updateRecords[i]\n\n const supervisor = await referenceInDomain(\n getRepository(Employee, tx),\n 'supervisor' in updateRecord ? updateRecord.supervisor : undefined,\n domain,\n 'supervisor'\n )\n\n const department = await referenceInDomain(\n getRepository(Department, tx),\n 'department' in updateRecord ? updateRecord.department : undefined,\n domain,\n 'department'\n )\n\n const connectedUser = await userInDomain('user' in updateRecord ? updateRecord.user : undefined, domain, tx)\n\n const employee = await employeeRepo.findOne({\n where: { domain: { id: domain.id }, id: updateRecord.id }\n })\n\n if (!employee) {\n throw new Refusal('employee-not-found', {}, `failed to find employee to update: ${updateRecord.id}`)\n }\n\n await onUpdateEmployeeAsSystemUser(updateRecord, context)\n\n const result = await employeeRepo.save({\n ...employee,\n ...withDays(updateRecord),\n supervisor,\n department,\n user: connectedUser,\n updater: user\n })\n\n if (updateRecord.photo) {\n await deleteAttachmentsByRef(null, { refBys: [result.id] }, context)\n await createAttachment(\n null,\n {\n attachment: {\n file: updateRecord.photo,\n refType: Employee.name,\n refBy: result.id\n }\n },\n context\n )\n }\n\n results.push({ ...result, cuFlag: 'M' })\n }\n }\n\n return results\n }\n\n @Directive('@transaction')\n @Directive('@privilege(category: \"employee\", privilege: \"mutation\", domainOwnerGranted: true)')\n @Mutation(returns => Boolean, {\n description:\n 'Deletes an employee record identified by the given ID. Also deletes any attachments associated with the employee.'\n })\n async deleteEmployee(@Arg('id') id: string, @Ctx() context: ResolverContext): Promise<boolean> {\n const { domain, tx } = context.state\n\n await onDeleteEmployeeAsSystemUser(id, context)\n await getRepository(Employee, tx).delete({ domain: { id: domain.id }, id })\n await deleteAttachmentsByRef(null, { refBys: [id] }, context)\n\n return true\n }\n\n @Directive('@transaction')\n @Directive('@privilege(category: \"employee\", privilege: \"mutation\", domainOwnerGranted: true)')\n @Mutation(returns => Boolean, {\n description:\n 'Deletes multiple employee records identified by the given IDs. Also deletes any attachments associated with each employee.'\n })\n async deleteEmployees(\n @Arg('ids', type => [String]) ids: string[],\n @Ctx() context: ResolverContext\n ): Promise<boolean> {\n const { domain, tx } = context.state\n\n for (let id of ids) {\n await onDeleteEmployeeAsSystemUser(id, context)\n }\n\n await getRepository(Employee, tx).delete({\n domain: { id: domain.id },\n id: In(ids)\n })\n\n await deleteAttachmentsByRef(null, { refBys: ids }, context)\n\n return true\n }\n\n @Directive('@transaction')\n @Directive('@privilege(category: \"employee\", privilege: \"mutation\", domainOwnerGranted: true)')\n @Mutation(returns => Boolean, {\n description:\n 'Imports multiple employee records into the system. Each employee record must be provided in the EmployeePatch format.'\n })\n async importEmployees(\n @Arg('employees', type => [EmployeePatch]) employees: EmployeePatch[],\n @Ctx() context: ResolverContext\n ): Promise<boolean> {\n const { domain, tx } = context.state\n refusePrivateWrite(employees as any[])\n await refuseTakenControlNos(tx, domain, employees.map(employee => ({ id: employee.id, controlNo: employee.id ? employee.controlNo : employee.controlNo ?? null })))\n\n await Promise.all(\n employees.map(async (employee: EmployeePatch) => {\n const createdEmployee: Employee = await getRepository(Employee, tx).save({ domain, ...withDays(employee) })\n })\n )\n\n return true\n }\n\n @Directive('@transaction')\n @Directive('@privilege(category: \"employee\", privilege: \"mutation\", domainOwnerGranted: true)')\n @Mutation(returns => Employee, {\n description:\n 'Attaches an existing contact to an employee. The contact is identified by its ID and the employee is identified by their ID.'\n })\n async attachContact(\n @Arg('id') id: string,\n @Arg('contactId') contactId: string,\n @Ctx() context: ResolverContext\n ): Promise<Employee> {\n const { domain, user, tx } = context.state\n\n const employeeRepository = getRepository(Employee, tx)\n const employee = await employeeRepository.findOne({\n where: { domain: { id: domain.id }, id }\n })\n\n const contactRepository = getRepository(Contact, tx)\n const contact = await contactRepository.findOne({\n where: { domain: { id: domain.id }, id: contactId }\n })\n\n if (!contact) {\n throw Error(`Contact not found with given contactId(${contactId}).`)\n }\n\n const result = await employeeRepository.save({\n ...employee,\n name: contact.name,\n contact: { id: contactId },\n updater: user\n })\n\n return result\n }\n\n @Directive('@transaction')\n @Directive('@privilege(category: \"employee\", privilege: \"mutation\", domainOwnerGranted: true)')\n @Mutation(returns => Employee, {\n description: 'Detaches an existing contact from an employee. The employee is identified by their ID.'\n })\n async detachContact(@Arg('id') id: string, @Ctx() context: ResolverContext): Promise<Employee> {\n const { domain, user, tx } = context.state\n\n const repository = getRepository(Employee, tx)\n const employee = await repository.findOne({\n where: { domain: { id: domain.id }, id }\n })\n\n const result = await repository.save({\n ...employee,\n contact: null,\n updater: user\n })\n\n return result\n }\n\n @Directive('@transaction')\n @Directive('@privilege(category: \"user\", privilege: \"mutation\", domainOwnerGranted: true)')\n @Mutation(returns => Boolean, {\n description:\n 'Registers an existing employee as a system user, granting them access to the system. The employee is identified by their ID.'\n })\n async registerEmployeeAsSystemUser(\n @Arg('employeeId', { description: 'Employee Id' }) employeeId: string,\n @Ctx() context: ResolverContext\n ): Promise<boolean> {\n return !!(await registerEmployeeAsSystemUser(employeeId, context))\n }\n}\n"]}
|
|
@@ -90,7 +90,8 @@ tslib_1.__decorate([
|
|
|
90
90
|
tslib_1.__metadata("design:returntype", Promise)
|
|
91
91
|
], EmployeeProfileQuery.prototype, "myEmployeeProfileDocument", null);
|
|
92
92
|
exports.EmployeeProfileQuery = EmployeeProfileQuery = tslib_1.__decorate([
|
|
93
|
-
(0, type_graphql_1.Resolver)(employee_profile_1.EmployeeProfile)
|
|
93
|
+
(0, type_graphql_1.Resolver)(employee_profile_1.EmployeeProfile),
|
|
94
|
+
(0, type_graphql_1.UseMiddleware)(shell_1.SpeakRefusals)
|
|
94
95
|
], EmployeeProfileQuery);
|
|
95
96
|
/**
|
|
96
97
|
* The translator of the document's own words: the language asked for, or the reader's. Only the words the document
|
|
@@ -102,7 +103,7 @@ function documentTranslator(context, language) {
|
|
|
102
103
|
return (key, options) => String(context.t(key, options));
|
|
103
104
|
const runs = (env_1.config.get('i18n/languages', []) ?? []).map(one => one?.code);
|
|
104
105
|
if (!runs.includes(language))
|
|
105
|
-
throw new
|
|
106
|
+
throw new shell_1.Refusal('document-language-not-run', { language }, `The application does not run the language "${language}".`);
|
|
106
107
|
const fixed = context.i18next.getFixedT(language);
|
|
107
108
|
return (key, options) => String(fixed(key, options));
|
|
108
109
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"employee-profile-query.js","sourceRoot":"","sources":["../../../server/service/employee-profile/employee-profile-query.ts"],"names":[],"mappings":";;;AA+EA,gDAMC;;AArFD,+CAAmE;AAEnE,6CAA4C;AAC5C,iDAAqD;AACrD,6CAAgD;AAEhD,mDAA+C;AAC/C,+DAAwE;AACxE,yDAAoD;AACpD,qEAAyE;AACzE,2EAA+J;AAC/J,mEAAyG;AAEzG;;;;GAIG;AAEI,IAAM,oBAAoB,GAA1B,MAAM,oBAAoB;IAMzB,AAAN,KAAK,CAAC,iBAAiB,CAAQ,OAAwB;QACrD,MAAM,EAAE,MAAM,EAAE,EAAE,EAAE,GAAG,OAAO,CAAC,KAAK,CAAA;QACpC,MAAM,IAAI,GAAG,MAAM,IAAA,4BAAW,EAAC,OAAO,CAAC,CAAA;QACvC,IAAI,CAAC,IAAI,CAAC,MA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AM,GAAG,MAAM,IAAA,2CAAe,EAAC,MAAM,EAAE,KAAK,EAAE,OAAO,CAAC,CAAC,IAAI,CAAC,WAAW,EAAE,CAAA;IAC/E,OAAO;QACL,QAAQ,EAAE,IAAA,2CAAe,EAAC,IAAI,EAAE,MAAM,CAAC;QACvC,QAAQ,EAAE,mEAAmE;QAC7E,OAAO,EAAE,MAAM,CAAC,IAAI,CAAC,MAAqB,CAAC,CAAC,QAAQ,CAAC,QAAQ,CAAC;KAC/D,CAAA;AACH,CAAC;AAED,+GAA+G;AAC/G,KAAK,UAAU,kBAAkB,CAAC,OAAwB;IACxD,MAAM,EAAE,MAAM,EAAE,EAAE,EAAE,GAAG,OAAO,CAAC,KAAK,CAAA;IACpC,MAAM,SAAS,GAAG,MAAM,IAAA,qBAAa,EAAC,mBAAQ,EAAE,EAAE,CAAC,CAAC,IAAI,CAAC,EAAE,KAAK,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,EAAE,MAAM,CAAC,EAAE,EAAE,EAAE,EAAE,SAAS,EAAE,CAAC,YAAY,CAAC,EAAE,CAAC,CAAA;IAC7H,MAAM,QAAQ,GAAG,MAAM,IAAA,qBAAa,EAAC,kCAAe,EAAE,EAAE,CAAC,CAAC,IAAI,CAAC,EAAE,KAAK,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,EAAE,MAAM,CAAC,EAAE,EAAE,EAAE,EAAE,CAAC,CAAA;IAExG,OAAO,IAAA,8CAAqB,EAAC,SAAS,EAAE,QAAQ,EAAE,IAAA,gCAAO,GAAE,CAAQ,CAAA;AACrE,CAAC","sourcesContent":["import { Arg, Ctx, Directive, Query, Resolver } from 'type-graphql'\n\nimport { config } from '@things-factory/env'\nimport { getRepository } from '@things-factory/shell'\nimport { PdfService } from '@things-factory/pdf'\n\nimport { Employee } from '../employee/employee'\nimport { myEmployees, theOneEmployee } from '../employee/my-employee.js'\nimport { EmployeeProfile } from './employee-profile'\nimport { employeesWithProfiles, todayOf } from './employee-profile-rules'\nimport { profileFileName, profileFooterHtml, PROFILE_CSS, profileHtml, profilePreviewHtml, profileWordsOf, profileWorkbook } from './employee-profile-document'\nimport { EmployeeProfileFile, EmployeeProfileFormat, EmployeeWithProfile } from './employee-profile-type'\n\n/*\n * Reading profiles (ADR-0169 decisions 3 · 4): one's own under `employee-self`, every active employee's under\n * `employee-profile` - the seats that attach profiles to quotations. Neither reads the employee record beyond the\n * basics a profile sheet shows.\n */\n@Resolver(EmployeeProfile)\nexport class EmployeeProfileQuery {\n @Directive('@privilege(category: \"employee-self\", privilege: \"query\", domainOwnerGranted: true)')\n @Query(returns => EmployeeProfile, {\n nullable: true,\n description: \"Fetches the caller's own profile. Null when the caller has written none, or when the account is not linked to an employee (myEmployees tells which).\"\n })\n async myEmployeeProfile(@Ctx() context: ResolverContext): Promise<EmployeeProfile | null> {\n const { domain, tx } = context.state\n const mine = await myEmployees(context)\n if (!mine.length) return null\n\n const employee = theOneEmployee(mine, context)\n return await getRepository(EmployeeProfile, tx).findOne({ where: { domain: { id: domain.id }, employee: { id: employee.id } } })\n }\n\n @Directive('@privilege(category: \"employee-profile\", privilege: \"query\", domainOwnerGranted: true)')\n @Query(returns => [EmployeeWithProfile], {\n description:\n 'Fetches every active employee of the domain - not retired, not marked inactive - with their name, department, position, responsibility, hire day and profile; the profile is empty when they have written none.'\n })\n async employeeProfiles(@Ctx() context: ResolverContext): Promise<EmployeeWithProfile[]> {\n return await activeWithProfiles(context)\n }\n\n /*\n * The chosen people's profiles as one file to hand in with a quotation - Excel or PDF, from one layout\n * (employee-profile-document.ts). Only active employees of the domain, in the order chosen; an id that is none of\n * them is left out. The employer's name is the domain's description, as the sign-in page shows it.\n */\n @Directive('@privilege(category: \"employee-profile\", privilege: \"query\", domainOwnerGranted: true)')\n @Query(returns => EmployeeProfileFile, { description: \"Prints the chosen active employees' profiles as one Excel workbook or PDF, in the order chosen.\" })\n async employeeProfileDocument(\n @Arg('employeeIds', type => [String], { description: 'The employees, in the order their profiles are printed.' }) employeeIds: string[],\n @Arg('format', type => EmployeeProfileFormat, { description: 'Excel or PDF.' }) format: EmployeeProfileFormat,\n @Arg('language', { nullable: true, description: \"The language of the document's own words, one the application runs - the reader's when empty.\" }) language: string,\n @Ctx() context: ResolverContext\n ): Promise<EmployeeProfileFile> {\n const everyone = await activeWithProfiles(context)\n return await documentOf(employeeIds.map(id => everyone.find(one => one.employeeId === id)).filter(Boolean), format, context, language)\n }\n\n /* One's own profile as the document sales will hand in - to see it while writing it. */\n @Directive('@privilege(category: \"employee-self\", privilege: \"query\", domainOwnerGranted: true)')\n @Query(returns => EmployeeProfileFile, { description: \"Prints the caller's own profile as the Excel workbook or PDF a quotation attaches.\" })\n async myEmployeeProfileDocument(\n @Arg('format', type => EmployeeProfileFormat, { description: 'Excel or PDF.' }) format: EmployeeProfileFormat,\n @Arg('language', { nullable: true, description: \"The language of the document's own words, one the application runs - the reader's when empty.\" }) language: string,\n @Ctx() context: ResolverContext\n ): Promise<EmployeeProfileFile> {\n const mine = theOneEmployee(await myEmployees(context), context)\n const everyone = await activeWithProfiles(context)\n return await documentOf(everyone.filter(one => one.employeeId === mine.id), format, context, language)\n }\n}\n\n/**\n * The translator of the document's own words: the language asked for, or the reader's. Only the words the document\n * itself prints follow it - names, summaries and projects stay as their employees wrote them. A language the\n * application does not run (`i18n.languages`) is refused rather than printed half in another.\n */\nexport function documentTranslator(context: any, language?: string | null): (key: string, options?: any) => string {\n if (!language) return (key, options) => String(context.t(key, options))\n const runs = ((config.get('i18n/languages', []) as { code?: string }[]) ?? []).map(one => one?.code)\n if (!runs.includes(language)) throw new Error(`The application does not run the language \"${language}\".`)\n const fixed = context.i18next.getFixedT(language)\n return (key, options) => String(fixed(key, options))\n}\n\n/** The people's profiles as one file - Excel or PDF from one layout, the employer named as the sign-in page names it. */\nasync function documentOf(people: EmployeeWithProfile[], format: EmployeeProfileFormat, context: ResolverContext, language?: string): Promise<EmployeeProfileFile> {\n const t = documentTranslator(context, language)\n const words = profileWordsOf(t)\n const company = context.state.domain.description || context.state.domain.name\n const word = t('text.employee-profile-file')\n\n if (format === EmployeeProfileFormat.HTML) {\n return { fileName: profileFileName(word, 'html'), mimeType: 'text/html', content: Buffer.from(profilePreviewHtml(people, words, company), 'utf8').toString('base64') }\n }\n\n if (format === EmployeeProfileFormat.PDF) {\n const body = `<style>${PROFILE_CSS}</style>${profileHtml(people, words, company)}`\n const pdf = await new PdfService().generatePdf({ content_template: '{{{body}}}', footer_template: profileFooterHtml(company, words), page_size: 'A4' }, { body })\n return { fileName: profileFileName(word, 'pdf'), mimeType: 'application/pdf', content: pdf.toString('base64') }\n }\n\n const buffer = await profileWorkbook(people, words, company).xlsx.writeBuffer()\n return {\n fileName: profileFileName(word, 'xlsx'),\n mimeType: 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',\n content: Buffer.from(buffer as ArrayBuffer).toString('base64')\n }\n}\n\n/** Every active employee of the domain with their profile - the list and the document read the same people. */\nasync function activeWithProfiles(context: ResolverContext): Promise<EmployeeWithProfile[]> {\n const { domain, tx } = context.state\n const employees = await getRepository(Employee, tx).find({ where: { domain: { id: domain.id } }, relations: ['department'] })\n const profiles = await getRepository(EmployeeProfile, tx).find({ where: { domain: { id: domain.id } } })\n\n return employeesWithProfiles(employees, profiles, todayOf()) as any\n}\n"]}
|
|
1
|
+
{"version":3,"file":"employee-profile-query.js","sourceRoot":"","sources":["../../../server/service/employee-profile/employee-profile-query.ts"],"names":[],"mappings":";;;AAgFA,gDAMC;;AAtFD,+CAAkF;AAElF,6CAA4C;AAC5C,iDAA6E;AAC7E,6CAAgD;AAEhD,mDAA+C;AAC/C,+DAAwE;AACxE,yDAAoD;AACpD,qEAAyE;AACzE,2EAA+J;AAC/J,mEAAyG;AAEzG;;;;GAIG;AAGI,IAAM,oBAAoB,GAA1B,MAAM,oBAAoB;IAMzB,AAAN,KAAK,CAAC,iBAAiB,CAAQ,OAAwB;QACrD,MAAM,EAAE,MAAM,EAAE,EAAE,EAAE,GAAG,OAAO,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-graphql'\n\nimport { config } from '@things-factory/env'\nimport { getRepository, Refusal, SpeakRefusals } from '@things-factory/shell'\nimport { PdfService } from '@things-factory/pdf'\n\nimport { Employee } from '../employee/employee'\nimport { myEmployees, theOneEmployee } from '../employee/my-employee.js'\nimport { EmployeeProfile } from './employee-profile'\nimport { employeesWithProfiles, todayOf } from './employee-profile-rules'\nimport { profileFileName, profileFooterHtml, PROFILE_CSS, profileHtml, profilePreviewHtml, profileWordsOf, profileWorkbook } from './employee-profile-document'\nimport { EmployeeProfileFile, EmployeeProfileFormat, EmployeeWithProfile } from './employee-profile-type'\n\n/*\n * Reading profiles (ADR-0169 decisions 3 · 4): one's own under `employee-self`, every active employee's under\n * `employee-profile` - the seats that attach profiles to quotations. Neither reads the employee record beyond the\n * basics a profile sheet shows.\n */\n@Resolver(EmployeeProfile)\n@UseMiddleware(SpeakRefusals)\nexport class EmployeeProfileQuery {\n @Directive('@privilege(category: \"employee-self\", privilege: \"query\", domainOwnerGranted: true)')\n @Query(returns => EmployeeProfile, {\n nullable: true,\n description: \"Fetches the caller's own profile. Null when the caller has written none, or when the account is not linked to an employee (myEmployees tells which).\"\n })\n async myEmployeeProfile(@Ctx() context: ResolverContext): Promise<EmployeeProfile | null> {\n const { domain, tx } = context.state\n const mine = await myEmployees(context)\n if (!mine.length) return null\n\n const employee = theOneEmployee(mine, context)\n return await getRepository(EmployeeProfile, tx).findOne({ where: { domain: { id: domain.id }, employee: { id: employee.id } } })\n }\n\n @Directive('@privilege(category: \"employee-profile\", privilege: \"query\", domainOwnerGranted: true)')\n @Query(returns => [EmployeeWithProfile], {\n description:\n 'Fetches every active employee of the domain - not retired, not marked inactive - with their name, department, position, responsibility, hire day and profile; the profile is empty when they have written none.'\n })\n async employeeProfiles(@Ctx() context: ResolverContext): Promise<EmployeeWithProfile[]> {\n return await activeWithProfiles(context)\n }\n\n /*\n * The chosen people's profiles as one file to hand in with a quotation - Excel or PDF, from one layout\n * (employee-profile-document.ts). Only active employees of the domain, in the order chosen; an id that is none of\n * them is left out. The employer's name is the domain's description, as the sign-in page shows it.\n */\n @Directive('@privilege(category: \"employee-profile\", privilege: \"query\", domainOwnerGranted: true)')\n @Query(returns => EmployeeProfileFile, { description: \"Prints the chosen active employees' profiles as one Excel workbook or PDF, in the order chosen.\" })\n async employeeProfileDocument(\n @Arg('employeeIds', type => [String], { description: 'The employees, in the order their profiles are printed.' }) employeeIds: string[],\n @Arg('format', type => EmployeeProfileFormat, { description: 'Excel or PDF.' }) format: EmployeeProfileFormat,\n @Arg('language', { nullable: true, description: \"The language of the document's own words, one the application runs - the reader's when empty.\" }) language: string,\n @Ctx() context: ResolverContext\n ): Promise<EmployeeProfileFile> {\n const everyone = await activeWithProfiles(context)\n return await documentOf(employeeIds.map(id => everyone.find(one => one.employeeId === id)).filter(Boolean), format, context, language)\n }\n\n /* One's own profile as the document sales will hand in - to see it while writing it. */\n @Directive('@privilege(category: \"employee-self\", privilege: \"query\", domainOwnerGranted: true)')\n @Query(returns => EmployeeProfileFile, { description: \"Prints the caller's own profile as the Excel workbook or PDF a quotation attaches.\" })\n async myEmployeeProfileDocument(\n @Arg('format', type => EmployeeProfileFormat, { description: 'Excel or PDF.' }) format: EmployeeProfileFormat,\n @Arg('language', { nullable: true, description: \"The language of the document's own words, one the application runs - the reader's when empty.\" }) language: string,\n @Ctx() context: ResolverContext\n ): Promise<EmployeeProfileFile> {\n const mine = theOneEmployee(await myEmployees(context), context)\n const everyone = await activeWithProfiles(context)\n return await documentOf(everyone.filter(one => one.employeeId === mine.id), format, context, language)\n }\n}\n\n/**\n * The translator of the document's own words: the language asked for, or the reader's. Only the words the document\n * itself prints follow it - names, summaries and projects stay as their employees wrote them. A language the\n * application does not run (`i18n.languages`) is refused rather than printed half in another.\n */\nexport function documentTranslator(context: any, language?: string | null): (key: string, options?: any) => string {\n if (!language) return (key, options) => String(context.t(key, options))\n const runs = ((config.get('i18n/languages', []) as { code?: string }[]) ?? []).map(one => one?.code)\n if (!runs.includes(language)) throw new Refusal('document-language-not-run', { language }, `The application does not run the language \"${language}\".`)\n const fixed = context.i18next.getFixedT(language)\n return (key, options) => String(fixed(key, options))\n}\n\n/** The people's profiles as one file - Excel or PDF from one layout, the employer named as the sign-in page names it. */\nasync function documentOf(people: EmployeeWithProfile[], format: EmployeeProfileFormat, context: ResolverContext, language?: string): Promise<EmployeeProfileFile> {\n const t = documentTranslator(context, language)\n const words = profileWordsOf(t)\n const company = context.state.domain.description || context.state.domain.name\n const word = t('text.employee-profile-file')\n\n if (format === EmployeeProfileFormat.HTML) {\n return { fileName: profileFileName(word, 'html'), mimeType: 'text/html', content: Buffer.from(profilePreviewHtml(people, words, company), 'utf8').toString('base64') }\n }\n\n if (format === EmployeeProfileFormat.PDF) {\n const body = `<style>${PROFILE_CSS}</style>${profileHtml(people, words, company)}`\n const pdf = await new PdfService().generatePdf({ content_template: '{{{body}}}', footer_template: profileFooterHtml(company, words), page_size: 'A4' }, { body })\n return { fileName: profileFileName(word, 'pdf'), mimeType: 'application/pdf', content: pdf.toString('base64') }\n }\n\n const buffer = await profileWorkbook(people, words, company).xlsx.writeBuffer()\n return {\n fileName: profileFileName(word, 'xlsx'),\n mimeType: 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',\n content: Buffer.from(buffer as ArrayBuffer).toString('base64')\n }\n}\n\n/** Every active employee of the domain with their profile - the list and the document read the same people. */\nasync function activeWithProfiles(context: ResolverContext): Promise<EmployeeWithProfile[]> {\n const { domain, tx } = context.state\n const employees = await getRepository(Employee, tx).find({ where: { domain: { id: domain.id } }, relations: ['department'] })\n const profiles = await getRepository(EmployeeProfile, tx).find({ where: { domain: { id: domain.id } } })\n\n return employeesWithProfiles(employees, profiles, todayOf()) as any\n}\n"]}
|