@things-factory/organization 10.1.231 → 10.1.232
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.
|
@@ -15,6 +15,11 @@ const employment_certificate_templates_1 = require("./employment-certificate-tem
|
|
|
15
15
|
*/
|
|
16
16
|
exports.EMPLOYMENT_CERTIFICATE_KIND = 'organization.employment-certificate';
|
|
17
17
|
exports.CAREER_CERTIFICATE_KIND = 'organization.career-certificate';
|
|
18
|
+
/* Asked here only - no field gates on it - so declared here, or no role could be granted it. */
|
|
19
|
+
(0, auth_base_1.declarePrivileges)('organization employment certificates', [
|
|
20
|
+
['employee-certificate', 'query'],
|
|
21
|
+
['employee-certificate', 'mutation']
|
|
22
|
+
]);
|
|
18
23
|
/** What the caller holds, asked as the doors ask it. */
|
|
19
24
|
async function holds(context, category, privilege) {
|
|
20
25
|
const { domain, user, unsafeIP, prohibitedPrivileges } = context?.state ?? {};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"employment-certificates.js","sourceRoot":"","sources":["../../../server/service/certificate/employment-certificates.ts"],"names":[],"mappings":";;;AAAA,
|
|
1
|
+
{"version":3,"file":"employment-certificates.js","sourceRoot":"","sources":["../../../server/service/certificate/employment-certificates.ts"],"names":[],"mappings":";;;AAAA,yDAA8E;AAC9E,6CAAgE;AAChE,iDAA2E;AAE3E,mDAA+C;AAC/C,yDAAuD;AACvD,iFAA0G;AAC1G,yFAAyF;AAEzF;;;;GAIG;AACU,QAAA,2BAA2B,GAAG,qCAAqC,CAAA;AACnE,QAAA,uBAAuB,GAAG,iCAAiC,CAAA;AAExE,gGAAgG;AAChG,IAAA,6BAAiB,EAAC,sCAAsC,EAAE;IACxD,CAAC,sBAAsB,EAAE,OAAO,CAAC;IACjC,CAAC,sBAAsB,EAAE,UAAU,CAAC;CACrC,CAAC,CAAA;AAEF,wDAAwD;AACxD,KAAK,UAAU,KAAK,CAAC,OAAY,EAAE,QAAgB,EAAE,SAA+B;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,EAAE,MAAM,UAAU,CAAC,OAAO,EAAE,KAAK,CAAC,CAAC,CAAA;QACpE,CAAC;QACD,KAAK,CAAC,OAAO,CAAC,OAAO,EAAE,GAAG;YACxB,OAAO,IAAA,iDAAkB,EAAC,MAAM,UAAU,CAAC,OAAO,EAAE,GAAG,CAAC,KAAK,CAAC,CAAC,CAAA;QACjE,CAAC;KACF,CAAC,CAAA;AACJ,CAAC","sourcesContent":["import { checkPermission, declarePrivileges } from '@things-factory/auth-base'\nimport { registerIssuedDocumentKind } from '@things-factory/pdf'\nimport { calendarDay, getRepository, Refusal } from '@things-factory/shell'\n\nimport { Employee } from '../employee/employee'\nimport { myEmployeeIds } from '../employee/my-employee'\nimport { certificateFacts, mayIssueCertificate, mayReadCertificate } from './employment-certificate-rules'\nimport { CAREER_TEMPLATE, EMPLOYMENT_TEMPLATE } from './employment-certificate-templates'\n\n/*\n * 재직증명서 · 경력증명서 - issued documents of the employment, which organization owns (ADR-0176 decision 5). An employee\n * issues their own 재직증명서 (`employee-self`); everyone else's, and every 경력증명서, under `employee-certificate`\n * (`organization.certificates-issuing`). No birth date or address is printed (Q2).\n */\nexport const EMPLOYMENT_CERTIFICATE_KIND = 'organization.employment-certificate'\nexport const CAREER_CERTIFICATE_KIND = 'organization.career-certificate'\n\n/* Asked here only - no field gates on it - so declared here, or no role could be granted it. */\ndeclarePrivileges('organization employment certificates', [\n ['employee-certificate', 'query'],\n ['employee-certificate', 'mutation']\n])\n\n/** What the caller holds, asked as the doors ask it. */\nasync function holds(context: any, category: string, privilege: 'query' | 'mutation'): Promise<boolean> {\n const { domain, user, unsafeIP, prohibitedPrivileges } = context?.state ?? {}\n if (!domain || !user) return false\n return !!(await checkPermission({ category, privilege, owner: true } as any, user, domain, unsafeIP, prohibitedPrivileges))\n}\n\n/** Who is asking about whom: theirs, and what they hold. */\nasync function standingOf(context: any, employeeId: string | null | undefined) {\n return {\n own: !!employeeId && (await myEmployeeIds(context)).includes(employeeId),\n self: await holds(context, 'employee-self', 'mutation'),\n issuing: await holds(context, 'employee-certificate', 'mutation'),\n reading: await holds(context, 'employee-certificate', 'query')\n }\n}\n\nasync function employeeOf(context: any, id: string): Promise<Employee> {\n const { domain, tx } = context.state\n const employee = await getRepository(Employee, tx).findOne({ where: { id, domain: { id: domain.id } }, relations: ['department'] })\n if (!employee) throw new Refusal('employee-not-found', {}, 'the employee was not found')\n return employee\n}\n\nfor (const kind of [EMPLOYMENT_CERTIFICATE_KIND, CAREER_CERTIFICATE_KIND] as const) {\n const career = kind === CAREER_CERTIFICATE_KIND\n registerIssuedDocumentKind({\n kind,\n prefix: career ? '경력' : '재직',\n refType: 'Employee',\n template: { content_template: career ? CAREER_TEMPLATE : EMPLOYMENT_TEMPLATE, page_size: 'A4' },\n async dataOf(context, refId, input) {\n const employee = await employeeOf(context, refId)\n const facts = certificateFacts(kind, employee, calendarDay(context.state.domain.timezone))\n return { subjectName: employee.name ?? '', data: { employee: facts } }\n },\n /* One's own employee record - issued from 내 정보 › 내 증명서 (the issuance ledger). */\n async ownSubject(context) {\n const mine = await myEmployeeIds(context)\n return mine.length === 1 ? mine[0] : null\n },\n async mayIssue(context, refId) {\n return mayIssueCertificate(kind, await standingOf(context, refId))\n },\n async mayRead(context, row) {\n return mayReadCertificate(await standingOf(context, row.refId))\n }\n })\n}\n"]}
|