go-scheduler-node-sdk 1.0.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 +467 -0
- package/dist/client.d.ts +22 -0
- package/dist/client.js +31 -0
- package/dist/index.d.ts +9 -0
- package/dist/index.js +42 -0
- package/dist/resources/attendees.d.ts +31 -0
- package/dist/resources/attendees.js +51 -0
- package/dist/resources/calendarMembers.d.ts +13 -0
- package/dist/resources/calendarMembers.js +27 -0
- package/dist/resources/calendars.d.ts +30 -0
- package/dist/resources/calendars.js +95 -0
- package/dist/resources/events.d.ts +18 -0
- package/dist/resources/events.js +40 -0
- package/dist/resources/reminders.d.ts +22 -0
- package/dist/resources/reminders.js +27 -0
- package/dist/resources/webhooks.d.ts +12 -0
- package/dist/resources/webhooks.js +31 -0
- package/dist/types.d.ts +338 -0
- package/dist/types.js +31 -0
- package/dist/utils/http.d.ts +14 -0
- package/dist/utils/http.js +99 -0
- package/dist/utils/webhook.d.ts +112 -0
- package/dist/utils/webhook.js +262 -0
- package/package.json +33 -0
package/README.md
ADDED
|
@@ -0,0 +1,467 @@
|
|
|
1
|
+
# Go-Scheduler TypeScript SDK
|
|
2
|
+
|
|
3
|
+
TypeScript SDK for interacting with the go-scheduler REST API.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
yarn install go-scheduler-node-sdk
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
or
|
|
12
|
+
|
|
13
|
+
```bash
|
|
14
|
+
yarn add go-scheduler-node-sdk
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
## Quick Start
|
|
18
|
+
|
|
19
|
+
```typescript
|
|
20
|
+
import { SchedulerClient } from "go-scheduler-node-sdk";
|
|
21
|
+
|
|
22
|
+
const client = new SchedulerClient({
|
|
23
|
+
baseURL: "http://localhost:8080",
|
|
24
|
+
timeout: 30000,
|
|
25
|
+
headers: {
|
|
26
|
+
"Authorization": "Bearer your-token-here"
|
|
27
|
+
}
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
// Check service health
|
|
31
|
+
const health = await client.healthCheck();
|
|
32
|
+
console.log(health);
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
## Usage Examples
|
|
36
|
+
|
|
37
|
+
### Calendars
|
|
38
|
+
|
|
39
|
+
```typescript
|
|
40
|
+
// Create a calendar
|
|
41
|
+
const calendar = await client.calendars.create({
|
|
42
|
+
account_id: "user123",
|
|
43
|
+
name: "My Calendar",
|
|
44
|
+
description: "Personal calendar",
|
|
45
|
+
timezone: "America/New_York",
|
|
46
|
+
metadata: { color: "blue" }
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
// Get a calendar
|
|
50
|
+
const calendar = await client.calendars.get("calendar-uid");
|
|
51
|
+
|
|
52
|
+
// List calendars
|
|
53
|
+
const calendars = await client.calendars.list(50, 0);
|
|
54
|
+
|
|
55
|
+
// Update a calendar
|
|
56
|
+
const updated = await client.calendars.update("calendar-uid", {
|
|
57
|
+
name: "Updated Calendar Name",
|
|
58
|
+
description: "New description"
|
|
59
|
+
});
|
|
60
|
+
|
|
61
|
+
// Delete a calendar
|
|
62
|
+
await client.calendars.delete("calendar-uid");
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
### Events
|
|
66
|
+
|
|
67
|
+
```typescript
|
|
68
|
+
// Create a single event
|
|
69
|
+
const event = await client.events.create({
|
|
70
|
+
calendar_uid: "calendar-uid",
|
|
71
|
+
account_id: "user123",
|
|
72
|
+
start_ts: Math.floor(Date.now() / 1000) + 3600,
|
|
73
|
+
end_ts: Math.floor(Date.now() / 1000) + 7200,
|
|
74
|
+
timezone: "America/New_York",
|
|
75
|
+
metadata: {
|
|
76
|
+
title: "Team Meeting",
|
|
77
|
+
description: "Quarterly planning"
|
|
78
|
+
}
|
|
79
|
+
});
|
|
80
|
+
|
|
81
|
+
// Create a recurring event
|
|
82
|
+
const recurringEvent = await client.events.create({
|
|
83
|
+
calendar_uid: "calendar-uid",
|
|
84
|
+
account_id: "user123",
|
|
85
|
+
start_ts: Math.floor(Date.now() / 1000) + 3600,
|
|
86
|
+
end_ts: Math.floor(Date.now() / 1000) + 7200,
|
|
87
|
+
recurrence: {
|
|
88
|
+
rule: "FREQ=WEEKLY;BYDAY=MO,WE,FR",
|
|
89
|
+
count: 10
|
|
90
|
+
},
|
|
91
|
+
metadata: {
|
|
92
|
+
title: "Daily Standup"
|
|
93
|
+
}
|
|
94
|
+
});
|
|
95
|
+
|
|
96
|
+
// Get an event
|
|
97
|
+
const event = await client.events.get("event-uid");
|
|
98
|
+
|
|
99
|
+
// Get events for multiple calendars
|
|
100
|
+
const events = await client.events.getCalendarEvents({
|
|
101
|
+
calendar_uids: ["cal-1", "cal-2"],
|
|
102
|
+
start_ts: Math.floor(Date.now() / 1000),
|
|
103
|
+
end_ts: Math.floor(Date.now() / 1000) + 86400 * 7
|
|
104
|
+
});
|
|
105
|
+
|
|
106
|
+
// Update an event (single instance)
|
|
107
|
+
const updated = await client.events.update("event-uid", {
|
|
108
|
+
account_id: "user123",
|
|
109
|
+
start_ts: newStartTime,
|
|
110
|
+
end_ts: newEndTime,
|
|
111
|
+
scope: "single"
|
|
112
|
+
});
|
|
113
|
+
|
|
114
|
+
// Update all instances of a recurring event
|
|
115
|
+
await client.events.update("event-uid", {
|
|
116
|
+
account_id: "user123",
|
|
117
|
+
start_ts: newStartTime,
|
|
118
|
+
end_ts: newEndTime,
|
|
119
|
+
scope: "all"
|
|
120
|
+
});
|
|
121
|
+
|
|
122
|
+
// Toggle cancelled status
|
|
123
|
+
await client.events.toggleCancelled("event-uid");
|
|
124
|
+
|
|
125
|
+
// Delete an event
|
|
126
|
+
await client.events.delete("event-uid", "user123", "single");
|
|
127
|
+
|
|
128
|
+
// Transfer event ownership
|
|
129
|
+
await client.events.transferOwnership(
|
|
130
|
+
"event-uid",
|
|
131
|
+
"new-owner-account-id",
|
|
132
|
+
"new-calendar-uid",
|
|
133
|
+
"all"
|
|
134
|
+
);
|
|
135
|
+
```
|
|
136
|
+
|
|
137
|
+
### Reminders
|
|
138
|
+
|
|
139
|
+
```typescript
|
|
140
|
+
// Create a reminder (30 minutes before event)
|
|
141
|
+
const reminder = await client.reminders.create("event-uid", {
|
|
142
|
+
offset_seconds: -1800,
|
|
143
|
+
account_id: "user123",
|
|
144
|
+
metadata: { method: "email" },
|
|
145
|
+
scope: "single"
|
|
146
|
+
});
|
|
147
|
+
|
|
148
|
+
// List reminders for an event
|
|
149
|
+
const reminders = await client.reminders.list("event-uid", "user123");
|
|
150
|
+
|
|
151
|
+
// Update a reminder
|
|
152
|
+
const updated = await client.reminders.update("event-uid", "reminder-uid", {
|
|
153
|
+
offset_seconds: -3600,
|
|
154
|
+
metadata: { method: "push" },
|
|
155
|
+
scope: "single"
|
|
156
|
+
});
|
|
157
|
+
|
|
158
|
+
// Delete a reminder
|
|
159
|
+
await client.reminders.delete("event-uid", "reminder-uid", "single");
|
|
160
|
+
```
|
|
161
|
+
|
|
162
|
+
### Webhooks
|
|
163
|
+
|
|
164
|
+
```typescript
|
|
165
|
+
// Create a webhook
|
|
166
|
+
const webhook = await client.webhooks.create({
|
|
167
|
+
url: "https://example.com/webhook",
|
|
168
|
+
event_types: ["event.created", "event.updated", "event.deleted"],
|
|
169
|
+
retry_count: 3,
|
|
170
|
+
timeout_seconds: 30
|
|
171
|
+
});
|
|
172
|
+
|
|
173
|
+
// Get a webhook
|
|
174
|
+
const webhook = await client.webhooks.get("webhook-uid");
|
|
175
|
+
|
|
176
|
+
// List webhooks
|
|
177
|
+
const webhooks = await client.webhooks.list(50, 0);
|
|
178
|
+
|
|
179
|
+
// Update a webhook
|
|
180
|
+
const updated = await client.webhooks.update("webhook-uid", {
|
|
181
|
+
url: "https://example.com/new-webhook",
|
|
182
|
+
is_active: true
|
|
183
|
+
});
|
|
184
|
+
|
|
185
|
+
// Delete a webhook
|
|
186
|
+
await client.webhooks.delete("webhook-uid");
|
|
187
|
+
|
|
188
|
+
// Get webhook deliveries
|
|
189
|
+
const deliveries = await client.webhooks.getDeliveries("webhook-uid", 50, 0);
|
|
190
|
+
```
|
|
191
|
+
|
|
192
|
+
### Attendees
|
|
193
|
+
|
|
194
|
+
```typescript
|
|
195
|
+
// Add an attendee to an event
|
|
196
|
+
const attendee = await client.attendees.create("event-uid", {
|
|
197
|
+
account_id: "user456",
|
|
198
|
+
role: "attendee",
|
|
199
|
+
metadata: { department: "engineering" },
|
|
200
|
+
scope: "single"
|
|
201
|
+
});
|
|
202
|
+
|
|
203
|
+
// List attendees for an event
|
|
204
|
+
const attendees = await client.attendees.list("event-uid");
|
|
205
|
+
|
|
206
|
+
// Get a specific attendee
|
|
207
|
+
const attendee = await client.attendees.get("event-uid", "user456");
|
|
208
|
+
|
|
209
|
+
// Update an attendee
|
|
210
|
+
const updated = await client.attendees.update("event-uid", "user456", {
|
|
211
|
+
role: "organizer",
|
|
212
|
+
scope: "single"
|
|
213
|
+
});
|
|
214
|
+
|
|
215
|
+
// Update RSVP status
|
|
216
|
+
await client.attendees.updateRSVP("event-uid", "user456", {
|
|
217
|
+
rsvp_status: "accepted",
|
|
218
|
+
scope: "single"
|
|
219
|
+
});
|
|
220
|
+
|
|
221
|
+
// Remove an attendee
|
|
222
|
+
await client.attendees.delete("event-uid", "user456", "single");
|
|
223
|
+
|
|
224
|
+
// Get events for an account (where they are an attendee)
|
|
225
|
+
const events = await client.attendees.getAccountEvents(
|
|
226
|
+
"user456",
|
|
227
|
+
Math.floor(Date.now() / 1000),
|
|
228
|
+
Math.floor(Date.now() / 1000) + 86400 * 30,
|
|
229
|
+
"attendee",
|
|
230
|
+
"accepted"
|
|
231
|
+
);
|
|
232
|
+
```
|
|
233
|
+
|
|
234
|
+
### Calendar Members
|
|
235
|
+
|
|
236
|
+
```typescript
|
|
237
|
+
// Invite members to a calendar
|
|
238
|
+
await client.calendarMembers.invite("calendar-uid", {
|
|
239
|
+
members: [
|
|
240
|
+
{ account_id: "user1", role: "read" },
|
|
241
|
+
{ account_id: "user2", role: "write" }
|
|
242
|
+
]
|
|
243
|
+
});
|
|
244
|
+
|
|
245
|
+
// List calendar members
|
|
246
|
+
const members = await client.calendarMembers.list("calendar-uid");
|
|
247
|
+
|
|
248
|
+
// Update a member's role
|
|
249
|
+
const updated = await client.calendarMembers.update("calendar-uid", "user1", {
|
|
250
|
+
role: "write",
|
|
251
|
+
status: "confirmed"
|
|
252
|
+
});
|
|
253
|
+
|
|
254
|
+
// Remove a member
|
|
255
|
+
await client.calendarMembers.remove("calendar-uid", "user1");
|
|
256
|
+
```
|
|
257
|
+
|
|
258
|
+
### ICS Import
|
|
259
|
+
|
|
260
|
+
```typescript
|
|
261
|
+
// Import from ICS file
|
|
262
|
+
const formData = new FormData();
|
|
263
|
+
formData.append("file", icsFileBlob);
|
|
264
|
+
formData.append("account_id", "user123");
|
|
265
|
+
formData.append("calendar_metadata", JSON.stringify({ name: "Imported Calendar" }));
|
|
266
|
+
|
|
267
|
+
const result = await client.calendars.importICS(formData);
|
|
268
|
+
console.log(`Imported ${result.summary.imported_events} events`);
|
|
269
|
+
|
|
270
|
+
// Import from ICS URL (with automatic sync)
|
|
271
|
+
const syncedCalendar = await client.calendars.importICSLink({
|
|
272
|
+
accountId: "user123",
|
|
273
|
+
icsUrl: "https://calendar.google.com/calendar/ical/example/basic.ics",
|
|
274
|
+
authType: "none", // or "basic" or "bearer"
|
|
275
|
+
syncIntervalSeconds: 86400, // 24 hours
|
|
276
|
+
calendarMetadata: { name: "External Calendar", source: "google" },
|
|
277
|
+
});
|
|
278
|
+
|
|
279
|
+
// Manually trigger a resync
|
|
280
|
+
const resyncResult = await client.calendars.resync("calendar-uid");
|
|
281
|
+
console.log(`Resynced ${resyncResult.imported_events} events`);
|
|
282
|
+
```
|
|
283
|
+
|
|
284
|
+
### Webhook Utilities
|
|
285
|
+
|
|
286
|
+
The SDK includes utilities for verifying and handling webhook payloads:
|
|
287
|
+
|
|
288
|
+
```typescript
|
|
289
|
+
import {
|
|
290
|
+
WebhookUtils,
|
|
291
|
+
createWebhookVerificationMiddleware,
|
|
292
|
+
WebhookPayload,
|
|
293
|
+
isEventWebhook,
|
|
294
|
+
isCalendarWebhook,
|
|
295
|
+
} from "go-scheduler-node-sdk";
|
|
296
|
+
|
|
297
|
+
// Verify a webhook signature
|
|
298
|
+
const rawBody = req.body; // Raw request body as string or Buffer
|
|
299
|
+
const signature = req.headers["x-webhook-signature"];
|
|
300
|
+
const secret = "your-webhook-secret";
|
|
301
|
+
|
|
302
|
+
const verification = WebhookUtils.verifySignature(rawBody, signature, secret);
|
|
303
|
+
if (verification.valid) {
|
|
304
|
+
const payload = JSON.parse(rawBody) as WebhookPayload;
|
|
305
|
+
console.log("Valid webhook:", payload.event_type);
|
|
306
|
+
} else {
|
|
307
|
+
console.error("Invalid webhook:", verification.error);
|
|
308
|
+
}
|
|
309
|
+
|
|
310
|
+
// Parse and verify in one step
|
|
311
|
+
const result = WebhookUtils.parseAndVerify(rawBody, signature, secret);
|
|
312
|
+
if (result) {
|
|
313
|
+
console.log("Webhook data:", result.payload.data);
|
|
314
|
+
}
|
|
315
|
+
|
|
316
|
+
// Verify with timestamp freshness check
|
|
317
|
+
const verification = WebhookUtils.verifyWithTimestamp(
|
|
318
|
+
rawBody,
|
|
319
|
+
signature,
|
|
320
|
+
secret,
|
|
321
|
+
300 // 5 minute tolerance
|
|
322
|
+
);
|
|
323
|
+
|
|
324
|
+
// Type guards for webhook payloads
|
|
325
|
+
if (isEventWebhook(payload)) {
|
|
326
|
+
// TypeScript knows this is an event webhook
|
|
327
|
+
console.log("Event UID:", payload.data.event_uid);
|
|
328
|
+
}
|
|
329
|
+
|
|
330
|
+
if (isCalendarWebhook(payload)) {
|
|
331
|
+
// TypeScript knows this is a calendar webhook
|
|
332
|
+
console.log("Calendar UID:", payload.data.calendar_uid);
|
|
333
|
+
}
|
|
334
|
+
|
|
335
|
+
// Express middleware for automatic verification
|
|
336
|
+
import express from "express";
|
|
337
|
+
|
|
338
|
+
const app = express();
|
|
339
|
+
|
|
340
|
+
app.use(express.json({
|
|
341
|
+
verify: (req, res, buf) => {
|
|
342
|
+
req.rawBody = buf.toString("utf8");
|
|
343
|
+
},
|
|
344
|
+
}));
|
|
345
|
+
|
|
346
|
+
app.post(
|
|
347
|
+
"/webhook",
|
|
348
|
+
createWebhookVerificationMiddleware("your-webhook-secret", {
|
|
349
|
+
rawBodyKey: "rawBody",
|
|
350
|
+
toleranceSeconds: 300,
|
|
351
|
+
}),
|
|
352
|
+
(req, res) => {
|
|
353
|
+
// Webhook is verified and parsed
|
|
354
|
+
const payload = req.webhookPayload as WebhookPayload;
|
|
355
|
+
console.log("Received:", payload.event_type);
|
|
356
|
+
res.json({ received: true });
|
|
357
|
+
}
|
|
358
|
+
);
|
|
359
|
+
```
|
|
360
|
+
|
|
361
|
+
#### Webhook Utility Functions
|
|
362
|
+
|
|
363
|
+
- **`verifySignature(payload, signature, secret)`** - Verify HMAC-SHA256 signature
|
|
364
|
+
- **`computeSignature(payload, secret)`** - Compute signature for testing
|
|
365
|
+
- **`parseAndVerify(rawPayload, signature, secret)`** - Parse and verify in one step
|
|
366
|
+
- **`validatePayloadStructure(payload)`** - Validate webhook payload structure
|
|
367
|
+
- **`isTimestampFresh(timestamp, toleranceSeconds)`** - Check timestamp freshness
|
|
368
|
+
- **`verifyWithTimestamp(rawPayload, signature, secret, toleranceSeconds)`** - Verify signature and timestamp
|
|
369
|
+
- **`extractSignature(headers)`** - Extract signature from headers
|
|
370
|
+
- **`createWebhookVerificationMiddleware(secret, options)`** - Express middleware factory
|
|
371
|
+
|
|
372
|
+
#### Webhook Type Guards
|
|
373
|
+
|
|
374
|
+
- **`isCalendarWebhook(payload)`** - Check if calendar webhook
|
|
375
|
+
- **`isCalendarSyncedWebhook(payload)`** - Check if calendar synced webhook
|
|
376
|
+
- **`isEventWebhook(payload)`** - Check if event webhook
|
|
377
|
+
- **`isReminderDueWebhook(payload)`** - Check if reminder due webhook
|
|
378
|
+
- **`isAttendeeWebhook(payload)`** - Check if attendee webhook
|
|
379
|
+
- **`isMemberWebhook(payload)`** - Check if member webhook
|
|
380
|
+
|
|
381
|
+
## Configuration
|
|
382
|
+
|
|
383
|
+
The `SchedulerClient` accepts the following configuration options:
|
|
384
|
+
|
|
385
|
+
```typescript
|
|
386
|
+
interface SchedulerConfig {
|
|
387
|
+
baseURL: string; // Required: Base URL of the go-scheduler API
|
|
388
|
+
timeout?: number; // Optional: Request timeout in milliseconds (default: 30000)
|
|
389
|
+
headers?: Record<string, string>; // Optional: Custom headers to include in all requests
|
|
390
|
+
}
|
|
391
|
+
```
|
|
392
|
+
|
|
393
|
+
## Setting Custom Headers
|
|
394
|
+
|
|
395
|
+
You can set custom headers after initializing the client:
|
|
396
|
+
|
|
397
|
+
```typescript
|
|
398
|
+
// Set a header
|
|
399
|
+
client.setHeader("Authorization", "Bearer new-token");
|
|
400
|
+
|
|
401
|
+
// Remove a header
|
|
402
|
+
client.removeHeader("Authorization");
|
|
403
|
+
```
|
|
404
|
+
|
|
405
|
+
## Recurring Events
|
|
406
|
+
|
|
407
|
+
When working with recurring events, many operations support a `scope` parameter:
|
|
408
|
+
|
|
409
|
+
- `"single"`: Affects only the specific instance
|
|
410
|
+
- `"all"`: Affects all instances in the series
|
|
411
|
+
- `"future"`: Affects this instance and all future instances (for updates only)
|
|
412
|
+
|
|
413
|
+
```typescript
|
|
414
|
+
// Update only this instance
|
|
415
|
+
await client.events.update("instance-uid", {
|
|
416
|
+
account_id: "user123",
|
|
417
|
+
start_ts: newTime,
|
|
418
|
+
end_ts: newTime + 3600,
|
|
419
|
+
scope: "single"
|
|
420
|
+
});
|
|
421
|
+
|
|
422
|
+
// Update all instances
|
|
423
|
+
await client.events.update("master-uid", {
|
|
424
|
+
account_id: "user123",
|
|
425
|
+
start_ts: newTime,
|
|
426
|
+
end_ts: newTime + 3600,
|
|
427
|
+
scope: "all"
|
|
428
|
+
});
|
|
429
|
+
```
|
|
430
|
+
|
|
431
|
+
## Error Handling
|
|
432
|
+
|
|
433
|
+
The SDK throws errors with detailed information:
|
|
434
|
+
|
|
435
|
+
```typescript
|
|
436
|
+
try {
|
|
437
|
+
const event = await client.events.get("invalid-uid");
|
|
438
|
+
} catch (error) {
|
|
439
|
+
console.error("Error:", error.message);
|
|
440
|
+
console.error("Status:", error.status);
|
|
441
|
+
console.error("Response:", error.response);
|
|
442
|
+
}
|
|
443
|
+
```
|
|
444
|
+
|
|
445
|
+
## TypeScript Support
|
|
446
|
+
|
|
447
|
+
The SDK is written in TypeScript and includes full type definitions. Import types as needed:
|
|
448
|
+
|
|
449
|
+
```typescript
|
|
450
|
+
import {
|
|
451
|
+
Calendar,
|
|
452
|
+
Event,
|
|
453
|
+
Reminder,
|
|
454
|
+
Webhook,
|
|
455
|
+
Attendee,
|
|
456
|
+
CreateEventRequest,
|
|
457
|
+
UpdateScope
|
|
458
|
+
} from "go-scheduler-node-sdk";
|
|
459
|
+
```
|
|
460
|
+
|
|
461
|
+
## API Reference
|
|
462
|
+
|
|
463
|
+
For complete API documentation, see the [go-scheduler API documentation](https://github.com/jaysongiroux/go-scheduler).
|
|
464
|
+
|
|
465
|
+
## License
|
|
466
|
+
|
|
467
|
+
MIT
|
package/dist/client.d.ts
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { Calendars } from "./resources/calendars";
|
|
2
|
+
import { Events } from "./resources/events";
|
|
3
|
+
import { Reminders } from "./resources/reminders";
|
|
4
|
+
import { Webhooks } from "./resources/webhooks";
|
|
5
|
+
import { Attendees } from "./resources/attendees";
|
|
6
|
+
import { CalendarMembers } from "./resources/calendarMembers";
|
|
7
|
+
import { SchedulerConfig } from "./types";
|
|
8
|
+
export declare class SchedulerClient {
|
|
9
|
+
private http;
|
|
10
|
+
calendars: Calendars;
|
|
11
|
+
events: Events;
|
|
12
|
+
reminders: Reminders;
|
|
13
|
+
webhooks: Webhooks;
|
|
14
|
+
attendees: Attendees;
|
|
15
|
+
calendarMembers: CalendarMembers;
|
|
16
|
+
constructor(config: SchedulerConfig);
|
|
17
|
+
setHeader(key: string, value: string): void;
|
|
18
|
+
removeHeader(key: string): void;
|
|
19
|
+
healthCheck(): Promise<{
|
|
20
|
+
status: string;
|
|
21
|
+
}>;
|
|
22
|
+
}
|
package/dist/client.js
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.SchedulerClient = void 0;
|
|
4
|
+
const http_1 = require("./utils/http");
|
|
5
|
+
const calendars_1 = require("./resources/calendars");
|
|
6
|
+
const events_1 = require("./resources/events");
|
|
7
|
+
const reminders_1 = require("./resources/reminders");
|
|
8
|
+
const webhooks_1 = require("./resources/webhooks");
|
|
9
|
+
const attendees_1 = require("./resources/attendees");
|
|
10
|
+
const calendarMembers_1 = require("./resources/calendarMembers");
|
|
11
|
+
class SchedulerClient {
|
|
12
|
+
constructor(config) {
|
|
13
|
+
this.http = new http_1.HttpClient(config.baseURL, config.timeout, config.headers);
|
|
14
|
+
this.calendars = new calendars_1.Calendars(this.http);
|
|
15
|
+
this.events = new events_1.Events(this.http);
|
|
16
|
+
this.reminders = new reminders_1.Reminders(this.http);
|
|
17
|
+
this.webhooks = new webhooks_1.Webhooks(this.http);
|
|
18
|
+
this.attendees = new attendees_1.Attendees(this.http);
|
|
19
|
+
this.calendarMembers = new calendarMembers_1.CalendarMembers(this.http);
|
|
20
|
+
}
|
|
21
|
+
setHeader(key, value) {
|
|
22
|
+
this.http.setHeader(key, value);
|
|
23
|
+
}
|
|
24
|
+
removeHeader(key) {
|
|
25
|
+
this.http.removeHeader(key);
|
|
26
|
+
}
|
|
27
|
+
async healthCheck() {
|
|
28
|
+
return this.http.get("/health");
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
exports.SchedulerClient = SchedulerClient;
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export { SchedulerClient } from "./client";
|
|
2
|
+
export * from "./types";
|
|
3
|
+
export { Calendars } from "./resources/calendars";
|
|
4
|
+
export { Events } from "./resources/events";
|
|
5
|
+
export { Reminders } from "./resources/reminders";
|
|
6
|
+
export { Webhooks } from "./resources/webhooks";
|
|
7
|
+
export { Attendees } from "./resources/attendees";
|
|
8
|
+
export { CalendarMembers } from "./resources/calendarMembers";
|
|
9
|
+
export { WebhookUtils, createWebhookVerificationMiddleware, verifySignature, computeSignature, parseAndVerify, validatePayloadStructure, isTimestampFresh, verifyWithTimestamp, extractSignature, } from "./utils/webhook";
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
exports.extractSignature = exports.verifyWithTimestamp = exports.isTimestampFresh = exports.validatePayloadStructure = exports.parseAndVerify = exports.computeSignature = exports.verifySignature = exports.createWebhookVerificationMiddleware = exports.WebhookUtils = exports.CalendarMembers = exports.Attendees = exports.Webhooks = exports.Reminders = exports.Events = exports.Calendars = exports.SchedulerClient = void 0;
|
|
18
|
+
var client_1 = require("./client");
|
|
19
|
+
Object.defineProperty(exports, "SchedulerClient", { enumerable: true, get: function () { return client_1.SchedulerClient; } });
|
|
20
|
+
__exportStar(require("./types"), exports);
|
|
21
|
+
var calendars_1 = require("./resources/calendars");
|
|
22
|
+
Object.defineProperty(exports, "Calendars", { enumerable: true, get: function () { return calendars_1.Calendars; } });
|
|
23
|
+
var events_1 = require("./resources/events");
|
|
24
|
+
Object.defineProperty(exports, "Events", { enumerable: true, get: function () { return events_1.Events; } });
|
|
25
|
+
var reminders_1 = require("./resources/reminders");
|
|
26
|
+
Object.defineProperty(exports, "Reminders", { enumerable: true, get: function () { return reminders_1.Reminders; } });
|
|
27
|
+
var webhooks_1 = require("./resources/webhooks");
|
|
28
|
+
Object.defineProperty(exports, "Webhooks", { enumerable: true, get: function () { return webhooks_1.Webhooks; } });
|
|
29
|
+
var attendees_1 = require("./resources/attendees");
|
|
30
|
+
Object.defineProperty(exports, "Attendees", { enumerable: true, get: function () { return attendees_1.Attendees; } });
|
|
31
|
+
var calendarMembers_1 = require("./resources/calendarMembers");
|
|
32
|
+
Object.defineProperty(exports, "CalendarMembers", { enumerable: true, get: function () { return calendarMembers_1.CalendarMembers; } });
|
|
33
|
+
var webhook_1 = require("./utils/webhook");
|
|
34
|
+
Object.defineProperty(exports, "WebhookUtils", { enumerable: true, get: function () { return webhook_1.WebhookUtils; } });
|
|
35
|
+
Object.defineProperty(exports, "createWebhookVerificationMiddleware", { enumerable: true, get: function () { return webhook_1.createWebhookVerificationMiddleware; } });
|
|
36
|
+
Object.defineProperty(exports, "verifySignature", { enumerable: true, get: function () { return webhook_1.verifySignature; } });
|
|
37
|
+
Object.defineProperty(exports, "computeSignature", { enumerable: true, get: function () { return webhook_1.computeSignature; } });
|
|
38
|
+
Object.defineProperty(exports, "parseAndVerify", { enumerable: true, get: function () { return webhook_1.parseAndVerify; } });
|
|
39
|
+
Object.defineProperty(exports, "validatePayloadStructure", { enumerable: true, get: function () { return webhook_1.validatePayloadStructure; } });
|
|
40
|
+
Object.defineProperty(exports, "isTimestampFresh", { enumerable: true, get: function () { return webhook_1.isTimestampFresh; } });
|
|
41
|
+
Object.defineProperty(exports, "verifyWithTimestamp", { enumerable: true, get: function () { return webhook_1.verifyWithTimestamp; } });
|
|
42
|
+
Object.defineProperty(exports, "extractSignature", { enumerable: true, get: function () { return webhook_1.extractSignature; } });
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { HttpClient } from "../utils/http";
|
|
2
|
+
import { Attendee, CreateAttendeeRequest, UpdateAttendeeRequest, UpdateAttendeeRSVPRequest } from "../types";
|
|
3
|
+
export declare class Attendees {
|
|
4
|
+
private http;
|
|
5
|
+
constructor(http: HttpClient);
|
|
6
|
+
create(eventUID: string, data: CreateAttendeeRequest): Promise<{
|
|
7
|
+
attendee?: Attendee;
|
|
8
|
+
attendee_group_id?: string;
|
|
9
|
+
scope: string;
|
|
10
|
+
count: number;
|
|
11
|
+
}>;
|
|
12
|
+
list(eventUID: string, roleFilter?: string, rsvpFilter?: string): Promise<Attendee[]>;
|
|
13
|
+
get(eventUID: string, accountID: string): Promise<Attendee>;
|
|
14
|
+
update(eventUID: string, accountID: string, data: UpdateAttendeeRequest): Promise<{
|
|
15
|
+
attendee?: Attendee;
|
|
16
|
+
scope: string;
|
|
17
|
+
count: number;
|
|
18
|
+
}>;
|
|
19
|
+
delete(eventUID: string, accountID: string, scope?: "single" | "all"): Promise<{
|
|
20
|
+
message: string;
|
|
21
|
+
scope: string;
|
|
22
|
+
count: number;
|
|
23
|
+
reminders_deleted: number;
|
|
24
|
+
}>;
|
|
25
|
+
updateRSVP(eventUID: string, accountID: string, data: UpdateAttendeeRSVPRequest): Promise<{
|
|
26
|
+
attendee?: Attendee;
|
|
27
|
+
scope: string;
|
|
28
|
+
count: number;
|
|
29
|
+
}>;
|
|
30
|
+
getAccountEvents(accountID: string, startTs: number, endTs: number, roleFilter?: string, rsvpFilter?: string): Promise<any[]>;
|
|
31
|
+
}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Attendees = void 0;
|
|
4
|
+
class Attendees {
|
|
5
|
+
constructor(http) {
|
|
6
|
+
this.http = http;
|
|
7
|
+
}
|
|
8
|
+
async create(eventUID, data) {
|
|
9
|
+
return this.http.post(`/api/v1/events/${eventUID}/attendees`, data);
|
|
10
|
+
}
|
|
11
|
+
async list(eventUID, roleFilter, rsvpFilter) {
|
|
12
|
+
const params = {};
|
|
13
|
+
if (roleFilter)
|
|
14
|
+
params.role = roleFilter;
|
|
15
|
+
if (rsvpFilter)
|
|
16
|
+
params.rsvp_status = rsvpFilter;
|
|
17
|
+
return this.http.get(`/api/v1/events/${eventUID}/attendees`, {
|
|
18
|
+
params: Object.keys(params).length > 0 ? params : undefined,
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
async get(eventUID, accountID) {
|
|
22
|
+
return this.http.get(`/api/v1/events/${eventUID}/attendees/${accountID}`);
|
|
23
|
+
}
|
|
24
|
+
async update(eventUID, accountID, data) {
|
|
25
|
+
return this.http.patch(`/api/v1/events/${eventUID}/attendees/${accountID}`, data);
|
|
26
|
+
}
|
|
27
|
+
async delete(eventUID, accountID, scope) {
|
|
28
|
+
const params = scope ? { scope } : undefined;
|
|
29
|
+
return this.http.delete(`/api/v1/events/${eventUID}/attendees/${accountID}`, {
|
|
30
|
+
params,
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
async updateRSVP(eventUID, accountID, data) {
|
|
34
|
+
return this.http.put(`/api/v1/events/${eventUID}/attendees/${accountID}/rsvp`, data);
|
|
35
|
+
}
|
|
36
|
+
async getAccountEvents(accountID, startTs, endTs, roleFilter, rsvpFilter) {
|
|
37
|
+
const params = {
|
|
38
|
+
account_id: accountID,
|
|
39
|
+
start_ts: startTs.toString(),
|
|
40
|
+
end_ts: endTs.toString(),
|
|
41
|
+
};
|
|
42
|
+
if (roleFilter)
|
|
43
|
+
params.role = roleFilter;
|
|
44
|
+
if (rsvpFilter)
|
|
45
|
+
params.rsvp_status = rsvpFilter;
|
|
46
|
+
return this.http.get("/api/v1/attendees/events", {
|
|
47
|
+
params,
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
exports.Attendees = Attendees;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { HttpClient } from "../utils/http";
|
|
2
|
+
import { CalendarMember, InviteCalendarMembersRequest, UpdateCalendarMemberRequest } from "../types";
|
|
3
|
+
export declare class CalendarMembers {
|
|
4
|
+
private http;
|
|
5
|
+
constructor(http: HttpClient);
|
|
6
|
+
invite(calendarUID: string, data: InviteCalendarMembersRequest): Promise<{
|
|
7
|
+
invited_count: number;
|
|
8
|
+
members: CalendarMember[];
|
|
9
|
+
}>;
|
|
10
|
+
list(calendarUID: string, requestingAccountID: string): Promise<CalendarMember[]>;
|
|
11
|
+
update(calendarUID: string, memberAccountID: string, requestingAccountID: string, data: UpdateCalendarMemberRequest): Promise<CalendarMember>;
|
|
12
|
+
remove(calendarUID: string, memberAccountID: string, requestingAccountID: string): Promise<void>;
|
|
13
|
+
}
|