@hipnation-truth/sdk 0.17.2 → 0.18.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.d.mts +30 -1
- package/dist/index.d.ts +30 -1
- package/dist/index.js +81 -14
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +81 -14
- package/dist/index.mjs.map +1 -1
- package/dist/react.d.ts +1296 -1123
- package/dist/react.js +2388 -397
- package/dist/react.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -266,6 +266,19 @@ interface SetConversationTaskStatusInput {
|
|
|
266
266
|
status: ConversationTaskStatus;
|
|
267
267
|
resolvedBy?: string;
|
|
268
268
|
}
|
|
269
|
+
interface UpdateConversationTaskInput {
|
|
270
|
+
taskId: string;
|
|
271
|
+
/** Conversation the task belongs to. Truth requires this on PATCH. */
|
|
272
|
+
conversationId: string;
|
|
273
|
+
/** Required by the Truth task router — see `messages/procedures/tasks.ts`. */
|
|
274
|
+
author: string;
|
|
275
|
+
description: string;
|
|
276
|
+
/** Optional patch fields — pass only the ones you want to change. */
|
|
277
|
+
priority?: ConversationTaskPriority;
|
|
278
|
+
status?: ConversationTaskStatus;
|
|
279
|
+
assignee?: string;
|
|
280
|
+
type?: string;
|
|
281
|
+
}
|
|
269
282
|
interface SendConversationMessageInput {
|
|
270
283
|
fromNumber: string;
|
|
271
284
|
toNumber: string;
|
|
@@ -291,7 +304,8 @@ declare class ConversationNotesSubresource {
|
|
|
291
304
|
}
|
|
292
305
|
declare class ConversationTasksSubresource {
|
|
293
306
|
private readonly post;
|
|
294
|
-
|
|
307
|
+
private readonly patch;
|
|
308
|
+
constructor(post: <T>(path: string, body: unknown) => Promise<T>, patch: <T>(path: string, body: unknown) => Promise<T>);
|
|
295
309
|
/** Create a task on a conversation. */
|
|
296
310
|
create(input: CreateConversationTaskInput): Promise<{
|
|
297
311
|
id: string;
|
|
@@ -300,6 +314,14 @@ declare class ConversationTasksSubresource {
|
|
|
300
314
|
setStatus(input: SetConversationTaskStatusInput): Promise<{
|
|
301
315
|
ok: true;
|
|
302
316
|
}>;
|
|
317
|
+
/**
|
|
318
|
+
* Update task fields (priority, assignee, description, type). Wraps
|
|
319
|
+
* `PATCH /api/conversations/tasks/{id}` so CommHub doesn't have to
|
|
320
|
+
* direct-fetch for non-status field edits.
|
|
321
|
+
*/
|
|
322
|
+
update(input: UpdateConversationTaskInput): Promise<{
|
|
323
|
+
ok: true;
|
|
324
|
+
}>;
|
|
303
325
|
}
|
|
304
326
|
declare class ConversationMessagesSubresource {
|
|
305
327
|
private readonly post;
|
|
@@ -354,6 +376,13 @@ declare class ConversationsResource {
|
|
|
354
376
|
cleared: number;
|
|
355
377
|
}>;
|
|
356
378
|
private postRequest;
|
|
379
|
+
/**
|
|
380
|
+
* PATCH variant of `postRequest`. Mirrors the timeout + API-key
|
|
381
|
+
* handling so callers like `tasks.update()` don't need to roll their
|
|
382
|
+
* own fetch. The Truth task router treats unknown methods as 405, so
|
|
383
|
+
* a dedicated PATCH path is required.
|
|
384
|
+
*/
|
|
385
|
+
private patchRequest;
|
|
357
386
|
}
|
|
358
387
|
|
|
359
388
|
/**
|
package/dist/index.d.ts
CHANGED
|
@@ -266,6 +266,19 @@ interface SetConversationTaskStatusInput {
|
|
|
266
266
|
status: ConversationTaskStatus;
|
|
267
267
|
resolvedBy?: string;
|
|
268
268
|
}
|
|
269
|
+
interface UpdateConversationTaskInput {
|
|
270
|
+
taskId: string;
|
|
271
|
+
/** Conversation the task belongs to. Truth requires this on PATCH. */
|
|
272
|
+
conversationId: string;
|
|
273
|
+
/** Required by the Truth task router — see `messages/procedures/tasks.ts`. */
|
|
274
|
+
author: string;
|
|
275
|
+
description: string;
|
|
276
|
+
/** Optional patch fields — pass only the ones you want to change. */
|
|
277
|
+
priority?: ConversationTaskPriority;
|
|
278
|
+
status?: ConversationTaskStatus;
|
|
279
|
+
assignee?: string;
|
|
280
|
+
type?: string;
|
|
281
|
+
}
|
|
269
282
|
interface SendConversationMessageInput {
|
|
270
283
|
fromNumber: string;
|
|
271
284
|
toNumber: string;
|
|
@@ -291,7 +304,8 @@ declare class ConversationNotesSubresource {
|
|
|
291
304
|
}
|
|
292
305
|
declare class ConversationTasksSubresource {
|
|
293
306
|
private readonly post;
|
|
294
|
-
|
|
307
|
+
private readonly patch;
|
|
308
|
+
constructor(post: <T>(path: string, body: unknown) => Promise<T>, patch: <T>(path: string, body: unknown) => Promise<T>);
|
|
295
309
|
/** Create a task on a conversation. */
|
|
296
310
|
create(input: CreateConversationTaskInput): Promise<{
|
|
297
311
|
id: string;
|
|
@@ -300,6 +314,14 @@ declare class ConversationTasksSubresource {
|
|
|
300
314
|
setStatus(input: SetConversationTaskStatusInput): Promise<{
|
|
301
315
|
ok: true;
|
|
302
316
|
}>;
|
|
317
|
+
/**
|
|
318
|
+
* Update task fields (priority, assignee, description, type). Wraps
|
|
319
|
+
* `PATCH /api/conversations/tasks/{id}` so CommHub doesn't have to
|
|
320
|
+
* direct-fetch for non-status field edits.
|
|
321
|
+
*/
|
|
322
|
+
update(input: UpdateConversationTaskInput): Promise<{
|
|
323
|
+
ok: true;
|
|
324
|
+
}>;
|
|
303
325
|
}
|
|
304
326
|
declare class ConversationMessagesSubresource {
|
|
305
327
|
private readonly post;
|
|
@@ -354,6 +376,13 @@ declare class ConversationsResource {
|
|
|
354
376
|
cleared: number;
|
|
355
377
|
}>;
|
|
356
378
|
private postRequest;
|
|
379
|
+
/**
|
|
380
|
+
* PATCH variant of `postRequest`. Mirrors the timeout + API-key
|
|
381
|
+
* handling so callers like `tasks.update()` don't need to roll their
|
|
382
|
+
* own fetch. The Truth task router treats unknown methods as 405, so
|
|
383
|
+
* a dedicated PATCH path is required.
|
|
384
|
+
*/
|
|
385
|
+
private patchRequest;
|
|
357
386
|
}
|
|
358
387
|
|
|
359
388
|
/**
|
package/dist/index.js
CHANGED
|
@@ -334,8 +334,9 @@ var ConversationNotesSubresource = class {
|
|
|
334
334
|
}
|
|
335
335
|
};
|
|
336
336
|
var ConversationTasksSubresource = class {
|
|
337
|
-
constructor(post) {
|
|
337
|
+
constructor(post, patch) {
|
|
338
338
|
this.post = post;
|
|
339
|
+
this.patch = patch;
|
|
339
340
|
}
|
|
340
341
|
/** Create a task on a conversation. */
|
|
341
342
|
create(input) {
|
|
@@ -356,6 +357,24 @@ var ConversationTasksSubresource = class {
|
|
|
356
357
|
);
|
|
357
358
|
});
|
|
358
359
|
}
|
|
360
|
+
/**
|
|
361
|
+
* Update task fields (priority, assignee, description, type). Wraps
|
|
362
|
+
* `PATCH /api/conversations/tasks/{id}` so CommHub doesn't have to
|
|
363
|
+
* direct-fetch for non-status field edits.
|
|
364
|
+
*/
|
|
365
|
+
update(input) {
|
|
366
|
+
return __async(this, null, function* () {
|
|
367
|
+
return this.patch(
|
|
368
|
+
`/conversations/tasks/${encodeURIComponent(input.taskId)}`,
|
|
369
|
+
__spreadValues(__spreadValues(__spreadValues(__spreadValues({
|
|
370
|
+
id: input.taskId,
|
|
371
|
+
conversationId: input.conversationId,
|
|
372
|
+
author: input.author,
|
|
373
|
+
description: input.description
|
|
374
|
+
}, input.priority ? { priority: input.priority } : {}), input.status ? { status: input.status } : {}), input.assignee !== void 0 ? { assignee: input.assignee } : {}), input.type !== void 0 ? { type: input.type } : {})
|
|
375
|
+
);
|
|
376
|
+
});
|
|
377
|
+
}
|
|
359
378
|
};
|
|
360
379
|
var ConversationMessagesSubresource = class {
|
|
361
380
|
constructor(post) {
|
|
@@ -390,8 +409,9 @@ var _ConversationsResource = class _ConversationsResource {
|
|
|
390
409
|
this.apiKey = apiKey;
|
|
391
410
|
this.convex = convex != null ? convex : null;
|
|
392
411
|
const post = (path, body) => this.postRequest(path, body);
|
|
412
|
+
const patch = (path, body) => this.patchRequest(path, body);
|
|
393
413
|
this.notes = new ConversationNotesSubresource(post);
|
|
394
|
-
this.tasks = new ConversationTasksSubresource(post);
|
|
414
|
+
this.tasks = new ConversationTasksSubresource(post, patch);
|
|
395
415
|
this.messages = new ConversationMessagesSubresource(post);
|
|
396
416
|
}
|
|
397
417
|
/**
|
|
@@ -491,6 +511,56 @@ var _ConversationsResource = class _ConversationsResource {
|
|
|
491
511
|
return yield res.json();
|
|
492
512
|
});
|
|
493
513
|
}
|
|
514
|
+
/**
|
|
515
|
+
* PATCH variant of `postRequest`. Mirrors the timeout + API-key
|
|
516
|
+
* handling so callers like `tasks.update()` don't need to roll their
|
|
517
|
+
* own fetch. The Truth task router treats unknown methods as 405, so
|
|
518
|
+
* a dedicated PATCH path is required.
|
|
519
|
+
*/
|
|
520
|
+
patchRequest(path, body) {
|
|
521
|
+
return __async(this, null, function* () {
|
|
522
|
+
if (!this.apiKey) {
|
|
523
|
+
throw new ConversationsError(
|
|
524
|
+
path,
|
|
525
|
+
0,
|
|
526
|
+
"Truth API key not configured \u2014 request blocked"
|
|
527
|
+
);
|
|
528
|
+
}
|
|
529
|
+
const controller = new AbortController();
|
|
530
|
+
const timeout = setTimeout(
|
|
531
|
+
() => controller.abort(),
|
|
532
|
+
_ConversationsResource.REQUEST_TIMEOUT_MS
|
|
533
|
+
);
|
|
534
|
+
let res;
|
|
535
|
+
try {
|
|
536
|
+
res = yield fetch(`${this.baseUrl}/api${path}`, {
|
|
537
|
+
method: "PATCH",
|
|
538
|
+
headers: {
|
|
539
|
+
"Content-Type": "application/json",
|
|
540
|
+
Accept: "application/json",
|
|
541
|
+
"X-API-Key": this.apiKey
|
|
542
|
+
},
|
|
543
|
+
body: JSON.stringify(body),
|
|
544
|
+
signal: controller.signal
|
|
545
|
+
});
|
|
546
|
+
} catch (err) {
|
|
547
|
+
const isAbort = err instanceof Error && (err.name === "AbortError" || err.name === "TimeoutError");
|
|
548
|
+
const message = isAbort ? `Conversations ${path} timed out after ${_ConversationsResource.REQUEST_TIMEOUT_MS}ms` : err instanceof Error ? err.message : String(err);
|
|
549
|
+
throw new ConversationsError(path, 0, message);
|
|
550
|
+
} finally {
|
|
551
|
+
clearTimeout(timeout);
|
|
552
|
+
}
|
|
553
|
+
if (!res.ok) {
|
|
554
|
+
const text = yield res.text().catch(() => "");
|
|
555
|
+
throw new ConversationsError(
|
|
556
|
+
path,
|
|
557
|
+
res.status,
|
|
558
|
+
`Conversations ${path} failed: ${text.slice(0, 200)}`
|
|
559
|
+
);
|
|
560
|
+
}
|
|
561
|
+
return yield res.json();
|
|
562
|
+
});
|
|
563
|
+
}
|
|
494
564
|
};
|
|
495
565
|
/** 30s upstream timeout — matches NotesResource for consistency. */
|
|
496
566
|
_ConversationsResource.REQUEST_TIMEOUT_MS = 3e4;
|
|
@@ -742,18 +812,15 @@ var MessagesResource = class {
|
|
|
742
812
|
*/
|
|
743
813
|
getVoicemailUrl(voicemailLink) {
|
|
744
814
|
return __async(this, null, function* () {
|
|
745
|
-
const res = yield fetch(
|
|
746
|
-
|
|
747
|
-
{
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
body: JSON.stringify({ voicemailLink })
|
|
755
|
-
}
|
|
756
|
-
);
|
|
815
|
+
const res = yield fetch(`${this.baseUrl}/api/conversations/voicemail/url`, {
|
|
816
|
+
method: "POST",
|
|
817
|
+
headers: {
|
|
818
|
+
"Content-Type": "application/json",
|
|
819
|
+
Accept: "application/json",
|
|
820
|
+
"X-API-Key": this.apiKey
|
|
821
|
+
},
|
|
822
|
+
body: JSON.stringify({ voicemailLink })
|
|
823
|
+
});
|
|
757
824
|
if (!res.ok) {
|
|
758
825
|
const text = yield res.text().catch(() => "");
|
|
759
826
|
throw new Error(
|