@things-factory/work-shift 5.0.7 → 6.0.0-alpha.0
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 +4 -6
- package/dist-server/controllers/index.js.map +1 -1
- package/dist-server/index.js +5 -18
- package/dist-server/index.js.map +1 -1
- package/dist-server/middlewares/index.js.map +1 -1
- package/dist-server/migrations/index.js.map +1 -1
- package/dist-server/routes.js +0 -1
- package/dist-server/routes.js.map +1 -1
- package/dist-server/service/index.js +2 -15
- package/dist-server/service/index.js.map +1 -1
- package/dist-server/service/work-shift/index.js.map +1 -1
- package/dist-server/service/work-shift/work-shift-mutation.js +15 -26
- package/dist-server/service/work-shift/work-shift-mutation.js.map +1 -1
- package/dist-server/service/work-shift/work-shift-query.js +40 -53
- package/dist-server/service/work-shift/work-shift-query.js.map +1 -1
- package/dist-server/service/work-shift/work-shift-type.js +24 -32
- package/dist-server/service/work-shift/work-shift-type.js.map +1 -1
- package/dist-server/service/work-shift/work-shift.js +32 -41
- package/dist-server/service/work-shift/work-shift.js.map +1 -1
- package/dist-server/tsconfig.tsbuildinfo +1 -0
- package/package.json +6 -6
- package/server/controllers/index.ts +1 -2
- package/server/routes.ts +0 -2
- package/server/service/work-shift/work-shift-mutation.ts +8 -4
- package/server/service/work-shift/work-shift-query.ts +9 -7
|
@@ -1,12 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
3
|
exports.getWorkDateAndShift = void 0;
|
|
7
|
-
const
|
|
8
|
-
const
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const moment_timezone_1 = tslib_1.__importDefault(require("moment-timezone"));
|
|
9
6
|
const env_1 = require("@things-factory/env");
|
|
7
|
+
const shell_1 = require("@things-factory/shell");
|
|
10
8
|
const work_shift_1 = require("../service/work-shift/work-shift");
|
|
11
9
|
function between(fromDate, fromTime /* hh:mm */, toDate, toTime /* hh:mm */, theDay, dateTime) {
|
|
12
10
|
const convertedFromDate = new Date(theDay.getTime() + fromDate * (24 * 60 * 60 * 1000));
|
|
@@ -23,7 +21,7 @@ async function getWorkDateAndShift(domain, dateTime, options) {
|
|
|
23
21
|
const localDate = new Date(givenDate.format('YYYY-MM-DD HH:mm:ss'));
|
|
24
22
|
const workDate = givenDate.format(format);
|
|
25
23
|
/* 1. get work-shift list for the domain */
|
|
26
|
-
const workShifts = await (0,
|
|
24
|
+
const workShifts = await (0, shell_1.getRepository)(work_shift_1.WorkShift).find({
|
|
27
25
|
where: {
|
|
28
26
|
domain
|
|
29
27
|
},
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../server/controllers/index.ts"],"names":[],"mappings":"
|
|
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,C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I,CAAC,MAAM,CAAC,OAAO,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,IAAI,CAAC,CAAA;QACrE,MAAM,WAAW,GAAG,IAAI,IAAI,CAAC,MAAM,CAAC,OAAO,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,IAAI,CAAC,CAAA;QAEpE,MAAM,IAAI,GAAG,CAAC,YAAY,EAAE,MAAM,EAAE,WAAW,CAAC,CAAA;QAEhD,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,IAAI,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE;YACpC,MAAM,MAAM,GAAG,IAAI,CAAC,CAAC,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"]}
|
package/dist-server/index.js
CHANGED
|
@@ -1,22 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
-
};
|
|
16
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
|
|
18
|
-
__exportStar(require("./
|
|
19
|
-
__exportStar(require("./
|
|
20
|
-
__exportStar(require("./
|
|
3
|
+
const tslib_1 = require("tslib");
|
|
4
|
+
tslib_1.__exportStar(require("./controllers"), exports);
|
|
5
|
+
tslib_1.__exportStar(require("./migrations"), exports);
|
|
6
|
+
tslib_1.__exportStar(require("./middlewares"), exports);
|
|
7
|
+
tslib_1.__exportStar(require("./service"), exports);
|
|
21
8
|
require("./routes");
|
|
22
9
|
//# sourceMappingURL=index.js.map
|
package/dist-server/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../server/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../server/index.ts"],"names":[],"mappings":";;;AAAA,wDAA6B;AAC7B,uDAA4B;AAC5B,wDAA6B;AAC7B,oDAAyB;AAEzB,oBAAiB","sourcesContent":["export * from './controllers'\nexport * from './migrations'\nexport * from './middlewares'\nexport * from './service'\n\nimport './routes'\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../server/middlewares/index.ts"],"names":[],"mappings":";;;AAAA,SAAgB,eAAe,CAAC,GAAG;IACjC,kCAAkC;AACpC,CAAC;AAFD,0CAEC"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../server/middlewares/index.ts"],"names":[],"mappings":";;;AAAA,SAAgB,eAAe,CAAC,GAAG;IACjC,kCAAkC;AACpC,CAAC;AAFD,0CAEC","sourcesContent":["export function initMiddlewares(app) {\n /* can add middlewares into app */\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../server/migrations/index.ts"],"names":[],"mappings":";;;AAAA,MAAM,IAAI,GAAG,OAAO,CAAC,MAAM,CAAC,CAAA;AAC5B,MAAM,IAAI,GAAG,OAAO,CAAC,MAAM,CAAC,CAAA;AAEjB,QAAA,UAAU,GAAG,EAAE,CAAA;AAE1B,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,SAAS,EAAE,GAAG,EAAE,IAAI,EAAE,MAAM,CAAC,CAAC,CAAC,OAAO,CAAC,UAAS,IAAI;IACzE,IAAI,IAAI,CAAC,OAAO,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC;QAAE,OAAM;IAC3C,kBAAU,GAAG,kBAAU,CAAC,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC,CAAA;AAClF,CAAC,CAAC,CAAA"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../server/migrations/index.ts"],"names":[],"mappings":";;;AAAA,MAAM,IAAI,GAAG,OAAO,CAAC,MAAM,CAAC,CAAA;AAC5B,MAAM,IAAI,GAAG,OAAO,CAAC,MAAM,CAAC,CAAA;AAEjB,QAAA,UAAU,GAAG,EAAE,CAAA;AAE1B,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,SAAS,EAAE,GAAG,EAAE,IAAI,EAAE,MAAM,CAAC,CAAC,CAAC,OAAO,CAAC,UAAS,IAAI;IACzE,IAAI,IAAI,CAAC,OAAO,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC;QAAE,OAAM;IAC3C,kBAAU,GAAG,kBAAU,CAAC,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC,CAAA;AAClF,CAAC,CAAC,CAAA","sourcesContent":["const glob = require('glob')\nconst path = require('path')\n\nexport var migrations = []\n\nglob.sync(path.resolve(__dirname, '.', '**', '*.js')).forEach(function(file) {\n if (file.indexOf('index.js') !== -1) return\n migrations = migrations.concat(Object.values(require(path.resolve(file))) || [])\n})\n"]}
|
package/dist-server/routes.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"routes.js","sourceRoot":"","sources":["../server/routes.ts"],"names":[],"mappings":"AAAA,
|
|
1
|
+
{"version":3,"file":"routes.js","sourceRoot":"","sources":["../server/routes.ts"],"names":[],"mappings":"AAAA,OAAO,CAAC,EAAE,CAAC,sCAA6C,EAAE,CAAC,GAAG,EAAE,kBAAkB,EAAE,EAAE;IACpF;;;;;OAKG;AACL,CAAC,CAAC,CAAA;AAEF,OAAO,CAAC,EAAE,CAAC,uCAA8C,EAAE,CAAC,GAAG,EAAE,mBAAmB,EAAE,EAAE;IACtF;;OAEG;AACL,CAAC,CAAC,CAAA;AAEF,OAAO,CAAC,EAAE,CAAC,sCAA6C,EAAE,CAAC,GAAG,EAAE,kBAAkB,EAAE,EAAE;IACpF;;OAEG;AACL,CAAC,CAAC,CAAA;AAEF,OAAO,CAAC,EAAE,CAAC,uCAA8C,EAAE,CAAC,GAAG,EAAE,mBAAmB,EAAE,EAAE;IACtF;;OAEG;AACL,CAAC,CAAC,CAAA","sourcesContent":["process.on('bootstrap-module-global-public-route' as any, (app, globalPublicRouter) => {\n /*\n * can add global public routes to application (auth not required, tenancy not required)\n *\n * ex) routes.get('/path', async(context, next) => {})\n * ex) routes.post('/path', async(context, next) => {})\n */\n})\n\nprocess.on('bootstrap-module-global-private-route' as any, (app, globalPrivateRouter) => {\n /*\n * can add global private routes to application (auth required, tenancy not required)\n */\n})\n\nprocess.on('bootstrap-module-domain-public-route' as any, (app, domainPublicRouter) => {\n /*\n * can add domain public routes to application (auth not required, tenancy required)\n */\n})\n\nprocess.on('bootstrap-module-domain-private-route' as any, (app, domainPrivateRouter) => {\n /*\n * can add domain private routes to application (auth required, tenancy required)\n */\n})\n"]}
|
|
@@ -1,22 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
-
};
|
|
16
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
3
|
exports.schema = exports.entities = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
18
5
|
/* EXPORT ENTITY TYPES */
|
|
19
|
-
__exportStar(require("./work-shift/work-shift"), exports);
|
|
6
|
+
tslib_1.__exportStar(require("./work-shift/work-shift"), exports);
|
|
20
7
|
/* IMPORT ENTITIES AND RESOLVERS */
|
|
21
8
|
const work_shift_1 = require("./work-shift");
|
|
22
9
|
exports.entities = [
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../server/service/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../server/service/index.ts"],"names":[],"mappings":";;;;AAAA,yBAAyB;AACzB,kEAAuC;AAEvC,mCAAmC;AACnC,6CAA6F;AAEhF,QAAA,QAAQ,GAAG;IACtB,cAAc;IACf,GAAG,qBAAiB;CACpB,CAAA;AAGY,QAAA,MAAM,GAAG;IACpB,eAAe,EAAE;QACf,sBAAsB;QACxB,GAAG,sBAAkB;KACpB;CACF,CAAA","sourcesContent":["/* EXPORT ENTITY TYPES */\nexport * from './work-shift/work-shift'\n\n/* IMPORT ENTITIES AND RESOLVERS */\nimport { entities as WorkShiftEntities, resolvers as WorkShiftResolvers } from './work-shift'\n\nexport const entities = [ \n /* ENTITIES */\n\t...WorkShiftEntities,\n] \n\n\nexport const schema = {\n resolverClasses: [\n /* RESOLVER CLASSES */\n\t\t...WorkShiftResolvers,\n ] \n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../server/service/work-shift/index.ts"],"names":[],"mappings":";;;AAAA,yDAAyE;AAEzE,6CAAwC;AACxC,+DAAyD;AAE5C,QAAA,QAAQ,GAAG,CAAC,sBAAS,CAAC,CAAA;AACtB,QAAA,SAAS,GAAG,CAAC,uCAAoB,EAAE,iCAAc,EAAE,uCAAiB,CAAC,CAAA"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../server/service/work-shift/index.ts"],"names":[],"mappings":";;;AAAA,yDAAyE;AAEzE,6CAAwC;AACxC,+DAAyD;AAE5C,QAAA,QAAQ,GAAG,CAAC,sBAAS,CAAC,CAAA;AACtB,QAAA,SAAS,GAAG,CAAC,uCAAoB,EAAE,iCAAc,EAAE,uCAAiB,CAAC,CAAA","sourcesContent":["import { DomainWorkShiftQuery, WorkShiftQuery } from './work-shift-query'\n\nimport { WorkShift } from './work-shift'\nimport { WorkShiftMutation } from './work-shift-mutation'\n\nexport const entities = [WorkShift]\nexport const resolvers = [DomainWorkShiftQuery, WorkShiftQuery, WorkShiftMutation]\n"]}
|
|
@@ -1,18 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
-
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
-
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
-
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
-
};
|
|
8
|
-
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
-
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
-
};
|
|
11
|
-
var __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
12
|
-
return function (target, key) { decorator(target, key, paramIndex); }
|
|
13
|
-
};
|
|
14
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
3
|
exports.WorkShiftMutation = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
16
5
|
const type_graphql_1 = require("type-graphql");
|
|
17
6
|
const typeorm_1 = require("typeorm");
|
|
18
7
|
const work_shift_1 = require("./work-shift");
|
|
@@ -33,33 +22,33 @@ let WorkShiftMutation = class WorkShiftMutation {
|
|
|
33
22
|
async deleteWorkShifts(ids, context) {
|
|
34
23
|
const { domain, tx } = context.state;
|
|
35
24
|
await tx.getRepository(work_shift_1.WorkShift).delete({
|
|
36
|
-
domain,
|
|
25
|
+
domain: { id: domain.id },
|
|
37
26
|
id: (0, typeorm_1.In)(ids)
|
|
38
27
|
});
|
|
39
28
|
return true;
|
|
40
29
|
}
|
|
41
30
|
};
|
|
42
|
-
__decorate([
|
|
31
|
+
tslib_1.__decorate([
|
|
43
32
|
(0, type_graphql_1.Directive)('@privilege(category: "system", privilege: "mutation", domainOwnerGranted: true)'),
|
|
44
33
|
(0, type_graphql_1.Directive)('@transaction'),
|
|
45
34
|
(0, type_graphql_1.Mutation)(returns => [work_shift_1.WorkShift], { description: "To modify multiple WorkShifts' information" }),
|
|
46
|
-
__param(0, (0, type_graphql_1.Arg)('patches', type => [work_shift_type_1.WorkShiftPatch])),
|
|
47
|
-
__param(1, (0, type_graphql_1.Ctx)()),
|
|
48
|
-
__metadata("design:type", Function),
|
|
49
|
-
__metadata("design:paramtypes", [Array, Object]),
|
|
50
|
-
__metadata("design:returntype", Promise)
|
|
35
|
+
tslib_1.__param(0, (0, type_graphql_1.Arg)('patches', type => [work_shift_type_1.WorkShiftPatch])),
|
|
36
|
+
tslib_1.__param(1, (0, type_graphql_1.Ctx)()),
|
|
37
|
+
tslib_1.__metadata("design:type", Function),
|
|
38
|
+
tslib_1.__metadata("design:paramtypes", [Array, Object]),
|
|
39
|
+
tslib_1.__metadata("design:returntype", Promise)
|
|
51
40
|
], WorkShiftMutation.prototype, "updateMultipleWorkShift", null);
|
|
52
|
-
__decorate([
|
|
41
|
+
tslib_1.__decorate([
|
|
53
42
|
(0, type_graphql_1.Directive)('@privilege(category: "system", privilege: "mutation", domainOwnerGranted: true)'),
|
|
54
43
|
(0, type_graphql_1.Directive)('@transaction'),
|
|
55
44
|
(0, type_graphql_1.Mutation)(returns => Boolean, { description: 'To delete multiple workShifts' }),
|
|
56
|
-
__param(0, (0, type_graphql_1.Arg)('ids', type => [String])),
|
|
57
|
-
__param(1, (0, type_graphql_1.Ctx)()),
|
|
58
|
-
__metadata("design:type", Function),
|
|
59
|
-
__metadata("design:paramtypes", [Array, Object]),
|
|
60
|
-
__metadata("design:returntype", Promise)
|
|
45
|
+
tslib_1.__param(0, (0, type_graphql_1.Arg)('ids', type => [String])),
|
|
46
|
+
tslib_1.__param(1, (0, type_graphql_1.Ctx)()),
|
|
47
|
+
tslib_1.__metadata("design:type", Function),
|
|
48
|
+
tslib_1.__metadata("design:paramtypes", [Array, Object]),
|
|
49
|
+
tslib_1.__metadata("design:returntype", Promise)
|
|
61
50
|
], WorkShiftMutation.prototype, "deleteWorkShifts", null);
|
|
62
|
-
WorkShiftMutation = __decorate([
|
|
51
|
+
WorkShiftMutation = tslib_1.__decorate([
|
|
63
52
|
(0, type_graphql_1.Resolver)(work_shift_1.WorkShift)
|
|
64
53
|
], WorkShiftMutation);
|
|
65
54
|
exports.WorkShiftMutation = WorkShiftMutation;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"work-shift-mutation.js","sourceRoot":"","sources":["../../../server/service/work-shift/work-shift-mutation.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"work-shift-mutation.js","sourceRoot":"","sources":["../../../server/service/work-shift/work-shift-mutation.ts"],"names":[],"mappings":";;;;AAAA,+CAAsE;AACtE,qCAA4B;AAE5B,6CAAwC;AACxC,uDAAkD;AAGlD,IAAa,iBAAiB,GAA9B,MAAa,iBAAiB;IAI5B,KAAK,CAAC,uBAAuB,CACe,OAAyB,EAC5D,OAAwB;QAE/B,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,EAAE,EAAE,GAAG,OAAO,CAAC,KAAK,CAAA;QAE1C,IAAI,OAAO,GAAG,EAAE,CAAA;QAChB,MAAM,aAAa,GAAG,EAAE,CAAC,aAAa,CAAC,sBAAS,CAAC,CAAA;QAEjD,MAAM,aAAa,CAAC,MAAM,CAAC,EAAE,MAAM,EAAE,CAAC,CAAA;QAEtC,K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AAC,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,21 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
-
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
-
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
-
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
-
};
|
|
8
|
-
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
-
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
-
};
|
|
11
|
-
var __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
12
|
-
return function (target, key) { decorator(target, key, paramIndex); }
|
|
13
|
-
};
|
|
14
|
-
var _a, _b;
|
|
15
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
16
3
|
exports.WorkShiftQuery = exports.DomainWorkShiftQuery = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
17
5
|
const type_graphql_1 = require("type-graphql");
|
|
18
|
-
const typeorm_1 = require("typeorm");
|
|
19
6
|
const auth_base_1 = require("@things-factory/auth-base");
|
|
20
7
|
const shell_1 = require("@things-factory/shell");
|
|
21
8
|
const index_1 = require("../../controllers/index");
|
|
@@ -27,7 +14,7 @@ let DomainWorkShiftQuery = class DomainWorkShiftQuery {
|
|
|
27
14
|
return await (0, index_1.getWorkDateAndShift)(domain, dateTime);
|
|
28
15
|
}
|
|
29
16
|
async workShifts(domain) {
|
|
30
|
-
return await (0,
|
|
17
|
+
return await (0, shell_1.getRepository)(work_shift_1.WorkShift).find({
|
|
31
18
|
where: {
|
|
32
19
|
domain
|
|
33
20
|
},
|
|
@@ -38,22 +25,22 @@ let DomainWorkShiftQuery = class DomainWorkShiftQuery {
|
|
|
38
25
|
});
|
|
39
26
|
}
|
|
40
27
|
};
|
|
41
|
-
__decorate([
|
|
28
|
+
tslib_1.__decorate([
|
|
42
29
|
(0, type_graphql_1.Query)(returns => work_shift_type_1.WorkDateWorkShiftPair, { description: 'To fetch a work date and work shift for given datetime' }),
|
|
43
|
-
__param(0, (0, type_graphql_1.Arg)('dateTime')),
|
|
44
|
-
__param(1, (0, type_graphql_1.Ctx)()),
|
|
45
|
-
__metadata("design:type", Function),
|
|
46
|
-
__metadata("design:paramtypes", [Date, Object]),
|
|
47
|
-
__metadata("design:returntype", Promise)
|
|
30
|
+
tslib_1.__param(0, (0, type_graphql_1.Arg)('dateTime')),
|
|
31
|
+
tslib_1.__param(1, (0, type_graphql_1.Ctx)()),
|
|
32
|
+
tslib_1.__metadata("design:type", Function),
|
|
33
|
+
tslib_1.__metadata("design:paramtypes", [Date, Object]),
|
|
34
|
+
tslib_1.__metadata("design:returntype", Promise)
|
|
48
35
|
], DomainWorkShiftQuery.prototype, "getWorkDateAndShift", null);
|
|
49
|
-
__decorate([
|
|
36
|
+
tslib_1.__decorate([
|
|
50
37
|
(0, type_graphql_1.FieldResolver)(type => [work_shift_1.WorkShift]),
|
|
51
|
-
__param(0, (0, type_graphql_1.Root)()),
|
|
52
|
-
__metadata("design:type", Function),
|
|
53
|
-
__metadata("design:paramtypes", [
|
|
54
|
-
__metadata("design:returntype", Promise)
|
|
38
|
+
tslib_1.__param(0, (0, type_graphql_1.Root)()),
|
|
39
|
+
tslib_1.__metadata("design:type", Function),
|
|
40
|
+
tslib_1.__metadata("design:paramtypes", [shell_1.Domain]),
|
|
41
|
+
tslib_1.__metadata("design:returntype", Promise)
|
|
55
42
|
], DomainWorkShiftQuery.prototype, "workShifts", null);
|
|
56
|
-
DomainWorkShiftQuery = __decorate([
|
|
43
|
+
DomainWorkShiftQuery = tslib_1.__decorate([
|
|
57
44
|
(0, type_graphql_1.Resolver)(shell_1.Domain)
|
|
58
45
|
], DomainWorkShiftQuery);
|
|
59
46
|
exports.DomainWorkShiftQuery = DomainWorkShiftQuery;
|
|
@@ -61,7 +48,7 @@ let WorkShiftQuery = class WorkShiftQuery {
|
|
|
61
48
|
async workShifts(params, context) {
|
|
62
49
|
const { domain } = context.state;
|
|
63
50
|
const queryBuilder = (0, shell_1.getQueryBuilderFromListParams)({
|
|
64
|
-
repository: (0,
|
|
51
|
+
repository: (0, shell_1.getRepository)(work_shift_1.WorkShift),
|
|
65
52
|
params,
|
|
66
53
|
domain
|
|
67
54
|
});
|
|
@@ -69,45 +56,45 @@ let WorkShiftQuery = class WorkShiftQuery {
|
|
|
69
56
|
return { items, total };
|
|
70
57
|
}
|
|
71
58
|
async domain(workShift) {
|
|
72
|
-
return await (0,
|
|
59
|
+
return await (0, shell_1.getRepository)(shell_1.Domain).findOneBy({ id: workShift.domainId });
|
|
73
60
|
}
|
|
74
61
|
async updater(workShift) {
|
|
75
|
-
return await (0,
|
|
62
|
+
return await (0, shell_1.getRepository)(auth_base_1.User).findOneBy({ id: workShift.updaterId });
|
|
76
63
|
}
|
|
77
64
|
async creator(workShift) {
|
|
78
|
-
return await (0,
|
|
65
|
+
return await (0, shell_1.getRepository)(auth_base_1.User).findOneBy({ id: workShift.creatorId });
|
|
79
66
|
}
|
|
80
67
|
};
|
|
81
|
-
__decorate([
|
|
68
|
+
tslib_1.__decorate([
|
|
82
69
|
(0, type_graphql_1.Query)(returns => work_shift_type_1.WorkShiftList, { description: 'To fetch multiple WorkShifts' }),
|
|
83
|
-
__param(0, (0, type_graphql_1.Args)()),
|
|
84
|
-
__param(1, (0, type_graphql_1.Ctx)()),
|
|
85
|
-
__metadata("design:type", Function),
|
|
86
|
-
__metadata("design:paramtypes", [
|
|
87
|
-
__metadata("design:returntype", Promise)
|
|
70
|
+
tslib_1.__param(0, (0, type_graphql_1.Args)()),
|
|
71
|
+
tslib_1.__param(1, (0, type_graphql_1.Ctx)()),
|
|
72
|
+
tslib_1.__metadata("design:type", Function),
|
|
73
|
+
tslib_1.__metadata("design:paramtypes", [shell_1.ListParam, Object]),
|
|
74
|
+
tslib_1.__metadata("design:returntype", Promise)
|
|
88
75
|
], WorkShiftQuery.prototype, "workShifts", null);
|
|
89
|
-
__decorate([
|
|
76
|
+
tslib_1.__decorate([
|
|
90
77
|
(0, type_graphql_1.FieldResolver)(type => shell_1.Domain),
|
|
91
|
-
__param(0, (0, type_graphql_1.Root)()),
|
|
92
|
-
__metadata("design:type", Function),
|
|
93
|
-
__metadata("design:paramtypes", [work_shift_1.WorkShift]),
|
|
94
|
-
__metadata("design:returntype", Promise)
|
|
78
|
+
tslib_1.__param(0, (0, type_graphql_1.Root)()),
|
|
79
|
+
tslib_1.__metadata("design:type", Function),
|
|
80
|
+
tslib_1.__metadata("design:paramtypes", [work_shift_1.WorkShift]),
|
|
81
|
+
tslib_1.__metadata("design:returntype", Promise)
|
|
95
82
|
], WorkShiftQuery.prototype, "domain", null);
|
|
96
|
-
__decorate([
|
|
83
|
+
tslib_1.__decorate([
|
|
97
84
|
(0, type_graphql_1.FieldResolver)(type => auth_base_1.User),
|
|
98
|
-
__param(0, (0, type_graphql_1.Root)()),
|
|
99
|
-
__metadata("design:type", Function),
|
|
100
|
-
__metadata("design:paramtypes", [work_shift_1.WorkShift]),
|
|
101
|
-
__metadata("design:returntype", Promise)
|
|
85
|
+
tslib_1.__param(0, (0, type_graphql_1.Root)()),
|
|
86
|
+
tslib_1.__metadata("design:type", Function),
|
|
87
|
+
tslib_1.__metadata("design:paramtypes", [work_shift_1.WorkShift]),
|
|
88
|
+
tslib_1.__metadata("design:returntype", Promise)
|
|
102
89
|
], WorkShiftQuery.prototype, "updater", null);
|
|
103
|
-
__decorate([
|
|
90
|
+
tslib_1.__decorate([
|
|
104
91
|
(0, type_graphql_1.FieldResolver)(type => auth_base_1.User),
|
|
105
|
-
__param(0, (0, type_graphql_1.Root)()),
|
|
106
|
-
__metadata("design:type", Function),
|
|
107
|
-
__metadata("design:paramtypes", [work_shift_1.WorkShift]),
|
|
108
|
-
__metadata("design:returntype", Promise)
|
|
92
|
+
tslib_1.__param(0, (0, type_graphql_1.Root)()),
|
|
93
|
+
tslib_1.__metadata("design:type", Function),
|
|
94
|
+
tslib_1.__metadata("design:paramtypes", [work_shift_1.WorkShift]),
|
|
95
|
+
tslib_1.__metadata("design:returntype", Promise)
|
|
109
96
|
], WorkShiftQuery.prototype, "creator", null);
|
|
110
|
-
WorkShiftQuery = __decorate([
|
|
97
|
+
WorkShiftQuery = tslib_1.__decorate([
|
|
111
98
|
(0, type_graphql_1.Resolver)(work_shift_1.WorkShift)
|
|
112
99
|
], WorkShiftQuery);
|
|
113
100
|
exports.WorkShiftQuery = WorkShiftQuery;
|
|
@@ -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,oBA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AAO,CAAS,SAAoB;QACxC,OAAO,MAAM,IAAA,qBAAa,EAAC,gBAAI,CAAC,CAAC,SAAS,CAAC,EAAE,EAAE,EAAE,SAAS,CAAC,SAAS,EAAE,CAAC,CAAA;IACzE,CAAC;CACF,CAAA;AA5BC;IADC,IAAA,oBAAK,EAAC,OAAO,CAAC,EAAE,CAAC,+BAAa,EAAE,EAAE,WAAW,EAAE,8BAA8B,EAAE,CAAC;IAC/D,mBAAA,IAAA,mBAAI,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,72 +1,64 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
-
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
-
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
-
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
-
};
|
|
8
|
-
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
-
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
-
};
|
|
11
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
3
|
exports.WorkDateWorkShiftPair = exports.WorkShiftList = exports.WorkShiftPatch = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
13
5
|
const type_graphql_1 = require("type-graphql");
|
|
14
6
|
const work_shift_1 = require("./work-shift");
|
|
15
7
|
let WorkShiftPatch = class WorkShiftPatch {
|
|
16
8
|
};
|
|
17
|
-
__decorate([
|
|
9
|
+
tslib_1.__decorate([
|
|
18
10
|
(0, type_graphql_1.Field)(),
|
|
19
|
-
__metadata("design:type", String)
|
|
11
|
+
tslib_1.__metadata("design:type", String)
|
|
20
12
|
], WorkShiftPatch.prototype, "name", void 0);
|
|
21
|
-
__decorate([
|
|
13
|
+
tslib_1.__decorate([
|
|
22
14
|
(0, type_graphql_1.Field)({ nullable: true }),
|
|
23
|
-
__metadata("design:type", String)
|
|
15
|
+
tslib_1.__metadata("design:type", String)
|
|
24
16
|
], WorkShiftPatch.prototype, "description", void 0);
|
|
25
|
-
__decorate([
|
|
17
|
+
tslib_1.__decorate([
|
|
26
18
|
(0, type_graphql_1.Field)(),
|
|
27
|
-
__metadata("design:type", Number)
|
|
19
|
+
tslib_1.__metadata("design:type", Number)
|
|
28
20
|
], WorkShiftPatch.prototype, "fromDate", void 0);
|
|
29
|
-
__decorate([
|
|
21
|
+
tslib_1.__decorate([
|
|
30
22
|
(0, type_graphql_1.Field)(),
|
|
31
|
-
__metadata("design:type", String)
|
|
23
|
+
tslib_1.__metadata("design:type", String)
|
|
32
24
|
], WorkShiftPatch.prototype, "fromTime", void 0);
|
|
33
|
-
__decorate([
|
|
25
|
+
tslib_1.__decorate([
|
|
34
26
|
(0, type_graphql_1.Field)(),
|
|
35
|
-
__metadata("design:type", Number)
|
|
27
|
+
tslib_1.__metadata("design:type", Number)
|
|
36
28
|
], WorkShiftPatch.prototype, "toDate", void 0);
|
|
37
|
-
__decorate([
|
|
29
|
+
tslib_1.__decorate([
|
|
38
30
|
(0, type_graphql_1.Field)(),
|
|
39
|
-
__metadata("design:type", String)
|
|
31
|
+
tslib_1.__metadata("design:type", String)
|
|
40
32
|
], WorkShiftPatch.prototype, "toTime", void 0);
|
|
41
|
-
WorkShiftPatch = __decorate([
|
|
33
|
+
WorkShiftPatch = tslib_1.__decorate([
|
|
42
34
|
(0, type_graphql_1.InputType)()
|
|
43
35
|
], WorkShiftPatch);
|
|
44
36
|
exports.WorkShiftPatch = WorkShiftPatch;
|
|
45
37
|
let WorkShiftList = class WorkShiftList {
|
|
46
38
|
};
|
|
47
|
-
__decorate([
|
|
39
|
+
tslib_1.__decorate([
|
|
48
40
|
(0, type_graphql_1.Field)(type => [work_shift_1.WorkShift]),
|
|
49
|
-
__metadata("design:type", Array)
|
|
41
|
+
tslib_1.__metadata("design:type", Array)
|
|
50
42
|
], WorkShiftList.prototype, "items", void 0);
|
|
51
|
-
__decorate([
|
|
43
|
+
tslib_1.__decorate([
|
|
52
44
|
(0, type_graphql_1.Field)(type => type_graphql_1.Int),
|
|
53
|
-
__metadata("design:type", Number)
|
|
45
|
+
tslib_1.__metadata("design:type", Number)
|
|
54
46
|
], WorkShiftList.prototype, "total", void 0);
|
|
55
|
-
WorkShiftList = __decorate([
|
|
47
|
+
WorkShiftList = tslib_1.__decorate([
|
|
56
48
|
(0, type_graphql_1.ObjectType)()
|
|
57
49
|
], WorkShiftList);
|
|
58
50
|
exports.WorkShiftList = WorkShiftList;
|
|
59
51
|
let WorkDateWorkShiftPair = class WorkDateWorkShiftPair {
|
|
60
52
|
};
|
|
61
|
-
__decorate([
|
|
53
|
+
tslib_1.__decorate([
|
|
62
54
|
(0, type_graphql_1.Field)(),
|
|
63
|
-
__metadata("design:type", String)
|
|
55
|
+
tslib_1.__metadata("design:type", String)
|
|
64
56
|
], WorkDateWorkShiftPair.prototype, "workDate", void 0);
|
|
65
|
-
__decorate([
|
|
57
|
+
tslib_1.__decorate([
|
|
66
58
|
(0, type_graphql_1.Field)(),
|
|
67
|
-
__metadata("design:type", String)
|
|
59
|
+
tslib_1.__metadata("design:type", String)
|
|
68
60
|
], WorkDateWorkShiftPair.prototype, "workShift", void 0);
|
|
69
|
-
WorkDateWorkShiftPair = __decorate([
|
|
61
|
+
WorkDateWorkShiftPair = tslib_1.__decorate([
|
|
70
62
|
(0, type_graphql_1.ObjectType)()
|
|
71
63
|
], WorkDateWorkShiftPair);
|
|
72
64
|
exports.WorkDateWorkShiftPair = WorkDateWorkShiftPair;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"work-shift-type.js","sourceRoot":"","sources":["../../../server/service/work-shift/work-shift-type.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"work-shift-type.js","sourceRoot":"","sources":["../../../server/service/work-shift/work-shift-type.ts"],"names":[],"mappings":";;;;AAAA,+CAAsF;AACtF,6CAA2D;AAG3D,IAAa,cAAc,GAA3B,MAAa,cAAc;CAkB1B,CAAA;AAhBC;IADC,IAAA,oBAAK,GAAE;;4CACI;AAGZ;IADC,IAAA,oBAAK,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;;mDACN;AAGpB;IADC,IAAA,oBAAK,GAAE;;gDACmB;AAG3B;IADC,IAAA,oBAAK,GAAE;;gDACQ;AAGhB;IADC,IAAA,oBAAK,GAAE;;8CACiB;AAGzB;IADC,IAAA,oBAAK,GAAE;;8CACM;AAjBH,cAAc;IAD1B,IAAA,wBAAS,GAAE;GACC,cAAc,CAkB1B;AAlBY,wCAAc;AAqB3B,IAAa,aAAa,GAA1B,MAAa,aAAa;CAMzB,CAAA;AAJC;IADC,IAAA,oBAAK,EAAC,IAAI,CAAC,EAAE,CAAC,CAAC,sBAAS,CAAC,CAAC;;4CACT;AAGlB;IADC,IAAA,oBAAK,EAAC,IAAI,CAAC,EAAE,CAAC,kBAAG,CAAC;;4CACN;AALF,aAAa;IADzB,IAAA,yBAAU,GAAE;GACA,aAAa,CAMzB;AANY,sCAAa;AAS1B,IAAa,qBAAqB,GAAlC,MAAa,qBAAqB;CAMjC,CAAA;AAJC;IADC,IAAA,oBAAK,GAAE;;uDACQ;AAGhB;IADC,IAAA,oBAAK,GAAE;;wDACS;AALN,qBAAqB;IADjC,IAAA,yBAAU,GAAE;GACA,qBAAqB,CAMjC;AANY,sDAAqB","sourcesContent":["import { Field, ID, InputType, Int, ObjectType, registerEnumType } from 'type-graphql'\nimport { WorkShift, WorkShiftDateType } from './work-shift'\n\n@InputType()\nexport class WorkShiftPatch {\n @Field()\n name: string\n\n @Field({ nullable: true })\n description?: string\n\n @Field()\n fromDate: WorkShiftDateType\n\n @Field()\n fromTime: string\n\n @Field()\n toDate: WorkShiftDateType\n\n @Field()\n toTime: string\n}\n\n@ObjectType()\nexport class WorkShiftList {\n @Field(type => [WorkShift])\n items: WorkShift[]\n\n @Field(type => Int)\n total: number\n}\n\n@ObjectType()\nexport class WorkDateWorkShiftPair {\n @Field()\n workDate: string\n\n @Field()\n workShift: string\n}\n"]}
|