@hipnation-truth/sdk 0.15.3 → 0.16.1

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 CHANGED
@@ -1,3 +1,4 @@
1
+ import * as convex_browser from 'convex/browser';
1
2
  import { ConvexHttpClient } from 'convex/browser';
2
3
 
3
4
  /**
@@ -320,7 +321,38 @@ declare class ConversationsResource {
320
321
  private static readonly REQUEST_TIMEOUT_MS;
321
322
  private readonly baseUrl;
322
323
  private readonly apiKey;
323
- constructor(apiBaseUrl: string, apiKey: string);
324
+ private readonly convex;
325
+ constructor(apiBaseUrl: string, apiKey: string, convex?: convex_browser.ConvexHttpClient);
326
+ /**
327
+ * Mark a conversation read for the calling user (zeroes unreadCount,
328
+ * stamps `lastReadAt`). Calls the public Convex `markRead` mutation
329
+ * which enforces self-tenancy on the auth identity.
330
+ */
331
+ markRead(input: {
332
+ conversationId: string;
333
+ userId: string;
334
+ }): Promise<{
335
+ ok: true;
336
+ }>;
337
+ /**
338
+ * Mark a conversation unread for the calling user (sets unreadCount=1).
339
+ */
340
+ markUnread(input: {
341
+ conversationId: string;
342
+ userId: string;
343
+ }): Promise<{
344
+ updated: true;
345
+ }>;
346
+ /**
347
+ * Zero unread on every conversation the user has reads for, except
348
+ * those whose `providerPhone` is in `excludedProviderPhones`.
349
+ */
350
+ clearAllUnread(input: {
351
+ userId: string;
352
+ excludedProviderPhones?: string[];
353
+ }): Promise<{
354
+ cleared: number;
355
+ }>;
324
356
  private postRequest;
325
357
  }
326
358
 
