@things-factory/organization 10.1.182 → 10.1.183
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/tsconfig.tsbuildinfo +1 -1
- package/dist-server/service/employee/employee-history.js +2 -0
- package/dist-server/service/employee/employee-history.js.map +1 -1
- package/dist-server/service/employee/employee-mutation.js +5 -0
- package/dist-server/service/employee/employee-mutation.js.map +1 -1
- package/dist-server/service/employee/employee-private.d.ts +9 -0
- package/dist-server/service/employee/employee-private.js +26 -0
- package/dist-server/service/employee/employee-private.js.map +1 -0
- package/dist-server/service/employee/employee.js +2 -0
- package/dist-server/service/employee/employee.js.map +1 -1
- package/dist-server/tsconfig.tsbuildinfo +1 -1
- package/package.json +5 -5
- package/tests/employee-private.test.ts +26 -0
|
@@ -124,11 +124,13 @@ tslib_1.__decorate([
|
|
|
124
124
|
], EmployeeHistory.prototype, "emergencyContactPhone", void 0);
|
|
125
125
|
tslib_1.__decorate([
|
|
126
126
|
(0, typeorm_1.Column)({ nullable: true }),
|
|
127
|
+
(0, type_graphql_1.Directive)('@privilege(category: "employee-private", privilege: "query", domainOwnerGranted: true)'),
|
|
127
128
|
(0, type_graphql_1.Field)({ nullable: true }),
|
|
128
129
|
tslib_1.__metadata("design:type", String)
|
|
129
130
|
], EmployeeHistory.prototype, "bankAccount", void 0);
|
|
130
131
|
tslib_1.__decorate([
|
|
131
132
|
(0, typeorm_1.Column)({ nullable: true }),
|
|
133
|
+
(0, type_graphql_1.Directive)('@privilege(category: "employee-private", privilege: "query", domainOwnerGranted: true)'),
|
|
132
134
|
(0, type_graphql_1.Field)({ nullable: true }),
|
|
133
135
|
tslib_1.__metadata("design:type", String)
|
|
134
136
|
], EmployeeHistory.prototype, "bankName", void 0);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"employee-history.js","sourceRoot":"","sources":["../../../server/service/employee/employee-history.ts"],"names":[],"mappings":";;;;AAAA,+CAAoD;AACpD,q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AA,eAAK,EACJ,uBAAuB,EACvB,CAAC,eAAgC,EAAE,EAAE,CAAC,CAAC,eAAe,CAAC,UAAU,EAAE,eAAe,CAAC,OAAO,CAAC,EAC3F,EAAE,MAAM,EAAE,IAAI,EAAE,CACjB;IACA,IAAA,eAAK,EACJ,uBAAuB,EACvB,CAAC,eAAgC,EAAE,EAAE,CAAC,CAAC,eAAe,CAAC,MAAM,EAAE,eAAe,CAAC,UAAU,EAAE,eAAe,CAAC,OAAO,CAAC,EACnH,EAAE,MAAM,EAAE,IAAI,EAAE,CACjB;IACA,IAAA,yBAAU,EAAC,EAAE,WAAW,EAAE,4BAA4B,EAAE,CAAC;GAC7C,eAAe,CA0J3B","sourcesContent":["import { Field, ID, ObjectType } from 'type-graphql'\nimport { Column, Entity, Index, ManyToOne, OneToMany, PrimaryGeneratedColumn, RelationId } from 'typeorm'\n\nimport {\n HistoryActionColumn,\n HistoryActionType,\n HistoryEntityInterface,\n HistoryOriginalIdColumn\n} from '@operato/typeorm-history'\n\nimport { User } from '@things-factory/auth-base'\nimport { Contact } from '@things-factory/contact'\n\nimport { config } from '@things-factory/env'\nimport { Domain } from '@things-factory/shell'\n\nimport { Employee, EmployeeType } from './employee'\nimport { Department } from '../department/department'\n\nconst ORMCONFIG = config.get('ormconfig', {})\nconst DATABASE_TYPE = ORMCONFIG.type\n\n@Entity()\n@Index(\n 'ix_employee_history_0',\n (employeeHistory: EmployeeHistory) => [employeeHistory.originalId, employeeHistory.version],\n { unique: true }\n)\n@Index(\n 'ix_employee_history_1',\n (employeeHistory: EmployeeHistory) => [employeeHistory.domain, employeeHistory.originalId, employeeHistory.version],\n { unique: true }\n)\n@ObjectType({ description: 'History Entity of Employee' })\nexport class EmployeeHistory implements HistoryEntityInterface<Employee> {\n @PrimaryGeneratedColumn('uuid')\n @Field(type => ID)\n readonly id: string\n\n @Column({ nullable: true, default: 1 })\n @Field({ nullable: true })\n version?: number = 1\n\n @ManyToOne(type => Domain)\n @Field(type => Domain)\n domain?: Domain\n\n @RelationId((employee: Employee) => employee.domain)\n domainId?: string\n\n @Column()\n @Field()\n controlNo: string\n\n @Column()\n @Field({ nullable: true })\n name?: string\n\n @Column({ nullable: true })\n @Field({ nullable: true })\n alias?: string\n\n @Column({ nullable: true })\n @Field({ nullable: true })\n jobResponsibility?: string\n\n @Column({ nullable: true })\n @Field({ nullable: true })\n jobPosition?: string\n\n @Column({ nullable: true })\n @Field({ nullable: true })\n note?: string\n\n @ManyToOne(type => Employee, supervisor => supervisor.supervises, { nullable: true })\n @Field({ nullable: true })\n supervisor?: Employee\n\n @RelationId((employee: Employee) => employee.supervisor)\n supervisorId?: string\n\n @OneToMany(type => Employee, employee => employee.supervisor)\n @Field(type => [Employee])\n supervises?: Employee[]\n\n @OneToMany(type => Department, department => department.manager)\n @Field(type => [Department])\n manages?: Department[]\n\n @Column({ nullable: true })\n @Field({ nullable: true })\n active?: boolean\n\n @Column({ nullable: true })\n @Field({ nullable: true })\n type?: EmployeeType\n\n @Column({ nullable: true })\n @Field({ nullable: true, description: 'The hire day in YYYY-MM-DD format' })\n hiredOn?: string\n\n @Column({ nullable: true })\n @Field({ nullable: true, description: 'The retire day in YYYY-MM-DD format' })\n retiredOn?: string\n\n @Column({ nullable: true })\n @Field({ nullable: true })\n extension?: string\n\n @Column({ nullable: true })\n @Field({ nullable: true })\n emergencyContact?: string\n\n @Column({ nullable: true })\n @Field({ nullable: true })\n emergencyContactPhone?: string\n\n @Column({ nullable: true })\n @Field({ nullable: true })\n bankAccount?: string\n\n @Column({ nullable: true })\n @Field({ nullable: true })\n bankName?: string\n\n @Column({ nullable: true })\n @Field({ nullable: true })\n createdAt?: Date\n\n @Column({ nullable: true })\n @Field({ nullable: true })\n updatedAt?: Date\n\n @Column({ nullable: true })\n @Field({ nullable: true })\n deletedAt?: Date\n\n @ManyToOne(type => User, { nullable: true })\n @Field(type => User, { nullable: true })\n creator?: User\n\n @RelationId((employee: Employee) => employee.creator)\n creatorId?: string\n\n @ManyToOne(type => User, { nullable: true })\n @Field(type => User, { nullable: true })\n updater?: User\n\n @RelationId((employee: Employee) => employee.updater)\n updaterId?: string\n\n @Field(type => String, { nullable: true })\n photo?: string\n\n @ManyToOne(type => User, { nullable: true })\n @Field({ nullable: true })\n user?: User\n\n @RelationId((employee: Employee) => employee.user)\n userId?: string\n\n @ManyToOne(type => Contact, { nullable: true })\n @Field({ nullable: true })\n contact?: Contact\n\n @RelationId((employee: Employee) => employee.contact)\n contactId?: string\n\n @HistoryOriginalIdColumn()\n public originalId!: string\n\n @HistoryActionColumn({\n nullable: false,\n type:\n DATABASE_TYPE == 'postgres' || DATABASE_TYPE == 'mysql' || DATABASE_TYPE == 'mariadb'\n ? 'enum'\n : DATABASE_TYPE == 'oracle'\n ? 'varchar2'\n : DATABASE_TYPE == 'mssql'\n ? 'nvarchar'\n : 'varchar',\n enum:\n DATABASE_TYPE == 'postgres' || DATABASE_TYPE == 'mysql' || DATABASE_TYPE == 'mariadb'\n ? HistoryActionType\n : undefined,\n length: DATABASE_TYPE == 'postgres' || DATABASE_TYPE == 'mysql' || DATABASE_TYPE == 'mariadb' ? undefined : 10\n })\n public action!: HistoryActionType\n}\n"]}
|
|
1
|
+
{"version":3,"file":"employee-history.js","sourceRoot":"","sources":["../../../server/service/employee/employee-history.ts"],"names":[],"mappings":";;;;AAAA,+CAA+D;AAC/D,qCAAyG;AAEzG,8DAKiC;AAEjC,yDAAgD;AAChD,qDAAiD;AAEjD,6CAA4C;AAC5C,iDAA8C;AAE9C,yCAAmD;AACnD,yDAAqD;AAErD,MAAM,SAAS,GAAG,YAAM,CAAC,GAAG,CAAC,WAAW,EAAE,EAAE,CAAC,CAAA;AAC7C,MAAM,aAAa,GAAG,SAAS,CAAC,IAAI,CAAA;AAc7B,IAAM,eAAe,GAArB,MAAM,eAAe;IAArB;QAOL,YAAO,GAAY,CAAC,CAAA;IAsJtB,CAAC;CAAA,CAAA;AA7JY,0CAAe;AAGjB;IAFR,IAAA,gCAAsB,EAAC,MA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AAE,MAAM,EAAE,IAAI,EAAE,CACjB;IACA,IAAA,yBAAU,EAAC,EAAE,WAAW,EAAE,4BAA4B,EAAE,CAAC;GAC7C,eAAe,CA6J3B","sourcesContent":["import { Directive, Field, ID, ObjectType } from 'type-graphql'\nimport { Column, Entity, Index, ManyToOne, OneToMany, PrimaryGeneratedColumn, RelationId } from 'typeorm'\n\nimport {\n HistoryActionColumn,\n HistoryActionType,\n HistoryEntityInterface,\n HistoryOriginalIdColumn\n} from '@operato/typeorm-history'\n\nimport { User } from '@things-factory/auth-base'\nimport { Contact } from '@things-factory/contact'\n\nimport { config } from '@things-factory/env'\nimport { Domain } from '@things-factory/shell'\n\nimport { Employee, EmployeeType } from './employee'\nimport { Department } from '../department/department'\n\nconst ORMCONFIG = config.get('ormconfig', {})\nconst DATABASE_TYPE = ORMCONFIG.type\n\n@Entity()\n@Index(\n 'ix_employee_history_0',\n (employeeHistory: EmployeeHistory) => [employeeHistory.originalId, employeeHistory.version],\n { unique: true }\n)\n@Index(\n 'ix_employee_history_1',\n (employeeHistory: EmployeeHistory) => [employeeHistory.domain, employeeHistory.originalId, employeeHistory.version],\n { unique: true }\n)\n@ObjectType({ description: 'History Entity of Employee' })\nexport class EmployeeHistory implements HistoryEntityInterface<Employee> {\n @PrimaryGeneratedColumn('uuid')\n @Field(type => ID)\n readonly id: string\n\n @Column({ nullable: true, default: 1 })\n @Field({ nullable: true })\n version?: number = 1\n\n @ManyToOne(type => Domain)\n @Field(type => Domain)\n domain?: Domain\n\n @RelationId((employee: Employee) => employee.domain)\n domainId?: string\n\n @Column()\n @Field()\n controlNo: string\n\n @Column()\n @Field({ nullable: true })\n name?: string\n\n @Column({ nullable: true })\n @Field({ nullable: true })\n alias?: string\n\n @Column({ nullable: true })\n @Field({ nullable: true })\n jobResponsibility?: string\n\n @Column({ nullable: true })\n @Field({ nullable: true })\n jobPosition?: string\n\n @Column({ nullable: true })\n @Field({ nullable: true })\n note?: string\n\n @ManyToOne(type => Employee, supervisor => supervisor.supervises, { nullable: true })\n @Field({ nullable: true })\n supervisor?: Employee\n\n @RelationId((employee: Employee) => employee.supervisor)\n supervisorId?: string\n\n @OneToMany(type => Employee, employee => employee.supervisor)\n @Field(type => [Employee])\n supervises?: Employee[]\n\n @OneToMany(type => Department, department => department.manager)\n @Field(type => [Department])\n manages?: Department[]\n\n @Column({ nullable: true })\n @Field({ nullable: true })\n active?: boolean\n\n @Column({ nullable: true })\n @Field({ nullable: true })\n type?: EmployeeType\n\n @Column({ nullable: true })\n @Field({ nullable: true, description: 'The hire day in YYYY-MM-DD format' })\n hiredOn?: string\n\n @Column({ nullable: true })\n @Field({ nullable: true, description: 'The retire day in YYYY-MM-DD format' })\n retiredOn?: string\n\n @Column({ nullable: true })\n @Field({ nullable: true })\n extension?: string\n\n @Column({ nullable: true })\n @Field({ nullable: true })\n emergencyContact?: string\n\n @Column({ nullable: true })\n @Field({ nullable: true })\n emergencyContactPhone?: string\n\n /* The pay account is HR-payroll's (ADR-0139), not the roster's. */\n @Column({ nullable: true })\n @Directive('@privilege(category: \"employee-private\", privilege: \"query\", domainOwnerGranted: true)')\n @Field({ nullable: true })\n bankAccount?: string\n\n @Column({ nullable: true })\n @Directive('@privilege(category: \"employee-private\", privilege: \"query\", domainOwnerGranted: true)')\n @Field({ nullable: true })\n bankName?: string\n\n @Column({ nullable: true })\n @Field({ nullable: true })\n createdAt?: Date\n\n @Column({ nullable: true })\n @Field({ nullable: true })\n updatedAt?: Date\n\n @Column({ nullable: true })\n @Field({ nullable: true })\n deletedAt?: Date\n\n @ManyToOne(type => User, { nullable: true })\n @Field(type => User, { nullable: true })\n creator?: User\n\n @RelationId((employee: Employee) => employee.creator)\n creatorId?: string\n\n @ManyToOne(type => User, { nullable: true })\n @Field(type => User, { nullable: true })\n updater?: User\n\n @RelationId((employee: Employee) => employee.updater)\n updaterId?: string\n\n @Field(type => String, { nullable: true })\n photo?: string\n\n @ManyToOne(type => User, { nullable: true })\n @Field({ nullable: true })\n user?: User\n\n @RelationId((employee: Employee) => employee.user)\n userId?: string\n\n @ManyToOne(type => Contact, { nullable: true })\n @Field({ nullable: true })\n contact?: Contact\n\n @RelationId((employee: Employee) => employee.contact)\n contactId?: string\n\n @HistoryOriginalIdColumn()\n public originalId!: string\n\n @HistoryActionColumn({\n nullable: false,\n type:\n DATABASE_TYPE == 'postgres' || DATABASE_TYPE == 'mysql' || DATABASE_TYPE == 'mariadb'\n ? 'enum'\n : DATABASE_TYPE == 'oracle'\n ? 'varchar2'\n : DATABASE_TYPE == 'mssql'\n ? 'nvarchar'\n : 'varchar',\n enum:\n DATABASE_TYPE == 'postgres' || DATABASE_TYPE == 'mysql' || DATABASE_TYPE == 'mariadb'\n ? HistoryActionType\n : undefined,\n length: DATABASE_TYPE == 'postgres' || DATABASE_TYPE == 'mysql' || DATABASE_TYPE == 'mariadb' ? undefined : 10\n })\n public action!: HistoryActionType\n}\n"]}
|
|
@@ -11,11 +11,13 @@ const employee_1 = require("./employee");
|
|
|
11
11
|
const employee_type_1 = require("./employee-type");
|
|
12
12
|
const department_1 = require("../department/department");
|
|
13
13
|
const employee_day_1 = require("./employee-day");
|
|
14
|
+
const employee_private_1 = require("./employee-private");
|
|
14
15
|
const domain_reference_1 = require("../domain-reference");
|
|
15
16
|
const register_employee_as_system_user_1 = require("../../controllers/register-employee-as-system-user");
|
|
16
17
|
let EmployeeMutation = class EmployeeMutation {
|
|
17
18
|
async createEmployee(employee, context) {
|
|
18
19
|
const { domain, user, tx } = context.state;
|
|
20
|
+
await (0, employee_private_1.refusePrivateWrite)([employee], context);
|
|
19
21
|
const supervisor = await (0, domain_reference_1.referenceInDomain)((0, shell_1.getRepository)(employee_1.Employee, tx), 'supervisor' in employee ? employee.supervisor : undefined, domain, 'supervisor');
|
|
20
22
|
const department = await (0, domain_reference_1.referenceInDomain)((0, shell_1.getRepository)(department_1.Department, tx), 'department' in employee ? employee.department : undefined, domain, 'department');
|
|
21
23
|
const connectedUser = await (0, domain_reference_1.userInDomain)('user' in employee ? employee.user : undefined, domain, tx);
|
|
@@ -41,6 +43,7 @@ let EmployeeMutation = class EmployeeMutation {
|
|
|
41
43
|
}
|
|
42
44
|
async updateEmployee(id, patch, context) {
|
|
43
45
|
const { domain, user, tx } = context.state;
|
|
46
|
+
await (0, employee_private_1.refusePrivateWrite)([patch], context);
|
|
44
47
|
const supervisor = await (0, domain_reference_1.referenceInDomain)((0, shell_1.getRepository)(employee_1.Employee, tx), 'supervisor' in patch ? patch.supervisor : undefined, domain, 'supervisor');
|
|
45
48
|
const department = await (0, domain_reference_1.referenceInDomain)((0, shell_1.getRepository)(department_1.Department, tx), 'department' in patch ? patch.department : undefined, domain, 'department');
|
|
46
49
|
const connectedUser = await (0, domain_reference_1.userInDomain)('user' in patch ? patch.user : undefined, domain, tx);
|
|
@@ -71,6 +74,7 @@ let EmployeeMutation = class EmployeeMutation {
|
|
|
71
74
|
}
|
|
72
75
|
async updateMultipleEmployee(patches, context) {
|
|
73
76
|
const { domain, user, tx } = context.state;
|
|
77
|
+
await (0, employee_private_1.refusePrivateWrite)(patches, context);
|
|
74
78
|
let results = [];
|
|
75
79
|
const _createRecords = patches.filter((patch) => patch.cuFlag.toUpperCase() === '+');
|
|
76
80
|
const _updateRecords = patches.filter((patch) => patch.cuFlag.toUpperCase() === 'M');
|
|
@@ -159,6 +163,7 @@ let EmployeeMutation = class EmployeeMutation {
|
|
|
159
163
|
}
|
|
160
164
|
async importEmployees(employees, context) {
|
|
161
165
|
const { domain, tx } = context.state;
|
|
166
|
+
await (0, employee_private_1.refusePrivateWrite)(employees, context);
|
|
162
167
|
await Promise.all(employees.map(async (employee) => {
|
|
163
168
|
const createdEmployee = await (0, shell_1.getRepository)(employee_1.Employee, tx).save({ domain, ...(0, employee_day_1.withDays)(employee) });
|
|
164
169
|
}));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"employee-mutation.js","sourceRoot":"","sources":["../../../server/service/employee/employee-mutation.ts"],"names":[],"mappings":";;;;AAA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zC,mBAAA,IAAA,kBAAG,GAAE,CAAA;;;;uDAWP;AAQK;IANL,IAAA,wBAAS,EAAC,cAAc,CAAC;IACzB,IAAA,wBAAS,EAAC,mFAAmF,CAAC;IAC9F,IAAA,uBAAQ,EAAC,OAAO,CAAC,EAAE,CAAC,mBAAQ,EAAE;QAC7B,WAAW,EACT,8HAA8H;KACjI,CAAC;IAEC,mBAAA,IAAA,kBAAG,EAAC,IAAI,CAAC,CAAA;IACT,mBAAA,IAAA,kBAAG,EAAC,WAAW,CAAC,CAAA;IAChB,mBAAA,IAAA,kBAAG,GAAE,CAAA;;;;qDA0BP;AAOK;IALL,IAAA,wBAAS,EAAC,cAAc,CAAC;IACzB,IAAA,wBAAS,EAAC,mFAAmF,CAAC;IAC9F,IAAA,uBAAQ,EAAC,OAAO,CAAC,EAAE,CAAC,mBAAQ,EAAE;QAC7B,WAAW,EAAE,wFAAwF;KACtG,CAAC;IACmB,mBAAA,IAAA,kBAAG,EAAC,IAAI,CAAC,CAAA;IAAc,mBAAA,IAAA,kBAAG,GAAE,CAAA;;;;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;2BAvXU,gBAAgB;IAD5B,IAAA,uBAAQ,EAAC,mBAAQ,CAAC;GACN,gBAAgB,CAwX5B","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 { 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\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 @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\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\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\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,+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,MAAM,IAAA,qCAAkB,EAAC,C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AAS,EAAC,mFAAmF,CAAC;IAC9F,IAAA,uBAAQ,EAAC,OAAO,CAAC,EAAE,CAAC,mBAAQ,EAAE;QAC7B,WAAW,EACT,8HAA8H;KACjI,CAAC;IAEC,mBAAA,IAAA,kBAAG,EAAC,IAAI,CAAC,CAAA;IACT,mBAAA,IAAA,kBAAG,EAAC,WAAW,CAAC,CAAA;IAChB,mBAAA,IAAA,kBAAG,GAAE,CAAA;;;;qDA0BP;AAOK;IALL,IAAA,wBAAS,EAAC,cAAc,CAAC;IACzB,IAAA,wBAAS,EAAC,mFAAmF,CAAC;IAC9F,IAAA,uBAAQ,EAAC,OAAO,CAAC,EAAE,CAAC,mBAAQ,EAAE;QAC7B,WAAW,EAAE,wFAAwF;KACtG,CAAC;IACmB,mBAAA,IAAA,kBAAG,EAAC,IAAI,CAAC,CAAA;IAAc,mBAAA,IAAA,kBAAG,GAAE,CAAA;;;;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;2BA3XU,gBAAgB;IAD5B,IAAA,uBAAQ,EAAC,mBAAQ,CAAC;GACN,gBAAgB,CA4X5B","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 await refusePrivateWrite([employee as any], context)\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 @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 await refusePrivateWrite([patch as any], context)\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 await refusePrivateWrite(patches as any[], context)\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 await refusePrivateWrite(employees as any[], context)\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"]}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* An employee's pay account - where their pay goes. Who was paid what is HR-payroll's fact (ADR-0139), so these fields
|
|
3
|
+
* are read and written under `employee-private`, apart from the roster every seat reads (`employee`).
|
|
4
|
+
*/
|
|
5
|
+
export declare const EMPLOYEE_PRIVATE_FIELDS: readonly ["bankAccount", "bankName"];
|
|
6
|
+
/** The private fields a patch writes - a field left out of the patch is not written. */
|
|
7
|
+
export declare function privateFieldsOf(patch: Record<string, unknown> | null | undefined): string[];
|
|
8
|
+
/** Refuses a write of the pay account by someone who may not change it. */
|
|
9
|
+
export declare function refusePrivateWrite(patches: (Record<string, unknown> | null | undefined)[], context: any): Promise<void>;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.EMPLOYEE_PRIVATE_FIELDS = void 0;
|
|
4
|
+
exports.privateFieldsOf = privateFieldsOf;
|
|
5
|
+
exports.refusePrivateWrite = refusePrivateWrite;
|
|
6
|
+
const auth_base_1 = require("@things-factory/auth-base");
|
|
7
|
+
/**
|
|
8
|
+
* An employee's pay account - where their pay goes. Who was paid what is HR-payroll's fact (ADR-0139), so these fields
|
|
9
|
+
* are read and written under `employee-private`, apart from the roster every seat reads (`employee`).
|
|
10
|
+
*/
|
|
11
|
+
exports.EMPLOYEE_PRIVATE_FIELDS = ['bankAccount', 'bankName'];
|
|
12
|
+
/** The private fields a patch writes - a field left out of the patch is not written. */
|
|
13
|
+
function privateFieldsOf(patch) {
|
|
14
|
+
return exports.EMPLOYEE_PRIVATE_FIELDS.filter(field => !!patch && field in patch && patch[field] !== undefined);
|
|
15
|
+
}
|
|
16
|
+
/** Refuses a write of the pay account by someone who may not change it. */
|
|
17
|
+
async function refusePrivateWrite(patches, context) {
|
|
18
|
+
const written = [...new Set(patches.flatMap(privateFieldsOf))];
|
|
19
|
+
if (!written.length)
|
|
20
|
+
return;
|
|
21
|
+
const { domain, user, unsafeIP, prohibitedPrivileges } = context.state;
|
|
22
|
+
if (await (0, auth_base_1.checkPermission)({ category: 'employee-private', privilege: 'mutation', owner: true }, user, domain, unsafeIP, prohibitedPrivileges))
|
|
23
|
+
return;
|
|
24
|
+
throw new Error(`${written.join(', ')} - an employee's pay account is changed by whoever keeps pay (employee-private).`);
|
|
25
|
+
}
|
|
26
|
+
//# sourceMappingURL=employee-private.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"employee-private.js","sourceRoot":"","sources":["../../../server/service/employee/employee-private.ts"],"names":[],"mappings":";;;AASA,0CAEC;AAGD,gDAMC;AApBD,yDAA2D;AAE3D;;;GAGG;AACU,QAAA,uBAAuB,GAAG,CAAC,aAAa,EAAE,UAAU,CAAU,CAAA;AAE3E,wFAAwF;AACxF,SAAgB,eAAe,CAAC,KAAiD;IAC/E,OAAO,+BAAuB,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC,CAAC,KAAK,IAAI,KAAK,IAAI,KAAK,IAAI,KAAK,CAAC,KAAK,CAAC,KAAK,SAAS,CAAC,CAAA;AACzG,CAAC;AAED,2EAA2E;AACpE,KAAK,UAAU,kBAAkB,CAAC,OAAuD,EAAE,OAAY;IAC5G,MAAM,OAAO,GAAG,CAAC,GAAG,IAAI,GAAG,CAAC,OAAO,CAAC,OAAO,CAAC,eAAe,CAAC,CAAC,CAAC,CAAA;IAC9D,IAAI,CAAC,OAAO,CAAC,MAAM;QAAE,OAAM;IAC3B,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,QAAQ,EAAE,oBAAoB,EAAE,GAAG,OAAO,CAAC,KAAK,CAAA;IACtE,IAAI,MAAM,IAAA,2BAAe,EAAC,EAAE,QAAQ,EAAE,kBAAkB,EAAE,SAAS,EAAE,UAAU,EAAE,KAAK,EAAE,IAAI,EAAE,EAAE,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,oBAAoB,CAAC;QAAE,OAAM;IACrJ,MAAM,IAAI,KAAK,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,kFAAkF,CAAC,CAAA;AAC1H,CAAC","sourcesContent":["import { checkPermission } from '@things-factory/auth-base'\n\n/**\n * An employee's pay account - where their pay goes. Who was paid what is HR-payroll's fact (ADR-0139), so these fields\n * are read and written under `employee-private`, apart from the roster every seat reads (`employee`).\n */\nexport const EMPLOYEE_PRIVATE_FIELDS = ['bankAccount', 'bankName'] as const\n\n/** The private fields a patch writes - a field left out of the patch is not written. */\nexport function privateFieldsOf(patch: Record<string, unknown> | null | undefined): string[] {\n return EMPLOYEE_PRIVATE_FIELDS.filter(field => !!patch && field in patch && patch[field] !== undefined)\n}\n\n/** Refuses a write of the pay account by someone who may not change it. */\nexport async function refusePrivateWrite(patches: (Record<string, unknown> | null | undefined)[], context: any): Promise<void> {\n const written = [...new Set(patches.flatMap(privateFieldsOf))]\n if (!written.length) return\n const { domain, user, unsafeIP, prohibitedPrivileges } = context.state\n if (await checkPermission({ category: 'employee-private', privilege: 'mutation', owner: true }, user, domain, unsafeIP, prohibitedPrivileges)) return\n throw new Error(`${written.join(', ')} - an employee's pay account is changed by whoever keeps pay (employee-private).`)\n}\n"]}
|
|
@@ -164,11 +164,13 @@ tslib_1.__decorate([
|
|
|
164
164
|
], Employee.prototype, "emergencyContactPhone", void 0);
|
|
165
165
|
tslib_1.__decorate([
|
|
166
166
|
(0, typeorm_1.Column)({ nullable: true }),
|
|
167
|
+
(0, type_graphql_1.Directive)('@privilege(category: "employee-private", privilege: "query", domainOwnerGranted: true)'),
|
|
167
168
|
(0, type_graphql_1.Field)({ nullable: true }),
|
|
168
169
|
tslib_1.__metadata("design:type", String)
|
|
169
170
|
], Employee.prototype, "bankAccount", void 0);
|
|
170
171
|
tslib_1.__decorate([
|
|
171
172
|
(0, typeorm_1.Column)({ nullable: true }),
|
|
173
|
+
(0, type_graphql_1.Directive)('@privilege(category: "employee-private", privilege: "query", domainOwnerGranted: true)'),
|
|
172
174
|
(0, type_graphql_1.Field)({ nullable: true }),
|
|
173
175
|
tslib_1.__metadata("design:type", String)
|
|
174
176
|
], Employee.prototype, "bankName", void 0);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"employee.js","sourceRoot":"","sources":["../../../server/service/employee/employee.ts"],"names":[],"mappings":";;;;AAAA,qCAYgB;AAChB,+CAA2E;AAC3E,qDAAqD;AAErD,iDAA8C;AAC9C,yDAAgD;AAChD,qDAA0D;AAE1D,yDAAqD;AACrD,kEAA6D;AAE7D,IAAY,YAIX;AAJD,WAAY,YAAY;IACtB,qCAAqB,CAAA;IACrB,qCAAqB,CAAA;IACrB,uCAAuB,CAAA;AACzB,CAAC,EAJW,YAAY,4BAAZ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B,IAAA,gBAAM,GAAE;IACR,IAAA,eAAK,EAAC,eAAe,EAAE,CAAC,QAAkB,EAAE,EAAE,CAAC,CAAC,QAAQ,CAAC,MAAM,EAAE,QAAQ,CAAC,SAAS,EAAE,QAAQ,CAAC,SAAS,CAAC,EAAE;QACzG,MAAM,EAAE,IAAI;KACb,CAAC;IACD,IAAA,yBAAU,EAAC,EAAE,WAAW,EAAE,qBAAqB,EAAE,CAAC;GACtC,QAAQ,CA0JpB","sourcesContent":["import {\n CreateDateColumn,\n UpdateDateColumn,\n DeleteDateColumn,\n Entity,\n Index,\n Column,\n OneToMany,\n RelationId,\n ManyToOne,\n PrimaryGeneratedColumn,\n VersionColumn\n} from 'typeorm'\nimport { ObjectType, Field, Int, ID, registerEnumType } from 'type-graphql'\nimport { GraphQLEmailAddress } from 'graphql-scalars'\n\nimport { Domain } from '@things-factory/shell'\nimport { User } from '@things-factory/auth-base'\nimport { Contact, Profile } from '@things-factory/contact'\n\nimport { Department } from '../department/department'\nimport { ApprovalLine } from '../approval-line/approval-line'\n\nexport enum EmployeeType {\n FULLTIME = 'FULLTIME',\n PARTTIME = 'PARTTIME',\n TEMPORARY = 'TEMPORARY'\n}\n\nregisterEnumType(EmployeeType, {\n name: 'EmployeeType',\n description: 'type enumeration of a employee'\n})\n\n@Entity()\n@Index('ix_employee_0', (employee: Employee) => [employee.domain, employee.controlNo, employee.deletedAt], {\n unique: true\n})\n@ObjectType({ description: 'Entity for Employee' })\nexport class Employee {\n @PrimaryGeneratedColumn('uuid')\n @Field(type => ID)\n readonly id: string\n\n @VersionColumn()\n @Field({ nullable: true })\n version?: number = 1\n\n @ManyToOne(type => Domain)\n @Field(type => Domain)\n domain?: Domain\n\n @RelationId((employee: Employee) => employee.domain)\n domainId?: string\n\n @Column()\n @Field({ nullable: false })\n controlNo: string\n\n @Column()\n @Field({ nullable: true })\n name?: string\n\n @Column({ nullable: true })\n @Field({ nullable: true })\n alias?: string\n\n @Column({ nullable: true })\n @Field({ nullable: true })\n jobResponsibility?: string\n\n @Column({ nullable: true })\n @Field({ nullable: true })\n jobPosition?: string\n\n @ManyToOne(type => Employee, supervisor => supervisor.supervises, { nullable: true })\n @Field(type => Employee, { nullable: true })\n supervisor?: Employee\n\n @RelationId((employee: Employee) => employee.supervisor)\n supervisorId?: string\n\n @OneToMany(type => Employee, employee => employee.supervisor)\n @Field(type => [Employee])\n supervises?: Employee[]\n\n @ManyToOne(type => Department, department => department.members, { nullable: true })\n @Field(type => Department, { nullable: true })\n department?: Department\n\n @RelationId((employee: Employee) => employee.department)\n departmentId?: string\n\n @OneToMany(type => Department, department => department.manager)\n @Field(type => [Department])\n manages?: Department[]\n\n @OneToMany(type => ApprovalLine, employee => employee.ownerEmployee)\n @Field(type => [ApprovalLine])\n approvalLines?: ApprovalLine[]\n\n @Column({ nullable: true })\n @Field({ nullable: true })\n active?: boolean\n\n @Column({ nullable: true })\n @Field({ nullable: true })\n type?: EmployeeType\n\n @Column({ nullable: true })\n @Field({ nullable: true })\n extension?: string\n\n @Field(type => String, { nullable: true })\n photo?: string\n\n @ManyToOne(type => User, { nullable: true })\n @Field({ nullable: true })\n user?: User\n\n @RelationId((employee: Employee) => employee.user)\n userId?: string\n\n @ManyToOne(type => Contact, { nullable: true })\n @Field({ nullable: true })\n contact?: Contact\n\n @RelationId((employee: Employee) => employee.contact)\n contactId?: string\n\n @Field(type => GraphQLEmailAddress, { nullable: true })\n email?: string\n\n @Field({ nullable: true })\n phone?: string\n\n @Field(type => Profile, { nullable: true })\n profile?: Profile\n\n @Column({ nullable: true })\n @Field({ nullable: true })\n emergencyContact?: string\n\n @Column({ nullable: true })\n @Field({ nullable: true })\n emergencyContactPhone?: string\n\n @Column({ nullable: true })\n @Field({ nullable: true })\n bankAccount?: string\n\n @Column({ nullable: true })\n @Field({ nullable: true })\n bankName?: string\n\n @Column({ nullable: true })\n @Field({ nullable: true })\n note?: string\n\n /* Calendar days, not instants: 'YYYY-MM-DD' strings, so no time zone can move them to the day before. */\n @Column({ nullable: true })\n @Field({ nullable: true, description: 'The hire day in YYYY-MM-DD format' })\n hiredOn?: string\n\n @Column({ nullable: true })\n @Field({ nullable: true, description: 'The retire day in YYYY-MM-DD format' })\n retiredOn?: string\n\n @CreateDateColumn()\n @Field({ nullable: true })\n createdAt?: Date\n\n @UpdateDateColumn()\n @Field({ nullable: true })\n updatedAt?: Date\n\n @DeleteDateColumn()\n @Field({ nullable: true })\n deletedAt?: Date\n\n @ManyToOne(type => User, { nullable: true })\n @Field(type => User, { nullable: true })\n creator?: User\n\n @RelationId((employee: Employee) => employee.creator)\n creatorId?: string\n\n @ManyToOne(type => User, { nullable: true })\n @Field(type => User, { nullable: true })\n updater?: User\n\n @RelationId((employee: Employee) => employee.updater)\n updaterId?: string\n}\n"]}
|
|
1
|
+
{"version":3,"file":"employee.js","sourceRoot":"","sources":["../../../server/service/employee/employee.ts"],"names":[],"mappings":";;;;AAAA,qCAYgB;AAChB,+CAAsF;AACtF,qDAAqD;AAErD,iDAA8C;AAC9C,yDAAgD;AAChD,qDAA0D;AAE1D,yDAAqD;AACrD,kEAA6D;AAE7D,IAAY,YAIX;AAJD,WAAY,YAAY;IACtB,qCAAqB,CAAA;IACrB,qCAAqB,CAAA;IACrB,uCAAuB,CAAA;AACzB,CAAC,EAJW,YAAY,4BAAZ,YAAY,QAIvB;AAED,IAAA,+BAAgB,EAAC,YAAY,EAAE;IAC7B,IAAI,EAAE,cAAc;IACpB,WAAW,EAAE,gCAAgC;CAC9C,CAAC,CAAA;AAOK,IAAM,QAAQ,GAAd,MAAM,QAAQ;IAAd;QAOL,YAAO,GAAY,CAAC,CAAA;IAsJtB,CAAC;CAAA,CAAA;AA7JY,4BAAQ;AAGV;IAFR,IAAA,gCAAsB,EAAC,MAAM,CAAC;IAC9B,IAAA,oBAAK,EAAC,IAAI,CAAC,EAAE,CAAC,iBAAE,CAAC;;oCACC;AAInB;IAFC,IAAA,uBAAa,GAAE;IACf,IAAA,oBAAK,EAAC,EAAE,QAAQ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ateColumn,\n Entity,\n Index,\n Column,\n OneToMany,\n RelationId,\n ManyToOne,\n PrimaryGeneratedColumn,\n VersionColumn\n} from 'typeorm'\nimport { Directive, ObjectType, Field, Int, ID, registerEnumType } from 'type-graphql'\nimport { GraphQLEmailAddress } from 'graphql-scalars'\n\nimport { Domain } from '@things-factory/shell'\nimport { User } from '@things-factory/auth-base'\nimport { Contact, Profile } from '@things-factory/contact'\n\nimport { Department } from '../department/department'\nimport { ApprovalLine } from '../approval-line/approval-line'\n\nexport enum EmployeeType {\n FULLTIME = 'FULLTIME',\n PARTTIME = 'PARTTIME',\n TEMPORARY = 'TEMPORARY'\n}\n\nregisterEnumType(EmployeeType, {\n name: 'EmployeeType',\n description: 'type enumeration of a employee'\n})\n\n@Entity()\n@Index('ix_employee_0', (employee: Employee) => [employee.domain, employee.controlNo, employee.deletedAt], {\n unique: true\n})\n@ObjectType({ description: 'Entity for Employee' })\nexport class Employee {\n @PrimaryGeneratedColumn('uuid')\n @Field(type => ID)\n readonly id: string\n\n @VersionColumn()\n @Field({ nullable: true })\n version?: number = 1\n\n @ManyToOne(type => Domain)\n @Field(type => Domain)\n domain?: Domain\n\n @RelationId((employee: Employee) => employee.domain)\n domainId?: string\n\n @Column()\n @Field({ nullable: false })\n controlNo: string\n\n @Column()\n @Field({ nullable: true })\n name?: string\n\n @Column({ nullable: true })\n @Field({ nullable: true })\n alias?: string\n\n @Column({ nullable: true })\n @Field({ nullable: true })\n jobResponsibility?: string\n\n @Column({ nullable: true })\n @Field({ nullable: true })\n jobPosition?: string\n\n @ManyToOne(type => Employee, supervisor => supervisor.supervises, { nullable: true })\n @Field(type => Employee, { nullable: true })\n supervisor?: Employee\n\n @RelationId((employee: Employee) => employee.supervisor)\n supervisorId?: string\n\n @OneToMany(type => Employee, employee => employee.supervisor)\n @Field(type => [Employee])\n supervises?: Employee[]\n\n @ManyToOne(type => Department, department => department.members, { nullable: true })\n @Field(type => Department, { nullable: true })\n department?: Department\n\n @RelationId((employee: Employee) => employee.department)\n departmentId?: string\n\n @OneToMany(type => Department, department => department.manager)\n @Field(type => [Department])\n manages?: Department[]\n\n @OneToMany(type => ApprovalLine, employee => employee.ownerEmployee)\n @Field(type => [ApprovalLine])\n approvalLines?: ApprovalLine[]\n\n @Column({ nullable: true })\n @Field({ nullable: true })\n active?: boolean\n\n @Column({ nullable: true })\n @Field({ nullable: true })\n type?: EmployeeType\n\n @Column({ nullable: true })\n @Field({ nullable: true })\n extension?: string\n\n @Field(type => String, { nullable: true })\n photo?: string\n\n @ManyToOne(type => User, { nullable: true })\n @Field({ nullable: true })\n user?: User\n\n @RelationId((employee: Employee) => employee.user)\n userId?: string\n\n @ManyToOne(type => Contact, { nullable: true })\n @Field({ nullable: true })\n contact?: Contact\n\n @RelationId((employee: Employee) => employee.contact)\n contactId?: string\n\n @Field(type => GraphQLEmailAddress, { nullable: true })\n email?: string\n\n @Field({ nullable: true })\n phone?: string\n\n @Field(type => Profile, { nullable: true })\n profile?: Profile\n\n @Column({ nullable: true })\n @Field({ nullable: true })\n emergencyContact?: string\n\n @Column({ nullable: true })\n @Field({ nullable: true })\n emergencyContactPhone?: string\n\n /* The pay account is HR-payroll's (ADR-0139), not the roster's. */\n @Column({ nullable: true })\n @Directive('@privilege(category: \"employee-private\", privilege: \"query\", domainOwnerGranted: true)')\n @Field({ nullable: true })\n bankAccount?: string\n\n @Column({ nullable: true })\n @Directive('@privilege(category: \"employee-private\", privilege: \"query\", domainOwnerGranted: true)')\n @Field({ nullable: true })\n bankName?: string\n\n @Column({ nullable: true })\n @Field({ nullable: true })\n note?: string\n\n /* Calendar days, not instants: 'YYYY-MM-DD' strings, so no time zone can move them to the day before. */\n @Column({ nullable: true })\n @Field({ nullable: true, description: 'The hire day in YYYY-MM-DD format' })\n hiredOn?: string\n\n @Column({ nullable: true })\n @Field({ nullable: true, description: 'The retire day in YYYY-MM-DD format' })\n retiredOn?: string\n\n @CreateDateColumn()\n @Field({ nullable: true })\n createdAt?: Date\n\n @UpdateDateColumn()\n @Field({ nullable: true })\n updatedAt?: Date\n\n @DeleteDateColumn()\n @Field({ nullable: true })\n deletedAt?: Date\n\n @ManyToOne(type => User, { nullable: true })\n @Field(type => User, { nullable: true })\n creator?: User\n\n @RelationId((employee: Employee) => employee.creator)\n creatorId?: string\n\n @ManyToOne(type => User, { nullable: true })\n @Field(type => User, { nullable: true })\n updater?: User\n\n @RelationId((employee: Employee) => employee.updater)\n updaterId?: string\n}\n"]}
|