med-scribe-alliance-ts-sdk 2.0.54 → 2.0.55

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/README.md CHANGED
@@ -401,7 +401,7 @@ interface RecordingOptions {
401
401
  | `getCurrentSession()` | `CreateSessionResponse \| null` | Get the active session if any. |
402
402
  | `updateSession(request, sessionId?)` | `SDKResult<PatchSessionResponse>` | Patch session (patient details, status, etc.). |
403
403
  | `processTemplate(templateId, sessionId?)` | `SDKResult<ProcessTemplateResponse>` | Trigger processing for a specific template. |
404
- | `cancelSession(sessionId?)` | `SDKResult<PatchSessionResponse>` | Cancel session (stops recorder, no server processing). |
404
+ | `cancelSession(sessionId?, { keepAlive? })` | `SDKResult<PatchSessionResponse>` | Cancel session (stops recorder, no server processing). `keepAlive: true` lets the request survive page unload. |
405
405
 
406
406
  ### Discovery
407
407
 
package/dist/index.d.ts CHANGED
@@ -217,6 +217,8 @@ export interface TransportRequest {
217
217
  /** Additional HTTP status codes to treat as success (not throw). */
218
218
  acceptStatuses?: number[];
219
219
  maxRetries?: number;
220
+ /** Sets fetch keepalive so the request survives page unload. */
221
+ keepAlive?: boolean;
220
222
  }
221
223
  export interface TransportResponse<T = any> {
222
224
  status: number;
@@ -468,6 +470,7 @@ export interface PatchSessionRequest {
468
470
  language_hint?: string[];
469
471
  transcript_language?: string;
470
472
  templates?: string[];
473
+ conversation_id?: string;
471
474
  }
472
475
  export interface PatchSessionResponse {
473
476
  session_id: string;
@@ -852,7 +855,9 @@ export declare class ScribeClient {
852
855
  * Patch/update a session (e.g., update user_status or processing_status).
853
856
  * Uses the current active session if no sessionId is provided.
854
857
  */
855
- updateSession(request: PatchSessionRequest, sessionId?: string): Promise<SDKResult<PatchSessionResponse>>;
858
+ updateSession(request: PatchSessionRequest, sessionId?: string, options?: {
859
+ keepAlive?: boolean;
860
+ }): Promise<SDKResult<PatchSessionResponse>>;
856
861
  /**
857
862
  * Trigger processing for a specific template in a session.
858
863
  * Uses the current active session if no sessionId is provided.
@@ -862,7 +867,9 @@ export declare class ScribeClient {
862
867
  * Cancel a session by setting both user_status and processing_status to 'cancelled'.
863
868
  * Uses the current active session if no sessionId is provided.
864
869
  */
865
- cancelSession(sessionId?: string): Promise<SDKResult<PatchSessionResponse>>;
870
+ cancelSession(sessionId?: string, options?: {
871
+ keepAlive?: boolean;
872
+ }): Promise<SDKResult<PatchSessionResponse>>;
866
873
  /**
867
874
  * Get the resolved discovery config.
868
875
  * Returns error if discovery hasn't been fetched yet.
@@ -1098,7 +1105,9 @@ export declare class SessionManager {
1098
1105
  /**
1099
1106
  * Patch an existing session (e.g., update user_status or processing_status).
1100
1107
  */
1101
- patchSession(baseUrl: string, request: PatchSessionRequest, sessionId?: string): Promise<ApiCallResult<PatchSessionResponse>>;
1108
+ patchSession(baseUrl: string, request: PatchSessionRequest, sessionId?: string, options?: {
1109
+ keepAlive?: boolean;
1110
+ }): Promise<ApiCallResult<PatchSessionResponse>>;
1102
1111
  /**
1103
1112
  * Trigger processing for a specific template in a session.
1104
1113
  */
package/dist/index.mjs CHANGED
@@ -202,7 +202,8 @@ var r = "/.well-known/medscribealliance", i = 3600 * 1e3, a = /* @__PURE__ */ fu
202
202
  additional_data: e.record(e.string(), e.any()).optional(),
203
203
  language_hint: e.array(e.string()).optional(),
204
204
  transcript_language: e.string().optional(),
205
- templates: e.array(e.string()).optional()
205
+ templates: e.array(e.string()).optional(),
206
+ conversation_id: e.string().optional()
206
207
  }), le = e.object({
207
208
  session_id: e.string().min(1, "session_id is required"),
208
209
  status: e.string(),
@@ -456,7 +457,7 @@ var N = class {
456
457
  headers: t,
457
458
  credentials: n ? "omit" : "include"
458
459
  };
459
- if (e.isUpload && e.uploadFormFields) {
460
+ if (e.keepAlive && (r.keepalive = !0), e.isUpload && e.uploadFormFields) {
460
461
  let t = new FormData();
461
462
  for (let [n, r] of Object.entries(e.uploadFormFields)) t.append(n, r);
462
463
  e.uploadBlob && t.append(e.uploadFileFieldName ?? "file", e.uploadBlob, e.uploadFileName), r.body = t;
@@ -832,21 +833,22 @@ var F = class {
832
833
  throw e instanceof v ? e : new v(`Failed to get session status: ${e instanceof Error ? e.message : "Unknown error"}`);
833
834
  }
834
835
  }
835
- async patchSession(e, t, n) {
836
+ async patchSession(e, t, n, r) {
836
837
  try {
837
- let r = n ?? this.currentSession?.session_id;
838
- if (!r) throw new v("No active session. Provide a sessionId or start a session first.");
839
- this.validator.validateSessionId(r), this.validator.validatePatchSessionRequest(t);
840
- let i = `${e}/sessions/${r}`;
841
- this.debug && console.log("[ScribeSDK] Patching session:", r, t);
842
- let a = await this.transport.request({
838
+ let i = n ?? this.currentSession?.session_id;
839
+ if (!i) throw new v("No active session. Provide a sessionId or start a session first.");
840
+ this.validator.validateSessionId(i), this.validator.validatePatchSessionRequest(t);
841
+ let a = `${e}/sessions/${i}`;
842
+ this.debug && console.log("[ScribeSDK] Patching session:", i, t);
843
+ let o = await this.transport.request({
843
844
  method: "PATCH",
844
- url: i,
845
- body: t
845
+ url: a,
846
+ body: t,
847
+ keepAlive: r?.keepAlive
846
848
  });
847
- return this.validator.validatePatchSessionResponse(a.data), this.debug && console.log("[ScribeSDK] Session patched:", r, a.data.status), {
848
- data: a.data,
849
- httpStatus: a.status
849
+ return this.validator.validatePatchSessionResponse(o.data), this.debug && console.log("[ScribeSDK] Session patched:", i, o.data.status), {
850
+ data: o.data,
851
+ httpStatus: o.status
850
852
  };
851
853
  } catch (e) {
852
854
  throw e instanceof v ? e : new v(`Failed to patch session: ${e instanceof Error ? e.message : "Unknown error"}`);
@@ -2328,27 +2330,27 @@ var Q = class {
2328
2330
  getCurrentSession() {
2329
2331
  return this.recordingManager.getActiveSession() ?? this.sessionManager.getCurrentSession();
2330
2332
  }
2331
- async updateSession(e, t) {
2332
- let n = this.getEffectiveBaseUrl();
2333
- return this.wrapResult(() => this.sessionManager.patchSession(n, e, t));
2333
+ async updateSession(e, t, n) {
2334
+ let r = this.getEffectiveBaseUrl();
2335
+ return this.wrapResult(() => this.sessionManager.patchSession(r, e, t, n));
2334
2336
  }
2335
2337
  async processTemplate(e, t) {
2336
2338
  let n = this.getEffectiveBaseUrl();
2337
2339
  return this.wrapResult(() => this.sessionManager.processTemplate(n, e, t));
2338
2340
  }
2339
- async cancelSession(e) {
2340
- let t = e ?? this.recordingManager.getActiveSession()?.session_id ?? this.sessionManager.getCurrentSession()?.session_id;
2341
+ async cancelSession(e, t) {
2342
+ let n = e ?? this.recordingManager.getActiveSession()?.session_id ?? this.sessionManager.getCurrentSession()?.session_id;
2341
2343
  return this.recordingManager.isRecording() && this.recordingManager.forceStop(), this.recordingManager.reset(), this.sessionManager.clearCurrentSession(), this.callbackRegistry.dispatch("onSessionEvent", {
2342
2344
  type: p.DISCARDED,
2343
2345
  timestamp: (/* @__PURE__ */ new Date()).toISOString(),
2344
2346
  data: {
2345
- sessionId: t ?? null,
2347
+ sessionId: n ?? null,
2346
2348
  reason: h.CANCELLED
2347
2349
  }
2348
2350
  }), this.updateSession({
2349
2351
  user_status: "cancelled",
2350
2352
  processing_status: "cancelled"
2351
- }, t);
2353
+ }, n, t);
2352
2354
  }
2353
2355
  getDiscoveryConfig() {
2354
2356
  try {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "med-scribe-alliance-ts-sdk",
3
- "version": "2.0.54",
3
+ "version": "2.0.55",
4
4
  "description": "TypeScript SDK for the MedScribe Alliance Protocol",
5
5
  "main": "dist/index.mjs",
6
6
  "module": "dist/index.mjs",