@dssp/project 0.0.2
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/CHANGELOG.md +8 -0
- package/assets/images/hatiolab-logo.png +0 -0
- package/assets/images/o-mark.png +0 -0
- package/assets/images/x-mark.png +0 -0
- package/client/bootstrap.ts +0 -0
- package/client/index.ts +0 -0
- package/client/pages/checklist/checklist-importer.ts +96 -0
- package/client/pages/checklist/checklist-list-page.ts +355 -0
- package/client/pages/lib/waether.ts +159 -0
- package/client/pages/project/ox-progress-circle.ts +133 -0
- package/client/pages/project/project-create-popup.ts +148 -0
- package/client/pages/project/project-detail.ts +618 -0
- package/client/pages/project/project-list.ts +354 -0
- package/client/pages/project/project-plan-management.ts +437 -0
- package/client/pages/project/project-schedule-list.ts +280 -0
- package/client/pages/project/project-schedule.ts +248 -0
- package/client/pages/project/project-setting-list.ts +298 -0
- package/client/pages/project/project-update.ts +797 -0
- package/client/pages/resource/resource-importer.ts +96 -0
- package/client/pages/resource/resource-list-page.ts +355 -0
- package/client/pages/task/task-importer.ts +96 -0
- package/client/pages/task/task-list-page.ts +355 -0
- package/client/route.ts +39 -0
- package/client/tsconfig.json +11 -0
- package/dist-client/bootstrap.d.ts +0 -0
- package/dist-client/bootstrap.js +2 -0
- package/dist-client/bootstrap.js.map +1 -0
- package/dist-client/index.d.ts +0 -0
- package/dist-client/index.js +2 -0
- package/dist-client/index.js.map +1 -0
- package/dist-client/pages/checklist/checklist-importer.d.ts +9 -0
- package/dist-client/pages/checklist/checklist-importer.js +100 -0
- package/dist-client/pages/checklist/checklist-importer.js.map +1 -0
- package/dist-client/pages/checklist/checklist-list-page.d.ts +62 -0
- package/dist-client/pages/checklist/checklist-list-page.js +331 -0
- package/dist-client/pages/checklist/checklist-list-page.js.map +1 -0
- package/dist-client/pages/lib/waether.d.ts +6 -0
- package/dist-client/pages/lib/waether.js +152 -0
- package/dist-client/pages/lib/waether.js.map +1 -0
- package/dist-client/pages/project/ox-progress-circle.d.ts +41 -0
- package/dist-client/pages/project/ox-progress-circle.js +182 -0
- package/dist-client/pages/project/ox-progress-circle.js.map +1 -0
- package/dist-client/pages/project/project-create-popup.d.ts +14 -0
- package/dist-client/pages/project/project-create-popup.js +153 -0
- package/dist-client/pages/project/project-create-popup.js.map +1 -0
- package/dist-client/pages/project/project-detail.d.ts +35 -0
- package/dist-client/pages/project/project-detail.js +617 -0
- package/dist-client/pages/project/project-detail.js.map +1 -0
- package/dist-client/pages/project/project-list.d.ts +88 -0
- package/dist-client/pages/project/project-list.js +303 -0
- package/dist-client/pages/project/project-list.js.map +1 -0
- package/dist-client/pages/project/project-plan-management.d.ts +27 -0
- package/dist-client/pages/project/project-plan-management.js +438 -0
- package/dist-client/pages/project/project-plan-management.js.map +1 -0
- package/dist-client/pages/project/project-schedule-list.d.ts +18 -0
- package/dist-client/pages/project/project-schedule-list.js +292 -0
- package/dist-client/pages/project/project-schedule-list.js.map +1 -0
- package/dist-client/pages/project/project-schedule.d.ts +23 -0
- package/dist-client/pages/project/project-schedule.js +256 -0
- package/dist-client/pages/project/project-schedule.js.map +1 -0
- package/dist-client/pages/project/project-setting-list.d.ts +23 -0
- package/dist-client/pages/project/project-setting-list.js +307 -0
- package/dist-client/pages/project/project-setting-list.js.map +1 -0
- package/dist-client/pages/project/project-update.d.ts +24 -0
- package/dist-client/pages/project/project-update.js +797 -0
- package/dist-client/pages/project/project-update.js.map +1 -0
- package/dist-client/pages/resource/resource-importer.d.ts +9 -0
- package/dist-client/pages/resource/resource-importer.js +100 -0
- package/dist-client/pages/resource/resource-importer.js.map +1 -0
- package/dist-client/pages/resource/resource-list-page.d.ts +62 -0
- package/dist-client/pages/resource/resource-list-page.js +331 -0
- package/dist-client/pages/resource/resource-list-page.js.map +1 -0
- package/dist-client/pages/task/task-importer.d.ts +9 -0
- package/dist-client/pages/task/task-importer.js +100 -0
- package/dist-client/pages/task/task-importer.js.map +1 -0
- package/dist-client/pages/task/task-list-page.d.ts +62 -0
- package/dist-client/pages/task/task-list-page.js +331 -0
- package/dist-client/pages/task/task-list-page.js.map +1 -0
- package/dist-client/route.d.ts +1 -0
- package/dist-client/route.js +32 -0
- package/dist-client/route.js.map +1 -0
- package/dist-client/tsconfig.tsbuildinfo +1 -0
- package/dist-server/controllers/index.js +1 -0
- package/dist-server/controllers/index.js.map +1 -0
- package/dist-server/controllers/project-to-excel.js +30 -0
- package/dist-server/controllers/project-to-excel.js.map +1 -0
- package/dist-server/index.js +6 -0
- package/dist-server/index.js.map +1 -0
- package/dist-server/middlewares/index.js +8 -0
- package/dist-server/middlewares/index.js.map +1 -0
- package/dist-server/routes.js +105 -0
- package/dist-server/routes.js.map +1 -0
- package/dist-server/service/check-item/check-item-mutation.js +129 -0
- package/dist-server/service/check-item/check-item-mutation.js.map +1 -0
- package/dist-server/service/check-item/check-item-query.js +86 -0
- package/dist-server/service/check-item/check-item-query.js.map +1 -0
- package/dist-server/service/check-item/check-item-type.js +69 -0
- package/dist-server/service/check-item/check-item-type.js.map +1 -0
- package/dist-server/service/check-item/check-item.js +84 -0
- package/dist-server/service/check-item/check-item.js.map +1 -0
- package/dist-server/service/check-item/index.js +9 -0
- package/dist-server/service/check-item/index.js.map +1 -0
- package/dist-server/service/checklist/checklist-mutation.js +129 -0
- package/dist-server/service/checklist/checklist-mutation.js.map +1 -0
- package/dist-server/service/checklist/checklist-query.js +86 -0
- package/dist-server/service/checklist/checklist-query.js.map +1 -0
- package/dist-server/service/checklist/checklist-type.js +69 -0
- package/dist-server/service/checklist/checklist-type.js.map +1 -0
- package/dist-server/service/checklist/checklist.js +120 -0
- package/dist-server/service/checklist/checklist.js.map +1 -0
- package/dist-server/service/checklist/index.js +9 -0
- package/dist-server/service/checklist/index.js.map +1 -0
- package/dist-server/service/index.js +36 -0
- package/dist-server/service/index.js.map +1 -0
- package/dist-server/service/project/index.js +11 -0
- package/dist-server/service/project/index.js.map +1 -0
- package/dist-server/service/project/project-mutation.js +190 -0
- package/dist-server/service/project/project-mutation.js.map +1 -0
- package/dist-server/service/project/project-query.js +143 -0
- package/dist-server/service/project/project-query.js.map +1 -0
- package/dist-server/service/project/project-type.js +106 -0
- package/dist-server/service/project/project-type.js.map +1 -0
- package/dist-server/service/project/project.js +146 -0
- package/dist-server/service/project/project.js.map +1 -0
- package/dist-server/service/resource/index.js +9 -0
- package/dist-server/service/resource/index.js.map +1 -0
- package/dist-server/service/resource/resource-mutation.js +129 -0
- package/dist-server/service/resource/resource-mutation.js.map +1 -0
- package/dist-server/service/resource/resource-query.js +86 -0
- package/dist-server/service/resource/resource-query.js.map +1 -0
- package/dist-server/service/resource/resource-type.js +69 -0
- package/dist-server/service/resource/resource-type.js.map +1 -0
- package/dist-server/service/resource/resource.js +62 -0
- package/dist-server/service/resource/resource.js.map +1 -0
- package/dist-server/service/task/index.js +9 -0
- package/dist-server/service/task/index.js.map +1 -0
- package/dist-server/service/task/task-mutation.js +129 -0
- package/dist-server/service/task/task-mutation.js.map +1 -0
- package/dist-server/service/task/task-query.js +86 -0
- package/dist-server/service/task/task-query.js.map +1 -0
- package/dist-server/service/task/task-type.js +69 -0
- package/dist-server/service/task/task-type.js.map +1 -0
- package/dist-server/service/task/task.js +106 -0
- package/dist-server/service/task/task.js.map +1 -0
- package/dist-server/tsconfig.tsbuildinfo +1 -0
- package/helps/management/alarm.md +160 -0
- package/helps/management/alter-video.md +160 -0
- package/helps/management/cctv.md +160 -0
- package/helps/management/device.md +160 -0
- package/helps/management/parking.md +160 -0
- package/helps/management/site.md +160 -0
- package/helps/management/sun-pnl.md +160 -0
- package/helps/project/checklist.md +160 -0
- package/helps/project/project.md +160 -0
- package/helps/project/resource.md +160 -0
- package/helps/project/task.md +160 -0
- package/package.json +38 -0
- package/server/controllers/index.ts +0 -0
- package/server/controllers/project-to-excel.ts +40 -0
- package/server/index.ts +3 -0
- package/server/middlewares/index.ts +3 -0
- package/server/routes.ts +108 -0
- package/server/service/check-item/check-item-mutation.ts +142 -0
- package/server/service/check-item/check-item-query.ts +56 -0
- package/server/service/check-item/check-item-type.ts +49 -0
- package/server/service/check-item/check-item.ts +74 -0
- package/server/service/check-item/index.ts +6 -0
- package/server/service/checklist/checklist-mutation.ts +142 -0
- package/server/service/checklist/checklist-query.ts +56 -0
- package/server/service/checklist/checklist-type.ts +49 -0
- package/server/service/checklist/checklist.ts +105 -0
- package/server/service/checklist/index.ts +6 -0
- package/server/service/index.ts +35 -0
- package/server/service/project/index.ts +8 -0
- package/server/service/project/project-mutation.ts +201 -0
- package/server/service/project/project-query.ts +103 -0
- package/server/service/project/project-type.ts +71 -0
- package/server/service/project/project.ts +131 -0
- package/server/service/resource/index.ts +6 -0
- package/server/service/resource/resource-mutation.ts +139 -0
- package/server/service/resource/resource-query.ts +56 -0
- package/server/service/resource/resource-type.ts +49 -0
- package/server/service/resource/resource.ts +56 -0
- package/server/service/task/index.ts +6 -0
- package/server/service/task/task-mutation.ts +136 -0
- package/server/service/task/task-query.ts +56 -0
- package/server/service/task/task-type.ts +49 -0
- package/server/service/task/task.ts +97 -0
- package/server/tsconfig.json +10 -0
- package/things-factory.config.js +20 -0
- package/translations/en.json +1 -0
- package/translations/ja.json +1 -0
- package/translations/ko.json +9 -0
- package/translations/ms.json +1 -0
- package/translations/zh.json +1 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"project.js","sourceRoot":"","sources":["../../../server/service/project/project.ts"],"names":[],"mappings":";;;;;AAAA,qCAagB;AAChB,+CAAsE;AAEtE,iDAAgE;AAChE,yDAAgD;AAChD,uCAAmC;AACnC,6DAAwD;AACxD,qEAA4D;AAE5D,IAAY,aAGX;AAHD,WAAY,aAAa;IACvB,kCAAmB,CAAA;IACnB,mCAAoB,CAAA;AACtB,CAAC,EAHW,aAAa,GAAb,qBAAa,KAAb,qBAAa,QAGxB;AAED,IAAA,+BAAgB,EAAC,aAAa,EAAE;IAC9B,IAAI,EAAE,eAAe;IACrB,WAAW,EAAE,SAAS;CACvB,CAAC,CAAA;AAKK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EAAC,IAAI,CAAC,EAAE,CAAC,gBAAI,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;sCAC9B,gBAAI;wCAAA;AAEd;IAAC,IAAA,oBAAU,EAAC,CAAC,OAAgB,EAAE,EAAE,CAAC,OAAO,CAAC,OAAO,CAAC;;0CAChC;AAElB;IAAC,IAAA,mBAAS,EAAC,IAAI,CAAC,EAAE,CAAC,gBAAI,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;IAC3C,IAAA,oBAAK,EAAC,IAAI,CAAC,EAAE,CAAC,gBAAI,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;sCAC9B,gBAAI;wCAAA;AAEd;IAAC,IAAA,oBAAU,EAAC,CAAC,OAAgB,EAAE,EAAE,CAAC,OAAO,CAAC,OAAO,CAAC;;0CAChC;AA9FP,OAAO;IAHnB,IAAA,gBAAM,GAAE;IACR,IAAA,eAAK,EAAC,cAAc,EAAE,CAAC,OAAgB,EAAE,EAAE,CAAC,CAAC,OAAO,CAAC,eAAe,CAAC,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,KAAK,EAAE,sBAAsB,EAAE,CAAC;IACvH,IAAA,yBAAU,EAAC,EAAE,WAAW,EAAE,MAAM,EAAE,CAAC;GACvB,OAAO,CA+FnB;AA/FY,0BAAO","sourcesContent":["import {\n CreateDateColumn,\n UpdateDateColumn,\n DeleteDateColumn,\n Entity,\n Index,\n Column,\n RelationId,\n ManyToOne,\n OneToOne,\n OneToMany,\n JoinColumn,\n PrimaryGeneratedColumn\n} from 'typeorm'\nimport { ObjectType, Field, ID, registerEnumType } from 'type-graphql'\n\nimport { Domain, roundTransformer } from '@things-factory/shell'\nimport { User } from '@things-factory/auth-base'\nimport { Task } from '../task/task'\nimport { BuildingComplex } from '@dssp/building-complex'\nimport { Attachment } from '@things-factory/attachment-base'\n\nexport enum ProjectStatus {\n 'PROCEEDING' = '10',\n 'COMPLICATED' = '20'\n}\n\nregisterEnumType(ProjectStatus, {\n name: 'ProjectStatus',\n description: '프로젝트 상태'\n})\n\n@Entity()\n@Index('ix_project_0', (project: Project) => [project.buildingComplex], { unique: true, where: '\"deleted_at\" IS NULL' })\n@ObjectType({ description: '프로젝트' })\nexport class Project {\n @PrimaryGeneratedColumn('uuid')\n @Field(type => ID)\n readonly id: string\n\n @ManyToOne(type => Domain)\n @Field({ nullable: true })\n domain?: Domain\n\n @RelationId((project: Project) => project.domain)\n domainId?: string\n\n @Column({ nullable: false, comment: '프로젝트 이름' })\n @Field({ nullable: false })\n name?: string\n\n @Column({ nullable: false, default: ProjectStatus.PROCEEDING, comment: '프로젝트 상태 (10: 진행중, 20: 완료)' })\n @Field({ nullable: false })\n state?: ProjectStatus\n\n @Column({ type: 'date', nullable: true, comment: '착공일정' })\n @Field({ nullable: true })\n startDate?: string\n\n @Column({ type: 'date', nullable: true, comment: '준공일정' })\n @Field({ nullable: true })\n endDate?: string\n\n // 대표 사진\n @Field(type => Attachment, { nullable: true })\n mainPhoto?: Attachment\n\n @Column({ type: 'float', nullable: true, default: 0, transformer: roundTransformer, comment: '전체 진행현황' })\n @Field({ nullable: true })\n totalProgress?: number\n\n @Column({ type: 'float', nullable: true, default: 0, transformer: roundTransformer, comment: '주간 진행현황' })\n @Field({ nullable: true })\n weeklyProgress?: number\n\n @Column({ type: 'float', nullable: true, default: 0, transformer: roundTransformer, comment: 'KPI' })\n @Field({ nullable: true })\n kpi?: number\n\n @Column({ type: 'float', nullable: true, default: 0, transformer: roundTransformer, comment: '검측/통과 비율' })\n @Field({ nullable: true })\n inspPassRate?: number\n\n @Column({ type: 'float', nullable: true, default: 0, transformer: roundTransformer, comment: '로봇 작업 진행율' })\n @Field({ nullable: true })\n robotProgressRate?: number\n\n @Column({ type: 'float', nullable: true, default: 0, transformer: roundTransformer, comment: '구조 안전도' })\n @Field({ nullable: true })\n structuralSafetyRate?: number\n\n // 단지 정보 (1:1 테이블 참조)\n @OneToOne(type => BuildingComplex)\n @JoinColumn()\n @Field({ nullable: true })\n buildingComplex?: BuildingComplex\n\n @RelationId((project: Project) => project.buildingComplex)\n buildingComplexId?: string\n\n // 작업 정보 (하위 테이블 참조)\n @Field(() => [Task], { nullable: true })\n @OneToMany(() => Task, task => task.project)\n tasks?: Task[]\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((project: Project) => project.creator)\n creatorId?: string\n\n @ManyToOne(type => User, { nullable: true })\n @Field(type => User, { nullable: true })\n updater?: User\n\n @RelationId((project: Project) => project.updater)\n updaterId?: string\n}\n"]}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.resolvers = exports.entities = void 0;
|
|
4
|
+
const resource_1 = require("./resource");
|
|
5
|
+
const resource_query_1 = require("./resource-query");
|
|
6
|
+
const resource_mutation_1 = require("./resource-mutation");
|
|
7
|
+
exports.entities = [resource_1.Resource];
|
|
8
|
+
exports.resolvers = [resource_query_1.ResourceQuery, resource_mutation_1.ResourceMutation];
|
|
9
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../server/service/resource/index.ts"],"names":[],"mappings":";;;AAAA,yCAAqC;AACrC,qDAAgD;AAChD,2DAAsD;AAEzC,QAAA,QAAQ,GAAG,CAAC,mBAAQ,CAAC,CAAA;AACrB,QAAA,SAAS,GAAG,CAAC,8BAAa,EAAE,oCAAgB,CAAC,CAAA","sourcesContent":["import { Resource } from './resource'\nimport { ResourceQuery } from './resource-query'\nimport { ResourceMutation } from './resource-mutation'\n\nexport const entities = [Resource]\nexport const resolvers = [ResourceQuery, ResourceMutation]\n"]}
|
|
@@ -0,0 +1,129 @@
|
|
|
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
|
|
@@ -0,0 +1 @@
|
|
|
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AC,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"]}
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ResourceQuery = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const type_graphql_1 = require("type-graphql");
|
|
6
|
+
const attachment_base_1 = require("@things-factory/attachment-base");
|
|
7
|
+
const shell_1 = require("@things-factory/shell");
|
|
8
|
+
const auth_base_1 = require("@things-factory/auth-base");
|
|
9
|
+
const resource_1 = require("./resource");
|
|
10
|
+
const resource_type_1 = require("./resource-type");
|
|
11
|
+
let ResourceQuery = class ResourceQuery {
|
|
12
|
+
async resource(id, context) {
|
|
13
|
+
const { domain } = context.state;
|
|
14
|
+
return await (0, shell_1.getRepository)(resource_1.Resource).findOne({
|
|
15
|
+
where: { id }
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
async resources(params, context) {
|
|
19
|
+
const { domain } = context.state;
|
|
20
|
+
const queryBuilder = (0, shell_1.getQueryBuilderFromListParams)({
|
|
21
|
+
domain,
|
|
22
|
+
params,
|
|
23
|
+
repository: await (0, shell_1.getRepository)(resource_1.Resource),
|
|
24
|
+
searchables: ['name', 'description']
|
|
25
|
+
});
|
|
26
|
+
const [items, total] = await queryBuilder.getManyAndCount();
|
|
27
|
+
return { items, total };
|
|
28
|
+
}
|
|
29
|
+
async thumbnail(resource) {
|
|
30
|
+
const attachment = await (0, shell_1.getRepository)(attachment_base_1.Attachment).findOne({
|
|
31
|
+
where: {
|
|
32
|
+
refType: resource_1.Resource.name,
|
|
33
|
+
refBy: resource.id
|
|
34
|
+
}
|
|
35
|
+
});
|
|
36
|
+
return attachment === null || attachment === void 0 ? void 0 : attachment.fullpath;
|
|
37
|
+
}
|
|
38
|
+
async updater(resource) {
|
|
39
|
+
return await (0, shell_1.getRepository)(auth_base_1.User).findOneBy({ id: resource.updaterId });
|
|
40
|
+
}
|
|
41
|
+
async creator(resource) {
|
|
42
|
+
return await (0, shell_1.getRepository)(auth_base_1.User).findOneBy({ id: resource.creatorId });
|
|
43
|
+
}
|
|
44
|
+
};
|
|
45
|
+
tslib_1.__decorate([
|
|
46
|
+
(0, type_graphql_1.Query)(returns => resource_1.Resource, { nullable: true, description: 'To fetch a Resource' }),
|
|
47
|
+
tslib_1.__param(0, (0, type_graphql_1.Arg)('id')),
|
|
48
|
+
tslib_1.__param(1, (0, type_graphql_1.Ctx)()),
|
|
49
|
+
tslib_1.__metadata("design:type", Function),
|
|
50
|
+
tslib_1.__metadata("design:paramtypes", [String, Object]),
|
|
51
|
+
tslib_1.__metadata("design:returntype", Promise)
|
|
52
|
+
], ResourceQuery.prototype, "resource", null);
|
|
53
|
+
tslib_1.__decorate([
|
|
54
|
+
(0, type_graphql_1.Query)(returns => resource_type_1.ResourceList, { description: 'To fetch multiple Resources' }),
|
|
55
|
+
tslib_1.__param(0, (0, type_graphql_1.Args)()),
|
|
56
|
+
tslib_1.__param(1, (0, type_graphql_1.Ctx)()),
|
|
57
|
+
tslib_1.__metadata("design:type", Function),
|
|
58
|
+
tslib_1.__metadata("design:paramtypes", [shell_1.ListParam, Object]),
|
|
59
|
+
tslib_1.__metadata("design:returntype", Promise)
|
|
60
|
+
], ResourceQuery.prototype, "resources", null);
|
|
61
|
+
tslib_1.__decorate([
|
|
62
|
+
(0, type_graphql_1.FieldResolver)(type => String),
|
|
63
|
+
tslib_1.__param(0, (0, type_graphql_1.Root)()),
|
|
64
|
+
tslib_1.__metadata("design:type", Function),
|
|
65
|
+
tslib_1.__metadata("design:paramtypes", [resource_1.Resource]),
|
|
66
|
+
tslib_1.__metadata("design:returntype", Promise)
|
|
67
|
+
], ResourceQuery.prototype, "thumbnail", null);
|
|
68
|
+
tslib_1.__decorate([
|
|
69
|
+
(0, type_graphql_1.FieldResolver)(type => auth_base_1.User),
|
|
70
|
+
tslib_1.__param(0, (0, type_graphql_1.Root)()),
|
|
71
|
+
tslib_1.__metadata("design:type", Function),
|
|
72
|
+
tslib_1.__metadata("design:paramtypes", [resource_1.Resource]),
|
|
73
|
+
tslib_1.__metadata("design:returntype", Promise)
|
|
74
|
+
], ResourceQuery.prototype, "updater", null);
|
|
75
|
+
tslib_1.__decorate([
|
|
76
|
+
(0, type_graphql_1.FieldResolver)(type => auth_base_1.User),
|
|
77
|
+
tslib_1.__param(0, (0, type_graphql_1.Root)()),
|
|
78
|
+
tslib_1.__metadata("design:type", Function),
|
|
79
|
+
tslib_1.__metadata("design:paramtypes", [resource_1.Resource]),
|
|
80
|
+
tslib_1.__metadata("design:returntype", Promise)
|
|
81
|
+
], ResourceQuery.prototype, "creator", null);
|
|
82
|
+
ResourceQuery = tslib_1.__decorate([
|
|
83
|
+
(0, type_graphql_1.Resolver)(resource_1.Resource)
|
|
84
|
+
], ResourceQuery);
|
|
85
|
+
exports.ResourceQuery = ResourceQuery;
|
|
86
|
+
//# sourceMappingURL=resource-query.js.map
|
|
@@ -0,0 +1 @@
|
|
|
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,C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,qBAAqB,EAAE,CAAC;IACpE,mBAAA,IAAA,kBAAG,EAAC,IAAI,CAAC,CAAA;IAAc,mBAAA,IAAA,kBAAG,GAAE,CAAA;;;;6CAM3C;AAGK;IADL,IAAA,oBAAK,EAAC,OAAO,CAAC,EAAE,CAAC,4BAAY,EAAE,EAAE,WAAW,EAAE,6BAA6B,EAAE,CAAC;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"]}
|
|
@@ -0,0 +1,69 @@
|
|
|
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
|
|
@@ -0,0 +1 @@
|
|
|
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"]}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Resource = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const typeorm_1 = require("typeorm");
|
|
6
|
+
const type_graphql_1 = require("type-graphql");
|
|
7
|
+
const auth_base_1 = require("@things-factory/auth-base");
|
|
8
|
+
let Resource = class Resource {
|
|
9
|
+
};
|
|
10
|
+
tslib_1.__decorate([
|
|
11
|
+
(0, typeorm_1.PrimaryGeneratedColumn)('uuid'),
|
|
12
|
+
(0, type_graphql_1.Field)(type => type_graphql_1.ID),
|
|
13
|
+
tslib_1.__metadata("design:type", String)
|
|
14
|
+
], Resource.prototype, "id", void 0);
|
|
15
|
+
tslib_1.__decorate([
|
|
16
|
+
(0, typeorm_1.Column)({ nullable: true, comment: '직군' }),
|
|
17
|
+
(0, type_graphql_1.Field)({ nullable: true }),
|
|
18
|
+
tslib_1.__metadata("design:type", String)
|
|
19
|
+
], Resource.prototype, "name", void 0);
|
|
20
|
+
tslib_1.__decorate([
|
|
21
|
+
(0, typeorm_1.CreateDateColumn)(),
|
|
22
|
+
(0, type_graphql_1.Field)({ nullable: true }),
|
|
23
|
+
tslib_1.__metadata("design:type", Date)
|
|
24
|
+
], Resource.prototype, "createdAt", void 0);
|
|
25
|
+
tslib_1.__decorate([
|
|
26
|
+
(0, typeorm_1.UpdateDateColumn)(),
|
|
27
|
+
(0, type_graphql_1.Field)({ nullable: true }),
|
|
28
|
+
tslib_1.__metadata("design:type", Date)
|
|
29
|
+
], Resource.prototype, "updatedAt", void 0);
|
|
30
|
+
tslib_1.__decorate([
|
|
31
|
+
(0, typeorm_1.DeleteDateColumn)(),
|
|
32
|
+
(0, type_graphql_1.Field)({ nullable: true }),
|
|
33
|
+
tslib_1.__metadata("design:type", Date)
|
|
34
|
+
], Resource.prototype, "deletedAt", void 0);
|
|
35
|
+
tslib_1.__decorate([
|
|
36
|
+
(0, typeorm_1.ManyToOne)(type => auth_base_1.User, { nullable: true }),
|
|
37
|
+
(0, type_graphql_1.Field)(type => auth_base_1.User, { nullable: true }),
|
|
38
|
+
tslib_1.__metadata("design:type", auth_base_1.User)
|
|
39
|
+
], Resource.prototype, "creator", void 0);
|
|
40
|
+
tslib_1.__decorate([
|
|
41
|
+
(0, typeorm_1.RelationId)((resource) => resource.creator),
|
|
42
|
+
tslib_1.__metadata("design:type", String)
|
|
43
|
+
], Resource.prototype, "creatorId", void 0);
|
|
44
|
+
tslib_1.__decorate([
|
|
45
|
+
(0, typeorm_1.ManyToOne)(type => auth_base_1.User, { nullable: true }),
|
|
46
|
+
(0, type_graphql_1.Field)(type => auth_base_1.User, { nullable: true }),
|
|
47
|
+
tslib_1.__metadata("design:type", auth_base_1.User)
|
|
48
|
+
], Resource.prototype, "updater", void 0);
|
|
49
|
+
tslib_1.__decorate([
|
|
50
|
+
(0, typeorm_1.RelationId)((resource) => resource.updater),
|
|
51
|
+
tslib_1.__metadata("design:type", String)
|
|
52
|
+
], Resource.prototype, "updaterId", void 0);
|
|
53
|
+
Resource = tslib_1.__decorate([
|
|
54
|
+
(0, typeorm_1.Entity)(),
|
|
55
|
+
(0, typeorm_1.Index)('ix_resource_0', (resource) => [resource.name], {
|
|
56
|
+
unique: true,
|
|
57
|
+
where: '"deleted_at" IS NULL'
|
|
58
|
+
}),
|
|
59
|
+
(0, type_graphql_1.ObjectType)({ description: '리소스 관리 (작업자)' })
|
|
60
|
+
], Resource);
|
|
61
|
+
exports.Resource = Resource;
|
|
62
|
+
//# sourceMappingURL=resource.js.map
|
|
@@ -0,0 +1 @@
|
|
|
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,IAAI,EAAE,CA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E,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"]}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.resolvers = exports.entities = void 0;
|
|
4
|
+
const task_1 = require("./task");
|
|
5
|
+
const task_query_1 = require("./task-query");
|
|
6
|
+
const task_mutation_1 = require("./task-mutation");
|
|
7
|
+
exports.entities = [task_1.Task];
|
|
8
|
+
exports.resolvers = [task_query_1.TaskQuery, task_mutation_1.TaskMutation];
|
|
9
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../server/service/task/index.ts"],"names":[],"mappings":";;;AAAA,iCAA6B;AAC7B,6CAAwC;AACxC,mDAA8C;AAEjC,QAAA,QAAQ,GAAG,CAAC,WAAI,CAAC,CAAA;AACjB,QAAA,SAAS,GAAG,CAAC,sBAAS,EAAE,4BAAY,CAAC,CAAA","sourcesContent":["import { Task } from './task'\nimport { TaskQuery } from './task-query'\nimport { TaskMutation } from './task-mutation'\n\nexport const entities = [Task]\nexport const resolvers = [TaskQuery, TaskMutation]\n"]}
|
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.TaskMutation = 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 task_1 = require("./task");
|
|
9
|
+
const task_type_1 = require("./task-type");
|
|
10
|
+
let TaskMutation = class TaskMutation {
|
|
11
|
+
async createTask(task, context) {
|
|
12
|
+
const { domain, user, tx } = context.state;
|
|
13
|
+
const result = await tx.getRepository(task_1.Task).save(Object.assign(Object.assign({}, task), { domain, creator: user, updater: user }));
|
|
14
|
+
return result;
|
|
15
|
+
}
|
|
16
|
+
async updateTask(id, patch, context) {
|
|
17
|
+
const { domain, user, tx } = context.state;
|
|
18
|
+
const repository = tx.getRepository(task_1.Task);
|
|
19
|
+
const task = await repository.findOne({
|
|
20
|
+
where: { id }
|
|
21
|
+
});
|
|
22
|
+
const result = await repository.save(Object.assign(Object.assign(Object.assign({}, task), patch), { updater: user }));
|
|
23
|
+
return result;
|
|
24
|
+
}
|
|
25
|
+
async updateMultipleTask(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 taskRepo = tx.getRepository(task_1.Task);
|
|
31
|
+
if (_createRecords.length > 0) {
|
|
32
|
+
for (let i = 0; i < _createRecords.length; i++) {
|
|
33
|
+
const newRecord = _createRecords[i];
|
|
34
|
+
const result = await taskRepo.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 task = await taskRepo.findOneBy({ id: updateRecord.id });
|
|
42
|
+
const result = await taskRepo.save(Object.assign(Object.assign(Object.assign({}, task), updateRecord), { updater: user }));
|
|
43
|
+
results.push(Object.assign(Object.assign({}, result), { cuFlag: 'M' }));
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
return results;
|
|
47
|
+
}
|
|
48
|
+
async deleteTask(id, context) {
|
|
49
|
+
const { domain, tx } = context.state;
|
|
50
|
+
await tx.getRepository(task_1.Task).delete({ id });
|
|
51
|
+
await (0, attachment_base_1.deleteAttachmentsByRef)(null, { refBys: [id] }, context);
|
|
52
|
+
return true;
|
|
53
|
+
}
|
|
54
|
+
async deleteTasks(ids, context) {
|
|
55
|
+
const { domain, tx } = context.state;
|
|
56
|
+
await tx.getRepository(task_1.Task).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 importTasks(tasks, context) {
|
|
63
|
+
const { domain, tx } = context.state;
|
|
64
|
+
await Promise.all(tasks.map(async (task) => {
|
|
65
|
+
const createdTask = await tx.getRepository(task_1.Task).save(Object.assign({ domain }, task));
|
|
66
|
+
}));
|
|
67
|
+
return true;
|
|
68
|
+
}
|
|
69
|
+
};
|
|
70
|
+
tslib_1.__decorate([
|
|
71
|
+
(0, type_graphql_1.Directive)('@transaction'),
|
|
72
|
+
(0, type_graphql_1.Mutation)(returns => task_1.Task, { description: 'To create new Task' }),
|
|
73
|
+
tslib_1.__param(0, (0, type_graphql_1.Arg)('task')),
|
|
74
|
+
tslib_1.__param(1, (0, type_graphql_1.Ctx)()),
|
|
75
|
+
tslib_1.__metadata("design:type", Function),
|
|
76
|
+
tslib_1.__metadata("design:paramtypes", [task_type_1.NewTask, Object]),
|
|
77
|
+
tslib_1.__metadata("design:returntype", Promise)
|
|
78
|
+
], TaskMutation.prototype, "createTask", null);
|
|
79
|
+
tslib_1.__decorate([
|
|
80
|
+
(0, type_graphql_1.Directive)('@transaction'),
|
|
81
|
+
(0, type_graphql_1.Mutation)(returns => task_1.Task, { description: 'To modify Task 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, task_type_1.TaskPatch, Object]),
|
|
87
|
+
tslib_1.__metadata("design:returntype", Promise)
|
|
88
|
+
], TaskMutation.prototype, "updateTask", null);
|
|
89
|
+
tslib_1.__decorate([
|
|
90
|
+
(0, type_graphql_1.Directive)('@transaction'),
|
|
91
|
+
(0, type_graphql_1.Mutation)(returns => [task_1.Task], { description: "To modify multiple Tasks' information" }),
|
|
92
|
+
tslib_1.__param(0, (0, type_graphql_1.Arg)('patches', type => [task_type_1.TaskPatch])),
|
|
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
|
+
], TaskMutation.prototype, "updateMultipleTask", null);
|
|
98
|
+
tslib_1.__decorate([
|
|
99
|
+
(0, type_graphql_1.Directive)('@transaction'),
|
|
100
|
+
(0, type_graphql_1.Mutation)(returns => Boolean, { description: 'To delete Task' }),
|
|
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
|
+
], TaskMutation.prototype, "deleteTask", null);
|
|
107
|
+
tslib_1.__decorate([
|
|
108
|
+
(0, type_graphql_1.Directive)('@transaction'),
|
|
109
|
+
(0, type_graphql_1.Mutation)(returns => Boolean, { description: 'To delete multiple Tasks' }),
|
|
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
|
+
], TaskMutation.prototype, "deleteTasks", null);
|
|
116
|
+
tslib_1.__decorate([
|
|
117
|
+
(0, type_graphql_1.Directive)('@transaction'),
|
|
118
|
+
(0, type_graphql_1.Mutation)(returns => Boolean, { description: 'To import multiple Tasks' }),
|
|
119
|
+
tslib_1.__param(0, (0, type_graphql_1.Arg)('tasks', type => [task_type_1.TaskPatch])),
|
|
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
|
+
], TaskMutation.prototype, "importTasks", null);
|
|
125
|
+
TaskMutation = tslib_1.__decorate([
|
|
126
|
+
(0, type_graphql_1.Resolver)(task_1.Task)
|
|
127
|
+
], TaskMutation);
|
|
128
|
+
exports.TaskMutation = TaskMutation;
|
|
129
|
+
//# sourceMappingURL=task-mutation.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"task-mutation.js","sourceRoot":"","sources":["../../../server/service/task/task-mutation.ts"],"names":[],"mappings":";;;;AAAA,+CAAsE;AACtE,qCAA4B;AAE5B,qEAA0F;AAE1F,iCAA6B;AAC7B,2CAAgD;AAGzC,IAAM,YAAY,GAAlB,MAAM,YAAY;IAGjB,AAAN,KAAK,CAAC,UAAU,CAAc,IAAa,EAAS,OAAwB;QAC1E,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,EAAE,EAAE,GAAG,OAAO,CAAC,KAAK,CAAA;QAE1C,MAAM,MAAM,GAAG,MAAM,EAAE,CAAC,aAAa,CAAC,WAAI,CAAC,CAAC,IAAI,iCAC3C,IAAI,KACP,MAAM,EACN,OAAO,EAAE,IAAI,EACb,OAAO,EAAE,IAAI,IACb,CAAA;QAEF,OAAO,MAAM,CAAA;IACf,CAAC;IAIK,AAAN,KAAK,CAAC,UAAU,CACH,EAAU,EACP,KAAgB,EACvB,OAAwB;QAE/B,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,EAAE,EAAE,GAAG,OAAO,CAAC,KAAK,CAAA;QAE1C,MAAM,UAAU,GAAG,EAAE,CAAC,aAAa,CAAC,WAAI,CAAC,CAAA;QACzC,MAAM,IAAI,GAAG,MAAM,UAAU,CAAC,OAAO,CAAC;YACpC,KAAK,EAAE,EAAE,EAAE,EAAE;SACd,CAAC,CAAA;QAEF,MAAM,MAAM,GAAG,MAAM,UAAU,CAAC,IAAI,+CAC/B,IAAI,GAC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AAC,OAAO,CAAC,EAAE,CAAC,OAAO,EAAE,EAAE,WAAW,EAAE,gBAAgB,EAAE,CAAC;IAC9C,mBAAA,IAAA,kBAAG,EAAC,IAAI,CAAC,CAAA;IAAc,mBAAA,IAAA,kBAAG,GAAE,CAAA;;;;8CAO7C;AAIK;IAFL,IAAA,wBAAS,EAAC,cAAc,CAAC;IACzB,IAAA,uBAAQ,EAAC,OAAO,CAAC,EAAE,CAAC,OAAO,EAAE,EAAE,WAAW,EAAE,0BAA0B,EAAE,CAAC;IACvD,mBAAA,IAAA,kBAAG,EAAC,KAAK,EAAE,IAAI,CAAC,EAAE,CAAC,CAAC,MAAM,CAAC,CAAC,CAAA;IAAiB,mBAAA,IAAA,kBAAG,GAAE,CAAA;;;;+CAUpE;AAIK;IAFL,IAAA,wBAAS,EAAC,cAAc,CAAC;IACzB,IAAA,uBAAQ,EAAC,OAAO,CAAC,EAAE,CAAC,OAAO,EAAE,EAAE,WAAW,EAAE,0BAA0B,EAAE,CAAC;IAEvE,mBAAA,IAAA,kBAAG,EAAC,OAAO,EAAE,IAAI,CAAC,EAAE,CAAC,CAAC,qBAAS,CAAC,CAAC,CAAA;IACjC,mBAAA,IAAA,kBAAG,GAAE,CAAA;;;;+CAWP;AA7HU,YAAY;IADxB,IAAA,uBAAQ,EAAC,WAAI,CAAC;GACF,YAAY,CA8HxB;AA9HY,oCAAY","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 { Task } from './task'\nimport { NewTask, TaskPatch } from './task-type'\n\n@Resolver(Task)\nexport class TaskMutation {\n @Directive('@transaction')\n @Mutation(returns => Task, { description: 'To create new Task' })\n async createTask(@Arg('task') task: NewTask, @Ctx() context: ResolverContext): Promise<Task> {\n const { domain, user, tx } = context.state\n\n const result = await tx.getRepository(Task).save({\n ...task,\n domain,\n creator: user,\n updater: user\n })\n\n return result\n }\n\n @Directive('@transaction')\n @Mutation(returns => Task, { description: 'To modify Task information' })\n async updateTask(\n @Arg('id') id: string,\n @Arg('patch') patch: TaskPatch,\n @Ctx() context: ResolverContext\n ): Promise<Task> {\n const { domain, user, tx } = context.state\n\n const repository = tx.getRepository(Task)\n const task = await repository.findOne({\n where: { id }\n })\n\n const result = await repository.save({\n ...task,\n ...patch,\n updater: user\n })\n\n return result\n }\n\n @Directive('@transaction')\n @Mutation(returns => [Task], { description: \"To modify multiple Tasks' information\" })\n async updateMultipleTask(\n @Arg('patches', type => [TaskPatch]) patches: TaskPatch[],\n @Ctx() context: ResolverContext\n ): Promise<Task[]> {\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 taskRepo = tx.getRepository(Task)\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 taskRepo.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 task = await taskRepo.findOneBy({ id: updateRecord.id })\n\n const result = await taskRepo.save({\n ...task,\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 Task' })\n async deleteTask(@Arg('id') id: string, @Ctx() context: ResolverContext): Promise<boolean> {\n const { domain, tx } = context.state\n\n await tx.getRepository(Task).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 Tasks' })\n async deleteTasks(@Arg('ids', type => [String]) ids: string[], @Ctx() context: ResolverContext): Promise<boolean> {\n const { domain, tx } = context.state\n\n await tx.getRepository(Task).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 Tasks' })\n async importTasks(\n @Arg('tasks', type => [TaskPatch]) tasks: TaskPatch[],\n @Ctx() context: ResolverContext\n ): Promise<boolean> {\n const { domain, tx } = context.state\n\n await Promise.all(\n tasks.map(async (task: TaskPatch) => {\n const createdTask: Task = await tx.getRepository(Task).save({ domain, ...task })\n })\n )\n\n return true\n }\n}\n"]}
|