@hipnation-truth/sdk 0.13.0 → 0.15.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 +103 -1
- package/dist/index.d.ts +103 -1
- package/dist/index.js +128 -0
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +126 -0
- package/dist/index.mjs.map +1 -1
- package/dist/react.d.ts +88 -1
- package/dist/react.js +70 -3
- package/dist/react.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -224,6 +224,106 @@ declare class AttachmentsResource {
|
|
|
224
224
|
}>;
|
|
225
225
|
}
|
|
226
226
|
|
|
227
|
+
/**
|
|
228
|
+
* ConversationsResource — write methods that hang off a specific
|
|
229
|
+
* conversation: notes, tasks, outbound messages.
|
|
230
|
+
*
|
|
231
|
+
* Replaces CommHub's `truthConversationApi.ts` raw-fetch wrappers so
|
|
232
|
+
* the frontend goes through a typed SDK surface instead of building
|
|
233
|
+
* URLs by hand.
|
|
234
|
+
*
|
|
235
|
+
* All methods proxy the matching oRPC procedures (`/conversations/*`)
|
|
236
|
+
* via Truth's application-key auth. Errors surface as
|
|
237
|
+
* `ConversationsError` with a status code so callers can distinguish
|
|
238
|
+
* transport failures (status=0) from API rejections (status>=400).
|
|
239
|
+
*/
|
|
240
|
+
/** Address a conversation by either Convex `_id` or the phonePair. */
|
|
241
|
+
interface ConversationAddress {
|
|
242
|
+
conversationId?: string;
|
|
243
|
+
phonePair?: string;
|
|
244
|
+
}
|
|
245
|
+
type ConversationTaskStatus = "pending" | "completed";
|
|
246
|
+
type ConversationTaskPriority = "high" | "medium" | "low";
|
|
247
|
+
interface CreateConversationNoteInput extends ConversationAddress {
|
|
248
|
+
eventId?: string;
|
|
249
|
+
author: string;
|
|
250
|
+
content: string;
|
|
251
|
+
status?: string;
|
|
252
|
+
type?: string;
|
|
253
|
+
}
|
|
254
|
+
interface CreateConversationTaskInput extends ConversationAddress {
|
|
255
|
+
eventId?: string;
|
|
256
|
+
author: string;
|
|
257
|
+
description: string;
|
|
258
|
+
status?: ConversationTaskStatus;
|
|
259
|
+
priority?: ConversationTaskPriority;
|
|
260
|
+
assignee?: string;
|
|
261
|
+
type?: string;
|
|
262
|
+
}
|
|
263
|
+
interface SetConversationTaskStatusInput {
|
|
264
|
+
taskId: string;
|
|
265
|
+
status: ConversationTaskStatus;
|
|
266
|
+
resolvedBy?: string;
|
|
267
|
+
}
|
|
268
|
+
interface SendConversationMessageInput {
|
|
269
|
+
fromNumber: string;
|
|
270
|
+
toNumber: string;
|
|
271
|
+
message?: string;
|
|
272
|
+
media?: string;
|
|
273
|
+
}
|
|
274
|
+
interface SendConversationMessageResult {
|
|
275
|
+
id: number;
|
|
276
|
+
messageStatus: string;
|
|
277
|
+
direction: string;
|
|
278
|
+
}
|
|
279
|
+
declare class ConversationsError extends Error {
|
|
280
|
+
readonly status: number;
|
|
281
|
+
constructor(operation: string, status: number, message?: string);
|
|
282
|
+
}
|
|
283
|
+
declare class ConversationNotesSubresource {
|
|
284
|
+
private readonly post;
|
|
285
|
+
constructor(post: <T>(path: string, body: unknown) => Promise<T>);
|
|
286
|
+
/** Create a note on a conversation (addressed by id or phonePair). */
|
|
287
|
+
create(input: CreateConversationNoteInput): Promise<{
|
|
288
|
+
id: string;
|
|
289
|
+
}>;
|
|
290
|
+
}
|
|
291
|
+
declare class ConversationTasksSubresource {
|
|
292
|
+
private readonly post;
|
|
293
|
+
constructor(post: <T>(path: string, body: unknown) => Promise<T>);
|
|
294
|
+
/** Create a task on a conversation. */
|
|
295
|
+
create(input: CreateConversationTaskInput): Promise<{
|
|
296
|
+
id: string;
|
|
297
|
+
}>;
|
|
298
|
+
/** Mark a task pending or completed. */
|
|
299
|
+
setStatus(input: SetConversationTaskStatusInput): Promise<{
|
|
300
|
+
ok: true;
|
|
301
|
+
}>;
|
|
302
|
+
}
|
|
303
|
+
declare class ConversationMessagesSubresource {
|
|
304
|
+
private readonly post;
|
|
305
|
+
constructor(post: <T>(path: string, body: unknown) => Promise<T>);
|
|
306
|
+
/**
|
|
307
|
+
* Send an outbound SMS / MMS via the typed `sendMessage` oRPC procedure.
|
|
308
|
+
*
|
|
309
|
+
* Prefer this over the generic Dialpad proxy (`messages.dialpad.sendSms`)
|
|
310
|
+
* — this hits the validated Truth route and consistently surfaces
|
|
311
|
+
* `ConversationsError` on failure.
|
|
312
|
+
*/
|
|
313
|
+
send(input: SendConversationMessageInput): Promise<SendConversationMessageResult>;
|
|
314
|
+
}
|
|
315
|
+
declare class ConversationsResource {
|
|
316
|
+
readonly notes: ConversationNotesSubresource;
|
|
317
|
+
readonly tasks: ConversationTasksSubresource;
|
|
318
|
+
readonly messages: ConversationMessagesSubresource;
|
|
319
|
+
/** 30s upstream timeout — matches NotesResource for consistency. */
|
|
320
|
+
private static readonly REQUEST_TIMEOUT_MS;
|
|
321
|
+
private readonly baseUrl;
|
|
322
|
+
private readonly apiKey;
|
|
323
|
+
constructor(apiBaseUrl: string, apiKey: string);
|
|
324
|
+
private postRequest;
|
|
325
|
+
}
|
|
326
|
+
|
|
227
327
|
/**
|
|
228
328
|
* Dialpad resource — typed access to Truth's Dialpad proxy endpoints.
|
|
229
329
|
*
|
|
@@ -1374,6 +1474,8 @@ declare class TruthClient {
|
|
|
1374
1474
|
readonly physicians: PhysiciansResource;
|
|
1375
1475
|
/** Push / web notifications (AWS End User Messaging) */
|
|
1376
1476
|
readonly notifications: NotificationsResource;
|
|
1477
|
+
/** Conversation-tied writes — notes, tasks, outbound messages. */
|
|
1478
|
+
readonly conversations: ConversationsResource;
|
|
1377
1479
|
private readonly convex;
|
|
1378
1480
|
private readonly tracker;
|
|
1379
1481
|
private _vapidPublicKey;
|
|
@@ -1529,4 +1631,4 @@ declare function subscriptionToJSON(sub: PushSubscription): {
|
|
|
1529
1631
|
};
|
|
1530
1632
|
declare function onServiceWorkerMessage(type: string, callback: (payload: unknown) => void): () => void;
|
|
1531
1633
|
|
|
1532
|
-
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 ConversationAttachmentDownloadedPayload, type ConversationAttachmentUploadedPayload, type ConversationCreatedPayload, type ConversationEventType, type ConversationMarkedReadPayload, type ConversationMessageReceivedPayload, type ConversationMessageSentPayload, 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 SendNotificationInput, type SendNotificationResult, type SendSmsParams, type SendSmsResponse, 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 };
|
|
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 };
|
package/dist/index.d.ts
CHANGED
|
@@ -224,6 +224,106 @@ declare class AttachmentsResource {
|
|
|
224
224
|
}>;
|
|
225
225
|
}
|
|
226
226
|
|
|
227
|
+
/**
|
|
228
|
+
* ConversationsResource — write methods that hang off a specific
|
|
229
|
+
* conversation: notes, tasks, outbound messages.
|
|
230
|
+
*
|
|
231
|
+
* Replaces CommHub's `truthConversationApi.ts` raw-fetch wrappers so
|
|
232
|
+
* the frontend goes through a typed SDK surface instead of building
|
|
233
|
+
* URLs by hand.
|
|
234
|
+
*
|
|
235
|
+
* All methods proxy the matching oRPC procedures (`/conversations/*`)
|
|
236
|
+
* via Truth's application-key auth. Errors surface as
|
|
237
|
+
* `ConversationsError` with a status code so callers can distinguish
|
|
238
|
+
* transport failures (status=0) from API rejections (status>=400).
|
|
239
|
+
*/
|
|
240
|
+
/** Address a conversation by either Convex `_id` or the phonePair. */
|
|
241
|
+
interface ConversationAddress {
|
|
242
|
+
conversationId?: string;
|
|
243
|
+
phonePair?: string;
|
|
244
|
+
}
|
|
245
|
+
type ConversationTaskStatus = "pending" | "completed";
|
|
246
|
+
type ConversationTaskPriority = "high" | "medium" | "low";
|
|
247
|
+
interface CreateConversationNoteInput extends ConversationAddress {
|
|
248
|
+
eventId?: string;
|
|
249
|
+
author: string;
|
|
250
|
+
content: string;
|
|
251
|
+
status?: string;
|
|
252
|
+
type?: string;
|
|
253
|
+
}
|
|
254
|
+
interface CreateConversationTaskInput extends ConversationAddress {
|
|
255
|
+
eventId?: string;
|
|
256
|
+
author: string;
|
|
257
|
+
description: string;
|
|
258
|
+
status?: ConversationTaskStatus;
|
|
259
|
+
priority?: ConversationTaskPriority;
|
|
260
|
+
assignee?: string;
|
|
261
|
+
type?: string;
|
|
262
|
+
}
|
|
263
|
+
interface SetConversationTaskStatusInput {
|
|
264
|
+
taskId: string;
|
|
265
|
+
status: ConversationTaskStatus;
|
|
266
|
+
resolvedBy?: string;
|
|
267
|
+
}
|
|
268
|
+
interface SendConversationMessageInput {
|
|
269
|
+
fromNumber: string;
|
|
270
|
+
toNumber: string;
|
|
271
|
+
message?: string;
|
|
272
|
+
media?: string;
|
|
273
|
+
}
|
|
274
|
+
interface SendConversationMessageResult {
|
|
275
|
+
id: number;
|
|
276
|
+
messageStatus: string;
|
|
277
|
+
direction: string;
|
|
278
|
+
}
|
|
279
|
+
declare class ConversationsError extends Error {
|
|
280
|
+
readonly status: number;
|
|
281
|
+
constructor(operation: string, status: number, message?: string);
|
|
282
|
+
}
|
|
283
|
+
declare class ConversationNotesSubresource {
|
|
284
|
+
private readonly post;
|
|
285
|
+
constructor(post: <T>(path: string, body: unknown) => Promise<T>);
|
|
286
|
+
/** Create a note on a conversation (addressed by id or phonePair). */
|
|
287
|
+
create(input: CreateConversationNoteInput): Promise<{
|
|
288
|
+
id: string;
|
|
289
|
+
}>;
|
|
290
|
+
}
|
|
291
|
+
declare class ConversationTasksSubresource {
|
|
292
|
+
private readonly post;
|
|
293
|
+
constructor(post: <T>(path: string, body: unknown) => Promise<T>);
|
|
294
|
+
/** Create a task on a conversation. */
|
|
295
|
+
create(input: CreateConversationTaskInput): Promise<{
|
|
296
|
+
id: string;
|
|
297
|
+
}>;
|
|
298
|
+
/** Mark a task pending or completed. */
|
|
299
|
+
setStatus(input: SetConversationTaskStatusInput): Promise<{
|
|
300
|
+
ok: true;
|
|
301
|
+
}>;
|
|
302
|
+
}
|
|
303
|
+
declare class ConversationMessagesSubresource {
|
|
304
|
+
private readonly post;
|
|
305
|
+
constructor(post: <T>(path: string, body: unknown) => Promise<T>);
|
|
306
|
+
/**
|
|
307
|
+
* Send an outbound SMS / MMS via the typed `sendMessage` oRPC procedure.
|
|
308
|
+
*
|
|
309
|
+
* Prefer this over the generic Dialpad proxy (`messages.dialpad.sendSms`)
|
|
310
|
+
* — this hits the validated Truth route and consistently surfaces
|
|
311
|
+
* `ConversationsError` on failure.
|
|
312
|
+
*/
|
|
313
|
+
send(input: SendConversationMessageInput): Promise<SendConversationMessageResult>;
|
|
314
|
+
}
|
|
315
|
+
declare class ConversationsResource {
|
|
316
|
+
readonly notes: ConversationNotesSubresource;
|
|
317
|
+
readonly tasks: ConversationTasksSubresource;
|
|
318
|
+
readonly messages: ConversationMessagesSubresource;
|
|
319
|
+
/** 30s upstream timeout — matches NotesResource for consistency. */
|
|
320
|
+
private static readonly REQUEST_TIMEOUT_MS;
|
|
321
|
+
private readonly baseUrl;
|
|
322
|
+
private readonly apiKey;
|
|
323
|
+
constructor(apiBaseUrl: string, apiKey: string);
|
|
324
|
+
private postRequest;
|
|
325
|
+
}
|
|
326
|
+
|
|
227
327
|
/**
|
|
228
328
|
* Dialpad resource — typed access to Truth's Dialpad proxy endpoints.
|
|
229
329
|
*
|
|
@@ -1374,6 +1474,8 @@ declare class TruthClient {
|
|
|
1374
1474
|
readonly physicians: PhysiciansResource;
|
|
1375
1475
|
/** Push / web notifications (AWS End User Messaging) */
|
|
1376
1476
|
readonly notifications: NotificationsResource;
|
|
1477
|
+
/** Conversation-tied writes — notes, tasks, outbound messages. */
|
|
1478
|
+
readonly conversations: ConversationsResource;
|
|
1377
1479
|
private readonly convex;
|
|
1378
1480
|
private readonly tracker;
|
|
1379
1481
|
private _vapidPublicKey;
|
|
@@ -1529,4 +1631,4 @@ declare function subscriptionToJSON(sub: PushSubscription): {
|
|
|
1529
1631
|
};
|
|
1530
1632
|
declare function onServiceWorkerMessage(type: string, callback: (payload: unknown) => void): () => void;
|
|
1531
1633
|
|
|
1532
|
-
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 ConversationAttachmentDownloadedPayload, type ConversationAttachmentUploadedPayload, type ConversationCreatedPayload, type ConversationEventType, type ConversationMarkedReadPayload, type ConversationMessageReceivedPayload, type ConversationMessageSentPayload, 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 SendNotificationInput, type SendNotificationResult, type SendSmsParams, type SendSmsResponse, 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 };
|
|
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 };
|
package/dist/index.js
CHANGED
|
@@ -61,6 +61,8 @@ __export(src_exports, {
|
|
|
61
61
|
AttachmentsResource: () => AttachmentsResource,
|
|
62
62
|
CALL_EVENTS: () => CALL_EVENTS,
|
|
63
63
|
CONVERSATION_EVENTS: () => CONVERSATION_EVENTS,
|
|
64
|
+
ConversationsError: () => ConversationsError,
|
|
65
|
+
ConversationsResource: () => ConversationsResource,
|
|
64
66
|
DialpadProxyError: () => DialpadProxyError,
|
|
65
67
|
DialpadResource: () => DialpadResource,
|
|
66
68
|
ENVIRONMENTS: () => ENVIRONMENTS,
|
|
@@ -291,6 +293,129 @@ var AttachmentsResource = class {
|
|
|
291
293
|
}
|
|
292
294
|
};
|
|
293
295
|
|
|
296
|
+
// src/resources/conversations.ts
|
|
297
|
+
var ConversationsError = class extends Error {
|
|
298
|
+
constructor(operation, status, message) {
|
|
299
|
+
super(message != null ? message : `Conversations ${operation} failed (HTTP ${status})`);
|
|
300
|
+
this.name = "ConversationsError";
|
|
301
|
+
this.status = status;
|
|
302
|
+
}
|
|
303
|
+
};
|
|
304
|
+
var ConversationNotesSubresource = class {
|
|
305
|
+
constructor(post) {
|
|
306
|
+
this.post = post;
|
|
307
|
+
}
|
|
308
|
+
/** Create a note on a conversation (addressed by id or phonePair). */
|
|
309
|
+
create(input) {
|
|
310
|
+
return __async(this, null, function* () {
|
|
311
|
+
return this.post("/conversations/notes", input);
|
|
312
|
+
});
|
|
313
|
+
}
|
|
314
|
+
};
|
|
315
|
+
var ConversationTasksSubresource = class {
|
|
316
|
+
constructor(post) {
|
|
317
|
+
this.post = post;
|
|
318
|
+
}
|
|
319
|
+
/** Create a task on a conversation. */
|
|
320
|
+
create(input) {
|
|
321
|
+
return __async(this, null, function* () {
|
|
322
|
+
return this.post("/conversations/tasks", input);
|
|
323
|
+
});
|
|
324
|
+
}
|
|
325
|
+
/** Mark a task pending or completed. */
|
|
326
|
+
setStatus(input) {
|
|
327
|
+
return __async(this, null, function* () {
|
|
328
|
+
return this.post(
|
|
329
|
+
`/conversations/tasks/${encodeURIComponent(input.taskId)}/status`,
|
|
330
|
+
__spreadValues({
|
|
331
|
+
id: input.taskId,
|
|
332
|
+
status: input.status
|
|
333
|
+
}, input.resolvedBy ? { resolvedBy: input.resolvedBy } : {})
|
|
334
|
+
);
|
|
335
|
+
});
|
|
336
|
+
}
|
|
337
|
+
};
|
|
338
|
+
var ConversationMessagesSubresource = class {
|
|
339
|
+
constructor(post) {
|
|
340
|
+
this.post = post;
|
|
341
|
+
}
|
|
342
|
+
/**
|
|
343
|
+
* Send an outbound SMS / MMS via the typed `sendMessage` oRPC procedure.
|
|
344
|
+
*
|
|
345
|
+
* Prefer this over the generic Dialpad proxy (`messages.dialpad.sendSms`)
|
|
346
|
+
* — this hits the validated Truth route and consistently surfaces
|
|
347
|
+
* `ConversationsError` on failure.
|
|
348
|
+
*/
|
|
349
|
+
send(input) {
|
|
350
|
+
return __async(this, null, function* () {
|
|
351
|
+
if (!input.message && !input.media) {
|
|
352
|
+
throw new ConversationsError(
|
|
353
|
+
"messages.send",
|
|
354
|
+
0,
|
|
355
|
+
"send requires `message` or `media`"
|
|
356
|
+
);
|
|
357
|
+
}
|
|
358
|
+
return this.post(
|
|
359
|
+
"/conversations/messages",
|
|
360
|
+
input
|
|
361
|
+
);
|
|
362
|
+
});
|
|
363
|
+
}
|
|
364
|
+
};
|
|
365
|
+
var _ConversationsResource = class _ConversationsResource {
|
|
366
|
+
constructor(apiBaseUrl, apiKey) {
|
|
367
|
+
this.baseUrl = apiBaseUrl;
|
|
368
|
+
this.apiKey = apiKey;
|
|
369
|
+
const post = (path, body) => this.postRequest(path, body);
|
|
370
|
+
this.notes = new ConversationNotesSubresource(post);
|
|
371
|
+
this.tasks = new ConversationTasksSubresource(post);
|
|
372
|
+
this.messages = new ConversationMessagesSubresource(post);
|
|
373
|
+
}
|
|
374
|
+
postRequest(path, body) {
|
|
375
|
+
return __async(this, null, function* () {
|
|
376
|
+
if (!this.apiKey) {
|
|
377
|
+
throw new ConversationsError(
|
|
378
|
+
path,
|
|
379
|
+
0,
|
|
380
|
+
"Truth API key not configured \u2014 request blocked"
|
|
381
|
+
);
|
|
382
|
+
}
|
|
383
|
+
const controller = new AbortController();
|
|
384
|
+
const timeout = setTimeout(
|
|
385
|
+
() => controller.abort(),
|
|
386
|
+
_ConversationsResource.REQUEST_TIMEOUT_MS
|
|
387
|
+
);
|
|
388
|
+
let res;
|
|
389
|
+
try {
|
|
390
|
+
res = yield fetch(`${this.baseUrl}/api${path}`, {
|
|
391
|
+
method: "POST",
|
|
392
|
+
headers: {
|
|
393
|
+
"Content-Type": "application/json",
|
|
394
|
+
Accept: "application/json",
|
|
395
|
+
"X-API-Key": this.apiKey
|
|
396
|
+
},
|
|
397
|
+
body: JSON.stringify(body),
|
|
398
|
+
signal: controller.signal
|
|
399
|
+
});
|
|
400
|
+
} catch (err) {
|
|
401
|
+
const isAbort = err instanceof Error && (err.name === "AbortError" || err.name === "TimeoutError");
|
|
402
|
+
const message = isAbort ? `Conversations ${path} timed out after ${_ConversationsResource.REQUEST_TIMEOUT_MS}ms` : err instanceof Error ? err.message : "Conversations request failed before response";
|
|
403
|
+
throw new ConversationsError(path, 0, message);
|
|
404
|
+
} finally {
|
|
405
|
+
clearTimeout(timeout);
|
|
406
|
+
}
|
|
407
|
+
if (!res.ok) {
|
|
408
|
+
const text = yield res.text().catch(() => "");
|
|
409
|
+
throw new ConversationsError(path, res.status, text.slice(0, 200));
|
|
410
|
+
}
|
|
411
|
+
return yield res.json();
|
|
412
|
+
});
|
|
413
|
+
}
|
|
414
|
+
};
|
|
415
|
+
/** 30s upstream timeout — matches NotesResource for consistency. */
|
|
416
|
+
_ConversationsResource.REQUEST_TIMEOUT_MS = 3e4;
|
|
417
|
+
var ConversationsResource = _ConversationsResource;
|
|
418
|
+
|
|
294
419
|
// src/resources/dialpad.ts
|
|
295
420
|
var DialpadResource = class {
|
|
296
421
|
constructor(apiBaseUrl, apiKey) {
|
|
@@ -1619,6 +1744,7 @@ var TruthClient = class {
|
|
|
1619
1744
|
this.notes = new NotesResource(apiUrl, config.apiKey);
|
|
1620
1745
|
this.physicians = new PhysiciansResource(this.convex);
|
|
1621
1746
|
this.notifications = new NotificationsResource(apiUrl, config.apiKey);
|
|
1747
|
+
this.conversations = new ConversationsResource(apiUrl, config.apiKey);
|
|
1622
1748
|
this._serviceWorkerPath = (_h = config.serviceWorkerPath) != null ? _h : "/truth-sw.js";
|
|
1623
1749
|
if (typeof window !== "undefined" && isWebPushSupported() && config.autoInitServiceWorker !== false) {
|
|
1624
1750
|
this._webPushReady = this.initWebPush();
|
|
@@ -1798,6 +1924,8 @@ var ENVIRONMENTS = {
|
|
|
1798
1924
|
AttachmentsResource,
|
|
1799
1925
|
CALL_EVENTS,
|
|
1800
1926
|
CONVERSATION_EVENTS,
|
|
1927
|
+
ConversationsError,
|
|
1928
|
+
ConversationsResource,
|
|
1801
1929
|
DialpadProxyError,
|
|
1802
1930
|
DialpadResource,
|
|
1803
1931
|
ENVIRONMENTS,
|