@microboxlabs/miot-calendar-client 0.3.0 → 0.4.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/README.md CHANGED
@@ -314,6 +314,113 @@ Manually change a slot's status.
314
314
 
315
315
  ---
316
316
 
317
+ ### Slot Managers
318
+
319
+ Slot managers automate slot generation for calendars. Each manager keeps slots generated a configurable number of days in advance and can be triggered manually or by an external scheduler (e.g. K8s CronJob).
320
+
321
+ #### `slotManagers.list(params?)`
322
+
323
+ List all slot managers, optionally filtered by active status.
324
+
325
+ | Param | Type | Required | Description |
326
+ |-------|------|----------|-------------|
327
+ | `active` | `boolean` | No | When `true`, return only active managers |
328
+
329
+ **Returns:** `SlotManagerResponse[]`
330
+
331
+ #### `slotManagers.create(body)`
332
+
333
+ Create an automatic slot generation manager for a calendar.
334
+
335
+ | Field | Type | Required | Default | Description |
336
+ |-------|------|----------|---------|-------------|
337
+ | `calendarId` | `string` | Yes | — | Calendar ID to manage |
338
+ | `active` | `boolean` | No | `true` | Enable or disable automatic generation |
339
+ | `daysInAdvance` | `number` | No | `30` | Days ahead to keep slots generated |
340
+ | `batchDays` | `number` | No | `7` | Max days to generate per scheduler run |
341
+ | `reprocessFrom` | `string` | No | — | Force regeneration from this date (`YYYY-MM-DD`) |
342
+ | `reprocessTo` | `string` | No | — | Force regeneration through this date (required with `reprocessFrom`) |
343
+
344
+ **Returns:** `SlotManagerResponse`
345
+
346
+ **Throws:** `MiotCalendarApiError` with status `400` if invalid or duplicate.
347
+
348
+ #### `slotManagers.get(id)`
349
+
350
+ Get a slot manager by ID.
351
+
352
+ | Param | Type | Required | Description |
353
+ |-------|------|----------|-------------|
354
+ | `id` | `string` | Yes | Slot manager ID |
355
+
356
+ **Returns:** `SlotManagerResponse`
357
+
358
+ **Throws:** `MiotCalendarApiError` with status `404` if not found.
359
+
360
+ #### `slotManagers.update(id, body)`
361
+
362
+ Update a slot manager's configuration. Takes the same body as `create`. Set `reprocessFrom` + `reprocessTo` to schedule one-shot slot regeneration.
363
+
364
+ | Param | Type | Required | Description |
365
+ |-------|------|----------|-------------|
366
+ | `id` | `string` | Yes | Slot manager ID |
367
+ | `body` | `SlotManagerRequest` | Yes | Updated configuration |
368
+
369
+ **Returns:** `SlotManagerResponse`
370
+
371
+ #### `slotManagers.deactivate(id)`
372
+
373
+ Deactivate a slot manager (soft delete — disables automatic generation without removing history).
374
+
375
+ | Param | Type | Required | Description |
376
+ |-------|------|----------|-------------|
377
+ | `id` | `string` | Yes | Slot manager ID |
378
+
379
+ **Returns:** `void` (HTTP 204 — no content)
380
+
381
+ #### `slotManagers.runAll()`
382
+
383
+ Synchronously run all active slot managers. Returns when all managers have completed.
384
+
385
+ **Returns:** `SlotManagerRunResponse[]`
386
+
387
+ #### `slotManagers.run(id)`
388
+
389
+ Synchronously run a single slot manager and return its run record.
390
+
391
+ | Param | Type | Required | Description |
392
+ |-------|------|----------|-------------|
393
+ | `id` | `string` | Yes | Slot manager ID |
394
+
395
+ **Returns:** `SlotManagerRunResponse`
396
+
397
+ **Throws:** `MiotCalendarApiError` with status `404` if not found.
398
+
399
+ #### `slotManagers.listAllRuns(params?)`
400
+
401
+ List recent runs across all managers.
402
+
403
+ | Param | Type | Required | Default | Description |
404
+ |-------|------|----------|---------|-------------|
405
+ | `limit` | `number` | No | `50` | Maximum number of records to return |
406
+
407
+ **Returns:** `SlotManagerRunResponse[]`
408
+
409
+ #### `slotManagers.listRuns(id, params?)`
410
+
411
+ List runs for a specific manager.
412
+
413
+ | Param | Type | Required | Default | Description |
414
+ |-------|------|----------|---------|-------------|
415
+ | `id` | `string` | Yes | — | Slot manager ID |
416
+ | `limit` | `number` | No | `20` | Maximum number of records to return |
417
+
418
+ **Returns:** `SlotManagerRunResponse[]`
419
+
420
+ **Throws:** `MiotCalendarApiError` with status `404` if manager not found.
421
+
422
+ ---
423
+
317
424
  ### Bookings
318
425
 
319
426
  #### `bookings.list(params?)`
@@ -533,6 +640,59 @@ interface UpdateSlotStatusRequest {
533
640
  }
