@tempo-kit/plugin-holidays 0.0.0-stage → 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +49 -0
- package/LICENSE +21 -0
- package/README.md +93 -2
- package/dist/cache.d.ts +24 -0
- package/dist/calendars/au.d.ts +2 -0
- package/dist/calendars/ca.d.ts +2 -0
- package/dist/calendars/de.d.ts +2 -0
- package/dist/calendars/fr.d.ts +2 -0
- package/dist/calendars/gb.d.ts +2 -0
- package/dist/calendars/jp.d.ts +2 -0
- package/dist/calendars/nz.d.ts +2 -0
- package/dist/calendars/us.d.ts +2 -0
- package/dist/computus.d.ts +64 -0
- package/dist/engine.d.ts +105 -0
- package/dist/index.d.ts +116 -0
- package/dist/index.global.min.js +1 -0
- package/dist/index.js +1058 -0
- package/dist/install.d.ts +2 -0
- package/dist/install.global.min.js +1 -0
- package/dist/install.js +1061 -0
- package/dist/preload.d.ts +12 -0
- package/dist/registry.d.ts +31 -0
- package/dist/types.d.ts +45 -0
- package/package.json +64 -4
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { HolidayItem, HolidayOptions } from './types.js';
|
|
2
|
+
/**
|
|
3
|
+
* Preloads and caches holiday data for a specified year and country.
|
|
4
|
+
* - Built-in countries evaluate synchronously and populate storage cache.
|
|
5
|
+
* - Long-tail countries (100+ supported via tempo-fns / Nager.Date API) are fetched asynchronously,
|
|
6
|
+
* stored with a 24-hour TTL, and registered in the synchronous holiday evaluation registry.
|
|
7
|
+
*
|
|
8
|
+
* @param year - 4-digit calendar year
|
|
9
|
+
* @param countryOrOptions - Country code string or HolidayOptions
|
|
10
|
+
* @returns Promise resolving to the holiday items array
|
|
11
|
+
*/
|
|
12
|
+
export declare function preloadHolidayCalendar(year: number, countryOrOptions?: string | HolidayOptions): Promise<HolidayItem[]>;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import type { HolidayItem, HolidayOptions } from './types.js';
|
|
2
|
+
/**
|
|
3
|
+
* Checks whether a given country code has an offline built-in calendar generator.
|
|
4
|
+
*
|
|
5
|
+
* @param countryCode - Raw country code
|
|
6
|
+
* @returns True if country is built-in
|
|
7
|
+
*/
|
|
8
|
+
export declare function hasBuiltinCalendar(countryCode?: string): boolean;
|
|
9
|
+
/**
|
|
10
|
+
* Registers dynamic or preloaded holiday items in memory for synchronous access.
|
|
11
|
+
*
|
|
12
|
+
* @param year - 4-digit calendar year
|
|
13
|
+
* @param countryCode - Country code
|
|
14
|
+
* @param items - Array of holiday items
|
|
15
|
+
*/
|
|
16
|
+
export declare function registerHolidayItems(year: number, countryCode: string, items: HolidayItem[]): void;
|
|
17
|
+
/**
|
|
18
|
+
* Resolves a normalized ISO 3166-1 alpha-2 country code.
|
|
19
|
+
*
|
|
20
|
+
* @param countryCode - Raw country or region input
|
|
21
|
+
* @returns 2-letter uppercase country code, or 'US' default
|
|
22
|
+
*/
|
|
23
|
+
export declare function normalizeCountryCode(countryCode?: string): string;
|
|
24
|
+
/**
|
|
25
|
+
* Synchronously retrieves or generates the holiday calendar for a year and country.
|
|
26
|
+
*
|
|
27
|
+
* @param year - 4-digit calendar year
|
|
28
|
+
* @param options - Holiday configuration options
|
|
29
|
+
* @returns Array of holiday items
|
|
30
|
+
*/
|
|
31
|
+
export declare function getCalendarHolidays(year: number, options?: HolidayOptions): HolidayItem[];
|
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Represents an individual public or bank holiday item.
|
|
3
|
+
*/
|
|
4
|
+
export interface HolidayItem {
|
|
5
|
+
/** ISO date string of the holiday in YYYY-MM-DD format */
|
|
6
|
+
readonly date: string;
|
|
7
|
+
/** Standard human-readable name of the holiday */
|
|
8
|
+
readonly name: string;
|
|
9
|
+
/** Native or regional language name of the holiday (optional) */
|
|
10
|
+
readonly localName?: string | undefined;
|
|
11
|
+
/** ISO 3166-1 alpha-2 country code (e.g., 'US', 'AU', 'GB') */
|
|
12
|
+
readonly country: string;
|
|
13
|
+
/** Optional subdivision / state / province code (e.g., 'NSW', 'CA', 'ON') */
|
|
14
|
+
readonly region?: string | undefined;
|
|
15
|
+
/** True if this is an observed holiday date shifted from a weekend */
|
|
16
|
+
readonly isObserved?: boolean | undefined;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Configuration options for evaluating public holidays and business days.
|
|
20
|
+
*/
|
|
21
|
+
export interface HolidayOptions {
|
|
22
|
+
/** ISO 3166-1 alpha-2 country code (e.g. 'US', 'AU', 'GB') */
|
|
23
|
+
country?: string | undefined;
|
|
24
|
+
/** State, province, or subdivision code (e.g. 'AU-NSW', 'US-NY', 'NSW', 'NY') */
|
|
25
|
+
region?: string | undefined;
|
|
26
|
+
/** Additional custom holiday dates (YYYY-MM-DD strings) to treat as non-working days */
|
|
27
|
+
customHolidays?: string[] | undefined;
|
|
28
|
+
/** Whether to include shifted weekend-observed dates (default: true) */
|
|
29
|
+
includeObserved?: boolean | undefined;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Configuration options for calculating working business hours.
|
|
33
|
+
*/
|
|
34
|
+
export interface WorkingHoursOptions extends HolidayOptions {
|
|
35
|
+
/** Start hour for the working day (0-23, default: 9) */
|
|
36
|
+
startHour?: number | undefined;
|
|
37
|
+
/** End hour for the working day (0-23, default: 17) */
|
|
38
|
+
endHour?: number | undefined;
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Signature for a synchronous country-specific holiday generator function.
|
|
42
|
+
*
|
|
43
|
+
* @internal
|
|
44
|
+
*/
|
|
45
|
+
export type HolidayCalendarGenerator = (year: number, region?: string, includeObserved?: boolean) => HolidayItem[];
|
package/package.json
CHANGED
|
@@ -1,6 +1,66 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tempo-kit/plugin-holidays",
|
|
3
|
-
"version": "
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
3
|
+
"version": "2.0.0",
|
|
4
|
+
"description": "Regional bank holiday, public holiday, and business day SLA scheduling plugin for Tempo",
|
|
5
|
+
"main": "dist/index.js",
|
|
6
|
+
"types": "dist/index.d.ts",
|
|
7
|
+
"sideEffects": [
|
|
8
|
+
"./dist/install.js"
|
|
9
|
+
],
|
|
10
|
+
"license": "MIT",
|
|
11
|
+
"repository": {
|
|
12
|
+
"type": "git",
|
|
13
|
+
"url": "git+https://github.com/magmacomputing/magma.git",
|
|
14
|
+
"directory": "packages/plugins/holidays"
|
|
15
|
+
},
|
|
16
|
+
"files": [
|
|
17
|
+
"dist",
|
|
18
|
+
"README.md",
|
|
19
|
+
"CHANGELOG.md",
|
|
20
|
+
"LICENSE"
|
|
21
|
+
],
|
|
22
|
+
"publishConfig": {
|
|
23
|
+
"registry": "https://registry.npmjs.org/",
|
|
24
|
+
"access": "public"
|
|
25
|
+
},
|
|
26
|
+
"scripts": {
|
|
27
|
+
"build": "tsup && tsc",
|
|
28
|
+
"test": "vitest run -c ../vitest.shared.ts",
|
|
29
|
+
"prepublishOnly": "tempo-cli prepublish"
|
|
30
|
+
},
|
|
31
|
+
"peerDependencies": {
|
|
32
|
+
"tempo-kit": "^5.0.0"
|
|
33
|
+
},
|
|
34
|
+
"devDependencies": {
|
|
35
|
+
"tempo-kit": "^5.0.0",
|
|
36
|
+
"tempo-fns": "^1.0.0"
|
|
37
|
+
},
|
|
38
|
+
"keywords": [
|
|
39
|
+
"tempo-kit",
|
|
40
|
+
"tempo-kit-plugin",
|
|
41
|
+
"tempo",
|
|
42
|
+
"temporal",
|
|
43
|
+
"tempo-plugin",
|
|
44
|
+
"plugin",
|
|
45
|
+
"holidays",
|
|
46
|
+
"bank-holidays",
|
|
47
|
+
"public-holidays",
|
|
48
|
+
"business-days",
|
|
49
|
+
"calendar",
|
|
50
|
+
"sla",
|
|
51
|
+
"typescript"
|
|
52
|
+
],
|
|
53
|
+
"type": "module",
|
|
54
|
+
"exports": {
|
|
55
|
+
".": {
|
|
56
|
+
"types": "./dist/index.d.ts",
|
|
57
|
+
"import": "./dist/index.js",
|
|
58
|
+
"default": "./dist/index.js"
|
|
59
|
+
},
|
|
60
|
+
"./install": {
|
|
61
|
+
"types": "./dist/index.d.ts",
|
|
62
|
+
"import": "./dist/install.js",
|
|
63
|
+
"default": "./dist/install.js"
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
}
|