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