@things-factory/routing-base 5.0.15 → 6.0.0-alpha.10
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/service/operation/operation-mutation.js +4 -4
- package/dist-server/service/operation/operation-mutation.js.map +1 -1
- package/dist-server/service/operation/operation-query.js +9 -11
- package/dist-server/service/operation/operation-query.js.map +1 -1
- package/dist-server/service/operation/operation-type.js.map +1 -1
- package/dist-server/service/operation/operation.js +3 -4
- package/dist-server/service/operation/operation.js.map +1 -1
- package/dist-server/service/routing/routing-mutation.js +4 -4
- package/dist-server/service/routing/routing-mutation.js.map +1 -1
- package/dist-server/service/routing/routing-query.js +10 -12
- package/dist-server/service/routing/routing-query.js.map +1 -1
- package/dist-server/service/routing/routing-type.js.map +1 -1
- package/dist-server/service/routing/routing.js +3 -4
- package/dist-server/service/routing/routing.js.map +1 -1
- package/dist-server/service/routing-item/routing-item-mutation.js +4 -4
- package/dist-server/service/routing-item/routing-item-mutation.js.map +1 -1
- package/dist-server/service/routing-item/routing-item-query.js +7 -9
- package/dist-server/service/routing-item/routing-item-query.js.map +1 -1
- package/dist-server/service/routing-item/routing-item-type.js +4 -5
- package/dist-server/service/routing-item/routing-item-type.js.map +1 -1
- package/dist-server/service/routing-item/routing-item.js +3 -4
- package/dist-server/service/routing-item/routing-item.js.map +1 -1
- package/dist-server/tsconfig.tsbuildinfo +1 -1
- package/package.json +5 -5
- package/server/service/operation/operation-mutation.ts +15 -9
- package/server/service/operation/operation-query.ts +8 -9
- package/server/service/routing/routing-mutation.ts +12 -14
- package/server/service/routing/routing-query.ts +19 -12
- package/server/service/routing-item/routing-item-mutation.ts +17 -20
- package/server/service/routing-item/routing-item-query.ts +7 -8
|
@@ -26,7 +26,7 @@ let OperationMutation = class OperationMutation {
|
|
|
26
26
|
const { domain, user, tx } = context.state;
|
|
27
27
|
const repository = tx.getRepository(operation_1.Operation);
|
|
28
28
|
const operation = await repository.findOne({
|
|
29
|
-
where: { domain, id }
|
|
29
|
+
where: { domain: { id: domain.id }, id }
|
|
30
30
|
});
|
|
31
31
|
const result = await repository.save(Object.assign(Object.assign(Object.assign({}, operation), patch), { updater: user }));
|
|
32
32
|
if (patch.thumbnail) {
|
|
@@ -67,7 +67,7 @@ let OperationMutation = class OperationMutation {
|
|
|
67
67
|
if (_updateRecords.length > 0) {
|
|
68
68
|
for (let i = 0; i < _updateRecords.length; i++) {
|
|
69
69
|
const newRecord = _updateRecords[i];
|
|
70
|
-
const operation = await operationRepo.
|
|
70
|
+
const operation = await operationRepo.findOneBy({ id: newRecord.id });
|
|
71
71
|
const result = await operationRepo.save(Object.assign(Object.assign(Object.assign({}, operation), newRecord), { updater: user }));
|
|
72
72
|
if (newRecord.thumbnail) {
|
|
73
73
|
await (0, attachment_base_1.deleteAttachmentsByRef)(null, { refBys: [result.id] }, context);
|
|
@@ -86,14 +86,14 @@ let OperationMutation = class OperationMutation {
|
|
|
86
86
|
}
|
|
87
87
|
async deleteOperation(id, context) {
|
|
88
88
|
const { domain, tx } = context.state;
|
|
89
|
-
await tx.getRepository(operation_1.Operation).delete({ domain, id });
|
|
89
|
+
await tx.getRepository(operation_1.Operation).delete({ domain: { id: domain.id }, id });
|
|
90
90
|
await (0, attachment_base_1.deleteAttachmentsByRef)(null, { refBys: [id] }, context);
|
|
91
91
|
return true;
|
|
92
92
|
}
|
|
93
93
|
async deleteOperations(ids, context) {
|
|
94
94
|
const { domain, tx } = context.state;
|
|
95
95
|
await tx.getRepository(operation_1.Operation).delete({
|
|
96
|
-
domain,
|
|
96
|
+
domain: { id: domain.id },
|
|
97
97
|
id: (0, typeorm_1.In)(ids)
|
|
98
98
|
});
|
|
99
99
|
await (0, attachment_base_1.deleteAttachmentsByRef)(null, { refBys: ids }, context);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"operation-mutation.js","sourceRoot":"","sources":["../../../server/service/operation/operation-mutation.ts"],"names":[],"mappings":";;;;AAAA,+CAAsE;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,IAAA,kBAAG,EAAC,OAAO,CAAC,CAAA;IACZ,mBAAA,IAAA,kBAAG,GAAE,CAAA;;qDADe,+BAAc;;wDAiCpC;AAIK;IAFL,IAAA,wBAAS,EAAC,cAAc,CAAC;IACzB,IAAA,uBAAQ,EAAC,OAAO,CAAC,EAAE,CAAC,CAAC,qBAAS,CAAC,EAAE,EAAE,WAAW,EAAE,4CAA4C,EAAE,CAAC;IAE7F,mBAAA,IAAA,kBAAG,EAAC,SAAS,EAAE,IAAI,CAAC,EAAE,CAAC,CAAC,+BAAc,CAAC,CAAC,CAAA;IACxC,mBAAA,IAAA,kBAAG,GAAE,CAAA;;;;gEAqEP;AAIK;IAFL,IAAA,wBAAS,EAAC,cAAc,CAAC;IACzB,IAAA,uBAAQ,EAAC,OAAO,CAAC,EAAE,CAAC,OAAO,EAAE,EAAE,WAAW,EAAE,qBAAqB,EAAE,CAAC;IAC9C,mBAAA,IAAA,kBAAG,EAAC,IAAI,CAAC,CAAA;IAAc,mBAAA,IAAA,kBAAG,GAAE,CAAA;;;;wDAOlD;AAIK;IAFL,IAAA,wBAAS,EAAC,cAAc,CAAC;IACzB,IAAA,uBAAQ,EAAC,OAAO,CAAC,EAAE,CAAC,OAAO,EAAE,EAAE,WAAW,EAAE,+BAA+B,EAAE,CAAC;IACvD,mBAAA,IAAA,kBAAG,EAAC,KAAK,EAAE,IAAI,CAAC,EAAE,CAAC,CAAC,MAAM,CAAC,CAAC,CAAA;IAAiB,mBAAA,IAAA,kBAAG,GAAE,CAAA;;;;yDAWzE;AAxKU,iBAAiB;IAD7B,IAAA,uBAAQ,EAAC,qBAAS,CAAC;GACP,iBAAiB,CAyK7B;AAzKY,8CAAiB","sourcesContent":["import { Arg, Ctx, Directive, Mutation, Resolver } from 'type-graphql'\nimport { In } from 'typeorm'\n\nimport { createAttachment, deleteAttachmentsByRef } from '@things-factory/attachment-base'\n\nimport { Operation } from './operation'\nimport { NewOperation, OperationPatch } from './operation-type'\n\n@Resolver(Operation)\nexport class OperationMutation {\n @Directive('@transaction')\n @Mutation(returns => Operation, { description: 'To create new Operation' })\n async createOperation(@Arg('operation') operation: NewOperation, @Ctx() context: any): Promise<Operation> {\n const { domain, user, tx } = context.state\n\n const result = await tx.getRepository(Operation).save({\n ...operation,\n domain,\n creator: user,\n updater: user\n })\n\n if (operation.thumbnail) {\n await createAttachment(\n null,\n {\n attachment: {\n file: operation.thumbnail,\n refType: Operation.name,\n refBy: result.id\n }\n },\n context\n )\n }\n\n return result\n }\n\n @Directive('@transaction')\n @Mutation(returns => Operation, { description: 'To modify Operation information' })\n async updateOperation(\n @Arg('id') id: string,\n @Arg('patch') patch: OperationPatch,\n @Ctx() context: any\n ): Promise<Operation> {\n const { domain, user, tx } = context.state\n\n const repository = tx.getRepository(Operation)\n const operation = await repository.findOne({\n where: { domain, id }\n })\n\n const result = await repository.save({\n ...operation,\n ...patch,\n updater: user\n })\n\n if (patch.thumbnail) {\n // ?? { refBys: [operation.id] }\n await deleteAttachmentsByRef(null, { refBys: [result.id] }, context)\n await createAttachment(\n null,\n {\n attachment: {\n file: patch.thumbnail,\n refType: Operation.name,\n refBy: result.id\n }\n },\n context\n )\n }\n\n return result\n }\n\n @Directive('@transaction')\n @Mutation(returns => [Operation], { description: \"To modify multiple Operations' information\" })\n async updateMultipleOperation(\n @Arg('patches', type => [OperationPatch]) patches: OperationPatch[],\n @Ctx() context: any\n ): Promise<Operation[]> {\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 operationRepo = tx.getRepository(Operation)\n\n if (_createRecords.length > 0) {\n for (let i = 0; i < _createRecords.length; i++) {\n const newRecord = _createRecords[i]\n\n const result = await operationRepo.save({\n ...newRecord,\n domain,\n creator: user,\n updater: user\n })\n\n if (newRecord.thumbnail) {\n await createAttachment(\n null,\n {\n attachment: {\n file: newRecord.thumbnail,\n refType: Operation.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 newRecord = _updateRecords[i]\n const operation = await operationRepo.findOne(newRecord.id)\n\n const result = await operationRepo.save({\n ...operation,\n ...newRecord,\n updater: user\n })\n\n if (newRecord.thumbnail) {\n await deleteAttachmentsByRef(null, { refBys: [result.id] }, context)\n await createAttachment(\n null,\n {\n attachment: {\n file: newRecord.thumbnail,\n refType: Operation.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 @Mutation(returns => Boolean, { description: 'To delete Operation' })\n async deleteOperation(@Arg('id') id: string, @Ctx() context: any): Promise<boolean> {\n const { domain, tx } = context.state\n\n await tx.getRepository(Operation).delete({ domain, id })\n await deleteAttachmentsByRef(null, { refBys: [id] }, context)\n\n return true\n }\n\n @Directive('@transaction')\n @Mutation(returns => Boolean, { description: 'To delete multiple operations' })\n async deleteOperations(@Arg('ids', type => [String]) ids: string[], @Ctx() context: any): Promise<boolean> {\n const { domain, tx } = context.state\n\n await tx.getRepository(Operation).delete({\n domain,\n id: In(ids)\n })\n\n await deleteAttachmentsByRef(null, { refBys: ids }, context)\n\n return true\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"operation-mutation.js","sourceRoot":"","sources":["../../../server/service/operation/operation-mutation.ts"],"names":[],"mappings":";;;;AAAA,+CAAsE;AACtE,qCAA4B;AAE5B,qEAA0F;AAE1F,2CAAuC;AACvC,qDAA+D;AAG/D,IAAa,iBAAiB,GAA9B,MAAa,iBAAiB;IAG5B,KAAK,CAAC,eAAe,CACD,SAAuB,EAClC,OAAwB;QAE/B,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,EAAE,EAAE,GAAG,OAAO,CAAC,KAAK,CAAA;QAE1C,MAAM,MAAM,GAAG,MAAM,EAAE,CA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;IACzB,IAAA,uBAAQ,EAAC,OAAO,CAAC,EAAE,CAAC,CAAC,qBAAS,CAAC,EAAE,EAAE,WAAW,EAAE,4CAA4C,EAAE,CAAC;IAE7F,mBAAA,IAAA,kBAAG,EAAC,SAAS,EAAE,IAAI,CAAC,EAAE,CAAC,CAAC,+BAAc,CAAC,CAAC,CAAA;IACxC,mBAAA,IAAA,kBAAG,GAAE,CAAA;;;;gEAqEP;AAID;IAFC,IAAA,wBAAS,EAAC,cAAc,CAAC;IACzB,IAAA,uBAAQ,EAAC,OAAO,CAAC,EAAE,CAAC,OAAO,EAAE,EAAE,WAAW,EAAE,qBAAqB,EAAE,CAAC;IAC9C,mBAAA,IAAA,kBAAG,EAAC,IAAI,CAAC,CAAA;IAAc,mBAAA,IAAA,kBAAG,GAAE,CAAA;;;;wDAOlD;AAID;IAFC,IAAA,wBAAS,EAAC,cAAc,CAAC;IACzB,IAAA,uBAAQ,EAAC,OAAO,CAAC,EAAE,CAAC,OAAO,EAAE,EAAE,WAAW,EAAE,+BAA+B,EAAE,CAAC;IAE5E,mBAAA,IAAA,kBAAG,EAAC,KAAK,EAAE,IAAI,CAAC,EAAE,CAAC,CAAC,MAAM,CAAC,CAAC,CAAA;IAC5B,mBAAA,IAAA,kBAAG,GAAE,CAAA;;;;yDAYP;AA9KU,iBAAiB;IAD7B,IAAA,uBAAQ,EAAC,qBAAS,CAAC;GACP,iBAAiB,CA+K7B;AA/KY,8CAAiB","sourcesContent":["import { Arg, Ctx, Directive, Mutation, Resolver } from 'type-graphql'\nimport { In } from 'typeorm'\n\nimport { createAttachment, deleteAttachmentsByRef } from '@things-factory/attachment-base'\n\nimport { Operation } from './operation'\nimport { NewOperation, OperationPatch } from './operation-type'\n\n@Resolver(Operation)\nexport class OperationMutation {\n @Directive('@transaction')\n @Mutation(returns => Operation, { description: 'To create new Operation' })\n async createOperation(\n @Arg('operation') operation: NewOperation,\n @Ctx() context: ResolverContext\n ): Promise<Operation> {\n const { domain, user, tx } = context.state\n\n const result = await tx.getRepository(Operation).save({\n ...operation,\n domain,\n creator: user,\n updater: user\n })\n\n if (operation.thumbnail) {\n await createAttachment(\n null,\n {\n attachment: {\n file: operation.thumbnail,\n refType: Operation.name,\n refBy: result.id\n }\n },\n context\n )\n }\n\n return result\n }\n\n @Directive('@transaction')\n @Mutation(returns => Operation, { description: 'To modify Operation information' })\n async updateOperation(\n @Arg('id') id: string,\n @Arg('patch') patch: OperationPatch,\n @Ctx() context: ResolverContext\n ): Promise<Operation> {\n const { domain, user, tx } = context.state\n\n const repository = tx.getRepository(Operation)\n const operation = await repository.findOne({\n where: { domain: { id: domain.id }, id }\n })\n\n const result = await repository.save({\n ...operation,\n ...patch,\n updater: user\n })\n\n if (patch.thumbnail) {\n // ?? { refBys: [operation.id] }\n await deleteAttachmentsByRef(null, { refBys: [result.id] }, context)\n await createAttachment(\n null,\n {\n attachment: {\n file: patch.thumbnail,\n refType: Operation.name,\n refBy: result.id\n }\n },\n context\n )\n }\n\n return result\n }\n\n @Directive('@transaction')\n @Mutation(returns => [Operation], { description: \"To modify multiple Operations' information\" })\n async updateMultipleOperation(\n @Arg('patches', type => [OperationPatch]) patches: OperationPatch[],\n @Ctx() context: ResolverContext\n ): Promise<Operation[]> {\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 operationRepo = tx.getRepository(Operation)\n\n if (_createRecords.length > 0) {\n for (let i = 0; i < _createRecords.length; i++) {\n const newRecord = _createRecords[i]\n\n const result = await operationRepo.save({\n ...newRecord,\n domain,\n creator: user,\n updater: user\n })\n\n if (newRecord.thumbnail) {\n await createAttachment(\n null,\n {\n attachment: {\n file: newRecord.thumbnail,\n refType: Operation.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 newRecord = _updateRecords[i]\n const operation = await operationRepo.findOneBy({ id: newRecord.id })\n\n const result = await operationRepo.save({\n ...operation,\n ...newRecord,\n updater: user\n })\n\n if (newRecord.thumbnail) {\n await deleteAttachmentsByRef(null, { refBys: [result.id] }, context)\n await createAttachment(\n null,\n {\n attachment: {\n file: newRecord.thumbnail,\n refType: Operation.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 @Mutation(returns => Boolean, { description: 'To delete Operation' })\n async deleteOperation(@Arg('id') id: string, @Ctx() context: ResolverContext): Promise<boolean> {\n const { domain, tx } = context.state\n\n await tx.getRepository(Operation).delete({ domain: { id: domain.id }, id })\n await deleteAttachmentsByRef(null, { refBys: [id] }, context)\n\n return true\n }\n\n @Directive('@transaction')\n @Mutation(returns => Boolean, { description: 'To delete multiple operations' })\n async deleteOperations(\n @Arg('ids', type => [String]) ids: string[],\n @Ctx() context: ResolverContext\n ): Promise<boolean> {\n const { domain, tx } = context.state\n\n await tx.getRepository(Operation).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"]}
|
|
@@ -1,10 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var _a;
|
|
3
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
3
|
exports.OperationQuery = void 0;
|
|
5
4
|
const tslib_1 = require("tslib");
|
|
6
5
|
const type_graphql_1 = require("type-graphql");
|
|
7
|
-
const typeorm_1 = require("typeorm");
|
|
8
6
|
const attachment_base_1 = require("@things-factory/attachment-base");
|
|
9
7
|
const auth_base_1 = require("@things-factory/auth-base");
|
|
10
8
|
const shell_1 = require("@things-factory/shell");
|
|
@@ -13,14 +11,14 @@ const operation_type_1 = require("./operation-type");
|
|
|
13
11
|
let OperationQuery = class OperationQuery {
|
|
14
12
|
async operation(id, context) {
|
|
15
13
|
const { domain } = context.state;
|
|
16
|
-
return await (0,
|
|
17
|
-
where: { domain, id }
|
|
14
|
+
return await (0, shell_1.getRepository)(operation_1.Operation).findOne({
|
|
15
|
+
where: { domain: { id: domain.id }, id }
|
|
18
16
|
});
|
|
19
17
|
}
|
|
20
18
|
async operations(params, context) {
|
|
21
19
|
const { domain } = context.state;
|
|
22
20
|
const queryBuilder = (0, shell_1.getQueryBuilderFromListParams)({
|
|
23
|
-
repository: (0,
|
|
21
|
+
repository: (0, shell_1.getRepository)(operation_1.Operation),
|
|
24
22
|
params,
|
|
25
23
|
domain,
|
|
26
24
|
searchables: ['name', 'description']
|
|
@@ -29,18 +27,18 @@ let OperationQuery = class OperationQuery {
|
|
|
29
27
|
return { items, total };
|
|
30
28
|
}
|
|
31
29
|
async domain(operation) {
|
|
32
|
-
return await (0,
|
|
30
|
+
return await (0, shell_1.getRepository)(shell_1.Domain).findOneBy({ id: operation.domainId });
|
|
33
31
|
}
|
|
34
32
|
async updater(operation) {
|
|
35
|
-
return await (0,
|
|
33
|
+
return await (0, shell_1.getRepository)(auth_base_1.User).findOneBy({ id: operation.updaterId });
|
|
36
34
|
}
|
|
37
35
|
async creator(operation) {
|
|
38
|
-
return await (0,
|
|
36
|
+
return await (0, shell_1.getRepository)(auth_base_1.User).findOneBy({ id: operation.creatorId });
|
|
39
37
|
}
|
|
40
38
|
async thumbnail(operation) {
|
|
41
|
-
const attachment = await (0,
|
|
39
|
+
const attachment = await (0, shell_1.getRepository)(attachment_base_1.Attachment).findOne({
|
|
42
40
|
where: {
|
|
43
|
-
domain: operation.domainId,
|
|
41
|
+
domain: { id: operation.domainId },
|
|
44
42
|
refBy: operation.id
|
|
45
43
|
}
|
|
46
44
|
});
|
|
@@ -60,7 +58,7 @@ tslib_1.__decorate([
|
|
|
60
58
|
tslib_1.__param(0, (0, type_graphql_1.Args)()),
|
|
61
59
|
tslib_1.__param(1, (0, type_graphql_1.Ctx)()),
|
|
62
60
|
tslib_1.__metadata("design:type", Function),
|
|
63
|
-
tslib_1.__metadata("design:paramtypes", [
|
|
61
|
+
tslib_1.__metadata("design:paramtypes", [shell_1.ListParam, Object]),
|
|
64
62
|
tslib_1.__metadata("design:returntype", Promise)
|
|
65
63
|
], OperationQuery.prototype, "operations", null);
|
|
66
64
|
tslib_1.__decorate([
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"operation-query.js","sourceRoot":"","sources":["../../../server/service/operation/operation-query.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"operation-query.js","sourceRoot":"","sources":["../../../server/service/operation/operation-query.ts"],"names":[],"mappings":";;;;AAAA,+CAAmF;AAEnF,qEAA4D;AAC5D,yDAAgD;AAChD,iDAAuG;AAEvG,2CAAuC;AACvC,qDAAgD;AAGhD,IAAa,cAAc,GAA3B,MAAa,cAAc;IAEzB,KAAK,CAAC,SAAS,CAAY,EAAU,EAAS,OAAwB;QACpE,MAAM,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,KAAK,CAAA;QAEhC,OAAO,MAAM,IAAA,qBAAa,EAAC,qBAAS,CAAC,CAAC,OAAO,CAAC;YAC5C,KAAK,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,EAAE,MAAM,CAAC,EAAE,EAAE,EAAE,EAAE,EAAE;SACzC,CAAC,CAAA;IACJ,CAAC;IAGD,KAAK,CAAC,UAAU,CAAS,MAAiB,EAAS,OAAwB;QACzE,MAAM,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,KAAK,CAAA;QAEhC,MAAM,YAAY,GAAG,IAAA,qCAA6B,EAAC;YACjD,UAAU,EAAE,IAAA,qBAAa,EAAC,qBAAS,CAAC;YACpC,MAAM;YACN,MAAM;YACN,WAAW,EAAE,CAAC,MAAM,EAAE,aAAa,CAAC;SACrC,CAAC,CAAA;QAEF,MAAM,CAAC,KAAK,EAAE,KAAK,CAAC,GAAG,MAAM,YAAY,CAAC,eAAe,EAAE,CAAA;QAE3D,OAAO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,mBAAA,IAAA,mBAAI,GAAE,CAAA;IAAqB,mBAAA,IAAA,kBAAG,GAAE,CAAA;;6CAAjB,iBAAS;;gDAazC;AAGD;IADC,IAAA,4BAAa,EAAC,IAAI,CAAC,EAAE,CAAC,cAAM,CAAC;IAChB,mBAAA,IAAA,mBAAI,GAAE,CAAA;;6CAAY,qBAAS;;4CAExC;AAGD;IADC,IAAA,4BAAa,EAAC,IAAI,CAAC,EAAE,CAAC,gBAAI,CAAC;IACb,mBAAA,IAAA,mBAAI,GAAE,CAAA;;6CAAY,qBAAS;;6CAEzC;AAGD;IADC,IAAA,4BAAa,EAAC,IAAI,CAAC,EAAE,CAAC,gBAAI,CAAC;IACb,mBAAA,IAAA,mBAAI,GAAE,CAAA;;6CAAY,qBAAS;;6CAEzC;AAGD;IADC,IAAA,4BAAa,EAAC,IAAI,CAAC,EAAE,CAAC,MAAM,CAAC;IACb,mBAAA,IAAA,mBAAI,GAAE,CAAA;;6CAAY,qBAAS;;+CAS3C;AAnDU,cAAc;IAD1B,IAAA,uBAAQ,EAAC,qBAAS,CAAC;GACP,cAAc,CAoD1B;AApDY,wCAAc","sourcesContent":["import { Arg, Args, Ctx, FieldResolver, Query, Resolver, Root } from 'type-graphql'\n\nimport { Attachment } from '@things-factory/attachment-base'\nimport { User } from '@things-factory/auth-base'\nimport { Domain, getQueryBuilderFromListParams, getRepository, ListParam } from '@things-factory/shell'\n\nimport { Operation } from './operation'\nimport { OperationList } from './operation-type'\n\n@Resolver(Operation)\nexport class OperationQuery {\n @Query(returns => Operation, { description: 'To fetch a Operation' })\n async operation(@Arg('id') id: string, @Ctx() context: ResolverContext): Promise<Operation> {\n const { domain } = context.state\n\n return await getRepository(Operation).findOne({\n where: { domain: { id: domain.id }, id }\n })\n }\n\n @Query(returns => OperationList, { description: 'To fetch multiple Operations' })\n async operations(@Args() params: ListParam, @Ctx() context: ResolverContext): Promise<OperationList> {\n const { domain } = context.state\n\n const queryBuilder = getQueryBuilderFromListParams({\n repository: getRepository(Operation),\n params,\n domain,\n searchables: ['name', 'description']\n })\n\n const [items, total] = await queryBuilder.getManyAndCount()\n\n return { items, total }\n }\n\n @FieldResolver(type => Domain)\n async domain(@Root() operation: Operation): Promise<Domain> {\n return await getRepository(Domain).findOneBy({ id: operation.domainId })\n }\n\n @FieldResolver(type => User)\n async updater(@Root() operation: Operation): Promise<User> {\n return await getRepository(User).findOneBy({ id: operation.updaterId })\n }\n\n @FieldResolver(type => User)\n async creator(@Root() operation: Operation): Promise<User> {\n return await getRepository(User).findOneBy({ id: operation.creatorId })\n }\n\n @FieldResolver(type => String)\n async thumbnail(@Root() operation: Operation): Promise<string | undefined> {\n const attachment: Attachment = await getRepository(Attachment).findOne({\n where: {\n domain: { id: operation.domainId },\n refBy: operation.id\n }\n })\n\n return attachment?.fullpath\n }\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"operation-type.js","sourceRoot":"","sources":["../../../server/service/operation/operation-type.ts"],"names":[],"mappings":";;;;AACA,+FAA2D;AAC3D,+CAAoE;AAEpE,2CAAuC;
|
|
1
|
+
{"version":3,"file":"operation-type.js","sourceRoot":"","sources":["../../../server/service/operation/operation-type.ts"],"names":[],"mappings":";;;;AACA,+FAA2D;AAC3D,+CAAoE;AAEpE,2CAAuC;AAGvC,IAAa,YAAY,GAAzB,MAAa,YAAY;CAqBxB,CAAA;AAnBC;IADC,IAAA,oBAAK,EAAC,EAAE,QAAQ,EAAE,KAAK,EAAE,CAAC;;0CACf;AAGZ;IADC,IAAA,oBAAK,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;;iDACN;AAGpB;IADC,IAAA,oBAAK,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;;0CACb;AAGb;IADC,IAAA,oBAAK,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;;uDACA;AAG1B;IADC,IAAA,oBAAK,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;;sDACD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CAAC,CAAC;;4CACT;AAGlB;IADC,IAAA,oBAAK,EAAC,IAAI,CAAC,EAAE,CAAC,kBAAG,CAAC;;4CACN;AALF,aAAa;IADzB,IAAA,yBAAU,GAAE;GACA,aAAa,CAMzB;AANY,sCAAa","sourcesContent":["import type { FileUpload } from 'graphql-upload/GraphQLUpload.js'\nimport GraphQLUpload from 'graphql-upload/GraphQLUpload.js'\nimport { Field, ID, InputType, Int, ObjectType } from 'type-graphql'\n\nimport { Operation } from './operation'\n\n@InputType()\nexport class NewOperation {\n @Field({ nullable: false })\n name: string\n\n @Field({ nullable: true })\n description?: string\n\n @Field({ nullable: true })\n type?: string\n\n @Field({ nullable: true })\n operationStdChart?: string\n\n @Field({ nullable: true })\n operationStdTime?: string\n\n @Field({ nullable: true })\n active?: boolean\n\n @Field(type => GraphQLUpload, { nullable: true })\n thumbnail?: FileUpload\n}\n\n@InputType()\nexport class OperationPatch {\n @Field(type => ID, { nullable: true })\n id!: string\n\n @Field({ nullable: true })\n name: string\n\n @Field({ nullable: true })\n description?: string\n\n @Field({ nullable: true })\n type?: string\n\n @Field({ nullable: true })\n operationStdChart?: string\n\n @Field({ nullable: true })\n operationStdTime?: string\n\n @Field({ nullable: true })\n active?: boolean\n\n @Field(type => GraphQLUpload, { nullable: true })\n thumbnail?: FileUpload\n\n @Field()\n cuFlag: string\n}\n\n@ObjectType()\nexport class OperationList {\n @Field(type => [Operation])\n items: Operation[]\n\n @Field(type => Int)\n total: number\n}\n"]}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var _a, _b, _c;
|
|
3
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
3
|
exports.Operation = exports.OperationStatus = void 0;
|
|
5
4
|
const tslib_1 = require("tslib");
|
|
@@ -32,7 +31,7 @@ tslib_1.__decorate([
|
|
|
32
31
|
tslib_1.__decorate([
|
|
33
32
|
(0, typeorm_1.ManyToOne)(type => shell_1.Domain),
|
|
34
33
|
(0, type_graphql_1.Field)(type => shell_1.Domain, { nullable: false }),
|
|
35
|
-
tslib_1.__metadata("design:type",
|
|
34
|
+
tslib_1.__metadata("design:type", shell_1.Domain)
|
|
36
35
|
], Operation.prototype, "domain", void 0);
|
|
37
36
|
tslib_1.__decorate([
|
|
38
37
|
(0, typeorm_1.RelationId)((operation) => operation.domain),
|
|
@@ -87,7 +86,7 @@ tslib_1.__decorate([
|
|
|
87
86
|
nullable: true
|
|
88
87
|
}),
|
|
89
88
|
(0, type_graphql_1.Field)(type => auth_base_1.User, { nullable: true }),
|
|
90
|
-
tslib_1.__metadata("design:type",
|
|
89
|
+
tslib_1.__metadata("design:type", auth_base_1.User)
|
|
91
90
|
], Operation.prototype, "creator", void 0);
|
|
92
91
|
tslib_1.__decorate([
|
|
93
92
|
(0, typeorm_1.RelationId)((operation) => operation.creator),
|
|
@@ -98,7 +97,7 @@ tslib_1.__decorate([
|
|
|
98
97
|
nullable: true
|
|
99
98
|
}),
|
|
100
99
|
(0, type_graphql_1.Field)(type => auth_base_1.User, { nullable: true }),
|
|
101
|
-
tslib_1.__metadata("design:type",
|
|
100
|
+
tslib_1.__metadata("design:type", auth_base_1.User)
|
|
102
101
|
], Operation.prototype, "updater", void 0);
|
|
103
102
|
tslib_1.__decorate([
|
|
104
103
|
(0, typeorm_1.RelationId)((operation) => operation.creator),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"operation.js","sourceRoot":"","sources":["../../../server/service/operation/operation.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"operation.js","sourceRoot":"","sources":["../../../server/service/operation/operation.ts"],"names":[],"mappings":";;;;AAAA,+CAAsE;AACtE,qCASgB;AAEhB,yDAAgD;AAChD,iDAA8C;AAE9C,IAAY,eASX;AATD,WAAY,eAAe;IACzB,wCAAqB,CAAA;IACrB,wCAAqB,CAAA;IACrB,oCAAiB,CAAA;IACjB,oCAAiB,CAAA;IACjB,mCAAgB,CAAA;IAChB,8BAAW,CAAA;I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AS;IAHrB,IAAA,gBAAM,GAAE;IACR,IAAA,eAAK,EAAC,gBAAgB,EAAE,CAAC,SAAoB,EAAE,EAAE,CAAC,CAAC,SAAS,CAAC,MAAM,EAAE,SAAS,CAAC,IAAI,CAAC,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC;IACvG,IAAA,yBAAU,EAAC,EAAE,WAAW,EAAE,sBAAsB,EAAE,CAAC;GACvC,SAAS,CA0ErB;AA1EY,8BAAS","sourcesContent":["import { Field, ID, ObjectType, registerEnumType } from 'type-graphql'\nimport {\n Column,\n CreateDateColumn,\n Entity,\n Index,\n ManyToOne,\n PrimaryGeneratedColumn,\n RelationId,\n UpdateDateColumn\n} from 'typeorm'\n\nimport { User } from '@things-factory/auth-base'\nimport { Domain } from '@things-factory/shell'\n\nexport enum OperationStatus {\n STATUS_A = 'STATUS_A',\n STATUS_B = 'STATUS_B',\n ASSY = 'Assembly',\n INV = 'Inventory',\n PACK = 'Packing',\n SMT = 'SMT',\n STD = 'Standard',\n TEST = 'Test'\n}\n\nregisterEnumType(OperationStatus, {\n name: 'OperationStatus',\n description: 'state enumeration of a operation'\n})\n\n@Entity()\n@Index('ix_operation_0', (operation: Operation) => [operation.domain, operation.name], { unique: true })\n@ObjectType({ description: 'Entity for Operation' })\nexport class Operation {\n @PrimaryGeneratedColumn('uuid')\n @Field(type => ID, { nullable: false })\n readonly id: string\n\n @ManyToOne(type => Domain)\n @Field(type => Domain, { nullable: false })\n domain: Domain\n\n @RelationId((operation: Operation) => operation.domain)\n domainId: string\n\n @Column()\n @Field({ nullable: false })\n name: string\n\n @Column({\n nullable: true\n })\n @Field({ nullable: true })\n description?: 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 operationStdChart?: string\n\n @Column({\n nullable: true\n })\n @Field({ nullable: true })\n operationStdTime?: string\n\n @Column({\n nullable: true\n })\n @Field({ nullable: true })\n active?: boolean\n\n @Field(type => String, { nullable: true })\n thumbnail?: string\n\n @ManyToOne(type => User, {\n nullable: true\n })\n @Field(type => User, { nullable: true })\n creator?: User\n\n @RelationId((operation: Operation) => operation.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((operation: Operation) => operation.creator)\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"]}
|
|
@@ -15,7 +15,7 @@ let RoutingMutation = class RoutingMutation {
|
|
|
15
15
|
const { domain, user, tx } = context.state;
|
|
16
16
|
const repository = tx.getRepository(routing_1.Routing);
|
|
17
17
|
const routing = await repository.findOne({
|
|
18
|
-
where: { domain, id }
|
|
18
|
+
where: { domain: { id: domain.id }, id }
|
|
19
19
|
});
|
|
20
20
|
return await repository.save(Object.assign(Object.assign(Object.assign({}, routing), patch), { updater: user }));
|
|
21
21
|
}
|
|
@@ -35,7 +35,7 @@ let RoutingMutation = class RoutingMutation {
|
|
|
35
35
|
if (_updateRecords.length > 0) {
|
|
36
36
|
for (let i = 0; i < _updateRecords.length; i++) {
|
|
37
37
|
const newRecord = _updateRecords[i];
|
|
38
|
-
const routing = await routingRepo.
|
|
38
|
+
const routing = await routingRepo.findOneBy({ id: newRecord.id });
|
|
39
39
|
const result = await routingRepo.save(Object.assign(Object.assign(Object.assign({}, routing), newRecord), { updater: user }));
|
|
40
40
|
results.push(Object.assign(Object.assign({}, result), { cuFlag: 'M' }));
|
|
41
41
|
}
|
|
@@ -44,13 +44,13 @@ let RoutingMutation = class RoutingMutation {
|
|
|
44
44
|
}
|
|
45
45
|
async deleteRouting(id, context) {
|
|
46
46
|
const { domain, tx } = context.state;
|
|
47
|
-
await tx.getRepository(routing_1.Routing).delete({ domain, id });
|
|
47
|
+
await tx.getRepository(routing_1.Routing).delete({ domain: { id: domain.id }, id });
|
|
48
48
|
return true;
|
|
49
49
|
}
|
|
50
50
|
async deleteRoutings(ids, context) {
|
|
51
51
|
const { domain, tx } = context.state;
|
|
52
52
|
await tx.getRepository(routing_1.Routing).delete({
|
|
53
|
-
domain,
|
|
53
|
+
domain: { id: domain.id },
|
|
54
54
|
id: (0, typeorm_1.In)(ids)
|
|
55
55
|
});
|
|
56
56
|
return true;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"routing-mutation.js","sourceRoot":"","sources":["../../../server/service/routing/routing-mutation.ts"],"names":[],"mappings":";;;;AAAA,+CAAsE;AACtE,
|
|
1
|
+
{"version":3,"file":"routing-mutation.js","sourceRoot":"","sources":["../../../server/service/routing/routing-mutation.ts"],"names":[],"mappings":";;;;AAAA,+CAAsE;AACtE,qCAA4B;AAE5B,uCAAmC;AACnC,iDAAyD;AAGzD,IAAa,eAAe,GAA5B,MAAa,eAAe;IAG1B,KAAK,CAAC,aAAa,CAAiB,OAAmB,EAAS,OAAwB;QACtF,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,EAAE,EAAE,GAAG,OAAO,CAAC,KAAK,CAAA;QAE1C,OAAO,MAAM,EAAE,CAAC,aAAa,CAAC,iBAAO,CAAC,CAAC,IAAI,iCACtC,OAAO,KACV,MAAM,EACN,OAAO,EAAE,IAAI,EACb,OAAO,EAAE,IAAI,IACb,CAAA;IACJ,CAAC;IAID,KAAK,CAAC,aAAa,CACN,EAAU,EACP,KAAmB,EAC1B,OAAwB;QAE/B,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,EAAE,EAAE,GAAG,OAAO,CAAC,KAAK,CAAA;QAE1C,MAAM,UAAU,GAAG,EAAE,CAAC,aAAa,CAAC,iBAAO,CAAC,CAAA;QAC5C,MAAM,OAAO,GAAG,MAAM,UAAU,CAAC,OAAO,CAAC;YACvC,KAAK,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,EAAE,MAAM,CAAC,EAAE,EAAE,EAAE,EAAE,EAAE;SACzC,CAAC,CAAA;QAEF,O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BAAQ,EAAC,iBAAO,CAAC;GACL,eAAe,CAsG3B;AAtGY,0CAAe","sourcesContent":["import { Arg, Ctx, Directive, Mutation, Resolver } from 'type-graphql'\nimport { In } from 'typeorm'\n\nimport { Routing } from './routing'\nimport { NewRouting, RoutingPatch } from './routing-type'\n\n@Resolver(Routing)\nexport class RoutingMutation {\n @Directive('@transaction')\n @Mutation(returns => Routing, { description: 'To create new Routing' })\n async createRouting(@Arg('routing') routing: NewRouting, @Ctx() context: ResolverContext): Promise<Routing> {\n const { domain, user, tx } = context.state\n\n return await tx.getRepository(Routing).save({\n ...routing,\n domain,\n creator: user,\n updater: user\n })\n }\n\n @Directive('@transaction')\n @Mutation(returns => Routing, { description: 'To modify Routing information' })\n async updateRouting(\n @Arg('id') id: string,\n @Arg('patch') patch: RoutingPatch,\n @Ctx() context: ResolverContext\n ): Promise<Routing> {\n const { domain, user, tx } = context.state\n\n const repository = tx.getRepository(Routing)\n const routing = await repository.findOne({\n where: { domain: { id: domain.id }, id }\n })\n\n return await repository.save({\n ...routing,\n ...patch,\n updater: user\n })\n }\n\n @Directive('@transaction')\n @Mutation(returns => [Routing], { description: \"To modify multiple Routings' information\" })\n async updateMultipleRouting(\n @Arg('patches', type => [RoutingPatch]) patches: RoutingPatch[],\n @Ctx() context: ResolverContext\n ): Promise<Routing[]> {\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 routingRepo = tx.getRepository(Routing)\n\n if (_createRecords.length > 0) {\n for (let i = 0; i < _createRecords.length; i++) {\n const newRecord = _createRecords[i]\n\n const result = await routingRepo.save({\n ...newRecord,\n domain,\n creator: user,\n updater: user\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 newRecord = _updateRecords[i]\n const routing = await routingRepo.findOneBy({ id: newRecord.id })\n\n const result = await routingRepo.save({\n ...routing,\n ...newRecord,\n updater: user\n })\n\n results.push({ ...result, cuFlag: 'M' })\n }\n }\n\n return results\n }\n\n @Directive('@transaction')\n @Mutation(returns => Boolean, { description: 'To delete Routing' })\n async deleteRouting(@Arg('id') id: string, @Ctx() context: ResolverContext): Promise<boolean> {\n const { domain, tx } = context.state\n\n await tx.getRepository(Routing).delete({ domain: { id: domain.id }, id })\n return true\n }\n\n @Directive('@transaction')\n @Mutation(returns => Boolean, { description: 'To delete multiple routings' })\n async deleteRoutings(@Arg('ids', type => [String]) ids: string[], @Ctx() context: ResolverContext): Promise<boolean> {\n const { domain, tx } = context.state\n\n await tx.getRepository(Routing).delete({\n domain: { id: domain.id },\n id: In(ids)\n })\n\n return true\n }\n}\n"]}
|
|
@@ -1,10 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var _a;
|
|
3
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
3
|
exports.lastOperation = exports.prevOperation = exports.nextOperation = exports.firstOperation = exports.RoutingQuery = void 0;
|
|
5
4
|
const tslib_1 = require("tslib");
|
|
6
5
|
const type_graphql_1 = require("type-graphql");
|
|
7
|
-
const typeorm_1 = require("typeorm");
|
|
8
6
|
const auth_base_1 = require("@things-factory/auth-base");
|
|
9
7
|
const shell_1 = require("@things-factory/shell");
|
|
10
8
|
const operation_1 = require("../operation/operation");
|
|
@@ -13,14 +11,14 @@ const routing_type_1 = require("./routing-type");
|
|
|
13
11
|
let RoutingQuery = class RoutingQuery {
|
|
14
12
|
async routing(id, context) {
|
|
15
13
|
const { domain } = context.state;
|
|
16
|
-
return await (0,
|
|
17
|
-
where: { domain,
|
|
14
|
+
return await (0, shell_1.getRepository)(routing_1.Routing).findOne({
|
|
15
|
+
where: { domain: { id: domain.id }, id }
|
|
18
16
|
});
|
|
19
17
|
}
|
|
20
18
|
async routings(params, context) {
|
|
21
19
|
const { domain } = context.state;
|
|
22
20
|
const queryBuilder = (0, shell_1.getQueryBuilderFromListParams)({
|
|
23
|
-
repository: (0,
|
|
21
|
+
repository: (0, shell_1.getRepository)(routing_1.Routing),
|
|
24
22
|
params,
|
|
25
23
|
domain,
|
|
26
24
|
searchables: ['name']
|
|
@@ -29,13 +27,13 @@ let RoutingQuery = class RoutingQuery {
|
|
|
29
27
|
return { items, total };
|
|
30
28
|
}
|
|
31
29
|
async domain(routing) {
|
|
32
|
-
return await (0,
|
|
30
|
+
return await (0, shell_1.getRepository)(shell_1.Domain).findOneBy({ id: routing.domainId });
|
|
33
31
|
}
|
|
34
32
|
async updater(routing) {
|
|
35
|
-
return await (0,
|
|
33
|
+
return await (0, shell_1.getRepository)(auth_base_1.User).findOneBy({ id: routing.updaterId });
|
|
36
34
|
}
|
|
37
35
|
async creator(routing) {
|
|
38
|
-
return await (0,
|
|
36
|
+
return await (0, shell_1.getRepository)(auth_base_1.User).findOneBy({ id: routing.creatorId });
|
|
39
37
|
}
|
|
40
38
|
};
|
|
41
39
|
tslib_1.__decorate([
|
|
@@ -51,7 +49,7 @@ tslib_1.__decorate([
|
|
|
51
49
|
tslib_1.__param(0, (0, type_graphql_1.Args)()),
|
|
52
50
|
tslib_1.__param(1, (0, type_graphql_1.Ctx)()),
|
|
53
51
|
tslib_1.__metadata("design:type", Function),
|
|
54
|
-
tslib_1.__metadata("design:paramtypes", [
|
|
52
|
+
tslib_1.__metadata("design:paramtypes", [shell_1.ListParam, Object]),
|
|
55
53
|
tslib_1.__metadata("design:returntype", Promise)
|
|
56
54
|
], RoutingQuery.prototype, "routings", null);
|
|
57
55
|
tslib_1.__decorate([
|
|
@@ -111,7 +109,7 @@ async function firstOperation(routingId, context) {
|
|
|
111
109
|
}
|
|
112
110
|
exports.firstOperation = firstOperation;
|
|
113
111
|
async function nextOperation(operationId, routingId, context) {
|
|
114
|
-
const operation = await (0,
|
|
112
|
+
const operation = await (0, shell_1.getRepository)(operation_1.Operation).query(`
|
|
115
113
|
select
|
|
116
114
|
*
|
|
117
115
|
from
|
|
@@ -153,7 +151,7 @@ async function nextOperation(operationId, routingId, context) {
|
|
|
153
151
|
}
|
|
154
152
|
exports.nextOperation = nextOperation;
|
|
155
153
|
async function prevOperation(operationId, routingId, context) {
|
|
156
|
-
const operation = await (0,
|
|
154
|
+
const operation = await (0, shell_1.getRepository)(operation_1.Operation).query(`
|
|
157
155
|
select
|
|
158
156
|
*
|
|
159
157
|
from
|
|
@@ -195,7 +193,7 @@ async function prevOperation(operationId, routingId, context) {
|
|
|
195
193
|
}
|
|
196
194
|
exports.prevOperation = prevOperation;
|
|
197
195
|
async function lastOperation(routingId, context) {
|
|
198
|
-
const operation = await (0,
|
|
196
|
+
const operation = await (0, shell_1.getRepository)(operation_1.Operation).query(`
|
|
199
197
|
select
|
|
200
198
|
*
|
|
201
199
|
from
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"routing-query.js","sourceRoot":"","sources":["../../../server/service/routing/routing-query.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"routing-query.js","sourceRoot":"","sources":["../../../server/service/routing/routing-query.ts"],"names":[],"mappings":";;;;AAAA,+CAAmF;AAEnF,yDAAgD;AAChD,iDAAuG;AAEvG,sDAAkD;AAClD,uCAAmC;AACnC,iDAA4C;AAG5C,IAAa,YAAY,GAAzB,MAAa,YAAY;IAEvB,KAAK,CAAC,OAAO,CAAY,EAAU,EAAS,OAAwB;QAClE,MAAM,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,KAAK,CAAA;QAEhC,OAAO,MAAM,IAAA,qBAAa,EAAC,iBAAO,CAAC,CAAC,OAAO,CAAC;YAC1C,KAAK,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,EAAE,MAAM,CAAC,EAAE,EAAE,EAAE,EAAE,EAAE;SACzC,CAAC,CAAA;IACJ,CAAC;IAGD,KAAK,CAAC,QAAQ,CAAS,MAAiB,EAAS,OAAwB;QACvE,MAAM,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC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B;IAExB,MAAM,SAAS,GAAG,MAAM,IAAA,qBAAa,EAAC,qBAAS,CAAC,CAAC,KAAK,CACpD;;;;;;;;;;;;;gCAa4B,SAAS;;;;;;;;;sCASH,SAAS;;;;;;;;;4CASH,SAAS;;8CAEP,WAAW;;;;OAIlD,CACJ,CAAA;IAED,OAAO,SAAS,CAAA;AAClB,CAAC;AA/CD,sCA+CC;AAEM,KAAK,UAAU,aAAa,CAAC,SAAiB,EAAE,OAAwB;IAC7E,MAAM,SAAS,GAAG,MAAM,IAAA,qBAAa,EAAC,qBAAS,CAAC,CAAC,KAAK,CACpD;;;;;;;;;;;;;gCAa4B,SAAS;;;;;;;;;sCASH,SAAS;;;OAGxC,CACJ,CAAA;IACD,OAAO,SAAS,CAAA;AAClB,CAAC;AA9BD,sCA8BC","sourcesContent":["import { Arg, Args, Ctx, FieldResolver, Query, Resolver, Root } from 'type-graphql'\n\nimport { User } from '@things-factory/auth-base'\nimport { Domain, getQueryBuilderFromListParams, getRepository, ListParam } from '@things-factory/shell'\n\nimport { Operation } from '../operation/operation'\nimport { Routing } from './routing'\nimport { RoutingList } from './routing-type'\n\n@Resolver(Routing)\nexport class RoutingQuery {\n @Query(returns => Routing, { description: 'To fetch a Routing' })\n async routing(@Arg('id') id: string, @Ctx() context: ResolverContext): Promise<Routing> {\n const { domain } = context.state\n\n return await getRepository(Routing).findOne({\n where: { domain: { id: domain.id }, id }\n })\n }\n\n @Query(returns => RoutingList, { description: 'To fetch multiple Routings' })\n async routings(@Args() params: ListParam, @Ctx() context: ResolverContext): Promise<RoutingList> {\n const { domain } = context.state\n\n const queryBuilder = getQueryBuilderFromListParams({\n repository: getRepository(Routing),\n params,\n domain,\n searchables: ['name']\n })\n\n const [items, total] = await queryBuilder.getManyAndCount()\n\n return { items, total }\n }\n\n @FieldResolver(type => Domain)\n async domain(@Root() routing: Routing): Promise<Domain> {\n return await getRepository(Domain).findOneBy({ id: routing.domainId })\n }\n\n @FieldResolver(type => User)\n async updater(@Root() routing: Routing): Promise<User> {\n return await getRepository(User).findOneBy({ id: routing.updaterId })\n }\n\n @FieldResolver(type => User)\n async creator(@Root() routing: Routing): Promise<User> {\n return await getRepository(User).findOneBy({ id: routing.creatorId })\n }\n}\n\nexport async function firstOperation(routingId: string, context: ResolverContext): Promise<Operation> {\n const { domain, user, tx } = context.state\n const operation: Operation = await tx.getRepository(Operation).query(\n `\n select \n * \n from \n operations \n where \n id = \n (\n select \n operation_id \n from \n routing_items \n where \n routing_id = '${routingId}' \n and \n rank = \n (\n select \n min(rank) \n from \n routing_items \n where \n routing_id = '${routingId}'\n )\n )\n `\n )\n return operation\n}\n\nexport async function nextOperation(\n operationId: string,\n routingId: string,\n context: ResolverContext\n): Promise<Operation> {\n const operation = await getRepository(Operation).query(\n `\n select \n * \n from \n operations \n where \n id = \n (\n select \n operation_id \n from \n routing_items \n where \n routing_id = '${routingId}' \n and \n rank = \n (\n select \n min(rank) \n from \n routing_items \n where \n routing_id = '${routingId}' \n and \n rank > \n (\n select \n rank \n from \n routing_items \n where \n routing_id = '${routingId}' \n and \n operation_id = '${operationId}'\n )\n )\n )\n `\n )\n return operation\n}\n\nexport async function prevOperation(\n operationId: string,\n routingId: string,\n context: ResolverContext\n): Promise<Operation> {\n const operation = await getRepository(Operation).query(\n `\n select \n * \n from \n operations \n where \n id = \n (\n select \n operation_id \n from \n routing_items \n where \n routing_id = '${routingId}' \n and \n rank = \n (\n select \n max(rank) \n from \n routing_items \n where \n routing_id = '${routingId}' \n and \n rank < \n (\n select \n rank \n from \n routing_items \n where \n routing_id = '${routingId}' \n and \n operation_id = '${operationId}'\n )\n )\n )\n `\n )\n\n return operation\n}\n\nexport async function lastOperation(routingId: string, context: ResolverContext): Promise<Operation> {\n const operation = await getRepository(Operation).query(\n `\n select \n * \n from \n operations \n where \n id = \n (\n select \n operation_id \n from \n routing_items \n where \n routing_id = '${routingId}' \n and \n rank = \n (\n select \n max(rank) \n from \n routing_items \n where \n routing_id = '${routingId}'\n )\n )\n `\n )\n return operation\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"routing-type.js","sourceRoot":"","sources":["../../../server/service/routing/routing-type.ts"],"names":[],"mappings":";;;;AAAA,+CAAsF;AAEtF,uCAAmC;
|
|
1
|
+
{"version":3,"file":"routing-type.js","sourceRoot":"","sources":["../../../server/service/routing/routing-type.ts"],"names":[],"mappings":";;;;AAAA,+CAAsF;AAEtF,uCAAmC;AAGnC,IAAa,UAAU,GAAvB,MAAa,UAAU;CAYtB,CAAA;AAVC;IADC,IAAA,oBAAK,EAAC,EAAE,QAAQ,EAAE,KAAK,EAAE,CAAC;;wCACf;AAGZ;IADC,IAAA,oBAAK,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;;+CACN;AAGpB;IADC,IAAA,oBAAK,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;;8CACN;AAGpB;IADC,IAAA,oBAAK,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;;0CACV;AAXL,UAAU;IADtB,IAAA,wBAAS,GAAE;GACC,UAAU,CAYtB;AAZY,gCAAU;AAevB,IAAa,YAAY,GAAzB,MAAa,YAAY;CAkBxB,CAAA;AAhBC;IADC,IAAA,oBAAK,EAAC,IAAI,CAAC,EAAE,CAAC,iBAAE,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;;wCAC5B;AAGV;IADC,IAAA,oBAAK,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;;0CACd;AAGZ;IADC,IAAA,oBAAK,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;;iDACN;AAGpB;IADC,IAAA,oBAAK,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;;gDACN;AAGpB;IADC,IAAA,oBAAK,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;;4CACV;AAGhB;IADC,IAAA,oBAAK,GAAE;;4CACM;AAjBH,YAAY;IADxB,IAAA,wBAAS,GAAE;GACC,YAAY,CAkBxB;AAlBY,oCAAY;AAqBzB,IAAa,WAAW,GAAxB,MAAa,WAAW;CAMvB,CAAA;AAJC;IADC,IAAA,oBAAK,EAAC,IAAI,CAAC,EAAE,CAAC,CAAC,iBAAO,CAAC,CAAC;;0CACT;AAGhB;IADC,IAAA,oBAAK,EAAC,IAAI,CAAC,EAAE,CAAC,kBAAG,CAAC;;0CACN;AALF,WAAW;IADvB,IAAA,yBAAU,GAAE;GACA,WAAW,CAMvB;AANY,kCAAW","sourcesContent":["import { ObjectType, Field, InputType, Int, ID, registerEnumType } from 'type-graphql'\n\nimport { Routing } from './routing'\n\n@InputType()\nexport class NewRouting {\n @Field({ nullable: false })\n name: string\n\n @Field({ nullable: true })\n description?: string\n\n @Field({ nullable: true })\n createdLot?: boolean\n\n @Field({ nullable: true })\n active?: boolean\n}\n\n@InputType()\nexport class RoutingPatch {\n @Field(type => ID, { nullable: true })\n id: string\n\n @Field({ nullable: true })\n name: string\n\n @Field({ nullable: true })\n description?: string\n\n @Field({ nullable: true })\n createdLot?: boolean\n\n @Field({ nullable: true })\n active?: boolean\n\n @Field()\n cuFlag: string\n}\n\n@ObjectType()\nexport class RoutingList {\n @Field(type => [Routing])\n items: Routing[]\n\n @Field(type => Int)\n total: number\n}\n"]}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var _a, _b, _c;
|
|
3
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
3
|
exports.Routing = exports.RoutingStatus = void 0;
|
|
5
4
|
const tslib_1 = require("tslib");
|
|
@@ -26,7 +25,7 @@ tslib_1.__decorate([
|
|
|
26
25
|
tslib_1.__decorate([
|
|
27
26
|
(0, typeorm_1.ManyToOne)(type => shell_1.Domain, { nullable: false }),
|
|
28
27
|
(0, type_graphql_1.Field)({ nullable: false }),
|
|
29
|
-
tslib_1.__metadata("design:type",
|
|
28
|
+
tslib_1.__metadata("design:type", shell_1.Domain)
|
|
30
29
|
], Routing.prototype, "domain", void 0);
|
|
31
30
|
tslib_1.__decorate([
|
|
32
31
|
(0, typeorm_1.RelationId)((routing) => routing.domain),
|
|
@@ -73,7 +72,7 @@ tslib_1.__decorate([
|
|
|
73
72
|
nullable: true
|
|
74
73
|
}),
|
|
75
74
|
(0, type_graphql_1.Field)({ nullable: true }),
|
|
76
|
-
tslib_1.__metadata("design:type",
|
|
75
|
+
tslib_1.__metadata("design:type", auth_base_1.User)
|
|
77
76
|
], Routing.prototype, "creator", void 0);
|
|
78
77
|
tslib_1.__decorate([
|
|
79
78
|
(0, typeorm_1.RelationId)((routing) => routing.creator),
|
|
@@ -84,7 +83,7 @@ tslib_1.__decorate([
|
|
|
84
83
|
nullable: true
|
|
85
84
|
}),
|
|
86
85
|
(0, type_graphql_1.Field)({ nullable: true }),
|
|
87
|
-
tslib_1.__metadata("design:type",
|
|
86
|
+
tslib_1.__metadata("design:type", auth_base_1.User)
|
|
88
87
|
], Routing.prototype, "updater", void 0);
|
|
89
88
|
tslib_1.__decorate([
|
|
90
89
|
(0, typeorm_1.RelationId)((routing) => routing.creator),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"routing.js","sourceRoot":"","sources":["../../../server/service/routing/routing.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"routing.js","sourceRoot":"","sources":["../../../server/service/routing/routing.ts"],"names":[],"mappings":";;;;AAAA,qCASgB;AAChB,+CAA2E;AAE3E,iDAA8C;AAC9C,yDAAgD;AAEhD,IAAY,aAGX;AAHD,WAAY,aAAa;IACvB,sCAAqB,CAAA;IACrB,sCAAqB,CAAA;AACvB,CAAC,EAHW,aAAa,GAAb,qBAAa,KAAb,qBAAa,QAGxB;AAED,IAAA,+BAAgB,EAAC,aAAa,EAAE;IAC9B,IAAI,EAAE,eAAe;IACrB,WAAW,EAAE,gCAAgC;CAC9C,CAAC,CAAA;AAKF,IAAa,OAAO,GAApB,MAAa,OAAO;CA2DnB,CAAA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IAAA,mBAAS,EAAC,IAAI,CAAC,EAAE,CAAC,gBAAI,EAAE;QACvB,QAAQ,EAAE,IAAI;KACf,CAAC;IACD,IAAA,oBAAK,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;sCAChB,gBAAI;wCAAA;AAGd;IADC,IAAA,oBAAU,EAAC,CAAC,OAAgB,EAAE,EAAE,CAAC,OAAO,CAAC,OAAO,CAAC;;0CAChC;AAMlB;IAJC,IAAA,mBAAS,EAAC,IAAI,CAAC,EAAE,CAAC,gBAAI,EAAE;QACvB,QAAQ,EAAE,IAAI;KACf,CAAC;IACD,IAAA,oBAAK,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;sCAChB,gBAAI;wCAAA;AAGd;IADC,IAAA,oBAAU,EAAC,CAAC,OAAgB,EAAE,EAAE,CAAC,OAAO,CAAC,OAAO,CAAC;;0CAChC;AA1DP,OAAO;IAHnB,IAAA,gBAAM,GAAE;IACR,IAAA,eAAK,EAAC,cAAc,EAAE,CAAC,OAAgB,EAAE,EAAE,CAAC,CAAC,OAAO,CAAC,MAAM,EAAE,OAAO,CAAC,IAAI,CAAC,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC;IAC7F,IAAA,yBAAU,EAAC,EAAE,WAAW,EAAE,oBAAoB,EAAE,CAAC;GACrC,OAAO,CA2DnB;AA3DY,0BAAO","sourcesContent":["import {\n CreateDateColumn,\n UpdateDateColumn,\n Entity,\n Index,\n Column,\n RelationId,\n ManyToOne,\n PrimaryGeneratedColumn\n} from 'typeorm'\nimport { ObjectType, Field, Int, ID, registerEnumType } from 'type-graphql'\n\nimport { Domain } from '@things-factory/shell'\nimport { User } from '@things-factory/auth-base'\n\nexport enum RoutingStatus {\n STATUS_A = 'STATUS_A',\n STATUS_B = 'STATUS_B'\n}\n\nregisterEnumType(RoutingStatus, {\n name: 'RoutingStatus',\n description: 'state enumeration of a routing'\n})\n\n@Entity()\n@Index('ix_routing_0', (routing: Routing) => [routing.domain, routing.name], { unique: true })\n@ObjectType({ description: 'Entity for Routing' })\nexport class Routing {\n @PrimaryGeneratedColumn('uuid')\n @Field(type => ID, { nullable: false })\n readonly id: string\n\n @ManyToOne(type => Domain, { nullable: false })\n @Field({ nullable: false })\n domain?: Domain\n\n @RelationId((routing: Routing) => routing.domain)\n domainId?: string\n\n @Column({ nullable: false })\n @Field({ nullable: false })\n name: string\n\n @Column({\n nullable: true\n })\n @Field({ nullable: true })\n description?: string\n\n @Column({\n nullable: true\n })\n @Field({ nullable: true })\n createdLot?: boolean\n\n @Column({\n nullable: true\n })\n @Field({ nullable: true })\n active?: boolean\n\n @CreateDateColumn()\n @Field({ nullable: true })\n createdAt?: Date\n\n @UpdateDateColumn()\n @Field({ nullable: true })\n updatedAt?: Date\n\n @ManyToOne(type => User, {\n nullable: true\n })\n @Field({ nullable: true })\n creator?: User\n\n @RelationId((routing: Routing) => routing.creator)\n creatorId?: string\n\n @ManyToOne(type => User, {\n nullable: true\n })\n @Field({ nullable: true })\n updater?: User\n\n @RelationId((routing: Routing) => routing.creator)\n updaterId?: string\n}\n"]}
|
|
@@ -15,7 +15,7 @@ let RoutingItemMutation = class RoutingItemMutation {
|
|
|
15
15
|
const { domain, user, tx } = context.state;
|
|
16
16
|
const repository = tx.getRepository(routing_item_1.RoutingItem);
|
|
17
17
|
const routingItem = await repository.findOne({
|
|
18
|
-
where: { domain, id }
|
|
18
|
+
where: { domain: { id: domain.id }, id }
|
|
19
19
|
});
|
|
20
20
|
return await repository.save(Object.assign(Object.assign(Object.assign({}, routingItem), patch), { updater: user }));
|
|
21
21
|
}
|
|
@@ -35,7 +35,7 @@ let RoutingItemMutation = class RoutingItemMutation {
|
|
|
35
35
|
if (_updateRecords.length > 0) {
|
|
36
36
|
for (let i = 0; i < _updateRecords.length; i++) {
|
|
37
37
|
const newRecord = _updateRecords[i];
|
|
38
|
-
const routingItem = await routingItemRepo.
|
|
38
|
+
const routingItem = await routingItemRepo.findOneBy({ id: newRecord.id });
|
|
39
39
|
const result = await routingItemRepo.save(Object.assign(Object.assign(Object.assign({}, routingItem), newRecord), { updater: user }));
|
|
40
40
|
results.push(Object.assign(Object.assign({}, result), { cuFlag: 'M' }));
|
|
41
41
|
}
|
|
@@ -44,13 +44,13 @@ let RoutingItemMutation = class RoutingItemMutation {
|
|
|
44
44
|
}
|
|
45
45
|
async deleteRoutingItem(id, context) {
|
|
46
46
|
const { domain, tx } = context.state;
|
|
47
|
-
await tx.getRepository(routing_item_1.RoutingItem).delete({ domain, id });
|
|
47
|
+
await tx.getRepository(routing_item_1.RoutingItem).delete({ domain: { id: domain.id }, id });
|
|
48
48
|
return true;
|
|
49
49
|
}
|
|
50
50
|
async deleteRoutingItems(ids, context) {
|
|
51
51
|
const { domain, tx } = context.state;
|
|
52
52
|
await tx.getRepository(routing_item_1.RoutingItem).delete({
|
|
53
|
-
domain,
|
|
53
|
+
domain: { id: domain.id },
|
|
54
54
|
id: (0, typeorm_1.In)(ids)
|
|
55
55
|
});
|
|
56
56
|
return true;
|