@hipnation-truth/sdk 0.1.6 → 0.2.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 CHANGED
@@ -127,6 +127,70 @@ declare class AppointmentResource {
127
127
  list(options?: AppointmentListOptions): Promise<PaginatedResult<Appointment>>;
128
128
  }
129
129
 
130
+ /**
131
+ * AttachmentsResource — presigned S3 upload/download + Convex metadata.
132
+ *
133
+ * Replaces CommHub's base64-in-Postgres attachment flow:
134
+ * 1. client.attachments.createUploadUrl(...) → presigned PUT URL
135
+ * 2. Client PUTs bytes directly to S3
136
+ * 3. client.attachments.record(...) → writes Convex metadata
137
+ * 4. client.attachments.getDownloadUrl(s3Key) → presigned GET URL
138
+ */
139
+
140
+ interface CreateUploadUrlInput {
141
+ fileName: string;
142
+ mimeType: string;
143
+ size: number;
144
+ conversationId?: string;
145
+ }
146
+ interface CreateUploadUrlResult {
147
+ uploadUrl: string;
148
+ s3Key: string;
149
+ expiresIn: number;
150
+ applicationId: string | null;
151
+ }
152
+ interface GetDownloadUrlResult {
153
+ url: string;
154
+ expiresIn: number;
155
+ }
156
+ interface RecordAttachmentInput {
157
+ s3Key: string;
158
+ fileName: string;
159
+ mimeType: string;
160
+ size: number;
161
+ conversationId?: string;
162
+ uploadedBy: string;
163
+ }
164
+ interface Attachment {
165
+ _id: string;
166
+ s3Key: string;
167
+ fileName: string;
168
+ mimeType: string;
169
+ size: number;
170
+ conversationId?: string;
171
+ uploadedBy: string;
172
+ createdAt: string;
173
+ }
174
+ declare class AttachmentsError extends Error {
175
+ readonly status: number;
176
+ constructor(operation: string, status: number, message?: string);
177
+ }
178
+ declare class AttachmentsResource {
179
+ private readonly baseUrl;
180
+ private readonly apiKey;
181
+ private readonly convex;
182
+ constructor(apiBaseUrl: string, apiKey: string, convexClient: ConvexHttpClient);
183
+ private post;
184
+ createUploadUrl(input: CreateUploadUrlInput): Promise<CreateUploadUrlResult>;
185
+ getDownloadUrl(s3Key: string, expiresIn?: number): Promise<GetDownloadUrlResult>;
186
+ record(input: RecordAttachmentInput): Promise<{
187
+ attachmentId: string;
188
+ s3Key: string;
189
+ }>;
190
+ get(attachmentId: string): Promise<Attachment | null>;
191
+ listByConversation(conversationId: string): Promise<Attachment[]>;
192
+ }
193
+
130
194
  /**
131
195
  * Dialpad resource — typed access to Truth's Dialpad proxy endpoints.
132
196
  *
@@ -142,7 +206,7 @@ interface SendSmsParams {
142
206
  from_number: string;
143
207
  to_number: string;
144
208
  message?: string;
145
- media?: string;
209
+ media?: string | string[];
146
210
  }
147
211
  interface SendSmsResponse {
148
212
  id: string;
@@ -176,7 +240,8 @@ interface VoicemailAuthResponse {
176
240
  }
177
241
  declare class DialpadResource {
178
242
  private readonly baseUrl;
179
- constructor(apiBaseUrl: string);
243
+ private readonly apiKey;
244
+ constructor(apiBaseUrl: string, apiKey: string);
180
245
  /**
181
246
  * Send an SMS or MMS message via Dialpad.
182
247
  */
