@sinch/functions-runtime 0.7.2 → 0.7.3

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.ts CHANGED
@@ -994,10 +994,23 @@ export interface IFunctionStorage {
994
994
  * @param callId - The call the recording belongs to
995
995
  * @param format - Lowercase file extension, `mp3` or `wav`
996
996
  */
997
+ /**
998
+ * The presigned PUT URL for `recordings/<callId>.<format>`: the same URL the host swaps in for
999
+ * `recordToFunctions()`. Use it to pass your own `startRecording({ destinationUrl })` (or any
1000
+ * recording command) the function's storage as the destination. Optional like
1001
+ * `getRecordingDestination`; the built-in dev and production storage both provide it.
1002
+ *
1003
+ * @param callId - The call the recording belongs to
1004
+ * @param format - `mp3` (default) or `wav`, any case
1005
+ * @throws On an unsupported format, or when no URL can be produced (dev without a tunnel)
1006
+ */
1007
+ recordingUrl?(callId: string, format?: string): Promise<string>;
997
1008
  getRecordingDestination?(callId: string, format: "mp3" | "wav"): Promise<string>;
998
1009
  }
999
1010
  /** Where the dev runtime receives Sinch's recording upload (`PUT <path><callId>.<format>`). */
1000
1011
  export declare const RECORDING_RECEIVER_PATH = "/_sinch/recording/";
1012
+ /** Lowercase a recording format and reject anything but `mp3` or `wav`. */
1013
+ export declare function normalizeRecordingFormat(format: string): "mp3" | "wav";
1001
1014
  /**
1002
1015
  * The storage key for a call's recording, `recordings/<callId>.<format>`, with anything outside
1003
1016
  * `[\w-]` in the callId replaced so it cannot leave `recordings/`.
@@ -4119,7 +4132,7 @@ export declare function handleVoiceWebhook(userFunction: SinchFunction, context:
4119
4132
  * whose `destinationUrl` is {@link RECORD_TO_FUNCTIONS_SENTINEL}. This walks the finished
4120
4133
  * webhook body (the command can sit inside any nested flow), asks the storage for a URL for the
4121
4134
  * exact key `recordings/<callId>.<format>`, and writes it in. Where that is impossible — no
4122
- * callId, storage without `getRecordingDestination`, or it throws — the command is removed and
4135
+ * callId, storage with neither `recordingUrl` nor `getRecordingDestination`, or it throws — the command is removed and
4123
4136
  * a warning logged, so the placeholder never reaches Sinch.
4124
4137
  * @internal
4125
4138
  */
@@ -6023,6 +6036,8 @@ export declare class LocalStorage implements IFunctionStorage {
6023
6036
  * `PUT /_sinch/recording/:file` receiver (RECORDING_RECEIVER_PATH) over the tunnel, which writes into `recordings/`.
6024
6037
  */
6025
6038
  getRecordingDestination(callId: string, format: "mp3" | "wav"): Promise<string>;
6039
+ /** The URL `recordToFunctions()` records to; see {@link IFunctionStorage.recordingUrl}. */
6040
+ recordingUrl(callId: string, format?: string): Promise<string>;
6026
6041
  write(key: string, data: string | Buffer): Promise<void>;
6027
6042
  read(key: string): Promise<Buffer>;
6028
6043
  list(prefix?: string): Promise<string[]>;
package/dist/index.js CHANGED
@@ -116,6 +116,7 @@ import {
116
116
  isTextMessage,
117
117
  isVoiceV1Callback,
118
118
  isVoiceWebhook,
119
+ normalizeRecordingFormat,
119
120
  onCall,
120
121
  parseJson,
121
122
  realtimeAgent,
@@ -148,7 +149,7 @@ import {
148
149
  validateVoiceV1Request,
149
150
  verifyVoiceWebhook,
150
151
  voiceRelay
151
- } from "./chunk-KGCIUPCT.js";
152
+ } from "./chunk-KCLRM3MM.js";
152
153
  export {
153
154
  AGENT_HEADER_TOKEN,
154
155
  AGENT_STREAM_PATH,
@@ -265,6 +266,7 @@ export {
265
266
  isTextMessage,
266
267
  isVoiceV1Callback,
267
268
  isVoiceWebhook,
269
+ normalizeRecordingFormat,
268
270
  onCall,
269
271
  parseJson,
270
272
  parseJson as parseJsonLenient,
@@ -266,6 +266,17 @@ interface IFunctionStorage {
266
266
  * @param callId - The call the recording belongs to
267
267
  * @param format - Lowercase file extension, `mp3` or `wav`
268
268
  */
269
+ /**
270
+ * The presigned PUT URL for `recordings/<callId>.<format>`: the same URL the host swaps in for
271
+ * `recordToFunctions()`. Use it to pass your own `startRecording({ destinationUrl })` (or any
272
+ * recording command) the function's storage as the destination. Optional like
273
+ * `getRecordingDestination`; the built-in dev and production storage both provide it.
274
+ *
275
+ * @param callId - The call the recording belongs to
276
+ * @param format - `mp3` (default) or `wav`, any case
277
+ * @throws On an unsupported format, or when no URL can be produced (dev without a tunnel)
278
+ */
279
+ recordingUrl?(callId: string, format?: string): Promise<string>;
269
280
  getRecordingDestination?(callId: string, format: "mp3" | "wav"): Promise<string>;
270
281
  }
271
282
  interface ClientContext {
package/dist/voice/v2.js CHANGED
@@ -42,7 +42,7 @@ import {
42
42
  toWebhookRequest,
43
43
  tool,
44
44
  voiceRelay
45
- } from "../chunk-KGCIUPCT.js";
45
+ } from "../chunk-KCLRM3MM.js";
46
46
  export {
47
47
  Client,
48
48
  CommandBuilder,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sinch/functions-runtime",
3
- "version": "0.7.2",
3
+ "version": "0.7.3",
4
4
  "description": "Node.js SDK and local development runtime for Sinch Functions: voice, messaging and HTTP serverless functions",
5
5
  "type": "module",
6
6
  "exports": {