@catlabtech/mycal-core 0.1.1 → 0.1.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +3 -0
- package/dist/business-days.d.ts +7 -0
- package/dist/business-days.js +106 -0
- package/dist/filter.d.ts +18 -0
- package/dist/filter.js +75 -0
- package/dist/hijri.d.ts +36 -0
- package/dist/hijri.js +59 -0
- package/dist/ical.d.ts +2 -0
- package/dist/ical.js +90 -0
- package/dist/index.d.ts +14 -803
- package/dist/index.js +22 -517
- package/dist/long-weekend.d.ts +18 -0
- package/dist/long-weekend.js +127 -0
- package/dist/replacement.d.ts +2 -0
- package/dist/replacement.js +69 -0
- package/dist/schemas.d.ts +652 -0
- package/dist/schemas.js +136 -0
- package/dist/school.d.ts +10 -0
- package/dist/school.js +44 -0
- package/dist/state-resolver.d.ts +4 -0
- package/dist/state-resolver.js +18 -0
- package/dist/types.d.ts +144 -0
- package/dist/types.js +2 -0
- package/dist/validation.d.ts +21 -0
- package/dist/validation.js +94 -0
- package/dist/weekend.d.ts +8 -0
- package/dist/weekend.js +57 -0
- package/package.json +8 -3
package/dist/index.d.ts
CHANGED
|
@@ -1,803 +1,14 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
readonly endDate?: string;
|
|
16
|
-
readonly name: LocalizedString;
|
|
17
|
-
readonly type: HolidayType;
|
|
18
|
-
readonly status: HolidayStatus;
|
|
19
|
-
readonly states: readonly string[];
|
|
20
|
-
readonly isPublicHoliday: boolean;
|
|
21
|
-
readonly gazetteLevel: GazetteLevel;
|
|
22
|
-
readonly isReplacementFor?: string;
|
|
23
|
-
readonly hijriDate?: string;
|
|
24
|
-
readonly gazetteRef?: string;
|
|
25
|
-
readonly source: HolidaySource;
|
|
26
|
-
readonly confirmedAt?: string;
|
|
27
|
-
readonly createdAt: string;
|
|
28
|
-
readonly updatedAt: string;
|
|
29
|
-
}
|
|
30
|
-
type StateGroup = "A" | "B";
|
|
31
|
-
interface WeekendConfig {
|
|
32
|
-
readonly from: string;
|
|
33
|
-
readonly to: string | null;
|
|
34
|
-
readonly weekendDays: readonly number[];
|
|
35
|
-
readonly group: StateGroup;
|
|
36
|
-
}
|
|
37
|
-
type StateType = "state" | "federal_territory";
|
|
38
|
-
interface State {
|
|
39
|
-
readonly code: string;
|
|
40
|
-
readonly aliases: readonly string[];
|
|
41
|
-
readonly name: LocalizedString;
|
|
42
|
-
readonly type: StateType;
|
|
43
|
-
readonly weekendHistory: readonly WeekendConfig[];
|
|
44
|
-
readonly group: StateGroup;
|
|
45
|
-
}
|
|
46
|
-
interface SchoolTermSegment {
|
|
47
|
-
readonly startDate: string;
|
|
48
|
-
readonly endDate: string;
|
|
49
|
-
readonly schoolDays: number;
|
|
50
|
-
}
|
|
51
|
-
interface SchoolTerm {
|
|
52
|
-
readonly id: string;
|
|
53
|
-
readonly year: number;
|
|
54
|
-
readonly term: 1 | 2;
|
|
55
|
-
readonly group: StateGroup;
|
|
56
|
-
readonly segments: readonly SchoolTermSegment[];
|
|
57
|
-
readonly totalSchoolDays: number;
|
|
58
|
-
readonly startDate: string;
|
|
59
|
-
readonly endDate: string;
|
|
60
|
-
}
|
|
61
|
-
type SchoolHolidayType = "cuti_penggal_1" | "cuti_pertengahan" | "cuti_penggal_2" | "cuti_akhir" | "cuti_perayaan_kpm";
|
|
62
|
-
interface SchoolHoliday {
|
|
63
|
-
readonly id: string;
|
|
64
|
-
readonly year: number;
|
|
65
|
-
readonly group: StateGroup;
|
|
66
|
-
readonly type: SchoolHolidayType;
|
|
67
|
-
readonly name: LocalizedString;
|
|
68
|
-
readonly startDate: string;
|
|
69
|
-
readonly endDate: string;
|
|
70
|
-
readonly days: number;
|
|
71
|
-
readonly states?: readonly string[];
|
|
72
|
-
readonly excludeStates?: readonly string[];
|
|
73
|
-
readonly remarks?: string;
|
|
74
|
-
}
|
|
75
|
-
type ExamType = "spm" | "stpm" | "muet" | "pt3" | "stam" | "other";
|
|
76
|
-
type ExamSource = "kpm" | "mpm";
|
|
77
|
-
interface Exam {
|
|
78
|
-
readonly id: string;
|
|
79
|
-
readonly year: number;
|
|
80
|
-
readonly name: string;
|
|
81
|
-
readonly fullName: LocalizedString;
|
|
82
|
-
readonly type: ExamType;
|
|
83
|
-
readonly startDate: string;
|
|
84
|
-
readonly endDate?: string;
|
|
85
|
-
readonly status: "confirmed" | "tentative";
|
|
86
|
-
readonly resultsDate?: string;
|
|
87
|
-
readonly source: ExamSource;
|
|
88
|
-
}
|
|
89
|
-
interface CheckDateResult {
|
|
90
|
-
readonly date: string;
|
|
91
|
-
readonly dayOfWeek: string;
|
|
92
|
-
readonly isHoliday: boolean;
|
|
93
|
-
readonly isWeekend: boolean;
|
|
94
|
-
readonly isWorkingDay: boolean;
|
|
95
|
-
readonly isSchoolDay: boolean;
|
|
96
|
-
readonly holidays: readonly Holiday[];
|
|
97
|
-
readonly school: {
|
|
98
|
-
readonly group: StateGroup;
|
|
99
|
-
readonly term: SchoolTerm | null;
|
|
100
|
-
readonly holiday: SchoolHoliday | null;
|
|
101
|
-
} | null;
|
|
102
|
-
readonly state: {
|
|
103
|
-
readonly code: string;
|
|
104
|
-
readonly weekendDays: readonly string[];
|
|
105
|
-
readonly group: StateGroup;
|
|
106
|
-
};
|
|
107
|
-
}
|
|
108
|
-
interface BusinessDaysResult {
|
|
109
|
-
readonly totalDays: number;
|
|
110
|
-
readonly businessDays: number;
|
|
111
|
-
readonly holidays: number;
|
|
112
|
-
readonly weekendDays: number;
|
|
113
|
-
readonly holidayList: readonly Holiday[];
|
|
114
|
-
}
|
|
115
|
-
interface LongWeekend {
|
|
116
|
-
readonly startDate: string;
|
|
117
|
-
readonly endDate: string;
|
|
118
|
-
readonly totalDays: number;
|
|
119
|
-
readonly holidays: readonly Holiday[];
|
|
120
|
-
readonly weekendDays: number;
|
|
121
|
-
readonly bridgeDaysNeeded: number;
|
|
122
|
-
}
|
|
123
|
-
interface ChangelogEntry {
|
|
124
|
-
readonly timestamp: string;
|
|
125
|
-
readonly event: string;
|
|
126
|
-
readonly holidayId?: string;
|
|
127
|
-
readonly examId?: string;
|
|
128
|
-
readonly description: string;
|
|
129
|
-
readonly changes?: Record<string, {
|
|
130
|
-
from: unknown;
|
|
131
|
-
to: unknown;
|
|
132
|
-
}>;
|
|
133
|
-
}
|
|
134
|
-
|
|
135
|
-
declare const holidaySchema: z.ZodObject<{
|
|
136
|
-
id: z.ZodString;
|
|
137
|
-
date: z.ZodString;
|
|
138
|
-
endDate: z.ZodOptional<z.ZodString>;
|
|
139
|
-
name: z.ZodObject<{
|
|
140
|
-
ms: z.ZodString;
|
|
141
|
-
en: z.ZodString;
|
|
142
|
-
zh: z.ZodOptional<z.ZodString>;
|
|
143
|
-
}, "strip", z.ZodTypeAny, {
|
|
144
|
-
ms: string;
|
|
145
|
-
en: string;
|
|
146
|
-
zh?: string | undefined;
|
|
147
|
-
}, {
|
|
148
|
-
ms: string;
|
|
149
|
-
en: string;
|
|
150
|
-
zh?: string | undefined;
|
|
151
|
-
}>;
|
|
152
|
-
type: z.ZodEnum<["federal", "state", "islamic", "islamic_state", "replacement", "adhoc"]>;
|
|
153
|
-
status: z.ZodEnum<["confirmed", "tentative", "announced", "cancelled"]>;
|
|
154
|
-
states: z.ZodArray<z.ZodString, "many">;
|
|
155
|
-
isPublicHoliday: z.ZodBoolean;
|
|
156
|
-
gazetteLevel: z.ZodEnum<["P", "N"]>;
|
|
157
|
-
isReplacementFor: z.ZodOptional<z.ZodString>;
|
|
158
|
-
hijriDate: z.ZodOptional<z.ZodString>;
|
|
159
|
-
gazetteRef: z.ZodOptional<z.ZodString>;
|
|
160
|
-
source: z.ZodEnum<["jpm", "jakim", "state-gov", "community", "admin"]>;
|
|
161
|
-
confirmedAt: z.ZodOptional<z.ZodString>;
|
|
162
|
-
createdAt: z.ZodString;
|
|
163
|
-
updatedAt: z.ZodString;
|
|
164
|
-
}, "strip", z.ZodTypeAny, {
|
|
165
|
-
type: "federal" | "state" | "islamic" | "islamic_state" | "replacement" | "adhoc";
|
|
166
|
-
status: "confirmed" | "tentative" | "announced" | "cancelled";
|
|
167
|
-
id: string;
|
|
168
|
-
date: string;
|
|
169
|
-
name: {
|
|
170
|
-
ms: string;
|
|
171
|
-
en: string;
|
|
172
|
-
zh?: string | undefined;
|
|
173
|
-
};
|
|
174
|
-
states: string[];
|
|
175
|
-
isPublicHoliday: boolean;
|
|
176
|
-
gazetteLevel: "P" | "N";
|
|
177
|
-
source: "jpm" | "jakim" | "state-gov" | "community" | "admin";
|
|
178
|
-
createdAt: string;
|
|
179
|
-
updatedAt: string;
|
|
180
|
-
endDate?: string | undefined;
|
|
181
|
-
isReplacementFor?: string | undefined;
|
|
182
|
-
hijriDate?: string | undefined;
|
|
183
|
-
gazetteRef?: string | undefined;
|
|
184
|
-
confirmedAt?: string | undefined;
|
|
185
|
-
}, {
|
|
186
|
-
type: "federal" | "state" | "islamic" | "islamic_state" | "replacement" | "adhoc";
|
|
187
|
-
status: "confirmed" | "tentative" | "announced" | "cancelled";
|
|
188
|
-
id: string;
|
|
189
|
-
date: string;
|
|
190
|
-
name: {
|
|
191
|
-
ms: string;
|
|
192
|
-
en: string;
|
|
193
|
-
zh?: string | undefined;
|
|
194
|
-
};
|
|
195
|
-
states: string[];
|
|
196
|
-
isPublicHoliday: boolean;
|
|
197
|
-
gazetteLevel: "P" | "N";
|
|
198
|
-
source: "jpm" | "jakim" | "state-gov" | "community" | "admin";
|
|
199
|
-
createdAt: string;
|
|
200
|
-
updatedAt: string;
|
|
201
|
-
endDate?: string | undefined;
|
|
202
|
-
isReplacementFor?: string | undefined;
|
|
203
|
-
hijriDate?: string | undefined;
|
|
204
|
-
gazetteRef?: string | undefined;
|
|
205
|
-
confirmedAt?: string | undefined;
|
|
206
|
-
}>;
|
|
207
|
-
declare const holidayFileSchema: z.ZodArray<z.ZodObject<{
|
|
208
|
-
id: z.ZodString;
|
|
209
|
-
date: z.ZodString;
|
|
210
|
-
endDate: z.ZodOptional<z.ZodString>;
|
|
211
|
-
name: z.ZodObject<{
|
|
212
|
-
ms: z.ZodString;
|
|
213
|
-
en: z.ZodString;
|
|
214
|
-
zh: z.ZodOptional<z.ZodString>;
|
|
215
|
-
}, "strip", z.ZodTypeAny, {
|
|
216
|
-
ms: string;
|
|
217
|
-
en: string;
|
|
218
|
-
zh?: string | undefined;
|
|
219
|
-
}, {
|
|
220
|
-
ms: string;
|
|
221
|
-
en: string;
|
|
222
|
-
zh?: string | undefined;
|
|
223
|
-
}>;
|
|
224
|
-
type: z.ZodEnum<["federal", "state", "islamic", "islamic_state", "replacement", "adhoc"]>;
|
|
225
|
-
status: z.ZodEnum<["confirmed", "tentative", "announced", "cancelled"]>;
|
|
226
|
-
states: z.ZodArray<z.ZodString, "many">;
|
|
227
|
-
isPublicHoliday: z.ZodBoolean;
|
|
228
|
-
gazetteLevel: z.ZodEnum<["P", "N"]>;
|
|
229
|
-
isReplacementFor: z.ZodOptional<z.ZodString>;
|
|
230
|
-
hijriDate: z.ZodOptional<z.ZodString>;
|
|
231
|
-
gazetteRef: z.ZodOptional<z.ZodString>;
|
|
232
|
-
source: z.ZodEnum<["jpm", "jakim", "state-gov", "community", "admin"]>;
|
|
233
|
-
confirmedAt: z.ZodOptional<z.ZodString>;
|
|
234
|
-
createdAt: z.ZodString;
|
|
235
|
-
updatedAt: z.ZodString;
|
|
236
|
-
}, "strip", z.ZodTypeAny, {
|
|
237
|
-
type: "federal" | "state" | "islamic" | "islamic_state" | "replacement" | "adhoc";
|
|
238
|
-
status: "confirmed" | "tentative" | "announced" | "cancelled";
|
|
239
|
-
id: string;
|
|
240
|
-
date: string;
|
|
241
|
-
name: {
|
|
242
|
-
ms: string;
|
|
243
|
-
en: string;
|
|
244
|
-
zh?: string | undefined;
|
|
245
|
-
};
|
|
246
|
-
states: string[];
|
|
247
|
-
isPublicHoliday: boolean;
|
|
248
|
-
gazetteLevel: "P" | "N";
|
|
249
|
-
source: "jpm" | "jakim" | "state-gov" | "community" | "admin";
|
|
250
|
-
createdAt: string;
|
|
251
|
-
updatedAt: string;
|
|
252
|
-
endDate?: string | undefined;
|
|
253
|
-
isReplacementFor?: string | undefined;
|
|
254
|
-
hijriDate?: string | undefined;
|
|
255
|
-
gazetteRef?: string | undefined;
|
|
256
|
-
confirmedAt?: string | undefined;
|
|
257
|
-
}, {
|
|
258
|
-
type: "federal" | "state" | "islamic" | "islamic_state" | "replacement" | "adhoc";
|
|
259
|
-
status: "confirmed" | "tentative" | "announced" | "cancelled";
|
|
260
|
-
id: string;
|
|
261
|
-
date: string;
|
|
262
|
-
name: {
|
|
263
|
-
ms: string;
|
|
264
|
-
en: string;
|
|
265
|
-
zh?: string | undefined;
|
|
266
|
-
};
|
|
267
|
-
states: string[];
|
|
268
|
-
isPublicHoliday: boolean;
|
|
269
|
-
gazetteLevel: "P" | "N";
|
|
270
|
-
source: "jpm" | "jakim" | "state-gov" | "community" | "admin";
|
|
271
|
-
createdAt: string;
|
|
272
|
-
updatedAt: string;
|
|
273
|
-
endDate?: string | undefined;
|
|
274
|
-
isReplacementFor?: string | undefined;
|
|
275
|
-
hijriDate?: string | undefined;
|
|
276
|
-
gazetteRef?: string | undefined;
|
|
277
|
-
confirmedAt?: string | undefined;
|
|
278
|
-
}>, "many">;
|
|
279
|
-
declare const stateSchema: z.ZodObject<{
|
|
280
|
-
code: z.ZodString;
|
|
281
|
-
aliases: z.ZodArray<z.ZodString, "many">;
|
|
282
|
-
name: z.ZodObject<{
|
|
283
|
-
ms: z.ZodString;
|
|
284
|
-
en: z.ZodString;
|
|
285
|
-
zh: z.ZodOptional<z.ZodString>;
|
|
286
|
-
}, "strip", z.ZodTypeAny, {
|
|
287
|
-
ms: string;
|
|
288
|
-
en: string;
|
|
289
|
-
zh?: string | undefined;
|
|
290
|
-
}, {
|
|
291
|
-
ms: string;
|
|
292
|
-
en: string;
|
|
293
|
-
zh?: string | undefined;
|
|
294
|
-
}>;
|
|
295
|
-
type: z.ZodEnum<["state", "federal_territory"]>;
|
|
296
|
-
weekendHistory: z.ZodArray<z.ZodObject<{
|
|
297
|
-
from: z.ZodString;
|
|
298
|
-
to: z.ZodNullable<z.ZodString>;
|
|
299
|
-
weekendDays: z.ZodArray<z.ZodNumber, "many">;
|
|
300
|
-
group: z.ZodEnum<["A", "B"]>;
|
|
301
|
-
}, "strip", z.ZodTypeAny, {
|
|
302
|
-
from: string;
|
|
303
|
-
to: string | null;
|
|
304
|
-
weekendDays: number[];
|
|
305
|
-
group: "A" | "B";
|
|
306
|
-
}, {
|
|
307
|
-
from: string;
|
|
308
|
-
to: string | null;
|
|
309
|
-
weekendDays: number[];
|
|
310
|
-
group: "A" | "B";
|
|
311
|
-
}>, "many">;
|
|
312
|
-
group: z.ZodEnum<["A", "B"]>;
|
|
313
|
-
}, "strip", z.ZodTypeAny, {
|
|
314
|
-
code: string;
|
|
315
|
-
type: "state" | "federal_territory";
|
|
316
|
-
name: {
|
|
317
|
-
ms: string;
|
|
318
|
-
en: string;
|
|
319
|
-
zh?: string | undefined;
|
|
320
|
-
};
|
|
321
|
-
group: "A" | "B";
|
|
322
|
-
aliases: string[];
|
|
323
|
-
weekendHistory: {
|
|
324
|
-
from: string;
|
|
325
|
-
to: string | null;
|
|
326
|
-
weekendDays: number[];
|
|
327
|
-
group: "A" | "B";
|
|
328
|
-
}[];
|
|
329
|
-
}, {
|
|
330
|
-
code: string;
|
|
331
|
-
type: "state" | "federal_territory";
|
|
332
|
-
name: {
|
|
333
|
-
ms: string;
|
|
334
|
-
en: string;
|
|
335
|
-
zh?: string | undefined;
|
|
336
|
-
};
|
|
337
|
-
group: "A" | "B";
|
|
338
|
-
aliases: string[];
|
|
339
|
-
weekendHistory: {
|
|
340
|
-
from: string;
|
|
341
|
-
to: string | null;
|
|
342
|
-
weekendDays: number[];
|
|
343
|
-
group: "A" | "B";
|
|
344
|
-
}[];
|
|
345
|
-
}>;
|
|
346
|
-
declare const statesFileSchema: z.ZodArray<z.ZodObject<{
|
|
347
|
-
code: z.ZodString;
|
|
348
|
-
aliases: z.ZodArray<z.ZodString, "many">;
|
|
349
|
-
name: z.ZodObject<{
|
|
350
|
-
ms: z.ZodString;
|
|
351
|
-
en: z.ZodString;
|
|
352
|
-
zh: z.ZodOptional<z.ZodString>;
|
|
353
|
-
}, "strip", z.ZodTypeAny, {
|
|
354
|
-
ms: string;
|
|
355
|
-
en: string;
|
|
356
|
-
zh?: string | undefined;
|
|
357
|
-
}, {
|
|
358
|
-
ms: string;
|
|
359
|
-
en: string;
|
|
360
|
-
zh?: string | undefined;
|
|
361
|
-
}>;
|
|
362
|
-
type: z.ZodEnum<["state", "federal_territory"]>;
|
|
363
|
-
weekendHistory: z.ZodArray<z.ZodObject<{
|
|
364
|
-
from: z.ZodString;
|
|
365
|
-
to: z.ZodNullable<z.ZodString>;
|
|
366
|
-
weekendDays: z.ZodArray<z.ZodNumber, "many">;
|
|
367
|
-
group: z.ZodEnum<["A", "B"]>;
|
|
368
|
-
}, "strip", z.ZodTypeAny, {
|
|
369
|
-
from: string;
|
|
370
|
-
to: string | null;
|
|
371
|
-
weekendDays: number[];
|
|
372
|
-
group: "A" | "B";
|
|
373
|
-
}, {
|
|
374
|
-
from: string;
|
|
375
|
-
to: string | null;
|
|
376
|
-
weekendDays: number[];
|
|
377
|
-
group: "A" | "B";
|
|
378
|
-
}>, "many">;
|
|
379
|
-
group: z.ZodEnum<["A", "B"]>;
|
|
380
|
-
}, "strip", z.ZodTypeAny, {
|
|
381
|
-
code: string;
|
|
382
|
-
type: "state" | "federal_territory";
|
|
383
|
-
name: {
|
|
384
|
-
ms: string;
|
|
385
|
-
en: string;
|
|
386
|
-
zh?: string | undefined;
|
|
387
|
-
};
|
|
388
|
-
group: "A" | "B";
|
|
389
|
-
aliases: string[];
|
|
390
|
-
weekendHistory: {
|
|
391
|
-
from: string;
|
|
392
|
-
to: string | null;
|
|
393
|
-
weekendDays: number[];
|
|
394
|
-
group: "A" | "B";
|
|
395
|
-
}[];
|
|
396
|
-
}, {
|
|
397
|
-
code: string;
|
|
398
|
-
type: "state" | "federal_territory";
|
|
399
|
-
name: {
|
|
400
|
-
ms: string;
|
|
401
|
-
en: string;
|
|
402
|
-
zh?: string | undefined;
|
|
403
|
-
};
|
|
404
|
-
group: "A" | "B";
|
|
405
|
-
aliases: string[];
|
|
406
|
-
weekendHistory: {
|
|
407
|
-
from: string;
|
|
408
|
-
to: string | null;
|
|
409
|
-
weekendDays: number[];
|
|
410
|
-
group: "A" | "B";
|
|
411
|
-
}[];
|
|
412
|
-
}>, "many">;
|
|
413
|
-
declare const schoolTermSchema: z.ZodObject<{
|
|
414
|
-
id: z.ZodString;
|
|
415
|
-
year: z.ZodNumber;
|
|
416
|
-
term: z.ZodUnion<[z.ZodLiteral<1>, z.ZodLiteral<2>]>;
|
|
417
|
-
group: z.ZodEnum<["A", "B"]>;
|
|
418
|
-
segments: z.ZodArray<z.ZodObject<{
|
|
419
|
-
startDate: z.ZodString;
|
|
420
|
-
endDate: z.ZodString;
|
|
421
|
-
schoolDays: z.ZodNumber;
|
|
422
|
-
}, "strip", z.ZodTypeAny, {
|
|
423
|
-
endDate: string;
|
|
424
|
-
startDate: string;
|
|
425
|
-
schoolDays: number;
|
|
426
|
-
}, {
|
|
427
|
-
endDate: string;
|
|
428
|
-
startDate: string;
|
|
429
|
-
schoolDays: number;
|
|
430
|
-
}>, "many">;
|
|
431
|
-
totalSchoolDays: z.ZodNumber;
|
|
432
|
-
startDate: z.ZodString;
|
|
433
|
-
endDate: z.ZodString;
|
|
434
|
-
}, "strip", z.ZodTypeAny, {
|
|
435
|
-
id: string;
|
|
436
|
-
endDate: string;
|
|
437
|
-
group: "A" | "B";
|
|
438
|
-
startDate: string;
|
|
439
|
-
year: number;
|
|
440
|
-
term: 1 | 2;
|
|
441
|
-
segments: {
|
|
442
|
-
endDate: string;
|
|
443
|
-
startDate: string;
|
|
444
|
-
schoolDays: number;
|
|
445
|
-
}[];
|
|
446
|
-
totalSchoolDays: number;
|
|
447
|
-
}, {
|
|
448
|
-
id: string;
|
|
449
|
-
endDate: string;
|
|
450
|
-
group: "A" | "B";
|
|
451
|
-
startDate: string;
|
|
452
|
-
year: number;
|
|
453
|
-
term: 1 | 2;
|
|
454
|
-
segments: {
|
|
455
|
-
endDate: string;
|
|
456
|
-
startDate: string;
|
|
457
|
-
schoolDays: number;
|
|
458
|
-
}[];
|
|
459
|
-
totalSchoolDays: number;
|
|
460
|
-
}>;
|
|
461
|
-
declare const schoolHolidaySchema: z.ZodObject<{
|
|
462
|
-
id: z.ZodString;
|
|
463
|
-
year: z.ZodNumber;
|
|
464
|
-
group: z.ZodEnum<["A", "B"]>;
|
|
465
|
-
type: z.ZodEnum<["cuti_penggal_1", "cuti_pertengahan", "cuti_penggal_2", "cuti_akhir", "cuti_perayaan_kpm"]>;
|
|
466
|
-
name: z.ZodObject<{
|
|
467
|
-
ms: z.ZodString;
|
|
468
|
-
en: z.ZodString;
|
|
469
|
-
zh: z.ZodOptional<z.ZodString>;
|
|
470
|
-
}, "strip", z.ZodTypeAny, {
|
|
471
|
-
ms: string;
|
|
472
|
-
en: string;
|
|
473
|
-
zh?: string | undefined;
|
|
474
|
-
}, {
|
|
475
|
-
ms: string;
|
|
476
|
-
en: string;
|
|
477
|
-
zh?: string | undefined;
|
|
478
|
-
}>;
|
|
479
|
-
startDate: z.ZodString;
|
|
480
|
-
endDate: z.ZodString;
|
|
481
|
-
days: z.ZodNumber;
|
|
482
|
-
states: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
483
|
-
excludeStates: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
484
|
-
remarks: z.ZodOptional<z.ZodString>;
|
|
485
|
-
}, "strip", z.ZodTypeAny, {
|
|
486
|
-
type: "cuti_penggal_1" | "cuti_pertengahan" | "cuti_penggal_2" | "cuti_akhir" | "cuti_perayaan_kpm";
|
|
487
|
-
id: string;
|
|
488
|
-
endDate: string;
|
|
489
|
-
name: {
|
|
490
|
-
ms: string;
|
|
491
|
-
en: string;
|
|
492
|
-
zh?: string | undefined;
|
|
493
|
-
};
|
|
494
|
-
group: "A" | "B";
|
|
495
|
-
startDate: string;
|
|
496
|
-
year: number;
|
|
497
|
-
days: number;
|
|
498
|
-
states?: string[] | undefined;
|
|
499
|
-
excludeStates?: string[] | undefined;
|
|
500
|
-
remarks?: string | undefined;
|
|
501
|
-
}, {
|
|
502
|
-
type: "cuti_penggal_1" | "cuti_pertengahan" | "cuti_penggal_2" | "cuti_akhir" | "cuti_perayaan_kpm";
|
|
503
|
-
id: string;
|
|
504
|
-
endDate: string;
|
|
505
|
-
name: {
|
|
506
|
-
ms: string;
|
|
507
|
-
en: string;
|
|
508
|
-
zh?: string | undefined;
|
|
509
|
-
};
|
|
510
|
-
group: "A" | "B";
|
|
511
|
-
startDate: string;
|
|
512
|
-
year: number;
|
|
513
|
-
days: number;
|
|
514
|
-
states?: string[] | undefined;
|
|
515
|
-
excludeStates?: string[] | undefined;
|
|
516
|
-
remarks?: string | undefined;
|
|
517
|
-
}>;
|
|
518
|
-
declare const schoolTermsFileSchema: z.ZodArray<z.ZodObject<{
|
|
519
|
-
id: z.ZodString;
|
|
520
|
-
year: z.ZodNumber;
|
|
521
|
-
term: z.ZodUnion<[z.ZodLiteral<1>, z.ZodLiteral<2>]>;
|
|
522
|
-
group: z.ZodEnum<["A", "B"]>;
|
|
523
|
-
segments: z.ZodArray<z.ZodObject<{
|
|
524
|
-
startDate: z.ZodString;
|
|
525
|
-
endDate: z.ZodString;
|
|
526
|
-
schoolDays: z.ZodNumber;
|
|
527
|
-
}, "strip", z.ZodTypeAny, {
|
|
528
|
-
endDate: string;
|
|
529
|
-
startDate: string;
|
|
530
|
-
schoolDays: number;
|
|
531
|
-
}, {
|
|
532
|
-
endDate: string;
|
|
533
|
-
startDate: string;
|
|
534
|
-
schoolDays: number;
|
|
535
|
-
}>, "many">;
|
|
536
|
-
totalSchoolDays: z.ZodNumber;
|
|
537
|
-
startDate: z.ZodString;
|
|
538
|
-
endDate: z.ZodString;
|
|
539
|
-
}, "strip", z.ZodTypeAny, {
|
|
540
|
-
id: string;
|
|
541
|
-
endDate: string;
|
|
542
|
-
group: "A" | "B";
|
|
543
|
-
startDate: string;
|
|
544
|
-
year: number;
|
|
545
|
-
term: 1 | 2;
|
|
546
|
-
segments: {
|
|
547
|
-
endDate: string;
|
|
548
|
-
startDate: string;
|
|
549
|
-
schoolDays: number;
|
|
550
|
-
}[];
|
|
551
|
-
totalSchoolDays: number;
|
|
552
|
-
}, {
|
|
553
|
-
id: string;
|
|
554
|
-
endDate: string;
|
|
555
|
-
group: "A" | "B";
|
|
556
|
-
startDate: string;
|
|
557
|
-
year: number;
|
|
558
|
-
term: 1 | 2;
|
|
559
|
-
segments: {
|
|
560
|
-
endDate: string;
|
|
561
|
-
startDate: string;
|
|
562
|
-
schoolDays: number;
|
|
563
|
-
}[];
|
|
564
|
-
totalSchoolDays: number;
|
|
565
|
-
}>, "many">;
|
|
566
|
-
declare const schoolHolidaysFileSchema: z.ZodArray<z.ZodObject<{
|
|
567
|
-
id: z.ZodString;
|
|
568
|
-
year: z.ZodNumber;
|
|
569
|
-
group: z.ZodEnum<["A", "B"]>;
|
|
570
|
-
type: z.ZodEnum<["cuti_penggal_1", "cuti_pertengahan", "cuti_penggal_2", "cuti_akhir", "cuti_perayaan_kpm"]>;
|
|
571
|
-
name: z.ZodObject<{
|
|
572
|
-
ms: z.ZodString;
|
|
573
|
-
en: z.ZodString;
|
|
574
|
-
zh: z.ZodOptional<z.ZodString>;
|
|
575
|
-
}, "strip", z.ZodTypeAny, {
|
|
576
|
-
ms: string;
|
|
577
|
-
en: string;
|
|
578
|
-
zh?: string | undefined;
|
|
579
|
-
}, {
|
|
580
|
-
ms: string;
|
|
581
|
-
en: string;
|
|
582
|
-
zh?: string | undefined;
|
|
583
|
-
}>;
|
|
584
|
-
startDate: z.ZodString;
|
|
585
|
-
endDate: z.ZodString;
|
|
586
|
-
days: z.ZodNumber;
|
|
587
|
-
states: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
588
|
-
excludeStates: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
589
|
-
remarks: z.ZodOptional<z.ZodString>;
|
|
590
|
-
}, "strip", z.ZodTypeAny, {
|
|
591
|
-
type: "cuti_penggal_1" | "cuti_pertengahan" | "cuti_penggal_2" | "cuti_akhir" | "cuti_perayaan_kpm";
|
|
592
|
-
id: string;
|
|
593
|
-
endDate: string;
|
|
594
|
-
name: {
|
|
595
|
-
ms: string;
|
|
596
|
-
en: string;
|
|
597
|
-
zh?: string | undefined;
|
|
598
|
-
};
|
|
599
|
-
group: "A" | "B";
|
|
600
|
-
startDate: string;
|
|
601
|
-
year: number;
|
|
602
|
-
days: number;
|
|
603
|
-
states?: string[] | undefined;
|
|
604
|
-
excludeStates?: string[] | undefined;
|
|
605
|
-
remarks?: string | undefined;
|
|
606
|
-
}, {
|
|
607
|
-
type: "cuti_penggal_1" | "cuti_pertengahan" | "cuti_penggal_2" | "cuti_akhir" | "cuti_perayaan_kpm";
|
|
608
|
-
id: string;
|
|
609
|
-
endDate: string;
|
|
610
|
-
name: {
|
|
611
|
-
ms: string;
|
|
612
|
-
en: string;
|
|
613
|
-
zh?: string | undefined;
|
|
614
|
-
};
|
|
615
|
-
group: "A" | "B";
|
|
616
|
-
startDate: string;
|
|
617
|
-
year: number;
|
|
618
|
-
days: number;
|
|
619
|
-
states?: string[] | undefined;
|
|
620
|
-
excludeStates?: string[] | undefined;
|
|
621
|
-
remarks?: string | undefined;
|
|
622
|
-
}>, "many">;
|
|
623
|
-
declare const examSchema: z.ZodObject<{
|
|
624
|
-
id: z.ZodString;
|
|
625
|
-
year: z.ZodNumber;
|
|
626
|
-
name: z.ZodString;
|
|
627
|
-
fullName: z.ZodObject<{
|
|
628
|
-
ms: z.ZodString;
|
|
629
|
-
en: z.ZodString;
|
|
630
|
-
zh: z.ZodOptional<z.ZodString>;
|
|
631
|
-
}, "strip", z.ZodTypeAny, {
|
|
632
|
-
ms: string;
|
|
633
|
-
en: string;
|
|
634
|
-
zh?: string | undefined;
|
|
635
|
-
}, {
|
|
636
|
-
ms: string;
|
|
637
|
-
en: string;
|
|
638
|
-
zh?: string | undefined;
|
|
639
|
-
}>;
|
|
640
|
-
type: z.ZodEnum<["spm", "stpm", "muet", "pt3", "stam", "other"]>;
|
|
641
|
-
startDate: z.ZodString;
|
|
642
|
-
endDate: z.ZodOptional<z.ZodString>;
|
|
643
|
-
status: z.ZodEnum<["confirmed", "tentative"]>;
|
|
644
|
-
resultsDate: z.ZodOptional<z.ZodString>;
|
|
645
|
-
source: z.ZodEnum<["kpm", "mpm"]>;
|
|
646
|
-
}, "strip", z.ZodTypeAny, {
|
|
647
|
-
type: "spm" | "stpm" | "muet" | "pt3" | "stam" | "other";
|
|
648
|
-
status: "confirmed" | "tentative";
|
|
649
|
-
id: string;
|
|
650
|
-
name: string;
|
|
651
|
-
source: "kpm" | "mpm";
|
|
652
|
-
startDate: string;
|
|
653
|
-
year: number;
|
|
654
|
-
fullName: {
|
|
655
|
-
ms: string;
|
|
656
|
-
en: string;
|
|
657
|
-
zh?: string | undefined;
|
|
658
|
-
};
|
|
659
|
-
endDate?: string | undefined;
|
|
660
|
-
resultsDate?: string | undefined;
|
|
661
|
-
}, {
|
|
662
|
-
type: "spm" | "stpm" | "muet" | "pt3" | "stam" | "other";
|
|
663
|
-
status: "confirmed" | "tentative";
|
|
664
|
-
id: string;
|
|
665
|
-
name: string;
|
|
666
|
-
source: "kpm" | "mpm";
|
|
667
|
-
startDate: string;
|
|
668
|
-
year: number;
|
|
669
|
-
fullName: {
|
|
670
|
-
ms: string;
|
|
671
|
-
en: string;
|
|
672
|
-
zh?: string | undefined;
|
|
673
|
-
};
|
|
674
|
-
endDate?: string | undefined;
|
|
675
|
-
resultsDate?: string | undefined;
|
|
676
|
-
}>;
|
|
677
|
-
declare const examsFileSchema: z.ZodArray<z.ZodObject<{
|
|
678
|
-
id: z.ZodString;
|
|
679
|
-
year: z.ZodNumber;
|
|
680
|
-
name: z.ZodString;
|
|
681
|
-
fullName: z.ZodObject<{
|
|
682
|
-
ms: z.ZodString;
|
|
683
|
-
en: z.ZodString;
|
|
684
|
-
zh: z.ZodOptional<z.ZodString>;
|
|
685
|
-
}, "strip", z.ZodTypeAny, {
|
|
686
|
-
ms: string;
|
|
687
|
-
en: string;
|
|
688
|
-
zh?: string | undefined;
|
|
689
|
-
}, {
|
|
690
|
-
ms: string;
|
|
691
|
-
en: string;
|
|
692
|
-
zh?: string | undefined;
|
|
693
|
-
}>;
|
|
694
|
-
type: z.ZodEnum<["spm", "stpm", "muet", "pt3", "stam", "other"]>;
|
|
695
|
-
startDate: z.ZodString;
|
|
696
|
-
endDate: z.ZodOptional<z.ZodString>;
|
|
697
|
-
status: z.ZodEnum<["confirmed", "tentative"]>;
|
|
698
|
-
resultsDate: z.ZodOptional<z.ZodString>;
|
|
699
|
-
source: z.ZodEnum<["kpm", "mpm"]>;
|
|
700
|
-
}, "strip", z.ZodTypeAny, {
|
|
701
|
-
type: "spm" | "stpm" | "muet" | "pt3" | "stam" | "other";
|
|
702
|
-
status: "confirmed" | "tentative";
|
|
703
|
-
id: string;
|
|
704
|
-
name: string;
|
|
705
|
-
source: "kpm" | "mpm";
|
|
706
|
-
startDate: string;
|
|
707
|
-
year: number;
|
|
708
|
-
fullName: {
|
|
709
|
-
ms: string;
|
|
710
|
-
en: string;
|
|
711
|
-
zh?: string | undefined;
|
|
712
|
-
};
|
|
713
|
-
endDate?: string | undefined;
|
|
714
|
-
resultsDate?: string | undefined;
|
|
715
|
-
}, {
|
|
716
|
-
type: "spm" | "stpm" | "muet" | "pt3" | "stam" | "other";
|
|
717
|
-
status: "confirmed" | "tentative";
|
|
718
|
-
id: string;
|
|
719
|
-
name: string;
|
|
720
|
-
source: "kpm" | "mpm";
|
|
721
|
-
startDate: string;
|
|
722
|
-
year: number;
|
|
723
|
-
fullName: {
|
|
724
|
-
ms: string;
|
|
725
|
-
en: string;
|
|
726
|
-
zh?: string | undefined;
|
|
727
|
-
};
|
|
728
|
-
endDate?: string | undefined;
|
|
729
|
-
resultsDate?: string | undefined;
|
|
730
|
-
}>, "many">;
|
|
731
|
-
|
|
732
|
-
declare function resolveStateCode(query: string, states: readonly State[]): State | null;
|
|
733
|
-
declare function getStateByCode(code: string, states: readonly State[]): State | null;
|
|
734
|
-
declare function getStatesByGroup(group: "A" | "B", states: readonly State[]): readonly State[];
|
|
735
|
-
|
|
736
|
-
declare function getWeekendConfig(state: State, date: string): WeekendConfig;
|
|
737
|
-
declare function isWeekend(date: string, state: State): boolean;
|
|
738
|
-
declare function getDayOfWeekName(date: string): string;
|
|
739
|
-
declare function getWeekendDayNames(state: State, date: string): readonly string[];
|
|
740
|
-
declare function addDays(date: string, days: number): string;
|
|
741
|
-
declare function nextWorkingDay(date: string, state: State, holidayDates: ReadonlySet<string>): string;
|
|
742
|
-
declare function diffDays(start: string, end: string): number;
|
|
743
|
-
|
|
744
|
-
interface HolidayFilter {
|
|
745
|
-
readonly year?: number;
|
|
746
|
-
readonly month?: number;
|
|
747
|
-
readonly state?: string;
|
|
748
|
-
readonly type?: HolidayType;
|
|
749
|
-
readonly status?: HolidayStatus;
|
|
750
|
-
}
|
|
751
|
-
declare function filterHolidays(holidays: readonly Holiday[], filter: HolidayFilter): readonly Holiday[];
|
|
752
|
-
declare function findHolidaysByDate(date: string, holidays: readonly Holiday[], stateCode?: string): readonly Holiday[];
|
|
753
|
-
declare function findNextHoliday(afterDate: string, holidays: readonly Holiday[], stateCode?: string, type?: HolidayType, limit?: number): readonly Holiday[];
|
|
754
|
-
|
|
755
|
-
declare function calculateReplacementHolidays(holidays: readonly Holiday[], state: State): readonly Holiday[];
|
|
756
|
-
|
|
757
|
-
declare function countBusinessDays(start: string, end: string, state: State, holidays: readonly Holiday[]): BusinessDaysResult;
|
|
758
|
-
declare function addBusinessDays(startDate: string, daysToAdd: number, state: State, holidays: readonly Holiday[]): string;
|
|
759
|
-
|
|
760
|
-
declare function findSchoolTermByDate(date: string, terms: readonly SchoolTerm[], group: StateGroup): SchoolTerm | null;
|
|
761
|
-
declare function findSchoolHolidayByDate(date: string, holidays: readonly SchoolHoliday[], group: StateGroup, stateCode?: string): SchoolHoliday | null;
|
|
762
|
-
declare function isSchoolDay(date: string, terms: readonly SchoolTerm[], schoolHolidays: readonly SchoolHoliday[], group: StateGroup, isPublicHoliday: boolean, isWeekendDay: boolean, stateCode?: string): boolean;
|
|
763
|
-
|
|
764
|
-
declare function generateIcal(holidays: readonly Holiday[], schoolHolidays: readonly SchoolHoliday[], calendarName: string): string;
|
|
765
|
-
|
|
766
|
-
/**
|
|
767
|
-
* Basic Hijri date utilities.
|
|
768
|
-
*
|
|
769
|
-
* Note: Hijri dates for Islamic holidays are approximate until confirmed
|
|
770
|
-
* by JAKIM rukyah (moon sighting). This module provides reference mapping
|
|
771
|
-
* only — actual dates should come from the gazette/JAKIM confirmation.
|
|
772
|
-
*/
|
|
773
|
-
interface HijriMonth {
|
|
774
|
-
readonly number: number;
|
|
775
|
-
readonly nameMs: string;
|
|
776
|
-
readonly nameEn: string;
|
|
777
|
-
readonly nameAr: string;
|
|
778
|
-
}
|
|
779
|
-
declare const HIJRI_MONTHS: readonly HijriMonth[];
|
|
780
|
-
/**
|
|
781
|
-
* Parse a hijri date string like "1 Syawal 1447" → { day, month, year }
|
|
782
|
-
*/
|
|
783
|
-
declare function parseHijriDate(hijriStr: string): {
|
|
784
|
-
day: number;
|
|
785
|
-
month: HijriMonth;
|
|
786
|
-
year: number;
|
|
787
|
-
} | null;
|
|
788
|
-
/**
|
|
789
|
-
* Format a hijri date for display: "1 Syawal 1447"
|
|
790
|
-
*/
|
|
791
|
-
declare function formatHijriDate(day: number, monthNumber: number, year: number): string;
|
|
792
|
-
/**
|
|
793
|
-
* Key Islamic holidays and their Hijri dates (fixed in the Islamic calendar).
|
|
794
|
-
* Gregorian dates shift ~11 days earlier each year.
|
|
795
|
-
*/
|
|
796
|
-
declare const ISLAMIC_HOLIDAY_DATES: readonly {
|
|
797
|
-
readonly nameMs: string;
|
|
798
|
-
readonly nameEn: string;
|
|
799
|
-
readonly hijriMonth: number;
|
|
800
|
-
readonly hijriDay: number;
|
|
801
|
-
}[];
|
|
802
|
-
|
|
803
|
-
export { type BusinessDaysResult, type ChangelogEntry, type CheckDateResult, type Exam, type ExamSource, type ExamType, type GazetteLevel, HIJRI_MONTHS, type HijriMonth, type Holiday, type HolidayFilter, type HolidaySource, type HolidayStatus, type HolidayType, ISLAMIC_HOLIDAY_DATES, type LocalizedString, type LongWeekend, type SchoolHoliday, type SchoolHolidayType, type SchoolTerm, type SchoolTermSegment, type State, type StateGroup, type StateType, type WeekendConfig, addBusinessDays, addDays, calculateReplacementHolidays, countBusinessDays, diffDays, examSchema, examsFileSchema, filterHolidays, findHolidaysByDate, findNextHoliday, findSchoolHolidayByDate, findSchoolTermByDate, formatHijriDate, generateIcal, getDayOfWeekName, getStateByCode, getStatesByGroup, getWeekendConfig, getWeekendDayNames, holidayFileSchema, holidaySchema, isSchoolDay, isWeekend, nextWorkingDay, parseHijriDate, resolveStateCode, schoolHolidaySchema, schoolHolidaysFileSchema, schoolTermSchema, schoolTermsFileSchema, stateSchema, statesFileSchema };
|
|
1
|
+
export type { LocalizedString, Holiday, HolidayType, HolidayCategory, HolidayStatus, HolidaySource, GazetteLevel, State, StateGroup, StateType, WeekendConfig, SchoolTerm, SchoolTermSegment, SchoolHoliday, SchoolHolidayType, Exam, ExamType, ExamSource, CheckDateResult, BusinessDaysResult, LongWeekend, LeaveSuggestion, ChangelogEntry, } from "./types.js";
|
|
2
|
+
export { holidaySchema, holidayCategorySchema, holidayFileSchema, stateSchema, statesFileSchema, schoolTermSchema, schoolTermsFileSchema, schoolHolidaySchema, schoolHolidaysFileSchema, examSchema, examsFileSchema, } from "./schemas.js";
|
|
3
|
+
export { resolveStateCode, getStateByCode, getStatesByGroup, } from "./state-resolver.js";
|
|
4
|
+
export { getWeekendConfig, isWeekend, getDayOfWeekName, getWeekendDayNames, addDays, nextWorkingDay, diffDays, } from "./weekend.js";
|
|
5
|
+
export { filterHolidays, findHolidaysByDate, findNextHoliday, groupHolidaysByDate, } from "./filter.js";
|
|
6
|
+
export type { HolidayFilter } from "./filter.js";
|
|
7
|
+
export { calculateReplacementHolidays } from "./replacement.js";
|
|
8
|
+
export { countBusinessDays, addBusinessDays, subtractBusinessDays, isBusinessDay, nextBusinessDay, previousBusinessDay, } from "./business-days.js";
|
|
9
|
+
export { findLongWeekends, optimizeLeave } from "./long-weekend.js";
|
|
10
|
+
export { isValidISODate, timingSafeEqualString, isSafePublicHttpsUrl, } from "./validation.js";
|
|
11
|
+
export { findSchoolTermByDate, findSchoolHolidayByDate, filterSchoolHolidays, isSchoolDay, } from "./school.js";
|
|
12
|
+
export { generateIcal } from "./ical.js";
|
|
13
|
+
export { HIJRI_MONTHS, ISLAMIC_HOLIDAY_DATES, parseHijriDate, formatHijriDate, } from "./hijri.js";
|
|
14
|
+
export type { HijriMonth } from "./hijri.js";
|