@workast/sdk 3.0.0 → 3.2.0

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