@sinch/functions-runtime 0.7.0 → 0.7.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/bin/sinch-runtime.js +1 -1
- package/dist/{chunk-DLBCKZ6X.js → chunk-5K5FDUEL.js} +81 -5
- package/dist/chunk-5K5FDUEL.js.map +1 -0
- package/dist/index.d.ts +10 -1
- package/dist/index.js +1 -1
- package/dist/voice/v2.d.ts +5 -0
- package/dist/voice/v2.js +1 -1
- package/package.json +1 -1
- package/dist/chunk-DLBCKZ6X.js.map +0 -1
|
@@ -60226,6 +60226,67 @@ function toHeaderMap(headers) {
|
|
|
60226
60226
|
return { ...headers };
|
|
60227
60227
|
}
|
|
60228
60228
|
|
|
60229
|
+
// ../voice-v2-preview/dist/core/say-limit.js
|
|
60230
|
+
var MAX_SAY_CHARS = 600;
|
|
60231
|
+
var MAX_MESSAGES = 10;
|
|
60232
|
+
var EXCERPT_CHARS = 40;
|
|
60233
|
+
var WHITESPACE = "\\u0009-\\u000D\\u0020\\u0085\\u00A0\\u1680\\u2000-\\u200A\\u2028\\u2029\\u202F\\u205F\\u3000";
|
|
60234
|
+
var SENTENCE_BREAK = new RegExp(`(?<=[.!?]+["'\u201D\u2019)\\]]*)[${WHITESPACE}]+`, "g");
|
|
60235
|
+
var EDGE_WHITESPACE = new RegExp(`^[${WHITESPACE}]+|[${WHITESPACE}]+$`, "g");
|
|
60236
|
+
function sayParts(text, format) {
|
|
60237
|
+
if (text.length <= MAX_SAY_CHARS)
|
|
60238
|
+
return [text];
|
|
60239
|
+
if (format === "SSML") {
|
|
60240
|
+
throw new Error(`Voice v2 limits each SAY message to ${MAX_SAY_CHARS} characters, and SSML is never split. This SSML document is ${text.length} characters. Shorten it, or pass it as several say() calls.`);
|
|
60241
|
+
}
|
|
60242
|
+
return packSentences(text.replace(EDGE_WHITESPACE, ""));
|
|
60243
|
+
}
|
|
60244
|
+
function assertPromptFits(text) {
|
|
60245
|
+
if (text.length > MAX_SAY_CHARS) {
|
|
60246
|
+
throw new Error(`Voice v2 limits each SAY message to ${MAX_SAY_CHARS} characters, and menu prompts are never split. This prompt is ${text.length} characters. Shorten it.`);
|
|
60247
|
+
}
|
|
60248
|
+
}
|
|
60249
|
+
function assertMessageCount(count) {
|
|
60250
|
+
if (count > MAX_MESSAGES) {
|
|
60251
|
+
throw new Error(`Voice v2 limits a messages list to ${MAX_MESSAGES} items, and each SAY message to ${MAX_SAY_CHARS} characters. These say()/play() calls need ${count} items once long text is split. Shorten the text.`);
|
|
60252
|
+
}
|
|
60253
|
+
}
|
|
60254
|
+
function assertPromptMessageCount(count) {
|
|
60255
|
+
if (count > MAX_MESSAGES) {
|
|
60256
|
+
throw new Error(`Voice v2 limits a menu prompt to ${MAX_MESSAGES} messages. This prompt's say()/play() calls need ${count}. Remove some.`);
|
|
60257
|
+
}
|
|
60258
|
+
}
|
|
60259
|
+
function packSentences(text) {
|
|
60260
|
+
const sentences = sentenceSpans(text);
|
|
60261
|
+
for (const { start, end } of sentences) {
|
|
60262
|
+
if (end - start > MAX_SAY_CHARS) {
|
|
60263
|
+
throw new Error(`Voice v2 limits each SAY message to ${MAX_SAY_CHARS} characters. Longer text is split between sentences, but this sentence alone is ${end - start} characters: "${text.slice(start, start + EXCERPT_CHARS)}\u2026". Shorten it.`);
|
|
60264
|
+
}
|
|
60265
|
+
}
|
|
60266
|
+
const parts = [];
|
|
60267
|
+
let first = 0;
|
|
60268
|
+
while (first < sentences.length) {
|
|
60269
|
+
const start = sentences[first].start;
|
|
60270
|
+
let last = first;
|
|
60271
|
+
while (last + 1 < sentences.length && sentences[last + 1].end - start <= MAX_SAY_CHARS) {
|
|
60272
|
+
last++;
|
|
60273
|
+
}
|
|
60274
|
+
parts.push(text.slice(start, sentences[last].end));
|
|
60275
|
+
first = last + 1;
|
|
60276
|
+
}
|
|
60277
|
+
return parts;
|
|
60278
|
+
}
|
|
60279
|
+
function sentenceSpans(text) {
|
|
60280
|
+
const spans = [];
|
|
60281
|
+
let start = 0;
|
|
60282
|
+
for (const separator of text.matchAll(SENTENCE_BREAK)) {
|
|
60283
|
+
spans.push({ start, end: separator.index });
|
|
60284
|
+
start = separator.index + separator[0].length;
|
|
60285
|
+
}
|
|
60286
|
+
spans.push({ start, end: text.length });
|
|
60287
|
+
return spans;
|
|
60288
|
+
}
|
|
60289
|
+
|
|
60229
60290
|
// ../voice-v2-preview/dist/core/commands.js
|
|
60230
60291
|
function internals(builder) {
|
|
60231
60292
|
return builder;
|
|
@@ -60438,8 +60499,12 @@ var PromptBuilder = class {
|
|
|
60438
60499
|
*
|
|
60439
60500
|
* @param text - Text to synthesise, or an SSML document when `format` is `SSML`
|
|
60440
60501
|
* @param options - Voice and format overrides
|
|
60502
|
+
* @throws If `text` is over 600 characters (prompts are never split), or the prompt would hold
|
|
60503
|
+
* more than 10 messages
|
|
60441
60504
|
*/
|
|
60442
60505
|
say(text, options = {}) {
|
|
60506
|
+
assertPromptFits(text);
|
|
60507
|
+
assertPromptMessageCount(this.messages.length + 1);
|
|
60443
60508
|
this.messages.push(sayMessage(text, options));
|
|
60444
60509
|
return this;
|
|
60445
60510
|
}
|
|
@@ -60447,8 +60512,10 @@ var PromptBuilder = class {
|
|
|
60447
60512
|
* Play an audio file.
|
|
60448
60513
|
*
|
|
60449
60514
|
* @param url - Publicly reachable URL of the audio file
|
|
60515
|
+
* @throws If the prompt would hold more than 10 messages
|
|
60450
60516
|
*/
|
|
60451
60517
|
play(url2) {
|
|
60518
|
+
assertPromptMessageCount(this.messages.length + 1);
|
|
60452
60519
|
this.messages.push({ type: "PLAY", play: { url: url2 } });
|
|
60453
60520
|
return this;
|
|
60454
60521
|
}
|
|
@@ -60504,6 +60571,7 @@ var MenuItemBuilder = class {
|
|
|
60504
60571
|
* Prompt played when the menu is entered.
|
|
60505
60572
|
*
|
|
60506
60573
|
* @param prompt - Plain text, a {@link PromptBuilder}, or a callback receiving one
|
|
60574
|
+
* @throws If any prompt text is over 600 characters, or a callback queues more than 10 messages
|
|
60507
60575
|
*/
|
|
60508
60576
|
prompt(prompt) {
|
|
60509
60577
|
this.item.prompt = resolvePrompt(prompt);
|
|
@@ -60513,6 +60581,7 @@ var MenuItemBuilder = class {
|
|
|
60513
60581
|
* Prompt played on each retry. Falls back to `prompt` when unset.
|
|
60514
60582
|
*
|
|
60515
60583
|
* @param prompt - Plain text, a {@link PromptBuilder}, or a callback receiving one
|
|
60584
|
+
* @throws If any prompt text is over 600 characters, or a callback queues more than 10 messages
|
|
60516
60585
|
*/
|
|
60517
60586
|
repeatPrompt(prompt) {
|
|
60518
60587
|
this.item.repeatPrompt = resolvePrompt(prompt);
|
|
@@ -60660,21 +60729,28 @@ var CommandBuilder = class {
|
|
|
60660
60729
|
/** Set only on the builder `onCall` injects — see {@link FlowScope} */
|
|
60661
60730
|
scope;
|
|
60662
60731
|
/**
|
|
60663
|
-
* Speak text on the call.
|
|
60732
|
+
* Speak text on the call. `TEXT` over 600 characters is split between sentences into
|
|
60733
|
+
* consecutive messages.
|
|
60664
60734
|
*
|
|
60665
60735
|
* @param text - Text to synthesise, or an SSML document when `format` is `SSML`
|
|
60666
60736
|
* @param options - Voice and format overrides
|
|
60737
|
+
* @throws If a sentence, or any SSML document, is over 600 characters, or the pending
|
|
60738
|
+
* messages would pass 10 items
|
|
60667
60739
|
*/
|
|
60668
60740
|
say(text, options = {}) {
|
|
60669
|
-
|
|
60741
|
+
const messages = sayParts(text, options.format).map((part) => sayMessage(part, options));
|
|
60742
|
+
assertMessageCount(this.pending.length + messages.length);
|
|
60743
|
+
this.pending.push(...messages);
|
|
60670
60744
|
return this;
|
|
60671
60745
|
}
|
|
60672
60746
|
/**
|
|
60673
60747
|
* Play an audio file on the call.
|
|
60674
60748
|
*
|
|
60675
60749
|
* @param url - Publicly reachable URL of the audio file
|
|
60750
|
+
* @throws If the pending messages would pass 10 items
|
|
60676
60751
|
*/
|
|
60677
60752
|
play(url2) {
|
|
60753
|
+
assertMessageCount(this.pending.length + 1);
|
|
60678
60754
|
this.pending.push({ type: "PLAY", play: { url: url2 } });
|
|
60679
60755
|
return this;
|
|
60680
60756
|
}
|
|
@@ -68977,10 +69053,10 @@ var VALID_DIGITS = "0-9\uFF10-\uFF19\u0660-\u0669\u06F0-\u06F9";
|
|
|
68977
69053
|
var DASHES = "-\u2010-\u2015\u2212\u30FC\uFF0D";
|
|
68978
69054
|
var SLASHES = "\uFF0F/";
|
|
68979
69055
|
var DOTS = "\uFF0E.";
|
|
68980
|
-
var
|
|
69056
|
+
var WHITESPACE2 = " \xA0\xAD\u200B\u2060\u3000";
|
|
68981
69057
|
var BRACKETS = "()\uFF08\uFF09\uFF3B\uFF3D\\[\\]";
|
|
68982
69058
|
var TILDES = "~\u2053\u223C\uFF5E";
|
|
68983
|
-
var VALID_PUNCTUATION = "".concat(DASHES).concat(SLASHES).concat(DOTS).concat(
|
|
69059
|
+
var VALID_PUNCTUATION = "".concat(DASHES).concat(SLASHES).concat(DOTS).concat(WHITESPACE2).concat(BRACKETS).concat(TILDES);
|
|
68984
69060
|
var PLUS_CHARS = "+\uFF0B";
|
|
68985
69061
|
|
|
68986
69062
|
// ../../node_modules/libphonenumber-js/es6/helpers/stripIddPrefix.js
|
|
@@ -77154,4 +77230,4 @@ serve-static/index.js:
|
|
|
77154
77230
|
* MIT Licensed
|
|
77155
77231
|
*)
|
|
77156
77232
|
*/
|
|
77157
|
-
//# sourceMappingURL=chunk-
|
|
77233
|
+
//# sourceMappingURL=chunk-5K5FDUEL.js.map
|