@dssp/project 0.0.2 → 0.0.5
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/client/pages/checklist/checklist-importer.ts +6 -8
- package/client/pages/checklist/checklist-list-page.ts +10 -25
- package/client/pages/project/popup/popup-plan-upload.ts +138 -0
- package/client/pages/project/{project-create-popup.ts → popup/popup-project-create.ts} +2 -3
- package/client/pages/project/project-detail.ts +8 -7
- package/client/pages/project/project-list.ts +17 -10
- package/client/pages/project/project-plan-management.ts +117 -39
- package/client/pages/project/project-schedule-list.ts +2 -0
- package/client/pages/project/project-schedule.ts +296 -7
- package/client/pages/project/project-setting-list.ts +10 -6
- package/client/pages/project/project-update.ts +5 -2
- package/client/pages/resource/construction-type-management.ts +192 -0
- package/client/pages/resource/manager-management.ts +181 -0
- package/client/pages/resource/worker-type-management.ts +194 -0
- package/client/pages/task/task-importer.ts +6 -8
- package/client/pages/task/task-list-page.ts +10 -25
- package/client/route.ts +8 -4
- package/dist-client/pages/checklist/checklist-importer.d.ts +1 -0
- package/dist-client/pages/checklist/checklist-importer.js +3 -2
- package/dist-client/pages/checklist/checklist-importer.js.map +1 -1
- package/dist-client/pages/checklist/checklist-list-page.d.ts +1 -0
- package/dist-client/pages/checklist/checklist-list-page.js +8 -16
- package/dist-client/pages/checklist/checklist-list-page.js.map +1 -1
- package/dist-client/pages/project/popup/popup-plan-upload.d.ts +10 -0
- package/dist-client/pages/project/popup/popup-plan-upload.js +139 -0
- package/dist-client/pages/project/popup/popup-plan-upload.js.map +1 -0
- package/dist-client/pages/project/{project-create-popup.d.ts → popup/popup-project-create.d.ts} +1 -3
- package/dist-client/pages/project/{project-create-popup.js → popup/popup-project-create.js} +9 -10
- package/dist-client/pages/project/popup/popup-project-create.js.map +1 -0
- package/dist-client/pages/project/project-detail.d.ts +5 -4
- package/dist-client/pages/project/project-detail.js +7 -6
- package/dist-client/pages/project/project-detail.js.map +1 -1
- package/dist-client/pages/project/project-list.d.ts +12 -2
- package/dist-client/pages/project/project-list.js +11 -14
- package/dist-client/pages/project/project-list.js.map +1 -1
- package/dist-client/pages/project/project-plan-management.d.ts +9 -4
- package/dist-client/pages/project/project-plan-management.js +105 -35
- package/dist-client/pages/project/project-plan-management.js.map +1 -1
- package/dist-client/pages/project/project-schedule-list.d.ts +1 -0
- package/dist-client/pages/project/project-schedule-list.js +1 -0
- package/dist-client/pages/project/project-schedule-list.js.map +1 -1
- package/dist-client/pages/project/project-schedule.d.ts +10 -3
- package/dist-client/pages/project/project-schedule.js +294 -7
- package/dist-client/pages/project/project-schedule.js.map +1 -1
- package/dist-client/pages/project/project-setting-list.d.ts +3 -2
- package/dist-client/pages/project/project-setting-list.js +9 -6
- package/dist-client/pages/project/project-setting-list.js.map +1 -1
- package/dist-client/pages/project/project-update.d.ts +3 -2
- package/dist-client/pages/project/project-update.js +4 -2
- package/dist-client/pages/project/project-update.js.map +1 -1
- package/dist-client/pages/resource/construction-type-management.d.ts +27 -0
- package/dist-client/pages/resource/construction-type-management.js +189 -0
- package/dist-client/pages/resource/construction-type-management.js.map +1 -0
- package/dist-client/pages/resource/manager-management.d.ts +31 -0
- package/dist-client/pages/resource/manager-management.js +175 -0
- package/dist-client/pages/resource/manager-management.js.map +1 -0
- package/dist-client/pages/resource/worker-type-management.d.ts +27 -0
- package/dist-client/pages/resource/worker-type-management.js +191 -0
- package/dist-client/pages/resource/worker-type-management.js.map +1 -0
- package/dist-client/pages/task/task-importer.d.ts +1 -0
- package/dist-client/pages/task/task-importer.js +3 -2
- package/dist-client/pages/task/task-importer.js.map +1 -1
- package/dist-client/pages/task/task-list-page.d.ts +1 -0
- package/dist-client/pages/task/task-list-page.js +8 -16
- package/dist-client/pages/task/task-list-page.js.map +1 -1
- package/dist-client/route.d.ts +1 -1
- package/dist-client/route.js +7 -4
- package/dist-client/route.js.map +1 -1
- package/dist-client/tsconfig.tsbuildinfo +1 -1
- package/dist-server/controllers/index.d.ts +0 -0
- package/dist-server/controllers/project-to-excel.d.ts +7 -0
- package/dist-server/index.d.ts +2 -0
- package/dist-server/middlewares/index.d.ts +1 -0
- package/dist-server/routes.d.ts +1 -0
- package/dist-server/service/check-item/check-item-mutation.d.ts +10 -0
- package/dist-server/service/check-item/check-item-query.d.ts +11 -0
- package/dist-server/service/check-item/check-item-type.d.ts +18 -0
- package/dist-server/service/check-item/check-item.d.ts +18 -0
- package/dist-server/service/check-item/index.d.ts +5 -0
- package/dist-server/service/checklist/checklist-mutation.d.ts +10 -0
- package/dist-server/service/checklist/checklist-query.d.ts +11 -0
- package/dist-server/service/checklist/checklist-type.d.ts +18 -0
- package/dist-server/service/checklist/checklist.d.ts +26 -0
- package/dist-server/service/checklist/index.d.ts +5 -0
- package/dist-server/service/construction-type/construction-type-mutation.d.ts +6 -0
- package/dist-server/service/construction-type/construction-type-mutation.js +64 -0
- package/dist-server/service/construction-type/construction-type-mutation.js.map +1 -0
- package/dist-server/service/construction-type/construction-type-query.d.ts +11 -0
- package/dist-server/service/construction-type/construction-type-query.js +78 -0
- package/dist-server/service/construction-type/construction-type-query.js.map +1 -0
- package/dist-server/service/construction-type/construction-type-type.d.ts +11 -0
- package/dist-server/service/construction-type/construction-type-type.js +43 -0
- package/dist-server/service/construction-type/construction-type-type.js.map +1 -0
- package/dist-server/service/construction-type/construction-type.d.ts +16 -0
- package/dist-server/service/construction-type/construction-type.js +77 -0
- package/dist-server/service/construction-type/construction-type.js.map +1 -0
- package/dist-server/service/construction-type/index.d.ts +5 -0
- package/dist-server/service/construction-type/index.js +9 -0
- package/dist-server/service/construction-type/index.js.map +1 -0
- package/dist-server/service/index.d.ts +12 -0
- package/dist-server/service/index.js +12 -4
- package/dist-server/service/index.js.map +1 -1
- package/dist-server/service/manager/index.d.ts +5 -0
- package/dist-server/service/manager/index.js +9 -0
- package/dist-server/service/manager/index.js.map +1 -0
- package/dist-server/service/manager/manager-mutation.d.ts +5 -0
- package/dist-server/service/manager/manager-mutation.js +39 -0
- package/dist-server/service/manager/manager-mutation.js.map +1 -0
- package/dist-server/service/manager/manager-query.d.ts +4 -0
- package/dist-server/service/manager/manager-query.js +39 -0
- package/dist-server/service/manager/manager-query.js.map +1 -0
- package/dist-server/service/manager/manager-type.d.ts +15 -0
- package/dist-server/service/manager/manager-type.js +62 -0
- package/dist-server/service/manager/manager-type.js.map +1 -0
- package/dist-server/service/manager/manager.d.ts +8 -0
- package/dist-server/service/manager/manager.js +41 -0
- package/dist-server/service/manager/manager.js.map +1 -0
- package/dist-server/service/project/index.d.ts +7 -0
- package/dist-server/service/project/project-mutation.d.ts +9 -0
- package/dist-server/service/project/project-mutation.js +61 -55
- package/dist-server/service/project/project-mutation.js.map +1 -1
- package/dist-server/service/project/project-query.d.ts +16 -0
- package/dist-server/service/project/project-query.js +3 -3
- package/dist-server/service/project/project-query.js.map +1 -1
- package/dist-server/service/project/project-type.d.ts +29 -0
- package/dist-server/service/project/project-type.js +1 -2
- package/dist-server/service/project/project-type.js.map +1 -1
- package/dist-server/service/project/project.d.ts +35 -0
- package/dist-server/service/project/project.js +1 -2
- package/dist-server/service/project/project.js.map +1 -1
- package/dist-server/service/task/index.d.ts +5 -0
- package/dist-server/service/task/task-mutation.d.ts +10 -0
- package/dist-server/service/task/task-query.d.ts +11 -0
- package/dist-server/service/task/task-type.d.ts +18 -0
- package/dist-server/service/task/task.d.ts +25 -0
- package/dist-server/service/worker-type/index.d.ts +5 -0
- package/dist-server/service/worker-type/index.js +9 -0
- package/dist-server/service/worker-type/index.js.map +1 -0
- package/dist-server/service/worker-type/worker-type-mutation.d.ts +6 -0
- package/dist-server/service/worker-type/worker-type-mutation.js +64 -0
- package/dist-server/service/worker-type/worker-type-mutation.js.map +1 -0
- package/dist-server/service/worker-type/worker-type-query.d.ts +11 -0
- package/dist-server/service/{resource/resource-query.js → worker-type/worker-type-query.js} +31 -39
- package/dist-server/service/worker-type/worker-type-query.js.map +1 -0
- package/dist-server/service/worker-type/worker-type-type.d.ts +11 -0
- package/dist-server/service/worker-type/worker-type-type.js +43 -0
- package/dist-server/service/worker-type/worker-type-type.js.map +1 -0
- package/dist-server/service/worker-type/worker-type.d.ts +16 -0
- package/dist-server/service/{resource/resource.js → worker-type/worker-type.js} +35 -20
- package/dist-server/service/worker-type/worker-type.js.map +1 -0
- package/dist-server/tsconfig.tsbuildinfo +1 -1
- package/package.json +3 -3
- package/server/service/construction-type/construction-type-mutation.ts +66 -0
- package/server/service/construction-type/construction-type-query.ts +47 -0
- package/server/service/construction-type/construction-type-type.ts +26 -0
- package/server/service/{resource/resource.ts → construction-type/construction-type.ts} +18 -6
- package/server/service/construction-type/index.ts +6 -0
- package/server/service/index.ts +12 -4
- package/server/service/manager/index.ts +6 -0
- package/server/service/manager/manager-mutation.ts +42 -0
- package/server/service/manager/manager-query.ts +28 -0
- package/server/service/manager/manager-type.ts +40 -0
- package/server/service/manager/manager.ts +29 -0
- package/server/service/project/project-mutation.ts +101 -79
- package/server/service/project/project-query.ts +4 -4
- package/server/service/worker-type/index.ts +6 -0
- package/server/service/worker-type/worker-type-mutation.ts +66 -0
- package/server/service/worker-type/worker-type-query.ts +47 -0
- package/server/service/worker-type/worker-type-type.ts +26 -0
- package/server/service/worker-type/worker-type.ts +68 -0
- package/things-factory.config.js +3 -0
- package/client/pages/project/ox-progress-circle.ts +0 -133
- package/client/pages/resource/resource-importer.ts +0 -96
- package/client/pages/resource/resource-list-page.ts +0 -355
- package/dist-client/pages/project/ox-progress-circle.d.ts +0 -41
- package/dist-client/pages/project/ox-progress-circle.js +0 -182
- package/dist-client/pages/project/ox-progress-circle.js.map +0 -1
- package/dist-client/pages/project/project-create-popup.js.map +0 -1
- package/dist-client/pages/resource/resource-importer.d.ts +0 -9
- package/dist-client/pages/resource/resource-importer.js +0 -100
- package/dist-client/pages/resource/resource-importer.js.map +0 -1
- package/dist-client/pages/resource/resource-list-page.d.ts +0 -62
- package/dist-client/pages/resource/resource-list-page.js +0 -331
- package/dist-client/pages/resource/resource-list-page.js.map +0 -1
- package/dist-server/service/resource/index.js +0 -9
- package/dist-server/service/resource/index.js.map +0 -1
- package/dist-server/service/resource/resource-mutation.js +0 -129
- package/dist-server/service/resource/resource-mutation.js.map +0 -1
- package/dist-server/service/resource/resource-query.js.map +0 -1
- package/dist-server/service/resource/resource-type.js +0 -69
- package/dist-server/service/resource/resource-type.js.map +0 -1
- package/dist-server/service/resource/resource.js.map +0 -1
- package/server/service/resource/index.ts +0 -6
- package/server/service/resource/resource-mutation.ts +0 -139
- package/server/service/resource/resource-query.ts +0 -56
- package/server/service/resource/resource-type.ts +0 -49
|
@@ -1,129 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.ResourceMutation = void 0;
|
|
4
|
-
const tslib_1 = require("tslib");
|
|
5
|
-
const type_graphql_1 = require("type-graphql");
|
|
6
|
-
const typeorm_1 = require("typeorm");
|
|
7
|
-
const attachment_base_1 = require("@things-factory/attachment-base");
|
|
8
|
-
const resource_1 = require("./resource");
|
|
9
|
-
const resource_type_1 = require("./resource-type");
|
|
10
|
-
let ResourceMutation = class ResourceMutation {
|
|
11
|
-
async createResource(resource, context) {
|
|
12
|
-
const { domain, user, tx } = context.state;
|
|
13
|
-
const result = await tx.getRepository(resource_1.Resource).save(Object.assign(Object.assign({}, resource), { domain, creator: user, updater: user }));
|
|
14
|
-
return result;
|
|
15
|
-
}
|
|
16
|
-
async updateResource(id, patch, context) {
|
|
17
|
-
const { domain, user, tx } = context.state;
|
|
18
|
-
const repository = tx.getRepository(resource_1.Resource);
|
|
19
|
-
const resource = await repository.findOne({
|
|
20
|
-
where: { id }
|
|
21
|
-
});
|
|
22
|
-
const result = await repository.save(Object.assign(Object.assign(Object.assign({}, resource), patch), { updater: user }));
|
|
23
|
-
return result;
|
|
24
|
-
}
|
|
25
|
-
async updateMultipleResource(patches, context) {
|
|
26
|
-
const { domain, user, tx } = context.state;
|
|
27
|
-
let results = [];
|
|
28
|
-
const _createRecords = patches.filter((patch) => patch.cuFlag.toUpperCase() === '+');
|
|
29
|
-
const _updateRecords = patches.filter((patch) => patch.cuFlag.toUpperCase() === 'M');
|
|
30
|
-
const resourceRepo = tx.getRepository(resource_1.Resource);
|
|
31
|
-
if (_createRecords.length > 0) {
|
|
32
|
-
for (let i = 0; i < _createRecords.length; i++) {
|
|
33
|
-
const newRecord = _createRecords[i];
|
|
34
|
-
const result = await resourceRepo.save(Object.assign(Object.assign({}, newRecord), { domain, creator: user, updater: user }));
|
|
35
|
-
results.push(Object.assign(Object.assign({}, result), { cuFlag: '+' }));
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
if (_updateRecords.length > 0) {
|
|
39
|
-
for (let i = 0; i < _updateRecords.length; i++) {
|
|
40
|
-
const updateRecord = _updateRecords[i];
|
|
41
|
-
const resource = await resourceRepo.findOneBy({ id: updateRecord.id });
|
|
42
|
-
const result = await resourceRepo.save(Object.assign(Object.assign(Object.assign({}, resource), updateRecord), { updater: user }));
|
|
43
|
-
results.push(Object.assign(Object.assign({}, result), { cuFlag: 'M' }));
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
return results;
|
|
47
|
-
}
|
|
48
|
-
async deleteResource(id, context) {
|
|
49
|
-
const { domain, tx } = context.state;
|
|
50
|
-
await tx.getRepository(resource_1.Resource).delete({ id });
|
|
51
|
-
await (0, attachment_base_1.deleteAttachmentsByRef)(null, { refBys: [id] }, context);
|
|
52
|
-
return true;
|
|
53
|
-
}
|
|
54
|
-
async deleteResources(ids, context) {
|
|
55
|
-
const { domain, tx } = context.state;
|
|
56
|
-
await tx.getRepository(resource_1.Resource).delete({
|
|
57
|
-
id: (0, typeorm_1.In)(ids)
|
|
58
|
-
});
|
|
59
|
-
await (0, attachment_base_1.deleteAttachmentsByRef)(null, { refBys: ids }, context);
|
|
60
|
-
return true;
|
|
61
|
-
}
|
|
62
|
-
async importResources(resources, context) {
|
|
63
|
-
const { domain, tx } = context.state;
|
|
64
|
-
await Promise.all(resources.map(async (resource) => {
|
|
65
|
-
const createdResource = await tx.getRepository(resource_1.Resource).save(Object.assign({ domain }, resource));
|
|
66
|
-
}));
|
|
67
|
-
return true;
|
|
68
|
-
}
|
|
69
|
-
};
|
|
70
|
-
tslib_1.__decorate([
|
|
71
|
-
(0, type_graphql_1.Directive)('@transaction'),
|
|
72
|
-
(0, type_graphql_1.Mutation)(returns => resource_1.Resource, { description: 'To create new Resource' }),
|
|
73
|
-
tslib_1.__param(0, (0, type_graphql_1.Arg)('resource')),
|
|
74
|
-
tslib_1.__param(1, (0, type_graphql_1.Ctx)()),
|
|
75
|
-
tslib_1.__metadata("design:type", Function),
|
|
76
|
-
tslib_1.__metadata("design:paramtypes", [resource_type_1.NewResource, Object]),
|
|
77
|
-
tslib_1.__metadata("design:returntype", Promise)
|
|
78
|
-
], ResourceMutation.prototype, "createResource", null);
|
|
79
|
-
tslib_1.__decorate([
|
|
80
|
-
(0, type_graphql_1.Directive)('@transaction'),
|
|
81
|
-
(0, type_graphql_1.Mutation)(returns => resource_1.Resource, { description: 'To modify Resource information' }),
|
|
82
|
-
tslib_1.__param(0, (0, type_graphql_1.Arg)('id')),
|
|
83
|
-
tslib_1.__param(1, (0, type_graphql_1.Arg)('patch')),
|
|
84
|
-
tslib_1.__param(2, (0, type_graphql_1.Ctx)()),
|
|
85
|
-
tslib_1.__metadata("design:type", Function),
|
|
86
|
-
tslib_1.__metadata("design:paramtypes", [String, resource_type_1.ResourcePatch, Object]),
|
|
87
|
-
tslib_1.__metadata("design:returntype", Promise)
|
|
88
|
-
], ResourceMutation.prototype, "updateResource", null);
|
|
89
|
-
tslib_1.__decorate([
|
|
90
|
-
(0, type_graphql_1.Directive)('@transaction'),
|
|
91
|
-
(0, type_graphql_1.Mutation)(returns => [resource_1.Resource], { description: "To modify multiple Resources' information" }),
|
|
92
|
-
tslib_1.__param(0, (0, type_graphql_1.Arg)('patches', type => [resource_type_1.ResourcePatch])),
|
|
93
|
-
tslib_1.__param(1, (0, type_graphql_1.Ctx)()),
|
|
94
|
-
tslib_1.__metadata("design:type", Function),
|
|
95
|
-
tslib_1.__metadata("design:paramtypes", [Array, Object]),
|
|
96
|
-
tslib_1.__metadata("design:returntype", Promise)
|
|
97
|
-
], ResourceMutation.prototype, "updateMultipleResource", null);
|
|
98
|
-
tslib_1.__decorate([
|
|
99
|
-
(0, type_graphql_1.Directive)('@transaction'),
|
|
100
|
-
(0, type_graphql_1.Mutation)(returns => Boolean, { description: 'To delete Resource' }),
|
|
101
|
-
tslib_1.__param(0, (0, type_graphql_1.Arg)('id')),
|
|
102
|
-
tslib_1.__param(1, (0, type_graphql_1.Ctx)()),
|
|
103
|
-
tslib_1.__metadata("design:type", Function),
|
|
104
|
-
tslib_1.__metadata("design:paramtypes", [String, Object]),
|
|
105
|
-
tslib_1.__metadata("design:returntype", Promise)
|
|
106
|
-
], ResourceMutation.prototype, "deleteResource", null);
|
|
107
|
-
tslib_1.__decorate([
|
|
108
|
-
(0, type_graphql_1.Directive)('@transaction'),
|
|
109
|
-
(0, type_graphql_1.Mutation)(returns => Boolean, { description: 'To delete multiple Resources' }),
|
|
110
|
-
tslib_1.__param(0, (0, type_graphql_1.Arg)('ids', type => [String])),
|
|
111
|
-
tslib_1.__param(1, (0, type_graphql_1.Ctx)()),
|
|
112
|
-
tslib_1.__metadata("design:type", Function),
|
|
113
|
-
tslib_1.__metadata("design:paramtypes", [Array, Object]),
|
|
114
|
-
tslib_1.__metadata("design:returntype", Promise)
|
|
115
|
-
], ResourceMutation.prototype, "deleteResources", null);
|
|
116
|
-
tslib_1.__decorate([
|
|
117
|
-
(0, type_graphql_1.Directive)('@transaction'),
|
|
118
|
-
(0, type_graphql_1.Mutation)(returns => Boolean, { description: 'To import multiple Resources' }),
|
|
119
|
-
tslib_1.__param(0, (0, type_graphql_1.Arg)('resources', type => [resource_type_1.ResourcePatch])),
|
|
120
|
-
tslib_1.__param(1, (0, type_graphql_1.Ctx)()),
|
|
121
|
-
tslib_1.__metadata("design:type", Function),
|
|
122
|
-
tslib_1.__metadata("design:paramtypes", [Array, Object]),
|
|
123
|
-
tslib_1.__metadata("design:returntype", Promise)
|
|
124
|
-
], ResourceMutation.prototype, "importResources", null);
|
|
125
|
-
ResourceMutation = tslib_1.__decorate([
|
|
126
|
-
(0, type_graphql_1.Resolver)(resource_1.Resource)
|
|
127
|
-
], ResourceMutation);
|
|
128
|
-
exports.ResourceMutation = ResourceMutation;
|
|
129
|
-
//# sourceMappingURL=resource-mutation.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"resource-mutation.js","sourceRoot":"","sources":["../../../server/service/resource/resource-mutation.ts"],"names":[],"mappings":";;;;AAAA,+CAAsE;AACtE,qCAA4B;AAE5B,qEAA0F;AAE1F,yCAAqC;AACrC,mDAA4D;AAGrD,IAAM,gBAAgB,GAAtB,MAAM,gBAAgB;IAGrB,AAAN,KAAK,CAAC,cAAc,CAAkB,QAAqB,EAAS,OAAwB;QAC1F,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,EAAE,EAAE,GAAG,OAAO,CAAC,KAAK,CAAA;QAE1C,MAAM,MAAM,GAAG,MAAM,EAAE,CAAC,aAAa,CAAC,mBAAQ,CAAC,CAAC,IAAI,iCAC/C,QAAQ,KACX,MAAM,EACN,OAAO,EAAE,IAAI,EACb,OAAO,EAAE,IAAI,IACb,CAAA;QAEF,OAAO,MAAM,CAAA;IACf,CAAC;IAIK,AAAN,KAAK,CAAC,cAAc,CACP,EAAU,EACP,KAAoB,EAC3B,OAAwB;QAE/B,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,EAAE,EAAE,GAAG,OAAO,CAAC,KAAK,CAAA;QAE1C,MAAM,UAAU,GAAG,EAAE,CAAC,aAAa,CAAC,mBAAQ,CAAC,CAAA;QAC7C,MAAM,QAAQ,GAAG,MAAM,UAAU,CAAC,OAAO,CAAC;YACxC,KAAK,EAAE,EAAE,EAAE,EAAE;SACd,CAAC,CAAA;QAEF,MAAM,MAAM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K;IAFL,IAAA,wBAAS,EAAC,cAAc,CAAC;IACzB,IAAA,uBAAQ,EAAC,OAAO,CAAC,EAAE,CAAC,OAAO,EAAE,EAAE,WAAW,EAAE,oBAAoB,EAAE,CAAC;IAC9C,mBAAA,IAAA,kBAAG,EAAC,IAAI,CAAC,CAAA;IAAc,mBAAA,IAAA,kBAAG,GAAE,CAAA;;;;sDAOjD;AAIK;IAFL,IAAA,wBAAS,EAAC,cAAc,CAAC;IACzB,IAAA,uBAAQ,EAAC,OAAO,CAAC,EAAE,CAAC,OAAO,EAAE,EAAE,WAAW,EAAE,8BAA8B,EAAE,CAAC;IAE3E,mBAAA,IAAA,kBAAG,EAAC,KAAK,EAAE,IAAI,CAAC,EAAE,CAAC,CAAC,MAAM,CAAC,CAAC,CAAA;IAC5B,mBAAA,IAAA,kBAAG,GAAE,CAAA;;;;uDAWP;AAIK;IAFL,IAAA,wBAAS,EAAC,cAAc,CAAC;IACzB,IAAA,uBAAQ,EAAC,OAAO,CAAC,EAAE,CAAC,OAAO,EAAE,EAAE,WAAW,EAAE,8BAA8B,EAAE,CAAC;IAE3E,mBAAA,IAAA,kBAAG,EAAC,WAAW,EAAE,IAAI,CAAC,EAAE,CAAC,CAAC,6BAAa,CAAC,CAAC,CAAA;IACzC,mBAAA,IAAA,kBAAG,GAAE,CAAA;;;;uDAWP;AAhIU,gBAAgB;IAD5B,IAAA,uBAAQ,EAAC,mBAAQ,CAAC;GACN,gBAAgB,CAiI5B;AAjIY,4CAAgB","sourcesContent":["import { Resolver, Mutation, Arg, Ctx, Directive } from 'type-graphql'\nimport { In } from 'typeorm'\n\nimport { createAttachment, deleteAttachmentsByRef } from '@things-factory/attachment-base'\n\nimport { Resource } from './resource'\nimport { NewResource, ResourcePatch } from './resource-type'\n\n@Resolver(Resource)\nexport class ResourceMutation {\n @Directive('@transaction')\n @Mutation(returns => Resource, { description: 'To create new Resource' })\n async createResource(@Arg('resource') resource: NewResource, @Ctx() context: ResolverContext): Promise<Resource> {\n const { domain, user, tx } = context.state\n\n const result = await tx.getRepository(Resource).save({\n ...resource,\n domain,\n creator: user,\n updater: user\n })\n\n return result\n }\n\n @Directive('@transaction')\n @Mutation(returns => Resource, { description: 'To modify Resource information' })\n async updateResource(\n @Arg('id') id: string,\n @Arg('patch') patch: ResourcePatch,\n @Ctx() context: ResolverContext\n ): Promise<Resource> {\n const { domain, user, tx } = context.state\n\n const repository = tx.getRepository(Resource)\n const resource = await repository.findOne({\n where: { id }\n })\n\n const result = await repository.save({\n ...resource,\n ...patch,\n updater: user\n })\n\n return result\n }\n\n @Directive('@transaction')\n @Mutation(returns => [Resource], { description: \"To modify multiple Resources' information\" })\n async updateMultipleResource(\n @Arg('patches', type => [ResourcePatch]) patches: ResourcePatch[],\n @Ctx() context: ResolverContext\n ): Promise<Resource[]> {\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 resourceRepo = tx.getRepository(Resource)\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 resourceRepo.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 updateRecord = _updateRecords[i]\n const resource = await resourceRepo.findOneBy({ id: updateRecord.id })\n\n const result = await resourceRepo.save({\n ...resource,\n ...updateRecord,\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 Resource' })\n async deleteResource(@Arg('id') id: string, @Ctx() context: ResolverContext): Promise<boolean> {\n const { domain, tx } = context.state\n\n await tx.getRepository(Resource).delete({ 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 Resources' })\n async deleteResources(\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(Resource).delete({\n id: In(ids)\n })\n\n await deleteAttachmentsByRef(null, { refBys: ids }, context)\n\n return true\n }\n\n @Directive('@transaction')\n @Mutation(returns => Boolean, { description: 'To import multiple Resources' })\n async importResources(\n @Arg('resources', type => [ResourcePatch]) resources: ResourcePatch[],\n @Ctx() context: ResolverContext\n ): Promise<boolean> {\n const { domain, tx } = context.state\n\n await Promise.all(\n resources.map(async (resource: ResourcePatch) => {\n const createdResource: Resource = await tx.getRepository(Resource).save({ domain, ...resource })\n })\n )\n\n return true\n }\n}\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"resource-query.js","sourceRoot":"","sources":["../../../server/service/resource/resource-query.ts"],"names":[],"mappings":";;;;AAAA,+CAA8F;AAC9F,qEAA4D;AAC5D,iDAAuG;AACvG,yDAAgD;AAChD,yCAAqC;AACrC,mDAA8C;AAGvC,IAAM,aAAa,GAAnB,MAAM,aAAa;IAElB,AAAN,KAAK,CAAC,QAAQ,CAAY,EAAU,EAAS,OAAwB;QACnE,MAAM,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,KAAK,CAAA;QAEhC,OAAO,MAAM,IAAA,qBAAa,EAAC,mBAAQ,CAAC,CAAC,OAAO,CAAC;YAC3C,KAAK,EAAE,EAAE,EAAE,EAAE;SACd,CAAC,CAAA;IACJ,CAAC;IAGK,AAAN,KAAK,CAAC,SAAS,CAAS,MAAiB,EAAS,OAAwB;QACxE,MAAM,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,KAAK,CAAA;QAEhC,MAAM,YAAY,GAAG,IAAA,qCAA6B,EAAC;YACjD,MAAM;YACN,MAAM;YACN,UAAU,EAAE,MAAM,IAAA,qBAAa,EAAC,mBAAQ,CAAC;YAC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AC;IAC9D,mBAAA,IAAA,mBAAI,GAAE,CAAA;IAAqB,mBAAA,IAAA,kBAAG,GAAE,CAAA;;6CAAjB,iBAAS;;8CAaxC;AAGK;IADL,IAAA,4BAAa,EAAC,IAAI,CAAC,EAAE,CAAC,MAAM,CAAC;IACb,mBAAA,IAAA,mBAAI,GAAE,CAAA;;6CAAW,mBAAQ;;8CASzC;AAGK;IADL,IAAA,4BAAa,EAAC,IAAI,CAAC,EAAE,CAAC,gBAAI,CAAC;IACb,mBAAA,IAAA,mBAAI,GAAE,CAAA;;6CAAW,mBAAQ;;4CAEvC;AAGK;IADL,IAAA,4BAAa,EAAC,IAAI,CAAC,EAAE,CAAC,gBAAI,CAAC;IACb,mBAAA,IAAA,mBAAI,GAAE,CAAA;;6CAAW,mBAAQ;;4CAEvC;AA9CU,aAAa;IADzB,IAAA,uBAAQ,EAAC,mBAAQ,CAAC;GACN,aAAa,CA+CzB;AA/CY,sCAAa","sourcesContent":["import { Resolver, Query, FieldResolver, Root, Args, Arg, Ctx, Directive } from 'type-graphql'\nimport { Attachment } from '@things-factory/attachment-base'\nimport { Domain, getQueryBuilderFromListParams, getRepository, ListParam } from '@things-factory/shell'\nimport { User } from '@things-factory/auth-base'\nimport { Resource } from './resource'\nimport { ResourceList } from './resource-type'\n\n@Resolver(Resource)\nexport class ResourceQuery {\n @Query(returns => Resource!, { nullable: true, description: 'To fetch a Resource' })\n async resource(@Arg('id') id: string, @Ctx() context: ResolverContext): Promise<Resource> {\n const { domain } = context.state\n\n return await getRepository(Resource).findOne({\n where: { id }\n })\n }\n\n @Query(returns => ResourceList, { description: 'To fetch multiple Resources' })\n async resources(@Args() params: ListParam, @Ctx() context: ResolverContext): Promise<ResourceList> {\n const { domain } = context.state\n\n const queryBuilder = getQueryBuilderFromListParams({\n domain,\n params,\n repository: await getRepository(Resource),\n searchables: ['name', 'description']\n })\n\n const [items, total] = await queryBuilder.getManyAndCount()\n\n return { items, total }\n }\n\n @FieldResolver(type => String)\n async thumbnail(@Root() resource: Resource): Promise<string | undefined> {\n const attachment: Attachment = await getRepository(Attachment).findOne({\n where: {\n refType: Resource.name,\n refBy: resource.id\n }\n })\n\n return attachment?.fullpath\n }\n\n @FieldResolver(type => User)\n async updater(@Root() resource: Resource): Promise<User> {\n return await getRepository(User).findOneBy({ id: resource.updaterId })\n }\n\n @FieldResolver(type => User)\n async creator(@Root() resource: Resource): Promise<User> {\n return await getRepository(User).findOneBy({ id: resource.creatorId })\n }\n}\n"]}
|
|
@@ -1,69 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.ResourceList = exports.ResourcePatch = exports.NewResource = void 0;
|
|
4
|
-
const tslib_1 = require("tslib");
|
|
5
|
-
const type_graphql_1 = require("type-graphql");
|
|
6
|
-
const resource_1 = require("./resource");
|
|
7
|
-
let NewResource = class NewResource {
|
|
8
|
-
};
|
|
9
|
-
tslib_1.__decorate([
|
|
10
|
-
(0, type_graphql_1.Field)(),
|
|
11
|
-
tslib_1.__metadata("design:type", String)
|
|
12
|
-
], NewResource.prototype, "name", void 0);
|
|
13
|
-
tslib_1.__decorate([
|
|
14
|
-
(0, type_graphql_1.Field)({ nullable: true }),
|
|
15
|
-
tslib_1.__metadata("design:type", String)
|
|
16
|
-
], NewResource.prototype, "description", void 0);
|
|
17
|
-
tslib_1.__decorate([
|
|
18
|
-
(0, type_graphql_1.Field)({ nullable: true }),
|
|
19
|
-
tslib_1.__metadata("design:type", Boolean)
|
|
20
|
-
], NewResource.prototype, "active", void 0);
|
|
21
|
-
tslib_1.__decorate([
|
|
22
|
-
(0, type_graphql_1.Field)({ nullable: true }),
|
|
23
|
-
tslib_1.__metadata("design:type", String)
|
|
24
|
-
], NewResource.prototype, "params", void 0);
|
|
25
|
-
NewResource = tslib_1.__decorate([
|
|
26
|
-
(0, type_graphql_1.InputType)()
|
|
27
|
-
], NewResource);
|
|
28
|
-
exports.NewResource = NewResource;
|
|
29
|
-
let ResourcePatch = class ResourcePatch {
|
|
30
|
-
};
|
|
31
|
-
tslib_1.__decorate([
|
|
32
|
-
(0, type_graphql_1.Field)(type => type_graphql_1.ID, { nullable: true }),
|
|
33
|
-
tslib_1.__metadata("design:type", String)
|
|
34
|
-
], ResourcePatch.prototype, "id", void 0);
|
|
35
|
-
tslib_1.__decorate([
|
|
36
|
-
(0, type_graphql_1.Field)({ nullable: true }),
|
|
37
|
-
tslib_1.__metadata("design:type", String)
|
|
38
|
-
], ResourcePatch.prototype, "name", void 0);
|
|
39
|
-
tslib_1.__decorate([
|
|
40
|
-
(0, type_graphql_1.Field)({ nullable: true }),
|
|
41
|
-
tslib_1.__metadata("design:type", String)
|
|
42
|
-
], ResourcePatch.prototype, "description", void 0);
|
|
43
|
-
tslib_1.__decorate([
|
|
44
|
-
(0, type_graphql_1.Field)({ nullable: true }),
|
|
45
|
-
tslib_1.__metadata("design:type", Boolean)
|
|
46
|
-
], ResourcePatch.prototype, "active", void 0);
|
|
47
|
-
tslib_1.__decorate([
|
|
48
|
-
(0, type_graphql_1.Field)({ nullable: true }),
|
|
49
|
-
tslib_1.__metadata("design:type", String)
|
|
50
|
-
], ResourcePatch.prototype, "cuFlag", void 0);
|
|
51
|
-
ResourcePatch = tslib_1.__decorate([
|
|
52
|
-
(0, type_graphql_1.InputType)()
|
|
53
|
-
], ResourcePatch);
|
|
54
|
-
exports.ResourcePatch = ResourcePatch;
|
|
55
|
-
let ResourceList = class ResourceList {
|
|
56
|
-
};
|
|
57
|
-
tslib_1.__decorate([
|
|
58
|
-
(0, type_graphql_1.Field)(type => [resource_1.Resource]),
|
|
59
|
-
tslib_1.__metadata("design:type", Array)
|
|
60
|
-
], ResourceList.prototype, "items", void 0);
|
|
61
|
-
tslib_1.__decorate([
|
|
62
|
-
(0, type_graphql_1.Field)(type => type_graphql_1.Int),
|
|
63
|
-
tslib_1.__metadata("design:type", Number)
|
|
64
|
-
], ResourceList.prototype, "total", void 0);
|
|
65
|
-
ResourceList = tslib_1.__decorate([
|
|
66
|
-
(0, type_graphql_1.ObjectType)()
|
|
67
|
-
], ResourceList);
|
|
68
|
-
exports.ResourceList = ResourceList;
|
|
69
|
-
//# sourceMappingURL=resource-type.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"resource-type.js","sourceRoot":"","sources":["../../../server/service/resource/resource-type.ts"],"names":[],"mappings":";;;;AAEA,+CAAsF;AAItF,yCAAqC;AAG9B,IAAM,WAAW,GAAjB,MAAM,WAAW;CAYvB,CAAA;AAXC;IAAC,IAAA,oBAAK,GAAE;;yCACI;AAEZ;IAAC,IAAA,oBAAK,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;;gDACN;AAEpB;IAAC,IAAA,oBAAK,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;;2CACV;AAEhB;IAAC,IAAA,oBAAK,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;;2CACX;AAXJ,WAAW;IADvB,IAAA,wBAAS,GAAE;GACC,WAAW,CAYvB;AAZY,kCAAW;AAejB,IAAM,aAAa,GAAnB,MAAM,aAAa;CAezB,CAAA;AAdC;IAAC,IAAA,oBAAK,EAAC,IAAI,CAAC,EAAE,CAAC,iBAAE,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;;yCAC3B;AAEX;IAAC,IAAA,oBAAK,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;;2CACb;AAEb;IAAC,IAAA,oBAAK,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;;kDACN;AAEpB;IAAC,IAAA,oBAAK,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;;6CACV;AAEhB;IAAC,IAAA,oBAAK,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;;6CACX;AAdJ,aAAa;IADzB,IAAA,wBAAS,GAAE;GACC,aAAa,CAezB;AAfY,sCAAa;AAkBnB,IAAM,YAAY,GAAlB,MAAM,YAAY;CAMxB,CAAA;AALC;IAAC,IAAA,oBAAK,EAAC,IAAI,CAAC,EAAE,CAAC,CAAC,mBAAQ,CAAC,CAAC;;2CACT;AAEjB;IAAC,IAAA,oBAAK,EAAC,IAAI,CAAC,EAAE,CAAC,kBAAG,CAAC;;2CACN;AALF,YAAY;IADxB,IAAA,yBAAU,GAAE;GACA,YAAY,CAMxB;AANY,oCAAY","sourcesContent":["import type { FileUpload } from 'graphql-upload/GraphQLUpload.js'\nimport GraphQLUpload from 'graphql-upload/GraphQLUpload.js'\nimport { ObjectType, Field, InputType, Int, ID, registerEnumType } from 'type-graphql'\n\nimport { ObjectRef, ScalarObject } from '@things-factory/shell'\n\nimport { Resource } from './resource'\n\n@InputType()\nexport class NewResource {\n @Field()\n name: string\n\n @Field({ nullable: true })\n description?: string\n\n @Field({ nullable: true })\n active?: boolean\n\n @Field({ nullable: true })\n params?: string\n}\n\n@InputType()\nexport class ResourcePatch {\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 active?: boolean\n\n @Field({ nullable: true })\n cuFlag?: string\n}\n\n@ObjectType()\nexport class ResourceList {\n @Field(type => [Resource])\n items: Resource[]\n\n @Field(type => Int)\n total: number\n}\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"resource.js","sourceRoot":"","sources":["../../../server/service/resource/resource.ts"],"names":[],"mappings":";;;;AAAA,qCAUgB;AAChB,+CAAoD;AAEpD,yDAAgD;AAQzC,IAAM,QAAQ,GAAd,MAAM,QAAQ;CAkCpB,CAAA;AAjCC;IAAC,IAAA,gCAAsB,EAAC,MAAM,CAAC;IAC9B,IAAA,oBAAK,EAAC,IAAI,CAAC,EAAE,CAAC,iBAAE,CAAC;;oCACC;AAEnB;IAAC,IAAA,gBAAM,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,OAAO,EAAE,IAA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,MAAM,EAAE,IAAI;QACZ,KAAK,EAAE,sBAAsB;KAC9B,CAAC;IACD,IAAA,yBAAU,EAAC,EAAE,WAAW,EAAE,cAAc,EAAE,CAAC;GAC/B,QAAQ,CAkCpB;AAlCY,4BAAQ","sourcesContent":["import {\n CreateDateColumn,\n UpdateDateColumn,\n DeleteDateColumn,\n Entity,\n Index,\n Column,\n RelationId,\n ManyToOne,\n PrimaryGeneratedColumn\n} from 'typeorm'\nimport { ObjectType, Field, ID } from 'type-graphql'\n\nimport { User } from '@things-factory/auth-base'\n\n@Entity()\n@Index('ix_resource_0', (resource: Resource) => [resource.name], {\n unique: true,\n where: '\"deleted_at\" IS NULL'\n})\n@ObjectType({ description: '리소스 관리 (작업자)' })\nexport class Resource {\n @PrimaryGeneratedColumn('uuid')\n @Field(type => ID)\n readonly id: string\n\n @Column({ nullable: true, comment: '직군' })\n @Field({ nullable: true })\n name?: string\n\n @CreateDateColumn()\n @Field({ nullable: true })\n createdAt?: Date\n\n @UpdateDateColumn()\n @Field({ nullable: true })\n updatedAt?: Date\n\n @DeleteDateColumn()\n @Field({ nullable: true })\n deletedAt?: Date\n\n @ManyToOne(type => User, { nullable: true })\n @Field(type => User, { nullable: true })\n creator?: User\n\n @RelationId((resource: Resource) => resource.creator)\n creatorId?: string\n\n @ManyToOne(type => User, { nullable: true })\n @Field(type => User, { nullable: true })\n updater?: User\n\n @RelationId((resource: Resource) => resource.updater)\n updaterId?: string\n}\n"]}
|
|
@@ -1,139 +0,0 @@
|
|
|
1
|
-
import { Resolver, Mutation, Arg, Ctx, Directive } from 'type-graphql'
|
|
2
|
-
import { In } from 'typeorm'
|
|
3
|
-
|
|
4
|
-
import { createAttachment, deleteAttachmentsByRef } from '@things-factory/attachment-base'
|
|
5
|
-
|
|
6
|
-
import { Resource } from './resource'
|
|
7
|
-
import { NewResource, ResourcePatch } from './resource-type'
|
|
8
|
-
|
|
9
|
-
@Resolver(Resource)
|
|
10
|
-
export class ResourceMutation {
|
|
11
|
-
@Directive('@transaction')
|
|
12
|
-
@Mutation(returns => Resource, { description: 'To create new Resource' })
|
|
13
|
-
async createResource(@Arg('resource') resource: NewResource, @Ctx() context: ResolverContext): Promise<Resource> {
|
|
14
|
-
const { domain, user, tx } = context.state
|
|
15
|
-
|
|
16
|
-
const result = await tx.getRepository(Resource).save({
|
|
17
|
-
...resource,
|
|
18
|
-
domain,
|
|
19
|
-
creator: user,
|
|
20
|
-
updater: user
|
|
21
|
-
})
|
|
22
|
-
|
|
23
|
-
return result
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
@Directive('@transaction')
|
|
27
|
-
@Mutation(returns => Resource, { description: 'To modify Resource information' })
|
|
28
|
-
async updateResource(
|
|
29
|
-
@Arg('id') id: string,
|
|
30
|
-
@Arg('patch') patch: ResourcePatch,
|
|
31
|
-
@Ctx() context: ResolverContext
|
|
32
|
-
): Promise<Resource> {
|
|
33
|
-
const { domain, user, tx } = context.state
|
|
34
|
-
|
|
35
|
-
const repository = tx.getRepository(Resource)
|
|
36
|
-
const resource = await repository.findOne({
|
|
37
|
-
where: { id }
|
|
38
|
-
})
|
|
39
|
-
|
|
40
|
-
const result = await repository.save({
|
|
41
|
-
...resource,
|
|
42
|
-
...patch,
|
|
43
|
-
updater: user
|
|
44
|
-
})
|
|
45
|
-
|
|
46
|
-
return result
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
@Directive('@transaction')
|
|
50
|
-
@Mutation(returns => [Resource], { description: "To modify multiple Resources' information" })
|
|
51
|
-
async updateMultipleResource(
|
|
52
|
-
@Arg('patches', type => [ResourcePatch]) patches: ResourcePatch[],
|
|
53
|
-
@Ctx() context: ResolverContext
|
|
54
|
-
): Promise<Resource[]> {
|
|
55
|
-
const { domain, user, tx } = context.state
|
|
56
|
-
|
|
57
|
-
let results = []
|
|
58
|
-
const _createRecords = patches.filter((patch: any) => patch.cuFlag.toUpperCase() === '+')
|
|
59
|
-
const _updateRecords = patches.filter((patch: any) => patch.cuFlag.toUpperCase() === 'M')
|
|
60
|
-
const resourceRepo = tx.getRepository(Resource)
|
|
61
|
-
|
|
62
|
-
if (_createRecords.length > 0) {
|
|
63
|
-
for (let i = 0; i < _createRecords.length; i++) {
|
|
64
|
-
const newRecord = _createRecords[i]
|
|
65
|
-
|
|
66
|
-
const result = await resourceRepo.save({
|
|
67
|
-
...newRecord,
|
|
68
|
-
domain,
|
|
69
|
-
creator: user,
|
|
70
|
-
updater: user
|
|
71
|
-
})
|
|
72
|
-
|
|
73
|
-
results.push({ ...result, cuFlag: '+' })
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
if (_updateRecords.length > 0) {
|
|
78
|
-
for (let i = 0; i < _updateRecords.length; i++) {
|
|
79
|
-
const updateRecord = _updateRecords[i]
|
|
80
|
-
const resource = await resourceRepo.findOneBy({ id: updateRecord.id })
|
|
81
|
-
|
|
82
|
-
const result = await resourceRepo.save({
|
|
83
|
-
...resource,
|
|
84
|
-
...updateRecord,
|
|
85
|
-
updater: user
|
|
86
|
-
})
|
|
87
|
-
|
|
88
|
-
results.push({ ...result, cuFlag: 'M' })
|
|
89
|
-
}
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
return results
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
@Directive('@transaction')
|
|
96
|
-
@Mutation(returns => Boolean, { description: 'To delete Resource' })
|
|
97
|
-
async deleteResource(@Arg('id') id: string, @Ctx() context: ResolverContext): Promise<boolean> {
|
|
98
|
-
const { domain, tx } = context.state
|
|
99
|
-
|
|
100
|
-
await tx.getRepository(Resource).delete({ id })
|
|
101
|
-
await deleteAttachmentsByRef(null, { refBys: [id] }, context)
|
|
102
|
-
|
|
103
|
-
return true
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
@Directive('@transaction')
|
|
107
|
-
@Mutation(returns => Boolean, { description: 'To delete multiple Resources' })
|
|
108
|
-
async deleteResources(
|
|
109
|
-
@Arg('ids', type => [String]) ids: string[],
|
|
110
|
-
@Ctx() context: ResolverContext
|
|
111
|
-
): Promise<boolean> {
|
|
112
|
-
const { domain, tx } = context.state
|
|
113
|
-
|
|
114
|
-
await tx.getRepository(Resource).delete({
|
|
115
|
-
id: In(ids)
|
|
116
|
-
})
|
|
117
|
-
|
|
118
|
-
await deleteAttachmentsByRef(null, { refBys: ids }, context)
|
|
119
|
-
|
|
120
|
-
return true
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
@Directive('@transaction')
|
|
124
|
-
@Mutation(returns => Boolean, { description: 'To import multiple Resources' })
|
|
125
|
-
async importResources(
|
|
126
|
-
@Arg('resources', type => [ResourcePatch]) resources: ResourcePatch[],
|
|
127
|
-
@Ctx() context: ResolverContext
|
|
128
|
-
): Promise<boolean> {
|
|
129
|
-
const { domain, tx } = context.state
|
|
130
|
-
|
|
131
|
-
await Promise.all(
|
|
132
|
-
resources.map(async (resource: ResourcePatch) => {
|
|
133
|
-
const createdResource: Resource = await tx.getRepository(Resource).save({ domain, ...resource })
|
|
134
|
-
})
|
|
135
|
-
)
|
|
136
|
-
|
|
137
|
-
return true
|
|
138
|
-
}
|
|
139
|
-
}
|
|
@@ -1,56 +0,0 @@
|
|
|
1
|
-
import { Resolver, Query, FieldResolver, Root, Args, Arg, Ctx, Directive } from 'type-graphql'
|
|
2
|
-
import { Attachment } from '@things-factory/attachment-base'
|
|
3
|
-
import { Domain, getQueryBuilderFromListParams, getRepository, ListParam } from '@things-factory/shell'
|
|
4
|
-
import { User } from '@things-factory/auth-base'
|
|
5
|
-
import { Resource } from './resource'
|
|
6
|
-
import { ResourceList } from './resource-type'
|
|
7
|
-
|
|
8
|
-
@Resolver(Resource)
|
|
9
|
-
export class ResourceQuery {
|
|
10
|
-
@Query(returns => Resource!, { nullable: true, description: 'To fetch a Resource' })
|
|
11
|
-
async resource(@Arg('id') id: string, @Ctx() context: ResolverContext): Promise<Resource> {
|
|
12
|
-
const { domain } = context.state
|
|
13
|
-
|
|
14
|
-
return await getRepository(Resource).findOne({
|
|
15
|
-
where: { id }
|
|
16
|
-
})
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
@Query(returns => ResourceList, { description: 'To fetch multiple Resources' })
|
|
20
|
-
async resources(@Args() params: ListParam, @Ctx() context: ResolverContext): Promise<ResourceList> {
|
|
21
|
-
const { domain } = context.state
|
|
22
|
-
|
|
23
|
-
const queryBuilder = getQueryBuilderFromListParams({
|
|
24
|
-
domain,
|
|
25
|
-
params,
|
|
26
|
-
repository: await getRepository(Resource),
|
|
27
|
-
searchables: ['name', 'description']
|
|
28
|
-
})
|
|
29
|
-
|
|
30
|
-
const [items, total] = await queryBuilder.getManyAndCount()
|
|
31
|
-
|
|
32
|
-
return { items, total }
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
@FieldResolver(type => String)
|
|
36
|
-
async thumbnail(@Root() resource: Resource): Promise<string | undefined> {
|
|
37
|
-
const attachment: Attachment = await getRepository(Attachment).findOne({
|
|
38
|
-
where: {
|
|
39
|
-
refType: Resource.name,
|
|
40
|
-
refBy: resource.id
|
|
41
|
-
}
|
|
42
|
-
})
|
|
43
|
-
|
|
44
|
-
return attachment?.fullpath
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
@FieldResolver(type => User)
|
|
48
|
-
async updater(@Root() resource: Resource): Promise<User> {
|
|
49
|
-
return await getRepository(User).findOneBy({ id: resource.updaterId })
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
@FieldResolver(type => User)
|
|
53
|
-
async creator(@Root() resource: Resource): Promise<User> {
|
|
54
|
-
return await getRepository(User).findOneBy({ id: resource.creatorId })
|
|
55
|
-
}
|
|
56
|
-
}
|
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
import type { FileUpload } from 'graphql-upload/GraphQLUpload.js'
|
|
2
|
-
import GraphQLUpload from 'graphql-upload/GraphQLUpload.js'
|
|
3
|
-
import { ObjectType, Field, InputType, Int, ID, registerEnumType } from 'type-graphql'
|
|
4
|
-
|
|
5
|
-
import { ObjectRef, ScalarObject } from '@things-factory/shell'
|
|
6
|
-
|
|
7
|
-
import { Resource } from './resource'
|
|
8
|
-
|
|
9
|
-
@InputType()
|
|
10
|
-
export class NewResource {
|
|
11
|
-
@Field()
|
|
12
|
-
name: string
|
|
13
|
-
|
|
14
|
-
@Field({ nullable: true })
|
|
15
|
-
description?: string
|
|
16
|
-
|
|
17
|
-
@Field({ nullable: true })
|
|
18
|
-
active?: boolean
|
|
19
|
-
|
|
20
|
-
@Field({ nullable: true })
|
|
21
|
-
params?: string
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
@InputType()
|
|
25
|
-
export class ResourcePatch {
|
|
26
|
-
@Field(type => ID, { nullable: true })
|
|
27
|
-
id?: string
|
|
28
|
-
|
|
29
|
-
@Field({ nullable: true })
|
|
30
|
-
name?: string
|
|
31
|
-
|
|
32
|
-
@Field({ nullable: true })
|
|
33
|
-
description?: string
|
|
34
|
-
|
|
35
|
-
@Field({ nullable: true })
|
|
36
|
-
active?: boolean
|
|
37
|
-
|
|
38
|
-
@Field({ nullable: true })
|
|
39
|
-
cuFlag?: string
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
@ObjectType()
|
|
43
|
-
export class ResourceList {
|
|
44
|
-
@Field(type => [Resource])
|
|
45
|
-
items: Resource[]
|
|
46
|
-
|
|
47
|
-
@Field(type => Int)
|
|
48
|
-
total: number
|
|
49
|
-
}
|