@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.
Files changed (196) hide show
  1. package/client/pages/checklist/checklist-importer.ts +6 -8
  2. package/client/pages/checklist/checklist-list-page.ts +10 -25
  3. package/client/pages/project/popup/popup-plan-upload.ts +138 -0
  4. package/client/pages/project/{project-create-popup.ts → popup/popup-project-create.ts} +2 -3
  5. package/client/pages/project/project-detail.ts +8 -7
  6. package/client/pages/project/project-list.ts +17 -10
  7. package/client/pages/project/project-plan-management.ts +117 -39
  8. package/client/pages/project/project-schedule-list.ts +2 -0
  9. package/client/pages/project/project-schedule.ts +296 -7
  10. package/client/pages/project/project-setting-list.ts +10 -6
  11. package/client/pages/project/project-update.ts +5 -2
  12. package/client/pages/resource/construction-type-management.ts +192 -0
  13. package/client/pages/resource/manager-management.ts +181 -0
  14. package/client/pages/resource/worker-type-management.ts +194 -0
  15. package/client/pages/task/task-importer.ts +6 -8
  16. package/client/pages/task/task-list-page.ts +10 -25
  17. package/client/route.ts +8 -4
  18. package/dist-client/pages/checklist/checklist-importer.d.ts +1 -0
  19. package/dist-client/pages/checklist/checklist-importer.js +3 -2
  20. package/dist-client/pages/checklist/checklist-importer.js.map +1 -1
  21. package/dist-client/pages/checklist/checklist-list-page.d.ts +1 -0
  22. package/dist-client/pages/checklist/checklist-list-page.js +8 -16
  23. package/dist-client/pages/checklist/checklist-list-page.js.map +1 -1
  24. package/dist-client/pages/project/popup/popup-plan-upload.d.ts +10 -0
  25. package/dist-client/pages/project/popup/popup-plan-upload.js +139 -0
  26. package/dist-client/pages/project/popup/popup-plan-upload.js.map +1 -0
  27. package/dist-client/pages/project/{project-create-popup.d.ts → popup/popup-project-create.d.ts} +1 -3
  28. package/dist-client/pages/project/{project-create-popup.js → popup/popup-project-create.js} +9 -10
  29. package/dist-client/pages/project/popup/popup-project-create.js.map +1 -0
  30. package/dist-client/pages/project/project-detail.d.ts +5 -4
  31. package/dist-client/pages/project/project-detail.js +7 -6
  32. package/dist-client/pages/project/project-detail.js.map +1 -1
  33. package/dist-client/pages/project/project-list.d.ts +12 -2
  34. package/dist-client/pages/project/project-list.js +11 -14
  35. package/dist-client/pages/project/project-list.js.map +1 -1
  36. package/dist-client/pages/project/project-plan-management.d.ts +9 -4
  37. package/dist-client/pages/project/project-plan-management.js +105 -35
  38. package/dist-client/pages/project/project-plan-management.js.map +1 -1
  39. package/dist-client/pages/project/project-schedule-list.d.ts +1 -0
  40. package/dist-client/pages/project/project-schedule-list.js +1 -0
  41. package/dist-client/pages/project/project-schedule-list.js.map +1 -1
  42. package/dist-client/pages/project/project-schedule.d.ts +10 -3
  43. package/dist-client/pages/project/project-schedule.js +294 -7
  44. package/dist-client/pages/project/project-schedule.js.map +1 -1
  45. package/dist-client/pages/project/project-setting-list.d.ts +3 -2
  46. package/dist-client/pages/project/project-setting-list.js +9 -6
  47. package/dist-client/pages/project/project-setting-list.js.map +1 -1
  48. package/dist-client/pages/project/project-update.d.ts +3 -2
  49. package/dist-client/pages/project/project-update.js +4 -2
  50. package/dist-client/pages/project/project-update.js.map +1 -1
  51. package/dist-client/pages/resource/construction-type-management.d.ts +27 -0
  52. package/dist-client/pages/resource/construction-type-management.js +189 -0
  53. package/dist-client/pages/resource/construction-type-management.js.map +1 -0
  54. package/dist-client/pages/resource/manager-management.d.ts +31 -0
  55. package/dist-client/pages/resource/manager-management.js +175 -0
  56. package/dist-client/pages/resource/manager-management.js.map +1 -0
  57. package/dist-client/pages/resource/worker-type-management.d.ts +27 -0
  58. package/dist-client/pages/resource/worker-type-management.js +191 -0
  59. package/dist-client/pages/resource/worker-type-management.js.map +1 -0
  60. package/dist-client/pages/task/task-importer.d.ts +1 -0
  61. package/dist-client/pages/task/task-importer.js +3 -2
  62. package/dist-client/pages/task/task-importer.js.map +1 -1
  63. package/dist-client/pages/task/task-list-page.d.ts +1 -0
  64. package/dist-client/pages/task/task-list-page.js +8 -16
  65. package/dist-client/pages/task/task-list-page.js.map +1 -1
  66. package/dist-client/route.d.ts +1 -1
  67. package/dist-client/route.js +7 -4
  68. package/dist-client/route.js.map +1 -1
  69. package/dist-client/tsconfig.tsbuildinfo +1 -1
  70. package/dist-server/controllers/index.d.ts +0 -0
  71. package/dist-server/controllers/project-to-excel.d.ts +7 -0
  72. package/dist-server/index.d.ts +2 -0
  73. package/dist-server/middlewares/index.d.ts +1 -0
  74. package/dist-server/routes.d.ts +1 -0
  75. package/dist-server/service/check-item/check-item-mutation.d.ts +10 -0
  76. package/dist-server/service/check-item/check-item-query.d.ts +11 -0
  77. package/dist-server/service/check-item/check-item-type.d.ts +18 -0
  78. package/dist-server/service/check-item/check-item.d.ts +18 -0
  79. package/dist-server/service/check-item/index.d.ts +5 -0
  80. package/dist-server/service/checklist/checklist-mutation.d.ts +10 -0
  81. package/dist-server/service/checklist/checklist-query.d.ts +11 -0
  82. package/dist-server/service/checklist/checklist-type.d.ts +18 -0
  83. package/dist-server/service/checklist/checklist.d.ts +26 -0
  84. package/dist-server/service/checklist/index.d.ts +5 -0
  85. package/dist-server/service/construction-type/construction-type-mutation.d.ts +6 -0
  86. package/dist-server/service/construction-type/construction-type-mutation.js +64 -0
  87. package/dist-server/service/construction-type/construction-type-mutation.js.map +1 -0
  88. package/dist-server/service/construction-type/construction-type-query.d.ts +11 -0
  89. package/dist-server/service/construction-type/construction-type-query.js +78 -0
  90. package/dist-server/service/construction-type/construction-type-query.js.map +1 -0
  91. package/dist-server/service/construction-type/construction-type-type.d.ts +11 -0
  92. package/dist-server/service/construction-type/construction-type-type.js +43 -0
  93. package/dist-server/service/construction-type/construction-type-type.js.map +1 -0
  94. package/dist-server/service/construction-type/construction-type.d.ts +16 -0
  95. package/dist-server/service/construction-type/construction-type.js +77 -0
  96. package/dist-server/service/construction-type/construction-type.js.map +1 -0
  97. package/dist-server/service/construction-type/index.d.ts +5 -0
  98. package/dist-server/service/construction-type/index.js +9 -0
  99. package/dist-server/service/construction-type/index.js.map +1 -0
  100. package/dist-server/service/index.d.ts +12 -0
  101. package/dist-server/service/index.js +12 -4
  102. package/dist-server/service/index.js.map +1 -1
  103. package/dist-server/service/manager/index.d.ts +5 -0
  104. package/dist-server/service/manager/index.js +9 -0
  105. package/dist-server/service/manager/index.js.map +1 -0
  106. package/dist-server/service/manager/manager-mutation.d.ts +5 -0
  107. package/dist-server/service/manager/manager-mutation.js +39 -0
  108. package/dist-server/service/manager/manager-mutation.js.map +1 -0
  109. package/dist-server/service/manager/manager-query.d.ts +4 -0
  110. package/dist-server/service/manager/manager-query.js +39 -0
  111. package/dist-server/service/manager/manager-query.js.map +1 -0
  112. package/dist-server/service/manager/manager-type.d.ts +15 -0
  113. package/dist-server/service/manager/manager-type.js +62 -0
  114. package/dist-server/service/manager/manager-type.js.map +1 -0
  115. package/dist-server/service/manager/manager.d.ts +8 -0
  116. package/dist-server/service/manager/manager.js +41 -0
  117. package/dist-server/service/manager/manager.js.map +1 -0
  118. package/dist-server/service/project/index.d.ts +7 -0
  119. package/dist-server/service/project/project-mutation.d.ts +9 -0
  120. package/dist-server/service/project/project-mutation.js +61 -55
  121. package/dist-server/service/project/project-mutation.js.map +1 -1
  122. package/dist-server/service/project/project-query.d.ts +16 -0
  123. package/dist-server/service/project/project-query.js +3 -3
  124. package/dist-server/service/project/project-query.js.map +1 -1
  125. package/dist-server/service/project/project-type.d.ts +29 -0
  126. package/dist-server/service/project/project-type.js +1 -2
  127. package/dist-server/service/project/project-type.js.map +1 -1
  128. package/dist-server/service/project/project.d.ts +35 -0
  129. package/dist-server/service/project/project.js +1 -2
  130. package/dist-server/service/project/project.js.map +1 -1
  131. package/dist-server/service/task/index.d.ts +5 -0
  132. package/dist-server/service/task/task-mutation.d.ts +10 -0
  133. package/dist-server/service/task/task-query.d.ts +11 -0
  134. package/dist-server/service/task/task-type.d.ts +18 -0
  135. package/dist-server/service/task/task.d.ts +25 -0
  136. package/dist-server/service/worker-type/index.d.ts +5 -0
  137. package/dist-server/service/worker-type/index.js +9 -0
  138. package/dist-server/service/worker-type/index.js.map +1 -0
  139. package/dist-server/service/worker-type/worker-type-mutation.d.ts +6 -0
  140. package/dist-server/service/worker-type/worker-type-mutation.js +64 -0
  141. package/dist-server/service/worker-type/worker-type-mutation.js.map +1 -0
  142. package/dist-server/service/worker-type/worker-type-query.d.ts +11 -0
  143. package/dist-server/service/{resource/resource-query.js → worker-type/worker-type-query.js} +31 -39
  144. package/dist-server/service/worker-type/worker-type-query.js.map +1 -0
  145. package/dist-server/service/worker-type/worker-type-type.d.ts +11 -0
  146. package/dist-server/service/worker-type/worker-type-type.js +43 -0
  147. package/dist-server/service/worker-type/worker-type-type.js.map +1 -0
  148. package/dist-server/service/worker-type/worker-type.d.ts +16 -0
  149. package/dist-server/service/{resource/resource.js → worker-type/worker-type.js} +35 -20
  150. package/dist-server/service/worker-type/worker-type.js.map +1 -0
  151. package/dist-server/tsconfig.tsbuildinfo +1 -1
  152. package/package.json +3 -3
  153. package/server/service/construction-type/construction-type-mutation.ts +66 -0
  154. package/server/service/construction-type/construction-type-query.ts +47 -0
  155. package/server/service/construction-type/construction-type-type.ts +26 -0
  156. package/server/service/{resource/resource.ts → construction-type/construction-type.ts} +18 -6
  157. package/server/service/construction-type/index.ts +6 -0
  158. package/server/service/index.ts +12 -4
  159. package/server/service/manager/index.ts +6 -0
  160. package/server/service/manager/manager-mutation.ts +42 -0
  161. package/server/service/manager/manager-query.ts +28 -0
  162. package/server/service/manager/manager-type.ts +40 -0
  163. package/server/service/manager/manager.ts +29 -0
  164. package/server/service/project/project-mutation.ts +101 -79
  165. package/server/service/project/project-query.ts +4 -4
  166. package/server/service/worker-type/index.ts +6 -0
  167. package/server/service/worker-type/worker-type-mutation.ts +66 -0
  168. package/server/service/worker-type/worker-type-query.ts +47 -0
  169. package/server/service/worker-type/worker-type-type.ts +26 -0
  170. package/server/service/worker-type/worker-type.ts +68 -0
  171. package/things-factory.config.js +3 -0
  172. package/client/pages/project/ox-progress-circle.ts +0 -133
  173. package/client/pages/resource/resource-importer.ts +0 -96
  174. package/client/pages/resource/resource-list-page.ts +0 -355
  175. package/dist-client/pages/project/ox-progress-circle.d.ts +0 -41
  176. package/dist-client/pages/project/ox-progress-circle.js +0 -182
  177. package/dist-client/pages/project/ox-progress-circle.js.map +0 -1
  178. package/dist-client/pages/project/project-create-popup.js.map +0 -1
  179. package/dist-client/pages/resource/resource-importer.d.ts +0 -9
  180. package/dist-client/pages/resource/resource-importer.js +0 -100
  181. package/dist-client/pages/resource/resource-importer.js.map +0 -1
  182. package/dist-client/pages/resource/resource-list-page.d.ts +0 -62
  183. package/dist-client/pages/resource/resource-list-page.js +0 -331
  184. package/dist-client/pages/resource/resource-list-page.js.map +0 -1
  185. package/dist-server/service/resource/index.js +0 -9
  186. package/dist-server/service/resource/index.js.map +0 -1
  187. package/dist-server/service/resource/resource-mutation.js +0 -129
  188. package/dist-server/service/resource/resource-mutation.js.map +0 -1
  189. package/dist-server/service/resource/resource-query.js.map +0 -1
  190. package/dist-server/service/resource/resource-type.js +0 -69
  191. package/dist-server/service/resource/resource-type.js.map +0 -1
  192. package/dist-server/service/resource/resource.js.map +0 -1
  193. package/server/service/resource/index.ts +0 -6
  194. package/server/service/resource/resource-mutation.ts +0 -139
  195. package/server/service/resource/resource-query.ts +0 -56
  196. 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,EA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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,q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, 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,6 +0,0 @@
1
- import { Resource } from './resource'
2
- import { ResourceQuery } from './resource-query'
3
- import { ResourceMutation } from './resource-mutation'
4
-
5
- export const entities = [Resource]
6
- export const resolvers = [ResourceQuery, ResourceMutation]
@@ -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
- }