@hipnation-truth/sdk 0.15.3 → 0.16.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 +90 -2
- package/dist/index.d.ts +90 -2
- package/dist/index.js +121 -2
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +120 -2
- package/dist/index.mjs.map +1 -1
- package/dist/react.d.ts +1432 -33
- package/dist/react.js +164 -17
- package/dist/react.js.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -309,14 +309,72 @@ var ConversationMessagesSubresource = class {
|
|
|
309
309
|
}
|
|
310
310
|
};
|
|
311
311
|
var _ConversationsResource = class _ConversationsResource {
|
|
312
|
-
constructor(apiBaseUrl, apiKey) {
|
|
312
|
+
constructor(apiBaseUrl, apiKey, convex) {
|
|
313
313
|
this.baseUrl = apiBaseUrl;
|
|
314
314
|
this.apiKey = apiKey;
|
|
315
|
+
this.convex = convex != null ? convex : null;
|
|
315
316
|
const post = (path, body) => this.postRequest(path, body);
|
|
316
317
|
this.notes = new ConversationNotesSubresource(post);
|
|
317
318
|
this.tasks = new ConversationTasksSubresource(post);
|
|
318
319
|
this.messages = new ConversationMessagesSubresource(post);
|
|
319
320
|
}
|
|
321
|
+
/**
|
|
322
|
+
* Mark a conversation read for the calling user (zeroes unreadCount,
|
|
323
|
+
* stamps `lastReadAt`). Calls the public Convex `markRead` mutation
|
|
324
|
+
* which enforces self-tenancy on the auth identity.
|
|
325
|
+
*/
|
|
326
|
+
markRead(input) {
|
|
327
|
+
return __async(this, null, function* () {
|
|
328
|
+
if (!this.convex) {
|
|
329
|
+
throw new ConversationsError(
|
|
330
|
+
"/markRead",
|
|
331
|
+
0,
|
|
332
|
+
"ConversationsResource missing Convex client"
|
|
333
|
+
);
|
|
334
|
+
}
|
|
335
|
+
return yield this.convex.mutation(
|
|
336
|
+
"conversations:markRead",
|
|
337
|
+
input
|
|
338
|
+
);
|
|
339
|
+
});
|
|
340
|
+
}
|
|
341
|
+
/**
|
|
342
|
+
* Mark a conversation unread for the calling user (sets unreadCount=1).
|
|
343
|
+
*/
|
|
344
|
+
markUnread(input) {
|
|
345
|
+
return __async(this, null, function* () {
|
|
346
|
+
if (!this.convex) {
|
|
347
|
+
throw new ConversationsError(
|
|
348
|
+
"/markUnread",
|
|
349
|
+
0,
|
|
350
|
+
"ConversationsResource missing Convex client"
|
|
351
|
+
);
|
|
352
|
+
}
|
|
353
|
+
return yield this.convex.mutation(
|
|
354
|
+
"conversations:markUnread",
|
|
355
|
+
input
|
|
356
|
+
);
|
|
357
|
+
});
|
|
358
|
+
}
|
|
359
|
+
/**
|
|
360
|
+
* Zero unread on every conversation the user has reads for, except
|
|
361
|
+
* those whose `providerPhone` is in `excludedProviderPhones`.
|
|
362
|
+
*/
|
|
363
|
+
clearAllUnread(input) {
|
|
364
|
+
return __async(this, null, function* () {
|
|
365
|
+
if (!this.convex) {
|
|
366
|
+
throw new ConversationsError(
|
|
367
|
+
"/clearAllUnread",
|
|
368
|
+
0,
|
|
369
|
+
"ConversationsResource missing Convex client"
|
|
370
|
+
);
|
|
371
|
+
}
|
|
372
|
+
return yield this.convex.mutation(
|
|
373
|
+
"conversations:clearAllUnread",
|
|
374
|
+
input
|
|
375
|
+
);
|
|
376
|
+
});
|
|
377
|
+
}
|
|
320
378
|
postRequest(path, body) {
|
|
321
379
|
return __async(this, null, function* () {
|
|
322
380
|
if (!this.apiKey) {
|
|
@@ -593,6 +651,42 @@ var MessagesResource = class {
|
|
|
593
651
|
this.baseUrl = apiBaseUrl;
|
|
594
652
|
this.apiKey = apiKey;
|
|
595
653
|
}
|
|
654
|
+
/**
|
|
655
|
+
* Get an authenticated URL for a Dialpad voicemail recording.
|
|
656
|
+
*
|
|
657
|
+
* Replaces CommHub's `getAuthenticatedVoicemailUrl` Hasura mutation
|
|
658
|
+
* (which proxied to the legacy NestJS backend). Truth appends the
|
|
659
|
+
* Dialpad API key, follows redirects, strips the key from the final
|
|
660
|
+
* URL, and returns it for client-side audio playback.
|
|
661
|
+
*
|
|
662
|
+
* @param voicemailLink The raw Dialpad voicemail download URL (value
|
|
663
|
+
* of the `voicemail_link` field on the call event row).
|
|
664
|
+
* @returns An object with `url` (clean playback URL) and `expiresAt`
|
|
665
|
+
* (ISO-8601 timestamp, ~5 min from request time, informational only).
|
|
666
|
+
*/
|
|
667
|
+
getVoicemailUrl(voicemailLink) {
|
|
668
|
+
return __async(this, null, function* () {
|
|
669
|
+
const res = yield fetch(
|
|
670
|
+
`${this.baseUrl}/api/conversations/voicemail/url`,
|
|
671
|
+
{
|
|
672
|
+
method: "POST",
|
|
673
|
+
headers: {
|
|
674
|
+
"Content-Type": "application/json",
|
|
675
|
+
Accept: "application/json",
|
|
676
|
+
"X-API-Key": this.apiKey
|
|
677
|
+
},
|
|
678
|
+
body: JSON.stringify({ voicemailLink })
|
|
679
|
+
}
|
|
680
|
+
);
|
|
681
|
+
if (!res.ok) {
|
|
682
|
+
const text = yield res.text().catch(() => "");
|
|
683
|
+
throw new Error(
|
|
684
|
+
`messages.getVoicemailUrl failed (HTTP ${res.status}): ${text.slice(0, 200)}`
|
|
685
|
+
);
|
|
686
|
+
}
|
|
687
|
+
return yield res.json();
|
|
688
|
+
});
|
|
689
|
+
}
|
|
596
690
|
/**
|
|
597
691
|
* End a Dialpad call via the typed oRPC procedure (POST hangup, with
|
|
598
692
|
* 404→`alreadyEnded` so the UI doesn't flash an error on a natural
|
|
@@ -1394,6 +1488,24 @@ var TranslationResource = class {
|
|
|
1394
1488
|
}
|
|
1395
1489
|
};
|
|
1396
1490
|
|
|
1491
|
+
// src/resources/user-settings.ts
|
|
1492
|
+
import { makeFunctionReference } from "convex/server";
|
|
1493
|
+
var upsertNotificationsRef = makeFunctionReference("userSettings:upsertNotifications");
|
|
1494
|
+
var UserSettingsResource = class {
|
|
1495
|
+
constructor(convex) {
|
|
1496
|
+
this.convex = convex;
|
|
1497
|
+
}
|
|
1498
|
+
/**
|
|
1499
|
+
* Upsert notification preferences for a user. Creates the row if it
|
|
1500
|
+
* doesn't exist; patches `notificationsEnabled` + `updatedAt` otherwise.
|
|
1501
|
+
*/
|
|
1502
|
+
updateNotifications(input) {
|
|
1503
|
+
return __async(this, null, function* () {
|
|
1504
|
+
return this.convex.mutation(upsertNotificationsRef, input);
|
|
1505
|
+
});
|
|
1506
|
+
}
|
|
1507
|
+
};
|
|
1508
|
+
|
|
1397
1509
|
// src/tracking/tracker.ts
|
|
1398
1510
|
function generateUuidV7() {
|
|
1399
1511
|
const now = Date.now();
|
|
@@ -1690,7 +1802,12 @@ var TruthClient = class {
|
|
|
1690
1802
|
this.notes = new NotesResource(apiUrl, config.apiKey);
|
|
1691
1803
|
this.physicians = new PhysiciansResource(this.convex);
|
|
1692
1804
|
this.notifications = new NotificationsResource(apiUrl, config.apiKey);
|
|
1693
|
-
this.conversations = new ConversationsResource(
|
|
1805
|
+
this.conversations = new ConversationsResource(
|
|
1806
|
+
apiUrl,
|
|
1807
|
+
config.apiKey,
|
|
1808
|
+
this.convex
|
|
1809
|
+
);
|
|
1810
|
+
this.userSettings = new UserSettingsResource(this.convex);
|
|
1694
1811
|
this._serviceWorkerPath = (_h = config.serviceWorkerPath) != null ? _h : "/truth-sw.js";
|
|
1695
1812
|
if (typeof window !== "undefined" && isWebPushSupported() && config.autoInitServiceWorker !== false) {
|
|
1696
1813
|
this._webPushReady = this.initWebPush();
|
|
@@ -1899,6 +2016,7 @@ export {
|
|
|
1899
2016
|
TranslationError,
|
|
1900
2017
|
TranslationResource,
|
|
1901
2018
|
TruthClient,
|
|
2019
|
+
UserSettingsResource,
|
|
1902
2020
|
generateUuidV7,
|
|
1903
2021
|
isWebPushSupported,
|
|
1904
2022
|
onServiceWorkerMessage,
|