@@ -189,6 +254,25 @@ declare class DialpadResource {
189
254
  * Hang up an active call.
190
255
  */
191
256
  hangupCall(callId: number): Promise<void>;
257
+ /**
258
+ * Alias for `hangupCall` — mirrors the CommHub `endCall` action name so
259
+ * the SDK swap is a direct rename.
260
+ */
261
+ endCall(callId: number): Promise<void>;
262
+ /**
263
+ * Send an MMS with a pre-uploaded attachment. Takes the S3 key returned
264
+ * by `client.attachments.createUploadUrl(...)` + PUT, fetches a short-
265
+ * lived download URL, and hands it to Dialpad as `media[]`.
266
+ *
267
+ * Replaces CommHub's `sendAttachment` Hasura Action (which stored bytes
268
+ * as base64 in Postgres and served them through a GET endpoint).
269
+ */
270
+ sendAttachmentWithUrl(params: {
271
+ from_number: string;
272
+ to_number: string;
273
+ mediaUrl: string;
274
+ message?: string;
275
+ }): Promise<SendSmsResponse>;
192
276
  /**
193
277
  * Get the status of a call.
194
278
  */
@@ -220,7 +304,7 @@ declare class DialpadResource {
220
304
  }
221
305
  declare class MessagesResource {
222
306
  readonly dialpad: DialpadResource;
223
- constructor(apiBaseUrl: string);
307
+ constructor(apiBaseUrl: string, apiKey: string);
224
308
  }
225
309
  declare class DialpadProxyError extends Error {
226
310
  readonly method: string;
@@ -284,6 +368,84 @@ declare class EhrProxyError extends Error {
284
368
  constructor(provider: string, method: string, path: string, status: number);
285
369
  }
286
370
 
371
+ /**
372
+ * NotesResource — push formatted notes to Elation.
373
+ *
374
+ * Caller assembles the note body (text + bullets). Truth owns the Elation
375
+ * OAuth token and the HTTP call so applications can drop Elation
376
+ * credentials from their own config.
377
+ */
378
+ interface NonVisitNoteBullet {
379
+ text: string;
380
+ category?: string;
381
+ }
382
+ interface PushNoteToElationInput {
383
+ patient: number;
384
+ physician: number;
385
+ practice: number;
386
+ note: {
387
+ text: string;
388
+ type?: string;
389
+ };
390
+ document_date?: string;
391
+ chart_date?: string;
392
+ bullets?: NonVisitNoteBullet[];
393
+ }
394
+ interface PushNoteToElationResult {
395
+ success: boolean;
396
+ elationNoteId: number | null;
397
+ }
398
+ declare class NotesError extends Error {
399
+ readonly status: number;
400
+ constructor(operation: string, status: number, message?: string);
401
+ }
402
+ declare class NotesResource {
403
+ private readonly baseUrl;
404
+ private readonly apiKey;
405
+ constructor(apiBaseUrl: string, apiKey: string);
406
+ pushToElation(input: PushNoteToElationInput): Promise<PushNoteToElationResult>;
407
+ }
408
+
409
+ /**
410
+ * PatientDetailsResource — merged Hint + Elation patient lookups.
411
+ *
412
+ * Backed by the Truth API at /api/patients/details/*, authenticated with
413
+ * X-API-Key. Replaces CommHub's getPatientDetails / getPatientBasicDetails
414
+ * / getPatientMedicalDetails actions.
415
+ */
416
+ interface PatientDetailsInput {
417
+ hintId?: string;
418
+ elationId?: string;
419
+ }
420
+ interface PatientDetailsResult {
421
+ hint: unknown | null;
422
+ elation: unknown | null;
423
+ resolvedElationId: string | null;
424
+ }
425
+ interface PatientBasicDetailsResult {
426
+ hint: unknown | null;
427
+ elationId: string | null;
428
+ }
429
+ interface PatientMedicalDetailsResult {
430
+ problems: unknown | null;
431
+ medications: unknown | null;
432
+ allergies: unknown | null;
433
+ appointments: unknown | null;
434
+ }
435
+ declare class PatientDetailsError extends Error {
436
+ readonly status: number;
437
+ constructor(operation: string, status: number, message?: string);
438
+ }
439
+ declare class PatientDetailsResource {
440
+ private readonly baseUrl;
441
+ private readonly apiKey;
442
+ constructor(apiBaseUrl: string, apiKey: string);
443
+ private post;
444
+ get(input: PatientDetailsInput): Promise<PatientDetailsResult>;
445
+ getBasic(input: PatientDetailsInput): Promise<PatientBasicDetailsResult>;
446
+ getMedical(elationId: string): Promise<PatientMedicalDetailsResult>;
447
+ }
448
+
287
449
  /**
288
450
  * Patient interfaces for the Truth SDK.
289
451
  */
@@ -356,6 +518,169 @@ declare class PatientResource {
356
518
  list(options?: PatientListOptions): Promise<PaginatedResult<Patient>>;
357
519
  }
358
520
 
521
+ /**
522
+ * Reminder types — scheduled conversation reminders.
523
+ */
524
+ type ReminderStatus = "pending" | "triggered" | "cancelled";
525
+ interface Reminder {
526
+ _id: string;
527
+ conversationId: string;
528
+ remindAt: string;
529
+ status: ReminderStatus;
530
+ note?: string;
531
+ createdBy: string;
532
+ createdAt: string;
533
+ triggeredAt?: string;
534
+ cancelledAt?: string;
535
+ }
536
+ interface ScheduleReminderInput {
537
+ conversationId: string;
538
+ remindAt: string | Date;
539
+ note?: string;
540
+ createdBy: string;
541
+ }
542
+ interface ScheduleReminderResult {
543
+ reminderId: string;
544
+ remindAt: string;
545
+ }
546
+
547
+ /**
548
+ * RemindersResource — schedule, cancel, and list conversation reminders.
549
+ *
550
+ * Backed by Convex mutations/queries (durable scheduled functions) — replaces
551
+ * the in-memory setTimeout scheduler that used to live in CommHub's NestJS
552
+ * backend.
553
+ */
554
+
555
+ declare class RemindersResource {
556
+ private readonly convex;
557
+ constructor(convexClient: ConvexHttpClient);
558
+ /**
559
+ * Schedule a reminder to fire at `remindAt`. Returns the reminder id,
560
+ * which callers should store if they may want to cancel it later.
561
+ */
562
+ schedule(input: ScheduleReminderInput): Promise<ScheduleReminderResult>;
563
+ /**
564
+ * Cancel a pending reminder. No-op if the reminder has already fired or
565
+ * been cancelled.
566
+ */
567
+ cancel(reminderId: string, cancelledBy: string): Promise<{
568
+ reminderId: string;
569
+ status: string;
570
+ }>;
571
+ /**
572
+ * List reminders for a conversation (most recent first).
573
+ */
574
+ listByConversation(conversationId: string): Promise<Reminder[]>;
575
+ }
576
+
577
+ type TaskStatus = "open" | "in_progress" | "resolved" | "cancelled";
578
+ interface Task {
579
+ _id: string;
580
+ eventId?: string;
581
+ assignedTo: string;
582
+ createdBy: string;
583
+ title: string;
584
+ description?: string;
585
+ data?: unknown;
586
+ status: TaskStatus;
587
+ resolvedBy?: string;
588
+ resolvedAt?: string;
589
+ createdAt: string;
590
+ updatedAt: string;
591
+ }
592
+ interface CreateTaskInput {
593
+ eventId?: string;
594
+ assignedTo: string;
595
+ createdBy: string;
596
+ title: string;
597
+ description?: string;
598
+ data?: unknown;
599
+ }
600
+ interface UpdateTaskStatusInput {
601
+ taskId: string;
602
+ status: TaskStatus;
603
+ resolvedBy?: string;
604
+ data?: unknown;
605
+ }
606
+
607
+ /**
608
+ * TasksResource — create, update status, list, get tasks.
609
+ *
610
+ * Backed by Convex. Replaces CommHub's createTaskWithNotification +
611
+ * updateTaskStatusWithNotification actions. Push notification side-effect
612
+ * is emitted downstream via Kinesis.
613
+ */
614
+
615
+ declare class TasksResource {
616
+ private readonly convex;
617
+ constructor(convexClient: ConvexHttpClient);
618
+ create(input: CreateTaskInput): Promise<{
619
+ taskId: string;
620
+ status: TaskStatus;
621
+ }>;
622
+ updateStatus(input: UpdateTaskStatusInput): Promise<{
623
+ taskId: string;
624
+ status: TaskStatus;
625
+ previousStatus: TaskStatus;
626
+ }>;
627
+ get(taskId: string): Promise<Task | null>;
628
+ listByAssignee(assignedTo: string, options?: {
629
+ status?: TaskStatus;
630
+ limit?: number;
631
+ }): Promise<Task[]>;
632
+ listOpen(limit?: number): Promise<Task[]>;
633
+ }
634
+
635
+ interface TranslationResult {
636
+ translatedText: string;
637
+ detectedLanguage?: {
638
+ language: string;
639
+ score: number;
640
+ };
641
+ sourceLanguage: string;
642
+ targetLanguage: string;
643
+ }
644
+ interface DetectionResult {
645
+ language: string;
646
+ score: number;
647
+ isTranslationSupported: boolean;
648
+ isTransliterationSupported: boolean;
649
+ }
650
+ interface TranslateTextInput {
651
+ text: string;
652
+ targetLanguage: string;
653
+ sourceLanguage?: string;
654
+ }
655
+ interface TranslateBatchInput {
656
+ texts: string[];
657
+ targetLanguage: string;
658
+ sourceLanguage?: string;
659
+ }
660
+
661
+ /**
662
+ * TranslationResource — Azure Translator proxy through Truth API.
663
+ *
664
+ * All three operations are HTTP calls to Truth's oRPC endpoints at
665
+ * `/api/translation/*`, authenticated with the same X-API-Key as the
666
+ * event tracker.
667
+ */
668
+
669
+ declare class TranslationError extends Error {
670
+ readonly status: number;
671
+ readonly operation: string;
672
+ constructor(operation: string, status: number, message?: string);
673
+ }
674
+ declare class TranslationResource {
675
+ private readonly baseUrl;
676
+ private readonly apiKey;
677
+ constructor(apiBaseUrl: string, apiKey: string);
678
+ private post;
679
+ translate(input: TranslateTextInput): Promise<TranslationResult>;
680
+ translateBatch(input: TranslateBatchInput): Promise<TranslationResult[]>;
681
+ detect(text: string): Promise<DetectionResult>;
682
+ }
683
+
359
684
  /**
360
685
  * Typed event definitions for the Truth Platform event store.
361
686
  *
@@ -729,6 +1054,18 @@ declare class TruthClient {
729
1054
  readonly ehr: EhrResource;
730
1055
  /** Messaging proxy — typed access to Dialpad APIs through Truth */
731
1056
  readonly messages: MessagesResource;
1057
+ /** Conversation reminders (Convex-backed, durable scheduler) */
1058
+ readonly reminders: RemindersResource;
1059
+ /** Translation (Azure Translator proxy) */
1060
+ readonly translation: TranslationResource;
1061
+ /** Tasks (Convex-backed) */
1062
+ readonly tasks: TasksResource;
1063
+ /** Patient details — merged Hint + Elation lookups via Truth API */
1064
+ readonly patientDetails: PatientDetailsResource;
1065
+ /** Attachments — presigned S3 upload/download + Convex metadata */
1066
+ readonly attachments: AttachmentsResource;
1067
+ /** Notes — push formatted notes to Elation */
1068
+ readonly notes: NotesResource;
732
1069
  private readonly convex;
733
1070
  private readonly tracker;
734
1071
  constructor(config: TruthClientConfig);
@@ -856,4 +1193,4 @@ declare class Tracker {
856
1193
  private registerShutdownHooks;
857
1194
  }
858
1195
 
859
- export { AUTH_EVENTS, type ActorContext, type Appointment, type AppointmentListOptions, AppointmentResource, type AuthEventType, type AuthLoginFailedPayload, type AuthLoginSucceededPayload, CALL_EVENTS, CONVERSATION_EVENTS, type CallConnectedPayload, type CallEndedPayload, type CallEventType, type CallInitiatedPayload, type CallMissedPayload, type CallStatusResponse, type ConversationAttachmentDownloadedPayload, type ConversationAttachmentUploadedPayload, type ConversationCreatedPayload, type ConversationEventType, type ConversationMarkedReadPayload, type ConversationMessageReceivedPayload, type ConversationMessageSentPayload, 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 InitiateCallResponse, MessagesResource, NOTIFICATION_EVENTS, type NotificationDeliveredPayload, type NotificationEventType, type NotificationOpenedPayload, type NotificationSentPayload, PROVIDER_EVENTS, type PaginatedResult, type Patient, type PatientListOptions, PatientResource, type ProviderEventType, type ProviderSyncFailedPayload, type ProviderSyncStartedPayload, type ProviderSyncSucceededPayload, REMINDER_EVENTS, type ReminderEventType, type ReminderScheduledPayload, type ReminderTriggeredPayload, SECURITY_EVENTS, type SecurityAccessDeniedPayload, type SecurityEventType, type SendSmsParams, type SendSmsResponse, TASK_EVENTS, TRANSLATION_EVENTS, type TaskAssignedPayload, type TaskCreatedPayload, type TaskEventType, type TaskStatusChangedPayload, type TrackOptions, Tracker, type TranslationCompletedPayload, type TranslationEventType, type TranslationRequestedPayload, TruthClient, type TruthClientConfig, type VoicemailAuthResponse, generateUuidV7 };
1196
+ 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 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 NotificationSentPayload, PROVIDER_EVENTS, type PaginatedResult, type Patient, type PatientBasicDetailsResult, PatientDetailsError, type PatientDetailsInput, PatientDetailsResource, type PatientDetailsResult, type PatientListOptions, type PatientMedicalDetailsResult, PatientResource, type ProviderEventType, type ProviderSyncFailedPayload, type ProviderSyncStartedPayload, type ProviderSyncSucceededPayload, type PushNoteToElationInput, type PushNoteToElationResult, REMINDER_EVENTS, type RecordAttachmentInput, type Reminder, type ReminderEventType, type ReminderScheduledPayload, type ReminderStatus, type ReminderTriggeredPayload, RemindersResource, SECURITY_EVENTS, type ScheduleReminderInput, type ScheduleReminderResult, type SecurityAccessDeniedPayload, type SecurityEventType, 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 UpdateTaskStatusInput, type VoicemailAuthResponse, generateUuidV7 };