@workast/sdk 2.3.0 → 3.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/dist/index.js ADDED
@@ -0,0 +1,1843 @@
1
+ // src/errors.ts
2
+ var ApiError = class extends Error {
3
+ status;
4
+ body;
5
+ constructor(message, status, body) {
6
+ super(message);
7
+ this.name = "ApiError";
8
+ this.status = status;
9
+ this.body = body;
10
+ }
11
+ };
12
+ var AuthenticationError = class extends ApiError {
13
+ constructor(message, status = 401, body) {
14
+ super(message, status, body);
15
+ this.name = "AuthenticationError";
16
+ }
17
+ };
18
+ var PermissionError = class extends ApiError {
19
+ constructor(message, status = 403, body) {
20
+ super(message, status, body);
21
+ this.name = "PermissionError";
22
+ }
23
+ };
24
+ var NotFoundError = class extends ApiError {
25
+ constructor(message, status = 404, body) {
26
+ super(message, status, body);
27
+ this.name = "NotFoundError";
28
+ }
29
+ };
30
+ var ValidationError = class extends ApiError {
31
+ constructor(message, status = 400, body) {
32
+ super(message, status, body);
33
+ this.name = "ValidationError";
34
+ }
35
+ };
36
+ function errorFromResponse(status, body) {
37
+ const message = messageFromBody(body) ?? `Request failed with status ${status}`;
38
+ switch (status) {
39
+ case 400:
40
+ return new ValidationError(message, status, body);
41
+ case 401:
42
+ return new AuthenticationError(message, status, body);
43
+ case 403:
44
+ return new PermissionError(message, status, body);
45
+ case 404:
46
+ return new NotFoundError(message, status, body);
47
+ default:
48
+ return new ApiError(message, status, body);
49
+ }
50
+ }
51
+ function messageFromBody(body) {
52
+ if (!body || typeof body !== "object") {
53
+ return void 0;
54
+ }
55
+ const { error, message } = body;
56
+ if (typeof error === "string") {
57
+ return typeof message === "string" ? message : error;
58
+ }
59
+ if (error && typeof error === "object") {
60
+ const nested = error;
61
+ if (typeof nested.message === "string") {
62
+ return nested.message;
63
+ }
64
+ }
65
+ if (typeof message === "string") {
66
+ return message;
67
+ }
68
+ return void 0;
69
+ }
70
+
71
+ // src/request.ts
72
+ function withoutAuthorization(headers = {}) {
73
+ const next = {};
74
+ for (const [key, value] of Object.entries(headers)) {
75
+ if (key.toLowerCase() !== "authorization") {
76
+ next[key] = value;
77
+ }
78
+ }
79
+ return next;
80
+ }
81
+ async function request(ctx, method, path, body, options) {
82
+ const token = await ctx.resolveAuth();
83
+ const headers = {
84
+ ...body !== void 0 ? { "Content-Type": "application/json" } : {},
85
+ ...ctx.headers,
86
+ ...withoutAuthorization(options?.headers),
87
+ Authorization: `Bearer ${token}`
88
+ };
89
+ let url = `${ctx.baseUrl.replace(/\/$/, "")}${path}`;
90
+ const qs = options?.query?.toString();
91
+ if (qs) {
92
+ url += `?${qs}`;
93
+ }
94
+ const response = await ctx.fetch(url, {
95
+ method,
96
+ headers,
97
+ body: body !== void 0 ? JSON.stringify(body) : void 0
98
+ });
99
+ if (!response.ok) {
100
+ let errorBody;
101
+ try {
102
+ errorBody = await response.json();
103
+ } catch {
104
+ errorBody = void 0;
105
+ }
106
+ throw errorFromResponse(response.status, errorBody);
107
+ }
108
+ if (response.status === 204) {
109
+ return void 0;
110
+ }
111
+ const text = await response.text();
112
+ if (!text) {
113
+ return void 0;
114
+ }
115
+ return JSON.parse(text);
116
+ }
117
+
118
+ // src/resources/attachments.ts
119
+ var Attachments = class {
120
+ constructor(client) {
121
+ this.client = client;
122
+ }
123
+ client;
124
+ /**
125
+ * Get a signed URL to download an attachment file.
126
+ *
127
+ * @example
128
+ * const attachment = await workast.attachments.retrieveFileUrl('attachment-id');
129
+ */
130
+ retrieveFileUrl(attachmentId, query, options) {
131
+ const params = new URLSearchParams(options?.query);
132
+ if (query?.download != null) {
133
+ params.set("download", String(query.download));
134
+ }
135
+ return this.client.request(
136
+ "GET",
137
+ `/attachment/${encodeURIComponent(attachmentId)}/file`,
138
+ void 0,
139
+ params.toString() ? { ...options, query: params } : options
140
+ );
141
+ }
142
+ };
143
+
144
+ // src/resources/calendar.ts
145
+ var CalendarEventsResource = class {
146
+ constructor(client) {
147
+ this.client = client;
148
+ }
149
+ client;
150
+ /**
151
+ * List user calendar events.
152
+ *
153
+ * @example
154
+ * const results = await workast.calendar.events.list({ from: '2025-10-29', to: '2025-11-05' });
155
+ */
156
+ list(query, options) {
157
+ const params = new URLSearchParams(options?.query);
158
+ if (query?.from) {
159
+ params.set("from", query.from);
160
+ }
161
+ if (query?.to) {
162
+ params.set("to", query.to);
163
+ }
164
+ if (query?.tzid) {
165
+ params.set("tzid", query.tzid);
166
+ }
167
+ if (query?.attendees) {
168
+ for (const value of query.attendees) {
169
+ params.append("attendees", value);
170
+ }
171
+ }
172
+ return this.client.request(
173
+ "GET",
174
+ "/calendar/events",
175
+ void 0,
176
+ params.toString() ? { ...options, query: params } : options
177
+ );
178
+ }
179
+ };
180
+ var CalendarResource = class {
181
+ events;
182
+ constructor(client) {
183
+ this.events = new CalendarEventsResource(client);
184
+ }
185
+ };
186
+
187
+ // src/resources/fields.ts
188
+ var Fields = class {
189
+ constructor(client) {
190
+ this.client = client;
191
+ }
192
+ client;
193
+ /**
194
+ * List custom fields in the team.
195
+ *
196
+ * @example
197
+ * const fields = await workast.fields.list({ listId: 'list-id' });
198
+ */
199
+ list(query, options) {
200
+ const params = new URLSearchParams(options?.query);
201
+ if (query?.listId) {
202
+ params.set("listId", query.listId);
203
+ }
204
+ return this.client.request(
205
+ "GET",
206
+ "/field",
207
+ void 0,
208
+ params.toString() ? { ...options, query: params } : options
209
+ );
210
+ }
211
+ /**
212
+ * Create a custom field.
213
+ *
214
+ * @example
215
+ * const field = await workast.fields.create({ name: 'Priority', type: 'text' });
216
+ */
217
+ create(body, options) {
218
+ return this.client.request("POST", "/field", body, options);
219
+ }
220
+ /**
221
+ * Update a custom field.
222
+ *
223
+ * @example
224
+ * const field = await workast.fields.update('field-id', { name: 'Priority' });
225
+ */
226
+ update(fieldId, body, options) {
227
+ return this.client.request(
228
+ "PUT",
229
+ `/field/${encodeURIComponent(fieldId)}`,
230
+ body,
231
+ options
232
+ );
233
+ }
234
+ /**
235
+ * Remove a custom field.
236
+ *
237
+ * @example
238
+ * await workast.fields.del('field-id');
239
+ */
240
+ del(fieldId, options) {
241
+ return this.client.request(
242
+ "DELETE",
243
+ `/field/${encodeURIComponent(fieldId)}`,
244
+ void 0,
245
+ options
246
+ );
247
+ }
248
+ };
249
+
250
+ // src/resources/lists.ts
251
+ var ListSublists = class {
252
+ constructor(client) {
253
+ this.client = client;
254
+ }
255
+ client;
256
+ /**
257
+ * List unique sublist names across lists.
258
+ *
259
+ * @example
260
+ * const names = await workast.lists.sublists.list({ types: ['group'] });
261
+ */
262
+ list(query, options) {
263
+ const params = new URLSearchParams(options?.query);
264
+ if (query?.onlyUserLists != null) {
265
+ params.set("onlyUserLists", String(query.onlyUserLists));
266
+ }
267
+ if (query?.types) {
268
+ for (const value of query.types) {
269
+ params.append("types", value);
270
+ }
271
+ }
272
+ return this.client.request(
273
+ "GET",
274
+ "/list/sublists",
275
+ void 0,
276
+ params.toString() ? { ...options, query: params } : options
277
+ );
278
+ }
279
+ /**
280
+ * Create a sublist in a list.
281
+ *
282
+ * @example
283
+ * const sublist = await workast.lists.sublists.create('list-id', { name: 'To-do' });
284
+ */
285
+ create(listId, body, options) {
286
+ return this.client.request(
287
+ "POST",
288
+ `/list/${encodeURIComponent(listId)}/sublist`,
289
+ body,
290
+ options
291
+ );
292
+ }
293
+ /**
294
+ * Update a sublist.
295
+ *
296
+ * @example
297
+ * await workast.lists.sublists.update('list-id', 'sublist-id', { name: 'Done' });
298
+ */
299
+ update(listId, subListId, body, options) {
300
+ return this.client.request(
301
+ "PATCH",
302
+ `/list/${encodeURIComponent(listId)}/sublist/${encodeURIComponent(subListId)}`,
303
+ body,
304
+ options
305
+ );
306
+ }
307
+ /**
308
+ * Remove a sublist.
309
+ *
310
+ * @example
311
+ * await workast.lists.sublists.del('list-id', 'sublist-id');
312
+ */
313
+ del(listId, subListId, options) {
314
+ return this.client.request(
315
+ "DELETE",
316
+ `/list/${encodeURIComponent(listId)}/sublist/${encodeURIComponent(subListId)}`,
317
+ void 0,
318
+ options
319
+ );
320
+ }
321
+ };
322
+ var ListParticipantsResource = class {
323
+ constructor(client) {
324
+ this.client = client;
325
+ }
326
+ client;
327
+ /**
328
+ * List participants on a list.
329
+ *
330
+ * @example
331
+ * const users = await workast.lists.participants.list('list-id');
332
+ */
333
+ list(listId, options) {
334
+ return this.client.request(
335
+ "GET",
336
+ `/list/${encodeURIComponent(listId)}/participant`,
337
+ void 0,
338
+ options
339
+ );
340
+ }
341
+ /**
342
+ * Add participants to a list.
343
+ *
344
+ * @example
345
+ * await workast.lists.participants.add('list-id', { users: ['user-id'] });
346
+ */
347
+ add(listId, body, options) {
348
+ return this.client.request(
349
+ "POST",
350
+ `/list/${encodeURIComponent(listId)}/participant`,
351
+ body,
352
+ options
353
+ );
354
+ }
355
+ /**
356
+ * Remove participants from a list.
357
+ *
358
+ * @example
359
+ * await workast.lists.participants.del('list-id', { users: ['user-id'] });
360
+ */
361
+ del(listId, body, options) {
362
+ return this.client.request(
363
+ "DELETE",
364
+ `/list/${encodeURIComponent(listId)}/participant`,
365
+ body,
366
+ options
367
+ );
368
+ }
369
+ };
370
+ var ListFields = class {
371
+ constructor(client) {
372
+ this.client = client;
373
+ }
374
+ client;
375
+ /**
376
+ * Enable a custom field on a list.
377
+ *
378
+ * @example
379
+ * await workast.lists.fields.enable('list-id', 'field-id');
380
+ */
381
+ enable(listId, fieldId, options) {
382
+ return this.client.request(
383
+ "POST",
384
+ `/list/${encodeURIComponent(listId)}/field/${encodeURIComponent(fieldId)}`,
385
+ void 0,
386
+ options
387
+ );
388
+ }
389
+ /**
390
+ * Disable a custom field on a list.
391
+ *
392
+ * @example
393
+ * await workast.lists.fields.disable('list-id', 'field-id');
394
+ */
395
+ disable(listId, fieldId, options) {
396
+ return this.client.request(
397
+ "DELETE",
398
+ `/list/${encodeURIComponent(listId)}/field/${encodeURIComponent(fieldId)}`,
399
+ void 0,
400
+ options
401
+ );
402
+ }
403
+ };
404
+ var Lists = class {
405
+ constructor(client) {
406
+ this.client = client;
407
+ this.sublists = new ListSublists(client);
408
+ this.participants = new ListParticipantsResource(client);
409
+ this.fields = new ListFields(client);
410
+ }
411
+ client;
412
+ sublists;
413
+ participants;
414
+ fields;
415
+ /**
416
+ * Create a list.
417
+ *
418
+ * @example
419
+ * const list = await workast.lists.create({ name: 'Engineering' });
420
+ */
421
+ create(body, options) {
422
+ return this.client.request("POST", "/list", body, options);
423
+ }
424
+ /**
425
+ * Get a list by ID.
426
+ *
427
+ * @example
428
+ * const list = await workast.lists.retrieve('list-id');
429
+ */
430
+ retrieve(listId, options) {
431
+ return this.client.request("GET", `/list/${encodeURIComponent(listId)}`, void 0, options);
432
+ }
433
+ /**
434
+ * Update a list.
435
+ *
436
+ * @example
437
+ * await workast.lists.update('list-id', { name: 'Engineering' });
438
+ */
439
+ update(listId, body, options) {
440
+ return this.client.request("PATCH", `/list/${encodeURIComponent(listId)}`, body, options);
441
+ }
442
+ /**
443
+ * Search lists.
444
+ *
445
+ * @example
446
+ * const lists = await workast.lists.list({ type: 'group', limit: 10 });
447
+ */
448
+ list(query, options) {
449
+ const params = new URLSearchParams(options?.query);
450
+ if (query?.onlyUserLists != null) {
451
+ params.set("onlyUserLists", String(query.onlyUserLists));
452
+ }
453
+ if (query?.statusIs) {
454
+ params.set("statusIs", query.statusIs);
455
+ }
456
+ if (query?.includeTemplates != null) {
457
+ params.set("includeTemplates", String(query.includeTemplates));
458
+ }
459
+ if (query?.type) {
460
+ params.set("type", query.type);
461
+ }
462
+ if (query?.channelId) {
463
+ params.set("channelId", query.channelId);
464
+ }
465
+ if (query?.participants) {
466
+ for (const value of query.participants) {
467
+ params.append("participants", value);
468
+ }
469
+ }
470
+ if (query?.name) {
471
+ params.set("name", query.name);
472
+ }
473
+ if (query?.limit != null) {
474
+ params.set("limit", String(query.limit));
475
+ }
476
+ if (query?.skip != null) {
477
+ params.set("skip", String(query.skip));
478
+ }
479
+ if (query?.sort) {
480
+ params.set("sort", query.sort);
481
+ }
482
+ return this.client.request(
483
+ "GET",
484
+ "/list",
485
+ void 0,
486
+ params.toString() ? { ...options, query: params } : options
487
+ );
488
+ }
489
+ /**
490
+ * Get the personal list.
491
+ *
492
+ * @example
493
+ * const list = await workast.lists.retrievePersonal();
494
+ */
495
+ retrievePersonal(options) {
496
+ return this.client.request("GET", "/list/personal", void 0, options);
497
+ }
498
+ /**
499
+ * Archive a list.
500
+ *
501
+ * @example
502
+ * await workast.lists.archive('list-id');
503
+ */
504
+ archive(listId, options) {
505
+ return this.client.request(
506
+ "POST",
507
+ `/list/${encodeURIComponent(listId)}/archive`,
508
+ void 0,
509
+ options
510
+ );
511
+ }
512
+ /**
513
+ * Unarchive a list.
514
+ *
515
+ * @example
516
+ * await workast.lists.unarchive('list-id');
517
+ */
518
+ unarchive(listId, options) {
519
+ return this.client.request(
520
+ "POST",
521
+ `/list/${encodeURIComponent(listId)}/unarchive`,
522
+ void 0,
523
+ options
524
+ );
525
+ }
526
+ /**
527
+ * Join a list.
528
+ *
529
+ * @example
530
+ * await workast.lists.join('list-id');
531
+ */
532
+ join(listId, options) {
533
+ return this.client.request(
534
+ "POST",
535
+ `/list/${encodeURIComponent(listId)}/participant/join`,
536
+ void 0,
537
+ options
538
+ );
539
+ }
540
+ /**
541
+ * Request access to a private list.
542
+ *
543
+ * @example
544
+ * await workast.lists.requestAccess('list-id');
545
+ */
546
+ requestAccess(listId, options) {
547
+ return this.client.request(
548
+ "POST",
549
+ `/list/${encodeURIComponent(listId)}/participant/request`,
550
+ void 0,
551
+ options
552
+ );
553
+ }
554
+ /**
555
+ * Import a template into a list.
556
+ *
557
+ * @example
558
+ * await workast.lists.importTemplate('list-id', 'template-id', { updateDueDates: 30 });
559
+ */
560
+ importTemplate(listId, templateId, body, options) {
561
+ return this.client.request(
562
+ "POST",
563
+ `/list/${encodeURIComponent(listId)}/import/${encodeURIComponent(templateId)}`,
564
+ body,
565
+ options
566
+ );
567
+ }
568
+ };
569
+
570
+ // src/resources/meetings.ts
571
+ var MeetingsResource = class {
572
+ constructor(client) {
573
+ this.client = client;
574
+ }
575
+ client;
576
+ /**
577
+ * List meetings.
578
+ *
579
+ * @example
580
+ * const results = await workast.meetings.list({ timeMin: '2026-01-01T00:00:00Z', maxResults: 15 });
581
+ */
582
+ list(query, options) {
583
+ const params = new URLSearchParams(options?.query);
584
+ if (query?.timeMin) {
585
+ params.set("timeMin", query.timeMin);
586
+ }
587
+ if (query?.timeMax) {
588
+ params.set("timeMax", query.timeMax);
589
+ }
590
+ if (query?.maxResults != null) {
591
+ params.set("maxResults", String(query.maxResults));
592
+ }
593
+ if (query?.pageToken) {
594
+ params.set("pageToken", query.pageToken);
595
+ }
596
+ if (query?.attendees) {
597
+ for (const value of query.attendees) {
598
+ params.append("attendees", value);
599
+ }
600
+ }
601
+ return this.client.request(
602
+ "GET",
603
+ "/meeting",
604
+ void 0,
605
+ params.toString() ? { ...options, query: params } : options
606
+ );
607
+ }
608
+ /**
609
+ * Create a meeting from a calendar event, or create a new calendar event.
610
+ *
611
+ * @example
612
+ * const meeting = await workast.meetings.createFromEvent({
613
+ * listId: 'list-id',
614
+ * summary: 'Standup',
615
+ * eventId: 'evt-1',
616
+ * });
617
+ */
618
+ createFromEvent(body, options) {
619
+ return this.client.request("POST", "/meeting", body, options);
620
+ }
621
+ /**
622
+ * Get a meeting by ID.
623
+ *
624
+ * @example
625
+ * const meeting = await workast.meetings.retrieve('meeting-id');
626
+ */
627
+ retrieve(meetingId, options) {
628
+ return this.client.request("GET", `/meeting/${encodeURIComponent(meetingId)}`, void 0, options);
629
+ }
630
+ /**
631
+ * Update meeting notes.
632
+ *
633
+ * @example
634
+ * const meeting = await workast.meetings.update('meeting-id', { notes: 'Ship v3' });
635
+ */
636
+ update(meetingId, body, options) {
637
+ return this.client.request("PATCH", `/meeting/${encodeURIComponent(meetingId)}`, body, options);
638
+ }
639
+ /**
640
+ * Get meeting recording assets and transcript.
641
+ *
642
+ * @example
643
+ * const recording = await workast.meetings.retrieveRecording('meeting-id');
644
+ */
645
+ retrieveRecording(meetingId, options) {
646
+ return this.client.request(
647
+ "GET",
648
+ `/meeting/${encodeURIComponent(meetingId)}/recording`,
649
+ void 0,
650
+ options
651
+ );
652
+ }
653
+ /**
654
+ * Enable the notetaker for a meeting.
655
+ *
656
+ * @example
657
+ * const meeting = await workast.meetings.enableNotetaker('meeting-id', {
658
+ * joinUrl: 'https://meet.example.com/abc',
659
+ * });
660
+ */
661
+ enableNotetaker(meetingId, body, options) {
662
+ return this.client.request(
663
+ "POST",
664
+ `/meeting/${encodeURIComponent(meetingId)}/notetaker`,
665
+ body,
666
+ options
667
+ );
668
+ }
669
+ /**
670
+ * Disable or remove the notetaker from a meeting.
671
+ *
672
+ * @example
673
+ * const meeting = await workast.meetings.disableNotetaker('meeting-id');
674
+ */
675
+ disableNotetaker(meetingId, options) {
676
+ return this.client.request(
677
+ "DELETE",
678
+ `/meeting/${encodeURIComponent(meetingId)}/notetaker`,
679
+ void 0,
680
+ options
681
+ );
682
+ }
683
+ };
684
+
685
+ // src/resources/notes.ts
686
+ var NotesResource = class {
687
+ constructor(client) {
688
+ this.client = client;
689
+ }
690
+ client;
691
+ /**
692
+ * List notes.
693
+ *
694
+ * @example
695
+ * const results = await workast.notes.list({ title: 'Spec', limit: 10 });
696
+ */
697
+ list(query, options) {
698
+ const params = new URLSearchParams(options?.query);
699
+ if (query?.showDeleted != null) {
700
+ params.set("showDeleted", String(query.showDeleted));
701
+ }
702
+ if (query?.lists) {
703
+ for (const value of query.lists) {
704
+ params.append("lists", value);
705
+ }
706
+ }
707
+ if (query?.title) {
708
+ params.set("title", query.title);
709
+ }
710
+ if (query?.owners) {
711
+ for (const value of query.owners) {
712
+ params.append("owners", value);
713
+ }
714
+ }
715
+ if (query?.sort) {
716
+ params.set("sort", query.sort);
717
+ }
718
+ if (query?.limit != null) {
719
+ params.set("limit", String(query.limit));
720
+ }
721
+ if (query?.skip != null) {
722
+ params.set("skip", String(query.skip));
723
+ }
724
+ return this.client.request(
725
+ "GET",
726
+ "/note",
727
+ void 0,
728
+ params.toString() ? { ...options, query: params } : options
729
+ );
730
+ }
731
+ /**
732
+ * Get a note by ID.
733
+ *
734
+ * @example
735
+ * const note = await workast.notes.retrieve('note-id');
736
+ */
737
+ retrieve(noteId, options) {
738
+ return this.client.request("GET", `/note/${encodeURIComponent(noteId)}`, void 0, options);
739
+ }
740
+ /**
741
+ * Update a note.
742
+ *
743
+ * @example
744
+ * const note = await workast.notes.update('note-id', { title: 'Spec', version: 1, body: '<p>Hello</p>' });
745
+ */
746
+ update(noteId, body, options) {
747
+ return this.client.request("PATCH", `/note/${encodeURIComponent(noteId)}`, body, options);
748
+ }
749
+ /**
750
+ * Delete a note.
751
+ *
752
+ * @example
753
+ * await workast.notes.del('note-id');
754
+ */
755
+ del(noteId, options) {
756
+ return this.client.request("DELETE", `/note/${encodeURIComponent(noteId)}`, void 0, options);
757
+ }
758
+ };
759
+
760
+ // src/resources/notifications.ts
761
+ var NotificationsResource = class {
762
+ constructor(client) {
763
+ this.client = client;
764
+ }
765
+ client;
766
+ /**
767
+ * List notifications for the logged-in user.
768
+ *
769
+ * @example
770
+ * const results = await workast.notifications.list({ read: false, limit: 10 });
771
+ */
772
+ list(query, options) {
773
+ const params = new URLSearchParams(options?.query);
774
+ if (query?.read != null) {
775
+ params.set("read", String(query.read));
776
+ }
777
+ if (query?.limit != null) {
778
+ params.set("limit", String(query.limit));
779
+ }
780
+ if (query?.skip != null) {
781
+ params.set("skip", String(query.skip));
782
+ }
783
+ if (query?.sort) {
784
+ params.set("sort", query.sort);
785
+ }
786
+ return this.client.request(
787
+ "GET",
788
+ "/notification",
789
+ void 0,
790
+ params.toString() ? { ...options, query: params } : options
791
+ );
792
+ }
793
+ /**
794
+ * Mark a notification as read.
795
+ *
796
+ * @example
797
+ * await workast.notifications.markRead('notification-id');
798
+ */
799
+ markRead(notificationId, options) {
800
+ return this.client.request(
801
+ "POST",
802
+ `/notification/${encodeURIComponent(notificationId)}/read`,
803
+ void 0,
804
+ options
805
+ );
806
+ }
807
+ /**
808
+ * Mark a notification as unread.
809
+ *
810
+ * @example
811
+ * await workast.notifications.markUnread('notification-id');
812
+ */
813
+ markUnread(notificationId, options) {
814
+ return this.client.request(
815
+ "POST",
816
+ `/notification/${encodeURIComponent(notificationId)}/unread`,
817
+ void 0,
818
+ options
819
+ );
820
+ }
821
+ };
822
+
823
+ // src/resources/reactions.ts
824
+ var Reactions = class {
825
+ constructor(client) {
826
+ this.client = client;
827
+ }
828
+ client;
829
+ /**
830
+ * Add a reaction to an activity.
831
+ *
832
+ * @example
833
+ * const reaction = await workast.reactions.add('activity-id', { emoji: ':+1:' });
834
+ */
835
+ add(activityId, body, options) {
836
+ return this.client.request(
837
+ "POST",
838
+ `/activity/${encodeURIComponent(activityId)}/reaction`,
839
+ body,
840
+ options
841
+ );
842
+ }
843
+ /**
844
+ * Remove a reaction from an activity.
845
+ *
846
+ * @example
847
+ * await workast.reactions.del('activity-id', 'reaction-id');
848
+ */
849
+ del(activityId, reactionId, options) {
850
+ return this.client.request(
851
+ "DELETE",
852
+ `/activity/${encodeURIComponent(activityId)}/reaction/${encodeURIComponent(reactionId)}`,
853
+ void 0,
854
+ options
855
+ );
856
+ }
857
+ };
858
+
859
+ // src/resources/searches.ts
860
+ var SearchesResource = class {
861
+ constructor(client) {
862
+ this.client = client;
863
+ }
864
+ client;
865
+ /**
866
+ * List searches for the logged-in user.
867
+ *
868
+ * @example
869
+ * const results = await workast.searches.list({ home: true, limit: 10 });
870
+ */
871
+ list(query, options) {
872
+ const params = new URLSearchParams(options?.query);
873
+ if (query?.limit != null) {
874
+ params.set("limit", String(query.limit));
875
+ }
876
+ if (query?.skip != null) {
877
+ params.set("skip", String(query.skip));
878
+ }
879
+ if (query?.sort) {
880
+ params.set("sort", query.sort);
881
+ }
882
+ if (query?.home != null) {
883
+ params.set("home", String(query.home));
884
+ }
885
+ return this.client.request(
886
+ "GET",
887
+ "/search",
888
+ void 0,
889
+ params.toString() ? { ...options, query: params } : options
890
+ );
891
+ }
892
+ /**
893
+ * Create a search.
894
+ *
895
+ * @example
896
+ * const search = await workast.searches.create({
897
+ * name: 'My tasks',
898
+ * payload: { predicates: [{ type: 'status', attribute: 'status', comparison: 'eq', value: 'pending' }] },
899
+ * });
900
+ */
901
+ create(body, options) {
902
+ return this.client.request("POST", "/search", body, options);
903
+ }
904
+ /**
905
+ * Get a search by ID.
906
+ *
907
+ * @example
908
+ * const search = await workast.searches.retrieve('search-id');
909
+ */
910
+ retrieve(searchId, query, options) {
911
+ const params = new URLSearchParams(options?.query);
912
+ if (query?.getTasks != null) {
913
+ params.set("getTasks", String(query.getTasks));
914
+ }
915
+ if (query?.expand) {
916
+ for (const value of query.expand) {
917
+ params.append("expand", value);
918
+ }
919
+ }
920
+ return this.client.request(
921
+ "GET",
922
+ `/search/${encodeURIComponent(searchId)}`,
923
+ void 0,
924
+ params.toString() ? { ...options, query: params } : options
925
+ );
926
+ }
927
+ /**
928
+ * Update a search.
929
+ *
930
+ * @example
931
+ * const search = await workast.searches.update('search-id', { name: 'Updated' });
932
+ */
933
+ update(searchId, body, options) {
934
+ return this.client.request(
935
+ "PATCH",
936
+ `/search/${encodeURIComponent(searchId)}`,
937
+ body,
938
+ options
939
+ );
940
+ }
941
+ /**
942
+ * Delete a search.
943
+ *
944
+ * @example
945
+ * await workast.searches.del('search-id');
946
+ */
947
+ del(searchId, options) {
948
+ return this.client.request(
949
+ "DELETE",
950
+ `/search/${encodeURIComponent(searchId)}`,
951
+ void 0,
952
+ options
953
+ );
954
+ }
955
+ /**
956
+ * Add a search to the home screen.
957
+ *
958
+ * @example
959
+ * await workast.searches.addHome('search-id');
960
+ */
961
+ addHome(searchId, options) {
962
+ return this.client.request(
963
+ "POST",
964
+ `/search/${encodeURIComponent(searchId)}/home`,
965
+ void 0,
966
+ options
967
+ );
968
+ }
969
+ /**
970
+ * Remove a search from the home screen.
971
+ *
972
+ * @example
973
+ * await workast.searches.removeHome('search-id');
974
+ */
975
+ removeHome(searchId, options) {
976
+ return this.client.request(
977
+ "DELETE",
978
+ `/search/${encodeURIComponent(searchId)}/home`,
979
+ void 0,
980
+ options
981
+ );
982
+ }
983
+ /**
984
+ * Share a search with users.
985
+ *
986
+ * @example
987
+ * await workast.searches.share('search-id', { users: ['user-id'] });
988
+ */
989
+ share(searchId, body, options) {
990
+ return this.client.request(
991
+ "POST",
992
+ `/search/${encodeURIComponent(searchId)}/user`,
993
+ body,
994
+ options
995
+ );
996
+ }
997
+ /**
998
+ * Unshare a search from users.
999
+ *
1000
+ * @example
1001
+ * await workast.searches.unshare('search-id', { users: ['user-id'] });
1002
+ */
1003
+ unshare(searchId, body, options) {
1004
+ return this.client.request(
1005
+ "DELETE",
1006
+ `/search/${encodeURIComponent(searchId)}/user`,
1007
+ body,
1008
+ options
1009
+ );
1010
+ }
1011
+ /**
1012
+ * Set a reminder on a search.
1013
+ *
1014
+ * @example
1015
+ * await workast.searches.setReminder('search-id', {
1016
+ * repeat: { freq: 'weekly', byhour: 9, byminute: 0 },
1017
+ * });
1018
+ */
1019
+ setReminder(searchId, body, options) {
1020
+ return this.client.request(
1021
+ "PUT",
1022
+ `/search/${encodeURIComponent(searchId)}/reminder`,
1023
+ body,
1024
+ options
1025
+ );
1026
+ }
1027
+ /**
1028
+ * Delete a reminder from a search.
1029
+ *
1030
+ * @example
1031
+ * await workast.searches.delReminder('search-id');
1032
+ */
1033
+ delReminder(searchId, options) {
1034
+ return this.client.request(
1035
+ "DELETE",
1036
+ `/search/${encodeURIComponent(searchId)}/reminder`,
1037
+ void 0,
1038
+ options
1039
+ );
1040
+ }
1041
+ };
1042
+
1043
+ // src/resources/tags.ts
1044
+ var Tags = class {
1045
+ constructor(client) {
1046
+ this.client = client;
1047
+ }
1048
+ client;
1049
+ /**
1050
+ * List tags in the team.
1051
+ *
1052
+ * @example
1053
+ * const tags = await workast.tags.list({ listId: 'list-id' });
1054
+ */
1055
+ list(query, options) {
1056
+ const params = new URLSearchParams(options?.query);
1057
+ if (query?.listId) {
1058
+ params.set("listId", query.listId);
1059
+ }
1060
+ if (query?.name) {
1061
+ params.set("name", query.name);
1062
+ }
1063
+ return this.client.request(
1064
+ "GET",
1065
+ "/tag",
1066
+ void 0,
1067
+ params.toString() ? { ...options, query: params } : options
1068
+ );
1069
+ }
1070
+ /**
1071
+ * Create a tag.
1072
+ *
1073
+ * @example
1074
+ * const tag = await workast.tags.create({ name: 'Priority', color: '#ff0000' });
1075
+ */
1076
+ create(body, options) {
1077
+ return this.client.request("POST", "/tag", body, options);
1078
+ }
1079
+ /**
1080
+ * Update a tag.
1081
+ *
1082
+ * @example
1083
+ * const tag = await workast.tags.update('tag-id', { name: 'Priority' });
1084
+ */
1085
+ update(tagId, body, options) {
1086
+ return this.client.request(
1087
+ "PATCH",
1088
+ `/tag/${encodeURIComponent(tagId)}`,
1089
+ body,
1090
+ options
1091
+ );
1092
+ }
1093
+ /**
1094
+ * Delete a tag.
1095
+ *
1096
+ * @example
1097
+ * await workast.tags.del('tag-id');
1098
+ */
1099
+ del(tagId, options) {
1100
+ return this.client.request(
1101
+ "DELETE",
1102
+ `/tag/${encodeURIComponent(tagId)}`,
1103
+ void 0,
1104
+ options
1105
+ );
1106
+ }
1107
+ };
1108
+
1109
+ // src/resources/tasks.ts
1110
+ var TaskSubtasks = class {
1111
+ constructor(client) {
1112
+ this.client = client;
1113
+ }
1114
+ client;
1115
+ /**
1116
+ * Create a subtask on a task.
1117
+ *
1118
+ * @example
1119
+ * const subtask = await workast.tasks.subtasks.create('task-id', { text: 'Write tests' });
1120
+ */
1121
+ create(taskId, body, options) {
1122
+ return this.client.request("POST", `/task/${encodeURIComponent(taskId)}/subtask`, body, options);
1123
+ }
1124
+ };
1125
+ var TaskDependencies = class {
1126
+ constructor(client) {
1127
+ this.client = client;
1128
+ }
1129
+ client;
1130
+ /**
1131
+ * Add a dependency to a task.
1132
+ *
1133
+ * @example
1134
+ * await workast.tasks.dependencies.add('task-id', 'dependency-id');
1135
+ */
1136
+ add(taskId, dependencyId, options) {
1137
+ return this.client.request(
1138
+ "POST",
1139
+ `/task/${encodeURIComponent(taskId)}/dependency/${encodeURIComponent(dependencyId)}`,
1140
+ void 0,
1141
+ options
1142
+ );
1143
+ }
1144
+ /**
1145
+ * Remove a dependency from a task.
1146
+ *
1147
+ * @example
1148
+ * await workast.tasks.dependencies.del('task-id', 'dependency-id');
1149
+ */
1150
+ del(taskId, dependencyId, options) {
1151
+ return this.client.request(
1152
+ "DELETE",
1153
+ `/task/${encodeURIComponent(taskId)}/dependency/${encodeURIComponent(dependencyId)}`,
1154
+ void 0,
1155
+ options
1156
+ );
1157
+ }
1158
+ };
1159
+ var TaskAttachments = class {
1160
+ constructor(client) {
1161
+ this.client = client;
1162
+ }
1163
+ client;
1164
+ /**
1165
+ * Create an attachment on a task.
1166
+ *
1167
+ * @example
1168
+ * const attachment = await workast.tasks.attachments.create('task-id', { author: 'user-id' });
1169
+ */
1170
+ create(taskId, body, options) {
1171
+ return this.client.request("POST", `/task/${encodeURIComponent(taskId)}/attachment`, body, options);
1172
+ }
1173
+ /**
1174
+ * Update a task attachment.
1175
+ *
1176
+ * @example
1177
+ * const attachment = await workast.tasks.attachments.update('task-id', 'attachment-id', { date: '2026-01-01' });
1178
+ */
1179
+ update(taskId, attachmentId, body, options) {
1180
+ return this.client.request(
1181
+ "PATCH",
1182
+ `/task/${encodeURIComponent(taskId)}/attachment/${encodeURIComponent(attachmentId)}`,
1183
+ body,
1184
+ options
1185
+ );
1186
+ }
1187
+ /**
1188
+ * Delete a task attachment.
1189
+ *
1190
+ * @example
1191
+ * await workast.tasks.attachments.del('task-id', 'attachment-id');
1192
+ */
1193
+ del(taskId, attachmentId, options) {
1194
+ return this.client.request(
1195
+ "DELETE",
1196
+ `/task/${encodeURIComponent(taskId)}/attachment/${encodeURIComponent(attachmentId)}`,
1197
+ void 0,
1198
+ options
1199
+ );
1200
+ }
1201
+ };
1202
+ var TaskActivitiesResource = class {
1203
+ constructor(client) {
1204
+ this.client = client;
1205
+ }
1206
+ client;
1207
+ /**
1208
+ * List activities on a task.
1209
+ *
1210
+ * @example
1211
+ * const results = await workast.tasks.activities.list('task-id', { type: ['comment'], limit: 10 });
1212
+ */
1213
+ list(taskId, query, options) {
1214
+ const params = new URLSearchParams(options?.query);
1215
+ if (query?.type) {
1216
+ for (const value of query.type) {
1217
+ params.append("type", value);
1218
+ }
1219
+ }
1220
+ if (query?.actorTypes) {
1221
+ for (const value of query.actorTypes) {
1222
+ params.append("actorTypes", value);
1223
+ }
1224
+ }
1225
+ if (query?.limit != null) {
1226
+ params.set("limit", String(query.limit));
1227
+ }
1228
+ if (query?.skip != null) {
1229
+ params.set("skip", String(query.skip));
1230
+ }
1231
+ if (query?.sort) {
1232
+ params.set("sort", query.sort);
1233
+ }
1234
+ return this.client.request(
1235
+ "GET",
1236
+ `/task/${encodeURIComponent(taskId)}/activity`,
1237
+ void 0,
1238
+ params.toString() ? { ...options, query: params } : options
1239
+ );
1240
+ }
1241
+ /**
1242
+ * Create a comment activity on a task.
1243
+ *
1244
+ * @example
1245
+ * const activity = await workast.tasks.activities.create('task-id', { type: 'comment', value: 'Looks good' });
1246
+ */
1247
+ create(taskId, body, options) {
1248
+ return this.client.request("POST", `/task/${encodeURIComponent(taskId)}/activity`, body, options);
1249
+ }
1250
+ /**
1251
+ * Update a task activity.
1252
+ *
1253
+ * @example
1254
+ * await workast.tasks.activities.update('task-id', 'activity-id', { value: 'Updated comment' });
1255
+ */
1256
+ update(taskId, activityId, body, options) {
1257
+ return this.client.request(
1258
+ "PATCH",
1259
+ `/task/${encodeURIComponent(taskId)}/activity/${encodeURIComponent(activityId)}`,
1260
+ body,
1261
+ options
1262
+ );
1263
+ }
1264
+ /**
1265
+ * Delete a task activity.
1266
+ *
1267
+ * @example
1268
+ * await workast.tasks.activities.del('task-id', 'activity-id');
1269
+ */
1270
+ del(taskId, activityId, options) {
1271
+ return this.client.request(
1272
+ "DELETE",
1273
+ `/task/${encodeURIComponent(taskId)}/activity/${encodeURIComponent(activityId)}`,
1274
+ void 0,
1275
+ options
1276
+ );
1277
+ }
1278
+ };
1279
+ var Tasks = class {
1280
+ constructor(client) {
1281
+ this.client = client;
1282
+ this.subtasks = new TaskSubtasks(client);
1283
+ this.dependencies = new TaskDependencies(client);
1284
+ this.attachments = new TaskAttachments(client);
1285
+ this.activities = new TaskActivitiesResource(client);
1286
+ }
1287
+ client;
1288
+ subtasks;
1289
+ dependencies;
1290
+ attachments;
1291
+ activities;
1292
+ /**
1293
+ * Create a task in a list.
1294
+ *
1295
+ * @example
1296
+ * const task = await workast.tasks.create('list-id', { text: 'Ship v3' });
1297
+ */
1298
+ create(listId, body, options) {
1299
+ return this.client.request("POST", `/list/${encodeURIComponent(listId)}/task`, body, options);
1300
+ }
1301
+ /**
1302
+ * Get a task by ID.
1303
+ *
1304
+ * @example
1305
+ * const task = await workast.tasks.retrieve('task-id');
1306
+ */
1307
+ retrieve(taskId, options) {
1308
+ return this.client.request("GET", `/task/${encodeURIComponent(taskId)}`, void 0, options);
1309
+ }
1310
+ /**
1311
+ * Get a task by short ID.
1312
+ *
1313
+ * @example
1314
+ * const task = await workast.tasks.retrieveByShortId('t4k1');
1315
+ */
1316
+ retrieveByShortId(shortId, options) {
1317
+ return this.client.request("GET", `/task/shortid/${encodeURIComponent(shortId)}`, void 0, options);
1318
+ }
1319
+ /**
1320
+ * Update a task.
1321
+ *
1322
+ * @example
1323
+ * await workast.tasks.update('task-id', { text: 'Ship v3' });
1324
+ */
1325
+ update(taskId, body, options) {
1326
+ return this.client.request("PATCH", `/task/${encodeURIComponent(taskId)}`, body, options);
1327
+ }
1328
+ /**
1329
+ * Delete a task.
1330
+ *
1331
+ * @example
1332
+ * await workast.tasks.del('task-id');
1333
+ */
1334
+ del(taskId, options) {
1335
+ return this.client.request("DELETE", `/task/${encodeURIComponent(taskId)}`, void 0, options);
1336
+ }
1337
+ /**
1338
+ * Search tasks.
1339
+ *
1340
+ * @example
1341
+ * const results = await workast.tasks.list({
1342
+ * predicates: [{ type: 'status', attribute: 'status', comparison: 'eq', value: 'pending' }],
1343
+ * });
1344
+ */
1345
+ list(body, options) {
1346
+ return this.client.request("POST", "/task/search", body, options);
1347
+ }
1348
+ /**
1349
+ * Complete a task.
1350
+ *
1351
+ * @example
1352
+ * await workast.tasks.complete('task-id');
1353
+ */
1354
+ complete(taskId, options) {
1355
+ return this.client.request("POST", `/task/${encodeURIComponent(taskId)}/done`, void 0, options);
1356
+ }
1357
+ /**
1358
+ * Uncomplete a task.
1359
+ *
1360
+ * @example
1361
+ * await workast.tasks.uncomplete('task-id');
1362
+ */
1363
+ uncomplete(taskId, options) {
1364
+ return this.client.request("POST", `/task/${encodeURIComponent(taskId)}/undone`, void 0, options);
1365
+ }
1366
+ /**
1367
+ * Assign users to a task.
1368
+ *
1369
+ * @example
1370
+ * await workast.tasks.assign('task-id', { users: ['user-id'] });
1371
+ */
1372
+ assign(taskId, body, options) {
1373
+ return this.client.request("POST", `/task/${encodeURIComponent(taskId)}/assigned`, body, options);
1374
+ }
1375
+ /**
1376
+ * Unassign users from a task.
1377
+ *
1378
+ * @example
1379
+ * await workast.tasks.unassign('task-id', { users: ['user-id'] });
1380
+ */
1381
+ unassign(taskId, body, options) {
1382
+ return this.client.request("DELETE", `/task/${encodeURIComponent(taskId)}/assigned`, body, options);
1383
+ }
1384
+ /**
1385
+ * Add followers to a task.
1386
+ *
1387
+ * @example
1388
+ * await workast.tasks.follow('task-id', { users: ['user-id'] });
1389
+ */
1390
+ follow(taskId, body, options) {
1391
+ return this.client.request("POST", `/task/${encodeURIComponent(taskId)}/follow`, body, options);
1392
+ }
1393
+ /**
1394
+ * Remove followers from a task.
1395
+ *
1396
+ * @example
1397
+ * await workast.tasks.unfollow('task-id', { users: ['user-id'] });
1398
+ */
1399
+ unfollow(taskId, body, options) {
1400
+ return this.client.request("POST", `/task/${encodeURIComponent(taskId)}/unfollow`, body, options);
1401
+ }
1402
+ /**
1403
+ * Move tasks to another list.
1404
+ *
1405
+ * @example
1406
+ * await workast.tasks.move('list-id', { tasks: ['task-id'], target: 'other-list-id' });
1407
+ */
1408
+ move(listId, body, options) {
1409
+ return this.client.request("POST", `/list/${encodeURIComponent(listId)}/move`, body, options);
1410
+ }
1411
+ /**
1412
+ * Create many tasks in a list.
1413
+ *
1414
+ * @example
1415
+ * await workast.tasks.createMany('list-id', [{ text: 'One' }, { text: 'Two' }]);
1416
+ */
1417
+ createMany(listId, body, options) {
1418
+ return this.client.request("POST", `/list/${encodeURIComponent(listId)}/task/bulk`, body, options);
1419
+ }
1420
+ /**
1421
+ * Update many tasks.
1422
+ *
1423
+ * @example
1424
+ * const result = await workast.tasks.updateMany({ tasks: ['task-id'], status: 'done' });
1425
+ */
1426
+ updateMany(body, options) {
1427
+ return this.client.request("PUT", "/task", body, options);
1428
+ }
1429
+ /**
1430
+ * List home (favourite) tasks.
1431
+ *
1432
+ * @example
1433
+ * const home = await workast.tasks.listHome();
1434
+ */
1435
+ listHome(options) {
1436
+ return this.client.request("GET", "/task/home", void 0, options);
1437
+ }
1438
+ /**
1439
+ * Add a task to the home screen.
1440
+ *
1441
+ * @example
1442
+ * await workast.tasks.addHome('task-id');
1443
+ */
1444
+ addHome(taskId, options) {
1445
+ return this.client.request("POST", `/task/${encodeURIComponent(taskId)}/home`, void 0, options);
1446
+ }
1447
+ /**
1448
+ * Remove a task from the home screen.
1449
+ *
1450
+ * @example
1451
+ * await workast.tasks.removeHome('task-id');
1452
+ */
1453
+ removeHome(taskId, options) {
1454
+ return this.client.request("DELETE", `/task/${encodeURIComponent(taskId)}/home`, void 0, options);
1455
+ }
1456
+ /**
1457
+ * Add tags to a task.
1458
+ *
1459
+ * @example
1460
+ * await workast.tasks.addTag('task-id', { tags: ['tag-id'] });
1461
+ */
1462
+ addTag(taskId, body, options) {
1463
+ return this.client.request("POST", `/task/${encodeURIComponent(taskId)}/tag`, body, options);
1464
+ }
1465
+ /**
1466
+ * Remove tags from a task.
1467
+ *
1468
+ * @example
1469
+ * await workast.tasks.removeTag('task-id', { tags: ['tag-id'] });
1470
+ */
1471
+ removeTag(taskId, body, options) {
1472
+ return this.client.request("DELETE", `/task/${encodeURIComponent(taskId)}/tag`, body, options);
1473
+ }
1474
+ /**
1475
+ * Convert a task into a subtask of another task.
1476
+ *
1477
+ * @example
1478
+ * await workast.tasks.convertToSubtask('task-id', { parentTaskId: 'parent-id' });
1479
+ */
1480
+ convertToSubtask(taskId, body, options) {
1481
+ return this.client.request(
1482
+ "POST",
1483
+ `/task/${encodeURIComponent(taskId)}/convert-to-subtask`,
1484
+ body,
1485
+ options
1486
+ );
1487
+ }
1488
+ /**
1489
+ * Convert a subtask into a standalone task.
1490
+ *
1491
+ * @example
1492
+ * const task = await workast.tasks.convertToTask('task-id');
1493
+ */
1494
+ convertToTask(taskId, options) {
1495
+ return this.client.request(
1496
+ "POST",
1497
+ `/task/${encodeURIComponent(taskId)}/convert-to-task`,
1498
+ void 0,
1499
+ options
1500
+ );
1501
+ }
1502
+ };
1503
+
1504
+ // src/resources/tokens.ts
1505
+ var Tokens = class {
1506
+ constructor(client) {
1507
+ this.client = client;
1508
+ }
1509
+ client;
1510
+ /**
1511
+ * Get the token details.
1512
+ *
1513
+ * @example
1514
+ * const token = await workast.tokens.retrieve();
1515
+ */
1516
+ retrieve(options) {
1517
+ return this.client.request("GET", "/me", void 0, options);
1518
+ }
1519
+ };
1520
+
1521
+ // src/resources/users.ts
1522
+ function appendValues(params, key, value) {
1523
+ if (value == null) {
1524
+ return;
1525
+ }
1526
+ if (Array.isArray(value)) {
1527
+ for (const item of value) {
1528
+ params.append(key, item);
1529
+ }
1530
+ return;
1531
+ }
1532
+ params.set(key, value);
1533
+ }
1534
+ var Users = class {
1535
+ constructor(client) {
1536
+ this.client = client;
1537
+ }
1538
+ client;
1539
+ /**
1540
+ * Get the logged-in user.
1541
+ *
1542
+ * @example
1543
+ * const me = await workast.users.me();
1544
+ */
1545
+ me(options) {
1546
+ return this.client.request("GET", "/user/me", void 0, options);
1547
+ }
1548
+ /**
1549
+ * List users in the team.
1550
+ *
1551
+ * @example
1552
+ * const users = await workast.users.list({ name: 'Ada', limit: 10 });
1553
+ */
1554
+ list(query, options) {
1555
+ const params = new URLSearchParams(options?.query);
1556
+ if (query?.name) {
1557
+ params.set("name", query.name);
1558
+ }
1559
+ if (query?.email) {
1560
+ params.set("email", query.email);
1561
+ }
1562
+ appendValues(params, "slackUserId", query?.slackUserId);
1563
+ appendValues(params, "webexUserId", query?.webexUserId);
1564
+ if (query?.random != null) {
1565
+ params.set("random", String(query.random));
1566
+ }
1567
+ appendValues(params, "status", query?.status);
1568
+ appendValues(params, "role", query?.role);
1569
+ if (query?.sort) {
1570
+ params.set("sort", query.sort);
1571
+ }
1572
+ if (query?.limit != null) {
1573
+ params.set("limit", String(query.limit));
1574
+ }
1575
+ if (query?.offset != null) {
1576
+ params.set("offset", String(query.offset));
1577
+ }
1578
+ return this.client.request(
1579
+ "GET",
1580
+ "/user",
1581
+ void 0,
1582
+ params.toString() ? { ...options, query: params } : options
1583
+ );
1584
+ }
1585
+ /**
1586
+ * Get a user by ID.
1587
+ *
1588
+ * @example
1589
+ * const user = await workast.users.retrieve('user-id');
1590
+ */
1591
+ retrieve(userId, options) {
1592
+ return this.client.request("GET", `/user/${encodeURIComponent(userId)}`, void 0, options);
1593
+ }
1594
+ /**
1595
+ * Get a user by email.
1596
+ *
1597
+ * @example
1598
+ * const user = await workast.users.retrieveByEmail('ada@example.com');
1599
+ */
1600
+ retrieveByEmail(email, query, options) {
1601
+ const params = new URLSearchParams(options?.query);
1602
+ if (query?.platform) {
1603
+ params.set("platform", query.platform);
1604
+ }
1605
+ return this.client.request(
1606
+ "GET",
1607
+ `/user/email/${encodeURIComponent(email)}`,
1608
+ void 0,
1609
+ params.toString() ? { ...options, query: params } : options
1610
+ );
1611
+ }
1612
+ /**
1613
+ * Invite a user to the team.
1614
+ *
1615
+ * @example
1616
+ * const user = await workast.users.invite({ name: 'Ada', email: 'ada@example.com', role: 'member' });
1617
+ */
1618
+ invite(body, options) {
1619
+ return this.client.request("POST", "/user/invite", body, options);
1620
+ }
1621
+ };
1622
+
1623
+ // src/resources/workflows.ts
1624
+ function pagingOptions(query, options) {
1625
+ const params = new URLSearchParams(options?.query);
1626
+ if (query?.limit != null) {
1627
+ params.set("limit", String(query.limit));
1628
+ }
1629
+ if (query?.skip != null) {
1630
+ params.set("skip", String(query.skip));
1631
+ }
1632
+ return params.toString() ? { ...options, query: params } : options;
1633
+ }
1634
+ var WorkflowsResource = class {
1635
+ constructor(client) {
1636
+ this.client = client;
1637
+ }
1638
+ client;
1639
+ /**
1640
+ * List workflows created by the logged-in user.
1641
+ *
1642
+ * @example
1643
+ * const results = await workast.workflows.list({ limit: 10, skip: 0 });
1644
+ */
1645
+ list(query, options) {
1646
+ return this.client.request("GET", "/workflow", void 0, pagingOptions(query, options));
1647
+ }
1648
+ /**
1649
+ * Create a workflow.
1650
+ *
1651
+ * @example
1652
+ * const workflow = await workast.workflows.create({
1653
+ * type: 'event',
1654
+ * trigger: 'task_created',
1655
+ * prompt: 'Ship v3',
1656
+ * lists: ['list-id'],
1657
+ * });
1658
+ */
1659
+ create(body, options) {
1660
+ return this.client.request("POST", "/workflow", body, options);
1661
+ }
1662
+ /**
1663
+ * Get a workflow by ID.
1664
+ *
1665
+ * @example
1666
+ * const workflow = await workast.workflows.retrieve('workflow-id');
1667
+ */
1668
+ retrieve(workflowId, options) {
1669
+ return this.client.request(
1670
+ "GET",
1671
+ `/workflow/${encodeURIComponent(workflowId)}`,
1672
+ void 0,
1673
+ options
1674
+ );
1675
+ }
1676
+ /**
1677
+ * Update a workflow.
1678
+ *
1679
+ * @example
1680
+ * await workast.workflows.update('workflow-id', { prompt: 'Ship v3' });
1681
+ */
1682
+ update(workflowId, body, options) {
1683
+ return this.client.request(
1684
+ "PATCH",
1685
+ `/workflow/${encodeURIComponent(workflowId)}`,
1686
+ body,
1687
+ options
1688
+ );
1689
+ }
1690
+ /**
1691
+ * Delete a workflow.
1692
+ *
1693
+ * @example
1694
+ * await workast.workflows.del('workflow-id');
1695
+ */
1696
+ del(workflowId, options) {
1697
+ return this.client.request(
1698
+ "DELETE",
1699
+ `/workflow/${encodeURIComponent(workflowId)}`,
1700
+ void 0,
1701
+ options
1702
+ );
1703
+ }
1704
+ /**
1705
+ * Activate a workflow.
1706
+ *
1707
+ * @example
1708
+ * await workast.workflows.activate('workflow-id');
1709
+ */
1710
+ activate(workflowId, options) {
1711
+ return this.client.request(
1712
+ "PATCH",
1713
+ `/workflow/${encodeURIComponent(workflowId)}/activate`,
1714
+ void 0,
1715
+ options
1716
+ );
1717
+ }
1718
+ /**
1719
+ * Deactivate a workflow.
1720
+ *
1721
+ * @example
1722
+ * await workast.workflows.deactivate('workflow-id');
1723
+ */
1724
+ deactivate(workflowId, options) {
1725
+ return this.client.request(
1726
+ "PATCH",
1727
+ `/workflow/${encodeURIComponent(workflowId)}/deactivate`,
1728
+ void 0,
1729
+ options
1730
+ );
1731
+ }
1732
+ };
1733
+
1734
+ // src/client.ts
1735
+ var DEFAULT_BASE_URL = "https://api.workast.com";
1736
+ var Workast = class _Workast {
1737
+ attachments;
1738
+ calendar;
1739
+ fields;
1740
+ lists;
1741
+ meetings;
1742
+ notes;
1743
+ notifications;
1744
+ reactions;
1745
+ searches;
1746
+ tags;
1747
+ tasks;
1748
+ tokens;
1749
+ users;
1750
+ workflows;
1751
+ apiKey;
1752
+ token;
1753
+ getTokenFn;
1754
+ baseUrl;
1755
+ fetchFn;
1756
+ headers;
1757
+ constructor(options) {
1758
+ const opts = typeof options === "string" ? { apiKey: options } : options;
1759
+ const passedApiKey = typeof options === "string" || "apiKey" in opts;
1760
+ if (typeof window !== "undefined" && passedApiKey) {
1761
+ throw new Error("apiKey cannot be used in a browser. Use token or getToken instead.");
1762
+ }
1763
+ if ("getToken" in opts) {
1764
+ this.getTokenFn = opts.getToken;
1765
+ } else if ("token" in opts) {
1766
+ this.token = opts.token;
1767
+ } else if ("apiKey" in opts) {
1768
+ this.apiKey = opts.apiKey;
1769
+ } else {
1770
+ throw new Error("Missing authentication. Provide apiKey, token, or getToken.");
1771
+ }
1772
+ this.baseUrl = opts.baseUrl ?? DEFAULT_BASE_URL;
1773
+ this.fetchFn = opts.fetch ?? globalThis.fetch.bind(globalThis);
1774
+ this.headers = withoutAuthorization(opts.headers);
1775
+ this.attachments = new Attachments(this);
1776
+ this.calendar = new CalendarResource(this);
1777
+ this.fields = new Fields(this);
1778
+ this.lists = new Lists(this);
1779
+ this.meetings = new MeetingsResource(this);
1780
+ this.notes = new NotesResource(this);
1781
+ this.notifications = new NotificationsResource(this);
1782
+ this.reactions = new Reactions(this);
1783
+ this.searches = new SearchesResource(this);
1784
+ this.tags = new Tags(this);
1785
+ this.tasks = new Tasks(this);
1786
+ this.tokens = new Tokens(this);
1787
+ this.users = new Users(this);
1788
+ this.workflows = new WorkflowsResource(this);
1789
+ }
1790
+ withHeaders(headers) {
1791
+ return new _Workast({
1792
+ ...this.authOptions(),
1793
+ baseUrl: this.baseUrl,
1794
+ fetch: this.fetchFn,
1795
+ headers: { ...this.headers, ...withoutAuthorization(headers) }
1796
+ });
1797
+ }
1798
+ setHeaders(headers) {
1799
+ this.headers = { ...this.headers, ...withoutAuthorization(headers) };
1800
+ }
1801
+ request(method, path, body, options) {
1802
+ return request(this.context(), method, path, body, options);
1803
+ }
1804
+ context() {
1805
+ return {
1806
+ baseUrl: this.baseUrl,
1807
+ headers: this.headers,
1808
+ fetch: this.fetchFn,
1809
+ resolveAuth: () => this.resolveAuth()
1810
+ };
1811
+ }
1812
+ authOptions() {
1813
+ if (this.getTokenFn) {
1814
+ return { getToken: this.getTokenFn };
1815
+ }
1816
+ if (this.token) {
1817
+ return { token: this.token };
1818
+ }
1819
+ if (this.apiKey) {
1820
+ return { apiKey: this.apiKey };
1821
+ }
1822
+ throw new Error("Missing authentication. Provide apiKey, token, or getToken.");
1823
+ }
1824
+ async resolveAuth() {
1825
+ const auth = this.authOptions();
1826
+ if ("getToken" in auth) {
1827
+ return auth.getToken();
1828
+ }
1829
+ if ("token" in auth) {
1830
+ return auth.token;
1831
+ }
1832
+ return auth.apiKey;
1833
+ }
1834
+ };
1835
+ export {
1836
+ ApiError,
1837
+ AuthenticationError,
1838
+ NotFoundError,
1839
+ PermissionError,
1840
+ ValidationError,
1841
+ Workast
1842
+ };
1843
+ //# sourceMappingURL=index.js.map