@hipnation-truth/sdk 0.17.2 → 0.19.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.mjs CHANGED
@@ -269,8 +269,9 @@ var ConversationNotesSubresource = class {
269
269
  }
270
270
  };
271
271
  var ConversationTasksSubresource = class {
272
- constructor(post) {
272
+ constructor(post, patch) {
273
273
  this.post = post;
274
+ this.patch = patch;
274
275
  }
275
276
  /** Create a task on a conversation. */
276
277
  create(input) {
@@ -291,6 +292,24 @@ var ConversationTasksSubresource = class {
291
292
  );
292
293
  });
293
294
  }
295
+ /**
296
+ * Update task fields (priority, assignee, description, type). Wraps
297
+ * `PATCH /api/conversations/tasks/{id}` so CommHub doesn't have to
298
+ * direct-fetch for non-status field edits.
299
+ */
300
+ update(input) {
301
+ return __async(this, null, function* () {
302
+ return this.patch(
303
+ `/conversations/tasks/${encodeURIComponent(input.taskId)}`,
304
+ __spreadValues(__spreadValues(__spreadValues(__spreadValues({
305
+ id: input.taskId,
306
+ conversationId: input.conversationId,
307
+ author: input.author,
308
+ description: input.description
309
+ }, input.priority ? { priority: input.priority } : {}), input.status ? { status: input.status } : {}), input.assignee !== void 0 ? { assignee: input.assignee } : {}), input.type !== void 0 ? { type: input.type } : {})
310
+ );
311
+ });
312
+ }
294
313
  };
295
314
  var ConversationMessagesSubresource = class {
296
315
  constructor(post) {
@@ -325,8 +344,9 @@ var _ConversationsResource = class _ConversationsResource {
325
344
  this.apiKey = apiKey;
326
345
  this.convex = convex != null ? convex : null;
327
346
  const post = (path, body) => this.postRequest(path, body);
347
+ const patch = (path, body) => this.patchRequest(path, body);
328
348
  this.notes = new ConversationNotesSubresource(post);
329
- this.tasks = new ConversationTasksSubresource(post);
349
+ this.tasks = new ConversationTasksSubresource(post, patch);
330
350
  this.messages = new ConversationMessagesSubresource(post);
331
351
  }
332
352
  /**
@@ -426,6 +446,56 @@ var _ConversationsResource = class _ConversationsResource {
426
446
  return yield res.json();
427
447
  });
428
448
  }
449
+ /**
450
+ * PATCH variant of `postRequest`. Mirrors the timeout + API-key
451
+ * handling so callers like `tasks.update()` don't need to roll their
452
+ * own fetch. The Truth task router treats unknown methods as 405, so
453
+ * a dedicated PATCH path is required.
454
+ */
455
+ patchRequest(path, body) {
456
+ return __async(this, null, function* () {
457
+ if (!this.apiKey) {
458
+ throw new ConversationsError(
459
+ path,
460
+ 0,
461
+ "Truth API key not configured \u2014 request blocked"
462
+ );
463
+ }
464
+ const controller = new AbortController();
465
+ const timeout = setTimeout(
466
+ () => controller.abort(),
467
+ _ConversationsResource.REQUEST_TIMEOUT_MS
468
+ );
469
+ let res;
470
+ try {
471
+ res = yield fetch(`${this.baseUrl}/api${path}`, {
472
+ method: "PATCH",
473
+ headers: {
474
+ "Content-Type": "application/json",
475
+ Accept: "application/json",
476
+ "X-API-Key": this.apiKey
477
+ },
478
+ body: JSON.stringify(body),
479
+ signal: controller.signal
480
+ });
481
+ } catch (err) {
482
+ const isAbort = err instanceof Error && (err.name === "AbortError" || err.name === "TimeoutError");
483
+ const message = isAbort ? `Conversations ${path} timed out after ${_ConversationsResource.REQUEST_TIMEOUT_MS}ms` : err instanceof Error ? err.message : String(err);
484
+ throw new ConversationsError(path, 0, message);
485
+ } finally {
486
+ clearTimeout(timeout);
487
+ }
488
+ if (!res.ok) {
489
+ const text = yield res.text().catch(() => "");
490
+ throw new ConversationsError(
491
+ path,
492
+ res.status,
493
+ `Conversations ${path} failed: ${text.slice(0, 200)}`
494
+ );
495
+ }
496
+ return yield res.json();
497
+ });
498
+ }
429
499
  };
430
500
  /** 30s upstream timeout — matches NotesResource for consistency. */
431
501
  _ConversationsResource.REQUEST_TIMEOUT_MS = 3e4;
@@ -677,18 +747,15 @@ var MessagesResource = class {
677
747
  */
678
748
  getVoicemailUrl(voicemailLink) {
679
749
  return __async(this, null, function* () {
680
- const res = yield fetch(
681
- `${this.baseUrl}/api/conversations/voicemail/url`,
682
- {
683
- method: "POST",
684
- headers: {
685
- "Content-Type": "application/json",
686
- Accept: "application/json",
687
- "X-API-Key": this.apiKey
688
- },
689
- body: JSON.stringify({ voicemailLink })
690
- }
691
- );
750
+ const res = yield fetch(`${this.baseUrl}/api/conversations/voicemail/url`, {
751
+ method: "POST",
752
+ headers: {
753
+ "Content-Type": "application/json",
754
+ Accept: "application/json",
755
+ "X-API-Key": this.apiKey
756
+ },
757
+ body: JSON.stringify({ voicemailLink })
758
+ });
692
759
  if (!res.ok) {
693
760
  const text = yield res.text().catch(() => "");
694
761
  throw new Error(