@catlabtech/mycal-core 0.1.0 → 0.1.1
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/README.md +53 -0
- package/package.json +2 -2
package/README.md
ADDED
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
# @catlabtech/mycal-core
|
|
2
|
+
|
|
3
|
+
Shared types, Zod schemas, and business logic for the **Malaysia Calendar API**. This is the underlying library used by [`@catlabtech/mycal-sdk`](https://www.npmjs.com/package/@catlabtech/mycal-sdk) and [`@catlabtech/mycal-mcp-server`](https://www.npmjs.com/package/@catlabtech/mycal-mcp-server).
|
|
4
|
+
|
|
5
|
+
> Most users should install the SDK or MCP server instead. Use `@catlabtech/mycal-core` directly only if you need the raw types, schemas, or pure business logic (e.g. for server-side implementations or custom runtimes).
|
|
6
|
+
|
|
7
|
+
## What's inside
|
|
8
|
+
|
|
9
|
+
- **TypeScript types** — `Holiday`, `State`, `SchoolTerm`, `SchoolHoliday`, `Exam`, `CheckDateResult`, `BusinessDaysResult`, `LongWeekend`, etc.
|
|
10
|
+
- **Zod schemas** — runtime validation matching the types exactly
|
|
11
|
+
- **State resolver** — alias → canonical state code (e.g. `kl` → `kuala-lumpur`)
|
|
12
|
+
- **Weekend logic** — per-state weekend history including Johor's 2014–2024 Fri–Sat switch
|
|
13
|
+
- **Business day calculations** — state-aware, holiday-aware
|
|
14
|
+
- **Cuti ganti generator** — replacement holiday logic per state rules
|
|
15
|
+
- **iCal generator** — RFC 5545 output with auto-refresh hints
|
|
16
|
+
- **School calendar logic** — term / holiday lookups for Kumpulan A and B
|
|
17
|
+
|
|
18
|
+
## Install
|
|
19
|
+
|
|
20
|
+
```bash
|
|
21
|
+
npm install @catlabtech/mycal-core
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
Node 18+. ESM only.
|
|
25
|
+
|
|
26
|
+
## Example
|
|
27
|
+
|
|
28
|
+
```ts
|
|
29
|
+
import {
|
|
30
|
+
resolveStateCode,
|
|
31
|
+
countBusinessDays,
|
|
32
|
+
isWeekend,
|
|
33
|
+
type Holiday,
|
|
34
|
+
type State,
|
|
35
|
+
} from "@catlabtech/mycal-core";
|
|
36
|
+
|
|
37
|
+
// Alias resolution
|
|
38
|
+
const { canonical } = resolveStateCode("kl", allStates); // "kuala-lumpur"
|
|
39
|
+
|
|
40
|
+
// Type-safe filtering
|
|
41
|
+
const federal = holidays.filter((h): h is Holiday => h.type === "federal");
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
## Documentation
|
|
45
|
+
|
|
46
|
+
- **Full docs:** [https://mycal-web.pages.dev/docs](https://mycal-web.pages.dev/docs)
|
|
47
|
+
- **Type reference:** [https://mycal-web.pages.dev/docs/sdk/reference](https://mycal-web.pages.dev/docs/sdk/reference)
|
|
48
|
+
|
|
49
|
+
## License
|
|
50
|
+
|
|
51
|
+
MIT — © catlab.tech
|
|
52
|
+
|
|
53
|
+
Issues and contributions: [github.com/Junhui20/malaysia-calendar-api](https://github.com/Junhui20/malaysia-calendar-api)
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@catlabtech/mycal-core",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.1",
|
|
4
4
|
"description": "Core types, schemas, and business logic for the Malaysia Calendar API",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"malaysia",
|
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
"url": "git+https://github.com/Junhui20/malaysia-calendar-api.git",
|
|
16
16
|
"directory": "packages/core"
|
|
17
17
|
},
|
|
18
|
-
"homepage": "https://mycal.pages.dev",
|
|
18
|
+
"homepage": "https://mycal-web.pages.dev",
|
|
19
19
|
"bugs": "https://github.com/Junhui20/malaysia-calendar-api/issues",
|
|
20
20
|
"type": "module",
|
|
21
21
|
"main": "./dist/index.js",
|