@@ -440,6 +472,23 @@ declare class MessagesResource {
440
472
  private readonly baseUrl;
441
473
  private readonly apiKey;
442
474
  constructor(apiBaseUrl: string, apiKey: string);
475
+ /**
476
+ * Get an authenticated URL for a Dialpad voicemail recording.
477
+ *
478
+ * Replaces CommHub's `getAuthenticatedVoicemailUrl` Hasura mutation
479
+ * (which proxied to the legacy NestJS backend). Truth appends the
480
+ * Dialpad API key, follows redirects, strips the key from the final
481
+ * URL, and returns it for client-side audio playback.
482
+ *
483
+ * @param voicemailLink The raw Dialpad voicemail download URL (value
484
+ * of the `voicemail_link` field on the call event row).
485
+ * @returns An object with `url` (clean playback URL) and `expiresAt`
486
+ * (ISO-8601 timestamp, ~5 min from request time, informational only).
487
+ */
488
+ getVoicemailUrl(voicemailLink: string): Promise<{
489
+ url: string;
490
+ expiresAt: string;
491
+ }>;
443
492
  /**
444
493
  * End a Dialpad call via the typed oRPC procedure (POST hangup, with
445
494
  * 404→`alreadyEnded` so the UI doesn't flash an error on a natural
@@ -1085,6 +1134,43 @@ declare class TranslationResource {
1085
1134
  detect(text: string): Promise<DetectionResult>;
1086
1135
  }
1087
1136
 
1137
+ /**
1138
+ * UserSettingsResource — typed client for the Truth `userSettings` Convex
1139
+ * table. Exposes the one mutation CommHub's Settings screen needs:
1140
+ * `updateNotifications({ userId, notificationsEnabled })`.
1141
+ *
1142
+ * Server-side / imperative use:
1143
+ * truth.userSettings.updateNotifications({ userId, notificationsEnabled: true })
1144
+ *
1145
+ * Reactive React use lives in `@hipnation-truth/sdk/react` via
1146
+ * `useUserSettings`.
1147
+ */
1148
+
1149
+ interface UserSettings {
1150
+ _id: string;
1151
+ userId: string;
1152
+ notificationsEnabled: boolean;
1153
+ createdAt: string;
1154
+ updatedAt: string;
1155
+ }
1156
+ interface UpdateNotificationsInput {
1157
+ userId: string;
1158
+ notificationsEnabled: boolean;
1159
+ }
1160
+ interface UpdateNotificationsResult {
1161
+ action: "inserted" | "updated";
1162
+ id: string;
1163
+ }
1164
+ declare class UserSettingsResource {
1165
+ private readonly convex;
1166
+ constructor(convex: ConvexHttpClient);
1167
+ /**
1168
+ * Upsert notification preferences for a user. Creates the row if it
1169
+ * doesn't exist; patches `notificationsEnabled` + `updatedAt` otherwise.
1170
+ */
1171
+ updateNotifications(input: UpdateNotificationsInput): Promise<UpdateNotificationsResult>;
1172
+ }
1173
+
1088
1174
  /**
1089
1175
  * Typed event definitions for the Truth Platform event store.
1090
1176
  *
@@ -1476,6 +1562,8 @@ declare class TruthClient {
1476
1562
  readonly notifications: NotificationsResource;
1477
1563
  /** Conversation-tied writes — notes, tasks, outbound messages. */
1478
1564
  readonly conversations: ConversationsResource;
1565
+ /** User settings — notification preferences (Convex-backed) */
1566
+ readonly userSettings: UserSettingsResource;
1479
1567
  private readonly convex;
1480
1568
  private readonly tracker;
1481
1569
  private _vapidPublicKey;
@@ -1631,4 +1719,4 @@ declare function subscriptionToJSON(sub: PushSubscription): {
1631
1719
  };
1632
1720
  declare function onServiceWorkerMessage(type: string, callback: (payload: unknown) => void): () => void;
1633
1721
 
1634
- export { AUTH_EVENTS, type ActorContext, type Appointment, type AppointmentListOptions, AppointmentResource, type Attachment, AttachmentsError, AttachmentsResource, type AuthEventType, type AuthLoginFailedPayload, type AuthLoginSucceededPayload, CALL_EVENTS, CONVERSATION_EVENTS, type CallConnectedPayload, type CallEndedPayload, type CallEventType, type CallInitiatedPayload, type CallMissedPayload, type CallStatusResponse, type CancelScheduledNotificationResult, type ConversationAddress, type ConversationAttachmentDownloadedPayload, type ConversationAttachmentUploadedPayload, type ConversationCreatedPayload, type ConversationEventType, type ConversationMarkedReadPayload, type ConversationMessageReceivedPayload, type ConversationMessageSentPayload, type ConversationTaskPriority, type ConversationTaskStatus, ConversationsError, ConversationsResource, type CreateConversationNoteInput, type CreateConversationTaskInput, type CreateTaskInput, type CreateUploadUrlInput, type CreateUploadUrlResult, type DetectionResult, type DialpadNumberInfo, DialpadProxyError, DialpadResource, type DialpadUser, ENVIRONMENTS, EVENT_TYPES, EhrProviderProxy, EhrProxyError, EhrResource, type Environment, type EventActor, type EventCompliance, type EventEnvelope, type EventPayloadMap, type EventSubject, type EventType, type GetDownloadUrlResult, type InitiateCallResponse, MessagesResource, NOTIFICATION_EVENTS, type NonVisitNoteBullet, NotesError, NotesResource, type NotificationDeliveredPayload, type NotificationEventType, type NotificationOpenedPayload, type NotificationPlatform, type NotificationPreferences, type NotificationSentPayload, NotificationsError, NotificationsResource, PROVIDER_EVENTS, type PaginatedResult, type Patient, type PatientBasicDetailsResult, PatientDetailsError, type PatientDetailsInput, PatientDetailsResource, type PatientDetailsResult, type PatientListOptions, type PatientMedicalDetailsResult, PatientResource, type Physician, PhysiciansResource, type ProviderEventType, type ProviderSyncFailedPayload, type ProviderSyncStartedPayload, type ProviderSyncSucceededPayload, type PushEventPayload, type PushNoteToElationInput, type PushNoteToElationResult, REMINDER_EVENTS, type RecordAttachmentInput, type RegisterDeviceInput, type RegisterDeviceResult, type Reminder, type ReminderEventType, type ReminderScheduledPayload, type ReminderStatus, type ReminderTriggeredPayload, RemindersResource, SECURITY_EVENTS, type ScheduleNotificationInput, type ScheduleNotificationResult, type ScheduleReminderInput, type ScheduleReminderResult, type ScheduledJobStatus, type ScheduledNotification, type SecurityAccessDeniedPayload, type SecurityEventType, type SendConversationMessageInput, type SendConversationMessageResult, type SendNotificationInput, type SendNotificationResult, type SendSmsParams, type SendSmsResponse, type SetConversationTaskStatusInput, TASK_EVENTS, TRANSLATION_EVENTS, type Task, type TaskAssignedPayload, type TaskCreatedPayload, type TaskEventType, type TaskStatus, type TaskStatusChangedPayload, TasksResource, type TrackOptions, Tracker, type TranslateBatchInput, type TranslateTextInput, type TranslationCompletedPayload, TranslationError, type TranslationEventType, type TranslationRequestedPayload, TranslationResource, type TranslationResult, TruthClient, type TruthClientConfig, type UnregisterDeviceInput, type UpdatePreferencesInput, type UpdateTaskStatusInput, type VoicemailAuthResponse, type WebPushConfig, generateUuidV7, isWebPushSupported, onServiceWorkerMessage, registerServiceWorker, subscribeToPush, subscriptionToJSON };
1722
+ export { AUTH_EVENTS, type ActorContext, type Appointment, type AppointmentListOptions, AppointmentResource, type Attachment, AttachmentsError, AttachmentsResource, type AuthEventType, type AuthLoginFailedPayload, type AuthLoginSucceededPayload, CALL_EVENTS, CONVERSATION_EVENTS, type CallConnectedPayload, type CallEndedPayload, type CallEventType, type CallInitiatedPayload, type CallMissedPayload, type CallStatusResponse, type CancelScheduledNotificationResult, type ConversationAddress, type ConversationAttachmentDownloadedPayload, type ConversationAttachmentUploadedPayload, type ConversationCreatedPayload, type ConversationEventType, type ConversationMarkedReadPayload, type ConversationMessageReceivedPayload, type ConversationMessageSentPayload, type ConversationTaskPriority, type ConversationTaskStatus, ConversationsError, ConversationsResource, type CreateConversationNoteInput, type CreateConversationTaskInput, type CreateTaskInput, type CreateUploadUrlInput, type CreateUploadUrlResult, type DetectionResult, type DialpadNumberInfo, DialpadProxyError, DialpadResource, type DialpadUser, ENVIRONMENTS, EVENT_TYPES, EhrProviderProxy, EhrProxyError, EhrResource, type Environment, type EventActor, type EventCompliance, type EventEnvelope, type EventPayloadMap, type EventSubject, type EventType, type GetDownloadUrlResult, type InitiateCallResponse, MessagesResource, NOTIFICATION_EVENTS, type NonVisitNoteBullet, NotesError, NotesResource, type NotificationDeliveredPayload, type NotificationEventType, type NotificationOpenedPayload, type NotificationPlatform, type NotificationPreferences, type NotificationSentPayload, NotificationsError, NotificationsResource, PROVIDER_EVENTS, type PaginatedResult, type Patient, type PatientBasicDetailsResult, PatientDetailsError, type PatientDetailsInput, PatientDetailsResource, type PatientDetailsResult, type PatientListOptions, type PatientMedicalDetailsResult, PatientResource, type Physician, PhysiciansResource, type ProviderEventType, type ProviderSyncFailedPayload, type ProviderSyncStartedPayload, type ProviderSyncSucceededPayload, type PushEventPayload, type PushNoteToElationInput, type PushNoteToElationResult, REMINDER_EVENTS, type RecordAttachmentInput, type RegisterDeviceInput, type RegisterDeviceResult, type Reminder, type ReminderEventType, type ReminderScheduledPayload, type ReminderStatus, type ReminderTriggeredPayload, RemindersResource, SECURITY_EVENTS, type ScheduleNotificationInput, type ScheduleNotificationResult, type ScheduleReminderInput, type ScheduleReminderResult, type ScheduledJobStatus, type ScheduledNotification, type SecurityAccessDeniedPayload, type SecurityEventType, type SendConversationMessageInput, type SendConversationMessageResult, type SendNotificationInput, type SendNotificationResult, type SendSmsParams, type SendSmsResponse, type SetConversationTaskStatusInput, TASK_EVENTS, TRANSLATION_EVENTS, type Task, type TaskAssignedPayload, type TaskCreatedPayload, type TaskEventType, type TaskStatus, type TaskStatusChangedPayload, TasksResource, type TrackOptions, Tracker, type TranslateBatchInput, type TranslateTextInput, type TranslationCompletedPayload, TranslationError, type TranslationEventType, type TranslationRequestedPayload, TranslationResource, type TranslationResult, TruthClient, type TruthClientConfig, type UnregisterDeviceInput, type UpdateNotificationsInput, type UpdateNotificationsResult, type UpdatePreferencesInput, type UpdateTaskStatusInput, type UserSettings, UserSettingsResource, type VoicemailAuthResponse, type WebPushConfig, generateUuidV7, isWebPushSupported, onServiceWorkerMessage, registerServiceWorker, subscribeToPush, subscriptionToJSON };
package/dist/index.d.ts CHANGED
@@ -1,3 +1,4 @@
1
+ import * as convex_browser from 'convex/browser';
1
2
  import { ConvexHttpClient } from 'convex/browser';
2
3
 
3
4
  /**
@@ -320,7 +321,38 @@ declare class ConversationsResource {
320
321
  private static readonly REQUEST_TIMEOUT_MS;
321
322
  private readonly baseUrl;
322
323
  private readonly apiKey;
323
- constructor(apiBaseUrl: string, apiKey: string);
324
+ private readonly convex;
325
+ constructor(apiBaseUrl: string, apiKey: string, convex?: convex_browser.ConvexHttpClient);
326
+ /**
327
+ * Mark a conversation read for the calling user (zeroes unreadCount,
328
+ * stamps `lastReadAt`). Calls the public Convex `markRead` mutation
329
+ * which enforces self-tenancy on the auth identity.
330
+ */
331
+ markRead(input: {
332
+ conversationId: string;
333
+ userId: string;
334
+ }): Promise<{
335
+ ok: true;
336
+ }>;
337
+ /**
338
+ * Mark a conversation unread for the calling user (sets unreadCount=1).
339
+ */
340
+ markUnread(input: {
341
+ conversationId: string;
342
+ userId: string;
343
+ }): Promise<{
344
+ updated: true;
345
+ }>;
346
+ /**
347
+ * Zero unread on every conversation the user has reads for, except
348
+ * those whose `providerPhone` is in `excludedProviderPhones`.
349
+ */
350
+ clearAllUnread(input: {
351
+ userId: string;
352
+ excludedProviderPhones?: string[];
353
+ }): Promise<{
354
+ cleared: number;
355
+ }>;
324
356
  private postRequest;
325
357
  }
