@things-factory/biz-base 10.1.247 → 10.1.254
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-server/index.d.ts +1 -1
- package/dist-server/index.js +1 -1
- package/dist-server/index.js.map +1 -1
- package/dist-server/role-tasks.js +2 -0
- package/dist-server/role-tasks.js.map +1 -1
- package/dist-server/service/company/company-mutation.d.ts +0 -3
- package/dist-server/service/company/company-mutation.js +0 -21
- package/dist-server/service/company/company-mutation.js.map +1 -1
- package/dist-server/service/company/company-query.d.ts +0 -2
- package/dist-server/service/company/company-query.js +0 -12
- package/dist-server/service/company/company-query.js.map +1 -1
- package/dist-server/service/company/company.js +1 -1
- package/dist-server/service/company/company.js.map +1 -1
- package/dist-server/service/company/our-company.d.ts +3 -9
- package/dist-server/service/company/our-company.js +5 -17
- package/dist-server/service/company/our-company.js.map +1 -1
- package/dist-server/service/company-seal/company-seal-mutation.d.ts +8 -0
- package/dist-server/service/company-seal/company-seal-mutation.js +52 -0
- package/dist-server/service/company-seal/company-seal-mutation.js.map +1 -0
- package/dist-server/service/company-seal/company-seal-query.d.ts +13 -0
- package/dist-server/service/company-seal/company-seal-query.js +91 -0
- package/dist-server/service/company-seal/company-seal-query.js.map +1 -0
- package/dist-server/service/company-seal/company-seal-reader.d.ts +6 -0
- package/dist-server/service/company-seal/company-seal-reader.js +16 -0
- package/dist-server/service/company-seal/company-seal-reader.js.map +1 -0
- package/dist-server/service/company-seal/company-seal-rules.d.ts +14 -0
- package/dist-server/service/company-seal/company-seal-rules.js +39 -0
- package/dist-server/service/company-seal/company-seal-rules.js.map +1 -0
- package/dist-server/service/company-seal/company-seal-service.d.ts +30 -0
- package/dist-server/service/company-seal/company-seal-service.js +77 -0
- package/dist-server/service/company-seal/company-seal-service.js.map +1 -0
- package/dist-server/service/company-seal/company-seal-types.d.ts +24 -0
- package/dist-server/service/company-seal/company-seal-types.js +93 -0
- package/dist-server/service/company-seal/company-seal-types.js.map +1 -0
- package/dist-server/service/company-seal/company-seal.d.ts +38 -0
- package/dist-server/service/company-seal/company-seal.js +130 -0
- package/dist-server/service/company-seal/company-seal.js.map +1 -0
- package/dist-server/service/company-seal/index.d.ts +5 -0
- package/dist-server/service/company-seal/index.js +9 -0
- package/dist-server/service/company-seal/index.js.map +1 -0
- package/dist-server/service/index.d.ts +6 -2
- package/dist-server/service/index.js +7 -0
- package/dist-server/service/index.js.map +1 -1
- package/dist-server/tsconfig.tsbuildinfo +1 -1
- package/package.json +4 -4
- package/tests/company-seal.test.mjs +103 -0
- package/tests/our-company.test.mjs +5 -17
- package/translations/en.json +15 -1
- package/translations/es.json +15 -1
- package/translations/ja.json +15 -1
- package/translations/ko.json +15 -1
- package/translations/ms.json +15 -1
- package/translations/zh.json +15 -1
- package/dist-server/service/company/company-seal-reader.d.ts +0 -6
- package/dist-server/service/company/company-seal-reader.js +0 -16
- package/dist-server/service/company/company-seal-reader.js.map +0 -1
package/dist-server/index.d.ts
CHANGED
package/dist-server/index.js
CHANGED
|
@@ -5,7 +5,7 @@ tslib_1.__exportStar(require("./service"), exports);
|
|
|
5
5
|
tslib_1.__exportStar(require("./migrations"), exports);
|
|
6
6
|
tslib_1.__exportStar(require("./utils"), exports);
|
|
7
7
|
require("./service/counterparty/counterparty-document-readers");
|
|
8
|
-
require("./service/company/company-seal-reader");
|
|
8
|
+
require("./service/company-seal/company-seal-reader");
|
|
9
9
|
const auth_base_1 = require("@things-factory/auth-base");
|
|
10
10
|
const role_tasks_1 = require("./role-tasks");
|
|
11
11
|
for (const task of role_tasks_1.ROLE_TASKS)
|
package/dist-server/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../server/index.ts"],"names":[],"mappings":";;;AAAA,oDAAyB;AACzB,uDAA4B;AAC5B,kDAAuB;AAEvB,gEAA6D;AAC7D,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../server/index.ts"],"names":[],"mappings":";;;AAAA,oDAAyB;AACzB,uDAA4B;AAC5B,kDAAuB;AAEvB,gEAA6D;AAC7D,sDAAmD;AAEnD,yDAA4D;AAC5D,6CAAyC;AAEzC,KAAK,MAAM,IAAI,IAAI,uBAAU;IAAE,IAAA,4BAAgB,EAAC,IAAI,CAAC,CAAA","sourcesContent":["export * from './service'\nexport * from './migrations'\nexport * from './utils'\n\nimport './service/counterparty/counterparty-document-readers'\nimport './service/company-seal/company-seal-reader'\n\nimport { registerRoleTask } from '@things-factory/auth-base'\nimport { ROLE_TASKS } from './role-tasks'\n\nfor (const task of ROLE_TASKS) registerRoleTask(task)\n"]}
|
|
@@ -11,6 +11,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
11
11
|
exports.ROLE_TASKS = void 0;
|
|
12
12
|
exports.ROLE_TASKS = [
|
|
13
13
|
{ id: 'biz-base.counterparty-keeping', grants: [{ category: 'counterparty', axes: ['query', 'mutation'] }] },
|
|
14
|
+
/* 인감 대장 - the seals, their keepers and impressions, and which one documents print (ADR-0188). */
|
|
15
|
+
{ id: 'biz-base.seal-keeping', grants: [{ category: 'company-seal', axes: ['query', 'mutation'] }] },
|
|
14
16
|
{ id: 'biz-base.company-keeping', grants: [{ category: 'company', axes: ['query', 'mutation'] }, { category: 'bizplace', axes: ['query', 'mutation'] }, { category: 'biz-option', axes: ['query', 'mutation'] }] }
|
|
15
17
|
];
|
|
16
18
|
//# sourceMappingURL=role-tasks.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"role-tasks.js","sourceRoot":"","sources":["../server/role-tasks.ts"],"names":[],"mappings":";AAAA;;;;;;;GAOG;;;AAIU,QAAA,UAAU,GAAe;IACpC,EAAE,EAAE,EAAE,+BAA+B,EAAE,MAAM,EAAE,CAAC,EAAE,QAAQ,EAAE,cAAc,EAAE,IAAI,EAAE,CAAC,OAAO,EAAE,UAAU,CAAC,EAAE,CAAC,EAAE;IAC5G,EAAE,EAAE,EAAE,0BAA0B,EAAE,MAAM,EAAE,CAAC,EAAE,QAAQ,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,OAAO,EAAE,UAAU,CAAC,EAAE,EAAE,EAAE,QAAQ,EAAE,UAAU,EAAE,IAAI,EAAE,CAAC,OAAO,EAAE,UAAU,CAAC,EAAE,EAAE,EAAE,QAAQ,EAAE,YAAY,EAAE,IAAI,EAAE,CAAC,OAAO,EAAE,UAAU,CAAC,EAAE,CAAC,EAAE;CACnN,CAAA","sourcesContent":["/*\n * The work this module names, for the seats applications build (ADR-0139 decision 11).\n *\n * A task holds whole privileges: each opens everything its doors open, and the words under `task.<id>` in this\n * module's translations say what that is. Seats are put together by applications (`RoleTemplate.tasks`).\n *\n * Data only - `server/index.ts` registers it - so an application's tests read it without starting the framework.\n */\n\nimport type { RoleTask } from '@things-factory/auth-base'\n\nexport const ROLE_TASKS: RoleTask[] = [\n { id: 'biz-base.counterparty-keeping', grants: [{ category: 'counterparty', axes: ['query', 'mutation'] }] },\n { id: 'biz-base.company-keeping', grants: [{ category: 'company', axes: ['query', 'mutation'] }, { category: 'bizplace', axes: ['query', 'mutation'] }, { category: 'biz-option', axes: ['query', 'mutation'] }] }\n]\n"]}
|
|
1
|
+
{"version":3,"file":"role-tasks.js","sourceRoot":"","sources":["../server/role-tasks.ts"],"names":[],"mappings":";AAAA;;;;;;;GAOG;;;AAIU,QAAA,UAAU,GAAe;IACpC,EAAE,EAAE,EAAE,+BAA+B,EAAE,MAAM,EAAE,CAAC,EAAE,QAAQ,EAAE,cAAc,EAAE,IAAI,EAAE,CAAC,OAAO,EAAE,UAAU,CAAC,EAAE,CAAC,EAAE;IAC5G,iGAAiG;IACjG,EAAE,EAAE,EAAE,uBAAuB,EAAE,MAAM,EAAE,CAAC,EAAE,QAAQ,EAAE,cAAc,EAAE,IAAI,EAAE,CAAC,OAAO,EAAE,UAAU,CAAC,EAAE,CAAC,EAAE;IACpG,EAAE,EAAE,EAAE,0BAA0B,EAAE,MAAM,EAAE,CAAC,EAAE,QAAQ,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,OAAO,EAAE,UAAU,CAAC,EAAE,EAAE,EAAE,QAAQ,EAAE,UAAU,EAAE,IAAI,EAAE,CAAC,OAAO,EAAE,UAAU,CAAC,EAAE,EAAE,EAAE,QAAQ,EAAE,YAAY,EAAE,IAAI,EAAE,CAAC,OAAO,EAAE,UAAU,CAAC,EAAE,CAAC,EAAE;CACnN,CAAA","sourcesContent":["/*\n * The work this module names, for the seats applications build (ADR-0139 decision 11).\n *\n * A task holds whole privileges: each opens everything its doors open, and the words under `task.<id>` in this\n * module's translations say what that is. Seats are put together by applications (`RoleTemplate.tasks`).\n *\n * Data only - `server/index.ts` registers it - so an application's tests read it without starting the framework.\n */\n\nimport type { RoleTask } from '@things-factory/auth-base'\n\nexport const ROLE_TASKS: RoleTask[] = [\n { id: 'biz-base.counterparty-keeping', grants: [{ category: 'counterparty', axes: ['query', 'mutation'] }] },\n /* 인감 대장 - the seals, their keepers and impressions, and which one documents print (ADR-0188). */\n { id: 'biz-base.seal-keeping', grants: [{ category: 'company-seal', axes: ['query', 'mutation'] }] },\n { id: 'biz-base.company-keeping', grants: [{ category: 'company', axes: ['query', 'mutation'] }, { category: 'bizplace', axes: ['query', 'mutation'] }, { category: 'biz-option', axes: ['query', 'mutation'] }] }\n]\n"]}
|
|
@@ -1,13 +1,10 @@
|
|
|
1
|
-
import type { FileUpload } from 'graphql-upload/GraphQLUpload.js';
|
|
2
1
|
import { EntityManager } from 'typeorm';
|
|
3
|
-
import { Attachment } from '@things-factory/attachment-base';
|
|
4
2
|
import { User } from '@things-factory/auth-base';
|
|
5
3
|
import { Domain } from '@things-factory/shell';
|
|
6
4
|
import { Company } from './company';
|
|
7
5
|
import { CompanyPatch, NewCompany } from './company-types';
|
|
8
6
|
export declare class CompanyMutation {
|
|
9
7
|
saveCompany(company: CompanyPatch, context: ResolverContext): Promise<Company>;
|
|
10
|
-
attachCompanySeal(companyId: string, file: FileUpload | null, context: ResolverContext): Promise<Attachment | null>;
|
|
11
8
|
createCompany(company: NewCompany, context: ResolverContext): Promise<Company>;
|
|
12
9
|
updateCompany(name: string, patch: CompanyPatch, context: ResolverContext): Promise<Company>;
|
|
13
10
|
updateMultipleCompany(patches: CompanyPatch[], context: ResolverContext): Promise<any[]>;
|
|
@@ -7,9 +7,7 @@ exports.deleteCompanies = deleteCompanies;
|
|
|
7
7
|
exports.deleteCompany = deleteCompany;
|
|
8
8
|
exports.saveOurCompany = saveOurCompany;
|
|
9
9
|
const tslib_1 = require("tslib");
|
|
10
|
-
const GraphQLUpload_js_1 = tslib_1.__importDefault(require("graphql-upload/GraphQLUpload.js"));
|
|
11
10
|
const type_graphql_1 = require("type-graphql");
|
|
12
|
-
const attachment_base_1 = require("@things-factory/attachment-base");
|
|
13
11
|
const shell_1 = require("@things-factory/shell");
|
|
14
12
|
const utils_1 = require("@things-factory/utils");
|
|
15
13
|
const company_1 = require("./company");
|
|
@@ -20,13 +18,6 @@ let CompanyMutation = class CompanyMutation {
|
|
|
20
18
|
const { domain, user, tx } = context.state;
|
|
21
19
|
return await saveOurCompany(company, domain, user, tx);
|
|
22
20
|
}
|
|
23
|
-
async attachCompanySeal(companyId, file, context) {
|
|
24
|
-
const { domain, tx } = context.state;
|
|
25
|
-
const company = await (0, our_company_1.ourCompanyOf)(domain, tx);
|
|
26
|
-
if (!company || company.id !== companyId)
|
|
27
|
-
throw new shell_1.Refusal('company-not-found', {}, 'save the company first');
|
|
28
|
-
return await (0, attachment_base_1.replaceAttachment)({ file, refType: our_company_1.COMPANY_SEAL_REF_TYPE, refBy: company.id, category: 'seal' }, context);
|
|
29
|
-
}
|
|
30
21
|
async createCompany(company, context) {
|
|
31
22
|
const { domain, user, tx } = context.state;
|
|
32
23
|
return await createCompany(company, domain, user, tx);
|
|
@@ -76,18 +67,6 @@ tslib_1.__decorate([
|
|
|
76
67
|
tslib_1.__metadata("design:paramtypes", [company_types_1.CompanyPatch, Object]),
|
|
77
68
|
tslib_1.__metadata("design:returntype", Promise)
|
|
78
69
|
], CompanyMutation.prototype, "saveCompany", null);
|
|
79
|
-
tslib_1.__decorate([
|
|
80
|
-
(0, type_graphql_1.Directive)('@privilege(category: "company", privilege: "mutation", domainOwnerGranted: true)'),
|
|
81
|
-
(0, type_graphql_1.Directive)('@auditTarget(kind: "Company", arg: "companyId")'),
|
|
82
|
-
(0, type_graphql_1.Directive)('@transaction'),
|
|
83
|
-
(0, type_graphql_1.Mutation)(returns => attachment_base_1.Attachment, { nullable: true, description: 'To put the seal (직인) on 「우리 회사」, replacing the one it had; no file takes it away' }),
|
|
84
|
-
tslib_1.__param(0, (0, type_graphql_1.Arg)('companyId')),
|
|
85
|
-
tslib_1.__param(1, (0, type_graphql_1.Arg)('file', type => GraphQLUpload_js_1.default, { nullable: true })),
|
|
86
|
-
tslib_1.__param(2, (0, type_graphql_1.Ctx)()),
|
|
87
|
-
tslib_1.__metadata("design:type", Function),
|
|
88
|
-
tslib_1.__metadata("design:paramtypes", [String, Object, Object]),
|
|
89
|
-
tslib_1.__metadata("design:returntype", Promise)
|
|
90
|
-
], CompanyMutation.prototype, "attachCompanySeal", null);
|
|
91
70
|
tslib_1.__decorate([
|
|
92
71
|
(0, type_graphql_1.Directive)('@privilege(category: "company", privilege: "mutation")'),
|
|
93
72
|
(0, type_graphql_1.Directive)('@transaction'),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"company-mutation.js","sourceRoot":"","sources":["../../../server/service/company/company-mutation.ts"],"names":[],"mappings":";;;AAiHA,sCAeC;AAED,sCAYC;AAED,0CAGC;AAED,sCAGC;AASD,wCAcC;;AA9KD,+FAA2D;AAC3D,+CAAqF;AAGrF,qEAA+E;AAE/E,iDAAqF;AACrF,iDAA+C;AAE/C,uCAAmC;AACnC,mDAA0D;AAC1D,+CAAmE;AAI5D,IAAM,eAAe,GAArB,MAAM,eAAe;IAKpB,AAAN,KAAK,CAAC,WAAW,CAAiB,OAAqB,EAAS,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AkB,EAAE,CAAC;QACvC,MAAM,KAAK,GAAG,KAAK,CAAC,KAAK,CAAC,CAAA;QAC1B,IAAI,KAAK,KAAK,SAAS;YAAE,SAAQ;QACjC,KAAK,CAAC,KAAK,CAAC,GAAG,OAAO,KAAK,KAAK,QAAQ,CAAC,CAAC,CAAC,KAAK,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,KAAK,CAAA;IACjE,CAAC;IACD,MAAM,IAAI,GAAG,KAAK,CAAC,IAAI,IAAI,OAAO,EAAE,IAAI,CAAA;IACxC,IAAI,CAAC,IAAI;QAAE,MAAM,IAAI,eAAO,CAAC,uBAAuB,EAAE,EAAE,EAAE,wBAAwB,CAAC,CAAA;IACnF,MAAM,KAAK,GAAG,MAAM,UAAU,CAAC,OAAO,CAAC,EAAE,KAAK,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,EAAE,MAAM,CAAC,EAAE,EAAE,EAAE,IAAI,EAAE,EAAE,CAAC,CAAA;IACtF,IAAI,KAAK,IAAI,KAAK,CAAC,EAAE,KAAK,OAAO,EAAE,EAAE;QAAE,MAAM,IAAI,eAAO,CAAC,oBAAoB,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,EAAE,SAAS,IAAI,+BAA+B,CAAC,CAAA;IAC7I,OAAO,MAAM,UAAU,CAAC,IAAI,CAAC,EAAE,GAAG,CAAC,OAAO,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC,EAAE,GAAG,KAAK,EAAE,OAAO,EAAE,IAAI,EAAa,CAAC,CAAA;AACjH,CAAC","sourcesContent":["import type { FileUpload } from 'graphql-upload/GraphQLUpload.js'\nimport GraphQLUpload from 'graphql-upload/GraphQLUpload.js'\nimport { Arg, Ctx, Directive, Mutation, Resolver, UseMiddleware } from 'type-graphql'\nimport { EntityManager, Repository } from 'typeorm'\n\nimport { Attachment, replaceAttachment } from '@things-factory/attachment-base'\nimport { User } from '@things-factory/auth-base'\nimport { Domain, getRepository, Refusal, SpeakRefusals } from '@things-factory/shell'\nimport { slugger } from '@things-factory/utils'\n\nimport { Company } from './company'\nimport { CompanyPatch, NewCompany } from './company-types'\nimport { COMPANY_SEAL_REF_TYPE, ourCompanyOf } from './our-company'\n\n@Resolver(Company)\n@UseMiddleware(SpeakRefusals)\nexport class CompanyMutation {\n @Directive('@privilege(category: \"company\", privilege: \"mutation\", domainOwnerGranted: true)')\n @Directive('@auditTarget(kind: \"Company\", arg: \"company\")')\n @Directive('@transaction')\n @Mutation(returns => Company, { description: \"To keep 「우리 회사」 - this domain's own company, made on its first save (ADR-0176)\" })\n async saveCompany(@Arg('company') company: CompanyPatch, @Ctx() context: ResolverContext): Promise<Company> {\n const { domain, user, tx } = context.state\n return await saveOurCompany(company, domain, user, tx)\n }\n\n @Directive('@privilege(category: \"company\", privilege: \"mutation\", domainOwnerGranted: true)')\n @Directive('@auditTarget(kind: \"Company\", arg: \"companyId\")')\n @Directive('@transaction')\n @Mutation(returns => Attachment, { nullable: true, description: 'To put the seal (직인) on 「우리 회사」, replacing the one it had; no file takes it away' })\n async attachCompanySeal(\n @Arg('companyId') companyId: string,\n @Arg('file', type => GraphQLUpload, { nullable: true }) file: FileUpload | null,\n @Ctx() context: ResolverContext\n ): Promise<Attachment | null> {\n const { domain, tx } = context.state\n const company = await ourCompanyOf(domain, tx)\n if (!company || company.id !== companyId) throw new Refusal('company-not-found', {}, 'save the company first')\n return await replaceAttachment({ file, refType: COMPANY_SEAL_REF_TYPE, refBy: company.id, category: 'seal' }, context)\n }\n\n @Directive('@privilege(category: \"company\", privilege: \"mutation\")')\n @Directive('@transaction')\n @Mutation(returns => Company)\n async createCompany(@Arg('company') company: NewCompany, @Ctx() context: ResolverContext): Promise<Company> {\n const { domain, user, tx } = context.state\n return await createCompany(company, domain, user, tx)\n }\n\n @Directive('@privilege(category: \"company\", privilege: \"mutation\")')\n @Directive('@transaction')\n @Mutation(returns => Company)\n async updateCompany(\n @Arg('name') name: string,\n @Arg('patch') patch: CompanyPatch,\n @Ctx() context: ResolverContext\n ): Promise<Company> {\n const { domain, user, tx } = context.state\n return await updateCompany(name, patch, domain, user, tx)\n }\n\n @Directive('@privilege(category: \"company\", privilege: \"mutation\")')\n @Directive('@transaction')\n @Mutation(returns => [Company])\n async updateMultipleCompany(\n @Arg('patches', type => [CompanyPatch]) patches: CompanyPatch[],\n @Ctx() context: ResolverContext\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\n if (_createRecords.length > 0) {\n for (let i = 0; i < _createRecords.length; i++) {\n const patch: CompanyPatch = _createRecords[i]\n const result = await this.createCompany(patch as NewCompany, context)\n results.push({ ...result, cuFlag: '+' })\n }\n }\n\n if (_updateRecords.length > 0) {\n for (let i = 0; i < _updateRecords.length; i++) {\n const patch: CompanyPatch = _updateRecords[i]\n const result = await this.updateCompany(patch.name, patch, context)\n results.push({ ...result, cuFlag: 'M' })\n }\n }\n\n return results\n }\n\n @Directive('@privilege(category: \"company\", privilege: \"mutation\")')\n @Directive('@transaction')\n @Mutation(returns => Boolean)\n async deleteCompany(@Arg('id') id: string, @Ctx() context: ResolverContext): Promise<Boolean> {\n await deleteCompany(id, context.state.tx)\n\n return true\n }\n\n @Directive('@transaction')\n @Directive('@privilege(category: \"company\", privilege: \"mutation\")')\n @Mutation(returns => Boolean)\n async deleteCompanies(\n @Arg('ids', type => [String]) ids: string[],\n @Ctx() context: ResolverContext\n ): Promise<Boolean> {\n await deleteCompanies(ids, context.state.tx)\n\n return true\n }\n}\n\nexport async function createCompany(company: NewCompany, domain: Domain, user: User, tx?: EntityManager) {\n const companyRepository: Repository<Company> = tx ? tx.getRepository(Company) : getRepository(Company)\n const domainRepository: Repository<Domain> = tx ? tx.getRepository(Domain) : getRepository(Domain)\n\n const companyDomain: Domain = await domainRepository.save({\n subdomain: slugger(company.name),\n name: company.name\n })\n\n return await companyRepository.save({\n ...company,\n domain: companyDomain,\n creator: user,\n updater: user\n })\n}\n\nexport async function updateCompany(name: string, patch: CompanyPatch, domain: Domain, user: User, tx?: EntityManager) {\n const repository: Repository<Company> = tx ? tx.getRepository(Company) : getRepository(Company)\n const company = await repository.findOneBy({\n domain: { id: domain.id },\n name\n })\n\n return repository.save({\n ...company,\n ...patch,\n updater: user\n })\n}\n\nexport async function deleteCompanies(ids: string[], tx?: EntityManager) {\n const repository = tx ? tx.getRepository(Company) : getRepository(Company)\n return await repository.delete(ids)\n}\n\nexport async function deleteCompany(id: string, tx?: EntityManager) {\n const repository: Repository<Company> = tx ? tx.getRepository(Company) : getRepository(Company)\n return await repository.delete(id)\n}\n\n/** The words 「우리 회사」 keeps - what a save may set. */\nexport const OUR_COMPANY_FIELDS = ['name', 'representative', 'brn', 'corporateRegistrationNumber', 'address', 'phone'] as const\n\n/**\n * Keep this domain's own company: its row, made on the first save. Only the fields of 「우리 회사」 are taken, trimmed;\n * a name is required - a document cannot print a company without one.\n */\nexport async function saveOurCompany(patch: Partial<Company>, domain: Domain, user: User, tx: EntityManager): Promise<Company> {\n const repository = tx.getRepository(Company)\n const current = await ourCompanyOf(domain, tx)\n const words: Partial<Company> = {}\n for (const field of OUR_COMPANY_FIELDS) {\n const value = patch[field]\n if (value === undefined) continue\n words[field] = typeof value === 'string' ? value.trim() : value\n }\n const name = words.name ?? current?.name\n if (!name) throw new Refusal('company-name-required', {}, 'a company needs a name')\n const clash = await repository.findOne({ where: { domain: { id: domain.id }, name } })\n if (clash && clash.id !== current?.id) throw new Refusal('company-name-taken', { value: name }, `name: ${name} is already another company's`)\n return await repository.save({ ...(current ?? { domain, creator: user }), ...words, updater: user } as Company)\n}\n"]}
|
|
1
|
+
{"version":3,"file":"company-mutation.js","sourceRoot":"","sources":["../../../server/service/company/company-mutation.ts"],"names":[],"mappings":";;;AA+FA,sCAeC;AAED,sCAYC;AAED,0CAGC;AAED,sCAGC;AASD,wCAcC;;AA7JD,+CAAqF;AAIrF,iDAAqF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OAAO,EAAE,IAAI,EAAE,CAAC,EAAE,GAAG,KAAK,EAAE,OAAO,EAAE,IAAI,EAAa,CAAC,CAAA;AACjH,CAAC","sourcesContent":["import { Arg, Ctx, Directive, Mutation, Resolver, UseMiddleware } from 'type-graphql'\nimport { EntityManager, Repository } from 'typeorm'\n\nimport { User } from '@things-factory/auth-base'\nimport { Domain, getRepository, Refusal, SpeakRefusals } from '@things-factory/shell'\nimport { slugger } from '@things-factory/utils'\n\nimport { Company } from './company'\nimport { CompanyPatch, NewCompany } from './company-types'\nimport { ourCompanyOf } from './our-company'\n\n@Resolver(Company)\n@UseMiddleware(SpeakRefusals)\nexport class CompanyMutation {\n @Directive('@privilege(category: \"company\", privilege: \"mutation\", domainOwnerGranted: true)')\n @Directive('@auditTarget(kind: \"Company\", arg: \"company\")')\n @Directive('@transaction')\n @Mutation(returns => Company, { description: \"To keep 「우리 회사」 - this domain's own company, made on its first save (ADR-0176)\" })\n async saveCompany(@Arg('company') company: CompanyPatch, @Ctx() context: ResolverContext): Promise<Company> {\n const { domain, user, tx } = context.state\n return await saveOurCompany(company, domain, user, tx)\n }\n\n @Directive('@privilege(category: \"company\", privilege: \"mutation\")')\n @Directive('@transaction')\n @Mutation(returns => Company)\n async createCompany(@Arg('company') company: NewCompany, @Ctx() context: ResolverContext): Promise<Company> {\n const { domain, user, tx } = context.state\n return await createCompany(company, domain, user, tx)\n }\n\n @Directive('@privilege(category: \"company\", privilege: \"mutation\")')\n @Directive('@transaction')\n @Mutation(returns => Company)\n async updateCompany(\n @Arg('name') name: string,\n @Arg('patch') patch: CompanyPatch,\n @Ctx() context: ResolverContext\n ): Promise<Company> {\n const { domain, user, tx } = context.state\n return await updateCompany(name, patch, domain, user, tx)\n }\n\n @Directive('@privilege(category: \"company\", privilege: \"mutation\")')\n @Directive('@transaction')\n @Mutation(returns => [Company])\n async updateMultipleCompany(\n @Arg('patches', type => [CompanyPatch]) patches: CompanyPatch[],\n @Ctx() context: ResolverContext\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\n if (_createRecords.length > 0) {\n for (let i = 0; i < _createRecords.length; i++) {\n const patch: CompanyPatch = _createRecords[i]\n const result = await this.createCompany(patch as NewCompany, context)\n results.push({ ...result, cuFlag: '+' })\n }\n }\n\n if (_updateRecords.length > 0) {\n for (let i = 0; i < _updateRecords.length; i++) {\n const patch: CompanyPatch = _updateRecords[i]\n const result = await this.updateCompany(patch.name, patch, context)\n results.push({ ...result, cuFlag: 'M' })\n }\n }\n\n return results\n }\n\n @Directive('@privilege(category: \"company\", privilege: \"mutation\")')\n @Directive('@transaction')\n @Mutation(returns => Boolean)\n async deleteCompany(@Arg('id') id: string, @Ctx() context: ResolverContext): Promise<Boolean> {\n await deleteCompany(id, context.state.tx)\n\n return true\n }\n\n @Directive('@transaction')\n @Directive('@privilege(category: \"company\", privilege: \"mutation\")')\n @Mutation(returns => Boolean)\n async deleteCompanies(\n @Arg('ids', type => [String]) ids: string[],\n @Ctx() context: ResolverContext\n ): Promise<Boolean> {\n await deleteCompanies(ids, context.state.tx)\n\n return true\n }\n}\n\nexport async function createCompany(company: NewCompany, domain: Domain, user: User, tx?: EntityManager) {\n const companyRepository: Repository<Company> = tx ? tx.getRepository(Company) : getRepository(Company)\n const domainRepository: Repository<Domain> = tx ? tx.getRepository(Domain) : getRepository(Domain)\n\n const companyDomain: Domain = await domainRepository.save({\n subdomain: slugger(company.name),\n name: company.name\n })\n\n return await companyRepository.save({\n ...company,\n domain: companyDomain,\n creator: user,\n updater: user\n })\n}\n\nexport async function updateCompany(name: string, patch: CompanyPatch, domain: Domain, user: User, tx?: EntityManager) {\n const repository: Repository<Company> = tx ? tx.getRepository(Company) : getRepository(Company)\n const company = await repository.findOneBy({\n domain: { id: domain.id },\n name\n })\n\n return repository.save({\n ...company,\n ...patch,\n updater: user\n })\n}\n\nexport async function deleteCompanies(ids: string[], tx?: EntityManager) {\n const repository = tx ? tx.getRepository(Company) : getRepository(Company)\n return await repository.delete(ids)\n}\n\nexport async function deleteCompany(id: string, tx?: EntityManager) {\n const repository: Repository<Company> = tx ? tx.getRepository(Company) : getRepository(Company)\n return await repository.delete(id)\n}\n\n/** The words 「우리 회사」 keeps - what a save may set. */\nexport const OUR_COMPANY_FIELDS = ['name', 'representative', 'brn', 'corporateRegistrationNumber', 'address', 'phone'] as const\n\n/**\n * Keep this domain's own company: its row, made on the first save. Only the fields of 「우리 회사」 are taken, trimmed;\n * a name is required - a document cannot print a company without one.\n */\nexport async function saveOurCompany(patch: Partial<Company>, domain: Domain, user: User, tx: EntityManager): Promise<Company> {\n const repository = tx.getRepository(Company)\n const current = await ourCompanyOf(domain, tx)\n const words: Partial<Company> = {}\n for (const field of OUR_COMPANY_FIELDS) {\n const value = patch[field]\n if (value === undefined) continue\n words[field] = typeof value === 'string' ? value.trim() : value\n }\n const name = words.name ?? current?.name\n if (!name) throw new Refusal('company-name-required', {}, 'a company needs a name')\n const clash = await repository.findOne({ where: { domain: { id: domain.id }, name } })\n if (clash && clash.id !== current?.id) throw new Refusal('company-name-taken', { value: name }, `name: ${name} is already another company's`)\n return await repository.save({ ...(current ?? { domain, creator: user }), ...words, updater: user } as Company)\n}\n"]}
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { Attachment } from '@things-factory/attachment-base';
|
|
2
1
|
import { UserList } from '@things-factory/auth-base';
|
|
3
2
|
import { ListParam } from '@things-factory/shell';
|
|
4
3
|
import { BizplaceList } from '../bizplace/bizplace-types';
|
|
@@ -6,7 +5,6 @@ import { Company } from './company';
|
|
|
6
5
|
import { CompanyList } from './company-types';
|
|
7
6
|
export declare class CompanyQuery {
|
|
8
7
|
company(context: ResolverContext): Promise<Company | null>;
|
|
9
|
-
seal(company: Company): Promise<Attachment | null>;
|
|
10
8
|
companies(params: ListParam, context: ResolverContext): Promise<CompanyList>;
|
|
11
9
|
companyBizplaces(context: ResolverContext): Promise<BizplaceList>;
|
|
12
10
|
companyUsers(context: ResolverContext): Promise<UserList>;
|
|
@@ -4,7 +4,6 @@ exports.CompanyQuery = void 0;
|
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
5
|
const type_graphql_1 = require("type-graphql");
|
|
6
6
|
const typeorm_1 = require("typeorm");
|
|
7
|
-
const attachment_base_1 = require("@things-factory/attachment-base");
|
|
8
7
|
const auth_base_1 = require("@things-factory/auth-base");
|
|
9
8
|
const shell_1 = require("@things-factory/shell");
|
|
10
9
|
const bizplace_1 = require("../bizplace/bizplace");
|
|
@@ -16,9 +15,6 @@ let CompanyQuery = class CompanyQuery {
|
|
|
16
15
|
async company(context) {
|
|
17
16
|
return await (0, our_company_1.ourCompanyOf)(context.state.domain);
|
|
18
17
|
}
|
|
19
|
-
async seal(company) {
|
|
20
|
-
return await (0, our_company_1.companySealOf)(company);
|
|
21
|
-
}
|
|
22
18
|
async companies(params, context) {
|
|
23
19
|
const { domain } = context.state;
|
|
24
20
|
const convertedParams = (0, shell_1.convertListParams)(params, { domain });
|
|
@@ -58,14 +54,6 @@ tslib_1.__decorate([
|
|
|
58
54
|
tslib_1.__metadata("design:paramtypes", [Object]),
|
|
59
55
|
tslib_1.__metadata("design:returntype", Promise)
|
|
60
56
|
], CompanyQuery.prototype, "company", null);
|
|
61
|
-
tslib_1.__decorate([
|
|
62
|
-
(0, type_graphql_1.Directive)('@privilege(category: "company", privilege: "query", domainOwnerGranted: true)'),
|
|
63
|
-
(0, type_graphql_1.FieldResolver)(type => attachment_base_1.Attachment, { nullable: true, description: 'The seal (직인) official documents print' }),
|
|
64
|
-
tslib_1.__param(0, (0, type_graphql_1.Root)()),
|
|
65
|
-
tslib_1.__metadata("design:type", Function),
|
|
66
|
-
tslib_1.__metadata("design:paramtypes", [company_1.Company]),
|
|
67
|
-
tslib_1.__metadata("design:returntype", Promise)
|
|
68
|
-
], CompanyQuery.prototype, "seal", null);
|
|
69
57
|
tslib_1.__decorate([
|
|
70
58
|
(0, type_graphql_1.Directive)('@privilege(category: "company", privilege: "query")'),
|
|
71
59
|
(0, type_graphql_1.Query)(returns => company_types_1.CompanyList),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"company-query.js","sourceRoot":"","sources":["../../../server/service/company/company-query.ts"],"names":[],"mappings":";;;;AAAA,+
|
|
1
|
+
{"version":3,"file":"company-query.js","sourceRoot":"","sources":["../../../server/service/company/company-query.ts"],"names":[],"mappings":";;;;AAAA,+CAAoE;AACpE,qCAA4B;AAE5B,yDAA0F;AAC1F,iDAA2F;AAE3F,mDAA+C;AAC/C,+DAAyD;AACzD,uCAAmC;AACnC,mDAA6C;AAC7C,+CAA4C;AAGrC,IAAM,YAAY,GAAlB,MAAM,YAAY;IAGjB,AAAN,KAAK,CAAC,OAAO,CAAQ,OAAwB;QAC3C,OAAO,MAAM,IAAA,0BAAY,EAAC,OAAO,CAAC,KAAK,CAAC,MAAM,CAAC,CAAA;IACjD,CAAC;IAIK,AAAN,KAAK,CAAC,SAAS,CAA0B,MAAiB,EAAS,OAAwB;QACzF,MAAM,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,KAAK,CAAA;QAChC,MAAM,eAAe,GAAG,IAAA,yBAAiB,EAAC,MAAM,EAAE,EAAE,MAAM,EAAE,CAAC,CAAA;QAE7D,MAAM,CAAC,KAAK,EAAE,KAAK,CAAC,GAAG,MAAM,IAAA,qBAAa,EAAC,iBAAO,CAAC,CAAC,YAAY,CAAC;YAC/D,GAAG,eAAe;YAClB,SAAS,EAAE,CAAC,QAAQ,EAAE,SAAS,EAAE,SAAS,CAAC;SAC5C,CAAC,CAAA;QACF,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,CAAA;IACzB,CAAC;IAIK,AAAN,KAAK,CAAC,gBAAgB,CAAQ,OAAwB;QACpD,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,GAAG,OAAO,CAAC,KAAK,CAAA;QAEtC,MAAM,WAAW,GAAsB,MAAM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CAAC,EAAE,CAAC,2BAAW,CAAC;IACb,mBAAA,IAAA,mBAAI,EAAC,IAAI,CAAC,EAAE,CAAC,iBAAS,CAAC,CAAA;IAAqB,mBAAA,IAAA,kBAAG,GAAE,CAAA;;6CAAjB,iBAAS;;6CASzD;AAIK;IAFL,IAAA,wBAAS,EAAC,+EAA+E,CAAC;IAC1F,IAAA,oBAAK,EAAC,OAAO,CAAC,EAAE,CAAC,6BAAY,CAAC;IACP,mBAAA,IAAA,kBAAG,GAAE,CAAA;;;;oDAc5B;AAIK;IAFL,IAAA,wBAAS,EAAC,+EAA+E,CAAC;IAC1F,IAAA,oBAAK,EAAC,OAAO,CAAC,EAAE,CAAC,oBAAQ,CAAC;IACP,mBAAA,IAAA,kBAAG,GAAE,CAAA;;;;gDASxB;uBAjDU,YAAY;IADxB,IAAA,uBAAQ,EAAC,iBAAO,CAAC;GACL,YAAY,CAkDxB","sourcesContent":["import { Args, Ctx, Directive, Query, Resolver } from 'type-graphql'\nimport { In } from 'typeorm'\n\nimport { getDomainUsers, getUserDomains, User, UserList } from '@things-factory/auth-base'\nimport { convertListParams, Domain, getRepository, ListParam } from '@things-factory/shell'\n\nimport { Bizplace } from '../bizplace/bizplace'\nimport { BizplaceList } from '../bizplace/bizplace-types'\nimport { Company } from './company'\nimport { CompanyList } from './company-types'\nimport { ourCompanyOf } from './our-company'\n\n@Resolver(Company)\nexport class CompanyQuery {\n @Directive('@privilege(category: \"company\", privilege: \"query\", domainOwnerGranted: true)')\n @Query(returns => Company, { nullable: true, description: '「우리 회사」 - this domain\\'s own company, or none yet (ADR-0176)' })\n async company(@Ctx() context: ResolverContext): Promise<Company | null> {\n return await ourCompanyOf(context.state.domain)\n }\n\n @Directive('@privilege(category: \"company\", privilege: \"query\")')\n @Query(returns => CompanyList)\n async companies(@Args(type => ListParam) params: ListParam, @Ctx() context: ResolverContext): Promise<CompanyList> {\n const { domain } = context.state\n const convertedParams = convertListParams(params, { domain })\n\n const [items, total] = await getRepository(Company).findAndCount({\n ...convertedParams,\n relations: ['domain', 'creator', 'updater']\n })\n return { items, total }\n }\n\n @Directive('@privilege(category: \"company\", privilege: \"query\", domainOwnerGranted: true)')\n @Query(returns => BizplaceList)\n async companyBizplaces(@Ctx() context: ResolverContext): Promise<BizplaceList> {\n const { domain, user } = context.state\n\n const userDomains: Partial<Domain>[] = await getUserDomains(user)\n const company: Company = await getRepository(Company).findOneBy({\n domain: { id: domain.id }\n })\n\n const [items, total] = await getRepository(Bizplace).findAndCount({\n where: { company: { id: company.id }, domain: { id: In(userDomains.map(({ id }: Domain) => id)) } },\n relations: ['domain']\n })\n\n return { items, total }\n }\n\n @Directive('@privilege(category: \"company\", privilege: \"query\", domainOwnerGranted: true)')\n @Query(returns => UserList)\n async companyUsers(@Ctx() context: ResolverContext): Promise<UserList> {\n const { domain } = context.state\n\n const items: User[] = await getDomainUsers(domain)\n\n return {\n items,\n total: items.length\n }\n }\n}\n"]}
|
|
@@ -10,7 +10,7 @@ const bizplace_1 = require("../bizplace/bizplace");
|
|
|
10
10
|
/*
|
|
11
11
|
* A company and, for a domain, 「우리 회사」 (ADR-0176 decision 4): the one place its name, representative, registration
|
|
12
12
|
* numbers, address, phone and seal are kept. Quotations, invoices, pay slips and every official document read them from
|
|
13
|
-
* here (`our-company.ts`);
|
|
13
|
+
* here (`our-company.ts`); its seals are the seal register (`CompanySeal`, ADR-0188). A name is unique in its
|
|
14
14
|
* domain, not across domains - two businesses may share a trade name.
|
|
15
15
|
*/
|
|
16
16
|
let Company = class Company {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"company.js","sourceRoot":"","sources":["../../../server/service/company/company.ts"],"names":[],"mappings":";;;;AAAA,+CAAoD;AACpD,qCAUgB;AAEhB,yDAAgD;AAChD,iDAA8C;AAE9C,mDAA+C;AAE/C;;;;;GAKG;AAKI,IAAM,OAAO,GAAb,MAAM,OAAO;CAgGnB,CAAA;AAhGY,0BAAO;AAGT;IAFR,IAAA,gCAAsB,EAA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EAAC,IAAI,CAAC,EAAE,CAAC,gBAAI,EAAE;QACvB,QAAQ,EAAE,IAAI;KACf,CAAC;IACD,IAAA,oBAAK,EAAC,IAAI,CAAC,EAAE,CAAC,gBAAI,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;sCAC/B,gBAAI;wCAAA;AAGb;IADC,IAAA,oBAAU,EAAC,CAAC,OAAgB,EAAE,EAAE,CAAC,OAAO,CAAC,OAAO,CAAC;;0CACjC;AAIjB;IAFC,IAAA,0BAAgB,GAAE;IAClB,IAAA,oBAAK,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;sCACf,IAAI;0CAAA;AAIf;IAFC,IAAA,0BAAgB,GAAE;IAClB,IAAA,oBAAK,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;sCACf,IAAI;0CAAA;kBA/FJ,OAAO;IAJnB,IAAA,gBAAM,GAAE;IACR,IAAA,eAAK,EAAC,gBAAgB,EAAE,CAAC,OAAgB,EAAE,EAAE,CAAC,CAAC,OAAO,CAAC,MAAM,EAAE,OAAO,CAAC,IAAI,CAAC,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC;IAC/F,IAAA,eAAK,EAAC,gBAAgB,EAAE,CAAC,OAAgB,EAAE,EAAE,CAAC,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC;IAClF,IAAA,yBAAU,GAAE;GACA,OAAO,CAgGnB","sourcesContent":["import { Field, ID, ObjectType } from 'type-graphql'\nimport {\n Column,\n CreateDateColumn,\n Entity,\n Index,\n ManyToOne,\n OneToMany,\n PrimaryGeneratedColumn,\n RelationId,\n UpdateDateColumn\n} from 'typeorm'\n\nimport { User } from '@things-factory/auth-base'\nimport { Domain } from '@things-factory/shell'\n\nimport { Bizplace } from '../bizplace/bizplace'\n\n/*\n * A company and, for a domain, 「우리 회사」 (ADR-0176 decision 4): the one place its name, representative, registration\n * numbers, address, phone and seal are kept. Quotations, invoices, pay slips and every official document read them from\n * here (`our-company.ts`);
|
|
1
|
+
{"version":3,"file":"company.js","sourceRoot":"","sources":["../../../server/service/company/company.ts"],"names":[],"mappings":";;;;AAAA,+CAAoD;AACpD,qCAUgB;AAEhB,yDAAgD;AAChD,iDAA8C;AAE9C,mDAA+C;AAE/C;;;;;GAKG;AAKI,IAAM,OAAO,GAAb,MAAM,OAAO;CAgGnB,CAAA;AAhGY,0BAAO;AAGT;IAFR,IAAA,gCAAsB,EAAC,MAAM,CAAC;IAC9B,IAAA,oBAAK,EAAC,IAAI,CAAC,EAAE,CAAC,iBAAE,CAAC;;mCACC;AAInB;IAFC,IAAA,mBAAS,EAAC,IAAI,CAAC,EAAE,CAAC,cAAM,CAAC;IACzB,IAAA,oBAAK,EAAC,IAAI,CAAC,EAAE,CAAC,cAAM,CAAC;sCACb,cAAM;uCAAA;AAIf;IAFC,IAAA,oBAAU,EAAC,CAAC,OAAgB,EAAE,EAAE,CAAC,OAAO,CAAC,MAAM,CAAC;IAChD,IAAA,oBAAK,GAAE;;yCACQ;AAIhB;IAFC,IAAA,gBAAM,GAAE;IACR,IAAA,oBAAK,GAAE;;qCACI;AAMZ;IAJC,IAAA,gBAAM,EAAC;QACN,QAAQ,EAAE,IAAI;KACf,CAAC;IACD,IAAA,oBAAK,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;;4CACP;AAInB;IAFC,IAAA,gBAAM,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;IAC1B,IAAA,oBAAK,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;;4CACP;AAKnB;IAFC,IAAA,gBAAM,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;IAC1B,IAAA,oBAAK,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,WAAW,EAAE,wCAAwC,EAAE,CAAC;;oCACtE;AAKX;IAFC,IAAA,gBAAM,EAAC,EAAE,QAAQ,EAAE,IAAI,EA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ourcesContent":["import { Field, ID, ObjectType } from 'type-graphql'\nimport {\n Column,\n CreateDateColumn,\n Entity,\n Index,\n ManyToOne,\n OneToMany,\n PrimaryGeneratedColumn,\n RelationId,\n UpdateDateColumn\n} from 'typeorm'\n\nimport { User } from '@things-factory/auth-base'\nimport { Domain } from '@things-factory/shell'\n\nimport { Bizplace } from '../bizplace/bizplace'\n\n/*\n * A company and, for a domain, 「우리 회사」 (ADR-0176 decision 4): the one place its name, representative, registration\n * numbers, address, phone and seal are kept. Quotations, invoices, pay slips and every official document read them from\n * here (`our-company.ts`); its seals are the seal register (`CompanySeal`, ADR-0188). A name is unique in its\n * domain, not across domains - two businesses may share a trade name.\n */\n@Entity()\n@Index('ix_companies_0', (company: Company) => [company.domain, company.name], { unique: true })\n@Index('ix_companies_1', (company: Company) => [company.domain], { unique: false })\n@ObjectType()\nexport class Company {\n @PrimaryGeneratedColumn('uuid')\n @Field(type => ID)\n readonly id: string\n\n @ManyToOne(type => Domain)\n @Field(type => Domain)\n domain?: Domain\n\n @RelationId((company: Company) => company.domain)\n @Field()\n domainId: string\n\n @Column()\n @Field()\n name: string\n\n @Column({\n nullable: true\n })\n @Field({ nullable: true })\n description: string\n\n @Column({ nullable: true })\n @Field({ nullable: true })\n countryCode: string\n\n /* 사업자등록번호 */\n @Column({ nullable: true })\n @Field({ nullable: true, description: 'Business registration number (사업자등록번호)' })\n brn: string\n\n /* 법인등록번호 */\n @Column({ nullable: true })\n @Field({ nullable: true, description: 'Corporate registration number (법인등록번호)' })\n corporateRegistrationNumber: string\n\n @Column({ nullable: true })\n @Field({ nullable: true, description: 'The representative (대표자) as printed on official documents' })\n representative: string\n\n @Column({ nullable: true })\n @Field({ nullable: true })\n address: string\n\n @Column({ nullable: true })\n @Field({ nullable: true, description: 'The main phone number (대표 전화)' })\n phone: string\n\n @Column({\n nullable: true\n })\n @Field({ nullable: true })\n postalCode: string\n\n @Column({\n nullable: true\n })\n @Field({ nullable: true })\n type: string\n\n @Column({\n nullable: true\n })\n @Field({ nullable: true })\n status: string\n\n @OneToMany(type => Bizplace, bizplace => bizplace.company)\n @Field(type => [Bizplace])\n bizplaces: Bizplace[]\n\n @ManyToOne(type => User, {\n nullable: true\n })\n @Field(type => User, { nullable: true })\n creator: User\n\n @RelationId((company: Company) => company.creator)\n creatorId: string\n\n @ManyToOne(type => User, {\n nullable: true\n })\n @Field(type => User, { nullable: true })\n updater: User\n\n @RelationId((company: Company) => company.updater)\n updaterId: string\n\n @CreateDateColumn()\n @Field({ nullable: true })\n createdAt: Date\n\n @UpdateDateColumn()\n @Field({ nullable: true })\n updatedAt: Date\n}\n"]}
|
|
@@ -1,8 +1,5 @@
|
|
|
1
|
-
import { Attachment } from '@things-factory/attachment-base';
|
|
2
1
|
import { getRepository } from '@things-factory/shell';
|
|
3
2
|
import { Company } from './company';
|
|
4
|
-
/** The attachment `refType` of the company's seal - read by whoever keeps the company (`company-seal-reader.ts`). */
|
|
5
|
-
export declare const COMPANY_SEAL_REF_TYPE = "Company Seal";
|
|
6
3
|
/** The company as a document prints it. `seal` is a `data:` URL, made on the server only for a print. */
|
|
7
4
|
export interface PrintedCompany {
|
|
8
5
|
name: string;
|
|
@@ -20,18 +17,15 @@ type Source = {
|
|
|
20
17
|
export declare function ourCompanyOf(domain: {
|
|
21
18
|
id: string;
|
|
22
19
|
}, manager?: Source): Promise<Company | null>;
|
|
23
|
-
/** The seal attachment of a company, if one was put on it. */
|
|
24
|
-
export declare function companySealOf(company: {
|
|
25
|
-
id: string;
|
|
26
|
-
} | null, manager?: Source): Promise<Attachment | null>;
|
|
27
20
|
/** The words of a company row as printed - a domain with no row yet prints its own name (`description`, else `name`). */
|
|
28
21
|
export declare function printedWordsOf(company: Partial<Company> | null, domain: {
|
|
29
22
|
name?: string;
|
|
30
23
|
description?: string;
|
|
31
24
|
}): PrintedCompany;
|
|
32
25
|
/**
|
|
33
|
-
* The company as a document prints it. With `seal`, the
|
|
34
|
-
* module's print, whose page loads nothing but what it carries. Never handed
|
|
26
|
+
* The company as a document prints it. With `seal`, the impression of the seal register's printed seal (ADR-0188) is read
|
|
27
|
+
* from storage into a `data:` URL - for the pdf module's print, whose page loads nothing but what it carries. Never handed
|
|
28
|
+
* to a screen.
|
|
35
29
|
*/
|
|
36
30
|
export declare function printedCompanyOf(domain: {
|
|
37
31
|
id: string;
|
|
@@ -1,30 +1,17 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.COMPANY_SEAL_REF_TYPE = void 0;
|
|
4
3
|
exports.ourCompanyOf = ourCompanyOf;
|
|
5
|
-
exports.companySealOf = companySealOf;
|
|
6
4
|
exports.printedWordsOf = printedWordsOf;
|
|
7
5
|
exports.printedCompanyOf = printedCompanyOf;
|
|
8
6
|
const attachment_base_1 = require("@things-factory/attachment-base");
|
|
9
7
|
const shell_1 = require("@things-factory/shell");
|
|
8
|
+
const company_seal_service_1 = require("../company-seal/company-seal-service");
|
|
10
9
|
const company_1 = require("./company");
|
|
11
|
-
/*
|
|
12
|
-
* 「우리 회사」 (ADR-0176 decision 4) - the company row of a domain, as the documents it writes read it. Quotations,
|
|
13
|
-
* invoices, pay slips and the official documents all print it from here; none keeps a copy of its own.
|
|
14
|
-
*/
|
|
15
|
-
/** The attachment `refType` of the company's seal - read by whoever keeps the company (`company-seal-reader.ts`). */
|
|
16
|
-
exports.COMPANY_SEAL_REF_TYPE = 'Company Seal';
|
|
17
10
|
const sourceOf = (manager) => manager ?? { getRepository: shell_1.getRepository };
|
|
18
11
|
/** This domain's own company row, or none yet. */
|
|
19
12
|
async function ourCompanyOf(domain, manager) {
|
|
20
13
|
return (await sourceOf(manager).getRepository(company_1.Company).findOne({ where: { domain: { id: domain.id } }, order: { createdAt: 'ASC' } })) ?? null;
|
|
21
14
|
}
|
|
22
|
-
/** The seal attachment of a company, if one was put on it. */
|
|
23
|
-
async function companySealOf(company, manager) {
|
|
24
|
-
if (!company)
|
|
25
|
-
return null;
|
|
26
|
-
return (await sourceOf(manager).getRepository(attachment_base_1.Attachment).findOne({ where: { refType: exports.COMPANY_SEAL_REF_TYPE, refBy: company.id }, order: { createdAt: 'DESC' } })) ?? null;
|
|
27
|
-
}
|
|
28
15
|
/** The words of a company row as printed - a domain with no row yet prints its own name (`description`, else `name`). */
|
|
29
16
|
function printedWordsOf(company, domain) {
|
|
30
17
|
const text = (value) => (typeof value === 'string' ? value.trim() : '');
|
|
@@ -38,15 +25,16 @@ function printedWordsOf(company, domain) {
|
|
|
38
25
|
};
|
|
39
26
|
}
|
|
40
27
|
/**
|
|
41
|
-
* The company as a document prints it. With `seal`, the
|
|
42
|
-
* module's print, whose page loads nothing but what it carries. Never handed
|
|
28
|
+
* The company as a document prints it. With `seal`, the impression of the seal register's printed seal (ADR-0188) is read
|
|
29
|
+
* from storage into a `data:` URL - for the pdf module's print, whose page loads nothing but what it carries. Never handed
|
|
30
|
+
* to a screen.
|
|
43
31
|
*/
|
|
44
32
|
async function printedCompanyOf(domain, options = {}) {
|
|
45
33
|
const company = await ourCompanyOf(domain, options.manager);
|
|
46
34
|
const printed = printedWordsOf(company, domain);
|
|
47
35
|
if (!options.seal)
|
|
48
36
|
return printed;
|
|
49
|
-
const seal = await
|
|
37
|
+
const seal = await (0, company_seal_service_1.sealImpressionOf)(await (0, company_seal_service_1.printedSealOf)(domain, options.manager), options.manager);
|
|
50
38
|
if (!seal?.path)
|
|
51
39
|
return printed;
|
|
52
40
|
const contents = await attachment_base_1.STORAGE.readFile(seal.path);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"our-company.js","sourceRoot":"","sources":["../../../server/service/company/our-company.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"our-company.js","sourceRoot":"","sources":["../../../server/service/company/our-company.ts"],"names":[],"mappings":";;AA0BA,oCAEC;AAGD,wCAUC;AAOD,4CAQC;AAxDD,qEAAyD;AACzD,iDAAqD;AAErD,+EAAsF;AACtF,uCAAmC;AAmBnC,M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CAAC,MAAM,EAAE,OAAO,CAAC,OAAO,CAAC,CAAA;IAC3D,MAAM,OAAO,GAAG,cAAc,CAAC,OAAO,EAAE,MAAM,CAAC,CAAA;IAC/C,IAAI,CAAC,OAAO,CAAC,IAAI;QAAE,OAAO,OAAO,CAAA;IACjC,MAAM,IAAI,GAAG,MAAM,IAAA,uCAAgB,EAAC,MAAM,IAAA,oCAAa,EAAC,MAAM,EAAE,OAAO,CAAC,OAAO,CAAC,EAAE,OAAO,CAAC,OAAO,CAAC,CAAA;IAClG,IAAI,CAAC,IAAI,EAAE,IAAI;QAAE,OAAO,OAAO,CAAA;IAC/B,MAAM,QAAQ,GAAW,MAAM,yBAAO,CAAC,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;IAC1D,OAAO,EAAE,GAAG,OAAO,EAAE,IAAI,EAAE,QAAQ,IAAI,CAAC,QAAQ,IAAI,WAAW,WAAW,MAAM,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC,QAAQ,CAAC,QAAQ,CAAC,EAAE,EAAE,CAAA;AACxH,CAAC","sourcesContent":["import { STORAGE } from '@things-factory/attachment-base'\nimport { getRepository } from '@things-factory/shell'\n\nimport { printedSealOf, sealImpressionOf } from '../company-seal/company-seal-service'\nimport { Company } from './company'\n\n/*\n * 「우리 회사」 (ADR-0176 decision 4) - the company row of a domain, as the documents it writes read it. Quotations,\n * invoices, pay slips and the official documents all print it from here; none keeps a copy of its own.\n */\n\n/** The company as a document prints it. `seal` is a `data:` URL, made on the server only for a print. */\nexport interface PrintedCompany {\n name: string\n representative: string\n brn: string\n corporateRegistrationNumber: string\n address: string\n phone: string\n seal?: string\n}\n\ntype Source = { getRepository: typeof getRepository }\nconst sourceOf = (manager?: Source) => manager ?? { getRepository }\n\n/** This domain's own company row, or none yet. */\nexport async function ourCompanyOf(domain: { id: string }, manager?: Source): Promise<Company | null> {\n return (await sourceOf(manager).getRepository(Company).findOne({ where: { domain: { id: domain.id } }, order: { createdAt: 'ASC' } })) ?? null\n}\n\n/** The words of a company row as printed - a domain with no row yet prints its own name (`description`, else `name`). */\nexport function printedWordsOf(company: Partial<Company> | null, domain: { name?: string; description?: string }): PrintedCompany {\n const text = (value: unknown) => (typeof value === 'string' ? value.trim() : '')\n return {\n name: text(company?.name) || text(domain.description) || text(domain.name),\n representative: text(company?.representative),\n brn: text(company?.brn),\n corporateRegistrationNumber: text(company?.corporateRegistrationNumber),\n address: text(company?.address),\n phone: text(company?.phone)\n }\n}\n\n/**\n * The company as a document prints it. With `seal`, the impression of the seal register's printed seal (ADR-0188) is read\n * from storage into a `data:` URL - for the pdf module's print, whose page loads nothing but what it carries. Never handed\n * to a screen.\n */\nexport async function printedCompanyOf(domain: { id: string; name?: string; description?: string }, options: { seal?: boolean; manager?: Source } = {}): Promise<PrintedCompany> {\n const company = await ourCompanyOf(domain, options.manager)\n const printed = printedWordsOf(company, domain)\n if (!options.seal) return printed\n const seal = await sealImpressionOf(await printedSealOf(domain, options.manager), options.manager)\n if (!seal?.path) return printed\n const contents: Buffer = await STORAGE.readFile(seal.path)\n return { ...printed, seal: `data:${seal.mimetype || 'image/png'};base64,${Buffer.from(contents).toString('base64')}` }\n}\n"]}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { FileUpload } from 'graphql-upload/GraphQLUpload.js';
|
|
2
|
+
import { Attachment } from '@things-factory/attachment-base';
|
|
3
|
+
import { CompanySeal } from './company-seal';
|
|
4
|
+
import { CompanySealPatch } from './company-seal-types';
|
|
5
|
+
export declare class CompanySealMutation {
|
|
6
|
+
updateMultipleCompanySeal(patches: CompanySealPatch[], context: ResolverContext): Promise<CompanySeal[]>;
|
|
7
|
+
attachCompanySealImpression(sealId: string, file: FileUpload | null, context: ResolverContext): Promise<Attachment | null>;
|
|
8
|
+
}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.CompanySealMutation = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const GraphQLUpload_js_1 = tslib_1.__importDefault(require("graphql-upload/GraphQLUpload.js"));
|
|
6
|
+
const type_graphql_1 = require("type-graphql");
|
|
7
|
+
const attachment_base_1 = require("@things-factory/attachment-base");
|
|
8
|
+
const shell_1 = require("@things-factory/shell");
|
|
9
|
+
const company_seal_1 = require("./company-seal");
|
|
10
|
+
const company_seal_service_1 = require("./company-seal-service");
|
|
11
|
+
const company_seal_types_1 = require("./company-seal-types");
|
|
12
|
+
let CompanySealMutation = class CompanySealMutation {
|
|
13
|
+
async updateMultipleCompanySeal(patches, context) {
|
|
14
|
+
const { domain, user, tx } = context.state;
|
|
15
|
+
return await (0, company_seal_service_1.saveCompanySeals)(patches, domain, user, tx);
|
|
16
|
+
}
|
|
17
|
+
async attachCompanySealImpression(sealId, file, context) {
|
|
18
|
+
const { domain, tx } = context.state;
|
|
19
|
+
if (!(await (0, company_seal_service_1.companySealOf)(domain, sealId, tx)))
|
|
20
|
+
throw new shell_1.Refusal('company-seal-not-found', {}, 'the seal was not found. reload and try again.');
|
|
21
|
+
return await (0, attachment_base_1.replaceAttachment)({ file, refType: company_seal_service_1.COMPANY_SEAL_REF_TYPE, refBy: sealId, category: 'seal' }, context);
|
|
22
|
+
}
|
|
23
|
+
};
|
|
24
|
+
exports.CompanySealMutation = CompanySealMutation;
|
|
25
|
+
tslib_1.__decorate([
|
|
26
|
+
(0, type_graphql_1.Directive)('@privilege(category: "company-seal", privilege: "mutation", domainOwnerGranted: true)'),
|
|
27
|
+
(0, type_graphql_1.Directive)('@auditTarget(kind: "CompanySeal", arg: "patches")'),
|
|
28
|
+
(0, type_graphql_1.Directive)('@transaction'),
|
|
29
|
+
(0, type_graphql_1.Mutation)(returns => [company_seal_1.CompanySeal], { description: 'To keep the seal register - new and changed seals; a seal is closed by its disposal, never deleted (ADR-0188)' }),
|
|
30
|
+
tslib_1.__param(0, (0, type_graphql_1.Arg)('patches', type => [company_seal_types_1.CompanySealPatch])),
|
|
31
|
+
tslib_1.__param(1, (0, type_graphql_1.Ctx)()),
|
|
32
|
+
tslib_1.__metadata("design:type", Function),
|
|
33
|
+
tslib_1.__metadata("design:paramtypes", [Array, Object]),
|
|
34
|
+
tslib_1.__metadata("design:returntype", Promise)
|
|
35
|
+
], CompanySealMutation.prototype, "updateMultipleCompanySeal", null);
|
|
36
|
+
tslib_1.__decorate([
|
|
37
|
+
(0, type_graphql_1.Directive)('@privilege(category: "company-seal", privilege: "mutation", domainOwnerGranted: true)'),
|
|
38
|
+
(0, type_graphql_1.Directive)('@auditTarget(kind: "CompanySeal", arg: "sealId")'),
|
|
39
|
+
(0, type_graphql_1.Directive)('@transaction'),
|
|
40
|
+
(0, type_graphql_1.Mutation)(returns => attachment_base_1.Attachment, { nullable: true, description: "To put a seal's impression (인영) on its row, replacing the one it had; no file takes it away" }),
|
|
41
|
+
tslib_1.__param(0, (0, type_graphql_1.Arg)('sealId')),
|
|
42
|
+
tslib_1.__param(1, (0, type_graphql_1.Arg)('file', type => GraphQLUpload_js_1.default, { nullable: true })),
|
|
43
|
+
tslib_1.__param(2, (0, type_graphql_1.Ctx)()),
|
|
44
|
+
tslib_1.__metadata("design:type", Function),
|
|
45
|
+
tslib_1.__metadata("design:paramtypes", [String, Object, Object]),
|
|
46
|
+
tslib_1.__metadata("design:returntype", Promise)
|
|
47
|
+
], CompanySealMutation.prototype, "attachCompanySealImpression", null);
|
|
48
|
+
exports.CompanySealMutation = CompanySealMutation = tslib_1.__decorate([
|
|
49
|
+
(0, type_graphql_1.Resolver)(company_seal_1.CompanySeal),
|
|
50
|
+
(0, type_graphql_1.UseMiddleware)(shell_1.SpeakRefusals)
|
|
51
|
+
], CompanySealMutation);
|
|
52
|
+
//# sourceMappingURL=company-seal-mutation.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"company-seal-mutation.js","sourceRoot":"","sources":["../../../server/service/company-seal/company-seal-mutation.ts"],"names":[],"mappings":";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AAgB,CAAC,CAAC,CAAA;IAA+B,mBAAA,IAAA,kBAAG,GAAE,CAAA;;;;oEAG9G;AAMK;IAJL,IAAA,wBAAS,EAAC,uFAAuF,CAAC;IAClG,IAAA,wBAAS,EAAC,kDAAkD,CAAC;IAC7D,IAAA,wBAAS,EAAC,cAAc,CAAC;IACzB,IAAA,uBAAQ,EAAC,OAAO,CAAC,EAAE,CAAC,4BAAU,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,WAAW,EAAE,6FAA6F,EAAE,CAAC;IAE7J,mBAAA,IAAA,kBAAG,EAAC,QAAQ,CAAC,CAAA;IACb,mBAAA,IAAA,kBAAG,EAAC,MAAM,EAAE,IAAI,CAAC,EAAE,CAAC,0BAAa,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC,CAAA;IACtD,mBAAA,IAAA,kBAAG,GAAE,CAAA;;;;sEAKP;8BAtBU,mBAAmB;IAF/B,IAAA,uBAAQ,EAAC,0BAAW,CAAC;IACrB,IAAA,4BAAa,EAAC,qBAAa,CAAC;GAChB,mBAAmB,CAuB/B","sourcesContent":["import type { FileUpload } from 'graphql-upload/GraphQLUpload.js'\nimport GraphQLUpload from 'graphql-upload/GraphQLUpload.js'\nimport { Arg, Ctx, Directive, Mutation, Resolver, UseMiddleware } from 'type-graphql'\n\nimport { Attachment, replaceAttachment } from '@things-factory/attachment-base'\nimport { Refusal, SpeakRefusals } from '@things-factory/shell'\n\nimport { CompanySeal } from './company-seal'\nimport { COMPANY_SEAL_REF_TYPE, companySealOf, saveCompanySeals } from './company-seal-service'\nimport { CompanySealPatch } from './company-seal-types'\n\n@Resolver(CompanySeal)\n@UseMiddleware(SpeakRefusals)\nexport class CompanySealMutation {\n @Directive('@privilege(category: \"company-seal\", privilege: \"mutation\", domainOwnerGranted: true)')\n @Directive('@auditTarget(kind: \"CompanySeal\", arg: \"patches\")')\n @Directive('@transaction')\n @Mutation(returns => [CompanySeal], { description: 'To keep the seal register - new and changed seals; a seal is closed by its disposal, never deleted (ADR-0188)' })\n async updateMultipleCompanySeal(@Arg('patches', type => [CompanySealPatch]) patches: CompanySealPatch[], @Ctx() context: ResolverContext): Promise<CompanySeal[]> {\n const { domain, user, tx } = context.state\n return await saveCompanySeals(patches, domain, user, tx)\n }\n\n @Directive('@privilege(category: \"company-seal\", privilege: \"mutation\", domainOwnerGranted: true)')\n @Directive('@auditTarget(kind: \"CompanySeal\", arg: \"sealId\")')\n @Directive('@transaction')\n @Mutation(returns => Attachment, { nullable: true, description: \"To put a seal's impression (인영) on its row, replacing the one it had; no file takes it away\" })\n async attachCompanySealImpression(\n @Arg('sealId') sealId: string,\n @Arg('file', type => GraphQLUpload, { nullable: true }) file: FileUpload | null,\n @Ctx() context: ResolverContext\n ): Promise<Attachment | null> {\n const { domain, tx } = context.state\n if (!(await companySealOf(domain, sealId, tx))) throw new Refusal('company-seal-not-found', {}, 'the seal was not found. reload and try again.')\n return await replaceAttachment({ file, refType: COMPANY_SEAL_REF_TYPE, refBy: sealId, category: 'seal' }, context)\n }\n}\n"]}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { Attachment } from '@things-factory/attachment-base';
|
|
2
|
+
import { User } from '@things-factory/auth-base';
|
|
3
|
+
import { ListParam } from '@things-factory/shell';
|
|
4
|
+
import { CompanySeal } from './company-seal';
|
|
5
|
+
import { CompanySealCustodianChoice, CompanySealList } from './company-seal-types';
|
|
6
|
+
export declare class CompanySealQuery {
|
|
7
|
+
companySeals(params: ListParam, context: ResolverContext): Promise<CompanySealList>;
|
|
8
|
+
companySealCustodianChoices(context: ResolverContext): Promise<CompanySealCustodianChoice[]>;
|
|
9
|
+
impression(seal: CompanySeal): Promise<Attachment | null>;
|
|
10
|
+
inUse(seal: CompanySeal): boolean;
|
|
11
|
+
custodian(seal: CompanySeal): Promise<User | null>;
|
|
12
|
+
updater(seal: CompanySeal): Promise<User | null>;
|
|
13
|
+
}
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.CompanySealQuery = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const type_graphql_1 = require("type-graphql");
|
|
6
|
+
const attachment_base_1 = require("@things-factory/attachment-base");
|
|
7
|
+
const auth_base_1 = require("@things-factory/auth-base");
|
|
8
|
+
const shell_1 = require("@things-factory/shell");
|
|
9
|
+
const company_seal_1 = require("./company-seal");
|
|
10
|
+
const company_seal_rules_1 = require("./company-seal-rules");
|
|
11
|
+
const company_seal_service_1 = require("./company-seal-service");
|
|
12
|
+
const company_seal_types_1 = require("./company-seal-types");
|
|
13
|
+
let CompanySealQuery = class CompanySealQuery {
|
|
14
|
+
async companySeals(params, context) {
|
|
15
|
+
const queryBuilder = (0, shell_1.getQueryBuilderFromListParams)({
|
|
16
|
+
domain: context.state.domain,
|
|
17
|
+
params,
|
|
18
|
+
repository: (0, shell_1.getRepository)(company_seal_1.CompanySeal),
|
|
19
|
+
searchables: ['name', 'keptAt', 'usage', 'notes'],
|
|
20
|
+
alias: 'seal',
|
|
21
|
+
defaultSortings: [{ name: 'kind' }, { name: 'name' }]
|
|
22
|
+
});
|
|
23
|
+
const [items, total] = await queryBuilder.getManyAndCount();
|
|
24
|
+
return { items, total };
|
|
25
|
+
}
|
|
26
|
+
async companySealCustodianChoices(context) {
|
|
27
|
+
return (await (0, auth_base_1.getDomainUsers)(context.state.domain)).map(one => ({ id: one.id, name: one.name, email: one.email }));
|
|
28
|
+
}
|
|
29
|
+
async impression(seal) {
|
|
30
|
+
return await (0, company_seal_service_1.sealImpressionOf)(seal);
|
|
31
|
+
}
|
|
32
|
+
inUse(seal) {
|
|
33
|
+
return (0, company_seal_rules_1.inUse)(seal);
|
|
34
|
+
}
|
|
35
|
+
async custodian(seal) {
|
|
36
|
+
return seal.custodianId ? await (0, shell_1.getRepository)(auth_base_1.User).findOne({ where: { id: seal.custodianId } }) : null;
|
|
37
|
+
}
|
|
38
|
+
async updater(seal) {
|
|
39
|
+
return seal.updaterId ? await (0, shell_1.getRepository)(auth_base_1.User).findOne({ where: { id: seal.updaterId } }) : null;
|
|
40
|
+
}
|
|
41
|
+
};
|
|
42
|
+
exports.CompanySealQuery = CompanySealQuery;
|
|
43
|
+
tslib_1.__decorate([
|
|
44
|
+
(0, type_graphql_1.Directive)('@privilege(category: "company-seal", privilege: "query", domainOwnerGranted: true)'),
|
|
45
|
+
(0, type_graphql_1.Query)(returns => company_seal_types_1.CompanySealList, { description: '인감 대장 - the seals of 「우리 회사」 (ADR-0188)' }),
|
|
46
|
+
tslib_1.__param(0, (0, type_graphql_1.Args)(type => shell_1.ListParam)),
|
|
47
|
+
tslib_1.__param(1, (0, type_graphql_1.Ctx)()),
|
|
48
|
+
tslib_1.__metadata("design:type", Function),
|
|
49
|
+
tslib_1.__metadata("design:paramtypes", [shell_1.ListParam, Object]),
|
|
50
|
+
tslib_1.__metadata("design:returntype", Promise)
|
|
51
|
+
], CompanySealQuery.prototype, "companySeals", null);
|
|
52
|
+
tslib_1.__decorate([
|
|
53
|
+
(0, type_graphql_1.Directive)('@privilege(category: "company-seal", privilege: "mutation", domainOwnerGranted: true)'),
|
|
54
|
+
(0, type_graphql_1.Query)(returns => [company_seal_types_1.CompanySealCustodianChoice], { description: 'The people of the domain who can keep a seal' }),
|
|
55
|
+
tslib_1.__param(0, (0, type_graphql_1.Ctx)()),
|
|
56
|
+
tslib_1.__metadata("design:type", Function),
|
|
57
|
+
tslib_1.__metadata("design:paramtypes", [Object]),
|
|
58
|
+
tslib_1.__metadata("design:returntype", Promise)
|
|
59
|
+
], CompanySealQuery.prototype, "companySealCustodianChoices", null);
|
|
60
|
+
tslib_1.__decorate([
|
|
61
|
+
(0, type_graphql_1.FieldResolver)(type => attachment_base_1.Attachment, { nullable: true, description: 'Its impression (인영)' }),
|
|
62
|
+
tslib_1.__param(0, (0, type_graphql_1.Root)()),
|
|
63
|
+
tslib_1.__metadata("design:type", Function),
|
|
64
|
+
tslib_1.__metadata("design:paramtypes", [company_seal_1.CompanySeal]),
|
|
65
|
+
tslib_1.__metadata("design:returntype", Promise)
|
|
66
|
+
], CompanySealQuery.prototype, "impression", null);
|
|
67
|
+
tslib_1.__decorate([
|
|
68
|
+
(0, type_graphql_1.FieldResolver)(type => Boolean, { description: 'Not disposed of' }),
|
|
69
|
+
tslib_1.__param(0, (0, type_graphql_1.Root)()),
|
|
70
|
+
tslib_1.__metadata("design:type", Function),
|
|
71
|
+
tslib_1.__metadata("design:paramtypes", [company_seal_1.CompanySeal]),
|
|
72
|
+
tslib_1.__metadata("design:returntype", Boolean)
|
|
73
|
+
], CompanySealQuery.prototype, "inUse", null);
|
|
74
|
+
tslib_1.__decorate([
|
|
75
|
+
(0, type_graphql_1.FieldResolver)(type => auth_base_1.User, { nullable: true }),
|
|
76
|
+
tslib_1.__param(0, (0, type_graphql_1.Root)()),
|
|
77
|
+
tslib_1.__metadata("design:type", Function),
|
|
78
|
+
tslib_1.__metadata("design:paramtypes", [company_seal_1.CompanySeal]),
|
|
79
|
+
tslib_1.__metadata("design:returntype", Promise)
|
|
80
|
+
], CompanySealQuery.prototype, "custodian", null);
|
|
81
|
+
tslib_1.__decorate([
|
|
82
|
+
(0, type_graphql_1.FieldResolver)(type => auth_base_1.User, { nullable: true }),
|
|
83
|
+
tslib_1.__param(0, (0, type_graphql_1.Root)()),
|
|
84
|
+
tslib_1.__metadata("design:type", Function),
|
|
85
|
+
tslib_1.__metadata("design:paramtypes", [company_seal_1.CompanySeal]),
|
|
86
|
+
tslib_1.__metadata("design:returntype", Promise)
|
|
87
|
+
], CompanySealQuery.prototype, "updater", null);
|
|
88
|
+
exports.CompanySealQuery = CompanySealQuery = tslib_1.__decorate([
|
|
89
|
+
(0, type_graphql_1.Resolver)(company_seal_1.CompanySeal)
|
|
90
|
+
], CompanySealQuery);
|
|
91
|
+
//# sourceMappingURL=company-seal-query.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"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Q,EAAE,IAAI,EAAE,WAAW,EAAE,qBAAqB,EAAE,CAAC;IACxE,mBAAA,IAAA,mBAAI,GAAE,CAAA;;6CAAO,0BAAW;;kDAEzC;AAGD;IADC,IAAA,4BAAa,EAAC,IAAI,CAAC,EAAE,CAAC,OAAO,EAAE,EAAE,WAAW,EAAE,iBAAiB,EAAE,CAAC;IAC5D,mBAAA,IAAA,mBAAI,GAAE,CAAA;;6CAAO,0BAAW;;6CAE9B;AAGK;IADL,IAAA,4BAAa,EAAC,IAAI,CAAC,EAAE,CAAC,gBAAI,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;IAC/B,mBAAA,IAAA,mBAAI,GAAE,CAAA;;6CAAO,0BAAW;;iDAExC;AAGK;IADL,IAAA,4BAAa,EAAC,IAAI,CAAC,EAAE,CAAC,gBAAI,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;IACjC,mBAAA,IAAA,mBAAI,GAAE,CAAA;;6CAAO,0BAAW;;+CAEtC;2BAxCU,gBAAgB;IAD5B,IAAA,uBAAQ,EAAC,0BAAW,CAAC;GACT,gBAAgB,CAyC5B","sourcesContent":["import { Args, Ctx, Directive, FieldResolver, Query, Resolver, Root } from 'type-graphql'\n\nimport { Attachment } from '@things-factory/attachment-base'\nimport { getDomainUsers, User } from '@things-factory/auth-base'\nimport { getQueryBuilderFromListParams, getRepository, ListParam } from '@things-factory/shell'\n\nimport { CompanySeal } from './company-seal'\nimport { inUse } from './company-seal-rules'\nimport { sealImpressionOf } from './company-seal-service'\nimport { CompanySealCustodianChoice, CompanySealList } from './company-seal-types'\n\n@Resolver(CompanySeal)\nexport class CompanySealQuery {\n @Directive('@privilege(category: \"company-seal\", privilege: \"query\", domainOwnerGranted: true)')\n @Query(returns => CompanySealList, { description: '인감 대장 - the seals of 「우리 회사」 (ADR-0188)' })\n async companySeals(@Args(type => ListParam) params: ListParam, @Ctx() context: ResolverContext): Promise<CompanySealList> {\n const queryBuilder = getQueryBuilderFromListParams({\n domain: context.state.domain,\n params,\n repository: getRepository(CompanySeal),\n searchables: ['name', 'keptAt', 'usage', 'notes'],\n alias: 'seal',\n defaultSortings: [{ name: 'kind' }, { name: 'name' }]\n })\n const [items, total] = await queryBuilder.getManyAndCount()\n return { items, total }\n }\n\n @Directive('@privilege(category: \"company-seal\", privilege: \"mutation\", domainOwnerGranted: true)')\n @Query(returns => [CompanySealCustodianChoice], { description: 'The people of the domain who can keep a seal' })\n async companySealCustodianChoices(@Ctx() context: ResolverContext): Promise<CompanySealCustodianChoice[]> {\n return (await getDomainUsers(context.state.domain)).map(one => ({ id: one.id, name: one.name, email: one.email }))\n }\n\n @FieldResolver(type => Attachment, { nullable: true, description: 'Its impression (인영)' })\n async impression(@Root() seal: CompanySeal): Promise<Attachment | null> {\n return await sealImpressionOf(seal)\n }\n\n @FieldResolver(type => Boolean, { description: 'Not disposed of' })\n inUse(@Root() seal: CompanySeal): boolean {\n return inUse(seal)\n }\n\n @FieldResolver(type => User, { nullable: true })\n async custodian(@Root() seal: CompanySeal): Promise<User | null> {\n return seal.custodianId ? await getRepository(User).findOne({ where: { id: seal.custodianId } }) : null\n }\n\n @FieldResolver(type => User, { nullable: true })\n async updater(@Root() seal: CompanySeal): Promise<User | null> {\n return seal.updaterId ? await getRepository(User).findOne({ where: { id: seal.updaterId } }) : null\n }\n}\n"]}
|