ambiguous 0.1.1 → 0.1.2

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.
Files changed (2) hide show
  1. package/dist/index.js +868 -2
  2. package/package.json +1 -3
package/dist/index.js CHANGED
@@ -1,4 +1,10 @@
1
1
  #!/usr/bin/env node
2
+ var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
3
+ get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
4
+ }) : x)(function(x) {
5
+ if (typeof require !== "undefined") return require.apply(this, arguments);
6
+ throw Error('Dynamic require of "' + x + '" is not supported');
7
+ });
2
8
 
3
9
  // src/index.ts
4
10
  import { Command } from "commander";
@@ -98,8 +104,868 @@ function info(msg) {
98
104
  console.error(dim(msg));
99
105
  }
100
106
 
101
- // src/lib/client.ts
102
- import { AmbiguousClient, AmbiguousApiError } from "@ambiguous/api-client";
107
+ // ../../packages/api-client/dist/index.js
108
+ var __require2 = /* @__PURE__ */ ((x) => typeof __require !== "undefined" ? __require : typeof Proxy !== "undefined" ? new Proxy(x, {
109
+ get: (a, b) => (typeof __require !== "undefined" ? __require : a)[b]
110
+ }) : x)(function(x) {
111
+ if (typeof __require !== "undefined") return __require.apply(this, arguments);
112
+ throw Error('Dynamic require of "' + x + '" is not supported');
113
+ });
114
+ var AmbiguousApiError = class extends Error {
115
+ constructor(statusCode, body) {
116
+ super(body.error || `HTTP ${statusCode}`);
117
+ this.statusCode = statusCode;
118
+ this.body = body;
119
+ this.name = "AmbiguousApiError";
120
+ }
121
+ };
122
+ var AmbiguousClient = class {
123
+ baseUrl;
124
+ apiKey;
125
+ token;
126
+ _fetch;
127
+ auth;
128
+ docs;
129
+ sheets;
130
+ slides;
131
+ chat;
132
+ mail;
133
+ drive;
134
+ tasks;
135
+ crm;
136
+ forms;
137
+ calendar;
138
+ wiki;
139
+ admin;
140
+ webhooks;
141
+ constructor(options) {
142
+ this.baseUrl = options.baseUrl.replace(/\/$/, "");
143
+ this.apiKey = options.apiKey;
144
+ this.token = options.token;
145
+ this._fetch = options.fetch ?? globalThis.fetch.bind(globalThis);
146
+ this.auth = new AuthNamespace(this);
147
+ this.docs = new DocsNamespace(this);
148
+ this.sheets = new SheetsNamespace(this);
149
+ this.slides = new SlidesNamespace(this);
150
+ this.chat = new ChatNamespace(this);
151
+ this.mail = new MailNamespace(this);
152
+ this.drive = new DriveNamespace(this);
153
+ this.tasks = new TasksNamespace(this);
154
+ this.crm = new CrmNamespace(this);
155
+ this.forms = new FormsNamespace(this);
156
+ this.calendar = new CalendarNamespace(this);
157
+ this.wiki = new WikiNamespace(this);
158
+ this.admin = new AdminNamespace(this);
159
+ this.webhooks = new WebhooksNamespace(this);
160
+ }
161
+ /** Set the API key after construction */
162
+ setApiKey(key) {
163
+ this.apiKey = key;
164
+ this.token = void 0;
165
+ }
166
+ /** Set the JWT token after construction */
167
+ setToken(token) {
168
+ this.token = token;
169
+ this.apiKey = void 0;
170
+ }
171
+ /** Health check */
172
+ async health() {
173
+ return this.request("GET", "/api/health");
174
+ }
175
+ /** Internal request method — used by all namespaces */
176
+ async request(method, path, body, query) {
177
+ const url = new URL(`${this.baseUrl}${path}`);
178
+ if (query) {
179
+ for (const [k, v] of Object.entries(query)) {
180
+ if (v !== void 0 && v !== null) url.searchParams.set(k, v);
181
+ }
182
+ }
183
+ const headers = {
184
+ "Content-Type": "application/json"
185
+ };
186
+ if (this.apiKey) {
187
+ headers["Authorization"] = `Bearer ${this.apiKey}`;
188
+ } else if (this.token) {
189
+ headers["Authorization"] = `Bearer ${this.token}`;
190
+ }
191
+ const init = { method, headers };
192
+ if (body !== void 0 && method !== "GET") {
193
+ init.body = JSON.stringify(body);
194
+ }
195
+ const res = await this._fetch(url.toString(), init);
196
+ if (!res.ok) {
197
+ const errBody = await res.json().catch(() => ({}));
198
+ throw new AmbiguousApiError(res.status, errBody);
199
+ }
200
+ if (res.status === 204) return void 0;
201
+ return res.json();
202
+ }
203
+ };
204
+ var AuthNamespace = class {
205
+ constructor(client) {
206
+ this.client = client;
207
+ }
208
+ /** Register a human account */
209
+ async registerHuman(params) {
210
+ return this.client.request("POST", "/api/auth/register", { ...params, type: "human" });
211
+ }
212
+ /** Register an agent account */
213
+ async registerAgent(params) {
214
+ return this.client.request("POST", "/api/auth/register", { ...params, type: "agent" });
215
+ }
216
+ /** Login with email and password */
217
+ async login(params) {
218
+ return this.client.request("POST", "/api/auth/login", params);
219
+ }
220
+ /** Get the current user's profile */
221
+ async me() {
222
+ return this.client.request("GET", "/api/users/me");
223
+ }
224
+ };
225
+ var DocsNamespace = class {
226
+ constructor(client) {
227
+ this.client = client;
228
+ }
229
+ /** List user's documents */
230
+ async list(params) {
231
+ return this.client.request("GET", "/api/documents", void 0, { type: params?.type });
232
+ }
233
+ /** Create a document */
234
+ async create(params) {
235
+ return this.client.request("POST", "/api/documents", params);
236
+ }
237
+ /** Get a document by ID (includes comments) */
238
+ async get(id) {
239
+ return this.client.request("GET", `/api/documents/${id}`);
240
+ }
241
+ /** Update a document */
242
+ async update(id, params) {
243
+ return this.client.request("PATCH", `/api/documents/${id}`, params);
244
+ }
245
+ /** Delete a document */
246
+ async delete(id) {
247
+ return this.client.request("DELETE", `/api/documents/${id}`);
248
+ }
249
+ /** List permissions on a document */
250
+ async listPermissions(docId) {
251
+ return this.client.request("GET", `/api/documents/${docId}/permissions`);
252
+ }
253
+ /** Grant or update a permission */
254
+ async setPermission(docId, params) {
255
+ return this.client.request("POST", `/api/documents/${docId}/permissions`, params);
256
+ }
257
+ /** Remove a permission */
258
+ async removePermission(docId, userId) {
259
+ return this.client.request("DELETE", `/api/documents/${docId}/permissions/${userId}`);
260
+ }
261
+ /** List threaded comments */
262
+ async listComments(docId) {
263
+ return this.client.request("GET", `/api/documents/${docId}/comments`);
264
+ }
265
+ /** Add a comment or reply */
266
+ async addComment(docId, params) {
267
+ return this.client.request("POST", `/api/documents/${docId}/comments`, params);
268
+ }
269
+ /** Resolve or unresolve a comment */
270
+ async resolveComment(docId, commentId, resolved) {
271
+ return this.client.request("PATCH", `/api/documents/${docId}/comments/${commentId}`, { resolved });
272
+ }
273
+ /** Delete a comment */
274
+ async deleteComment(docId, commentId) {
275
+ return this.client.request("DELETE", `/api/documents/${docId}/comments/${commentId}`);
276
+ }
277
+ };
278
+ var SheetsNamespace = class {
279
+ constructor(client) {
280
+ this.client = client;
281
+ }
282
+ /** Get sheet data as structured JSON */
283
+ async getData(id) {
284
+ return this.client.request("GET", `/api/sheets/${id}/data`);
285
+ }
286
+ /** Update specific cells */
287
+ async updateCells(id, cells) {
288
+ return this.client.request("PATCH", `/api/sheets/${id}/cells`, { cells });
289
+ }
290
+ /** Add a sheet tab */
291
+ async addTab(id, name) {
292
+ return this.client.request("POST", `/api/sheets/${id}/tabs`, name ? { name } : {});
293
+ }
294
+ /** Rename a sheet tab */
295
+ async renameTab(id, tabName, newName) {
296
+ return this.client.request("PATCH", `/api/sheets/${id}/tabs/${encodeURIComponent(tabName)}`, { name: newName });
297
+ }
298
+ /** Remove a sheet tab */
299
+ async removeTab(id, tabName) {
300
+ return this.client.request("DELETE", `/api/sheets/${id}/tabs/${encodeURIComponent(tabName)}`);
301
+ }
302
+ /** Replace tab data (columns and/or rows) */
303
+ async replaceTabData(id, tabName, data) {
304
+ return this.client.request("PUT", `/api/sheets/${id}/tabs/${encodeURIComponent(tabName)}`, data);
305
+ }
306
+ /** Add a column */
307
+ async addColumn(id, params) {
308
+ return this.client.request("POST", `/api/sheets/${id}/columns`, params);
309
+ }
310
+ /** Remove a column */
311
+ async removeColumn(id, columnId, sheet) {
312
+ return this.client.request("DELETE", `/api/sheets/${id}/columns/${columnId}`, void 0, { sheet });
313
+ }
314
+ /** Add rows */
315
+ async addRows(id, rows, sheet) {
316
+ return this.client.request("POST", `/api/sheets/${id}/rows`, { rows, sheet });
317
+ }
318
+ /** Delete rows by indices */
319
+ async deleteRows(id, indices, sheet) {
320
+ return this.client.request("DELETE", `/api/sheets/${id}/rows`, { indices, sheet });
321
+ }
322
+ };
323
+ var SlidesNamespace = class {
324
+ constructor(client) {
325
+ this.client = client;
326
+ }
327
+ /** List available slide layouts */
328
+ async listLayouts() {
329
+ return this.client.request("GET", "/api/slides/layouts");
330
+ }
331
+ /** Get presentation data */
332
+ async getData(id) {
333
+ return this.client.request("GET", `/api/slides/${id}/data`);
334
+ }
335
+ /** Update a specific slide */
336
+ async updateSlide(id, index, params) {
337
+ return this.client.request("PATCH", `/api/slides/${id}/slides/${index}`, params);
338
+ }
339
+ /** Add a new slide */
340
+ async addSlide(id, params) {
341
+ return this.client.request("POST", `/api/slides/${id}/slides`, params ?? {});
342
+ }
343
+ /** Remove a slide */
344
+ async removeSlide(id, index) {
345
+ return this.client.request("DELETE", `/api/slides/${id}/slides/${index}`);
346
+ }
347
+ /** Reorder slides */
348
+ async reorder(id, order) {
349
+ return this.client.request("PATCH", `/api/slides/${id}/reorder`, { order });
350
+ }
351
+ /** Update deck settings */
352
+ async updateSettings(id, settings) {
353
+ return this.client.request("PATCH", `/api/slides/${id}/settings`, settings);
354
+ }
355
+ };
356
+ var ChatNamespace = class {
357
+ constructor(client) {
358
+ this.client = client;
359
+ }
360
+ /** List user's channels */
361
+ async listChannels() {
362
+ return this.client.request("GET", "/api/channels");
363
+ }
364
+ /** Create a channel */
365
+ async createChannel(params) {
366
+ return this.client.request("POST", "/api/channels", params);
367
+ }
368
+ /** Get channel details */
369
+ async getChannel(id) {
370
+ return this.client.request("GET", `/api/channels/${id}`);
371
+ }
372
+ /** Update channel */
373
+ async updateChannel(id, params) {
374
+ return this.client.request("PATCH", `/api/channels/${id}`, params);
375
+ }
376
+ /** Delete channel */
377
+ async deleteChannel(id) {
378
+ return this.client.request("DELETE", `/api/channels/${id}`);
379
+ }
380
+ /** Add member(s) to a channel */
381
+ async addMembers(channelId, userIds) {
382
+ return this.client.request("POST", `/api/channels/${channelId}/members`, { user_ids: userIds });
383
+ }
384
+ /** Remove a member from a channel */
385
+ async removeMember(channelId, userId) {
386
+ return this.client.request("DELETE", `/api/channels/${channelId}/members/${userId}`);
387
+ }
388
+ /** List messages in a channel */
389
+ async listMessages(channelId, params) {
390
+ return this.client.request("GET", `/api/channels/${channelId}/messages`, void 0, {
391
+ limit: params?.limit?.toString(),
392
+ before: params?.before
393
+ });
394
+ }
395
+ /** Send a message */
396
+ async sendMessage(channelId, params) {
397
+ return this.client.request("POST", `/api/channels/${channelId}/messages`, params);
398
+ }
399
+ /** Edit a message */
400
+ async editMessage(channelId, messageId, content) {
401
+ return this.client.request("PATCH", `/api/channels/${channelId}/messages/${messageId}`, { content });
402
+ }
403
+ /** Delete a message */
404
+ async deleteMessage(channelId, messageId) {
405
+ return this.client.request("DELETE", `/api/channels/${channelId}/messages/${messageId}`);
406
+ }
407
+ /** Add a reaction */
408
+ async addReaction(channelId, messageId, emoji) {
409
+ return this.client.request("POST", `/api/channels/${channelId}/messages/${messageId}/reactions`, { emoji });
410
+ }
411
+ /** Remove a reaction */
412
+ async removeReaction(channelId, messageId, emoji) {
413
+ return this.client.request("DELETE", `/api/channels/${channelId}/messages/${messageId}/reactions/${encodeURIComponent(emoji)}`);
414
+ }
415
+ /** Get thread replies */
416
+ async getThread(channelId, messageId) {
417
+ return this.client.request("GET", `/api/channels/${channelId}/messages/${messageId}/thread`);
418
+ }
419
+ };
420
+ var MailNamespace = class {
421
+ constructor(client) {
422
+ this.client = client;
423
+ }
424
+ /** Send an email */
425
+ async send(params) {
426
+ return this.client.request("POST", "/api/mail/send", params);
427
+ }
428
+ /** List inbox emails */
429
+ async inbox(params) {
430
+ return this.client.request("GET", "/api/mail/inbox", void 0, {
431
+ limit: params?.limit?.toString(),
432
+ offset: params?.offset?.toString(),
433
+ unread: params?.unread !== void 0 ? String(params.unread) : void 0
434
+ });
435
+ }
436
+ /** List sent emails */
437
+ async sent(params) {
438
+ return this.client.request("GET", "/api/mail/sent", void 0, {
439
+ limit: params?.limit?.toString(),
440
+ offset: params?.offset?.toString()
441
+ });
442
+ }
443
+ /** Get a single email (marks as read) */
444
+ async get(id) {
445
+ return this.client.request("GET", `/api/mail/${id}`);
446
+ }
447
+ /** Mark email as read or unread */
448
+ async markRead(id, read) {
449
+ return this.client.request("PATCH", `/api/mail/${id}`, { read });
450
+ }
451
+ /** Delete an email */
452
+ async delete(id) {
453
+ return this.client.request("DELETE", `/api/mail/${id}`);
454
+ }
455
+ };
456
+ var DriveNamespace = class {
457
+ constructor(client) {
458
+ this.client = client;
459
+ }
460
+ /** List files in a folder (or root) */
461
+ async list(params) {
462
+ return this.client.request("GET", "/api/drive", void 0, {
463
+ parent_id: params?.parent_id,
464
+ q: params?.q
465
+ });
466
+ }
467
+ /** Create a folder */
468
+ async createFolder(params) {
469
+ return this.client.request("POST", "/api/drive/folders", params);
470
+ }
471
+ /** Initiate a file upload (returns presigned URL) */
472
+ async initiateUpload(params) {
473
+ return this.client.request("POST", "/api/drive/upload", params);
474
+ }
475
+ /** Get file/folder metadata */
476
+ async get(id) {
477
+ return this.client.request("GET", `/api/drive/${id}`);
478
+ }
479
+ /** Get a presigned download URL */
480
+ async getDownloadUrl(id) {
481
+ return this.client.request("GET", `/api/drive/${id}/download`);
482
+ }
483
+ /** Rename or move a file */
484
+ async update(id, params) {
485
+ return this.client.request("PATCH", `/api/drive/${id}`, params);
486
+ }
487
+ /** Delete a file or folder */
488
+ async delete(id) {
489
+ return this.client.request("DELETE", `/api/drive/${id}`);
490
+ }
491
+ };
492
+ var TasksNamespace = class {
493
+ constructor(client) {
494
+ this.client = client;
495
+ }
496
+ /** List tasks */
497
+ async list(params) {
498
+ return this.client.request("GET", "/api/tasks", void 0, {
499
+ assignee_id: params?.assignee_id,
500
+ creator_id: params?.creator_id,
501
+ status: params?.status,
502
+ priority: params?.priority,
503
+ project_id: params?.project_id,
504
+ parent_task_id: params?.parent_task_id === null ? "null" : params?.parent_task_id,
505
+ limit: params?.limit?.toString(),
506
+ offset: params?.offset?.toString()
507
+ });
508
+ }
509
+ /** Create a task */
510
+ async create(params) {
511
+ return this.client.request("POST", "/api/tasks", params);
512
+ }
513
+ /** Get a task */
514
+ async get(id) {
515
+ return this.client.request("GET", `/api/tasks/${id}`);
516
+ }
517
+ /** Update a task */
518
+ async update(id, params) {
519
+ return this.client.request("PATCH", `/api/tasks/${id}`, params);
520
+ }
521
+ /** Delete a task */
522
+ async delete(id) {
523
+ return this.client.request("DELETE", `/api/tasks/${id}`);
524
+ }
525
+ /** List subtasks of a task */
526
+ async listSubtasks(id) {
527
+ return this.client.request("GET", `/api/tasks/${id}/subtasks`);
528
+ }
529
+ };
530
+ var CrmNamespace = class {
531
+ constructor(client) {
532
+ this.client = client;
533
+ }
534
+ // --- Contacts ---
535
+ /** List contacts */
536
+ async listContacts(params) {
537
+ return this.client.request("GET", "/api/crm/contacts", void 0, {
538
+ type: params?.type,
539
+ lifecycle_stage: params?.lifecycle_stage,
540
+ owner_id: params?.owner_id,
541
+ q: params?.q,
542
+ limit: params?.limit?.toString(),
543
+ offset: params?.offset?.toString()
544
+ });
545
+ }
546
+ /** Create a contact */
547
+ async createContact(params) {
548
+ return this.client.request("POST", "/api/crm/contacts", params);
549
+ }
550
+ /** Get a contact */
551
+ async getContact(id) {
552
+ return this.client.request("GET", `/api/crm/contacts/${id}`);
553
+ }
554
+ /** Update a contact */
555
+ async updateContact(id, params) {
556
+ return this.client.request("PATCH", `/api/crm/contacts/${id}`, params);
557
+ }
558
+ /** Delete a contact */
559
+ async deleteContact(id) {
560
+ return this.client.request("DELETE", `/api/crm/contacts/${id}`);
561
+ }
562
+ /** List activities for a contact */
563
+ async listContactActivities(contactId, params) {
564
+ return this.client.request("GET", `/api/crm/contacts/${contactId}/activities`, void 0, { type: params?.type });
565
+ }
566
+ // --- Deals ---
567
+ /** List deals */
568
+ async listDeals(params) {
569
+ return this.client.request("GET", "/api/crm/deals", void 0, {
570
+ pipeline_id: params?.pipeline_id,
571
+ stage_id: params?.stage_id,
572
+ status: params?.status,
573
+ limit: params?.limit?.toString(),
574
+ offset: params?.offset?.toString()
575
+ });
576
+ }
577
+ /** Create a deal */
578
+ async createDeal(params) {
579
+ return this.client.request("POST", "/api/crm/deals", params);
580
+ }
581
+ /** Get a deal */
582
+ async getDeal(id) {
583
+ return this.client.request("GET", `/api/crm/deals/${id}`);
584
+ }
585
+ /** Update a deal */
586
+ async updateDeal(id, params) {
587
+ return this.client.request("PATCH", `/api/crm/deals/${id}`, params);
588
+ }
589
+ /** Delete a deal */
590
+ async deleteDeal(id) {
591
+ return this.client.request("DELETE", `/api/crm/deals/${id}`);
592
+ }
593
+ // --- Pipelines ---
594
+ /** List pipelines with stages */
595
+ async listPipelines() {
596
+ return this.client.request("GET", "/api/crm/pipelines");
597
+ }
598
+ /** Create a pipeline */
599
+ async createPipeline(params) {
600
+ return this.client.request("POST", "/api/crm/pipelines", params);
601
+ }
602
+ /** Update a pipeline */
603
+ async updatePipeline(id, params) {
604
+ return this.client.request("PATCH", `/api/crm/pipelines/${id}`, params);
605
+ }
606
+ /** Delete a pipeline */
607
+ async deletePipeline(id) {
608
+ return this.client.request("DELETE", `/api/crm/pipelines/${id}`);
609
+ }
610
+ // --- Activities ---
611
+ /** Log an activity */
612
+ async logActivity(params) {
613
+ return this.client.request("POST", "/api/crm/activities", params);
614
+ }
615
+ /** Delete an activity */
616
+ async deleteActivity(id) {
617
+ return this.client.request("DELETE", `/api/crm/activities/${id}`);
618
+ }
619
+ };
620
+ var FormsNamespace = class {
621
+ constructor(client) {
622
+ this.client = client;
623
+ }
624
+ /** List user's forms */
625
+ async list(params) {
626
+ return this.client.request("GET", "/api/forms", void 0, {
627
+ q: params?.q,
628
+ published: params?.published !== void 0 ? String(params.published) : void 0
629
+ });
630
+ }
631
+ /** Create a form */
632
+ async create(params) {
633
+ return this.client.request("POST", "/api/forms", params);
634
+ }
635
+ /** Get a form */
636
+ async get(id) {
637
+ return this.client.request("GET", `/api/forms/${id}`);
638
+ }
639
+ /** Update a form */
640
+ async update(id, params) {
641
+ return this.client.request("PATCH", `/api/forms/${id}`, params);
642
+ }
643
+ /** Delete a form */
644
+ async delete(id) {
645
+ return this.client.request("DELETE", `/api/forms/${id}`);
646
+ }
647
+ /** List form responses */
648
+ async listResponses(formId, params) {
649
+ return this.client.request("GET", `/api/forms/${formId}/responses`, void 0, {
650
+ limit: params?.limit?.toString(),
651
+ offset: params?.offset?.toString()
652
+ });
653
+ }
654
+ /** Get a single response */
655
+ async getResponse(formId, responseId) {
656
+ return this.client.request("GET", `/api/forms/${formId}/responses/${responseId}`);
657
+ }
658
+ /** Delete a response */
659
+ async deleteResponse(formId, responseId) {
660
+ return this.client.request("DELETE", `/api/forms/${formId}/responses/${responseId}`);
661
+ }
662
+ /** Submit a response (public endpoint — uses slug) */
663
+ async submit(slug, data) {
664
+ return this.client.request("POST", `/api/forms/${slug}/submit`, { data });
665
+ }
666
+ };
667
+ var CalendarNamespace = class {
668
+ constructor(client) {
669
+ this.client = client;
670
+ }
671
+ /** List user's calendars */
672
+ async listCalendars() {
673
+ return this.client.request("GET", "/api/calendars");
674
+ }
675
+ /** Create a calendar */
676
+ async createCalendar(params) {
677
+ return this.client.request("POST", "/api/calendars", params);
678
+ }
679
+ /** Update a calendar */
680
+ async updateCalendar(id, params) {
681
+ return this.client.request("PATCH", `/api/calendars/${id}`, params);
682
+ }
683
+ /** Delete a calendar */
684
+ async deleteCalendar(id) {
685
+ return this.client.request("DELETE", `/api/calendars/${id}`);
686
+ }
687
+ /** List events across calendars */
688
+ async listEvents(params) {
689
+ return this.client.request("GET", "/api/calendars/events", void 0, {
690
+ start: params?.start,
691
+ end: params?.end,
692
+ calendar_id: params?.calendar_id
693
+ });
694
+ }
695
+ /** Create an event */
696
+ async createEvent(calendarId, params) {
697
+ return this.client.request("POST", `/api/calendars/${calendarId}/events`, params);
698
+ }
699
+ /** Get an event */
700
+ async getEvent(id) {
701
+ return this.client.request("GET", `/api/calendars/events/${id}`);
702
+ }
703
+ /** Update an event */
704
+ async updateEvent(id, params) {
705
+ return this.client.request("PATCH", `/api/calendars/events/${id}`, params);
706
+ }
707
+ /** Delete an event */
708
+ async deleteEvent(id) {
709
+ return this.client.request("DELETE", `/api/calendars/events/${id}`);
710
+ }
711
+ /** RSVP to an event */
712
+ async rsvp(eventId, status) {
713
+ return this.client.request("POST", `/api/calendars/events/${eventId}/rsvp`, { rsvp: status });
714
+ }
715
+ /** Check free/busy availability */
716
+ async checkAvailability(params) {
717
+ return this.client.request("GET", "/api/calendars/availability", void 0, {
718
+ user_ids: params.user_ids.join(","),
719
+ start: params.start,
720
+ end: params.end
721
+ });
722
+ }
723
+ };
724
+ var WikiNamespace = class {
725
+ constructor(client) {
726
+ this.client = client;
727
+ }
728
+ // --- Spaces ---
729
+ /** List wiki spaces */
730
+ async listSpaces() {
731
+ return this.client.request("GET", "/api/wiki/spaces");
732
+ }
733
+ /** Create a wiki space */
734
+ async createSpace(params) {
735
+ return this.client.request("POST", "/api/wiki/spaces", params);
736
+ }
737
+ /** Get a space with page tree */
738
+ async getSpace(slug) {
739
+ return this.client.request("GET", `/api/wiki/spaces/${slug}`);
740
+ }
741
+ /** Update a space */
742
+ async updateSpace(id, params) {
743
+ return this.client.request("PATCH", `/api/wiki/spaces/${id}`, params);
744
+ }
745
+ /** Delete a space */
746
+ async deleteSpace(id) {
747
+ return this.client.request("DELETE", `/api/wiki/spaces/${id}`);
748
+ }
749
+ // --- Pages ---
750
+ /** Create a page in a space */
751
+ async createPage(spaceId, params) {
752
+ return this.client.request("POST", `/api/wiki/spaces/${spaceId}/pages`, params);
753
+ }
754
+ /** Get a page */
755
+ async getPage(id) {
756
+ return this.client.request("GET", `/api/wiki/pages/${id}`);
757
+ }
758
+ /** Update a page */
759
+ async updatePage(id, params) {
760
+ return this.client.request("PATCH", `/api/wiki/pages/${id}`, params);
761
+ }
762
+ /** Delete a page (and children) */
763
+ async deletePage(id) {
764
+ return this.client.request("DELETE", `/api/wiki/pages/${id}`);
765
+ }
766
+ /** List child pages */
767
+ async listChildren(pageId) {
768
+ return this.client.request("GET", `/api/wiki/pages/${pageId}/children`);
769
+ }
770
+ /** List backlinks */
771
+ async listBacklinks(pageId) {
772
+ return this.client.request("GET", `/api/wiki/pages/${pageId}/backlinks`);
773
+ }
774
+ /** Duplicate a page */
775
+ async duplicatePage(pageId) {
776
+ return this.client.request("POST", `/api/wiki/pages/${pageId}/duplicate`);
777
+ }
778
+ /** Search wiki */
779
+ async search(params) {
780
+ return this.client.request("GET", "/api/wiki/search", void 0, {
781
+ q: params.q,
782
+ space: params.space
783
+ });
784
+ }
785
+ // --- Databases ---
786
+ /** Get a database */
787
+ async getDatabase(id) {
788
+ return this.client.request("GET", `/api/wiki/databases/${id}`);
789
+ }
790
+ /** Update a database schema or views */
791
+ async updateDatabase(id, params) {
792
+ return this.client.request("PATCH", `/api/wiki/databases/${id}`, params);
793
+ }
794
+ /** Create a database in a page */
795
+ async createDatabase(pageId, params) {
796
+ return this.client.request("POST", `/api/wiki/pages/${pageId}/databases`, params);
797
+ }
798
+ /** Create a database row */
799
+ async createRow(databaseId, properties) {
800
+ return this.client.request("POST", `/api/wiki/databases/${databaseId}/rows`, { properties });
801
+ }
802
+ /** Update a database row */
803
+ async updateRow(databaseId, rowId, properties) {
804
+ return this.client.request("PATCH", `/api/wiki/databases/${databaseId}/rows/${rowId}`, { properties });
805
+ }
806
+ /** Delete a database row */
807
+ async deleteRow(databaseId, rowId) {
808
+ return this.client.request("DELETE", `/api/wiki/databases/${databaseId}/rows/${rowId}`);
809
+ }
810
+ /** Query database rows */
811
+ async queryRows(databaseId, params) {
812
+ return this.client.request("GET", `/api/wiki/databases/${databaseId}/query`, void 0, {
813
+ page_size: params?.page_size?.toString(),
814
+ offset: params?.offset?.toString()
815
+ });
816
+ }
817
+ };
818
+ var AdminNamespace = class {
819
+ constructor(client) {
820
+ this.client = client;
821
+ }
822
+ // --- Users ---
823
+ /** List all users */
824
+ async listUsers(params) {
825
+ return this.client.request("GET", "/api/admin/users", void 0, {
826
+ type: params?.type,
827
+ role: params?.role,
828
+ q: params?.q,
829
+ limit: params?.limit?.toString(),
830
+ offset: params?.offset?.toString()
831
+ });
832
+ }
833
+ /** Get user details */
834
+ async getUser(id) {
835
+ return this.client.request("GET", `/api/admin/users/${id}`);
836
+ }
837
+ /** Update user */
838
+ async updateUser(id, params) {
839
+ return this.client.request("PATCH", `/api/admin/users/${id}`, params);
840
+ }
841
+ /** Delete user */
842
+ async deleteUser(id) {
843
+ return this.client.request("DELETE", `/api/admin/users/${id}`);
844
+ }
845
+ /** Assign role to user */
846
+ async assignRole(userId, roleName) {
847
+ return this.client.request("POST", `/api/admin/users/${userId}/roles`, { role: roleName });
848
+ }
849
+ /** Remove role from user */
850
+ async removeRole(userId, roleName) {
851
+ return this.client.request("DELETE", `/api/admin/users/${userId}/roles/${roleName}`);
852
+ }
853
+ // --- Roles ---
854
+ /** List all roles */
855
+ async listRoles() {
856
+ return this.client.request("GET", "/api/admin/roles");
857
+ }
858
+ /** Create a custom role */
859
+ async createRole(params) {
860
+ return this.client.request("POST", "/api/admin/roles", params);
861
+ }
862
+ /** Update a role */
863
+ async updateRole(id, params) {
864
+ return this.client.request("PATCH", `/api/admin/roles/${id}`, params);
865
+ }
866
+ /** Delete a role */
867
+ async deleteRole(id) {
868
+ return this.client.request("DELETE", `/api/admin/roles/${id}`);
869
+ }
870
+ // --- Settings ---
871
+ /** Get workspace settings */
872
+ async getSettings() {
873
+ return this.client.request("GET", "/api/admin/settings");
874
+ }
875
+ /** Update workspace settings */
876
+ async updateSettings(settings) {
877
+ return this.client.request("PATCH", "/api/admin/settings", settings);
878
+ }
879
+ // --- Audit Log ---
880
+ /** Query audit log */
881
+ async queryAuditLog(params) {
882
+ return this.client.request("GET", "/api/admin/audit-log", void 0, {
883
+ user_id: params?.user_id,
884
+ action: params?.action,
885
+ resource_type: params?.resource_type,
886
+ start: params?.start,
887
+ end: params?.end,
888
+ limit: params?.limit?.toString(),
889
+ offset: params?.offset?.toString()
890
+ });
891
+ }
892
+ // --- API Keys ---
893
+ /** List all API keys */
894
+ async listApiKeys(params) {
895
+ return this.client.request("GET", "/api/admin/api-keys", void 0, {
896
+ user_id: params?.user_id
897
+ });
898
+ }
899
+ /** Create an API key */
900
+ async createApiKey(params) {
901
+ return this.client.request("POST", "/api/admin/api-keys", params);
902
+ }
903
+ /** Revoke an API key */
904
+ async revokeApiKey(id) {
905
+ return this.client.request("DELETE", `/api/admin/api-keys/${id}`);
906
+ }
907
+ // --- Usage ---
908
+ /** Get usage statistics */
909
+ async getUsage() {
910
+ return this.client.request("GET", "/api/admin/usage");
911
+ }
912
+ /** Initialize system roles */
913
+ async initRoles() {
914
+ return this.client.request("POST", "/api/admin/init");
915
+ }
916
+ };
917
+ var WebhooksNamespace = class {
918
+ constructor(client) {
919
+ this.client = client;
920
+ }
921
+ /** List user's registered webhooks */
922
+ async list() {
923
+ return this.client.request("GET", "/api/webhooks");
924
+ }
925
+ /** Register a new webhook */
926
+ async create(params) {
927
+ return this.client.request("POST", "/api/webhooks", params);
928
+ }
929
+ /** Get webhook details by ID */
930
+ async get(id) {
931
+ return this.client.request("GET", `/api/webhooks/${id}`);
932
+ }
933
+ /** Update a webhook */
934
+ async update(id, params) {
935
+ return this.client.request("PATCH", `/api/webhooks/${id}`, params);
936
+ }
937
+ /** Delete a webhook */
938
+ async delete(id) {
939
+ return this.client.request("DELETE", `/api/webhooks/${id}`);
940
+ }
941
+ /** Rotate the webhook signing secret */
942
+ async rotateSecret(id) {
943
+ return this.client.request("POST", `/api/webhooks/${id}/rotate-secret`);
944
+ }
945
+ /** List delivery attempts for a webhook */
946
+ async listDeliveries(id, params) {
947
+ const query = params ? {
948
+ limit: params.limit?.toString(),
949
+ offset: params.offset?.toString()
950
+ } : void 0;
951
+ return this.client.request("GET", `/api/webhooks/${id}/deliveries`, void 0, query);
952
+ }
953
+ /** Send a test ping to a webhook */
954
+ async test(id) {
955
+ return this.client.request("POST", `/api/webhooks/${id}/test`);
956
+ }
957
+ /** List available webhook event types */
958
+ async listEventTypes() {
959
+ return this.client.request("GET", "/api/webhooks/event-types");
960
+ }
961
+ /** Verify a webhook signature (static utility) */
962
+ static verifySignature(payload, timestamp, signature, secret) {
963
+ const { createHmac } = __require2("crypto");
964
+ const signatureInput = `${timestamp}.${payload}`;
965
+ const expected = createHmac("sha256", secret).update(signatureInput).digest("hex");
966
+ return `sha256=${expected}` === signature;
967
+ }
968
+ };
103
969
 
104
970
  // src/lib/config.ts
105
971
  import Conf from "conf";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ambiguous",
3
- "version": "0.1.1",
3
+ "version": "0.1.2",
4
4
  "description": "CLI for Ambiguous Workspace — manage docs, tasks, mail, calendar, CRM, and more from the terminal",
5
5
  "type": "module",
6
6
  "bin": {
@@ -23,8 +23,6 @@
23
23
  "clean": "rm -rf dist"
24
24
  },
25
25
  "dependencies": {
26
- "@ambiguous/api-client": "*",
27
- "@ambiguous/shared-types": "*",
28
26
  "chalk": "^5.4.0",
29
27
  "commander": "^13.1.0",
30
28
  "conf": "^13.1.0",