@doctocar/tooling 0.3.1-33 → 0.3.1-35

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.
Files changed (35) hide show
  1. package/dist/firebase/cloudFunctions/enums/OnCallCloudFunctionsNames.enum.d.ts +1 -0
  2. package/dist/firebase/cloudFunctions/enums/OnCallCloudFunctionsNames.enum.js +1 -0
  3. package/dist/firebase/cloudFunctions/maps/OnCallCloudFunctionsTypeMappings.map.d.ts +5 -1
  4. package/dist/firebase/cloudFunctions/types/users/fcm/ClearUserFcmBadgeRequestData.type.d.ts +3 -0
  5. package/dist/firebase/cloudFunctions/types/users/fcm/ClearUserFcmBadgeRequestData.type.js +2 -0
  6. package/dist/firebase/cloudFunctions/types/users/fcm/ClearUserFcmBadgeResponseData.type.d.ts +1 -0
  7. package/dist/firebase/cloudFunctions/types/users/fcm/ClearUserFcmBadgeResponseData.type.js +2 -0
  8. package/dist/firebase/cloudFunctions/types/users/fcm/index.d.ts +2 -0
  9. package/dist/firebase/cloudFunctions/types/users/fcm/index.js +2 -0
  10. package/dist/firebase/firestore/utils/dataValidators/slots/__tests__/isValidOneTimeSlot.test.d.ts +1 -0
  11. package/dist/firebase/firestore/utils/dataValidators/slots/__tests__/isValidOneTimeSlot.test.js +287 -0
  12. package/dist/firebase/firestore/utils/dataValidators/slots/__tests__/isValidRecurringSlot.test.d.ts +1 -0
  13. package/dist/firebase/firestore/utils/dataValidators/slots/__tests__/isValidRecurringSlot.test.js +527 -0
  14. package/dist/firebase/firestore/utils/dataValidators/slots/__tests__/isValidTimeOffSlot.test.d.ts +1 -0
  15. package/dist/firebase/firestore/utils/dataValidators/slots/__tests__/isValidTimeOffSlot.test.js +272 -0
  16. package/dist/firebase/firestore/utils/dataValidators/slots/index.d.ts +3 -3
  17. package/dist/firebase/firestore/utils/dataValidators/slots/index.js +3 -3
  18. package/dist/firebase/firestore/utils/dataValidators/slots/isValidOneTimeSlot.d.ts +2 -0
  19. package/dist/firebase/firestore/utils/dataValidators/slots/isValidOneTimeSlot.js +45 -0
  20. package/dist/firebase/firestore/utils/dataValidators/slots/isValidRecurringSlot.d.ts +2 -0
  21. package/dist/firebase/firestore/utils/dataValidators/slots/isValidRecurringSlot.js +83 -0
  22. package/dist/firebase/firestore/utils/dataValidators/slots/isValidTimeOffSlot.d.ts +2 -0
  23. package/dist/firebase/firestore/utils/dataValidators/slots/isValidTimeOffSlot.js +45 -0
  24. package/dist/gcp/pubsub/enums/PubSubTopics.enum.d.ts +1 -1
  25. package/dist/gcp/pubsub/enums/PubSubTopics.enum.js +1 -1
  26. package/dist/gcp/pubsub/maps/PubSubTopicMessageMap.map.d.ts +2 -2
  27. package/dist/gcp/pubsub/types/orders/PubSubOrderInvoicedMessage.type.d.ts +3 -0
  28. package/dist/gcp/pubsub/types/orders/PubSubOrderInvoicedMessage.type.js +2 -0
  29. package/dist/gcp/pubsub/types/orders/index.d.ts +1 -1
  30. package/dist/gcp/pubsub/types/orders/index.js +1 -1
  31. package/dist/gcp/pubsub/utils/stubs/index.d.ts +1 -1
  32. package/dist/gcp/pubsub/utils/stubs/index.js +1 -1
  33. package/dist/gcp/pubsub/utils/stubs/pubSubOrderInvoicedMessageStub.d.ts +2 -0
  34. package/dist/gcp/pubsub/utils/stubs/pubSubOrderInvoicedMessageStub.js +9 -0
  35. package/package.json +1 -1
