@microboxlabs/miot-calendar-client 0.1.3 → 0.2.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 +99 -6
- package/dist/index.d.ts +28 -1
- package/dist/index.js +28 -5
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -89,11 +89,12 @@ const client = createMiotCalendarClient({
|
|
|
89
89
|
|
|
90
90
|
#### `calendars.list(params?)`
|
|
91
91
|
|
|
92
|
-
List all calendars, optionally filtered by active status.
|
|
92
|
+
List all calendars, optionally filtered by active status or group membership.
|
|
93
93
|
|
|
94
94
|
| Param | Type | Required | Description |
|
|
95
95
|
|-------|------|----------|-------------|
|
|
96
96
|
| `active` | `boolean` | No | Filter by active status |
|
|
97
|
+
| `groupCode` | `string` | No | Filter calendars belonging to this group code |
|
|
97
98
|
|
|
98
99
|
**Returns:** `CalendarResponse[]`
|
|
99
100
|
|
|
@@ -120,6 +121,7 @@ Create a new calendar.
|
|
|
120
121
|
| `description` | `string` | No | — | Optional description |
|
|
121
122
|
| `timezone` | `string` | No | `"UTC"` | IANA timezone |
|
|
122
123
|
| `active` | `boolean` | No | `true` | Whether the calendar is active |
|
|
124
|
+
| `groups` | `string[]` | No | — | Group codes to assign. `null` = no change; `[]` = remove all; `["code"]` = replace all |
|
|
123
125
|
|
|
124
126
|
**Returns:** `CalendarResponse`
|
|
125
127
|
|
|
@@ -130,7 +132,7 @@ Replace a calendar's fields. Takes the same body as `create`.
|
|
|
130
132
|
| Param | Type | Required | Description |
|
|
131
133
|
|-------|------|----------|-------------|
|
|
132
134
|
| `id` | `string` | Yes | Calendar ID |
|
|
133
|
-
| `body` | `CalendarRequest` | Yes | Updated calendar data |
|
|
135
|
+
| `body` | `CalendarRequest` | Yes | Updated calendar data (include `groups` to reassign group membership) |
|
|
134
136
|
|
|
135
137
|
**Returns:** `CalendarResponse`
|
|
136
138
|
|
|
@@ -192,6 +194,70 @@ Update a time window. Takes the same body as `createTimeWindow`.
|
|
|
192
194
|
|
|
193
195
|
---
|
|
194
196
|
|
|
197
|
+
### Groups
|
|
198
|
+
|
|
199
|
+
Calendar groups let you organize calendars into named collections. Calendars can belong to multiple groups; use `CalendarRequest.groups` on create or update to manage membership.
|
|
200
|
+
|
|
201
|
+
#### `groups.list(params?)`
|
|
202
|
+
|
|
203
|
+
List all calendar groups, optionally filtered by active status.
|
|
204
|
+
|
|
205
|
+
| Param | Type | Required | Description |
|
|
206
|
+
|-------|------|----------|-------------|
|
|
207
|
+
| `active` | `boolean` | No | Filter by active status |
|
|
208
|
+
|
|
209
|
+
**Returns:** `CalendarGroupResponse[]`
|
|
210
|
+
|
|
211
|
+
#### `groups.get(id)`
|
|
212
|
+
|
|
213
|
+
Get a single calendar group by ID.
|
|
214
|
+
|
|
215
|
+
| Param | Type | Required | Description |
|
|
216
|
+
|-------|------|----------|-------------|
|
|
217
|
+
| `id` | `string` | Yes | Group ID |
|
|
218
|
+
|
|
219
|
+
**Returns:** `CalendarGroupResponse`
|
|
220
|
+
|
|
221
|
+
**Throws:** `MiotCalendarApiError` with status `404` if not found.
|
|
222
|
+
|
|
223
|
+
#### `groups.create(body)`
|
|
224
|
+
|
|
225
|
+
Create a new calendar group.
|
|
226
|
+
|
|
227
|
+
| Field | Type | Required | Default | Description |
|
|
228
|
+
|-------|------|----------|---------|-------------|
|
|
229
|
+
| `code` | `string` | Yes | — | Unique code identifier (max 50 chars) |
|
|
230
|
+
| `name` | `string` | Yes | — | Display name (max 255 chars) |
|
|
231
|
+
| `description` | `string` | No | — | Optional description |
|
|
232
|
+
| `active` | `boolean` | No | `true` | Whether the group is active |
|
|
233
|
+
|
|
234
|
+
**Returns:** `CalendarGroupResponse`
|
|
235
|
+
|
|
236
|
+
**Throws:** `MiotCalendarApiError` with status `400` if the code is already taken.
|
|
237
|
+
|
|
238
|
+
#### `groups.update(id, body)`
|
|
239
|
+
|
|
240
|
+
Replace a calendar group's fields. Takes the same body as `create`.
|
|
241
|
+
|
|
242
|
+
| Param | Type | Required | Description |
|
|
243
|
+
|-------|------|----------|-------------|
|
|
244
|
+
| `id` | `string` | Yes | Group ID |
|
|
245
|
+
| `body` | `CalendarGroupRequest` | Yes | Updated group data |
|
|
246
|
+
|
|
247
|
+
**Returns:** `CalendarGroupResponse`
|
|
248
|
+
|
|
249
|
+
#### `groups.deactivate(id)`
|
|
250
|
+
|
|
251
|
+
Deactivate a calendar group (soft delete). Calendars in the group are not affected.
|
|
252
|
+
|
|
253
|
+
| Param | Type | Required | Description |
|
|
254
|
+
|-------|------|----------|-------------|
|
|
255
|
+
| `id` | `string` | Yes | Group ID |
|
|
256
|
+
|
|
257
|
+
**Returns:** `void` (HTTP 204 — no content)
|
|
258
|
+
|
|
259
|
+
---
|
|
260
|
+
|
|
195
261
|
### Slots
|
|
196
262
|
|
|
197
263
|
#### `slots.list(params)`
|
|
@@ -321,6 +387,31 @@ List all bookings for a specific resource.
|
|
|
321
387
|
|
|
322
388
|
## Types
|
|
323
389
|
|
|
390
|
+
### `CalendarGroupRequest`
|
|
391
|
+
|
|
392
|
+
```ts
|
|
393
|
+
interface CalendarGroupRequest {
|
|
394
|
+
code: string; // Unique code identifier (max 50 chars)
|
|
395
|
+
name: string; // Display name (max 255 chars)
|
|
396
|
+
description?: string; // Optional description
|
|
397
|
+
active?: boolean; // Active status (default: true)
|
|
398
|
+
}
|
|
399
|
+
```
|
|
400
|
+
|
|
401
|
+
### `CalendarGroupResponse`
|
|
402
|
+
|
|
403
|
+
```ts
|
|
404
|
+
interface CalendarGroupResponse {
|
|
405
|
+
id: string;
|
|
406
|
+
code: string;
|
|
407
|
+
name: string;
|
|
408
|
+
description?: string;
|
|
409
|
+
active: boolean;
|
|
410
|
+
createdAt: string; // ISO 8601
|
|
411
|
+
updatedAt: string; // ISO 8601
|
|
412
|
+
}
|
|
413
|
+
```
|
|
414
|
+
|
|
324
415
|
### `CalendarRequest`
|
|
325
416
|
|
|
326
417
|
```ts
|
|
@@ -330,6 +421,7 @@ interface CalendarRequest {
|
|
|
330
421
|
description?: string; // Optional description
|
|
331
422
|
timezone?: string; // IANA timezone (default: "UTC")
|
|
332
423
|
active?: boolean; // Active status (default: true)
|
|
424
|
+
groups?: string[]; // Group codes to assign. null = no change; [] = remove all; ["code"] = replace all
|
|
333
425
|
}
|
|
334
426
|
```
|
|
335
427
|
|
|
@@ -341,10 +433,11 @@ interface CalendarResponse {
|
|
|
341
433
|
code: string;
|
|
342
434
|
name: string;
|
|
343
435
|
description?: string;
|
|
344
|
-
timezone: string;
|
|
345
|
-
active: boolean;
|
|
346
|
-
createdAt: string;
|
|
347
|
-
updatedAt: string;
|
|
436
|
+
timezone: string; // Always present (default: "UTC")
|
|
437
|
+
active: boolean; // Always present (default: true)
|
|
438
|
+
createdAt: string; // ISO 8601
|
|
439
|
+
updatedAt: string; // ISO 8601
|
|
440
|
+
groups?: CalendarGroupResponse[]; // Groups this calendar belongs to
|
|
348
441
|
}
|
|
349
442
|
```
|
|
350
443
|
|
package/dist/index.d.ts
CHANGED
|
@@ -27,12 +27,28 @@ interface BookingListResponse {
|
|
|
27
27
|
data: BookingResponse[];
|
|
28
28
|
total: number;
|
|
29
29
|
}
|
|
30
|
+
interface CalendarGroupRequest {
|
|
31
|
+
code: string;
|
|
32
|
+
name: string;
|
|
33
|
+
description?: string;
|
|
34
|
+
active?: boolean;
|
|
35
|
+
}
|
|
36
|
+
interface CalendarGroupResponse {
|
|
37
|
+
id: string;
|
|
38
|
+
code: string;
|
|
39
|
+
name: string;
|
|
40
|
+
description?: string;
|
|
41
|
+
active: boolean;
|
|
42
|
+
createdAt: string;
|
|
43
|
+
updatedAt: string;
|
|
44
|
+
}
|
|
30
45
|
interface CalendarRequest {
|
|
31
46
|
code: string;
|
|
32
47
|
name: string;
|
|
33
48
|
description?: string;
|
|
34
49
|
timezone?: string;
|
|
35
50
|
active?: boolean;
|
|
51
|
+
groups?: string[];
|
|
36
52
|
}
|
|
37
53
|
interface CalendarResponse {
|
|
38
54
|
id: string;
|
|
@@ -43,6 +59,7 @@ interface CalendarResponse {
|
|
|
43
59
|
active: boolean;
|
|
44
60
|
createdAt: string;
|
|
45
61
|
updatedAt: string;
|
|
62
|
+
groups?: CalendarGroupResponse[];
|
|
46
63
|
}
|
|
47
64
|
interface TimeWindowRequest {
|
|
48
65
|
name: string;
|
|
@@ -130,6 +147,7 @@ declare function createMiotCalendarClient(config: ClientConfig): {
|
|
|
130
147
|
calendars: {
|
|
131
148
|
list(params?: {
|
|
132
149
|
active?: boolean;
|
|
150
|
+
groupCode?: string;
|
|
133
151
|
}): Promise<CalendarResponse[]>;
|
|
134
152
|
get(id: string): Promise<CalendarResponse>;
|
|
135
153
|
create(body: CalendarRequest): Promise<CalendarResponse>;
|
|
@@ -139,6 +157,15 @@ declare function createMiotCalendarClient(config: ClientConfig): {
|
|
|
139
157
|
createTimeWindow(calendarId: string, body: TimeWindowRequest): Promise<TimeWindowResponse>;
|
|
140
158
|
updateTimeWindow(calendarId: string, timeWindowId: string, body: TimeWindowRequest): Promise<TimeWindowResponse>;
|
|
141
159
|
};
|
|
160
|
+
groups: {
|
|
161
|
+
list(params?: {
|
|
162
|
+
active?: boolean;
|
|
163
|
+
}): Promise<CalendarGroupResponse[]>;
|
|
164
|
+
get(id: string): Promise<CalendarGroupResponse>;
|
|
165
|
+
create(body: CalendarGroupRequest): Promise<CalendarGroupResponse>;
|
|
166
|
+
update(id: string, body: CalendarGroupRequest): Promise<CalendarGroupResponse>;
|
|
167
|
+
deactivate(id: string): Promise<void>;
|
|
168
|
+
};
|
|
142
169
|
slots: {
|
|
143
170
|
list(params: {
|
|
144
171
|
calendarId: string;
|
|
@@ -159,4 +186,4 @@ declare class MiotCalendarApiError extends Error {
|
|
|
159
186
|
constructor(status: number, body: ErrorResponse | string);
|
|
160
187
|
}
|
|
161
188
|
|
|
162
|
-
export { type BookingListResponse, type BookingRequest, type BookingResponse, type CalendarRequest, type CalendarResponse, type ClientConfig, type ErrorResponse, type GenerateSlotsRequest, type GenerateSlotsResponse, MiotCalendarApiError, type ResourceData, type SlotData, type SlotListResponse, type SlotResponse, type SlotStatus, type TimeWindowRequest, type TimeWindowResponse, type UpdateSlotStatusRequest, createMiotCalendarClient };
|
|
189
|
+
export { type BookingListResponse, type BookingRequest, type BookingResponse, type CalendarGroupRequest, type CalendarGroupResponse, type CalendarRequest, type CalendarResponse, type ClientConfig, type ErrorResponse, type GenerateSlotsRequest, type GenerateSlotsResponse, MiotCalendarApiError, type ResourceData, type SlotData, type SlotListResponse, type SlotResponse, type SlotStatus, type TimeWindowRequest, type TimeWindowResponse, type UpdateSlotStatusRequest, createMiotCalendarClient };
|
package/dist/index.js
CHANGED
|
@@ -66,9 +66,9 @@ function createCalendarsApi(fetcher) {
|
|
|
66
66
|
};
|
|
67
67
|
}
|
|
68
68
|
|
|
69
|
-
// src/resources/
|
|
70
|
-
var BASE3 = "/api/v1/miot-calendar/
|
|
71
|
-
function
|
|
69
|
+
// src/resources/groups.ts
|
|
70
|
+
var BASE3 = "/api/v1/miot-calendar/groups";
|
|
71
|
+
function createGroupsApi(fetcher) {
|
|
72
72
|
return {
|
|
73
73
|
list(params) {
|
|
74
74
|
return fetcher("GET", BASE3, { query: params });
|
|
@@ -76,11 +76,33 @@ function createSlotsApi(fetcher) {
|
|
|
76
76
|
get(id) {
|
|
77
77
|
return fetcher("GET", `${BASE3}/${id}`);
|
|
78
78
|
},
|
|
79
|
+
create(body) {
|
|
80
|
+
return fetcher("POST", BASE3, { body });
|
|
81
|
+
},
|
|
82
|
+
update(id, body) {
|
|
83
|
+
return fetcher("PUT", `${BASE3}/${id}`, { body });
|
|
84
|
+
},
|
|
85
|
+
deactivate(id) {
|
|
86
|
+
return fetcher("DELETE", `${BASE3}/${id}`);
|
|
87
|
+
}
|
|
88
|
+
};
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
// src/resources/slots.ts
|
|
92
|
+
var BASE4 = "/api/v1/miot-calendar/slots";
|
|
93
|
+
function createSlotsApi(fetcher) {
|
|
94
|
+
return {
|
|
95
|
+
list(params) {
|
|
96
|
+
return fetcher("GET", BASE4, { query: params });
|
|
97
|
+
},
|
|
98
|
+
get(id) {
|
|
99
|
+
return fetcher("GET", `${BASE4}/${id}`);
|
|
100
|
+
},
|
|
79
101
|
generate(body) {
|
|
80
|
-
return fetcher("POST", `${
|
|
102
|
+
return fetcher("POST", `${BASE4}/generate`, { body });
|
|
81
103
|
},
|
|
82
104
|
updateStatus(id, body) {
|
|
83
|
-
return fetcher("PATCH", `${
|
|
105
|
+
return fetcher("PATCH", `${BASE4}/${id}/status`, { body });
|
|
84
106
|
}
|
|
85
107
|
};
|
|
86
108
|
}
|
|
@@ -130,6 +152,7 @@ function createMiotCalendarClient(config) {
|
|
|
130
152
|
return {
|
|
131
153
|
bookings: createBookingsApi(fetcher),
|
|
132
154
|
calendars: createCalendarsApi(fetcher),
|
|
155
|
+
groups: createGroupsApi(fetcher),
|
|
133
156
|
slots: createSlotsApi(fetcher)
|
|
134
157
|
};
|
|
135
158
|
}
|