@workast/sdk 2.3.0 → 3.0.0

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