@dssp/supervision 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/client/actions/main.ts +1 -0
- package/client/bootstrap.ts +8 -0
- package/client/index.ts +1 -0
- package/client/pages/action-plan/action-plan-importer.ts +96 -0
- package/client/pages/action-plan/action-plan-list-page.ts +355 -0
- package/client/pages/check-item/check-item-importer.ts +96 -0
- package/client/pages/check-item/check-item-list-page.ts +355 -0
- package/client/pages/issue/issue-importer.ts +96 -0
- package/client/pages/issue/issue-list-page.ts +355 -0
- package/client/pages/main.ts +25 -0
- package/client/pages/project-report/project-report-importer.ts +96 -0
- package/client/pages/project-report/project-report-list-page.ts +355 -0
- package/client/pages/supervisor/supervisor-importer.ts +96 -0
- package/client/pages/supervisor/supervisor-list-page.ts +355 -0
- package/client/reducers/main.ts +17 -0
- package/client/route.ts +27 -0
- package/client/tsconfig.json +11 -0
- package/dist-client/actions/main.d.ts +1 -0
- package/dist-client/actions/main.js +2 -0
- package/dist-client/actions/main.js.map +1 -0
- package/dist-client/bootstrap.d.ts +1 -0
- package/dist-client/bootstrap.js +8 -0
- package/dist-client/bootstrap.js.map +1 -0
- package/dist-client/index.d.ts +1 -0
- package/dist-client/index.js +2 -0
- package/dist-client/index.js.map +1 -0
- package/dist-client/pages/action-plan/action-plan-importer.d.ts +9 -0
- package/dist-client/pages/action-plan/action-plan-importer.js +100 -0
- package/dist-client/pages/action-plan/action-plan-importer.js.map +1 -0
- package/dist-client/pages/action-plan/action-plan-list-page.d.ts +62 -0
- package/dist-client/pages/action-plan/action-plan-list-page.js +331 -0
- package/dist-client/pages/action-plan/action-plan-list-page.js.map +1 -0
- package/dist-client/pages/check-item/check-item-importer.d.ts +9 -0
- package/dist-client/pages/check-item/check-item-importer.js +100 -0
- package/dist-client/pages/check-item/check-item-importer.js.map +1 -0
- package/dist-client/pages/check-item/check-item-list-page.d.ts +62 -0
- package/dist-client/pages/check-item/check-item-list-page.js +331 -0
- package/dist-client/pages/check-item/check-item-list-page.js.map +1 -0
- package/dist-client/pages/issue/issue-importer.d.ts +9 -0
- package/dist-client/pages/issue/issue-importer.js +100 -0
- package/dist-client/pages/issue/issue-importer.js.map +1 -0
- package/dist-client/pages/issue/issue-list-page.d.ts +62 -0
- package/dist-client/pages/issue/issue-list-page.js +331 -0
- package/dist-client/pages/issue/issue-list-page.js.map +1 -0
- package/dist-client/pages/main.d.ts +1 -0
- package/dist-client/pages/main.js +27 -0
- package/dist-client/pages/main.js.map +1 -0
- package/dist-client/pages/project-report/project-report-importer.d.ts +9 -0
- package/dist-client/pages/project-report/project-report-importer.js +100 -0
- package/dist-client/pages/project-report/project-report-importer.js.map +1 -0
- package/dist-client/pages/project-report/project-report-list-page.d.ts +62 -0
- package/dist-client/pages/project-report/project-report-list-page.js +331 -0
- package/dist-client/pages/project-report/project-report-list-page.js.map +1 -0
- package/dist-client/pages/supervisor/supervisor-importer.d.ts +9 -0
- package/dist-client/pages/supervisor/supervisor-importer.js +100 -0
- package/dist-client/pages/supervisor/supervisor-importer.js.map +1 -0
- package/dist-client/pages/supervisor/supervisor-list-page.d.ts +62 -0
- package/dist-client/pages/supervisor/supervisor-list-page.js +331 -0
- package/dist-client/pages/supervisor/supervisor-list-page.js.map +1 -0
- package/dist-client/reducers/main.d.ts +6 -0
- package/dist-client/reducers/main.js +14 -0
- package/dist-client/reducers/main.js.map +1 -0
- package/dist-client/route.d.ts +1 -0
- package/dist-client/route.js +23 -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/index.js +7 -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/migrations/index.js +12 -0
- package/dist-server/migrations/index.js.map +1 -0
- package/dist-server/routes.js +25 -0
- package/dist-server/routes.js.map +1 -0
- package/dist-server/service/action-plan/action-plan-mutation.js +168 -0
- package/dist-server/service/action-plan/action-plan-mutation.js.map +1 -0
- package/dist-server/service/action-plan/action-plan-query.js +97 -0
- package/dist-server/service/action-plan/action-plan-query.js.map +1 -0
- package/dist-server/service/action-plan/action-plan-type.js +86 -0
- package/dist-server/service/action-plan/action-plan-type.js.map +1 -0
- package/dist-server/service/action-plan/action-plan.js +116 -0
- package/dist-server/service/action-plan/action-plan.js.map +1 -0
- package/dist-server/service/action-plan/index.js +10 -0
- package/dist-server/service/action-plan/index.js.map +1 -0
- package/dist-server/service/check-item/check-item-mutation.js +168 -0
- package/dist-server/service/check-item/check-item-mutation.js.map +1 -0
- package/dist-server/service/check-item/check-item-query.js +97 -0
- package/dist-server/service/check-item/check-item-query.js.map +1 -0
- package/dist-server/service/check-item/check-item-type.js +86 -0
- package/dist-server/service/check-item/check-item-type.js.map +1 -0
- package/dist-server/service/check-item/check-item.js +117 -0
- package/dist-server/service/check-item/check-item.js.map +1 -0
- package/dist-server/service/check-item/index.js +10 -0
- package/dist-server/service/check-item/index.js.map +1 -0
- package/dist-server/service/index.js +43 -0
- package/dist-server/service/index.js.map +1 -0
- package/dist-server/service/issue/index.js +10 -0
- package/dist-server/service/issue/index.js.map +1 -0
- package/dist-server/service/issue/issue-mutation.js +168 -0
- package/dist-server/service/issue/issue-mutation.js.map +1 -0
- package/dist-server/service/issue/issue-query.js +97 -0
- package/dist-server/service/issue/issue-query.js.map +1 -0
- package/dist-server/service/issue/issue-type.js +86 -0
- package/dist-server/service/issue/issue-type.js.map +1 -0
- package/dist-server/service/issue/issue.js +117 -0
- package/dist-server/service/issue/issue.js.map +1 -0
- package/dist-server/service/project-report/index.js +10 -0
- package/dist-server/service/project-report/index.js.map +1 -0
- package/dist-server/service/project-report/project-report-mutation.js +168 -0
- package/dist-server/service/project-report/project-report-mutation.js.map +1 -0
- package/dist-server/service/project-report/project-report-query.js +97 -0
- package/dist-server/service/project-report/project-report-query.js.map +1 -0
- package/dist-server/service/project-report/project-report-type.js +86 -0
- package/dist-server/service/project-report/project-report-type.js.map +1 -0
- package/dist-server/service/project-report/project-report.js +128 -0
- package/dist-server/service/project-report/project-report.js.map +1 -0
- package/dist-server/service/supervisor/index.js +10 -0
- package/dist-server/service/supervisor/index.js.map +1 -0
- package/dist-server/service/supervisor/supervisor-mutation.js +168 -0
- package/dist-server/service/supervisor/supervisor-mutation.js.map +1 -0
- package/dist-server/service/supervisor/supervisor-query.js +97 -0
- package/dist-server/service/supervisor/supervisor-query.js.map +1 -0
- package/dist-server/service/supervisor/supervisor-type.js +86 -0
- package/dist-server/service/supervisor/supervisor-type.js.map +1 -0
- package/dist-server/service/supervisor/supervisor.js +127 -0
- package/dist-server/service/supervisor/supervisor.js.map +1 -0
- package/dist-server/tsconfig.tsbuildinfo +1 -0
- package/helps/supervision/action-plan.md +160 -0
- package/helps/supervision/check-item.md +160 -0
- package/helps/supervision/issue.md +160 -0
- package/helps/supervision/project-report.md +160 -0
- package/helps/supervision/supervisor.md +160 -0
- package/package.json +37 -0
- package/server/controllers/index.ts +0 -0
- package/server/index.ts +4 -0
- package/server/middlewares/index.ts +3 -0
- package/server/migrations/index.ts +9 -0
- package/server/routes.ts +28 -0
- package/server/service/action-plan/action-plan-mutation.ts +198 -0
- package/server/service/action-plan/action-plan-query.ts +62 -0
- package/server/service/action-plan/action-plan-type.ts +61 -0
- package/server/service/action-plan/action-plan.ts +103 -0
- package/server/service/action-plan/index.ts +7 -0
- package/server/service/check-item/check-item-mutation.ts +198 -0
- package/server/service/check-item/check-item-query.ts +62 -0
- package/server/service/check-item/check-item-type.ts +61 -0
- package/server/service/check-item/check-item.ts +111 -0
- package/server/service/check-item/index.ts +7 -0
- package/server/service/index.ts +42 -0
- package/server/service/issue/index.ts +7 -0
- package/server/service/issue/issue-mutation.ts +198 -0
- package/server/service/issue/issue-query.ts +62 -0
- package/server/service/issue/issue-type.ts +61 -0
- package/server/service/issue/issue.ts +105 -0
- package/server/service/project-report/index.ts +7 -0
- package/server/service/project-report/project-report-mutation.ts +198 -0
- package/server/service/project-report/project-report-query.ts +62 -0
- package/server/service/project-report/project-report-type.ts +61 -0
- package/server/service/project-report/project-report.ts +113 -0
- package/server/service/supervisor/index.ts +7 -0
- package/server/service/supervisor/supervisor-mutation.ts +198 -0
- package/server/service/supervisor/supervisor-query.ts +62 -0
- package/server/service/supervisor/supervisor-type.ts +61 -0
- package/server/service/supervisor/supervisor.ts +113 -0
- package/server/tsconfig.json +10 -0
- package/things-factory.config.js +15 -0
- package/translations/en.json +1 -0
- package/translations/ko.json +1 -0
- package/translations/ms.json +1 -0
- package/translations/zh.json +1 -0
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ActionPlanQuery = 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 action_plan_1 = require("./action-plan");
|
|
10
|
+
const action_plan_type_1 = require("./action-plan-type");
|
|
11
|
+
let ActionPlanQuery = class ActionPlanQuery {
|
|
12
|
+
async actionPlan(id, context) {
|
|
13
|
+
const { domain } = context.state;
|
|
14
|
+
return await (0, shell_1.getRepository)(action_plan_1.ActionPlan).findOne({
|
|
15
|
+
where: { domain: { id: domain.id }, id }
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
async actionPlans(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)(action_plan_1.ActionPlan),
|
|
24
|
+
searchables: ['name', 'description']
|
|
25
|
+
});
|
|
26
|
+
const [items, total] = await queryBuilder.getManyAndCount();
|
|
27
|
+
return { items, total };
|
|
28
|
+
}
|
|
29
|
+
async thumbnail(actionPlan) {
|
|
30
|
+
const attachment = await (0, shell_1.getRepository)(attachment_base_1.Attachment).findOne({
|
|
31
|
+
where: {
|
|
32
|
+
domain: { id: actionPlan.domainId },
|
|
33
|
+
refType: action_plan_1.ActionPlan.name,
|
|
34
|
+
refBy: actionPlan.id
|
|
35
|
+
}
|
|
36
|
+
});
|
|
37
|
+
return attachment === null || attachment === void 0 ? void 0 : attachment.fullpath;
|
|
38
|
+
}
|
|
39
|
+
async domain(actionPlan) {
|
|
40
|
+
return await (0, shell_1.getRepository)(shell_1.Domain).findOneBy({ id: actionPlan.domainId });
|
|
41
|
+
}
|
|
42
|
+
async updater(actionPlan) {
|
|
43
|
+
return await (0, shell_1.getRepository)(auth_base_1.User).findOneBy({ id: actionPlan.updaterId });
|
|
44
|
+
}
|
|
45
|
+
async creator(actionPlan) {
|
|
46
|
+
return await (0, shell_1.getRepository)(auth_base_1.User).findOneBy({ id: actionPlan.creatorId });
|
|
47
|
+
}
|
|
48
|
+
};
|
|
49
|
+
tslib_1.__decorate([
|
|
50
|
+
(0, type_graphql_1.Query)(returns => action_plan_1.ActionPlan, { nullable: true, description: 'To fetch a ActionPlan' }),
|
|
51
|
+
tslib_1.__param(0, (0, type_graphql_1.Arg)('id')),
|
|
52
|
+
tslib_1.__param(1, (0, type_graphql_1.Ctx)()),
|
|
53
|
+
tslib_1.__metadata("design:type", Function),
|
|
54
|
+
tslib_1.__metadata("design:paramtypes", [String, Object]),
|
|
55
|
+
tslib_1.__metadata("design:returntype", Promise)
|
|
56
|
+
], ActionPlanQuery.prototype, "actionPlan", null);
|
|
57
|
+
tslib_1.__decorate([
|
|
58
|
+
(0, type_graphql_1.Query)(returns => action_plan_type_1.ActionPlanList, { description: 'To fetch multiple ActionPlans' }),
|
|
59
|
+
tslib_1.__param(0, (0, type_graphql_1.Args)()),
|
|
60
|
+
tslib_1.__param(1, (0, type_graphql_1.Ctx)()),
|
|
61
|
+
tslib_1.__metadata("design:type", Function),
|
|
62
|
+
tslib_1.__metadata("design:paramtypes", [shell_1.ListParam, Object]),
|
|
63
|
+
tslib_1.__metadata("design:returntype", Promise)
|
|
64
|
+
], ActionPlanQuery.prototype, "actionPlans", null);
|
|
65
|
+
tslib_1.__decorate([
|
|
66
|
+
(0, type_graphql_1.FieldResolver)(type => String),
|
|
67
|
+
tslib_1.__param(0, (0, type_graphql_1.Root)()),
|
|
68
|
+
tslib_1.__metadata("design:type", Function),
|
|
69
|
+
tslib_1.__metadata("design:paramtypes", [action_plan_1.ActionPlan]),
|
|
70
|
+
tslib_1.__metadata("design:returntype", Promise)
|
|
71
|
+
], ActionPlanQuery.prototype, "thumbnail", null);
|
|
72
|
+
tslib_1.__decorate([
|
|
73
|
+
(0, type_graphql_1.FieldResolver)(type => shell_1.Domain),
|
|
74
|
+
tslib_1.__param(0, (0, type_graphql_1.Root)()),
|
|
75
|
+
tslib_1.__metadata("design:type", Function),
|
|
76
|
+
tslib_1.__metadata("design:paramtypes", [action_plan_1.ActionPlan]),
|
|
77
|
+
tslib_1.__metadata("design:returntype", Promise)
|
|
78
|
+
], ActionPlanQuery.prototype, "domain", null);
|
|
79
|
+
tslib_1.__decorate([
|
|
80
|
+
(0, type_graphql_1.FieldResolver)(type => auth_base_1.User),
|
|
81
|
+
tslib_1.__param(0, (0, type_graphql_1.Root)()),
|
|
82
|
+
tslib_1.__metadata("design:type", Function),
|
|
83
|
+
tslib_1.__metadata("design:paramtypes", [action_plan_1.ActionPlan]),
|
|
84
|
+
tslib_1.__metadata("design:returntype", Promise)
|
|
85
|
+
], ActionPlanQuery.prototype, "updater", null);
|
|
86
|
+
tslib_1.__decorate([
|
|
87
|
+
(0, type_graphql_1.FieldResolver)(type => auth_base_1.User),
|
|
88
|
+
tslib_1.__param(0, (0, type_graphql_1.Root)()),
|
|
89
|
+
tslib_1.__metadata("design:type", Function),
|
|
90
|
+
tslib_1.__metadata("design:paramtypes", [action_plan_1.ActionPlan]),
|
|
91
|
+
tslib_1.__metadata("design:returntype", Promise)
|
|
92
|
+
], ActionPlanQuery.prototype, "creator", null);
|
|
93
|
+
ActionPlanQuery = tslib_1.__decorate([
|
|
94
|
+
(0, type_graphql_1.Resolver)(action_plan_1.ActionPlan)
|
|
95
|
+
], ActionPlanQuery);
|
|
96
|
+
exports.ActionPlanQuery = ActionPlanQuery;
|
|
97
|
+
//# sourceMappingURL=action-plan-query.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"action-plan-query.js","sourceRoot":"","sources":["../../../server/service/action-plan/action-plan-query.ts"],"names":[],"mappings":";;;;AAAA,+CAA8F;AAC9F,qEAA4D;AAC5D,iDAAuG;AACvG,yDAAgD;AAChD,+CAA0C;AAC1C,yDAAmD;AAG5C,IAAM,eAAe,GAArB,MAAM,eAAe;IAEpB,AAAN,KAAK,CAAC,UAAU,CAAY,EAAU,EAAS,OAAwB;QACrE,MAAM,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,KAAK,CAAA;QAEhC,OAAO,MAAM,IAAA,qBAAa,EAAC,wBAAU,CAAC,CAAC,OAAO,CAAC;YAC7C,KAAK,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,EAAE,MAAM,CAAC,EAAE,EAAE,EAAE,EAAE,EAAE;SACzC,CAAC,CAAA;IACJ,CAAC;IAGK,AAAN,KAAK,CAAC,WAAW,CAAS,MAAiB,EAAS,OAAwB;QAC1E,MAAM,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,KAAK,CAAA;QAEhC,MAAM,YAAY,GAAG,IAAA,qCAA6B,EAAC;YACjD,MAAM;YACN,MAAM;YACN,UAAU,EAAE,MAAM,IAAA,qBAAa,EAAC,wBAAU,CAAC;YAC3C,WAAW,EAAE,CAAC,MAAM,EAAE,aAAa,CAAC;SACrC,CAAC,CAAA;QAEF,MA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IAAI,CAAC,CAAA;IAAc,mBAAA,IAAA,kBAAG,GAAE,CAAA;;;;iDAM7C;AAGK;IADL,IAAA,oBAAK,EAAC,OAAO,CAAC,EAAE,CAAC,iCAAc,EAAE,EAAE,WAAW,EAAE,+BAA+B,EAAE,CAAC;IAChE,mBAAA,IAAA,mBAAI,GAAE,CAAA;IAAqB,mBAAA,IAAA,kBAAG,GAAE,CAAA;;6CAAjB,iBAAS;;kDAa1C;AAGK;IADL,IAAA,4BAAa,EAAC,IAAI,CAAC,EAAE,CAAC,MAAM,CAAC;IACb,mBAAA,IAAA,mBAAI,GAAE,CAAA;;6CAAa,wBAAU;;gDAU7C;AAGK;IADL,IAAA,4BAAa,EAAC,IAAI,CAAC,EAAE,CAAC,cAAM,CAAC;IAChB,mBAAA,IAAA,mBAAI,GAAE,CAAA;;6CAAa,wBAAU;;6CAE1C;AAGK;IADL,IAAA,4BAAa,EAAC,IAAI,CAAC,EAAE,CAAC,gBAAI,CAAC;IACb,mBAAA,IAAA,mBAAI,GAAE,CAAA;;6CAAa,wBAAU;;8CAE3C;AAGK;IADL,IAAA,4BAAa,EAAC,IAAI,CAAC,EAAE,CAAC,gBAAI,CAAC;IACb,mBAAA,IAAA,mBAAI,GAAE,CAAA;;6CAAa,wBAAU;;8CAE3C;AApDU,eAAe;IAD3B,IAAA,uBAAQ,EAAC,wBAAU,CAAC;GACR,eAAe,CAqD3B;AArDY,0CAAe","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 { ActionPlan } from './action-plan'\nimport { ActionPlanList } from './action-plan-type'\n\n@Resolver(ActionPlan)\nexport class ActionPlanQuery {\n @Query(returns => ActionPlan!, { nullable: true, description: 'To fetch a ActionPlan' })\n async actionPlan(@Arg('id') id: string, @Ctx() context: ResolverContext): Promise<ActionPlan> {\n const { domain } = context.state\n\n return await getRepository(ActionPlan).findOne({\n where: { domain: { id: domain.id }, id }\n })\n }\n\n @Query(returns => ActionPlanList, { description: 'To fetch multiple ActionPlans' })\n async actionPlans(@Args() params: ListParam, @Ctx() context: ResolverContext): Promise<ActionPlanList> {\n const { domain } = context.state\n\n const queryBuilder = getQueryBuilderFromListParams({\n domain,\n params,\n repository: await getRepository(ActionPlan),\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() actionPlan: ActionPlan): Promise<string | undefined> {\n const attachment: Attachment = await getRepository(Attachment).findOne({\n where: {\n domain: { id: actionPlan.domainId },\n refType: ActionPlan.name,\n refBy: actionPlan.id\n }\n })\n\n return attachment?.fullpath\n }\n\n @FieldResolver(type => Domain)\n async domain(@Root() actionPlan: ActionPlan): Promise<Domain> {\n return await getRepository(Domain).findOneBy({ id: actionPlan.domainId })\n }\n\n @FieldResolver(type => User)\n async updater(@Root() actionPlan: ActionPlan): Promise<User> {\n return await getRepository(User).findOneBy({ id: actionPlan.updaterId })\n }\n\n @FieldResolver(type => User)\n async creator(@Root() actionPlan: ActionPlan): Promise<User> {\n return await getRepository(User).findOneBy({ id: actionPlan.creatorId })\n }\n}\n"]}
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ActionPlanList = exports.ActionPlanPatch = exports.NewActionPlan = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const GraphQLUpload_js_1 = tslib_1.__importDefault(require("graphql-upload/GraphQLUpload.js"));
|
|
6
|
+
const type_graphql_1 = require("type-graphql");
|
|
7
|
+
const action_plan_1 = require("./action-plan");
|
|
8
|
+
let NewActionPlan = class NewActionPlan {
|
|
9
|
+
};
|
|
10
|
+
tslib_1.__decorate([
|
|
11
|
+
(0, type_graphql_1.Field)(),
|
|
12
|
+
tslib_1.__metadata("design:type", String)
|
|
13
|
+
], NewActionPlan.prototype, "name", void 0);
|
|
14
|
+
tslib_1.__decorate([
|
|
15
|
+
(0, type_graphql_1.Field)({ nullable: true }),
|
|
16
|
+
tslib_1.__metadata("design:type", String)
|
|
17
|
+
], NewActionPlan.prototype, "description", void 0);
|
|
18
|
+
tslib_1.__decorate([
|
|
19
|
+
(0, type_graphql_1.Field)(type => action_plan_1.ActionPlanStatus, { nullable: true }),
|
|
20
|
+
tslib_1.__metadata("design:type", String)
|
|
21
|
+
], NewActionPlan.prototype, "state", void 0);
|
|
22
|
+
tslib_1.__decorate([
|
|
23
|
+
(0, type_graphql_1.Field)({ nullable: true }),
|
|
24
|
+
tslib_1.__metadata("design:type", Boolean)
|
|
25
|
+
], NewActionPlan.prototype, "active", void 0);
|
|
26
|
+
tslib_1.__decorate([
|
|
27
|
+
(0, type_graphql_1.Field)({ nullable: true }),
|
|
28
|
+
tslib_1.__metadata("design:type", String)
|
|
29
|
+
], NewActionPlan.prototype, "params", void 0);
|
|
30
|
+
tslib_1.__decorate([
|
|
31
|
+
(0, type_graphql_1.Field)(type => GraphQLUpload_js_1.default, { nullable: true }),
|
|
32
|
+
tslib_1.__metadata("design:type", Object)
|
|
33
|
+
], NewActionPlan.prototype, "thumbnail", void 0);
|
|
34
|
+
NewActionPlan = tslib_1.__decorate([
|
|
35
|
+
(0, type_graphql_1.InputType)()
|
|
36
|
+
], NewActionPlan);
|
|
37
|
+
exports.NewActionPlan = NewActionPlan;
|
|
38
|
+
let ActionPlanPatch = class ActionPlanPatch {
|
|
39
|
+
};
|
|
40
|
+
tslib_1.__decorate([
|
|
41
|
+
(0, type_graphql_1.Field)(type => type_graphql_1.ID, { nullable: true }),
|
|
42
|
+
tslib_1.__metadata("design:type", String)
|
|
43
|
+
], ActionPlanPatch.prototype, "id", void 0);
|
|
44
|
+
tslib_1.__decorate([
|
|
45
|
+
(0, type_graphql_1.Field)({ nullable: true }),
|
|
46
|
+
tslib_1.__metadata("design:type", String)
|
|
47
|
+
], ActionPlanPatch.prototype, "name", void 0);
|
|
48
|
+
tslib_1.__decorate([
|
|
49
|
+
(0, type_graphql_1.Field)({ nullable: true }),
|
|
50
|
+
tslib_1.__metadata("design:type", String)
|
|
51
|
+
], ActionPlanPatch.prototype, "description", void 0);
|
|
52
|
+
tslib_1.__decorate([
|
|
53
|
+
(0, type_graphql_1.Field)(type => action_plan_1.ActionPlanStatus, { nullable: true }),
|
|
54
|
+
tslib_1.__metadata("design:type", String)
|
|
55
|
+
], ActionPlanPatch.prototype, "state", void 0);
|
|
56
|
+
tslib_1.__decorate([
|
|
57
|
+
(0, type_graphql_1.Field)({ nullable: true }),
|
|
58
|
+
tslib_1.__metadata("design:type", Boolean)
|
|
59
|
+
], ActionPlanPatch.prototype, "active", void 0);
|
|
60
|
+
tslib_1.__decorate([
|
|
61
|
+
(0, type_graphql_1.Field)(type => GraphQLUpload_js_1.default, { nullable: true }),
|
|
62
|
+
tslib_1.__metadata("design:type", Object)
|
|
63
|
+
], ActionPlanPatch.prototype, "thumbnail", void 0);
|
|
64
|
+
tslib_1.__decorate([
|
|
65
|
+
(0, type_graphql_1.Field)({ nullable: true }),
|
|
66
|
+
tslib_1.__metadata("design:type", String)
|
|
67
|
+
], ActionPlanPatch.prototype, "cuFlag", void 0);
|
|
68
|
+
ActionPlanPatch = tslib_1.__decorate([
|
|
69
|
+
(0, type_graphql_1.InputType)()
|
|
70
|
+
], ActionPlanPatch);
|
|
71
|
+
exports.ActionPlanPatch = ActionPlanPatch;
|
|
72
|
+
let ActionPlanList = class ActionPlanList {
|
|
73
|
+
};
|
|
74
|
+
tslib_1.__decorate([
|
|
75
|
+
(0, type_graphql_1.Field)(type => [action_plan_1.ActionPlan]),
|
|
76
|
+
tslib_1.__metadata("design:type", Array)
|
|
77
|
+
], ActionPlanList.prototype, "items", void 0);
|
|
78
|
+
tslib_1.__decorate([
|
|
79
|
+
(0, type_graphql_1.Field)(type => type_graphql_1.Int),
|
|
80
|
+
tslib_1.__metadata("design:type", Number)
|
|
81
|
+
], ActionPlanList.prototype, "total", void 0);
|
|
82
|
+
ActionPlanList = tslib_1.__decorate([
|
|
83
|
+
(0, type_graphql_1.ObjectType)()
|
|
84
|
+
], ActionPlanList);
|
|
85
|
+
exports.ActionPlanList = ActionPlanList;
|
|
86
|
+
//# sourceMappingURL=action-plan-type.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"action-plan-type.js","sourceRoot":"","sources":["../../../server/service/action-plan/action-plan-type.ts"],"names":[],"mappings":";;;;AACA,+FAA2D;AAC3D,+CAAsF;AAItF,+CAA4D;AAGrD,IAAM,aAAa,GAAnB,MAAM,aAAa;CAkBzB,CAAA;AAjBC;IAAC,IAAA,oBAAK,GAAE;;2CACI;AAEZ;IAAC,IAAA,oBAAK,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;;kDACN;AAEpB;IAAC,IAAA,oBAAK,EAAC,IAAI,CAAC,EAAE,CAAC,8BAAgB,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;;4CAC5B;AAExB;IAAC,IAAA,oBAAK,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;;6CACV;AAEhB;IAAC,IAAA,oBAAK,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;;6CACX;AAEf;IAAC,IAAA,oBAAK,EAAC,IAAI,CAAC,EAAE,CAAC,0BAAa,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;;gDAC3B;AAjBX,aAAa;IADzB,IAAA,wBAAS,GAAE;GACC,aAAa,CAkBzB;AAlBY,sCAAa;AAqBnB,IAAM,eAAe,GAArB,MAAM,eAAe;CAqB3B,CAAA;AApBC;IAAC,IAAA,oBAAK,EAAC,IAAI,CAAC,EAAE,CAAC,iBAAE,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;;2CAC3B;AAEX;IAAC,IAAA,oBAAK,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;;6CACb;AAEb;IAAC,IAAA,oBAAK,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;;oDACN;AAEpB;IAAC,IAAA,oBAAK,EAAC,IAAI,CAAC,EAAE,CAAC,8BAAgB,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;;8CAC5B;AAExB;IAAC,IAAA,oBAAK,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;;+CACV;AAEhB;IAAC,IAAA,oBAAK,EAAC,IAAI,CAAC,EAAE,CAAC,0BAAa,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;;kDAC3B;AAEtB;IAAC,IAAA,oBAAK,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;;+CACX;AApBJ,eAAe;IAD3B,IAAA,wBAAS,GAAE;GACC,eAAe,CAqB3B;AArBY,0CAAe;AAwBrB,IAAM,cAAc,GAApB,MAAM,cAAc;CAM1B,CAAA;AALC;IAAC,IAAA,oBAAK,EAAC,IAAI,CAAC,EAAE,CAAC,CAAC,wBAAU,CAAC,CAAC;;6CACT;AAEnB;IAAC,IAAA,oBAAK,EAAC,IAAI,CAAC,EAAE,CAAC,kBAAG,CAAC;;6CACN;AALF,cAAc;IAD1B,IAAA,yBAAU,GAAE;GACA,cAAc,CAM1B;AANY,wCAAc","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 { ActionPlan, ActionPlanStatus } from './action-plan'\n\n@InputType()\nexport class NewActionPlan {\n @Field()\n name: string\n\n @Field({ nullable: true })\n description?: string\n\n @Field(type => ActionPlanStatus, { nullable: true })\n state?: ActionPlanStatus\n\n @Field({ nullable: true })\n active?: boolean\n\n @Field({ nullable: true })\n params?: string\n\n @Field(type => GraphQLUpload, { nullable: true })\n thumbnail?: FileUpload\n}\n\n@InputType()\nexport class ActionPlanPatch {\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(type => ActionPlanStatus, { nullable: true })\n state?: ActionPlanStatus\n\n @Field({ nullable: true })\n active?: boolean\n\n @Field(type => GraphQLUpload, { nullable: true })\n thumbnail?: FileUpload\n\n @Field({ nullable: true })\n cuFlag?: string\n}\n\n@ObjectType()\nexport class ActionPlanList {\n @Field(type => [ActionPlan])\n items: ActionPlan[]\n\n @Field(type => Int)\n total: number\n}\n"]}
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ActionPlan = exports.ActionPlanStatus = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const typeorm_1 = require("typeorm");
|
|
6
|
+
const type_graphql_1 = require("type-graphql");
|
|
7
|
+
const shell_1 = require("@things-factory/shell");
|
|
8
|
+
const auth_base_1 = require("@things-factory/auth-base");
|
|
9
|
+
const issue_1 = require("../issue/issue");
|
|
10
|
+
var ActionPlanStatus;
|
|
11
|
+
(function (ActionPlanStatus) {
|
|
12
|
+
ActionPlanStatus["STATUS_A"] = "STATUS_A";
|
|
13
|
+
ActionPlanStatus["STATUS_B"] = "STATUS_B";
|
|
14
|
+
})(ActionPlanStatus = exports.ActionPlanStatus || (exports.ActionPlanStatus = {}));
|
|
15
|
+
(0, type_graphql_1.registerEnumType)(ActionPlanStatus, {
|
|
16
|
+
name: 'ActionPlanStatus',
|
|
17
|
+
description: 'state enumeration of a actionPlan'
|
|
18
|
+
});
|
|
19
|
+
let ActionPlan = class ActionPlan {
|
|
20
|
+
};
|
|
21
|
+
tslib_1.__decorate([
|
|
22
|
+
(0, typeorm_1.PrimaryGeneratedColumn)('uuid'),
|
|
23
|
+
(0, type_graphql_1.Field)(type => type_graphql_1.ID),
|
|
24
|
+
tslib_1.__metadata("design:type", String)
|
|
25
|
+
], ActionPlan.prototype, "id", void 0);
|
|
26
|
+
tslib_1.__decorate([
|
|
27
|
+
(0, typeorm_1.ManyToOne)(type => shell_1.Domain),
|
|
28
|
+
(0, type_graphql_1.Field)({ nullable: true }),
|
|
29
|
+
tslib_1.__metadata("design:type", shell_1.Domain)
|
|
30
|
+
], ActionPlan.prototype, "domain", void 0);
|
|
31
|
+
tslib_1.__decorate([
|
|
32
|
+
(0, typeorm_1.RelationId)((actionPlan) => actionPlan.domain),
|
|
33
|
+
tslib_1.__metadata("design:type", String)
|
|
34
|
+
], ActionPlan.prototype, "domainId", void 0);
|
|
35
|
+
tslib_1.__decorate([
|
|
36
|
+
(0, typeorm_1.Column)(),
|
|
37
|
+
(0, type_graphql_1.Field)({ nullable: true }),
|
|
38
|
+
tslib_1.__metadata("design:type", String)
|
|
39
|
+
], ActionPlan.prototype, "name", void 0);
|
|
40
|
+
tslib_1.__decorate([
|
|
41
|
+
(0, typeorm_1.Column)({ nullable: true }),
|
|
42
|
+
(0, type_graphql_1.Field)({ nullable: true }),
|
|
43
|
+
tslib_1.__metadata("design:type", String)
|
|
44
|
+
], ActionPlan.prototype, "description", void 0);
|
|
45
|
+
tslib_1.__decorate([
|
|
46
|
+
(0, typeorm_1.Column)({ nullable: true }),
|
|
47
|
+
(0, type_graphql_1.Field)({ nullable: true }),
|
|
48
|
+
tslib_1.__metadata("design:type", Boolean)
|
|
49
|
+
], ActionPlan.prototype, "active", void 0);
|
|
50
|
+
tslib_1.__decorate([
|
|
51
|
+
(0, typeorm_1.Column)({ nullable: true }),
|
|
52
|
+
(0, type_graphql_1.Field)({ nullable: true }),
|
|
53
|
+
tslib_1.__metadata("design:type", String)
|
|
54
|
+
], ActionPlan.prototype, "state", void 0);
|
|
55
|
+
tslib_1.__decorate([
|
|
56
|
+
(0, typeorm_1.Column)({ nullable: true }),
|
|
57
|
+
(0, type_graphql_1.Field)({ nullable: true }),
|
|
58
|
+
tslib_1.__metadata("design:type", String)
|
|
59
|
+
], ActionPlan.prototype, "params", void 0);
|
|
60
|
+
tslib_1.__decorate([
|
|
61
|
+
(0, type_graphql_1.Field)(() => issue_1.Issue),
|
|
62
|
+
(0, typeorm_1.ManyToOne)(() => issue_1.Issue, issue => issue.actionPlans),
|
|
63
|
+
tslib_1.__metadata("design:type", issue_1.Issue)
|
|
64
|
+
], ActionPlan.prototype, "issue", void 0);
|
|
65
|
+
tslib_1.__decorate([
|
|
66
|
+
(0, typeorm_1.Column)({ nullable: true }),
|
|
67
|
+
(0, type_graphql_1.Field)({ nullable: true }),
|
|
68
|
+
tslib_1.__metadata("design:type", String)
|
|
69
|
+
], ActionPlan.prototype, "content", void 0);
|
|
70
|
+
tslib_1.__decorate([
|
|
71
|
+
(0, typeorm_1.CreateDateColumn)(),
|
|
72
|
+
(0, type_graphql_1.Field)({ nullable: true }),
|
|
73
|
+
tslib_1.__metadata("design:type", Date)
|
|
74
|
+
], ActionPlan.prototype, "createdAt", void 0);
|
|
75
|
+
tslib_1.__decorate([
|
|
76
|
+
(0, typeorm_1.UpdateDateColumn)(),
|
|
77
|
+
(0, type_graphql_1.Field)({ nullable: true }),
|
|
78
|
+
tslib_1.__metadata("design:type", Date)
|
|
79
|
+
], ActionPlan.prototype, "updatedAt", void 0);
|
|
80
|
+
tslib_1.__decorate([
|
|
81
|
+
(0, typeorm_1.DeleteDateColumn)(),
|
|
82
|
+
(0, type_graphql_1.Field)({ nullable: true }),
|
|
83
|
+
tslib_1.__metadata("design:type", Date)
|
|
84
|
+
], ActionPlan.prototype, "deletedAt", void 0);
|
|
85
|
+
tslib_1.__decorate([
|
|
86
|
+
(0, typeorm_1.ManyToOne)(type => auth_base_1.User, { nullable: true }),
|
|
87
|
+
(0, type_graphql_1.Field)(type => auth_base_1.User, { nullable: true }),
|
|
88
|
+
tslib_1.__metadata("design:type", auth_base_1.User)
|
|
89
|
+
], ActionPlan.prototype, "creator", void 0);
|
|
90
|
+
tslib_1.__decorate([
|
|
91
|
+
(0, typeorm_1.RelationId)((actionPlan) => actionPlan.creator),
|
|
92
|
+
tslib_1.__metadata("design:type", String)
|
|
93
|
+
], ActionPlan.prototype, "creatorId", void 0);
|
|
94
|
+
tslib_1.__decorate([
|
|
95
|
+
(0, typeorm_1.ManyToOne)(type => auth_base_1.User, { nullable: true }),
|
|
96
|
+
(0, type_graphql_1.Field)(type => auth_base_1.User, { nullable: true }),
|
|
97
|
+
tslib_1.__metadata("design:type", auth_base_1.User)
|
|
98
|
+
], ActionPlan.prototype, "updater", void 0);
|
|
99
|
+
tslib_1.__decorate([
|
|
100
|
+
(0, typeorm_1.RelationId)((actionPlan) => actionPlan.updater),
|
|
101
|
+
tslib_1.__metadata("design:type", String)
|
|
102
|
+
], ActionPlan.prototype, "updaterId", void 0);
|
|
103
|
+
tslib_1.__decorate([
|
|
104
|
+
(0, type_graphql_1.Field)(type => String, { nullable: true }),
|
|
105
|
+
tslib_1.__metadata("design:type", String)
|
|
106
|
+
], ActionPlan.prototype, "thumbnail", void 0);
|
|
107
|
+
ActionPlan = tslib_1.__decorate([
|
|
108
|
+
(0, typeorm_1.Entity)(),
|
|
109
|
+
(0, typeorm_1.Index)('ix_action_plan_0', (actionPlan) => [actionPlan.domain, actionPlan.name], {
|
|
110
|
+
unique: true,
|
|
111
|
+
where: '"deleted_at" IS NULL'
|
|
112
|
+
}),
|
|
113
|
+
(0, type_graphql_1.ObjectType)({ description: 'Entity for ActionPlan' })
|
|
114
|
+
], ActionPlan);
|
|
115
|
+
exports.ActionPlan = ActionPlan;
|
|
116
|
+
//# sourceMappingURL=action-plan.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"action-plan.js","sourceRoot":"","sources":["../../../server/service/action-plan/action-plan.ts"],"names":[],"mappings":";;;;AAAA,qCAWgB;AAChB,+CAA2E;AAE3E,iDAA8C;AAC9C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IAC3C,IAAA,oBAAK,EAAC,IAAI,CAAC,EAAE,CAAC,gBAAI,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;sCAC9B,gBAAI;2CAAA;AAEd;IAAC,IAAA,oBAAU,EAAC,CAAC,UAAsB,EAAE,EAAE,CAAC,UAAU,CAAC,OAAO,CAAC;;6CACzC;AAElB;IAAC,IAAA,oBAAK,EAAC,IAAI,CAAC,EAAE,CAAC,MAAM,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;;6CACxB;AAnEP,UAAU;IANtB,IAAA,gBAAM,GAAE;IACR,IAAA,eAAK,EAAC,kBAAkB,EAAE,CAAC,UAAsB,EAAE,EAAE,CAAC,CAAC,UAAU,CAAC,MAAM,EAAE,UAAU,CAAC,IAAI,CAAC,EAAE;QAC3F,MAAM,EAAE,IAAI;QACZ,KAAK,EAAE,sBAAsB;KAC9B,CAAC;IACD,IAAA,yBAAU,EAAC,EAAE,WAAW,EAAE,uBAAuB,EAAE,CAAC;GACxC,UAAU,CAoEtB;AApEY,gCAAU","sourcesContent":["import {\n CreateDateColumn,\n UpdateDateColumn,\n DeleteDateColumn,\n Entity,\n Index,\n Column,\n RelationId,\n ManyToOne,\n PrimaryGeneratedColumn,\n VersionColumn\n} from 'typeorm'\nimport { ObjectType, Field, Int, ID, registerEnumType } from 'type-graphql'\n\nimport { Domain } from '@things-factory/shell'\nimport { User } from '@things-factory/auth-base'\nimport { Issue } from '../issue/issue'\n\nexport enum ActionPlanStatus {\n STATUS_A = 'STATUS_A',\n STATUS_B = 'STATUS_B'\n}\n\nregisterEnumType(ActionPlanStatus, {\n name: 'ActionPlanStatus',\n description: 'state enumeration of a actionPlan'\n})\n\n@Entity()\n@Index('ix_action_plan_0', (actionPlan: ActionPlan) => [actionPlan.domain, actionPlan.name], {\n unique: true,\n where: '\"deleted_at\" IS NULL'\n})\n@ObjectType({ description: 'Entity for ActionPlan' })\nexport class ActionPlan {\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((actionPlan: ActionPlan) => actionPlan.domain)\n domainId?: string\n\n @Column()\n @Field({ nullable: true })\n name?: string\n\n @Column({ nullable: true })\n @Field({ nullable: true })\n description?: string\n\n @Column({ nullable: true })\n @Field({ nullable: true })\n active?: boolean\n\n @Column({ nullable: true })\n @Field({ nullable: true })\n state?: ActionPlanStatus\n\n @Column({ nullable: true })\n @Field({ nullable: true })\n params?: string\n\n @Field(() => Issue)\n @ManyToOne(() => Issue, issue => issue.actionPlans)\n issue: Issue\n\n @Column({ nullable: true })\n @Field({ nullable: true })\n content: 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((actionPlan: ActionPlan) => actionPlan.creator)\n creatorId?: string\n\n @ManyToOne(type => User, { nullable: true })\n @Field(type => User, { nullable: true })\n updater?: User\n\n @RelationId((actionPlan: ActionPlan) => actionPlan.updater)\n updaterId?: string\n\n @Field(type => String, { nullable: true })\n thumbnail?: string\n}\n"]}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.subscribers = exports.resolvers = exports.entities = void 0;
|
|
4
|
+
const action_plan_1 = require("./action-plan");
|
|
5
|
+
const action_plan_query_1 = require("./action-plan-query");
|
|
6
|
+
const action_plan_mutation_1 = require("./action-plan-mutation");
|
|
7
|
+
exports.entities = [action_plan_1.ActionPlan];
|
|
8
|
+
exports.resolvers = [action_plan_query_1.ActionPlanQuery, action_plan_mutation_1.ActionPlanMutation];
|
|
9
|
+
exports.subscribers = [];
|
|
10
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../server/service/action-plan/index.ts"],"names":[],"mappings":";;;AAAA,+CAA0C;AAC1C,2DAAqD;AACrD,iEAA2D;AAE9C,QAAA,QAAQ,GAAG,CAAC,wBAAU,CAAC,CAAA;AACvB,QAAA,SAAS,GAAG,CAAC,mCAAe,EAAE,yCAAkB,CAAC,CAAA;AACjD,QAAA,WAAW,GAAG,EAAE,CAAA","sourcesContent":["import { ActionPlan } from './action-plan'\nimport { ActionPlanQuery } from './action-plan-query'\nimport { ActionPlanMutation } from './action-plan-mutation'\n\nexport const entities = [ActionPlan]\nexport const resolvers = [ActionPlanQuery, ActionPlanMutation]\nexport const subscribers = []\n"]}
|
|
@@ -0,0 +1,168 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.CheckItemMutation = 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 check_item_1 = require("./check-item");
|
|
9
|
+
const check_item_type_1 = require("./check-item-type");
|
|
10
|
+
let CheckItemMutation = class CheckItemMutation {
|
|
11
|
+
async createCheckItem(checkItem, context) {
|
|
12
|
+
const { domain, user, tx } = context.state;
|
|
13
|
+
const result = await tx.getRepository(check_item_1.CheckItem).save(Object.assign(Object.assign({}, checkItem), { domain, creator: user, updater: user }));
|
|
14
|
+
if (checkItem.thumbnail) {
|
|
15
|
+
await (0, attachment_base_1.createAttachment)(null, {
|
|
16
|
+
attachment: {
|
|
17
|
+
file: checkItem.thumbnail,
|
|
18
|
+
refType: check_item_1.CheckItem.name,
|
|
19
|
+
refBy: result.id
|
|
20
|
+
}
|
|
21
|
+
}, context);
|
|
22
|
+
}
|
|
23
|
+
return result;
|
|
24
|
+
}
|
|
25
|
+
async updateCheckItem(id, patch, context) {
|
|
26
|
+
const { domain, user, tx } = context.state;
|
|
27
|
+
const repository = tx.getRepository(check_item_1.CheckItem);
|
|
28
|
+
const checkItem = await repository.findOne({
|
|
29
|
+
where: { domain: { id: domain.id }, id }
|
|
30
|
+
});
|
|
31
|
+
const result = await repository.save(Object.assign(Object.assign(Object.assign({}, checkItem), patch), { updater: user }));
|
|
32
|
+
if (patch.thumbnail) {
|
|
33
|
+
await (0, attachment_base_1.deleteAttachmentsByRef)(null, { refBys: [result.id] }, context);
|
|
34
|
+
await (0, attachment_base_1.createAttachment)(null, {
|
|
35
|
+
attachment: {
|
|
36
|
+
file: patch.thumbnail,
|
|
37
|
+
refType: check_item_1.CheckItem.name,
|
|
38
|
+
refBy: result.id
|
|
39
|
+
}
|
|
40
|
+
}, context);
|
|
41
|
+
}
|
|
42
|
+
return result;
|
|
43
|
+
}
|
|
44
|
+
async updateMultipleCheckItem(patches, context) {
|
|
45
|
+
const { domain, user, tx } = context.state;
|
|
46
|
+
let results = [];
|
|
47
|
+
const _createRecords = patches.filter((patch) => patch.cuFlag.toUpperCase() === '+');
|
|
48
|
+
const _updateRecords = patches.filter((patch) => patch.cuFlag.toUpperCase() === 'M');
|
|
49
|
+
const checkItemRepo = tx.getRepository(check_item_1.CheckItem);
|
|
50
|
+
if (_createRecords.length > 0) {
|
|
51
|
+
for (let i = 0; i < _createRecords.length; i++) {
|
|
52
|
+
const newRecord = _createRecords[i];
|
|
53
|
+
const result = await checkItemRepo.save(Object.assign(Object.assign({}, newRecord), { domain, creator: user, updater: user }));
|
|
54
|
+
if (newRecord.thumbnail) {
|
|
55
|
+
await (0, attachment_base_1.createAttachment)(null, {
|
|
56
|
+
attachment: {
|
|
57
|
+
file: newRecord.thumbnail,
|
|
58
|
+
refType: check_item_1.CheckItem.name,
|
|
59
|
+
refBy: result.id
|
|
60
|
+
}
|
|
61
|
+
}, context);
|
|
62
|
+
}
|
|
63
|
+
results.push(Object.assign(Object.assign({}, result), { cuFlag: '+' }));
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
if (_updateRecords.length > 0) {
|
|
67
|
+
for (let i = 0; i < _updateRecords.length; i++) {
|
|
68
|
+
const updateRecord = _updateRecords[i];
|
|
69
|
+
const checkItem = await checkItemRepo.findOneBy({ id: updateRecord.id });
|
|
70
|
+
const result = await checkItemRepo.save(Object.assign(Object.assign(Object.assign({}, checkItem), updateRecord), { updater: user }));
|
|
71
|
+
if (updateRecord.thumbnail) {
|
|
72
|
+
await (0, attachment_base_1.deleteAttachmentsByRef)(null, { refBys: [result.id] }, context);
|
|
73
|
+
await (0, attachment_base_1.createAttachment)(null, {
|
|
74
|
+
attachment: {
|
|
75
|
+
file: updateRecord.thumbnail,
|
|
76
|
+
refType: check_item_1.CheckItem.name,
|
|
77
|
+
refBy: result.id
|
|
78
|
+
}
|
|
79
|
+
}, context);
|
|
80
|
+
}
|
|
81
|
+
results.push(Object.assign(Object.assign({}, result), { cuFlag: 'M' }));
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
return results;
|
|
85
|
+
}
|
|
86
|
+
async deleteCheckItem(id, context) {
|
|
87
|
+
const { domain, tx } = context.state;
|
|
88
|
+
await tx.getRepository(check_item_1.CheckItem).delete({ domain: { id: domain.id }, id });
|
|
89
|
+
await (0, attachment_base_1.deleteAttachmentsByRef)(null, { refBys: [id] }, context);
|
|
90
|
+
return true;
|
|
91
|
+
}
|
|
92
|
+
async deleteCheckItems(ids, context) {
|
|
93
|
+
const { domain, tx } = context.state;
|
|
94
|
+
await tx.getRepository(check_item_1.CheckItem).delete({
|
|
95
|
+
domain: { id: domain.id },
|
|
96
|
+
id: (0, typeorm_1.In)(ids)
|
|
97
|
+
});
|
|
98
|
+
await (0, attachment_base_1.deleteAttachmentsByRef)(null, { refBys: ids }, context);
|
|
99
|
+
return true;
|
|
100
|
+
}
|
|
101
|
+
async importCheckItems(checkItems, context) {
|
|
102
|
+
const { domain, tx } = context.state;
|
|
103
|
+
await Promise.all(checkItems.map(async (checkItem) => {
|
|
104
|
+
const createdCheckItem = await tx.getRepository(check_item_1.CheckItem).save(Object.assign({ domain }, checkItem));
|
|
105
|
+
}));
|
|
106
|
+
return true;
|
|
107
|
+
}
|
|
108
|
+
};
|
|
109
|
+
tslib_1.__decorate([
|
|
110
|
+
(0, type_graphql_1.Directive)('@transaction'),
|
|
111
|
+
(0, type_graphql_1.Mutation)(returns => check_item_1.CheckItem, { description: 'To create new CheckItem' }),
|
|
112
|
+
tslib_1.__param(0, (0, type_graphql_1.Arg)('checkItem')),
|
|
113
|
+
tslib_1.__param(1, (0, type_graphql_1.Ctx)()),
|
|
114
|
+
tslib_1.__metadata("design:type", Function),
|
|
115
|
+
tslib_1.__metadata("design:paramtypes", [check_item_type_1.NewCheckItem, Object]),
|
|
116
|
+
tslib_1.__metadata("design:returntype", Promise)
|
|
117
|
+
], CheckItemMutation.prototype, "createCheckItem", null);
|
|
118
|
+
tslib_1.__decorate([
|
|
119
|
+
(0, type_graphql_1.Directive)('@transaction'),
|
|
120
|
+
(0, type_graphql_1.Mutation)(returns => check_item_1.CheckItem, { description: 'To modify CheckItem information' }),
|
|
121
|
+
tslib_1.__param(0, (0, type_graphql_1.Arg)('id')),
|
|
122
|
+
tslib_1.__param(1, (0, type_graphql_1.Arg)('patch')),
|
|
123
|
+
tslib_1.__param(2, (0, type_graphql_1.Ctx)()),
|
|
124
|
+
tslib_1.__metadata("design:type", Function),
|
|
125
|
+
tslib_1.__metadata("design:paramtypes", [String, check_item_type_1.CheckItemPatch, Object]),
|
|
126
|
+
tslib_1.__metadata("design:returntype", Promise)
|
|
127
|
+
], CheckItemMutation.prototype, "updateCheckItem", null);
|
|
128
|
+
tslib_1.__decorate([
|
|
129
|
+
(0, type_graphql_1.Directive)('@transaction'),
|
|
130
|
+
(0, type_graphql_1.Mutation)(returns => [check_item_1.CheckItem], { description: "To modify multiple CheckItems' information" }),
|
|
131
|
+
tslib_1.__param(0, (0, type_graphql_1.Arg)('patches', type => [check_item_type_1.CheckItemPatch])),
|
|
132
|
+
tslib_1.__param(1, (0, type_graphql_1.Ctx)()),
|
|
133
|
+
tslib_1.__metadata("design:type", Function),
|
|
134
|
+
tslib_1.__metadata("design:paramtypes", [Array, Object]),
|
|
135
|
+
tslib_1.__metadata("design:returntype", Promise)
|
|
136
|
+
], CheckItemMutation.prototype, "updateMultipleCheckItem", null);
|
|
137
|
+
tslib_1.__decorate([
|
|
138
|
+
(0, type_graphql_1.Directive)('@transaction'),
|
|
139
|
+
(0, type_graphql_1.Mutation)(returns => Boolean, { description: 'To delete CheckItem' }),
|
|
140
|
+
tslib_1.__param(0, (0, type_graphql_1.Arg)('id')),
|
|
141
|
+
tslib_1.__param(1, (0, type_graphql_1.Ctx)()),
|
|
142
|
+
tslib_1.__metadata("design:type", Function),
|
|
143
|
+
tslib_1.__metadata("design:paramtypes", [String, Object]),
|
|
144
|
+
tslib_1.__metadata("design:returntype", Promise)
|
|
145
|
+
], CheckItemMutation.prototype, "deleteCheckItem", null);
|
|
146
|
+
tslib_1.__decorate([
|
|
147
|
+
(0, type_graphql_1.Directive)('@transaction'),
|
|
148
|
+
(0, type_graphql_1.Mutation)(returns => Boolean, { description: 'To delete multiple CheckItems' }),
|
|
149
|
+
tslib_1.__param(0, (0, type_graphql_1.Arg)('ids', type => [String])),
|
|
150
|
+
tslib_1.__param(1, (0, type_graphql_1.Ctx)()),
|
|
151
|
+
tslib_1.__metadata("design:type", Function),
|
|
152
|
+
tslib_1.__metadata("design:paramtypes", [Array, Object]),
|
|
153
|
+
tslib_1.__metadata("design:returntype", Promise)
|
|
154
|
+
], CheckItemMutation.prototype, "deleteCheckItems", null);
|
|
155
|
+
tslib_1.__decorate([
|
|
156
|
+
(0, type_graphql_1.Directive)('@transaction'),
|
|
157
|
+
(0, type_graphql_1.Mutation)(returns => Boolean, { description: 'To import multiple CheckItems' }),
|
|
158
|
+
tslib_1.__param(0, (0, type_graphql_1.Arg)('checkItems', type => [check_item_type_1.CheckItemPatch])),
|
|
159
|
+
tslib_1.__param(1, (0, type_graphql_1.Ctx)()),
|
|
160
|
+
tslib_1.__metadata("design:type", Function),
|
|
161
|
+
tslib_1.__metadata("design:paramtypes", [Array, Object]),
|
|
162
|
+
tslib_1.__metadata("design:returntype", Promise)
|
|
163
|
+
], CheckItemMutation.prototype, "importCheckItems", null);
|
|
164
|
+
CheckItemMutation = tslib_1.__decorate([
|
|
165
|
+
(0, type_graphql_1.Resolver)(check_item_1.CheckItem)
|
|
166
|
+
], CheckItemMutation);
|
|
167
|
+
exports.CheckItemMutation = CheckItemMutation;
|
|
168
|
+
//# sourceMappingURL=check-item-mutation.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"check-item-mutation.js","sourceRoot":"","sources":["../../../server/service/check-item/check-item-mutation.ts"],"names":[],"mappings":";;;;AAAA,+CAAsE;AACtE,qCAA4B;AAE5B,qEAA0F;AAE1F,6CAAwC;AACxC,uDAAgE;AAGzD,IAAM,iBAAiB,GAAvB,MAAM,iBAAiB;IAGtB,AAAN,KAAK,CAAC,eAAe,CAAmB,SAAuB,EAAS,OAAwB;QAC9F,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,EAAE,EAAE,GAAG,OAAO,CAAC,KAAK,CAAA;QAE1C,MAAM,MAAM,GAAG,MAAM,EAAE,CAAC,aAAa,CAAC,sBAAS,CAAC,CAAC,IAAI,iCAChD,SAAS,KACZ,MAAM,EACN,OAAO,EAAE,IAAI,EACb,OAAO,EAAE,IAAI,IACb,CAAA;QAEF,IAAI,SAAS,CAAC,SAAS,EAAE;YACvB,MAAM,IAAA,kCAAgB,EACpB,IAAI,EACJ;gBACE,UAAU,EAAE;oBACV,IAAI,EAAE,SAAS,CAAC,SAAS;oBACzB,OAAO,EAAE,sBAAS,CAAC,IAAI;oBACvB,KAAK,EAAE,MAAM,CAAC,EAAE;iBACjB;aACF,EACD,OAAO,CACR,CAAA;SACF;QAED,OA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LY,8CAAiB","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 { CheckItem } from './check-item'\nimport { NewCheckItem, CheckItemPatch } from './check-item-type'\n\n@Resolver(CheckItem)\nexport class CheckItemMutation {\n @Directive('@transaction')\n @Mutation(returns => CheckItem, { description: 'To create new CheckItem' })\n async createCheckItem(@Arg('checkItem') checkItem: NewCheckItem, @Ctx() context: ResolverContext): Promise<CheckItem> {\n const { domain, user, tx } = context.state\n\n const result = await tx.getRepository(CheckItem).save({\n ...checkItem,\n domain,\n creator: user,\n updater: user\n })\n\n if (checkItem.thumbnail) {\n await createAttachment(\n null,\n {\n attachment: {\n file: checkItem.thumbnail,\n refType: CheckItem.name,\n refBy: result.id\n }\n },\n context\n )\n }\n\n return result\n }\n\n @Directive('@transaction')\n @Mutation(returns => CheckItem, { description: 'To modify CheckItem information' })\n async updateCheckItem(\n @Arg('id') id: string,\n @Arg('patch') patch: CheckItemPatch,\n @Ctx() context: ResolverContext\n ): Promise<CheckItem> {\n const { domain, user, tx } = context.state\n\n const repository = tx.getRepository(CheckItem)\n const checkItem = await repository.findOne({\n where: { domain: { id: domain.id }, id }\n })\n\n const result = await repository.save({\n ...checkItem,\n ...patch,\n updater: user\n })\n\n if (patch.thumbnail) {\n await deleteAttachmentsByRef(null, { refBys: [result.id] }, context)\n await createAttachment(\n null,\n {\n attachment: {\n file: patch.thumbnail,\n refType: CheckItem.name,\n refBy: result.id\n }\n },\n context\n )\n }\n\n return result\n }\n\n @Directive('@transaction')\n @Mutation(returns => [CheckItem], { description: \"To modify multiple CheckItems' information\" })\n async updateMultipleCheckItem(\n @Arg('patches', type => [CheckItemPatch]) patches: CheckItemPatch[],\n @Ctx() context: ResolverContext\n ): Promise<CheckItem[]> {\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 checkItemRepo = tx.getRepository(CheckItem)\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 checkItemRepo.save({\n ...newRecord,\n domain,\n creator: user,\n updater: user\n })\n\n if (newRecord.thumbnail) {\n await createAttachment(\n null,\n {\n attachment: {\n file: newRecord.thumbnail,\n refType: CheckItem.name,\n refBy: result.id\n }\n },\n context\n )\n }\n\n results.push({ ...result, cuFlag: '+' })\n }\n }\n\n if (_updateRecords.length > 0) {\n for (let i = 0; i < _updateRecords.length; i++) {\n const updateRecord = _updateRecords[i]\n const checkItem = await checkItemRepo.findOneBy({ id: updateRecord.id })\n\n const result = await checkItemRepo.save({\n ...checkItem,\n ...updateRecord,\n updater: user\n })\n\n if (updateRecord.thumbnail) {\n await deleteAttachmentsByRef(null, { refBys: [result.id] }, context)\n await createAttachment(\n null,\n {\n attachment: {\n file: updateRecord.thumbnail,\n refType: CheckItem.name,\n refBy: result.id\n }\n },\n context\n )\n }\n\n results.push({ ...result, cuFlag: 'M' })\n }\n }\n\n return results\n }\n\n @Directive('@transaction')\n @Mutation(returns => Boolean, { description: 'To delete CheckItem' })\n async deleteCheckItem(@Arg('id') id: string, @Ctx() context: ResolverContext): Promise<boolean> {\n const { domain, tx } = context.state\n\n await tx.getRepository(CheckItem).delete({ domain: { id: domain.id }, id })\n await deleteAttachmentsByRef(null, { refBys: [id] }, context)\n\n return true\n }\n\n @Directive('@transaction')\n @Mutation(returns => Boolean, { description: 'To delete multiple CheckItems' })\n async deleteCheckItems(\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(CheckItem).delete({\n domain: { id: domain.id },\n id: In(ids)\n })\n\n await deleteAttachmentsByRef(null, { refBys: ids }, context)\n\n return true\n }\n\n @Directive('@transaction')\n @Mutation(returns => Boolean, { description: 'To import multiple CheckItems' })\n async importCheckItems(\n @Arg('checkItems', type => [CheckItemPatch]) checkItems: CheckItemPatch[],\n @Ctx() context: ResolverContext\n ): Promise<boolean> {\n const { domain, tx } = context.state\n\n await Promise.all(\n checkItems.map(async (checkItem: CheckItemPatch) => {\n const createdCheckItem: CheckItem = await tx.getRepository(CheckItem).save({ domain, ...checkItem })\n })\n )\n\n return true\n }\n}\n"]}
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.CheckItemQuery = 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 check_item_1 = require("./check-item");
|
|
10
|
+
const check_item_type_1 = require("./check-item-type");
|
|
11
|
+
let CheckItemQuery = class CheckItemQuery {
|
|
12
|
+
async checkItem(id, context) {
|
|
13
|
+
const { domain } = context.state;
|
|
14
|
+
return await (0, shell_1.getRepository)(check_item_1.CheckItem).findOne({
|
|
15
|
+
where: { domain: { id: domain.id }, id }
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
async checkItems(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)(check_item_1.CheckItem),
|
|
24
|
+
searchables: ['name', 'description']
|
|
25
|
+
});
|
|
26
|
+
const [items, total] = await queryBuilder.getManyAndCount();
|
|
27
|
+
return { items, total };
|
|
28
|
+
}
|
|
29
|
+
async thumbnail(checkItem) {
|
|
30
|
+
const attachment = await (0, shell_1.getRepository)(attachment_base_1.Attachment).findOne({
|
|
31
|
+
where: {
|
|
32
|
+
domain: { id: checkItem.domainId },
|
|
33
|
+
refType: check_item_1.CheckItem.name,
|
|
34
|
+
refBy: checkItem.id
|
|
35
|
+
}
|
|
36
|
+
});
|
|
37
|
+
return attachment === null || attachment === void 0 ? void 0 : attachment.fullpath;
|
|
38
|
+
}
|
|
39
|
+
async domain(checkItem) {
|
|
40
|
+
return await (0, shell_1.getRepository)(shell_1.Domain).findOneBy({ id: checkItem.domainId });
|
|
41
|
+
}
|
|
42
|
+
async updater(checkItem) {
|
|
43
|
+
return await (0, shell_1.getRepository)(auth_base_1.User).findOneBy({ id: checkItem.updaterId });
|
|
44
|
+
}
|
|
45
|
+
async creator(checkItem) {
|
|
46
|
+
return await (0, shell_1.getRepository)(auth_base_1.User).findOneBy({ id: checkItem.creatorId });
|
|
47
|
+
}
|
|
48
|
+
};
|
|
49
|
+
tslib_1.__decorate([
|
|
50
|
+
(0, type_graphql_1.Query)(returns => check_item_1.CheckItem, { nullable: true, description: 'To fetch a CheckItem' }),
|
|
51
|
+
tslib_1.__param(0, (0, type_graphql_1.Arg)('id')),
|
|
52
|
+
tslib_1.__param(1, (0, type_graphql_1.Ctx)()),
|
|
53
|
+
tslib_1.__metadata("design:type", Function),
|
|
54
|
+
tslib_1.__metadata("design:paramtypes", [String, Object]),
|
|
55
|
+
tslib_1.__metadata("design:returntype", Promise)
|
|
56
|
+
], CheckItemQuery.prototype, "checkItem", null);
|
|
57
|
+
tslib_1.__decorate([
|
|
58
|
+
(0, type_graphql_1.Query)(returns => check_item_type_1.CheckItemList, { description: 'To fetch multiple CheckItems' }),
|
|
59
|
+
tslib_1.__param(0, (0, type_graphql_1.Args)()),
|
|
60
|
+
tslib_1.__param(1, (0, type_graphql_1.Ctx)()),
|
|
61
|
+
tslib_1.__metadata("design:type", Function),
|
|
62
|
+
tslib_1.__metadata("design:paramtypes", [shell_1.ListParam, Object]),
|
|
63
|
+
tslib_1.__metadata("design:returntype", Promise)
|
|
64
|
+
], CheckItemQuery.prototype, "checkItems", null);
|
|
65
|
+
tslib_1.__decorate([
|
|
66
|
+
(0, type_graphql_1.FieldResolver)(type => String),
|
|
67
|
+
tslib_1.__param(0, (0, type_graphql_1.Root)()),
|
|
68
|
+
tslib_1.__metadata("design:type", Function),
|
|
69
|
+
tslib_1.__metadata("design:paramtypes", [check_item_1.CheckItem]),
|
|
70
|
+
tslib_1.__metadata("design:returntype", Promise)
|
|
71
|
+
], CheckItemQuery.prototype, "thumbnail", null);
|
|
72
|
+
tslib_1.__decorate([
|
|
73
|
+
(0, type_graphql_1.FieldResolver)(type => shell_1.Domain),
|
|
74
|
+
tslib_1.__param(0, (0, type_graphql_1.Root)()),
|
|
75
|
+
tslib_1.__metadata("design:type", Function),
|
|
76
|
+
tslib_1.__metadata("design:paramtypes", [check_item_1.CheckItem]),
|
|
77
|
+
tslib_1.__metadata("design:returntype", Promise)
|
|
78
|
+
], CheckItemQuery.prototype, "domain", null);
|
|
79
|
+
tslib_1.__decorate([
|
|
80
|
+
(0, type_graphql_1.FieldResolver)(type => auth_base_1.User),
|
|
81
|
+
tslib_1.__param(0, (0, type_graphql_1.Root)()),
|
|
82
|
+
tslib_1.__metadata("design:type", Function),
|
|
83
|
+
tslib_1.__metadata("design:paramtypes", [check_item_1.CheckItem]),
|
|
84
|
+
tslib_1.__metadata("design:returntype", Promise)
|
|
85
|
+
], CheckItemQuery.prototype, "updater", null);
|
|
86
|
+
tslib_1.__decorate([
|
|
87
|
+
(0, type_graphql_1.FieldResolver)(type => auth_base_1.User),
|
|
88
|
+
tslib_1.__param(0, (0, type_graphql_1.Root)()),
|
|
89
|
+
tslib_1.__metadata("design:type", Function),
|
|
90
|
+
tslib_1.__metadata("design:paramtypes", [check_item_1.CheckItem]),
|
|
91
|
+
tslib_1.__metadata("design:returntype", Promise)
|
|
92
|
+
], CheckItemQuery.prototype, "creator", null);
|
|
93
|
+
CheckItemQuery = tslib_1.__decorate([
|
|
94
|
+
(0, type_graphql_1.Resolver)(check_item_1.CheckItem)
|
|
95
|
+
], CheckItemQuery);
|
|
96
|
+
exports.CheckItemQuery = CheckItemQuery;
|
|
97
|
+
//# sourceMappingURL=check-item-query.js.map
|