@things-factory/work-shift 10.0.18 → 10.1.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-client/pages/work-shift.d.ts +106 -1
- package/dist-client/pages/work-shift.js +798 -43
- package/dist-client/pages/work-shift.js.map +1 -1
- package/dist-client/shift-coverage.d.ts +76 -0
- package/dist-client/shift-coverage.js +146 -0
- package/dist-client/shift-coverage.js.map +1 -0
- package/dist-client/tsconfig.tsbuildinfo +1 -1
- package/dist-server/controllers/work-shift-range.js +23 -36
- package/dist-server/controllers/work-shift-range.js.map +1 -1
- package/dist-server/service/index.d.ts +5 -2
- package/dist-server/service/index.js +9 -0
- package/dist-server/service/index.js.map +1 -1
- package/dist-server/service/work-shift/days-of-week.d.ts +30 -0
- package/dist-server/service/work-shift/days-of-week.js +74 -0
- package/dist-server/service/work-shift/days-of-week.js.map +1 -0
- package/dist-server/service/work-shift/index.d.ts +5 -2
- package/dist-server/service/work-shift/index.js +11 -2
- package/dist-server/service/work-shift/index.js.map +1 -1
- package/dist-server/service/work-shift/work-shift-mutation.d.ts +10 -0
- package/dist-server/service/work-shift/work-shift-mutation.js +51 -1
- package/dist-server/service/work-shift/work-shift-mutation.js.map +1 -1
- package/dist-server/service/work-shift/work-shift-revision-query.d.ts +20 -0
- package/dist-server/service/work-shift/work-shift-revision-query.js +74 -0
- package/dist-server/service/work-shift/work-shift-revision-query.js.map +1 -0
- package/dist-server/service/work-shift/work-shift-revision-service.d.ts +69 -0
- package/dist-server/service/work-shift/work-shift-revision-service.js +186 -0
- package/dist-server/service/work-shift/work-shift-revision-service.js.map +1 -0
- package/dist-server/service/work-shift/work-shift-revision.d.ts +67 -0
- package/dist-server/service/work-shift/work-shift-revision.js +116 -0
- package/dist-server/service/work-shift/work-shift-revision.js.map +1 -0
- package/dist-server/service/work-shift/work-shift-selection.d.ts +50 -0
- package/dist-server/service/work-shift/work-shift-selection.js +65 -0
- package/dist-server/service/work-shift/work-shift-selection.js.map +1 -0
- package/dist-server/service/work-shift/work-shift-type.d.ts +12 -0
- package/dist-server/service/work-shift/work-shift-type.js +20 -1
- package/dist-server/service/work-shift/work-shift-type.js.map +1 -1
- package/dist-server/service/work-shift/work-shift.d.ts +32 -0
- package/dist-server/service/work-shift/work-shift.js +5 -0
- package/dist-server/service/work-shift/work-shift.js.map +1 -1
- package/dist-server/tsconfig.tsbuildinfo +1 -1
- package/helps/page/work-shift.ko.md +5 -0
- package/helps/page/work-shift.md +13 -0
- package/package.json +6 -5
- package/translations/en.json +31 -1
- package/translations/ja.json +1 -1
- package/translations/ko.json +31 -1
- package/translations/ms.json +1 -1
- package/translations/zh.json +1 -1
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { WorkShift, WorkShiftDateType } from './work-shift';
|
|
2
|
+
import { WorkShiftRevision } from './work-shift-revision';
|
|
2
3
|
export declare class WorkShiftPatch {
|
|
3
4
|
name: string;
|
|
4
5
|
description?: string;
|
|
@@ -6,11 +7,22 @@ export declare class WorkShiftPatch {
|
|
|
6
7
|
fromTime: string;
|
|
7
8
|
toDate: WorkShiftDateType;
|
|
8
9
|
toTime: string;
|
|
10
|
+
/**
|
|
11
|
+
* Which weekdays this shift runs on — 0 Sunday … 6 Saturday, empty for every day.
|
|
12
|
+
*
|
|
13
|
+
* Nullable so that a client written before this field existed keeps working: an
|
|
14
|
+
* absent value means every day, which is exactly what those clients meant.
|
|
15
|
+
*/
|
|
16
|
+
daysOfWeek?: string;
|
|
9
17
|
}
|
|
10
18
|
export declare class WorkShiftList {
|
|
11
19
|
items: WorkShift[];
|
|
12
20
|
total: number;
|
|
13
21
|
}
|
|
22
|
+
export declare class WorkShiftRevisionList {
|
|
23
|
+
items: WorkShiftRevision[];
|
|
24
|
+
total: number;
|
|
25
|
+
}
|
|
14
26
|
export declare class WorkShiftInfo {
|
|
15
27
|
workDate?: string;
|
|
16
28
|
workShift?: string;
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.WorkShiftInfo = exports.WorkShiftList = exports.WorkShiftPatch = void 0;
|
|
3
|
+
exports.WorkShiftInfo = exports.WorkShiftRevisionList = exports.WorkShiftList = exports.WorkShiftPatch = void 0;
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
5
|
const type_graphql_1 = require("type-graphql");
|
|
6
6
|
const work_shift_1 = require("./work-shift");
|
|
7
|
+
const work_shift_revision_1 = require("./work-shift-revision");
|
|
7
8
|
let WorkShiftPatch = class WorkShiftPatch {
|
|
8
9
|
};
|
|
9
10
|
exports.WorkShiftPatch = WorkShiftPatch;
|
|
@@ -31,6 +32,10 @@ tslib_1.__decorate([
|
|
|
31
32
|
(0, type_graphql_1.Field)(),
|
|
32
33
|
tslib_1.__metadata("design:type", String)
|
|
33
34
|
], WorkShiftPatch.prototype, "toTime", void 0);
|
|
35
|
+
tslib_1.__decorate([
|
|
36
|
+
(0, type_graphql_1.Field)({ nullable: true, description: 'Weekdays this shift runs on as a CSV of 0(Sun)..6(Sat). Empty means every day' }),
|
|
37
|
+
tslib_1.__metadata("design:type", String)
|
|
38
|
+
], WorkShiftPatch.prototype, "daysOfWeek", void 0);
|
|
34
39
|
exports.WorkShiftPatch = WorkShiftPatch = tslib_1.__decorate([
|
|
35
40
|
(0, type_graphql_1.InputType)()
|
|
36
41
|
], WorkShiftPatch);
|
|
@@ -48,6 +53,20 @@ tslib_1.__decorate([
|
|
|
48
53
|
exports.WorkShiftList = WorkShiftList = tslib_1.__decorate([
|
|
49
54
|
(0, type_graphql_1.ObjectType)()
|
|
50
55
|
], WorkShiftList);
|
|
56
|
+
let WorkShiftRevisionList = class WorkShiftRevisionList {
|
|
57
|
+
};
|
|
58
|
+
exports.WorkShiftRevisionList = WorkShiftRevisionList;
|
|
59
|
+
tslib_1.__decorate([
|
|
60
|
+
(0, type_graphql_1.Field)(type => [work_shift_revision_1.WorkShiftRevision]),
|
|
61
|
+
tslib_1.__metadata("design:type", Array)
|
|
62
|
+
], WorkShiftRevisionList.prototype, "items", void 0);
|
|
63
|
+
tslib_1.__decorate([
|
|
64
|
+
(0, type_graphql_1.Field)(type => type_graphql_1.Int),
|
|
65
|
+
tslib_1.__metadata("design:type", Number)
|
|
66
|
+
], WorkShiftRevisionList.prototype, "total", void 0);
|
|
67
|
+
exports.WorkShiftRevisionList = WorkShiftRevisionList = tslib_1.__decorate([
|
|
68
|
+
(0, type_graphql_1.ObjectType)()
|
|
69
|
+
], WorkShiftRevisionList);
|
|
51
70
|
let WorkShiftInfo = class WorkShiftInfo {
|
|
52
71
|
};
|
|
53
72
|
exports.WorkShiftInfo = WorkShiftInfo;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"work-shift-type.js","sourceRoot":"","sources":["../../../server/service/work-shift/work-shift-type.ts"],"names":[],"mappings":";;;;AAAA,+CAAsF;AACtF,6CAA2D;
|
|
1
|
+
{"version":3,"file":"work-shift-type.js","sourceRoot":"","sources":["../../../server/service/work-shift/work-shift-type.ts"],"names":[],"mappings":";;;;AAAA,+CAAsF;AACtF,6CAA2D;AAC3D,+DAAyD;AAGlD,IAAM,cAAc,GAApB,MAAM,cAAc;CA2B1B,CAAA;AA3BY,wCAAc;AAEzB;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;AASd;IADC,IAAA,oBAAK,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,WAAW,EAAE,+EAA+E,EAAE,CAAC;;kDACrG;yBA1BR,cAAc;IAD1B,IAAA,wBAAS,GAAE;GACC,cAAc,CA2B1B;AAGM,IAAM,aAAa,GAAnB,MAAM,aAAa;CAMzB,CAAA;AANY,sCAAa;AAExB;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;wBALF,aAAa;IADzB,IAAA,yBAAU,GAAE;GACA,aAAa,CAMzB;AAGM,IAAM,qBAAqB,GAA3B,MAAM,qBAAqB;CAMjC,CAAA;AANY,sDAAqB;AAEhC;IADC,IAAA,oBAAK,EAAC,IAAI,CAAC,EAAE,CAAC,CAAC,uCAAiB,CAAC,CAAC;;oDACT;AAG1B;IADC,IAAA,oBAAK,EAAC,IAAI,CAAC,EAAE,CAAC,kBAAG,CAAC;;oDACN;gCALF,qBAAqB;IADjC,IAAA,yBAAU,GAAE;GACA,qBAAqB,CAMjC;AAGM,IAAM,aAAa,GAAnB,MAAM,aAAa;CAYzB,CAAA;AAZY,sCAAa;AAExB;IADC,IAAA,oBAAK,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;;+CACT;AAGjB;IADC,IAAA,oBAAK,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;;gDACR;AAGlB;IADC,IAAA,oBAAK,EAAC,IAAI,CAAC,EAAE,CAAC,CAAC,IAAI,CAAC,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;;gDACxB;AAGlB;IADC,IAAA,oBAAK,EAAC,IAAI,CAAC,EAAE,CAAC,CAAC,IAAI,CAAC,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;;iDACvB;wBAXR,aAAa;IADzB,IAAA,yBAAU,GAAE;GACA,aAAa,CAYzB","sourcesContent":["import { Field, ID, InputType, Int, ObjectType, registerEnumType } from 'type-graphql'\nimport { WorkShift, WorkShiftDateType } from './work-shift'\nimport { WorkShiftRevision } from './work-shift-revision'\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 * Which weekdays this shift runs on — 0 Sunday … 6 Saturday, empty for every day.\n *\n * Nullable so that a client written before this field existed keeps working: an\n * absent value means every day, which is exactly what those clients meant.\n */\n @Field({ nullable: true, description: 'Weekdays this shift runs on as a CSV of 0(Sun)..6(Sat). Empty means every day' })\n daysOfWeek?: 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 WorkShiftRevisionList {\n @Field(type => [WorkShiftRevision])\n items: WorkShiftRevision[]\n\n @Field(type => Int)\n total: number\n}\n\n@ObjectType()\nexport class WorkShiftInfo {\n @Field({ nullable: true })\n workDate?: string\n\n @Field({ nullable: true })\n workShift?: string\n\n @Field(type => [Date], { nullable: true })\n dateRange?: Date[]\n\n @Field(type => [Date], { nullable: true })\n shiftRange?: Date[]\n}\n"]}
|
|
@@ -15,6 +15,38 @@ export declare class WorkShift {
|
|
|
15
15
|
fromTime: string;
|
|
16
16
|
toDate: WorkShiftDateType;
|
|
17
17
|
toTime: string;
|
|
18
|
+
/**
|
|
19
|
+
* Which weekdays this shift runs on — 0 Sunday … 6 Saturday. Empty means every day.
|
|
20
|
+
*
|
|
21
|
+
* ── What was wrong without it (2026-09-07) ────────────────────────────────
|
|
22
|
+
* A shift could only say what time of day it covers, never which days. So a site that
|
|
23
|
+
* rests on Saturday and Sunday was modelled as running 24 hours a day, seven days a
|
|
24
|
+
* week, and everything computed from available time inflated: OEE's planned production
|
|
25
|
+
* time, capacity, and the throughput predicted from them.
|
|
26
|
+
*
|
|
27
|
+
* The standard vocabulary already carried this. `WorkCalendarEntry` in
|
|
28
|
+
* `@operato/ops-contract` — ISA-95's `WorkCalendarEntryType` — has `daysOfWeek`, and
|
|
29
|
+
* operato-plant hands these rows to `equipment.workCalendar` as those entries. The
|
|
30
|
+
* field arrived at the boundary empty because there was nowhere here to read it from.
|
|
31
|
+
*
|
|
32
|
+
* ── Why a string and not a relation or an array column ────────────────────
|
|
33
|
+
* things-factory runs on five drivers and array columns are not portable across them
|
|
34
|
+
* (postgres spells them one way, sqlite has none). A short CSV of digits — `1,2,3,4,5`
|
|
35
|
+
* for a weekday-only shift — reads the same everywhere and is legible in a table
|
|
36
|
+
* during an incident.
|
|
37
|
+
*
|
|
38
|
+
* ── Empty means every day, and that is not the same as none ───────────────
|
|
39
|
+
* Existing rows have no value here and must keep behaving exactly as before, so absent
|
|
40
|
+
* reads as "every day". A shift that runs on no day at all is not a thing anyone means;
|
|
41
|
+
* if that ever needs saying, it is a shift that should be deleted or deactivated.
|
|
42
|
+
*
|
|
43
|
+
* ── One-off dates do not belong here ──────────────────────────────────────
|
|
44
|
+
* A holiday, a shutdown week, a maintenance window on one particular date is an
|
|
45
|
+
* absolute interval, and `@things-factory/calendar` already stores those as `Event`
|
|
46
|
+
* rows with `startDateTime`/`endDateTime`. Putting them here as well would give the
|
|
47
|
+
* same fact two homes and split which screen a person registers August 15th on.
|
|
48
|
+
*/
|
|
49
|
+
daysOfWeek?: string;
|
|
18
50
|
createdAt?: Date;
|
|
19
51
|
updatedAt?: Date;
|
|
20
52
|
creator?: User;
|
|
@@ -65,6 +65,11 @@ tslib_1.__decorate([
|
|
|
65
65
|
(0, type_graphql_1.Field)({ nullable: true }),
|
|
66
66
|
tslib_1.__metadata("design:type", String)
|
|
67
67
|
], WorkShift.prototype, "toTime", void 0);
|
|
68
|
+
tslib_1.__decorate([
|
|
69
|
+
(0, typeorm_1.Column)({ type: 'varchar', nullable: true }),
|
|
70
|
+
(0, type_graphql_1.Field)({ nullable: true, description: 'Weekdays this shift runs on as a CSV of 0(Sun)..6(Sat). Empty means every day' }),
|
|
71
|
+
tslib_1.__metadata("design:type", String)
|
|
72
|
+
], WorkShift.prototype, "daysOfWeek", void 0);
|
|
68
73
|
tslib_1.__decorate([
|
|
69
74
|
(0, typeorm_1.CreateDateColumn)(),
|
|
70
75
|
(0, type_graphql_1.Field)({ nullable: true }),
|
|
@@ -1 +1 @@
|
|
|
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,iCAAjB,iBAAiB,QAI5B;AAED,IAAA,+BAAgB,EAAC,iBAAiB,EAAE;IAClC,IAAI,EAAE,mBAAmB;IACzB,WAAW,EAAE,6BAA6B;CAC3C,CAAC,CAAA;AAQK,IAAM,SAAS,GAAf,MAAM,SAAS;
|
|
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,iCAAjB,iBAAiB,QAI5B;AAED,IAAA,+BAAgB,EAAC,iBAAiB,EAAE;IAClC,IAAI,EAAE,mBAAmB;IACzB,WAAW,EAAE,6BAA6B;CAC3C,CAAC,CAAA;AAQK,IAAM,SAAS,GAAf,MAAM,SAAS;CA8FrB,CAAA;AA9FY,8BAAS;AAGX;IAFR,IAAA,gCAAsB,EAAC,MAAM,CAAC;IAC9B,IAAA,oBAAK,EAAC,IAAI,CAAC,EAAE,CAAC,iBAAE,CAAC;;qCACC;AAInB;IAFC,IAAA,mBAAS,EAAC,IAAI,CAAC,EAA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import { 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(type => Domain)\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 /**\n * Which weekdays this shift runs on — 0 Sunday … 6 Saturday. Empty means every day.\n *\n * ── What was wrong without it (2026-09-07) ────────────────────────────────\n * A shift could only say what time of day it covers, never which days. So a site that\n * rests on Saturday and Sunday was modelled as running 24 hours a day, seven days a\n * week, and everything computed from available time inflated: OEE's planned production\n * time, capacity, and the throughput predicted from them.\n *\n * The standard vocabulary already carried this. `WorkCalendarEntry` in\n * `@operato/ops-contract` — ISA-95's `WorkCalendarEntryType` — has `daysOfWeek`, and\n * operato-plant hands these rows to `equipment.workCalendar` as those entries. The\n * field arrived at the boundary empty because there was nowhere here to read it from.\n *\n * ── Why a string and not a relation or an array column ────────────────────\n * things-factory runs on five drivers and array columns are not portable across them\n * (postgres spells them one way, sqlite has none). A short CSV of digits — `1,2,3,4,5`\n * for a weekday-only shift — reads the same everywhere and is legible in a table\n * during an incident.\n *\n * ── Empty means every day, and that is not the same as none ───────────────\n * Existing rows have no value here and must keep behaving exactly as before, so absent\n * reads as \"every day\". A shift that runs on no day at all is not a thing anyone means;\n * if that ever needs saying, it is a shift that should be deleted or deactivated.\n *\n * ── One-off dates do not belong here ──────────────────────────────────────\n * A holiday, a shutdown week, a maintenance window on one particular date is an\n * absolute interval, and `@things-factory/calendar` already stores those as `Event`\n * rows with `startDateTime`/`endDateTime`. Putting them here as well would give the\n * same fact two homes and split which screen a person registers August 15th on.\n */\n @Column({ type: 'varchar', nullable: true })\n @Field({ nullable: true, description: 'Weekdays this shift runs on as a CSV of 0(Sun)..6(Sat). Empty means every day' })\n daysOfWeek?: 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, { nullable: true })\n @Field(type => User, { nullable: true })\n creator?: User\n\n @RelationId((workShift: WorkShift) => workShift.creator)\n creatorId?: string\n\n @ManyToOne(type => User, { nullable: true })\n @Field(type => User, { nullable: true })\n updater?: User\n\n @RelationId((workShift: WorkShift) => workShift.updater)\n updaterId?: string\n}\n"]}
|