534
641
  ```
535
642
 
643
+ ### `SlotManagerRequest`
644
+
645
+ ```ts
646
+ interface SlotManagerRequest {
647
+ calendarId: string; // Calendar ID to manage
648
+ active?: boolean; // Enable/disable (default: true)
649
+ daysInAdvance?: number; // Days ahead to keep generated (default: 30)
650
+ batchDays?: number; // Max days per scheduler run (default: 7)
651
+ reprocessFrom?: string; // YYYY-MM-DD — one-shot regeneration start
652
+ reprocessTo?: string; // YYYY-MM-DD — one-shot regeneration end
653
+ }
654
+ ```
655
+
656
+ ### `SlotManagerResponse`
657
+
658
+ ```ts
659
+ interface SlotManagerResponse {
660
+ id: string;
661
+ calendarId: string;
662
+ calendarCode: string;
663
+ calendarName: string;
664
+ active: boolean;
665
+ daysInAdvance: number;
666
+ batchDays: number;
667
+ reprocessFrom?: string; // Cleared after successful run
668
+ reprocessTo?: string; // Cleared after successful run
669
+ lastRunAt?: string; // ISO 8601
670
+ lastRunStatus?: string; // IDLE, RUNNING, SUCCESS, FAILED, SKIPPED
671
+ lastRunError?: string; // Error message from last failed run
672
+ generatedThrough?: string; // YYYY-MM-DD — latest date with generated slots
673
+ createdAt: string; // ISO 8601
674
+ updatedAt: string; // ISO 8601
675
+ }
676
+ ```
677
+
678
+ ### `SlotManagerRunResponse`
679
+
680
+ ```ts
681
+ interface SlotManagerRunResponse {
682
+ id: string;
683
+ managerId: string;
684
+ triggeredBy: string; // SCHEDULER, API, CLI
685
+ startedAt: string; // ISO 8601
686
+ finishedAt?: string; // ISO 8601
687
+ status: string; // RUNNING, SUCCESS, FAILED, SKIPPED
688
+ slotsCreated: number;
689
+ slotsSkipped: number;
690
+ generatedFrom?: string; // YYYY-MM-DD
691
+ generatedThrough?: string; // YYYY-MM-DD
692
+ errorMessage?: string;
693
+ }
694
+ ```
695
+
536
696
  ### `BookingRequest`
537
697
 
538
698
  ```ts
package/dist/index.cjs CHANGED
@@ -79,6 +79,9 @@ function createCalendarsApi(fetcher) {
79
79
  deactivate(id) {
80
80
  return fetcher("DELETE", `${BASE2}/${id}`);
81
81
  },
82
+ purge(id) {
83
+ return fetcher("DELETE", `${BASE2}/${id}/purge`);
84
+ },
82
85
  listTimeWindows(calendarId) {
83
86
  return fetcher("GET", `${BASE2}/${calendarId}/time-windows`);
84
87
  },
package/dist/index.d.mts CHANGED
@@ -49,6 +49,7 @@ interface CalendarRequest {
49
49
  timezone?: string;
50
50
  active?: boolean;
51
51
  groups?: string[];
52
+ autoSlotManager?: boolean;
52
53
  }
53
54
  interface CalendarResponse {
54
55
  id: string;
@@ -60,6 +61,7 @@ interface CalendarResponse {
60
61
  createdAt: string;
61
62
  updatedAt: string;
62
63
  groups?: CalendarGroupResponse[];
64
+ hasSlotManager?: boolean;
63
65
  }
64
66
  interface TimeWindowRequest {
65
67
  name: string;
@@ -191,6 +193,7 @@ declare function createMiotCalendarClient(config: ClientConfig): {
191
193
  create(body: CalendarRequest): Promise<CalendarResponse>;
192
194
  update(id: string, body: CalendarRequest): Promise<CalendarResponse>;
193
195
  deactivate(id: string): Promise<void>;
196
+ purge(id: string): Promise<void>;
194
197
  listTimeWindows(calendarId: string): Promise<TimeWindowResponse[]>;
195
198
  createTimeWindow(calendarId: string, body: TimeWindowRequest): Promise<TimeWindowResponse>;
196
199
  updateTimeWindow(calendarId: string, timeWindowId: string, body: TimeWindowRequest): Promise<TimeWindowResponse>;
package/dist/index.d.ts CHANGED
@@ -49,6 +49,7 @@ interface CalendarRequest {
49
49
  timezone?: string;
50
50
  active?: boolean;
51
51
  groups?: string[];
52
+ autoSlotManager?: boolean;
52
53
  }
53
54
  interface CalendarResponse {
54
55
  id: string;
@@ -60,6 +61,7 @@ interface CalendarResponse {
60
61
  createdAt: string;
61
62
  updatedAt: string;
62
63
  groups?: CalendarGroupResponse[];
64
+ hasSlotManager?: boolean;
63
65
  }
64
66
  interface TimeWindowRequest {
65
67
  name: string;
@@ -191,6 +193,7 @@ declare function createMiotCalendarClient(config: ClientConfig): {
191
193
  create(body: CalendarRequest): Promise<CalendarResponse>;
192
194
  update(id: string, body: CalendarRequest): Promise<CalendarResponse>;
193
195
  deactivate(id: string): Promise<void>;
196
+ purge(id: string): Promise<void>;
194
197
  listTimeWindows(calendarId: string): Promise<TimeWindowResponse[]>;
195
198
  createTimeWindow(calendarId: string, body: TimeWindowRequest): Promise<TimeWindowResponse>;
196
199
  updateTimeWindow(calendarId: string, timeWindowId: string, body: TimeWindowRequest): Promise<TimeWindowResponse>;
package/dist/index.mjs CHANGED
@@ -52,6 +52,9 @@ function createCalendarsApi(fetcher) {
52
52
  deactivate(id) {
53
53
  return fetcher("DELETE", `${BASE2}/${id}`);
54
54
  },
55
+ purge(id) {
56
+ return fetcher("DELETE", `${BASE2}/${id}/purge`);
57
+ },
55
58
  listTimeWindows(calendarId) {
56
59
  return fetcher("GET", `${BASE2}/${calendarId}/time-windows`);
57
60
  },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@microboxlabs/miot-calendar-client",
3
- "version": "0.3.0",
3
+ "version": "0.4.0",
4
4
  "license": "Apache-2.0",
5
5
  "repository": {
6
6
  "type": "git",