@things-factory/calendar 10.1.232 → 10.1.236
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/calendar/calendar-days-off-page.d.ts +43 -0
- package/dist-client/pages/calendar/calendar-days-off-page.js +161 -0
- package/dist-client/pages/calendar/calendar-days-off-page.js.map +1 -0
- package/dist-client/pages/calendar/calendar-list-page.js +33 -5
- package/dist-client/pages/calendar/calendar-list-page.js.map +1 -1
- package/dist-client/pages/event/event-list-page.d.ts +4 -0
- package/dist-client/pages/event/event-list-page.js +60 -5
- package/dist-client/pages/event/event-list-page.js.map +1 -1
- package/dist-client/pages/sure-to-delete.d.ts +1 -0
- package/dist-client/pages/sure-to-delete.js +10 -0
- package/dist-client/pages/sure-to-delete.js.map +1 -0
- package/dist-client/route.d.ts +1 -1
- package/dist-client/route.js +3 -0
- package/dist-client/route.js.map +1 -1
- package/dist-client/tsconfig.tsbuildinfo +1 -1
- package/dist-server/service/calendar/calendar-service.js +14 -1
- package/dist-server/service/calendar/calendar-service.js.map +1 -1
- package/dist-server/service/calendar/calendar-type.d.ts +24 -1
- package/dist-server/service/calendar/calendar-type.js +85 -1
- package/dist-server/service/calendar/calendar-type.js.map +1 -1
- package/dist-server/service/calendar/calendar.d.ts +7 -0
- package/dist-server/service/calendar/calendar.js +22 -1
- package/dist-server/service/calendar/calendar.js.map +1 -1
- package/dist-server/service/calendar/index.d.ts +2 -1
- package/dist-server/service/calendar/index.js +2 -1
- package/dist-server/service/calendar/index.js.map +1 -1
- package/dist-server/service/calendar/working-days-resolver.d.ts +8 -0
- package/dist-server/service/calendar/working-days-resolver.js +92 -0
- package/dist-server/service/calendar/working-days-resolver.js.map +1 -0
- package/dist-server/service/calendar/working-days.d.ts +49 -0
- package/dist-server/service/calendar/working-days.js +185 -0
- package/dist-server/service/calendar/working-days.js.map +1 -0
- package/dist-server/service/event/event-query.js +1 -1
- package/dist-server/service/event/event-query.js.map +1 -1
- package/dist-server/service/event-series/recurrence.d.ts +2 -0
- package/dist-server/service/event-series/recurrence.js +1 -0
- package/dist-server/service/event-series/recurrence.js.map +1 -1
- package/dist-server/service/index.d.ts +3 -2
- package/dist-server/service/index.js +1 -0
- package/dist-server/service/index.js.map +1 -1
- package/dist-server/tsconfig.tsbuildinfo +1 -1
- package/package.json +5 -4
- package/things-factory.config.js +4 -0
- package/translations/en.json +23 -1
- package/translations/es.json +23 -1
- package/translations/ja.json +23 -1
- package/translations/ko.json +23 -1
- package/translations/ms.json +23 -1
- package/translations/zh.json +23 -1
|
@@ -27,7 +27,7 @@ async function checkCalendarName(tx, domain, name, id) {
|
|
|
27
27
|
async function createCalendar(tx, domain, user, input) {
|
|
28
28
|
const name = await checkCalendarName(tx, domain, input.name);
|
|
29
29
|
const repository = tx.getRepository(calendar_1.Calendar);
|
|
30
|
-
const saved = await repository.save(repository.create({ domain, name, description: input.description?.trim() || null, active: input.active ?? true, creator: user, updater: user }));
|
|
30
|
+
const saved = await repository.save(repository.create({ domain, name, description: input.description?.trim() || null, active: input.active ?? true, kind: await checkCalendarKind(tx, domain, input.kind ?? calendar_1.CalendarKind.GENERAL), creator: user, updater: user }));
|
|
31
31
|
return calendarInDomain(tx, domain, saved.id);
|
|
32
32
|
}
|
|
33
33
|
async function updateCalendar(tx, domain, user, id, patch) {
|
|
@@ -39,6 +39,8 @@ async function updateCalendar(tx, domain, user, id, patch) {
|
|
|
39
39
|
change.description = patch.description?.trim() || null;
|
|
40
40
|
if (patch.active !== undefined && patch.active !== null)
|
|
41
41
|
change.active = patch.active;
|
|
42
|
+
if (patch.kind !== undefined && patch.kind !== null && patch.kind !== calendar.kind)
|
|
43
|
+
change.kind = await checkCalendarKind(tx, domain, patch.kind, calendar.id);
|
|
42
44
|
await tx.getRepository(calendar_1.Calendar).update({ id: calendar.id }, change);
|
|
43
45
|
return calendarInDomain(tx, domain, id);
|
|
44
46
|
}
|
|
@@ -55,4 +57,15 @@ async function deleteCalendars(tx, domain, user, ids) {
|
|
|
55
57
|
await tx.getRepository(calendar_1.Calendar).softDelete({ id: (0, typeorm_1.In)(ids) });
|
|
56
58
|
return true;
|
|
57
59
|
}
|
|
60
|
+
/** The public holidays are one calendar of a domain, the one the import fills. */
|
|
61
|
+
async function checkCalendarKind(tx, domain, kind, id) {
|
|
62
|
+
if (!Object.values(calendar_1.CalendarKind).includes(kind))
|
|
63
|
+
throw new shell_1.Refusal('calendar-kind-invalid', { kind: String(kind) }, 'Choose general, days off or public holidays');
|
|
64
|
+
if (kind === calendar_1.CalendarKind.PUBLIC_HOLIDAYS) {
|
|
65
|
+
const other = await tx.getRepository(calendar_1.Calendar).findOne({ where: { domain: { id: domain.id }, kind, ...(id ? { id: (0, typeorm_1.Not)(id) } : {}) } });
|
|
66
|
+
if (other)
|
|
67
|
+
throw new shell_1.Refusal('calendar-public-holidays-taken', { name: other.name }, 'This domain already has its public holiday calendar');
|
|
68
|
+
}
|
|
69
|
+
return kind;
|
|
70
|
+
}
|
|
58
71
|
//# sourceMappingURL=calendar-service.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"calendar-service.js","sourceRoot":"","sources":["../../../server/service/calendar/calendar-service.ts"],"names":[],"mappings":";;AAUA,4CAIC;AAUD,wCAOC;AAED,
|
|
1
|
+
{"version":3,"file":"calendar-service.js","sourceRoot":"","sources":["../../../server/service/calendar/calendar-service.ts"],"names":[],"mappings":";;AAUA,4CAIC;AAUD,wCAOC;AAED,wCASC;AAGD,0CAUC;AAvDD,qCAAgD;AAGhD,iDAAuD;AAEvD,0CAAsC;AACtC,+DAA0D;AAC1D,yCAAmD;AAG5C,KAAK,UAAU,gBAAgB,CAAC,EAAiB,EAAE,MAAc,EAAE,EAAU;IAClF,MAAM,QAAQ,GAAG,MAAM,EAAE,CAAC,aAAa,CAAC,mBAAQ,CAAC,CAAC,OAAO,CAAC,EAAE,KAAK,EAAE,EAAE,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,EAAE,MAA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KAAK;YAAE,MAAM,IAAI,eAAO,CAAC,gCAAgC,EAAE,EAAE,IAAI,EAAE,KAAK,CAAC,IAAI,EAAE,EAAE,qDAAqD,CAAC,CAAA;IAC7I,CAAC;IACD,OAAO,IAAI,CAAA;AACb,CAAC","sourcesContent":["import { EntityManager, In, Not } from 'typeorm'\n\nimport { User } from '@things-factory/auth-base'\nimport { Domain, Refusal } from '@things-factory/shell'\n\nimport { Event } from '../event/event'\nimport { EventSeries } from '../event-series/event-series'\nimport { Calendar, CalendarKind } from './calendar'\nimport { CalendarPatch, NewCalendar } from './calendar-type'\n\nexport async function calendarInDomain(tx: EntityManager, domain: Domain, id: string): Promise<Calendar> {\n const calendar = await tx.getRepository(Calendar).findOne({ where: { id, domain: { id: domain.id } } })\n if (!calendar) throw new Refusal('calendar-not-found', {}, 'Choose a calendar of this domain')\n return calendar\n}\n\nasync function checkCalendarName(tx: EntityManager, domain: Domain, name: string | undefined, id?: string): Promise<string> {\n const trimmed = name?.trim()\n if (!trimmed) throw new Refusal('calendar-name-required', {}, 'Name the calendar')\n const same = await tx.getRepository(Calendar).findOne({ where: { domain: { id: domain.id }, name: trimmed, ...(id ? { id: Not(id) } : {}) } })\n if (same) throw new Refusal('calendar-name-duplicate', { name: trimmed }, 'Another calendar of this domain has that name')\n return trimmed\n}\n\nexport async function createCalendar(tx: EntityManager, domain: Domain, user: User, input: NewCalendar): Promise<Calendar> {\n const name = await checkCalendarName(tx, domain, input.name)\n const repository = tx.getRepository(Calendar)\n const saved = await repository.save(\n repository.create({ domain, name, description: input.description?.trim() || null, active: input.active ?? true, kind: await checkCalendarKind(tx, domain, input.kind ?? CalendarKind.GENERAL), creator: user, updater: user })\n )\n return calendarInDomain(tx, domain, saved.id)\n}\n\nexport async function updateCalendar(tx: EntityManager, domain: Domain, user: User, id: string, patch: CalendarPatch): Promise<Calendar> {\n const calendar = await calendarInDomain(tx, domain, id)\n const change: Partial<Calendar> = { updater: user }\n if (patch.name !== undefined) change.name = await checkCalendarName(tx, domain, patch.name, calendar.id)\n if (patch.description !== undefined) change.description = patch.description?.trim() || null\n if (patch.active !== undefined && patch.active !== null) change.active = patch.active\n if (patch.kind !== undefined && patch.kind !== null && patch.kind !== calendar.kind) change.kind = await checkCalendarKind(tx, domain, patch.kind, calendar.id)\n await tx.getRepository(Calendar).update({ id: calendar.id }, change)\n return calendarInDomain(tx, domain, id)\n}\n\n/** A calendar that still holds events or series is not deleted; they would lose their place. */\nexport async function deleteCalendars(tx: EntityManager, domain: Domain, user: User, ids: string[]): Promise<boolean> {\n const calendars = await tx.getRepository(Calendar).find({ where: { domain: { id: domain.id }, id: In(ids) } })\n if (calendars.length !== new Set(ids).size) throw new Refusal('calendar-not-found', {}, 'Choose a calendar of this domain')\n const used =\n (await tx.getRepository(Event).count({ where: { domain: { id: domain.id }, calendar: { id: In(ids) } } })) +\n (await tx.getRepository(EventSeries).count({ where: { domain: { id: domain.id }, calendar: { id: In(ids) } } }))\n if (used) throw new Refusal('calendar-in-use', {}, 'Move or delete the events and series of the calendar first')\n await tx.getRepository(Calendar).update({ id: In(ids) }, { updater: user })\n await tx.getRepository(Calendar).softDelete({ id: In(ids) })\n return true\n}\n\n/** The public holidays are one calendar of a domain, the one the import fills. */\nasync function checkCalendarKind(tx: EntityManager, domain: Domain, kind: CalendarKind, id?: string): Promise<CalendarKind> {\n if (!Object.values(CalendarKind).includes(kind)) throw new Refusal('calendar-kind-invalid', { kind: String(kind) }, 'Choose general, days off or public holidays')\n if (kind === CalendarKind.PUBLIC_HOLIDAYS) {\n const other = await tx.getRepository(Calendar).findOne({ where: { domain: { id: domain.id }, kind, ...(id ? { id: Not(id) } : {}) } })\n if (other) throw new Refusal('calendar-public-holidays-taken', { name: other.name }, 'This domain already has its public holiday calendar')\n }\n return kind\n}\n"]}
|
|
@@ -1,17 +1,40 @@
|
|
|
1
|
-
import { Calendar } from './calendar';
|
|
1
|
+
import { Calendar, CalendarKind } from './calendar';
|
|
2
2
|
export declare class NewCalendar {
|
|
3
3
|
name: string;
|
|
4
4
|
description?: string;
|
|
5
5
|
active?: boolean;
|
|
6
|
+
kind?: CalendarKind;
|
|
6
7
|
}
|
|
7
8
|
export declare class CalendarPatch {
|
|
8
9
|
id?: string;
|
|
9
10
|
name?: string;
|
|
10
11
|
description?: string;
|
|
11
12
|
active?: boolean;
|
|
13
|
+
kind?: CalendarKind;
|
|
12
14
|
cuFlag?: string;
|
|
13
15
|
}
|
|
14
16
|
export declare class CalendarList {
|
|
15
17
|
items: Calendar[];
|
|
16
18
|
total: number;
|
|
17
19
|
}
|
|
20
|
+
export declare class PublicHolidayInput {
|
|
21
|
+
day: string;
|
|
22
|
+
name: string;
|
|
23
|
+
}
|
|
24
|
+
export declare class DayOff {
|
|
25
|
+
day: string;
|
|
26
|
+
name: string;
|
|
27
|
+
}
|
|
28
|
+
export declare class DayOffSpan {
|
|
29
|
+
id: string;
|
|
30
|
+
name: string;
|
|
31
|
+
from: string;
|
|
32
|
+
to: string;
|
|
33
|
+
}
|
|
34
|
+
export declare class DayOffSpanPatch {
|
|
35
|
+
id?: string;
|
|
36
|
+
name?: string;
|
|
37
|
+
from?: string;
|
|
38
|
+
to?: string;
|
|
39
|
+
cuFlag: string;
|
|
40
|
+
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.CalendarList = exports.CalendarPatch = exports.NewCalendar = void 0;
|
|
3
|
+
exports.DayOffSpanPatch = exports.DayOffSpan = exports.DayOff = exports.PublicHolidayInput = exports.CalendarList = exports.CalendarPatch = exports.NewCalendar = void 0;
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
5
|
const type_graphql_1 = require("type-graphql");
|
|
6
6
|
const calendar_1 = require("./calendar");
|
|
@@ -19,6 +19,10 @@ tslib_1.__decorate([
|
|
|
19
19
|
(0, type_graphql_1.Field)({ nullable: true, description: 'Whether the calendar is in use; true when empty' }),
|
|
20
20
|
tslib_1.__metadata("design:type", Boolean)
|
|
21
21
|
], NewCalendar.prototype, "active", void 0);
|
|
22
|
+
tslib_1.__decorate([
|
|
23
|
+
(0, type_graphql_1.Field)(type => calendar_1.CalendarKind, { nullable: true, description: 'What its events mean for the working days; general when empty' }),
|
|
24
|
+
tslib_1.__metadata("design:type", String)
|
|
25
|
+
], NewCalendar.prototype, "kind", void 0);
|
|
22
26
|
exports.NewCalendar = NewCalendar = tslib_1.__decorate([
|
|
23
27
|
(0, type_graphql_1.InputType)({ description: 'A calendar to create' })
|
|
24
28
|
], NewCalendar);
|
|
@@ -41,6 +45,10 @@ tslib_1.__decorate([
|
|
|
41
45
|
(0, type_graphql_1.Field)({ nullable: true, description: 'Whether the calendar is in use' }),
|
|
42
46
|
tslib_1.__metadata("design:type", Boolean)
|
|
43
47
|
], CalendarPatch.prototype, "active", void 0);
|
|
48
|
+
tslib_1.__decorate([
|
|
49
|
+
(0, type_graphql_1.Field)(type => calendar_1.CalendarKind, { nullable: true, description: 'What its events mean for the working days' }),
|
|
50
|
+
tslib_1.__metadata("design:type", String)
|
|
51
|
+
], CalendarPatch.prototype, "kind", void 0);
|
|
44
52
|
tslib_1.__decorate([
|
|
45
53
|
(0, type_graphql_1.Field)({ nullable: true, description: 'Grid row flag: + to create, M to modify' }),
|
|
46
54
|
tslib_1.__metadata("design:type", String)
|
|
@@ -62,4 +70,80 @@ tslib_1.__decorate([
|
|
|
62
70
|
exports.CalendarList = CalendarList = tslib_1.__decorate([
|
|
63
71
|
(0, type_graphql_1.ObjectType)({ description: 'A page of calendars' })
|
|
64
72
|
], CalendarList);
|
|
73
|
+
let PublicHolidayInput = class PublicHolidayInput {
|
|
74
|
+
};
|
|
75
|
+
exports.PublicHolidayInput = PublicHolidayInput;
|
|
76
|
+
tslib_1.__decorate([
|
|
77
|
+
(0, type_graphql_1.Field)({ description: 'The day, YYYY-MM-DD' }),
|
|
78
|
+
tslib_1.__metadata("design:type", String)
|
|
79
|
+
], PublicHolidayInput.prototype, "day", void 0);
|
|
80
|
+
tslib_1.__decorate([
|
|
81
|
+
(0, type_graphql_1.Field)({ description: 'Name of the holiday' }),
|
|
82
|
+
tslib_1.__metadata("design:type", String)
|
|
83
|
+
], PublicHolidayInput.prototype, "name", void 0);
|
|
84
|
+
exports.PublicHolidayInput = PublicHolidayInput = tslib_1.__decorate([
|
|
85
|
+
(0, type_graphql_1.InputType)({ description: 'A public holiday of a year, as the import gives it' })
|
|
86
|
+
], PublicHolidayInput);
|
|
87
|
+
let DayOff = class DayOff {
|
|
88
|
+
};
|
|
89
|
+
exports.DayOff = DayOff;
|
|
90
|
+
tslib_1.__decorate([
|
|
91
|
+
(0, type_graphql_1.Field)({ description: 'The day, YYYY-MM-DD' }),
|
|
92
|
+
tslib_1.__metadata("design:type", String)
|
|
93
|
+
], DayOff.prototype, "day", void 0);
|
|
94
|
+
tslib_1.__decorate([
|
|
95
|
+
(0, type_graphql_1.Field)({ description: 'What makes it a day off - the holiday or the day off as named on its calendar' }),
|
|
96
|
+
tslib_1.__metadata("design:type", String)
|
|
97
|
+
], DayOff.prototype, "name", void 0);
|
|
98
|
+
exports.DayOff = DayOff = tslib_1.__decorate([
|
|
99
|
+
(0, type_graphql_1.ObjectType)({ description: 'A day that is not worked - a public holiday or a day off of the domain' })
|
|
100
|
+
], DayOff);
|
|
101
|
+
let DayOffSpan = class DayOffSpan {
|
|
102
|
+
};
|
|
103
|
+
exports.DayOffSpan = DayOffSpan;
|
|
104
|
+
tslib_1.__decorate([
|
|
105
|
+
(0, type_graphql_1.Field)(type => type_graphql_1.ID, { description: 'Id of the event that holds it' }),
|
|
106
|
+
tslib_1.__metadata("design:type", String)
|
|
107
|
+
], DayOffSpan.prototype, "id", void 0);
|
|
108
|
+
tslib_1.__decorate([
|
|
109
|
+
(0, type_graphql_1.Field)({ description: 'What the day off is - 창립기념일, 하계 휴무' }),
|
|
110
|
+
tslib_1.__metadata("design:type", String)
|
|
111
|
+
], DayOffSpan.prototype, "name", void 0);
|
|
112
|
+
tslib_1.__decorate([
|
|
113
|
+
(0, type_graphql_1.Field)({ description: 'The first day, YYYY-MM-DD' }),
|
|
114
|
+
tslib_1.__metadata("design:type", String)
|
|
115
|
+
], DayOffSpan.prototype, "from", void 0);
|
|
116
|
+
tslib_1.__decorate([
|
|
117
|
+
(0, type_graphql_1.Field)({ description: 'The last day, YYYY-MM-DD; the same as from for one day' }),
|
|
118
|
+
tslib_1.__metadata("design:type", String)
|
|
119
|
+
], DayOffSpan.prototype, "to", void 0);
|
|
120
|
+
exports.DayOffSpan = DayOffSpan = tslib_1.__decorate([
|
|
121
|
+
(0, type_graphql_1.ObjectType)({ description: 'A day off of a days-off calendar, written as whole days from one day to another' })
|
|
122
|
+
], DayOffSpan);
|
|
123
|
+
let DayOffSpanPatch = class DayOffSpanPatch {
|
|
124
|
+
};
|
|
125
|
+
exports.DayOffSpanPatch = DayOffSpanPatch;
|
|
126
|
+
tslib_1.__decorate([
|
|
127
|
+
(0, type_graphql_1.Field)(type => type_graphql_1.ID, { nullable: true, description: 'Id of the day off changed or taken away; empty for a new one' }),
|
|
128
|
+
tslib_1.__metadata("design:type", String)
|
|
129
|
+
], DayOffSpanPatch.prototype, "id", void 0);
|
|
130
|
+
tslib_1.__decorate([
|
|
131
|
+
(0, type_graphql_1.Field)({ nullable: true, description: 'What the day off is' }),
|
|
132
|
+
tslib_1.__metadata("design:type", String)
|
|
133
|
+
], DayOffSpanPatch.prototype, "name", void 0);
|
|
134
|
+
tslib_1.__decorate([
|
|
135
|
+
(0, type_graphql_1.Field)({ nullable: true, description: 'The first day, YYYY-MM-DD' }),
|
|
136
|
+
tslib_1.__metadata("design:type", String)
|
|
137
|
+
], DayOffSpanPatch.prototype, "from", void 0);
|
|
138
|
+
tslib_1.__decorate([
|
|
139
|
+
(0, type_graphql_1.Field)({ nullable: true, description: 'The last day, YYYY-MM-DD; left out, the first day' }),
|
|
140
|
+
tslib_1.__metadata("design:type", String)
|
|
141
|
+
], DayOffSpanPatch.prototype, "to", void 0);
|
|
142
|
+
tslib_1.__decorate([
|
|
143
|
+
(0, type_graphql_1.Field)({ description: "'+' to add, 'M' to change, '-' to take away" }),
|
|
144
|
+
tslib_1.__metadata("design:type", String)
|
|
145
|
+
], DayOffSpanPatch.prototype, "cuFlag", void 0);
|
|
146
|
+
exports.DayOffSpanPatch = DayOffSpanPatch = tslib_1.__decorate([
|
|
147
|
+
(0, type_graphql_1.InputType)({ description: 'A day off added, changed or taken away on a days-off calendar' })
|
|
148
|
+
], DayOffSpanPatch);
|
|
65
149
|
//# sourceMappingURL=calendar-type.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"calendar-type.js","sourceRoot":"","sources":["../../../server/service/calendar/calendar-type.ts"],"names":[],"mappings":";;;;AAAA,+CAAoE;AAEpE,
|
|
1
|
+
{"version":3,"file":"calendar-type.js","sourceRoot":"","sources":["../../../server/service/calendar/calendar-type.ts"],"names":[],"mappings":";;;;AAAA,+CAAoE;AAEpE,yCAAmD;AAG5C,IAAM,WAAW,GAAjB,MAAM,WAAW;CAYvB,CAAA;AAZY,kCAAW;AAEtB;IADC,IAAA,oBAAK,EAAC,EAAE,WAAW,EAAE,4CAA4C,EAAE,CAAC;;yCACzD;AAGZ;IADC,IAAA,oBAAK,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,WAAW,EAAE,0BAA0B,EAAE,CAAC;;gDAC/C;AAGpB;IADC,IAAA,oBAAK,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,WAAW,EAAE,iDAAiD,EAAE,CAAC;;2CAC1E;AAGhB;IADC,IAAA,oBAAK,EAAC,IAAI,CAAC,EAAE,CAAC,uBAAY,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,WAAW,EAAE,+DAA+D,EAAE,CAAC;;yCAC3G;sBAXR,WAAW;IADvB,IAAA,wBAAS,EAAC,EAAE,WAAW,EAAE,sBAAsB,EAAE,CAAC;GACtC,WAAW,CAYvB;AAGM,IAAM,aAAa,G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C,IAAA,oBAAK,EAAC,IAAI,CAAC,EAAE,CAAC,iBAAE,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,WAAW,EAAE,8DAA8D,EAAE,CAAC;;2CACxG;AAGX;IADC,IAAA,oBAAK,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,WAAW,EAAE,qBAAqB,EAAE,CAAC;;6CACjD;AAGb;IADC,IAAA,oBAAK,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,WAAW,EAAE,2BAA2B,EAAE,CAAC;;6CACvD;AAGb;IADC,IAAA,oBAAK,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,WAAW,EAAE,mDAAmD,EAAE,CAAC;;2CACjF;AAGX;IADC,IAAA,oBAAK,EAAC,EAAE,WAAW,EAAE,6CAA6C,EAAE,CAAC;;+CACxD;0BAdH,eAAe;IAD3B,IAAA,wBAAS,EAAC,EAAE,WAAW,EAAE,+DAA+D,EAAE,CAAC;GAC/E,eAAe,CAe3B","sourcesContent":["import { Field, ID, InputType, Int, ObjectType } from 'type-graphql'\n\nimport { Calendar, CalendarKind } from './calendar'\n\n@InputType({ description: 'A calendar to create' })\nexport class NewCalendar {\n @Field({ description: 'Name of the calendar, unique in the domain' })\n name: string\n\n @Field({ nullable: true, description: 'What the calendar is for' })\n description?: string\n\n @Field({ nullable: true, description: 'Whether the calendar is in use; true when empty' })\n active?: boolean\n\n @Field(type => CalendarKind, { nullable: true, description: 'What its events mean for the working days; general when empty' })\n kind?: CalendarKind\n}\n\n@InputType({ description: 'What changes on a calendar; a grid row carries its id and cuFlag' })\nexport class CalendarPatch {\n @Field(type => ID, { nullable: true, description: 'Id of the calendar, for a grid row' })\n id?: string\n\n @Field({ nullable: true, description: 'Name of the calendar, unique in the domain' })\n name?: string\n\n @Field({ nullable: true, description: 'What the calendar is for' })\n description?: string\n\n @Field({ nullable: true, description: 'Whether the calendar is in use' })\n active?: boolean\n\n @Field(type => CalendarKind, { nullable: true, description: 'What its events mean for the working days' })\n kind?: CalendarKind\n\n @Field({ nullable: true, description: 'Grid row flag: + to create, M to modify' })\n cuFlag?: string\n}\n\n@ObjectType({ description: 'A page of calendars' })\nexport class CalendarList {\n @Field(type => [Calendar], { description: 'The calendars on this page' })\n items: Calendar[]\n\n @Field(type => Int, { description: 'How many calendars match in all' })\n total: number\n}\n\n@InputType({ description: 'A public holiday of a year, as the import gives it' })\nexport class PublicHolidayInput {\n @Field({ description: 'The day, YYYY-MM-DD' })\n day: string\n\n @Field({ description: 'Name of the holiday' })\n name: string\n}\n\n@ObjectType({ description: 'A day that is not worked - a public holiday or a day off of the domain' })\nexport class DayOff {\n @Field({ description: 'The day, YYYY-MM-DD' })\n day: string\n\n @Field({ description: 'What makes it a day off - the holiday or the day off as named on its calendar' })\n name: string\n}\n\n@ObjectType({ description: 'A day off of a days-off calendar, written as whole days from one day to another' })\nexport class DayOffSpan {\n @Field(type => ID, { description: 'Id of the event that holds it' })\n id: string\n\n @Field({ description: 'What the day off is - 창립기념일, 하계 휴무' })\n name: string\n\n @Field({ description: 'The first day, YYYY-MM-DD' })\n from: string\n\n @Field({ description: 'The last day, YYYY-MM-DD; the same as from for one day' })\n to: string\n}\n\n@InputType({ description: 'A day off added, changed or taken away on a days-off calendar' })\nexport class DayOffSpanPatch {\n @Field(type => ID, { nullable: true, description: 'Id of the day off changed or taken away; empty for a new one' })\n id?: string\n\n @Field({ nullable: true, description: 'What the day off is' })\n name?: string\n\n @Field({ nullable: true, description: 'The first day, YYYY-MM-DD' })\n from?: string\n\n @Field({ nullable: true, description: 'The last day, YYYY-MM-DD; left out, the first day' })\n to?: string\n\n @Field({ description: \"'+' to add, 'M' to change, '-' to take away\" })\n cuFlag: string\n}\n\n"]}
|
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
import { Domain } from '@things-factory/shell';
|
|
2
2
|
import { User } from '@things-factory/auth-base';
|
|
3
|
+
/** What a calendar's events mean for the working days (ADR-0179 결정 2). */
|
|
4
|
+
export declare enum CalendarKind {
|
|
5
|
+
GENERAL = "GENERAL",
|
|
6
|
+
DAYS_OFF = "DAYS_OFF",
|
|
7
|
+
PUBLIC_HOLIDAYS = "PUBLIC_HOLIDAYS"
|
|
8
|
+
}
|
|
3
9
|
/**
|
|
4
10
|
* A named group of events in a domain — "management meetings", "plant holidays". Events and series may belong to
|
|
5
11
|
* one; it is optional.
|
|
@@ -11,6 +17,7 @@ export declare class Calendar {
|
|
|
11
17
|
name: string;
|
|
12
18
|
description?: string;
|
|
13
19
|
active: boolean;
|
|
20
|
+
kind: CalendarKind;
|
|
14
21
|
createdAt?: Date;
|
|
15
22
|
updatedAt?: Date;
|
|
16
23
|
deletedAt?: Date;
|
|
@@ -1,11 +1,27 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.Calendar = void 0;
|
|
3
|
+
exports.Calendar = exports.CalendarKind = void 0;
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
5
|
const typeorm_1 = require("typeorm");
|
|
6
6
|
const type_graphql_1 = require("type-graphql");
|
|
7
7
|
const shell_1 = require("@things-factory/shell");
|
|
8
8
|
const auth_base_1 = require("@things-factory/auth-base");
|
|
9
|
+
/** What a calendar's events mean for the working days (ADR-0179 결정 2). */
|
|
10
|
+
var CalendarKind;
|
|
11
|
+
(function (CalendarKind) {
|
|
12
|
+
CalendarKind["GENERAL"] = "GENERAL";
|
|
13
|
+
CalendarKind["DAYS_OFF"] = "DAYS_OFF";
|
|
14
|
+
CalendarKind["PUBLIC_HOLIDAYS"] = "PUBLIC_HOLIDAYS";
|
|
15
|
+
})(CalendarKind || (exports.CalendarKind = CalendarKind = {}));
|
|
16
|
+
(0, type_graphql_1.registerEnumType)(CalendarKind, {
|
|
17
|
+
name: 'CalendarKind',
|
|
18
|
+
description: 'What the events of a calendar mean for the working days',
|
|
19
|
+
valuesConfig: {
|
|
20
|
+
GENERAL: { description: 'Meetings and happenings; the working days do not change' },
|
|
21
|
+
DAYS_OFF: { description: "The company's own days off; a day one of its events covers is not a working day" },
|
|
22
|
+
PUBLIC_HOLIDAYS: { description: 'The public holidays, one per domain, filled by an import; not working days' }
|
|
23
|
+
}
|
|
24
|
+
});
|
|
9
25
|
/**
|
|
10
26
|
* A named group of events in a domain — "management meetings", "plant holidays". Events and series may belong to
|
|
11
27
|
* one; it is optional.
|
|
@@ -42,6 +58,11 @@ tslib_1.__decorate([
|
|
|
42
58
|
(0, type_graphql_1.Field)({ description: 'Whether the calendar is in use' }),
|
|
43
59
|
tslib_1.__metadata("design:type", Boolean)
|
|
44
60
|
], Calendar.prototype, "active", void 0);
|
|
61
|
+
tslib_1.__decorate([
|
|
62
|
+
(0, typeorm_1.Column)({ default: CalendarKind.GENERAL }),
|
|
63
|
+
(0, type_graphql_1.Field)(type => CalendarKind, { description: 'What the events of the calendar mean for the working days' }),
|
|
64
|
+
tslib_1.__metadata("design:type", String)
|
|
65
|
+
], Calendar.prototype, "kind", void 0);
|
|
45
66
|
tslib_1.__decorate([
|
|
46
67
|
(0, typeorm_1.CreateDateColumn)(),
|
|
47
68
|
(0, type_graphql_1.Field)({ nullable: true, description: 'Creation timestamp' }),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"calendar.js","sourceRoot":"","sources":["../../../server/service/calendar/calendar.ts"],"names":[],"mappings":";;;;AAAA,qCAAoJ;AACpJ,+
|
|
1
|
+
{"version":3,"file":"calendar.js","sourceRoot":"","sources":["../../../server/service/calendar/calendar.ts"],"names":[],"mappings":";;;;AAAA,qCAAoJ;AACpJ,+CAAsE;AAEtE,iDAA8C;AAC9C,yDAAgD;AAEhD,0EAA0E;AAC1E,IAAY,YAIX;AAJD,WAAY,YAAY;IACtB,mCAAmB,CAAA;IACnB,qCAAqB,CAAA;IACrB,mDAAmC,CAAA;AACrC,CAAC,EAJW,YAAY,4BAAZ,YAAY,QAIvB;AAED,IAAA,+BAAgB,EAAC,YAAY,EAAE;IAC7B,IAAI,EAAE,cAAc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AC,QAAkB,EAAE,EAAE,CAAC,QAAQ,CAAC,OAAO,CAAC;;2CACnC;mBApDP,QAAQ;IAHpB,IAAA,gBAAM,GAAE;IACR,IAAA,eAAK,EAAC,eAAe,EAAE,CAAC,QAAkB,EAAE,EAAE,CAAC,CAAC,QAAQ,CAAC,MAAM,EAAE,QAAQ,CAAC,IAAI,CAAC,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,KAAK,EAAE,sBAAsB,EAAE,CAAC;IACjI,IAAA,yBAAU,EAAC,EAAE,WAAW,EAAE,qCAAqC,EAAE,CAAC;GACtD,QAAQ,CAqDpB","sourcesContent":["import { Column, CreateDateColumn, DeleteDateColumn, Entity, Index, ManyToOne, PrimaryGeneratedColumn, RelationId, UpdateDateColumn } from 'typeorm'\nimport { Field, ID, ObjectType, registerEnumType } from 'type-graphql'\n\nimport { Domain } from '@things-factory/shell'\nimport { User } from '@things-factory/auth-base'\n\n/** What a calendar's events mean for the working days (ADR-0179 결정 2). */\nexport enum CalendarKind {\n GENERAL = 'GENERAL',\n DAYS_OFF = 'DAYS_OFF',\n PUBLIC_HOLIDAYS = 'PUBLIC_HOLIDAYS'\n}\n\nregisterEnumType(CalendarKind, {\n name: 'CalendarKind',\n description: 'What the events of a calendar mean for the working days',\n valuesConfig: {\n GENERAL: { description: 'Meetings and happenings; the working days do not change' },\n DAYS_OFF: { description: \"The company's own days off; a day one of its events covers is not a working day\" },\n PUBLIC_HOLIDAYS: { description: 'The public holidays, one per domain, filled by an import; not working days' }\n }\n})\n\n/**\n * A named group of events in a domain — \"management meetings\", \"plant holidays\". Events and series may belong to\n * one; it is optional.\n */\n@Entity()\n@Index('ix_calendar_0', (calendar: Calendar) => [calendar.domain, calendar.name], { unique: true, where: '\"deleted_at\" IS NULL' })\n@ObjectType({ description: 'A named group of events in a domain' })\nexport class Calendar {\n @PrimaryGeneratedColumn('uuid')\n @Field(type => ID, { description: 'Unique identifier of the calendar' })\n readonly id: string\n\n @ManyToOne(type => Domain)\n @Field(type => Domain, { nullable: true, description: 'The domain the calendar belongs to' })\n domain?: Domain\n\n @RelationId((calendar: Calendar) => calendar.domain)\n domainId?: string\n\n @Column()\n @Field({ description: 'Name of the calendar, unique in the domain' })\n name: string\n\n @Column({ type: 'text', nullable: true })\n @Field({ nullable: true, description: 'What the calendar is for' })\n description?: string\n\n @Column({ default: true })\n @Field({ description: 'Whether the calendar is in use' })\n active: boolean\n\n @Column({ default: CalendarKind.GENERAL })\n @Field(type => CalendarKind, { description: 'What the events of the calendar mean for the working days' })\n kind: CalendarKind\n\n @CreateDateColumn()\n @Field({ nullable: true, description: 'Creation timestamp' })\n createdAt?: Date\n\n @UpdateDateColumn()\n @Field({ nullable: true, description: 'Last update timestamp' })\n updatedAt?: Date\n\n @DeleteDateColumn()\n @Field({ nullable: true, description: 'Soft delete timestamp' })\n deletedAt?: Date\n\n @ManyToOne(type => User, { nullable: true })\n @Field(type => User, { nullable: true, description: 'Who created the calendar' })\n creator?: User\n\n @RelationId((calendar: Calendar) => calendar.creator)\n creatorId?: string\n\n @ManyToOne(type => User, { nullable: true })\n @Field(type => User, { nullable: true, description: 'Who last changed the calendar' })\n updater?: User\n\n @RelationId((calendar: Calendar) => calendar.updater)\n updaterId?: string\n}\n"]}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { Calendar } from './calendar';
|
|
2
2
|
import { CalendarQuery } from './calendar-query';
|
|
3
3
|
import { CalendarMutation } from './calendar-mutation';
|
|
4
|
+
import { WorkingDaysResolver } from './working-days-resolver';
|
|
4
5
|
export declare const entities: (typeof Calendar)[];
|
|
5
|
-
export declare const resolvers: (typeof CalendarQuery | typeof CalendarMutation)[];
|
|
6
|
+
export declare const resolvers: (typeof CalendarQuery | typeof CalendarMutation | typeof WorkingDaysResolver)[];
|
|
6
7
|
export declare const subscribers: any[];
|
|
@@ -4,7 +4,8 @@ exports.subscribers = exports.resolvers = exports.entities = void 0;
|
|
|
4
4
|
const calendar_1 = require("./calendar");
|
|
5
5
|
const calendar_query_1 = require("./calendar-query");
|
|
6
6
|
const calendar_mutation_1 = require("./calendar-mutation");
|
|
7
|
+
const working_days_resolver_1 = require("./working-days-resolver");
|
|
7
8
|
exports.entities = [calendar_1.Calendar];
|
|
8
|
-
exports.resolvers = [calendar_query_1.CalendarQuery, calendar_mutation_1.CalendarMutation];
|
|
9
|
+
exports.resolvers = [calendar_query_1.CalendarQuery, calendar_mutation_1.CalendarMutation, working_days_resolver_1.WorkingDaysResolver];
|
|
9
10
|
exports.subscribers = [];
|
|
10
11
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../server/service/calendar/index.ts"],"names":[],"mappings":";;;AAAA,yCAAqC;AACrC,qDAAgD;AAChD,2DAAsD;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../server/service/calendar/index.ts"],"names":[],"mappings":";;;AAAA,yCAAqC;AACrC,qDAAgD;AAChD,2DAAsD;AACtD,mEAA6D;AAEhD,QAAA,QAAQ,GAAG,CAAC,mBAAQ,CAAC,CAAA;AACrB,QAAA,SAAS,GAAG,CAAC,8BAAa,EAAE,oCAAgB,EAAE,2CAAmB,CAAC,CAAA;AAClE,QAAA,WAAW,GAAG,EAAE,CAAA","sourcesContent":["import { Calendar } from './calendar'\nimport { CalendarQuery } from './calendar-query'\nimport { CalendarMutation } from './calendar-mutation'\nimport { WorkingDaysResolver } from './working-days-resolver'\n\nexport const entities = [Calendar]\nexport const resolvers = [CalendarQuery, CalendarMutation, WorkingDaysResolver]\nexport const subscribers = []\n"]}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { DayOff, DayOffSpan, DayOffSpanPatch, PublicHolidayInput } from './calendar-type';
|
|
2
|
+
export declare class WorkingDaysResolver {
|
|
3
|
+
workingDays(from: string, to: string, context: ResolverContext): Promise<string[]>;
|
|
4
|
+
daysOff(from: string, to: string, context: ResolverContext): Promise<DayOff[]>;
|
|
5
|
+
savePublicHolidays(year: number, days: PublicHolidayInput[], context: ResolverContext): Promise<number>;
|
|
6
|
+
calendarDaysOff(calendarId: string, context: ResolverContext): Promise<DayOffSpan[]>;
|
|
7
|
+
updateCalendarDaysOff(calendarId: string, patches: DayOffSpanPatch[], context: ResolverContext): Promise<number>;
|
|
8
|
+
}
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.WorkingDaysResolver = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const type_graphql_1 = require("type-graphql");
|
|
6
|
+
const shell_1 = require("@things-factory/shell");
|
|
7
|
+
const calendar_type_1 = require("./calendar-type");
|
|
8
|
+
const working_days_1 = require("./working-days");
|
|
9
|
+
let WorkingDaysResolver = class WorkingDaysResolver {
|
|
10
|
+
/*
|
|
11
|
+
* Which days are worked is every member's to know, as the days off are - a calendar paints the others - so no calendar
|
|
12
|
+
* privilege is asked (ADR-0179). Read with no transaction, as the other reads of this module: a screen asks several
|
|
13
|
+
* reads at once, and on a single-connection database their transactions ran into each other.
|
|
14
|
+
*/
|
|
15
|
+
workingDays(from, to, context) {
|
|
16
|
+
return (0, working_days_1.workingDaysBetween)((0, shell_1.getDataSource)().manager, context.state.domain, from, to);
|
|
17
|
+
}
|
|
18
|
+
/*
|
|
19
|
+
* The days off are every member's to know - a work calendar, a cash calendar, a leave form draws them - so, like
|
|
20
|
+
* `myEvents`, no calendar privilege is asked: the holidays carry nothing private, and reading them grants no other
|
|
21
|
+
* event (ADR-0179). Read with no transaction, as workingDays.
|
|
22
|
+
*/
|
|
23
|
+
async daysOff(from, to, context) {
|
|
24
|
+
return [...(await (0, working_days_1.daysOffBetween)((0, shell_1.getDataSource)().manager, context.state.domain, from, to))].map(([day, name]) => ({ day, name }));
|
|
25
|
+
}
|
|
26
|
+
savePublicHolidays(year, days, context) {
|
|
27
|
+
const { domain, user, tx } = context.state;
|
|
28
|
+
return (0, working_days_1.savePublicHolidays)(tx, domain, user, year, days);
|
|
29
|
+
}
|
|
30
|
+
calendarDaysOff(calendarId, context) {
|
|
31
|
+
return (0, working_days_1.daysOffOfCalendar)((0, shell_1.getDataSource)().manager, context.state.domain, calendarId);
|
|
32
|
+
}
|
|
33
|
+
updateCalendarDaysOff(calendarId, patches, context) {
|
|
34
|
+
const { domain, user, tx } = context.state;
|
|
35
|
+
return (0, working_days_1.saveDaysOff)(tx, domain, user, calendarId, patches);
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
exports.WorkingDaysResolver = WorkingDaysResolver;
|
|
39
|
+
tslib_1.__decorate([
|
|
40
|
+
(0, type_graphql_1.Query)(returns => [String], { description: "The domain's working days from one day to another, both kept: its working weekdays less its days off and public holidays" }),
|
|
41
|
+
tslib_1.__param(0, (0, type_graphql_1.Arg)('from')),
|
|
42
|
+
tslib_1.__param(1, (0, type_graphql_1.Arg)('to')),
|
|
43
|
+
tslib_1.__param(2, (0, type_graphql_1.Ctx)()),
|
|
44
|
+
tslib_1.__metadata("design:type", Function),
|
|
45
|
+
tslib_1.__metadata("design:paramtypes", [String, String, Object]),
|
|
46
|
+
tslib_1.__metadata("design:returntype", Promise)
|
|
47
|
+
], WorkingDaysResolver.prototype, "workingDays", null);
|
|
48
|
+
tslib_1.__decorate([
|
|
49
|
+
(0, type_graphql_1.Query)(returns => [calendar_type_1.DayOff], { description: "The domain's days off from one day to another, both kept: its public holidays and days off, each with its name" }),
|
|
50
|
+
tslib_1.__param(0, (0, type_graphql_1.Arg)('from')),
|
|
51
|
+
tslib_1.__param(1, (0, type_graphql_1.Arg)('to')),
|
|
52
|
+
tslib_1.__param(2, (0, type_graphql_1.Ctx)()),
|
|
53
|
+
tslib_1.__metadata("design:type", Function),
|
|
54
|
+
tslib_1.__metadata("design:paramtypes", [String, String, Object]),
|
|
55
|
+
tslib_1.__metadata("design:returntype", Promise)
|
|
56
|
+
], WorkingDaysResolver.prototype, "daysOff", null);
|
|
57
|
+
tslib_1.__decorate([
|
|
58
|
+
(0, type_graphql_1.Directive)('@transaction'),
|
|
59
|
+
(0, type_graphql_1.Directive)('@privilege(category: "calendar", privilege: "mutation", domainOwnerGranted: true)'),
|
|
60
|
+
(0, type_graphql_1.Mutation)(returns => type_graphql_1.Int, { description: "To make a year's public holidays exactly these; the number kept" }),
|
|
61
|
+
tslib_1.__param(0, (0, type_graphql_1.Arg)('year', type => type_graphql_1.Int)),
|
|
62
|
+
tslib_1.__param(1, (0, type_graphql_1.Arg)('days', type => [calendar_type_1.PublicHolidayInput])),
|
|
63
|
+
tslib_1.__param(2, (0, type_graphql_1.Ctx)()),
|
|
64
|
+
tslib_1.__metadata("design:type", Function),
|
|
65
|
+
tslib_1.__metadata("design:paramtypes", [Number, Array, Object]),
|
|
66
|
+
tslib_1.__metadata("design:returntype", Promise)
|
|
67
|
+
], WorkingDaysResolver.prototype, "savePublicHolidays", null);
|
|
68
|
+
tslib_1.__decorate([
|
|
69
|
+
(0, type_graphql_1.Directive)('@privilege(category: "calendar", privilege: "query", domainOwnerGranted: true)'),
|
|
70
|
+
(0, type_graphql_1.Query)(returns => [calendar_type_1.DayOffSpan], { description: 'The days off a calendar holds, as rows from one day to another, earliest first' }),
|
|
71
|
+
tslib_1.__param(0, (0, type_graphql_1.Arg)('calendarId')),
|
|
72
|
+
tslib_1.__param(1, (0, type_graphql_1.Ctx)()),
|
|
73
|
+
tslib_1.__metadata("design:type", Function),
|
|
74
|
+
tslib_1.__metadata("design:paramtypes", [String, Object]),
|
|
75
|
+
tslib_1.__metadata("design:returntype", Promise)
|
|
76
|
+
], WorkingDaysResolver.prototype, "calendarDaysOff", null);
|
|
77
|
+
tslib_1.__decorate([
|
|
78
|
+
(0, type_graphql_1.Directive)('@transaction'),
|
|
79
|
+
(0, type_graphql_1.Directive)('@privilege(category: "calendar", privilege: "mutation", domainOwnerGranted: true)'),
|
|
80
|
+
(0, type_graphql_1.Mutation)(returns => type_graphql_1.Int, { description: "To add, change or take away a days-off calendar's days off; the number it keeps" }),
|
|
81
|
+
tslib_1.__param(0, (0, type_graphql_1.Arg)('calendarId')),
|
|
82
|
+
tslib_1.__param(1, (0, type_graphql_1.Arg)('patches', type => [calendar_type_1.DayOffSpanPatch])),
|
|
83
|
+
tslib_1.__param(2, (0, type_graphql_1.Ctx)()),
|
|
84
|
+
tslib_1.__metadata("design:type", Function),
|
|
85
|
+
tslib_1.__metadata("design:paramtypes", [String, Array, Object]),
|
|
86
|
+
tslib_1.__metadata("design:returntype", Promise)
|
|
87
|
+
], WorkingDaysResolver.prototype, "updateCalendarDaysOff", null);
|
|
88
|
+
exports.WorkingDaysResolver = WorkingDaysResolver = tslib_1.__decorate([
|
|
89
|
+
(0, type_graphql_1.UseMiddleware)(shell_1.SpeakRefusals),
|
|
90
|
+
(0, type_graphql_1.Resolver)()
|
|
91
|
+
], WorkingDaysResolver);
|
|
92
|
+
//# sourceMappingURL=working-days-resolver.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"working-days-resolver.js","sourceRoot":"","sources":["../../../server/service/calendar/working-days-resolver.ts"],"names":[],"mappings":";;;;AAAA,+CAAiG;AAEjG,iDAAoE;AAEpE,mDAAyF;AACzF,iDAAuH;AAIhH,IAAM,mBAAmB,GAAzB,MAAM,mBAAmB;IAC9B;;;;OAIG;IAEH,WAAW,CAAc,IAAY,EAAa,EAAU,EAAS,OAAwB;QAC3F,OAAO,IAAA,iCAAkB,EAAC,IAAA,qBAAa,GAAE,CAAC,OAAO,EAAE,OAAO,CAAC,KAAK,CAAC,MAAM,EAAE,IAAI,EAAE,EAAE,CAAC,CAAA;IACpF,CAAC;IAED;;;;OAIG;IAEG,AAAN,KAAK,CAAC,OAAO,CAAc,IAAY,EAAa,EAAU,EAAS,OAAwB;QAC7F,OAAO,CAAC,GAAG,CAAC,MAAM,IAAA,6BAAc,EAAC,IAAA,qBAAa,GAAE,CAAC,OAAO,EAAE,OAAO,CAAC,KAA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AAA;IACzC,mBAAA,IAAA,kBAAG,GAAE,CAAA;;;;gEAIP;8BA7CU,mBAAmB;IAF/B,IAAA,4BAAa,EAAC,qBAAa,CAAC;IAC5B,IAAA,uBAAQ,GAAE;GACE,mBAAmB,CA8C/B","sourcesContent":["import { Arg, Ctx, Directive, Int, Mutation, Query, Resolver, UseMiddleware } from 'type-graphql'\n\nimport { getDataSource, SpeakRefusals } from '@things-factory/shell'\n\nimport { DayOff, DayOffSpan, DayOffSpanPatch, PublicHolidayInput } from './calendar-type'\nimport { daysOffBetween, daysOffOfCalendar, saveDaysOff, savePublicHolidays, workingDaysBetween } from './working-days'\n\n@UseMiddleware(SpeakRefusals)\n@Resolver()\nexport class WorkingDaysResolver {\n /*\n * Which days are worked is every member's to know, as the days off are - a calendar paints the others - so no calendar\n * privilege is asked (ADR-0179). Read with no transaction, as the other reads of this module: a screen asks several\n * reads at once, and on a single-connection database their transactions ran into each other.\n */\n @Query(returns => [String], { description: \"The domain's working days from one day to another, both kept: its working weekdays less its days off and public holidays\" })\n workingDays(@Arg('from') from: string, @Arg('to') to: string, @Ctx() context: ResolverContext): Promise<string[]> {\n return workingDaysBetween(getDataSource().manager, context.state.domain, from, to)\n }\n\n /*\n * The days off are every member's to know - a work calendar, a cash calendar, a leave form draws them - so, like\n * `myEvents`, no calendar privilege is asked: the holidays carry nothing private, and reading them grants no other\n * event (ADR-0179). Read with no transaction, as workingDays.\n */\n @Query(returns => [DayOff], { description: \"The domain's days off from one day to another, both kept: its public holidays and days off, each with its name\" })\n async daysOff(@Arg('from') from: string, @Arg('to') to: string, @Ctx() context: ResolverContext): Promise<DayOff[]> {\n return [...(await daysOffBetween(getDataSource().manager, context.state.domain, from, to))].map(([day, name]) => ({ day, name }))\n }\n\n @Directive('@transaction')\n @Directive('@privilege(category: \"calendar\", privilege: \"mutation\", domainOwnerGranted: true)')\n @Mutation(returns => Int, { description: \"To make a year's public holidays exactly these; the number kept\" })\n savePublicHolidays(@Arg('year', type => Int) year: number, @Arg('days', type => [PublicHolidayInput]) days: PublicHolidayInput[], @Ctx() context: ResolverContext): Promise<number> {\n const { domain, user, tx } = context.state\n return savePublicHolidays(tx, domain, user, year, days)\n }\n\n @Directive('@privilege(category: \"calendar\", privilege: \"query\", domainOwnerGranted: true)')\n @Query(returns => [DayOffSpan], { description: 'The days off a calendar holds, as rows from one day to another, earliest first' })\n calendarDaysOff(@Arg('calendarId') calendarId: string, @Ctx() context: ResolverContext): Promise<DayOffSpan[]> {\n return daysOffOfCalendar(getDataSource().manager, context.state.domain, calendarId)\n }\n\n @Directive('@transaction')\n @Directive('@privilege(category: \"calendar\", privilege: \"mutation\", domainOwnerGranted: true)')\n @Mutation(returns => Int, { description: \"To add, change or take away a days-off calendar's days off; the number it keeps\" })\n updateCalendarDaysOff(\n @Arg('calendarId') calendarId: string,\n @Arg('patches', type => [DayOffSpanPatch]) patches: DayOffSpanPatch[],\n @Ctx() context: ResolverContext\n ): Promise<number> {\n const { domain, user, tx } = context.state\n return saveDaysOff(tx, domain, user, calendarId, patches)\n }\n}\n"]}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { EntityManager } from 'typeorm';
|
|
2
|
+
import { User } from '@things-factory/auth-base';
|
|
3
|
+
import { Domain } from '@things-factory/shell';
|
|
4
|
+
/**
|
|
5
|
+
* **The working days of a domain** (ADR-0179): its working weekdays, less every day an event of a days-off or a public
|
|
6
|
+
* holiday calendar covers. The one answer every module asks - a leave request, a grid of leave, a screen.
|
|
7
|
+
*
|
|
8
|
+
* The working weekdays are Monday to Friday. A domain that runs work shifts will read them from its shifts (ADR-0179 미결).
|
|
9
|
+
*/
|
|
10
|
+
export declare const WORK_WEEKDAYS: number[];
|
|
11
|
+
/** The longest span asked at once. */
|
|
12
|
+
export declare const WORKING_DAYS_MAX_SPAN = 400;
|
|
13
|
+
/** The name the public holiday calendar is made with; the domain may rename it. */
|
|
14
|
+
export declare const PUBLIC_HOLIDAYS_NAME = "\uAD6D\uAC00 \uACF5\uD734\uC77C";
|
|
15
|
+
/** The days off from `from` to `to` (both kept), each with the name of what makes it one. */
|
|
16
|
+
export declare function daysOffBetween(tx: EntityManager, domain: Domain, from: string, to: string): Promise<Map<string, string>>;
|
|
17
|
+
/** The working days from `from` to `to` (both kept), in order. */
|
|
18
|
+
export declare function workingDaysBetween(tx: EntityManager, domain: Domain, from: string, to: string): Promise<string[]>;
|
|
19
|
+
/**
|
|
20
|
+
* A year's public holidays as the import gives them: the domain's public holiday calendar (made when there is none)
|
|
21
|
+
* holds exactly these for the year - a day the import no longer gives is taken away. The number kept.
|
|
22
|
+
*/
|
|
23
|
+
export declare function savePublicHolidays(tx: EntityManager, domain: Domain, user: User, year: number, days: readonly {
|
|
24
|
+
day: string;
|
|
25
|
+
name: string;
|
|
26
|
+
}[]): Promise<number>;
|
|
27
|
+
/** The longest day off written as one row - a summer break, not a season. */
|
|
28
|
+
export declare const DAYS_OFF_MAX_SPAN = 31;
|
|
29
|
+
/** One row of a days-off calendar: a day off from one day to another, both kept, in the domain's days. */
|
|
30
|
+
export interface DayOffRow {
|
|
31
|
+
id: string;
|
|
32
|
+
name: string;
|
|
33
|
+
from: string;
|
|
34
|
+
to: string;
|
|
35
|
+
}
|
|
36
|
+
/** The days off a calendar holds, as the rows a person writes them - earliest first. */
|
|
37
|
+
export declare function daysOffOfCalendar(tx: EntityManager, domain: Domain, calendarId: string): Promise<DayOffRow[]>;
|
|
38
|
+
/**
|
|
39
|
+
* A company's days off written by hand (ADR-0179 결정 2): rows added, changed or taken away on a days-off calendar - the
|
|
40
|
+
* public holiday calendar is the import's, and written only by it. Each row is whole days from one day to another in the
|
|
41
|
+
* domain's days; refused by the field it is in. The number of rows the calendar keeps.
|
|
42
|
+
*/
|
|
43
|
+
export declare function saveDaysOff(tx: EntityManager, domain: Domain, user: User, calendarId: string, patches: readonly {
|
|
44
|
+
id?: string;
|
|
45
|
+
name?: string;
|
|
46
|
+
from?: string;
|
|
47
|
+
to?: string;
|
|
48
|
+
cuFlag: string;
|
|
49
|
+
}[]): Promise<number>;
|