@things-factory/work-shift 5.0.11 → 6.0.0-alpha.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist-server/controllers/index.js +2 -2
- package/dist-server/controllers/index.js.map +1 -1
- package/dist-server/service/work-shift/work-shift-mutation.js +1 -1
- package/dist-server/service/work-shift/work-shift-mutation.js.map +1 -1
- package/dist-server/service/work-shift/work-shift-query.js +7 -9
- package/dist-server/service/work-shift/work-shift-query.js.map +1 -1
- package/dist-server/service/work-shift/work-shift.js +3 -4
- package/dist-server/service/work-shift/work-shift.js.map +1 -1
- package/dist-server/tsconfig.tsbuildinfo +1 -1
- package/package.json +6 -6
- package/server/controllers/index.ts +1 -2
- package/server/service/work-shift/work-shift-mutation.ts +8 -4
- package/server/service/work-shift/work-shift-query.ts +9 -7
|
@@ -3,8 +3,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.getWorkDateAndShift = void 0;
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
5
|
const moment_timezone_1 = tslib_1.__importDefault(require("moment-timezone"));
|
|
6
|
-
const typeorm_1 = require("typeorm");
|
|
7
6
|
const env_1 = require("@things-factory/env");
|
|
7
|
+
const shell_1 = require("@things-factory/shell");
|
|
8
8
|
const work_shift_1 = require("../service/work-shift/work-shift");
|
|
9
9
|
function between(fromDate, fromTime /* hh:mm */, toDate, toTime /* hh:mm */, theDay, dateTime) {
|
|
10
10
|
const convertedFromDate = new Date(theDay.getTime() + fromDate * (24 * 60 * 60 * 1000));
|
|
@@ -21,7 +21,7 @@ async function getWorkDateAndShift(domain, dateTime, options) {
|
|
|
21
21
|
const localDate = new Date(givenDate.format('YYYY-MM-DD HH:mm:ss'));
|
|
22
22
|
const workDate = givenDate.format(format);
|
|
23
23
|
/* 1. get work-shift list for the domain */
|
|
24
|
-
const workShifts = await (0,
|
|
24
|
+
const workShifts = await (0, shell_1.getRepository)(work_shift_1.WorkShift).find({
|
|
25
25
|
where: {
|
|
26
26
|
domain
|
|
27
27
|
},
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../server/controllers/index.ts"],"names":[],"mappings":";;;;AAAA,8EAAoC;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../server/controllers/index.ts"],"names":[],"mappings":";;;;AAAA,8EAAoC;AAEpC,6CAA4C;AAC5C,iDAA6D;AAE7D,iEAA+E;AAG/E,SAAS,OAAO,CACd,QAA2B,EAC3B,QAAgB,CAAC,WAAW,EAC5B,MAAyB,EACzB,MAAc,CAAC,WAAW,EAC1B,MAAY,EACZ,QAAc;IAEd,MAAM,iBAAiB,GAAG,IAAI,IAAI,CAAC,MAAM,CAAC,OAAO,EAAE,GAAG,QAAQ,GAAG,CAAC,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,IAAI,CAAC,CAAC,CAAA;IACvF,MAAM,eAAe,GAAG,IAAI,IAAI,CAAC,MAAM,CAAC,OAAO,EAAE,GAAG,MAAM,GAAG,CAAC,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,IAAI,CAAC,CAAC,CAAA;IACnF,MAAM,IAAI,GAAG,IAAI,IAAI,CAAC,GAAG,iBAAiB,CAAC,WAAW,EAAE,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,IAAI,QAAQ,EAAE,CAAC,CAAA;IACrF,MAAM,EAAE,GAAG,IAAI,IAAI,CAAC,GAAG,eAAe,CAAC,WAAW,EAAE,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,IAAI,MAAM,EAAE,CAAC,CAAA;IAE/E,OAAO,QAAQ,IAAI,IAAI,IAAI,EAAE,GAAG,QAAQ,CAAA;AAC1C,CAAC;AAEM,KAAK,UAAU,mBAAmB,CACvC,MAAc,EACd,QAAc,EACd,OAAa;IAEb,MAAM,WAAW,mBAAK,QAAQ,EAAE,MAAM,CAAC,QAAQ,IAA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AAC,CAAC,CAAA;YAEtB,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,UAAU,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE;gBAC1C,MAAM,EAAE,IAAI,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,EAAE,GAAG,UAAU,CAAC,CAAC,CAAC,CAAA;gBAElE,IAAI,OAAO,CAAC,QAAQ,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,SAAS,CAAC,EAAE;oBAClE,OAAO;wBACL,QAAQ;wBACR,SAAS,EAAE,IAAI;qBAChB,CAAA;iBACF;aACF;SACF;QAED,YAAM,CAAC,KAAK,CAAC,IAAI,KAAK,CAAC,iBAAiB,CAAC,CAAC,CAAA;KAC3C;IAED,+EAA+E;IAC/E,OAAO;QACL,QAAQ;QACR,SAAS,EAAE,IAAI;KAChB,CAAA;AACH,CAAC;AAtDD,kDAsDC","sourcesContent":["import moment from 'moment-timezone'\n\nimport { logger } from '@things-factory/env'\nimport { Domain, getRepository } from '@things-factory/shell'\n\nimport { WorkShift, WorkShiftDateType } from '../service/work-shift/work-shift'\nimport { WorkDateWorkShiftPair } from '../service/work-shift/work-shift-type'\n\nfunction between(\n fromDate: WorkShiftDateType,\n fromTime: string /* hh:mm */,\n toDate: WorkShiftDateType,\n toTime: string /* hh:mm */,\n theDay: Date,\n dateTime: Date\n): boolean {\n const convertedFromDate = new Date(theDay.getTime() + fromDate * (24 * 60 * 60 * 1000))\n const convertedToDate = new Date(theDay.getTime() + toDate * (24 * 60 * 60 * 1000))\n const from = new Date(`${convertedFromDate.toISOString().split('T')[0]}T${fromTime}`)\n const to = new Date(`${convertedToDate.toISOString().split('T')[0]}T${toTime}`)\n\n return dateTime >= from && to > dateTime\n}\n\nexport async function getWorkDateAndShift(\n domain: Domain,\n dateTime: Date,\n options?: any\n): Promise<WorkDateWorkShiftPair> {\n const dateOptions = { timezone: domain.timezone || 'UTC', format: 'YYYY-MM-DD', ...options }\n const { timezone, format } = dateOptions\n\n // const givenDate = dateTime.toISOString().split('T')[0]\n const givenDate = moment(dateTime).tz(timezone)\n const localDate = new Date(givenDate.format('YYYY-MM-DD HH:mm:ss'))\n const workDate = givenDate.format(format)\n /* 1. get work-shift list for the domain */\n const workShifts = await getRepository(WorkShift).find({\n where: {\n domain\n },\n order: {\n fromDate: 'ASC',\n fromTime: 'ASC'\n }\n })\n\n /* 2. compare given date-time to every work-shift */\n if (workShifts && workShifts.length > 0) {\n const theDay = new Date(givenDate.format('YYYY-MM-DD'))\n const theDayBefore = new Date(theDay.getTime() - 24 * 60 * 60 * 1000)\n const theDayAfter = new Date(theDay.getTime() + 24 * 60 * 60 * 1000)\n\n const days = [theDayBefore, theDay, theDayAfter]\n\n for (let i = 0; i < days.length; i++) {\n const theDay = days[i]\n\n for (let j = 0; j < workShifts.length; j++) {\n const { name, fromDate, fromTime, toDate, toTime } = workShifts[j]\n\n if (between(fromDate, fromTime, toDate, toTime, theDay, localDate)) {\n return {\n workDate,\n workShift: name\n }\n }\n }\n }\n\n logger.error(new Error('shift not found'))\n }\n\n /* 3. in case there are no work-shift, just give date and default shift 'NA' */\n return {\n workDate,\n workShift: 'NA'\n }\n}\n"]}
|
|
@@ -22,7 +22,7 @@ let WorkShiftMutation = class WorkShiftMutation {
|
|
|
22
22
|
async deleteWorkShifts(ids, context) {
|
|
23
23
|
const { domain, tx } = context.state;
|
|
24
24
|
await tx.getRepository(work_shift_1.WorkShift).delete({
|
|
25
|
-
domain,
|
|
25
|
+
domain: { id: domain.id },
|
|
26
26
|
id: (0, typeorm_1.In)(ids)
|
|
27
27
|
});
|
|
28
28
|
return true;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"work-shift-mutation.js","sourceRoot":"","sources":["../../../server/service/work-shift/work-shift-mutation.ts"],"names":[],"mappings":";;;;AAAA,+CAAsE;AACtE,qCAA4B;
|
|
1
|
+
{"version":3,"file":"work-shift-mutation.js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AAA;AA3CC;IAHC,IAAA,wBAAS,EAAC,iFAAiF,CAAC;IAC5F,IAAA,wBAAS,EAAC,cAAc,CAAC;IACzB,IAAA,uBAAQ,EAAC,OAAO,CAAC,EAAE,CAAC,CAAC,sBAAS,CAAC,EAAE,EAAE,WAAW,EAAE,4CAA4C,EAAE,CAAC;IAE7F,mBAAA,IAAA,kBAAG,EAAC,SAAS,EAAE,IAAI,CAAC,EAAE,CAAC,CAAC,gCAAc,CAAC,CAAC,CAAA;IACxC,mBAAA,IAAA,kBAAG,GAAE,CAAA;;;;gEAuBP;AAKD;IAHC,IAAA,wBAAS,EAAC,iFAAiF,CAAC;IAC5F,IAAA,wBAAS,EAAC,cAAc,CAAC;IACzB,IAAA,uBAAQ,EAAC,OAAO,CAAC,EAAE,CAAC,OAAO,EAAE,EAAE,WAAW,EAAE,+BAA+B,EAAE,CAAC;IAE5E,mBAAA,IAAA,kBAAG,EAAC,KAAK,EAAE,IAAI,CAAC,EAAE,CAAC,CAAC,MAAM,CAAC,CAAC,CAAA;IAC5B,mBAAA,IAAA,kBAAG,GAAE,CAAA;;;;yDAUP;AA9CU,iBAAiB;IAD7B,IAAA,uBAAQ,EAAC,sBAAS,CAAC;GACP,iBAAiB,CA+C7B;AA/CY,8CAAiB","sourcesContent":["import { Arg, Ctx, Directive, Mutation, Resolver } from 'type-graphql'\nimport { In } from 'typeorm'\n\nimport { WorkShift } from './work-shift'\nimport { WorkShiftPatch } from './work-shift-type'\n\n@Resolver(WorkShift)\nexport class WorkShiftMutation {\n @Directive('@privilege(category: \"system\", privilege: \"mutation\", domainOwnerGranted: true)')\n @Directive('@transaction')\n @Mutation(returns => [WorkShift], { description: \"To modify multiple WorkShifts' information\" })\n async updateMultipleWorkShift(\n @Arg('patches', type => [WorkShiftPatch]) patches: WorkShiftPatch[],\n @Ctx() context: ResolverContext\n ): Promise<WorkShift[]> {\n const { domain, user, tx } = context.state\n\n let results = []\n const workShiftRepo = tx.getRepository(WorkShift)\n\n await workShiftRepo.delete({ domain })\n\n for (let i = 0; i < patches.length; i++) {\n const patch = patches[i]\n\n const result = await workShiftRepo.save({\n ...patch,\n domain,\n creator: user,\n updater: user\n })\n\n results.push({ ...result, cuFlag: '+' })\n }\n\n return results\n }\n\n @Directive('@privilege(category: \"system\", privilege: \"mutation\", domainOwnerGranted: true)')\n @Directive('@transaction')\n @Mutation(returns => Boolean, { description: 'To delete multiple workShifts' })\n async deleteWorkShifts(\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(WorkShift).delete({\n domain: { id: domain.id },\n id: In(ids)\n })\n\n return true\n }\n}\n"]}
|
|
@@ -1,10 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var _a, _b;
|
|
3
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
3
|
exports.WorkShiftQuery = exports.DomainWorkShiftQuery = void 0;
|
|
5
4
|
const tslib_1 = require("tslib");
|
|
6
5
|
const type_graphql_1 = require("type-graphql");
|
|
7
|
-
const typeorm_1 = require("typeorm");
|
|
8
6
|
const auth_base_1 = require("@things-factory/auth-base");
|
|
9
7
|
const shell_1 = require("@things-factory/shell");
|
|
10
8
|
const index_1 = require("../../controllers/index");
|
|
@@ -16,7 +14,7 @@ let DomainWorkShiftQuery = class DomainWorkShiftQuery {
|
|
|
16
14
|
return await (0, index_1.getWorkDateAndShift)(domain, dateTime);
|
|
17
15
|
}
|
|
18
16
|
async workShifts(domain) {
|
|
19
|
-
return await (0,
|
|
17
|
+
return await (0, shell_1.getRepository)(work_shift_1.WorkShift).find({
|
|
20
18
|
where: {
|
|
21
19
|
domain
|
|
22
20
|
},
|
|
@@ -39,7 +37,7 @@ tslib_1.__decorate([
|
|
|
39
37
|
(0, type_graphql_1.FieldResolver)(type => [work_shift_1.WorkShift]),
|
|
40
38
|
tslib_1.__param(0, (0, type_graphql_1.Root)()),
|
|
41
39
|
tslib_1.__metadata("design:type", Function),
|
|
42
|
-
tslib_1.__metadata("design:paramtypes", [
|
|
40
|
+
tslib_1.__metadata("design:paramtypes", [shell_1.Domain]),
|
|
43
41
|
tslib_1.__metadata("design:returntype", Promise)
|
|
44
42
|
], DomainWorkShiftQuery.prototype, "workShifts", null);
|
|
45
43
|
DomainWorkShiftQuery = tslib_1.__decorate([
|
|
@@ -50,7 +48,7 @@ let WorkShiftQuery = class WorkShiftQuery {
|
|
|
50
48
|
async workShifts(params, context) {
|
|
51
49
|
const { domain } = context.state;
|
|
52
50
|
const queryBuilder = (0, shell_1.getQueryBuilderFromListParams)({
|
|
53
|
-
repository: (0,
|
|
51
|
+
repository: (0, shell_1.getRepository)(work_shift_1.WorkShift),
|
|
54
52
|
params,
|
|
55
53
|
domain
|
|
56
54
|
});
|
|
@@ -58,13 +56,13 @@ let WorkShiftQuery = class WorkShiftQuery {
|
|
|
58
56
|
return { items, total };
|
|
59
57
|
}
|
|
60
58
|
async domain(workShift) {
|
|
61
|
-
return await (0,
|
|
59
|
+
return await (0, shell_1.getRepository)(shell_1.Domain).findOneBy({ id: workShift.domainId });
|
|
62
60
|
}
|
|
63
61
|
async updater(workShift) {
|
|
64
|
-
return await (0,
|
|
62
|
+
return await (0, shell_1.getRepository)(auth_base_1.User).findOneBy({ id: workShift.updaterId });
|
|
65
63
|
}
|
|
66
64
|
async creator(workShift) {
|
|
67
|
-
return await (0,
|
|
65
|
+
return await (0, shell_1.getRepository)(auth_base_1.User).findOneBy({ id: workShift.creatorId });
|
|
68
66
|
}
|
|
69
67
|
};
|
|
70
68
|
tslib_1.__decorate([
|
|
@@ -72,7 +70,7 @@ tslib_1.__decorate([
|
|
|
72
70
|
tslib_1.__param(0, (0, type_graphql_1.Args)()),
|
|
73
71
|
tslib_1.__param(1, (0, type_graphql_1.Ctx)()),
|
|
74
72
|
tslib_1.__metadata("design:type", Function),
|
|
75
|
-
tslib_1.__metadata("design:paramtypes", [
|
|
73
|
+
tslib_1.__metadata("design:paramtypes", [shell_1.ListParam, Object]),
|
|
76
74
|
tslib_1.__metadata("design:returntype", Promise)
|
|
77
75
|
], WorkShiftQuery.prototype, "workShifts", null);
|
|
78
76
|
tslib_1.__decorate([
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"work-shift-query.js","sourceRoot":"","sources":["../../../server/service/work-shift/work-shift-query.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"work-shift-query.js","sourceRoot":"","sources":["../../../server/service/work-shift/work-shift-query.ts"],"names":[],"mappings":";;;;AAAA,+CAAmF;AAEnF,yDAAgD;AAChD,iDAAuG;AAEvG,mDAA6D;AAC7D,6CAAwC;AACxC,uDAAwE;AAGxE,IAAa,oBAAoB,GAAjC,MAAa,oBAAoB;IAE/B,KAAK,CAAC,mBAAmB,CACN,QAAc,EACxB,OAAwB;QAE/B,MAAM,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,KAAK,CAAA;QAEhC,OAAO,MAAM,IAAA,2BAAmB,EAAC,MAAM,EAAE,QAAQ,CAAC,CAAA;IACpD,CAAC;IAGD,KAAK,CAAC,UAAU,CAAS,MAAc;QACrC,OAAO,MAAM,IAAA,qBAAa,EAAC,sBAAS,CAAC,CAAC,IAAI,CAAC;YACzC,KAAK,EAAE;gBACL,MAAM;aACP;YACD,KAAK,EAAE;gBACL,QAAQ,EAAE,KAAK;gBACf,QAAQ,EAAE,KAAK;aAChB;SACF,CAAC,CAAA;IACJ,CAAC;CACF,CAAA;AArBC;IADC,IAAA,oBAAK,EAAC,OAAO,CAAC,EAAE,CAAC,uCAAqB,EAAE,EAAE,WAAW,EAAE,wDAAwD,EAAE,CAAC;IAEhH,mBAAA,IAAA,kBAAG,EAAC,UAAU,CAAC,CAAA;IACf,mBAAA,IAAA,kBAAG,GAAE,CAAA;;6CADqB,IAAI;;+DAMhC;AAGD;IADC,IAAA,4BAAa,EAAC,IAAI,CAAC,EAAE,CAAC,CAAC,sBAAS,CAAC,CAAC;IACjB,mBAAA,IA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AI,GAAE,CAAA;IAAqB,mBAAA,IAAA,kBAAG,GAAE,CAAA;;6CAAjB,iBAAS;;gDAYzC;AAGD;IADC,IAAA,4BAAa,EAAC,IAAI,CAAC,EAAE,CAAC,cAAM,CAAC;IAChB,mBAAA,IAAA,mBAAI,GAAE,CAAA;;6CAAY,sBAAS;;4CAExC;AAGD;IADC,IAAA,4BAAa,EAAC,IAAI,CAAC,EAAE,CAAC,gBAAI,CAAC;IACb,mBAAA,IAAA,mBAAI,GAAE,CAAA;;6CAAY,sBAAS;;6CAEzC;AAGD;IADC,IAAA,4BAAa,EAAC,IAAI,CAAC,EAAE,CAAC,gBAAI,CAAC;IACb,mBAAA,IAAA,mBAAI,GAAE,CAAA;;6CAAY,sBAAS;;6CAEzC;AA7BU,cAAc;IAD1B,IAAA,uBAAQ,EAAC,sBAAS,CAAC;GACP,cAAc,CA8B1B;AA9BY,wCAAc","sourcesContent":["import { Arg, Args, Ctx, FieldResolver, Query, Resolver, Root } from 'type-graphql'\n\nimport { User } from '@things-factory/auth-base'\nimport { Domain, getQueryBuilderFromListParams, getRepository, ListParam } from '@things-factory/shell'\n\nimport { getWorkDateAndShift } from '../../controllers/index'\nimport { WorkShift } from './work-shift'\nimport { WorkDateWorkShiftPair, WorkShiftList } from './work-shift-type'\n\n@Resolver(Domain)\nexport class DomainWorkShiftQuery {\n @Query(returns => WorkDateWorkShiftPair, { description: 'To fetch a work date and work shift for given datetime' })\n async getWorkDateAndShift(\n @Arg('dateTime') dateTime: Date,\n @Ctx() context: ResolverContext\n ): Promise<WorkDateWorkShiftPair> {\n const { domain } = context.state\n\n return await getWorkDateAndShift(domain, dateTime)\n }\n\n @FieldResolver(type => [WorkShift])\n async workShifts(@Root() domain: Domain): Promise<WorkShift[]> {\n return await getRepository(WorkShift).find({\n where: {\n domain\n },\n order: {\n fromDate: 'ASC',\n fromTime: 'ASC'\n }\n })\n }\n}\n\n@Resolver(WorkShift)\nexport class WorkShiftQuery {\n @Query(returns => WorkShiftList, { description: 'To fetch multiple WorkShifts' })\n async workShifts(@Args() params: ListParam, @Ctx() context: ResolverContext): Promise<WorkShiftList> {\n const { domain } = context.state\n\n const queryBuilder = getQueryBuilderFromListParams({\n repository: getRepository(WorkShift),\n params,\n domain\n })\n\n const [items, total] = await queryBuilder.getManyAndCount()\n\n return { items, total }\n }\n\n @FieldResolver(type => Domain)\n async domain(@Root() workShift: WorkShift): Promise<Domain> {\n return await getRepository(Domain).findOneBy({ id: workShift.domainId })\n }\n\n @FieldResolver(type => User)\n async updater(@Root() workShift: WorkShift): Promise<User> {\n return await getRepository(User).findOneBy({ id: workShift.updaterId })\n }\n\n @FieldResolver(type => User)\n async creator(@Root() workShift: WorkShift): Promise<User> {\n return await getRepository(User).findOneBy({ id: workShift.creatorId })\n }\n}\n"]}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var _a, _b, _c;
|
|
3
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
3
|
exports.WorkShift = exports.WorkShiftDateType = void 0;
|
|
5
4
|
const tslib_1 = require("tslib");
|
|
@@ -27,7 +26,7 @@ tslib_1.__decorate([
|
|
|
27
26
|
tslib_1.__decorate([
|
|
28
27
|
(0, typeorm_1.ManyToOne)(type => shell_1.Domain),
|
|
29
28
|
(0, type_graphql_1.Field)({ nullable: true }),
|
|
30
|
-
tslib_1.__metadata("design:type",
|
|
29
|
+
tslib_1.__metadata("design:type", shell_1.Domain)
|
|
31
30
|
], WorkShift.prototype, "domain", void 0);
|
|
32
31
|
tslib_1.__decorate([
|
|
33
32
|
(0, typeorm_1.RelationId)((workShift) => workShift.domain),
|
|
@@ -80,7 +79,7 @@ tslib_1.__decorate([
|
|
|
80
79
|
nullable: true
|
|
81
80
|
}),
|
|
82
81
|
(0, type_graphql_1.Field)({ nullable: true }),
|
|
83
|
-
tslib_1.__metadata("design:type",
|
|
82
|
+
tslib_1.__metadata("design:type", auth_base_1.User)
|
|
84
83
|
], WorkShift.prototype, "creator", void 0);
|
|
85
84
|
tslib_1.__decorate([
|
|
86
85
|
(0, typeorm_1.RelationId)((workShift) => workShift.creator),
|
|
@@ -91,7 +90,7 @@ tslib_1.__decorate([
|
|
|
91
90
|
nullable: true
|
|
92
91
|
}),
|
|
93
92
|
(0, type_graphql_1.Field)({ nullable: true }),
|
|
94
|
-
tslib_1.__metadata("design:type",
|
|
93
|
+
tslib_1.__metadata("design:type", auth_base_1.User)
|
|
95
94
|
], WorkShift.prototype, "updater", void 0);
|
|
96
95
|
tslib_1.__decorate([
|
|
97
96
|
(0, typeorm_1.RelationId)((workShift) => workShift.creator),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"work-shift.js","sourceRoot":"","sources":["../../../server/service/work-shift/work-shift.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"work-shift.js","sourceRoot":"","sources":["../../../server/service/work-shift/work-shift.ts"],"names":[],"mappings":";;;;AAAA,qCASgB;AAChB,+CAA2E;AAE3E,iDAA8C;AAC9C,yDAAgD;AAEhD,IAAY,iBAIX;AAJD,WAAY,iBAAiB;IAC3B,0EAAiB,CAAA;IACjB,6DAAU,CAAA;IACV,uEAAe,CAAA;AACjB,CAAC,EAJW,iBAAiB,GAAjB,yBAAiB,KAAjB,yBAAiB,QAI5B;AAED,IAAA,+BAAgB,EAAC,iBAAiB,EAAE;IAClC,IAAI,EAAE,mBAAmB;IACzB,WAAW,EAAE,6BAA6B;CAC3C,CAAC,CAAA;AAQF,IAAa,SAAS,GAAtB,MAAa,SAAS;CA+DrB,CAAA;AA5DC;IAFC,IAAA,gCAAsB,EAAC,MAAM,CAAC;IAC9B,IAAA,oBAAK,EAAC,IAAI,CAAC,EAAE,CAAC,iBAAE,CAAC;;qCACC;AAInB;IAFC,IAAA,mBAAS,EAAC,IAAI,CAAC,EAAE,CAAC,cAAM,CAAC;IACzB,IAAA,oBAAK,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;sCACjB,cAAM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IAAA,mBAAS,EAAC,IAAI,CAAC,EAAE,CAAC,gBAAI,EAAE;QACvB,QAAQ,EAAE,IAAI;KACf,CAAC;IACD,IAAA,oBAAK,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;sCAChB,gBAAI;0CAAA;AAGd;IADC,IAAA,oBAAU,EAAC,CAAC,SAAoB,EAAE,EAAE,CAAC,SAAS,CAAC,OAAO,CAAC;;4CACtC;AA9DP,SAAS;IANrB,IAAA,gBAAM,GAAE;IACR,IAAA,eAAK,EAAC,iBAAiB,EAAE,CAAC,SAAoB,EAAE,EAAE,CAAC,CAAC,SAAS,CAAC,MAAM,EAAE,SAAS,CAAC,IAAI,CAAC,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC;IACxG,IAAA,eAAK,EAAC,iBAAiB,EAAE,CAAC,SAAoB,EAAE,EAAE,CAAC,CAAC,SAAS,CAAC,MAAM,EAAE,SAAS,CAAC,QAAQ,EAAE,SAAS,CAAC,QAAQ,CAAC,EAAE;QAC9G,MAAM,EAAE,IAAI;KACb,CAAC;IACD,IAAA,yBAAU,EAAC,EAAE,WAAW,EAAE,sBAAsB,EAAE,CAAC;GACvC,SAAS,CA+DrB;AA/DY,8BAAS","sourcesContent":["import {\n Column,\n CreateDateColumn,\n Entity,\n Index,\n ManyToOne,\n PrimaryGeneratedColumn,\n RelationId,\n UpdateDateColumn\n} from 'typeorm'\nimport { Field, ID, Int, ObjectType, registerEnumType } from 'type-graphql'\n\nimport { Domain } from '@things-factory/shell'\nimport { User } from '@things-factory/auth-base'\n\nexport enum WorkShiftDateType {\n TheDayBefore = -1,\n TheDay = 0,\n TheDayAfter = 1\n}\n\nregisterEnumType(WorkShiftDateType, {\n name: 'WorkShiftDateType',\n description: 'enumeration of a shift date'\n})\n\n@Entity()\n@Index('ix_work_shift_0', (workShift: WorkShift) => [workShift.domain, workShift.name], { unique: true })\n@Index('ix_work_shift_1', (workShift: WorkShift) => [workShift.domain, workShift.fromDate, workShift.fromTime], {\n unique: true\n})\n@ObjectType({ description: 'Entity for WorkShift' })\nexport class WorkShift {\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((workShift: WorkShift) => workShift.domain)\n domainId?: string\n\n @Column()\n @Field()\n name: string\n\n @Column({\n nullable: true\n })\n @Field({ nullable: true })\n description?: string\n\n @Column()\n @Field({ nullable: true })\n fromDate: WorkShiftDateType\n\n @Column()\n @Field({ nullable: true })\n fromTime: string\n\n @Column()\n @Field({ nullable: true })\n toDate: WorkShiftDateType\n\n @Column()\n @Field({ nullable: true })\n toTime: string\n\n @CreateDateColumn()\n @Field({ nullable: true })\n createdAt?: Date\n\n @UpdateDateColumn()\n @Field({ nullable: true })\n updatedAt?: Date\n\n @ManyToOne(type => User, {\n nullable: true\n })\n @Field({ nullable: true })\n creator?: User\n\n @RelationId((workShift: WorkShift) => workShift.creator)\n creatorId?: string\n\n @ManyToOne(type => User, {\n nullable: true\n })\n @Field({ nullable: true })\n updater?: User\n\n @RelationId((workShift: WorkShift) => workShift.creator)\n updaterId?: string\n}\n"]}
|