@glatam/calendar-core 1.0.0 → 1.0.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.
Files changed (2) hide show
  1. package/README.md +45 -0
  2. package/package.json +16 -1
package/README.md ADDED
@@ -0,0 +1,45 @@
1
+ # ⚙️ Core Logic Engine: @glatam/calendar-core
2
+
3
+ This is the pure logical calculation engine for the `@glatam/calendar` suite. It is responsible for availability evaluations, timezone translations, and slot collision algorithms. It contains no DOM/UI dependencies and is completely platform-agnostic.
4
+
5
+ ---
6
+
7
+ ## 🛠️ Architecture: Strategy Pattern
8
+
9
+ The core scheduler utilizes a **Strategy Pattern** to evaluate availability rules:
10
+
11
+ 1. **Weekly Strategy (`WeeklyStrategy`)**: Handles recurring availability or blockages on specific days of the week (e.g., "Every Monday from 2:00 PM to 4:00 PM").
12
+ 2. **Date Range Strategy (`DateRangeStrategy`)**: Handles specific date-bound blockages or tasks (e.g., "Out of office from 2026-07-25 to 2026-07-28").
13
+ 3. **Strategy Factory (`StrategyFactory`)**: Automatically instantiates the correct parser based on the rule payload type.
14
+
15
+ ---
16
+
17
+ ## 🌎 Timezone Math & DST Safety
18
+
19
+ The engine handles cross-timezone bookings using the browser's native `Intl` API:
20
+
21
+ - Converts operating slots to UTC timestamps using the host's base timezone.
22
+ - Evaluates collisions and blocks on absolute timestamps.
23
+ - Translates UTC timestamps back into the buyer's local time dynamically at runtime, accounting for Daylight Saving Time (DST) changes.
24
+
25
+ ---
26
+
27
+ ## 📦 Usage Example (Pure Logic)
28
+
29
+ ```typescript
30
+ import { evaluateAvailability } from '@glatam/calendar-core';
31
+
32
+ const slots = [
33
+ { start: '09:00', end: '10:00' },
34
+ { start: '10:00', end: '11:00' }
35
+ ];
36
+
37
+ const rules = [
38
+ { id: '1', type: 'weekly', daysOfWeek: [0, 6], description: 'Closed Weekends' }
39
+ ];
40
+
41
+ // Evaluate availability for a specific date
42
+ const availability = evaluateAvailability(new Date('2026-07-20'), slots, rules);
43
+ console.log(availability);
44
+ // Returns slots mapped with their availability status (blocked: false/true)
45
+ ```
package/package.json CHANGED
@@ -1,12 +1,27 @@
1
1
  {
2
2
  "name": "@glatam/calendar-core",
3
- "version": "1.0.0",
3
+ "version": "1.0.1",
4
4
  "description": "Lógica pura del calendario @glatam/calendar",
5
5
  "type": "module",
6
6
  "author": "Santiago Hernández Saldarriaga",
7
7
  "license": "MIT",
8
8
  "main": "./dist/index.js",
9
9
  "types": "./dist/index.d.ts",
10
+ "repository": {
11
+ "type": "git",
12
+ "url": "git+https://github.com/santiagoshs/glatam-calendar.git"
13
+ },
14
+ "bugs": {
15
+ "url": "https://github.com/santiagoshs/glatam-calendar/issues"
16
+ },
17
+ "homepage": "https://github.com/santiagoshs/glatam-calendar#readme",
18
+ "keywords": [
19
+ "calendar-core",
20
+ "booking-logic",
21
+ "availability-calculation",
22
+ "timezone-engine",
23
+ "scheduler-logic"
24
+ ],
10
25
  "scripts": {
11
26
  "build": "tsc",
12
27
  "test": "vitest run"