326
358
 
@@ -440,6 +472,23 @@ declare class MessagesResource {
440
472
  private readonly baseUrl;
441
473
  private readonly apiKey;
442
474
  constructor(apiBaseUrl: string, apiKey: string);
475
+ /**
476
+ * Get an authenticated URL for a Dialpad voicemail recording.
477
+ *
478
+ * Replaces CommHub's `getAuthenticatedVoicemailUrl` Hasura mutation
479
+ * (which proxied to the legacy NestJS backend). Truth appends the
480
+ * Dialpad API key, follows redirects, strips the key from the final
481
+ * URL, and returns it for client-side audio playback.
482
+ *
483
+ * @param voicemailLink The raw Dialpad voicemail download URL (value
484
+ * of the `voicemail_link` field on the call event row).
485
+ * @returns An object with `url` (clean playback URL) and `expiresAt`
486
+ * (ISO-8601 timestamp, ~5 min from request time, informational only).
487
+ */
488
+ getVoicemailUrl(voicemailLink: string): Promise<{
489
+ url: string;
490
+ expiresAt: string;
491
+ }>;
443
492
  /**
444
493
  * End a Dialpad call via the typed oRPC procedure (POST hangup, with
445
494
  * 404→`alreadyEnded` so the UI doesn't flash an error on a natural
@@ -1085,6 +1134,43 @@ declare class TranslationResource {
1085
1134
  detect(text: string): Promise<DetectionResult>;
1086
1135
  }
1087
1136
 
1137
+ /**
1138
+ * UserSettingsResource — typed client for the Truth `userSettings` Convex
1139
+ * table. Exposes the one mutation CommHub's Settings screen needs:
1140
+ * `updateNotifications({ userId, notificationsEnabled })`.
1141
+ *
1142
+ * Server-side / imperative use:
1143
+ * truth.userSettings.updateNotifications({ userId, notificationsEnabled: true })
1144
+ *
1145
+ * Reactive React use lives in `@hipnation-truth/sdk/react` via
1146
+ * `useUserSettings`.
1147
+ */
1148
+
1149
+ interface UserSettings {
1150
+ _id: string;
1151
+ userId: string;
1152
+ notificationsEnabled: boolean;
1153
+ createdAt: string;
1154
+ updatedAt: string;
1155
+ }
1156
+ interface UpdateNotificationsInput {
1157
+ userId: string;
1158
+ notificationsEnabled: boolean;
1159
+ }
1160
+ interface UpdateNotificationsResult {
1161
+ action: "inserted" | "updated";
1162
+ id: string;
1163
+ }
1164
+ declare class UserSettingsResource {
1165
+ private readonly convex;
1166
+ constructor(convex: ConvexHttpClient);
1167
+ /**
1168
+ * Upsert notification preferences for a user. Creates the row if it
1169
+ * doesn't exist; patches `notificationsEnabled` + `updatedAt` otherwise.
1170
+ */
1171
+ updateNotifications(input: UpdateNotificationsInput): Promise<UpdateNotificationsResult>;
1172
+ }
1173
+
1088
1174
  /**
1089
1175
  * Typed event definitions for the Truth Platform event store.
1090
1176
  *
@@ -1476,6 +1562,8 @@ declare class TruthClient {
1476
1562
  readonly notifications: NotificationsResource;
1477
1563
  /** Conversation-tied writes — notes, tasks, outbound messages. */
1478
1564
  readonly conversations: ConversationsResource;
1565
+ /** User settings — notification preferences (Convex-backed) */
1566
+ readonly userSettings: UserSettingsResource;
1479
1567
  private readonly convex;
1480
1568
  private readonly tracker;
1481
1569
  private _vapidPublicKey;
@@ -1631,4 +1719,4 @@ declare function subscriptionToJSON(sub: PushSubscription): {
1631
1719
  };
1632
1720
  declare function onServiceWorkerMessage(type: string, callback: (payload: unknown) => void): () => void;
1633
1721
 
1634
- export { AUTH_EVENTS, type ActorContext, type Appointment, type AppointmentListOptions, AppointmentResource, type Attachment, AttachmentsError, AttachmentsResource, type AuthEventType, type AuthLoginFailedPayload, type AuthLoginSucceededPayload, CALL_EVENTS, CONVERSATION_EVENTS, type CallConnectedPayload, type CallEndedPayload, type CallEventType, type CallInitiatedPayload, type CallMissedPayload, type CallStatusResponse, type CancelScheduledNotificationResult, type ConversationAddress, type ConversationAttachmentDownloadedPayload, type ConversationAttachmentUploadedPayload, type ConversationCreatedPayload, type ConversationEventType, type ConversationMarkedReadPayload, type ConversationMessageReceivedPayload, type ConversationMessageSentPayload, type ConversationTaskPriority, type ConversationTaskStatus, ConversationsError, ConversationsResource, type CreateConversationNoteInput, type CreateConversationTaskInput, type CreateTaskInput, type CreateUploadUrlInput, type CreateUploadUrlResult, type DetectionResult, type DialpadNumberInfo, DialpadProxyError, DialpadResource, type DialpadUser, ENVIRONMENTS, EVENT_TYPES, EhrProviderProxy, EhrProxyError, EhrResource, type Environment, type EventActor, type EventCompliance, type EventEnvelope, type EventPayloadMap, type EventSubject, type EventType, type GetDownloadUrlResult, type InitiateCallResponse, MessagesResource, NOTIFICATION_EVENTS, type NonVisitNoteBullet, NotesError, NotesResource, type NotificationDeliveredPayload, type NotificationEventType, type NotificationOpenedPayload, type NotificationPlatform, type NotificationPreferences, type NotificationSentPayload, NotificationsError, NotificationsResource, PROVIDER_EVENTS, type PaginatedResult, type Patient, type PatientBasicDetailsResult, PatientDetailsError, type PatientDetailsInput, PatientDetailsResource, type PatientDetailsResult, type PatientListOptions, type PatientMedicalDetailsResult, PatientResource, type Physician, PhysiciansResource, type ProviderEventType, type ProviderSyncFailedPayload, type ProviderSyncStartedPayload, type ProviderSyncSucceededPayload, type PushEventPayload, type PushNoteToElationInput, type PushNoteToElationResult, REMINDER_EVENTS, type RecordAttachmentInput, type RegisterDeviceInput, type RegisterDeviceResult, type Reminder, type ReminderEventType, type ReminderScheduledPayload, type ReminderStatus, type ReminderTriggeredPayload, RemindersResource, SECURITY_EVENTS, type ScheduleNotificationInput, type ScheduleNotificationResult, type ScheduleReminderInput, type ScheduleReminderResult, type ScheduledJobStatus, type ScheduledNotification, type SecurityAccessDeniedPayload, type SecurityEventType, type SendConversationMessageInput, type SendConversationMessageResult, type SendNotificationInput, type SendNotificationResult, type SendSmsParams, type SendSmsResponse, type SetConversationTaskStatusInput, TASK_EVENTS, TRANSLATION_EVENTS, type Task, type TaskAssignedPayload, type TaskCreatedPayload, type TaskEventType, type TaskStatus, type TaskStatusChangedPayload, TasksResource, type TrackOptions, Tracker, type TranslateBatchInput, type TranslateTextInput, type TranslationCompletedPayload, TranslationError, type TranslationEventType, type TranslationRequestedPayload, TranslationResource, type TranslationResult, TruthClient, type TruthClientConfig, type UnregisterDeviceInput, type UpdatePreferencesInput, type UpdateTaskStatusInput, type VoicemailAuthResponse, type WebPushConfig, generateUuidV7, isWebPushSupported, onServiceWorkerMessage, registerServiceWorker, subscribeToPush, subscriptionToJSON };
1722
+ export { AUTH_EVENTS, type ActorContext, type Appointment, type AppointmentListOptions, AppointmentResource, type Attachment, AttachmentsError, AttachmentsResource, type AuthEventType, type AuthLoginFailedPayload, type AuthLoginSucceededPayload, CALL_EVENTS, CONVERSATION_EVENTS, type CallConnectedPayload, type CallEndedPayload, type CallEventType, type CallInitiatedPayload, type CallMissedPayload, type CallStatusResponse, type CancelScheduledNotificationResult, type ConversationAddress, type ConversationAttachmentDownloadedPayload, type ConversationAttachmentUploadedPayload, type ConversationCreatedPayload, type ConversationEventType, type ConversationMarkedReadPayload, type ConversationMessageReceivedPayload, type ConversationMessageSentPayload, type ConversationTaskPriority, type ConversationTaskStatus, ConversationsError, ConversationsResource, type CreateConversationNoteInput, type CreateConversationTaskInput, type CreateTaskInput, type CreateUploadUrlInput, type CreateUploadUrlResult, type DetectionResult, type DialpadNumberInfo, DialpadProxyError, DialpadResource, type DialpadUser, ENVIRONMENTS, EVENT_TYPES, EhrProviderProxy, EhrProxyError, EhrResource, type Environment, type EventActor, type EventCompliance, type EventEnvelope, type EventPayloadMap, type EventSubject, type EventType, type GetDownloadUrlResult, type InitiateCallResponse, MessagesResource, NOTIFICATION_EVENTS, type NonVisitNoteBullet, NotesError, NotesResource, type NotificationDeliveredPayload, type NotificationEventType, type NotificationOpenedPayload, type NotificationPlatform, type NotificationPreferences, type NotificationSentPayload, NotificationsError, NotificationsResource, PROVIDER_EVENTS, type PaginatedResult, type Patient, type PatientBasicDetailsResult, PatientDetailsError, type PatientDetailsInput, PatientDetailsResource, type PatientDetailsResult, type PatientListOptions, type PatientMedicalDetailsResult, PatientResource, type Physician, PhysiciansResource, type ProviderEventType, type ProviderSyncFailedPayload, type ProviderSyncStartedPayload, type ProviderSyncSucceededPayload, type PushEventPayload, type PushNoteToElationInput, type PushNoteToElationResult, REMINDER_EVENTS, type RecordAttachmentInput, type RegisterDeviceInput, type RegisterDeviceResult, type Reminder, type ReminderEventType, type ReminderScheduledPayload, type ReminderStatus, type ReminderTriggeredPayload, RemindersResource, SECURITY_EVENTS, type ScheduleNotificationInput, type ScheduleNotificationResult, type ScheduleReminderInput, type ScheduleReminderResult, type ScheduledJobStatus, type ScheduledNotification, type SecurityAccessDeniedPayload, type SecurityEventType, type SendConversationMessageInput, type SendConversationMessageResult, type SendNotificationInput, type SendNotificationResult, type SendSmsParams, type SendSmsResponse, type SetConversationTaskStatusInput, TASK_EVENTS, TRANSLATION_EVENTS, type Task, type TaskAssignedPayload, type TaskCreatedPayload, type TaskEventType, type TaskStatus, type TaskStatusChangedPayload, TasksResource, type TrackOptions, Tracker, type TranslateBatchInput, type TranslateTextInput, type TranslationCompletedPayload, TranslationError, type TranslationEventType, type TranslationRequestedPayload, TranslationResource, type TranslationResult, TruthClient, type TruthClientConfig, type UnregisterDeviceInput, type UpdateNotificationsInput, type UpdateNotificationsResult, type UpdatePreferencesInput, type UpdateTaskStatusInput, type UserSettings, UserSettingsResource, type VoicemailAuthResponse, type WebPushConfig, generateUuidV7, isWebPushSupported, onServiceWorkerMessage, registerServiceWorker, subscribeToPush, subscriptionToJSON };
package/dist/index.js CHANGED
@@ -91,6 +91,7 @@ __export(src_exports, {
91
91
  TranslationError: () => TranslationError,
92
92
  TranslationResource: () => TranslationResource,
93
93
  TruthClient: () => TruthClient,
94
+ UserSettingsResource: () => UserSettingsResource,
94
95
  generateUuidV7: () => generateUuidV7,
95
96
  isWebPushSupported: () => isWebPushSupported,
96
97
  onServiceWorkerMessage: () => onServiceWorkerMessage,
@@ -373,14 +374,72 @@ var ConversationMessagesSubresource = class {
373
374
  }
374
375
  };
375
376
  var _ConversationsResource = class _ConversationsResource {
376
- constructor(apiBaseUrl, apiKey) {
377
+ constructor(apiBaseUrl, apiKey, convex) {
377
378
  this.baseUrl = apiBaseUrl;
378
379
  this.apiKey = apiKey;
380
+ this.convex = convex != null ? convex : null;
379
381
  const post = (path, body) => this.postRequest(path, body);
380
382
  this.notes = new ConversationNotesSubresource(post);
381
383
  this.tasks = new ConversationTasksSubresource(post);
382
384
  this.messages = new ConversationMessagesSubresource(post);
383
385
  }
386
+ /**
387
+ * Mark a conversation read for the calling user (zeroes unreadCount,
388
+ * stamps `lastReadAt`). Calls the public Convex `markRead` mutation
389
+ * which enforces self-tenancy on the auth identity.
390
+ */
391
+ markRead(input) {
392
+ return __async(this, null, function* () {
393
+ if (!this.convex) {
394
+ throw new ConversationsError(
395
+ "/markRead",
396
+ 0,
397
+ "ConversationsResource missing Convex client"
398
+ );
399
+ }
400
+ return yield this.convex.mutation(
401
+ "conversations:markRead",
402
+ input
403
+ );
404
+ });
405
+ }
406
+ /**
407
+ * Mark a conversation unread for the calling user (sets unreadCount=1).
408
+ */
409
+ markUnread(input) {
410
+ return __async(this, null, function* () {
411
+ if (!this.convex) {
412
+ throw new ConversationsError(
413
+ "/markUnread",
414
+ 0,
415
+ "ConversationsResource missing Convex client"
416
+ );
417
+ }
418
+ return yield this.convex.mutation(
419
+ "conversations:markUnread",
420
+ input
421
+ );
422
+ });
423
+ }
424
+ /**
425
+ * Zero unread on every conversation the user has reads for, except
426
+ * those whose `providerPhone` is in `excludedProviderPhones`.
427
+ */
428
+ clearAllUnread(input) {
429
+ return __async(this, null, function* () {
430
+ if (!this.convex) {
431
+ throw new ConversationsError(
432
+ "/clearAllUnread",
433
+ 0,
434
+ "ConversationsResource missing Convex client"
435
+ );
436
+ }
437
+ return yield this.convex.mutation(
438
+ "conversations:clearAllUnread",
439
+ input
440
+ );
441
+ });
442
+ }
384
443
  postRequest(path, body) {
385
444
  return __async(this, null, function* () {
386
445
  if (!this.apiKey) {
@@ -657,6 +716,42 @@ var MessagesResource = class {
657
716
  this.baseUrl = apiBaseUrl;
658
717
  this.apiKey = apiKey;
659
718
  }
719
+ /**
720
+ * Get an authenticated URL for a Dialpad voicemail recording.
721
+ *
722
+ * Replaces CommHub's `getAuthenticatedVoicemailUrl` Hasura mutation
723
+ * (which proxied to the legacy NestJS backend). Truth appends the
724
+ * Dialpad API key, follows redirects, strips the key from the final
725
+ * URL, and returns it for client-side audio playback.
726
+ *
727
+ * @param voicemailLink The raw Dialpad voicemail download URL (value
728
+ * of the `voicemail_link` field on the call event row).
729
+ * @returns An object with `url` (clean playback URL) and `expiresAt`
730
+ * (ISO-8601 timestamp, ~5 min from request time, informational only).
731
+ */
732
+ getVoicemailUrl(voicemailLink) {
733
+ return __async(this, null, function* () {
734
+ const res = yield fetch(
735
+ `${this.baseUrl}/api/conversations/voicemail/url`,
736
+ {
737
+ method: "POST",
738
+ headers: {
739
+ "Content-Type": "application/json",
740
+ Accept: "application/json",
741
+ "X-API-Key": this.apiKey
742
+ },
743
+ body: JSON.stringify({ voicemailLink })
744
+ }
745
+ );
746
+ if (!res.ok) {
747
+ const text = yield res.text().catch(() => "");
748
+ throw new Error(
749
+ `messages.getVoicemailUrl failed (HTTP ${res.status}): ${text.slice(0, 200)}`
750
+ );
751
+ }
752
+ return yield res.json();
753
+ });
754
+ }
660
755
  /**
661
756
  * End a Dialpad call via the typed oRPC procedure (POST hangup, with
662
757
  * 404→`alreadyEnded` so the UI doesn't flash an error on a natural
@@ -1458,6 +1553,24 @@ var TranslationResource = class {
1458
1553
  }
1459
1554
  };
1460
1555
 
1556
+ // src/resources/user-settings.ts
1557
+ var import_server = require("convex/server");
1558
+ var upsertNotificationsRef = (0, import_server.makeFunctionReference)("userSettings:upsertNotifications");
1559
+ var UserSettingsResource = class {
1560
+ constructor(convex) {
1561
+ this.convex = convex;
1562
+ }
1563
+ /**
1564
+ * Upsert notification preferences for a user. Creates the row if it
1565
+ * doesn't exist; patches `notificationsEnabled` + `updatedAt` otherwise.
1566
+ */
1567
+ updateNotifications(input) {
1568
+ return __async(this, null, function* () {
1569
+ return this.convex.mutation(upsertNotificationsRef, input);
1570
+ });
1571
+ }
1572
+ };
1573
+
1461
1574
  // src/tracking/tracker.ts
1462
1575
  function generateUuidV7() {
1463
1576
  const now = Date.now();
@@ -1754,7 +1867,12 @@ var TruthClient = class {
1754
1867
  this.notes = new NotesResource(apiUrl, config.apiKey);
1755
1868
  this.physicians = new PhysiciansResource(this.convex);
1756
1869
  this.notifications = new NotificationsResource(apiUrl, config.apiKey);
1757
- this.conversations = new ConversationsResource(apiUrl, config.apiKey);
1870
+ this.conversations = new ConversationsResource(
1871
+ apiUrl,
1872
+ config.apiKey,
1873
+ this.convex
1874
+ );
1875
+ this.userSettings = new UserSettingsResource(this.convex);
1758
1876
  this._serviceWorkerPath = (_h = config.serviceWorkerPath) != null ? _h : "/truth-sw.js";
1759
1877
  if (typeof window !== "undefined" && isWebPushSupported() && config.autoInitServiceWorker !== false) {
1760
1878
  this._webPushReady = this.initWebPush();
@@ -1964,6 +2082,7 @@ var ENVIRONMENTS = {
1964
2082
  TranslationError,
1965
2083
  TranslationResource,
1966
2084
  TruthClient,
2085
+ UserSettingsResource,
1967
2086
  generateUuidV7,
1968
2087
  isWebPushSupported,
1969
2088
  onServiceWorkerMessage,