@@ -0,0 +1,272 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ /* eslint-disable @typescript-eslint/no-explicit-any */
4
+ const constants_1 = require("../../../../../../constants");
5
+ const constants_2 = require("../../../../constants");
6
+ const enums_1 = require("../../../../enums");
7
+ const stubs_1 = require("../../../stubs");
8
+ const constants_3 = require("../constants");
9
+ const isValidTimeOffSlot_1 = require("../isValidTimeOffSlot");
10
+ describe("isValidTimeOffSlot", () => {
11
+ const baseValidSlot = {
12
+ type: enums_1.SlotType.TIME_OFF,
13
+ capacity: 3,
14
+ createdAt: (0, stubs_1.firestoreTimestampStub)(),
15
+ updatedAt: (0, stubs_1.firestoreTimestampStub)(),
16
+ timeZone: "Europe/Paris",
17
+ };
18
+ it("returns true for a valid slot", () => {
19
+ const slot = {
20
+ ...baseValidSlot,
21
+ timestampRange: {
22
+ startAt: (0, stubs_1.firestoreTimestampStub)({
23
+ toMillis: () => new Date().getTime() + constants_1.ONE_HOUR_IN_MS,
24
+ }),
25
+ endAt: (0, stubs_1.firestoreTimestampStub)({
26
+ toMillis: () => new Date().getTime() + constants_1.ONE_HOUR_IN_MS * 2,
27
+ }),
28
+ },
29
+ };
30
+ expect((0, isValidTimeOffSlot_1.isValidTimeOffSlot)(slot)).toBe(true);
31
+ });
32
+ it("return true for differents valid timezones", () => {
33
+ const validTimezones = [
34
+ "Europe/Paris",
35
+ "Europe/Berlin",
36
+ "Europe/Madrid",
37
+ "Europe/Rome",
38
+ "Europe/Brussels",
39
+ "Europe/Moscow",
40
+ "America/New_York",
41
+ "Asia/Tokyo",
42
+ "Australia/Sydney",
43
+ "UTC",
44
+ "Europe/London",
45
+ "America/Los_Angeles",
46
+ "Asia/Kolkata",
47
+ "America/Argentina/Buenos_Aires",
48
+ "Asia/Shanghai",
49
+ ];
50
+ validTimezones.forEach((timezone) => {
51
+ const slot = {
52
+ ...baseValidSlot,
53
+ timeZone: timezone,
54
+ timestampRange: {
55
+ startAt: (0, stubs_1.firestoreTimestampStub)({
56
+ toMillis: () => new Date().getTime() + constants_1.ONE_HOUR_IN_MS,
57
+ }),
58
+ endAt: (0, stubs_1.firestoreTimestampStub)({
59
+ toMillis: () => new Date().getTime() + constants_1.ONE_HOUR_IN_MS * 2,
60
+ }),
61
+ },
62
+ };
63
+ expect((0, isValidTimeOffSlot_1.isValidTimeOffSlot)(slot)).toBe(true);
64
+ });
65
+ });
66
+ it("return false if timeZone is missing or invalid", () => {
67
+ const missingTimeZone = {
68
+ ...baseValidSlot,
69
+ timeZone: undefined,
70
+ timestampRange: {
71
+ startAt: (0, stubs_1.firestoreTimestampStub)({
72
+ toMillis: () => new Date().getTime() + constants_1.ONE_HOUR_IN_MS,
73
+ }),
74
+ endAt: (0, stubs_1.firestoreTimestampStub)({
75
+ toMillis: () => new Date().getTime() + constants_1.ONE_HOUR_IN_MS * 2,
76
+ }),
77
+ },
78
+ };
79
+ expect((0, isValidTimeOffSlot_1.isValidTimeOffSlot)(missingTimeZone)).toBe(false);
80
+ const slot = {
81
+ ...baseValidSlot,
82
+ timeZone: "",
83
+ timestampRange: {
84
+ startAt: (0, stubs_1.firestoreTimestampStub)({
85
+ toMillis: () => new Date().getTime() + constants_1.ONE_HOUR_IN_MS,
86
+ }),
87
+ endAt: (0, stubs_1.firestoreTimestampStub)({
88
+ toMillis: () => new Date().getTime() + constants_1.ONE_HOUR_IN_MS * 2,
89
+ }),
90
+ },
91
+ };
92
+ expect((0, isValidTimeOffSlot_1.isValidTimeOffSlot)(slot)).toBe(false);
93
+ const invalidSlot = {
94
+ ...baseValidSlot,
95
+ timeZone: "Invalid/Timezone",
96
+ timestampRange: {
97
+ startAt: (0, stubs_1.firestoreTimestampStub)({
98
+ toMillis: () => new Date().getTime() + constants_1.ONE_HOUR_IN_MS,
99
+ }),
100
+ endAt: (0, stubs_1.firestoreTimestampStub)({
101
+ toMillis: () => new Date().getTime() + constants_1.ONE_HOUR_IN_MS * 2,
102
+ }),
103
+ },
104
+ };
105
+ expect((0, isValidTimeOffSlot_1.isValidTimeOffSlot)(invalidSlot)).toBe(false);
106
+ });
107
+ it("return false if type is not TIME_OFF", () => {
108
+ const slot = {
109
+ ...baseValidSlot,
110
+ type: enums_1.SlotType.RECURRING,
111
+ timestampRange: {
112
+ startAt: (0, stubs_1.firestoreTimestampStub)({
113
+ toMillis: () => new Date().getTime() + constants_1.ONE_HOUR_IN_MS,
114
+ }),
115
+ endAt: (0, stubs_1.firestoreTimestampStub)({
116
+ toMillis: () => new Date().getTime() + constants_1.ONE_HOUR_IN_MS * 2,
117
+ }),
118
+ },
119
+ };
120
+ expect((0, isValidTimeOffSlot_1.isValidTimeOffSlot)(slot)).toBe(false);
121
+ });
122
+ it("return false if startAt or endAt is missing", () => {
123
+ const missingStart = {
124
+ ...baseValidSlot,
125
+ timestampRange: {
126
+ endAt: (0, stubs_1.firestoreTimestampStub)({
127
+ toMillis: () => new Date().getTime() + constants_1.ONE_HOUR_IN_MS * 2,
128
+ }),
129
+ },
130
+ };
131
+ const missingEnd = {
132
+ ...baseValidSlot,
133
+ timestampRange: {
134
+ startAt: (0, stubs_1.firestoreTimestampStub)({
135
+ toMillis: () => new Date().getTime() + constants_1.ONE_HOUR_IN_MS,
136
+ }),
137
+ },
138
+ };
139
+ expect((0, isValidTimeOffSlot_1.isValidTimeOffSlot)(missingStart)).toBe(false);
140
+ expect((0, isValidTimeOffSlot_1.isValidTimeOffSlot)(missingEnd)).toBe(false);
141
+ });
142
+ it("return false if capacity is not an integer ≥ 1 <= MAXIMUM_SLOT_CAPACITY", () => {
143
+ const zeroCap = {
144
+ ...baseValidSlot,
145
+ capacity: 0,
146
+ timestampRange: {
147
+ startAt: (0, stubs_1.firestoreTimestampStub)({
148
+ toMillis: () => new Date().getTime() + constants_1.ONE_HOUR_IN_MS,
149
+ }),
150
+ endAt: (0, stubs_1.firestoreTimestampStub)({
151
+ toMillis: () => new Date().getTime() + constants_1.ONE_HOUR_IN_MS * 2,
152
+ }),
153
+ },
154
+ };
155
+ const negCap = {
156
+ ...baseValidSlot,
157
+ capacity: -5,
158
+ timestampRange: {
159
+ startAt: (0, stubs_1.firestoreTimestampStub)({
160
+ toMillis: () => new Date().getTime() + constants_1.ONE_HOUR_IN_MS,
161
+ }),
162
+ endAt: (0, stubs_1.firestoreTimestampStub)({
163
+ toMillis: () => new Date().getTime() + constants_1.ONE_HOUR_IN_MS * 2,
164
+ }),
165
+ },
166
+ };
167
+ const floatCap = {
168
+ ...baseValidSlot,
169
+ capacity: 2.5,
170
+ timestampRange: {
171
+ startAt: (0, stubs_1.firestoreTimestampStub)({
172
+ toMillis: () => new Date().getTime() + constants_1.ONE_HOUR_IN_MS,
173
+ }),
174
+ endAt: (0, stubs_1.firestoreTimestampStub)({
175
+ toMillis: () => new Date().getTime() + constants_1.ONE_HOUR_IN_MS * 2,
176
+ }),
177
+ },
178
+ };
179
+ const tooBigCap = {
180
+ ...baseValidSlot,
181
+ capacity: constants_2.MAXIMUM_SLOT_CAPACITY + 1,
182
+ timestampRange: {
183
+ startAt: (0, stubs_1.firestoreTimestampStub)({
184
+ toMillis: () => new Date().getTime() + constants_1.ONE_HOUR_IN_MS,
185
+ }),
186
+ endAt: (0, stubs_1.firestoreTimestampStub)({
187
+ toMillis: () => new Date().getTime() + constants_1.ONE_HOUR_IN_MS * 2,
188
+ }),
189
+ },
190
+ };
191
+ expect((0, isValidTimeOffSlot_1.isValidTimeOffSlot)(zeroCap)).toBe(false);
192
+ expect((0, isValidTimeOffSlot_1.isValidTimeOffSlot)(negCap)).toBe(false);
193
+ expect((0, isValidTimeOffSlot_1.isValidTimeOffSlot)(floatCap)).toBe(false);
194
+ expect((0, isValidTimeOffSlot_1.isValidTimeOffSlot)(tooBigCap)).toBe(false);
195
+ });
196
+ it("return false if startAt or endAt does not have toMillis()", () => {
197
+ const badStart = {
198
+ ...baseValidSlot,
199
+ timestampRange: {
200
+ startAt: { toMillis: undefined },
201
+ endAt: (0, stubs_1.firestoreTimestampStub)({
202
+ toMillis: () => 1,
203
+ }),
204
+ },
205
+ };
206
+ const badEnd = {
207
+ ...baseValidSlot,
208
+ timestampRange: {
209
+ startAt: (0, stubs_1.firestoreTimestampStub)({
210
+ toMillis: () => 0,
211
+ }),
212
+ endAt: { toMillis: undefined },
213
+ },
214
+ };
215
+ expect((0, isValidTimeOffSlot_1.isValidTimeOffSlot)(badStart)).toBe(false);
216
+ expect((0, isValidTimeOffSlot_1.isValidTimeOffSlot)(badEnd)).toBe(false);
217
+ });
218
+ it("return false if startAt ≥ endAt", () => {
219
+ const equalTimes = {
220
+ ...baseValidSlot,
221
+ timestampRange: {
222
+ startAt: (0, stubs_1.firestoreTimestampStub)({
223
+ toMillis: () => new Date().getTime() + constants_1.ONE_HOUR_IN_MS,
224
+ }),
225
+ endAt: (0, stubs_1.firestoreTimestampStub)({
226
+ toMillis: () => new Date().getTime() + constants_1.ONE_HOUR_IN_MS,
227
+ }),
228
+ },
229
+ };
230
+ const backwards = {
231
+ ...baseValidSlot,
232
+ timestampRange: {
233
+ startAt: (0, stubs_1.firestoreTimestampStub)({
234
+ toMillis: () => new Date().getTime() + constants_1.ONE_HOUR_IN_MS * 2,
235
+ }),
236
+ endAt: (0, stubs_1.firestoreTimestampStub)({
237
+ toMillis: () => new Date().getTime() + constants_1.ONE_HOUR_IN_MS,
238
+ }),
239
+ },
240
+ };
241
+ expect((0, isValidTimeOffSlot_1.isValidTimeOffSlot)(equalTimes)).toBe(false);
242
+ expect((0, isValidTimeOffSlot_1.isValidTimeOffSlot)(backwards)).toBe(false);
243
+ });
244
+ it("return false if startAt is in the past", () => {
245
+ const pastStart = {
246
+ ...baseValidSlot,
247
+ timestampRange: {
248
+ startAt: (0, stubs_1.firestoreTimestampStub)({
249
+ toMillis: () => new Date().getTime() - constants_1.ONE_HOUR_IN_MS,
250
+ }),
251
+ endAt: (0, stubs_1.firestoreTimestampStub)({
252
+ toMillis: () => Date.now() + constants_1.ONE_HOUR_IN_MS,
253
+ }),
254
+ },
255
+ };
256
+ expect((0, isValidTimeOffSlot_1.isValidTimeOffSlot)(pastStart)).toBe(false);
257
+ });
258
+ it("return false if endAt is more than MAX_SLOT_END_DATE_IN_MS future", () => {
259
+ const farFuture = {
260
+ ...baseValidSlot,
261
+ timestampRange: {
262
+ startAt: (0, stubs_1.firestoreTimestampStub)({
263
+ toMillis: () => Date.now(),
264
+ }),
265
+ endAt: (0, stubs_1.firestoreTimestampStub)({
266
+ toMillis: () => Date.now() + constants_3.MAX_SLOT_END_DATE_IN_MS + constants_1.ONE_DAY_IN_MS,
267
+ }),
268
+ },
269
+ };
270
+ expect((0, isValidTimeOffSlot_1.isValidTimeOffSlot)(farFuture)).toBe(false);
271
+ });
272
+ });
@@ -1,3 +1,3 @@
1
- export * from "./isValidOneTimeSlot.util";
2
- export * from "./isValidRecurringSlot.util";
3
- export * from "./isValidTimeOffSlot.util";
1
+ export * from "./isValidOneTimeSlot";
2
+ export * from "./isValidRecurringSlot";
3
+ export * from "./isValidTimeOffSlot";
@@ -14,6 +14,6 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
14
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
- __exportStar(require("./isValidOneTimeSlot.util"), exports);
18
- __exportStar(require("./isValidRecurringSlot.util"), exports);
19
- __exportStar(require("./isValidTimeOffSlot.util"), exports);
17
+ __exportStar(require("./isValidOneTimeSlot"), exports);
18
+ __exportStar(require("./isValidRecurringSlot"), exports);
19
+ __exportStar(require("./isValidTimeOffSlot"), exports);
@@ -0,0 +1,2 @@
1
+ import type { FirestoreOneTimeSlot } from "../../../types";
2
+ export declare function isValidOneTimeSlot(oneTimeSlot: FirestoreOneTimeSlot): boolean;
@@ -0,0 +1,45 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.isValidOneTimeSlot = isValidOneTimeSlot;
4
+ const constants_1 = require("../../../constants");
5
+ const enums_1 = require("../../../enums");
6
+ const constants_2 = require("./constants");
7
+ function isValidOneTimeSlot(oneTimeSlot) {
8
+ if (oneTimeSlot.type !== enums_1.SlotType.ONE_TIME) {
9
+ return false;
10
+ }
11
+ if (!oneTimeSlot.timestampRange ||
12
+ !oneTimeSlot.timestampRange.startAt ||
13
+ !oneTimeSlot.timestampRange.endAt ||
14
+ !oneTimeSlot.timeZone) {
15
+ return false;
16
+ }
17
+ if (typeof oneTimeSlot.timeZone !== "string" ||
18
+ oneTimeSlot.timeZone.trim() === "") {
19
+ return false;
20
+ }
21
+ try {
22
+ Intl.DateTimeFormat(undefined, { timeZone: oneTimeSlot.timeZone });
23
+ }
24
+ catch (error) {
25
+ return false;
26
+ }
27
+ if (!Number.isInteger(oneTimeSlot.capacity) ||
28
+ oneTimeSlot.capacity < 1 ||
29
+ oneTimeSlot.capacity > constants_1.MAXIMUM_SLOT_CAPACITY) {
30
+ return false;
31
+ }
32
+ if (!oneTimeSlot.timestampRange.startAt.toMillis ||
33
+ !oneTimeSlot.timestampRange.endAt.toMillis) {
34
+ return false;
35
+ }
36
+ const startAtInMs = oneTimeSlot.timestampRange.startAt.toMillis();
37
+ const endAtInMs = oneTimeSlot.timestampRange.endAt.toMillis();
38
+ const nowInMs = Date.now();
39
+ if (startAtInMs >= endAtInMs ||
40
+ startAtInMs < nowInMs ||
41
+ endAtInMs > constants_2.MAX_SLOT_END_DATE_IN_MS) {
42
+ return false;
43
+ }
44
+ return true;
45
+ }
@@ -0,0 +1,2 @@
1
+ import type { FirestoreRecurringSlot } from "../../../types";
2
+ export declare function isValidRecurringSlot(recurringSlot: FirestoreRecurringSlot): boolean;
@@ -0,0 +1,83 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.isValidRecurringSlot = isValidRecurringSlot;
4
+ const enums_1 = require("../../../../../enums");
5
+ const constants_1 = require("../../../constants");
6
+ const enums_2 = require("../../../enums");
7
+ function isValidRecurringSlot(recurringSlot) {
8
+ if (recurringSlot.type !== enums_2.SlotType.RECURRING) {
9
+ return false;
10
+ }
11
+ const requiredFields = [
12
+ recurringSlot.localTimeRangeOfDay,
13
+ recurringSlot.localTimeRangeOfDay?.startTime,
14
+ recurringSlot.localTimeRangeOfDay?.endTime,
15
+ recurringSlot.startDate,
16
+ recurringSlot.timeZone,
17
+ recurringSlot.intervalWeeks,
18
+ ];
19
+ if (requiredFields.some((f) => f == null)) {
20
+ return false;
21
+ }
22
+ if (typeof recurringSlot.timeZone !== "string" ||
23
+ recurringSlot.timeZone.trim() === "") {
24
+ return false;
25
+ }
26
+ try {
27
+ Intl.DateTimeFormat(undefined, { timeZone: recurringSlot.timeZone });
28
+ }
29
+ catch (error) {
30
+ return false;
31
+ }
32
+ if (!Number.isInteger(recurringSlot.capacity) ||
33
+ recurringSlot.capacity < 1 ||
34
+ recurringSlot.capacity > constants_1.MAXIMUM_SLOT_CAPACITY) {
35
+ return false;
36
+ }
37
+ const uniqueDaysOfWeek = Array.from(new Set(recurringSlot.daysOfWeek));
38
+ if (uniqueDaysOfWeek.length !== recurringSlot.daysOfWeek.length ||
39
+ uniqueDaysOfWeek.length === 0) {
40
+ return false;
41
+ }
42
+ if (!uniqueDaysOfWeek.every((d) => Object.values(enums_1.WeekDays).includes(d))) {
43
+ return false;
44
+ }
45
+ if (!recurringSlot.startDate.toMillis ||
46
+ isNaN(recurringSlot.startDate.toMillis())) {
47
+ return false;
48
+ }
49
+ if (recurringSlot.endDate) {
50
+ if (typeof recurringSlot.endDate.toMillis !== "function" ||
51
+ isNaN(recurringSlot.endDate.toMillis())) {
52
+ return false;
53
+ }
54
+ if (recurringSlot.endDate.toMillis() <= recurringSlot.startDate.toMillis()) {
55
+ return false;
56
+ }
57
+ }
58
+ for (const field of ["startTime", "endTime"]) {
59
+ const time = recurringSlot.localTimeRangeOfDay[field];
60
+ if (time == null ||
61
+ !Number.isInteger(time.hour) ||
62
+ !Number.isInteger(time.minute) ||
63
+ time.hour < 0 ||
64
+ time.hour > 23 ||
65
+ time.minute < 0 ||
66
+ time.minute > 59) {
67
+ return false;
68
+ }
69
+ }
70
+ const startMinutes = recurringSlot.localTimeRangeOfDay.startTime.hour * 60 +
71
+ recurringSlot.localTimeRangeOfDay.startTime.minute;
72
+ const endMinutes = recurringSlot.localTimeRangeOfDay.endTime.hour * 60 +
73
+ recurringSlot.localTimeRangeOfDay.endTime.minute;
74
+ if (endMinutes <= startMinutes) {
75
+ return false;
76
+ }
77
+ if (!Number.isInteger(recurringSlot.intervalWeeks) ||
78
+ recurringSlot.intervalWeeks < 1 ||
79
+ recurringSlot.intervalWeeks > 52) {
80
+ return false;
81
+ }
82
+ return true;
83
+ }
@@ -0,0 +1,2 @@
1
+ import type { FirestoreTimeOffSlot } from "../../../types";
2
+ export declare function isValidTimeOffSlot(timeOffSlot: FirestoreTimeOffSlot): boolean;
@@ -0,0 +1,45 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.isValidTimeOffSlot = isValidTimeOffSlot;
4
+ const constants_1 = require("../../../constants");
5
+ const enums_1 = require("../../../enums");
6
+ const constants_2 = require("./constants");
7
+ function isValidTimeOffSlot(timeOffSlot) {
8
+ if (timeOffSlot.type !== enums_1.SlotType.TIME_OFF) {
9
+ return false;
10
+ }
11
+ if (!timeOffSlot.timestampRange ||
12
+ !timeOffSlot.timestampRange.startAt ||
13
+ !timeOffSlot.timestampRange.endAt ||
14
+ !timeOffSlot.timeZone) {
15
+ return false;
16
+ }
17
+ if (typeof timeOffSlot.timeZone !== "string" ||
18
+ timeOffSlot.timeZone.trim() === "") {
19
+ return false;
20
+ }
21
+ try {
22
+ Intl.DateTimeFormat(undefined, { timeZone: timeOffSlot.timeZone });
23
+ }
24
+ catch (error) {
25
+ return false;
26
+ }
27
+ if (!Number.isInteger(timeOffSlot.capacity) ||
28
+ timeOffSlot.capacity < 1 ||
29
+ timeOffSlot.capacity > constants_1.MAXIMUM_SLOT_CAPACITY) {
30
+ return false;
31
+ }
32
+ if (!timeOffSlot.timestampRange.startAt.toMillis ||
33
+ !timeOffSlot.timestampRange.endAt.toMillis) {
34
+ return false;
35
+ }
36
+ const startAtInMs = timeOffSlot.timestampRange.startAt.toMillis();
37
+ const endAtInMs = timeOffSlot.timestampRange.endAt.toMillis();
38
+ const nowInMs = Date.now();
39
+ if (startAtInMs >= endAtInMs ||
40
+ startAtInMs < nowInMs ||
41
+ endAtInMs > constants_2.MAX_SLOT_END_DATE_IN_MS) {
42
+ return false;
43
+ }
44
+ return true;
45
+ }
@@ -8,7 +8,7 @@ export declare enum PubSubTopics {
8
8
  ORDER_PAYMENT_SUCCEEDED = "order-payment-succeeded",
9
9
  ORDER_PAYMENT_FAILED = "order-payment-failed",
10
10
  ORDER_PAYMENT_CANCELED = "order-payment-canceled",
11
- ORDER_INVOICES_READY = "order-invoices-ready",
11
+ ORDER_INVOICED = "order-invoiced",
12
12
  ORDER_ISSUE_REPORTED = "order-issue-reported",
13
13
  ORDER_ISSUES_STATE_RECOMPUTE_REQUESTED = "order-issues-state-recompute-requested",
14
14
  PROCESS_ORDER_REFUND_INTENT = "process-order-refund-intent",
@@ -12,7 +12,7 @@ var PubSubTopics;
12
12
  PubSubTopics["ORDER_PAYMENT_SUCCEEDED"] = "order-payment-succeeded";
13
13
  PubSubTopics["ORDER_PAYMENT_FAILED"] = "order-payment-failed";
14
14
  PubSubTopics["ORDER_PAYMENT_CANCELED"] = "order-payment-canceled";
15
- PubSubTopics["ORDER_INVOICES_READY"] = "order-invoices-ready";
15
+ PubSubTopics["ORDER_INVOICED"] = "order-invoiced";
16
16
  PubSubTopics["ORDER_ISSUE_REPORTED"] = "order-issue-reported";
17
17
  PubSubTopics["ORDER_ISSUES_STATE_RECOMPUTE_REQUESTED"] = "order-issues-state-recompute-requested";
18
18
  PubSubTopics["PROCESS_ORDER_REFUND_INTENT"] = "process-order-refund-intent";
@@ -1,5 +1,5 @@
1
1
  import type { PubSubTopics } from "../enums";
2
- import type { PubSubAutoCancelConfirmedOrderMessage, PubSubAutoCompleteOrderAfterIssueReportingWindowMessage, PubSubBillingAlertsMessage, PubSubDefaultDlqMessage, PubSubEntityMemberProjectionResyncRequestedMessage, PubSubEntityVatNumberVerificationRequestedMessage, PubSubFirestoreUserMetricsMessage, PubSubNotificationEventMessage, PubSubOrderCompletedMessage, PubSubOrderInvoicesReadyMessage, PubSubOrderIssueReportedMessage, PubSubOrderIssueStateRecomputeRequestedMessage, PubSubOrderOperationalStateRecomputeRequestedMessage, PubSubOrderPaymentCanceledMessage, PubSubOrderPaymentFailedMessage, PubSubOrderPaymentSucceededMessage, PubSubProcessOrderRefundIntentMessage, PubSubOrderExternalRefundSucceededMessage, PubSubOrderExternalRefundFailedMessage, PubSubOrderStartedMessage, PubSubProcessWalletWithdrawalRequestMessage, PubSubServiceProviderBookedSlotReleaseRequestedMessage, PubSubServiceProviderEntityStateRecomputeRequestedMessage, PubSubServiceProviderPublicProfileResyncRequestedMessage, PubSubServicesCompletedMessage, PubSubStripeConnectedAccountBalanceAvailableUpdatedMessage, PubSubStripeConnectedAccountUpdatedMessage, PubSubUserOrderReminderMessage, PubSubWalletWithdrawalFailedMessage, PubSubWalletWithdrawalSucceededMessage } from "../types";
2
+ import type { PubSubAutoCancelConfirmedOrderMessage, PubSubAutoCompleteOrderAfterIssueReportingWindowMessage, PubSubBillingAlertsMessage, PubSubDefaultDlqMessage, PubSubEntityMemberProjectionResyncRequestedMessage, PubSubEntityVatNumberVerificationRequestedMessage, PubSubFirestoreUserMetricsMessage, PubSubNotificationEventMessage, PubSubOrderCompletedMessage, PubSubOrderInvoicedMessage, PubSubOrderIssueReportedMessage, PubSubOrderIssueStateRecomputeRequestedMessage, PubSubOrderOperationalStateRecomputeRequestedMessage, PubSubOrderPaymentCanceledMessage, PubSubOrderPaymentFailedMessage, PubSubOrderPaymentSucceededMessage, PubSubProcessOrderRefundIntentMessage, PubSubOrderExternalRefundSucceededMessage, PubSubOrderExternalRefundFailedMessage, PubSubOrderStartedMessage, PubSubProcessWalletWithdrawalRequestMessage, PubSubServiceProviderBookedSlotReleaseRequestedMessage, PubSubServiceProviderEntityStateRecomputeRequestedMessage, PubSubServiceProviderPublicProfileResyncRequestedMessage, PubSubServicesCompletedMessage, PubSubStripeConnectedAccountBalanceAvailableUpdatedMessage, PubSubStripeConnectedAccountUpdatedMessage, PubSubUserOrderReminderMessage, PubSubWalletWithdrawalFailedMessage, PubSubWalletWithdrawalSucceededMessage } from "../types";
3
3
  type PubSubTopicMessageMapBase = {
4
4
  [PubSubTopics.BILLING_ALERTS]: PubSubBillingAlertsMessage;
5
5
  [PubSubTopics.STRIPE_CONNECTED_ACCOUNT_UPDATED]: PubSubStripeConnectedAccountUpdatedMessage;
@@ -13,7 +13,7 @@ type PubSubTopicMessageMapBase = {
13
13
  [PubSubTopics.USER_ORDER_REMINDER]: PubSubUserOrderReminderMessage;
14
14
  [PubSubTopics.ORDER_PAYMENT_FAILED]: PubSubOrderPaymentFailedMessage;
15
15
  [PubSubTopics.ORDER_PAYMENT_CANCELED]: PubSubOrderPaymentCanceledMessage;
16
- [PubSubTopics.ORDER_INVOICES_READY]: PubSubOrderInvoicesReadyMessage;
16
+ [PubSubTopics.ORDER_INVOICED]: PubSubOrderInvoicedMessage;
17
17
  [PubSubTopics.ORDER_OPERATIONAL_STATE_RECOMPUTE_REQUESTED]: PubSubOrderOperationalStateRecomputeRequestedMessage;
18
18
  [PubSubTopics.SERVICES_COMPLETED]: PubSubServicesCompletedMessage;
19
19
  [PubSubTopics.AUTO_CANCEL_EXPIRED_CONFIRMED_ORDER]: PubSubAutoCancelConfirmedOrderMessage;
@@ -0,0 +1,3 @@
1
+ export type PubSubOrderInvoicedMessage = {
2
+ orderDocumentId: string;
3
+ };
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -8,7 +8,7 @@ export * from "./PubSubServicesCompletedMessage.type";
8
8
  export * from "./PubSubUserOrderReminderMessage.type";
9
9
  export * from "./PubSubAutoCompleteOrderAfterIssueReportingWindowMessage.type";
10
10
  export * from "./PubSubOrderCompletedMessage.type";
11
- export * from "./PubSubOrderInvoicesReadyMessage.type";
11
+ export * from "./PubSubOrderInvoicedMessage.type";
12
12
  export * from "./PubSubOrderIssueReportedMessage.type";
13
13
  export * from "./PubSubOrderIssueStateRecomputeRequestedMessage.type";
14
14
  export * from "./PubSubProcessOrderRefundIntentMessage.type";
@@ -24,7 +24,7 @@ __exportStar(require("./PubSubServicesCompletedMessage.type"), exports);
24
24
  __exportStar(require("./PubSubUserOrderReminderMessage.type"), exports);
25
25
  __exportStar(require("./PubSubAutoCompleteOrderAfterIssueReportingWindowMessage.type"), exports);
26
26
  __exportStar(require("./PubSubOrderCompletedMessage.type"), exports);
27
- __exportStar(require("./PubSubOrderInvoicesReadyMessage.type"), exports);
27
+ __exportStar(require("./PubSubOrderInvoicedMessage.type"), exports);
28
28
  __exportStar(require("./PubSubOrderIssueReportedMessage.type"), exports);
29
29
  __exportStar(require("./PubSubOrderIssueStateRecomputeRequestedMessage.type"), exports);
30
30
  __exportStar(require("./PubSubProcessOrderRefundIntentMessage.type"), exports);
@@ -8,7 +8,7 @@ export * from "./pubSubOrderStartedMessageStub";
8
8
  export * from "./pubSubNotificationEventMessageStub";
9
9
  export * from "./pubSubServicesCompletedMessageStub";
10
10
  export * from "./pubSubUserOrderReminderMessageStub";
11
- export * from "./pubSubOrderInvoicesReadyMessageStub";
11
+ export * from "./pubSubOrderInvoicedMessageStub";
12
12
  export * from "./pubSubStripeConnectedAccountBalanceAvailableUpdatedMessageStub";
13
13
  export * from "./wallets";
14
14
  export * from "./pubSubOrderIssueReportedMessageStub";
@@ -24,7 +24,7 @@ __exportStar(require("./pubSubOrderStartedMessageStub"), exports);
24
24
  __exportStar(require("./pubSubNotificationEventMessageStub"), exports);
25
25
  __exportStar(require("./pubSubServicesCompletedMessageStub"), exports);
26
26
  __exportStar(require("./pubSubUserOrderReminderMessageStub"), exports);
27
- __exportStar(require("./pubSubOrderInvoicesReadyMessageStub"), exports);
27
+ __exportStar(require("./pubSubOrderInvoicedMessageStub"), exports);
28
28
  __exportStar(require("./pubSubStripeConnectedAccountBalanceAvailableUpdatedMessageStub"), exports);
29
29
  __exportStar(require("./wallets"), exports);
30
30
  __exportStar(require("./pubSubOrderIssueReportedMessageStub"), exports);
@@ -0,0 +1,2 @@
1
+ import type { PubSubOrderInvoicedMessage } from "../../types";
2
+ export declare function pubSubOrderInvoicedMessageStub(overwrite?: Partial<PubSubOrderInvoicedMessage>): PubSubOrderInvoicedMessage;
@@ -0,0 +1,9 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.pubSubOrderInvoicedMessageStub = pubSubOrderInvoicedMessageStub;
4
+ function pubSubOrderInvoicedMessageStub(overwrite = {}) {
5
+ return {
6
+ orderDocumentId: "order-document-id",
7
+ ...overwrite,
8
+ };
9
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@doctocar/tooling",
3
- "version": "0.3.1-33",
3
+ "version": "0.3.1-35",
4
4
  "description": "A set of tools for DoctoCar projects",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",