@blazeo.com/calendar-client 1.0.1 → 1.0.3
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 +15 -44
- package/dist/index.d.ts +101 -741
- package/dist/index.js +1320 -501
- package/dist/index.mjs +1309 -498
- package/package.json +3 -7
- package/dist/index.d.mts +0 -741
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# @blazeo.com/calendar-client
|
|
2
2
|
|
|
3
|
-
**Private package** – for Blazeo internal teams only.
|
|
3
|
+
**Private package** – for Blazeo internal teams only. JavaScript client for the Blazeo Calendar / Appointment API. Use it in React (or any JS app) to call calendar and event endpoints via MobX State Tree models.
|
|
4
4
|
|
|
5
5
|
## Install
|
|
6
6
|
|
|
@@ -19,60 +19,31 @@ cd your-app && npm link @blazeo.com/calendar-client
|
|
|
19
19
|
|
|
20
20
|
## Usage
|
|
21
21
|
|
|
22
|
-
|
|
23
|
-
import { AppointmentClient } from '@blazeo.com/calendar-client';
|
|
24
|
-
|
|
25
|
-
const client = new AppointmentClient({
|
|
26
|
-
baseUrl: 'https://your-appointment-api.example.com',
|
|
27
|
-
getDefaultOffset: () => new Date().getTimezoneOffset(), // optional
|
|
28
|
-
});
|
|
29
|
-
|
|
30
|
-
// Get calendar
|
|
31
|
-
const cal = await client.getCalendar('calendar-guid');
|
|
32
|
-
if (cal.status === 'success' && cal.data) {
|
|
33
|
-
console.log(cal.data.name);
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
// Get availability for a day (optional participant_id)
|
|
37
|
-
const slots = await client.getAvailability({
|
|
38
|
-
calendarId: 'calendar-guid',
|
|
39
|
-
participantId: 'participant-guid', // optional
|
|
40
|
-
year: 2026,
|
|
41
|
-
month: 2,
|
|
42
|
-
day: 15,
|
|
43
|
-
offset: new Date().getTimezoneOffset(),
|
|
44
|
-
});
|
|
45
|
-
|
|
46
|
-
// Create event (flexible input – snake_case or camelCase)
|
|
47
|
-
const created = await client.createEvent({
|
|
48
|
-
calendarId: 'calendar-guid',
|
|
49
|
-
visitor_email: 'visitor@example.com',
|
|
50
|
-
visitor_name: 'Jane',
|
|
51
|
-
start_date: '2026-02-15',
|
|
52
|
-
startTime: '14:30',
|
|
53
|
-
}, new Date().getTimezoneOffset());
|
|
54
|
-
```
|
|
55
|
-
|
|
56
|
-
## MobX State Tree models
|
|
22
|
+
Configure once at app startup, then use models and their methods:
|
|
57
23
|
|
|
58
|
-
|
|
24
|
+
```js
|
|
25
|
+
import { configure, setBaseUrl, CalendarModel, createRootStore } from '@blazeo.com/calendar-client';
|
|
59
26
|
|
|
60
|
-
|
|
61
|
-
|
|
27
|
+
configure({ baseUrl: 'https://your-appointment-api.example.com' });
|
|
28
|
+
// or: setBaseUrl('https://localhost:7051');
|
|
62
29
|
|
|
63
|
-
|
|
64
|
-
const
|
|
30
|
+
// Calendar static methods (no store needed)
|
|
31
|
+
const timezones = await CalendarModel.getTimeZones();
|
|
32
|
+
const calendar = await CalendarModel.get('calendar-guid');
|
|
65
33
|
|
|
34
|
+
// Or use RootStore with models
|
|
35
|
+
const store = createRootStore();
|
|
66
36
|
const cal = store.addCalendar({ calendarId: 'my-cal', name: 'My Calendar' });
|
|
67
37
|
await cal.create(); // POST to backend
|
|
68
38
|
```
|
|
69
39
|
|
|
70
40
|
## API overview
|
|
71
41
|
|
|
72
|
-
- **
|
|
73
|
-
- **
|
|
42
|
+
- **CalendarModel (static):** `get`, `getByCompany`, `getTimeZones`, `getTimeZone`, `getParticipants`, `getMonth`, `getEvents`, etc.
|
|
43
|
+
- **EventModel (instance):** `get`, `create`, `cancel`, `getCancellable`, `getAvailability`, `setReminder`
|
|
44
|
+
- **RootStore:** `addCalendar`, `addEvent`
|
|
74
45
|
|
|
75
|
-
All methods return `Promise<
|
|
46
|
+
All methods return `Promise<{ status, data?, message? }>`. Check `response.status === 'success'` and use `response.data`.
|
|
76
47
|
|
|
77
48
|
## Sample
|
|
78
49
|
|