jsfe 1.104.0 → 1.105.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/README.md +9 -0
- package/dist/forms/address-flows.d.ts.map +1 -1
- package/dist/forms/address-flows.js +8 -7
- package/dist/forms/index.d.ts +1 -0
- package/dist/forms/index.d.ts.map +1 -1
- package/dist/forms/index.js +3 -1
- package/dist/forms/scheduling-flows.d.ts +13 -0
- package/dist/forms/scheduling-flows.d.ts.map +1 -0
- package/dist/forms/scheduling-flows.js +301 -0
- package/dist/helpers/address.d.ts +34 -1
- package/dist/helpers/address.d.ts.map +1 -1
- package/dist/helpers/address.js +33 -2
- package/dist/helpers/index.d.ts +18 -1
- package/dist/helpers/index.d.ts.map +1 -1
- package/dist/helpers/index.js +4 -3
- package/dist/helpers/schedule.d.ts +82 -0
- package/dist/helpers/schedule.d.ts.map +1 -0
- package/dist/helpers/schedule.js +606 -0
- package/dist/runtime-identity.js +1 -1
- package/package.json +1 -1
package/dist/helpers/address.js
CHANGED
|
@@ -72,7 +72,21 @@ export function addressVerdict(result, said) {
|
|
|
72
72
|
}
|
|
73
73
|
/** The validate-address verdict applied to the street answer (the street validator's last step). Returns the validator's
|
|
74
74
|
* answer: a proposal to confirm Google's version first, or the street accepted. `keys` are the yes/no words for each language. */
|
|
75
|
-
|
|
75
|
+
/** The unit that goes into the street's one check: the form's, else the unit the street answer itself carries ("# 2",
|
|
76
|
+
* "Apt 2", "apartamento 2"), read with the unit input's own pattern. '' when none, or when it is not unit-shaped. */
|
|
77
|
+
export function streetUnit(state, values, reading) {
|
|
78
|
+
const norm = x => String(x ?? '').replace(/^(apartment|apartamento|departamento|apt\.?|unit|unidad|#)\s*/i, '').replace(/[.,#:]+/g, ' ').replace(/\s+/g, ' ').trim();
|
|
79
|
+
const shaped = u => /^[A-Za-z]$/.test(u) || /\d/.test(u) && /^[A-Za-z0-9-]{1,8}(?:\s[A-Za-z0-9-]{1,4})?$/.test(u) ? u : '';
|
|
80
|
+
const given = Object.assign({}, state.values, values).unit;
|
|
81
|
+
if (given)
|
|
82
|
+
return shaped(norm(given));
|
|
83
|
+
const spec = (state.specs || []).find(x => x.name === 'unit'), profile = spec && spec.profile, raw = String(reading && reading.raw || '');
|
|
84
|
+
if (!raw || !profile || !profile.regex)
|
|
85
|
+
return '';
|
|
86
|
+
const m = new RegExp(profile.regex, 'i').exec(raw);
|
|
87
|
+
return m ? shaped(norm(m[profile.group || 0])) : '';
|
|
88
|
+
}
|
|
89
|
+
export function streetCheck(state, values, verdict, value, reading, keys, unit) {
|
|
76
90
|
const data = state.data, said = String(value), cur = Object.assign({}, state.values, values);
|
|
77
91
|
const derived = state.accepted?.city?.origin === 'derived', cityInput = data.city_known === true;
|
|
78
92
|
const setCity = v => { if (!v.city)
|
|
@@ -112,6 +126,8 @@ export function streetCheck(state, values, verdict, value, reading, keys) {
|
|
|
112
126
|
data.check = null;
|
|
113
127
|
return { ok: true, value: said };
|
|
114
128
|
}
|
|
129
|
+
// the unit checked with the street, and whether Google confirmed it: the unit's own check and the form's check read it
|
|
130
|
+
data.check_unit = unit && verdict && verdict.street ? { unit: String(unit), confirmed: verdict.unit_confirmed === true } : null;
|
|
115
131
|
data.check = null;
|
|
116
132
|
data.street_city = cityFrom(verdict);
|
|
117
133
|
data.check_street = verdict && verdict.street ? verdict.street : '';
|
|
@@ -184,6 +200,12 @@ export function unitsGiven(state) {
|
|
|
184
200
|
data.units_told = true;
|
|
185
201
|
return { ok: false, invalid: [{ name: 'unit' }] };
|
|
186
202
|
}
|
|
203
|
+
// the unit Google checked with the street (given with it or before it) and could not confirm: asked once more, then kept as given
|
|
204
|
+
const c = data.check_unit, given = String(state.values.unit ?? '').replace(/^(apartment|apartamento|departamento|apt\.?|unit|unidad|#)\s*/i, '').replace(/[.,#:]+/g, ' ').replace(/\s+/g, ' ').trim();
|
|
205
|
+
if (c && c.confirmed === false && given === c.unit && !data.unit_retry) {
|
|
206
|
+
data.unit_retry = true;
|
|
207
|
+
return { ok: false, invalid: [{ name: 'unit' }], message: 'I could not confirm apartment ' + c.unit + ' at that address.', message_es: 'No pude confirmar el apartamento ' + c.unit + ' en esa dirección.' };
|
|
208
|
+
}
|
|
187
209
|
return { ok: true };
|
|
188
210
|
}
|
|
189
211
|
/** The unit question: the building's own wording once Google says it has units, else the form's ordinary one. */
|
|
@@ -202,16 +224,25 @@ export function unitPrecheck(data, value) {
|
|
|
202
224
|
const u = String(value).replace(/^(apartment|apartamento|departamento|apt\.?|unit|unidad|#)\s*/i, '').replace(/[.,#:]+/g, ' ').replace(/\s+/g, ' ').trim();
|
|
203
225
|
if (!(/^[A-Za-z]$/.test(u) || /\d/.test(u) && /^[A-Za-z0-9-]{1,8}(?:\s[A-Za-z0-9-]{1,4})?$/.test(u)))
|
|
204
226
|
return { ok: false, message: "That doesn't look like an apartment number.", message_es: 'Eso no parece un número de apartamento.' };
|
|
227
|
+
if (data.check_unit && data.check_unit.unit === u)
|
|
228
|
+
return { ok: true, value: String(value), check: true, known: true, confirmed: data.check_unit.confirmed, unit: u };
|
|
205
229
|
return data.check_street ? { ok: true, value: String(value), check: true, unit: u } : { ok: true, value: String(value) };
|
|
206
230
|
}
|
|
207
231
|
/** Google's answer for the address with its unit: a unit it could not confirm is asked once more, then kept as given. */
|
|
208
232
|
export function unitResult(data, pre, checked) {
|
|
209
233
|
if (!pre.check)
|
|
210
234
|
return { ok: pre.ok, ...(pre.value !== undefined ? { value: pre.value } : {}), ...(pre.quiet ? { quiet: true } : {}), ...(pre.message ? { message: pre.message, message_es: pre.message_es } : {}) };
|
|
235
|
+
// a unit the street's check already carried: taken without a second call; the form's check asks it once more when unconfirmed
|
|
236
|
+
const unconfirmed = () => ({ ok: false, message: 'I could not confirm apartment ' + pre.unit + ' at that address.', message_es: 'No pude confirmar el apartamento ' + pre.unit + ' en esa dirección.' });
|
|
237
|
+
if (pre.known) {
|
|
238
|
+
if (data.validation)
|
|
239
|
+
data.validation.unit_confirmed = pre.confirmed;
|
|
240
|
+
return { ok: true, value: pre.value };
|
|
241
|
+
}
|
|
211
242
|
const confirmed = !!(checked && checked.status === 'ok' && checked.parts && checked.parts.subpremise && checked.parts.subpremise.level === 'CONFIRMED');
|
|
212
243
|
if (checked && checked.status === 'ok' && !confirmed && !data.unit_retry) {
|
|
213
244
|
data.unit_retry = true;
|
|
214
|
-
return
|
|
245
|
+
return unconfirmed();
|
|
215
246
|
}
|
|
216
247
|
data.unit_retry = false;
|
|
217
248
|
if (data.validation)
|
package/dist/helpers/index.d.ts
CHANGED
|
@@ -75,6 +75,14 @@ export namespace STANDARD_FUNCTIONS {
|
|
|
75
75
|
export { yesNoKeys };
|
|
76
76
|
export { channelVerb };
|
|
77
77
|
export { dateToWords };
|
|
78
|
+
export { hoursPhrase };
|
|
79
|
+
export { scheduleOpenNow };
|
|
80
|
+
export { zipCovered };
|
|
81
|
+
export { readWhen };
|
|
82
|
+
export { openSlots };
|
|
83
|
+
export { slotToWords };
|
|
84
|
+
export { todayIn };
|
|
85
|
+
export { minutesUntil };
|
|
78
86
|
export { amountToSpeech };
|
|
79
87
|
export { phoneToSpeech };
|
|
80
88
|
export { validateCardNumber };
|
|
@@ -232,6 +240,15 @@ import { sorryNotCaught } from './phrases.js';
|
|
|
232
240
|
import { yesNoKeys } from './phrases.js';
|
|
233
241
|
import { channelVerb } from './phrases.js';
|
|
234
242
|
import { dateToWords } from './date-words.js';
|
|
243
|
+
import { agentHoursText } from './schedule.js';
|
|
244
|
+
import { hoursPhrase } from './schedule.js';
|
|
245
|
+
import { scheduleOpenNow } from './schedule.js';
|
|
246
|
+
import { zipCovered } from './schedule.js';
|
|
247
|
+
import { readWhen } from './schedule.js';
|
|
248
|
+
import { openSlots } from './schedule.js';
|
|
249
|
+
import { slotToWords } from './schedule.js';
|
|
250
|
+
import { todayIn } from './schedule.js';
|
|
251
|
+
import { minutesUntil } from './schedule.js';
|
|
235
252
|
import { amountToSpeech } from './amount-to-speech.js';
|
|
236
253
|
import { phoneToSpeech } from './phone-to-speech.js';
|
|
237
254
|
import { validateCardNumber } from './card-checks.js';
|
|
@@ -317,5 +334,5 @@ import { chatTranscript } from './sendables.js';
|
|
|
317
334
|
import { conversationCopy } from './sendables.js';
|
|
318
335
|
import { CONVERSATION_KEY } from './sendables.js';
|
|
319
336
|
import { WEB_LINK_KEY } from './sendables.js';
|
|
320
|
-
export { continuationSafetyProtocol, cancelFormTask, contextualResponseProtocol, validateFormResponse, hasFormResponse, formProposalPolicy, stageFormProposal, nextFormProposal, formProposalReadings, bindFormProposal, retireStaleFormProposal, decideFormProposal, commitFormProposals, settleFormProposalValidation, formProposalProtocol, validateFormProposalPolicy, validateFormProposalDescriptor, formProposalDescriptor, clearFormMisses, formNoOwner, missFormInput, formMustComplete, formInputPrompt, formUserDescriptionSource, formConcernLine, formAcknowledges, consumeFormFeedback, keepFormLine, deferFormClarification, takeFormClarification, formClarificationKept, clearFormLines, formConversationOutcome, readMoneyAmount, isMoneyAmount, moneyIntentAllows, isPastPaymentStatement, isPartialMoneyAnswer, validateMoneyOptions, takeChoiceOffer, saysConfirmWord, saysNoValue, confirmOutOfOrderLine, matchesChoice, ANSWER_WORDS, CONFIRM_WORDS, isAnswer, isAgentRequest, isExitRequest, isGlobalExit, isOtherRequest, isSpelledFragment, isAmountAnswer, amountInAnswer, pickChoice, pickWholeChoice, withoutPromptEcho, isReaderFiller, readEmail, emailWithoutEnding, emailEnding, emailSaid, readPhone, readInternationalPhone, readIdentifier, last4, maskEmail, callerTextNumber, textDestination, callerIsInternational, normalizeAndFindCapture, anythingElse, goodbye, sayName, sorryNotCaught, yesNoKeys, channelVerb, dateToWords, amountToSpeech, phoneToSpeech, validateCardNumber, validateExpiration, consumeActionReceipt, authorizeFormActionRetry, formSignature, selectFormAction, confirmFormRevision, prepareFormAction, actionConfirmationValid, beginFormAction, finishFormAction, actionGateVerified, sourceNeedsLoad, beginSourceRefresh, completeSourceRefresh, pickProviderQuestion, matchInputs, readFormAnswer, readArgument, groundAmount, joinSpokenNumbers, findNumbers, assignNumbers, addressDraft, readInputProfile, formAcceptanceTrace, resolveFormInputs, formInputApplies, formInputFilled, nextFormInput, formInputChain, openFormInstance, validateFormIncompleteOutcome, formIncompleteOutcome, validateFormExhaustion, exhaustFormInput, formInitialReadings, orderFormReadings, proposedFormValues, applyFormValidation, formReadingDependencies, exclusiveFormReadings, enrichFormMatches, expandFormActivations, settleFormActivations, rememberFormArguments, resetFormInputs, hasFormValue, formPath, formValuesEqual, formReadingReady, formReadingRelevant, formPreparation, queueFormReadings, pendingFormReadings, formWorkLimit, answerResetsFormReplays, rejectFormReadings, invalidateFormInputs, acceptFormReadings, formInstanceApplies, formParentResume, closeFormInstance, checkOtp, clearOtp, maskDestination, validateOTP, OTP_EXPIRY_MS, validateDigits, validatePhone, validateEmail, urlToSpeech, textWithUrlToSpeech, joinSpokenDigits, spokenDigitsText, wholeSpokenNumber, numberAlone, registerSendable, sendables, chatTranscript, conversationCopy, CONVERSATION_KEY, WEB_LINK_KEY };
|
|
337
|
+
export { continuationSafetyProtocol, cancelFormTask, contextualResponseProtocol, validateFormResponse, hasFormResponse, formProposalPolicy, stageFormProposal, nextFormProposal, formProposalReadings, bindFormProposal, retireStaleFormProposal, decideFormProposal, commitFormProposals, settleFormProposalValidation, formProposalProtocol, validateFormProposalPolicy, validateFormProposalDescriptor, formProposalDescriptor, clearFormMisses, formNoOwner, missFormInput, formMustComplete, formInputPrompt, formUserDescriptionSource, formConcernLine, formAcknowledges, consumeFormFeedback, keepFormLine, deferFormClarification, takeFormClarification, formClarificationKept, clearFormLines, formConversationOutcome, readMoneyAmount, isMoneyAmount, moneyIntentAllows, isPastPaymentStatement, isPartialMoneyAnswer, validateMoneyOptions, takeChoiceOffer, saysConfirmWord, saysNoValue, confirmOutOfOrderLine, matchesChoice, ANSWER_WORDS, CONFIRM_WORDS, isAnswer, isAgentRequest, isExitRequest, isGlobalExit, isOtherRequest, isSpelledFragment, isAmountAnswer, amountInAnswer, pickChoice, pickWholeChoice, withoutPromptEcho, isReaderFiller, readEmail, emailWithoutEnding, emailEnding, emailSaid, readPhone, readInternationalPhone, readIdentifier, last4, maskEmail, callerTextNumber, textDestination, callerIsInternational, normalizeAndFindCapture, anythingElse, goodbye, sayName, sorryNotCaught, yesNoKeys, channelVerb, dateToWords, agentHoursText, hoursPhrase, scheduleOpenNow, zipCovered, readWhen, openSlots, slotToWords, todayIn, minutesUntil, amountToSpeech, phoneToSpeech, validateCardNumber, validateExpiration, consumeActionReceipt, authorizeFormActionRetry, formSignature, selectFormAction, confirmFormRevision, prepareFormAction, actionConfirmationValid, beginFormAction, finishFormAction, actionGateVerified, sourceNeedsLoad, beginSourceRefresh, completeSourceRefresh, pickProviderQuestion, matchInputs, readFormAnswer, readArgument, groundAmount, joinSpokenNumbers, findNumbers, assignNumbers, addressDraft, readInputProfile, formAcceptanceTrace, resolveFormInputs, formInputApplies, formInputFilled, nextFormInput, formInputChain, openFormInstance, validateFormIncompleteOutcome, formIncompleteOutcome, validateFormExhaustion, exhaustFormInput, formInitialReadings, orderFormReadings, proposedFormValues, applyFormValidation, formReadingDependencies, exclusiveFormReadings, enrichFormMatches, expandFormActivations, settleFormActivations, rememberFormArguments, resetFormInputs, hasFormValue, formPath, formValuesEqual, formReadingReady, formReadingRelevant, formPreparation, queueFormReadings, pendingFormReadings, formWorkLimit, answerResetsFormReplays, rejectFormReadings, invalidateFormInputs, acceptFormReadings, formInstanceApplies, formParentResume, closeFormInstance, checkOtp, clearOtp, maskDestination, validateOTP, OTP_EXPIRY_MS, validateDigits, validatePhone, validateEmail, urlToSpeech, textWithUrlToSpeech, joinSpokenDigits, spokenDigitsText, wholeSpokenNumber, numberAlone, registerSendable, sendables, chatTranscript, conversationCopy, CONVERSATION_KEY, WEB_LINK_KEY };
|
|
321
338
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/helpers/index.js"],"names":[],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iB;gCAAjB,iBAAiB;kCAAjB,iBAAiB;oCAAjB,iBAAiB;8BAAjB,iBAAiB;wCAAjB,iBAAiB;mCAAjB,iBAAiB;qCAAjB,iBAAiB;mCAAjB,iBAAiB;oCAAjB,iBAAiB;iCAAjB,iBAAiB;kCAAjB,iBAAiB;yBACzqB,gBAAgB;yBAAhB,gBAAgB;gCAAhB,gBAAgB;4BAAhB,gBAAgB;8BAAhB,gBAAgB;+BACnC,iBAAiB;8BAAjB,iBAAiB;8BAAjB,iBAAiB;4BAI7B,iBAAiB;oCAAjB,iBAAiB;iCAHiB,oBAAoB;iCAApB,oBAAoB;kCAApB,oBAAoB;4BAApB,oBAAoB;iCA/BO,gBAAgB;0BAAhB,gBAAgB;+BAAhB,gBAAgB;iCAAhB,gBAAgB;iCAAhB,gBAAgB;6BAAhB,gBAAgB"}
|
package/dist/helpers/index.js
CHANGED
|
@@ -10,7 +10,7 @@ import { consumeActionReceipt, authorizeFormActionRetry, formSignature, selectFo
|
|
|
10
10
|
/**
|
|
11
11
|
* jsfe/helpers — the functions JSFE's system flows call from expressions, in ONE place for every host: reading an
|
|
12
12
|
* answer (matchesChoice, pickChoice, isAnswer, readEmail, readIdentifier, amountInAnswer, matchInputs …), saying
|
|
13
|
-
* values (amountToSpeech, phoneToSpeech, dateToWords, last4, urlToSpeech …), checking shapes and one-time codes. Pure: no credentials,
|
|
13
|
+
* values (amountToSpeech, phoneToSpeech, dateToWords, last4, urlToSpeech …), schedules and appointment times, checking shapes and one-time codes. Pure: no credentials,
|
|
14
14
|
* no network, no host state beyond the container a caller passes in.
|
|
15
15
|
*
|
|
16
16
|
* The engine does not register them by itself. A host lists them among its approved functions, usually all at once:
|
|
@@ -29,6 +29,7 @@ import { readEmail, emailWithoutEnding, emailEnding, emailSaid, readPhone, readI
|
|
|
29
29
|
import { normalizeAndFindCapture } from './capture.js';
|
|
30
30
|
import { anythingElse, goodbye, sayName, sorryNotCaught, yesNoKeys, channelVerb } from './phrases.js';
|
|
31
31
|
import { dateToWords } from './date-words.js';
|
|
32
|
+
import { agentHoursText, hoursPhrase, scheduleOpenNow, zipCovered, readWhen, openSlots, slotToWords, todayIn, minutesUntil } from './schedule.js';
|
|
32
33
|
import { amountToSpeech } from './amount-to-speech.js';
|
|
33
34
|
import { validateCardNumber, validateExpiration } from './card-checks.js';
|
|
34
35
|
import { matchInputs, readFormAnswer, readArgument, groundAmount, saysConfirmWord, saysNoValue, confirmOutOfOrderLine, readInputProfile, formAcceptanceTrace } from './match-inputs.js';
|
|
@@ -40,7 +41,7 @@ import { findNumbers, assignNumbers, joinSpokenNumbers } from './numbers.js';
|
|
|
40
41
|
import { addressDraft } from './address.js';
|
|
41
42
|
import { urlToSpeech, textWithUrlToSpeech } from './url-speech.js';
|
|
42
43
|
import { phoneToSpeech } from './phone-to-speech.js';
|
|
43
|
-
export { continuationSafetyProtocol, cancelFormTask, contextualResponseProtocol, validateFormResponse, hasFormResponse, formProposalPolicy, stageFormProposal, nextFormProposal, formProposalReadings, bindFormProposal, retireStaleFormProposal, decideFormProposal, commitFormProposals, settleFormProposalValidation, formProposalProtocol, validateFormProposalPolicy, validateFormProposalDescriptor, formProposalDescriptor, clearFormMisses, formNoOwner, missFormInput, formMustComplete, formInputPrompt, formUserDescriptionSource, formConcernLine, formAcknowledges, consumeFormFeedback, keepFormLine, deferFormClarification, takeFormClarification, formClarificationKept, clearFormLines, formConversationOutcome, readMoneyAmount, isMoneyAmount, moneyIntentAllows, isPastPaymentStatement, isPartialMoneyAnswer, validateMoneyOptions, takeChoiceOffer, saysConfirmWord, saysNoValue, confirmOutOfOrderLine, matchesChoice, ANSWER_WORDS, CONFIRM_WORDS, isAnswer, isAgentRequest, isExitRequest, isGlobalExit, isOtherRequest, isSpelledFragment, isAmountAnswer, amountInAnswer, pickChoice, pickWholeChoice, withoutPromptEcho, isReaderFiller, readEmail, emailWithoutEnding, emailEnding, emailSaid, readPhone, readInternationalPhone, readIdentifier, last4, maskEmail, callerTextNumber, textDestination, callerIsInternational, normalizeAndFindCapture, anythingElse, goodbye, sayName, sorryNotCaught, yesNoKeys, channelVerb, dateToWords, amountToSpeech, phoneToSpeech, validateCardNumber, validateExpiration, consumeActionReceipt, authorizeFormActionRetry, formSignature, selectFormAction, confirmFormRevision, prepareFormAction, actionConfirmationValid, beginFormAction, finishFormAction, actionGateVerified, sourceNeedsLoad, beginSourceRefresh, completeSourceRefresh, pickProviderQuestion, matchInputs, readFormAnswer, readArgument, groundAmount, joinSpokenNumbers, findNumbers, assignNumbers, addressDraft, readInputProfile, formAcceptanceTrace, resolveFormInputs, formInputApplies, formInputFilled, nextFormInput, formInputChain, openFormInstance, validateFormIncompleteOutcome, formIncompleteOutcome, validateFormExhaustion, exhaustFormInput, formInitialReadings, orderFormReadings, proposedFormValues, applyFormValidation, formReadingDependencies, exclusiveFormReadings, enrichFormMatches, expandFormActivations, settleFormActivations, rememberFormArguments, resetFormInputs, hasFormValue, formPath, formValuesEqual, formReadingReady, formReadingRelevant, formPreparation, queueFormReadings, pendingFormReadings, formWorkLimit, answerResetsFormReplays, rejectFormReadings, invalidateFormInputs, acceptFormReadings, formInstanceApplies, formParentResume, closeFormInstance, checkOtp, clearOtp, maskDestination, validateOTP, OTP_EXPIRY_MS, validateDigits, validatePhone, validateEmail, urlToSpeech, textWithUrlToSpeech, joinSpokenDigits, spokenDigitsText, wholeSpokenNumber, numberAlone, registerSendable, sendables, chatTranscript, conversationCopy, CONVERSATION_KEY, WEB_LINK_KEY, };
|
|
44
|
+
export { continuationSafetyProtocol, cancelFormTask, contextualResponseProtocol, validateFormResponse, hasFormResponse, formProposalPolicy, stageFormProposal, nextFormProposal, formProposalReadings, bindFormProposal, retireStaleFormProposal, decideFormProposal, commitFormProposals, settleFormProposalValidation, formProposalProtocol, validateFormProposalPolicy, validateFormProposalDescriptor, formProposalDescriptor, clearFormMisses, formNoOwner, missFormInput, formMustComplete, formInputPrompt, formUserDescriptionSource, formConcernLine, formAcknowledges, consumeFormFeedback, keepFormLine, deferFormClarification, takeFormClarification, formClarificationKept, clearFormLines, formConversationOutcome, readMoneyAmount, isMoneyAmount, moneyIntentAllows, isPastPaymentStatement, isPartialMoneyAnswer, validateMoneyOptions, takeChoiceOffer, saysConfirmWord, saysNoValue, confirmOutOfOrderLine, matchesChoice, ANSWER_WORDS, CONFIRM_WORDS, isAnswer, isAgentRequest, isExitRequest, isGlobalExit, isOtherRequest, isSpelledFragment, isAmountAnswer, amountInAnswer, pickChoice, pickWholeChoice, withoutPromptEcho, isReaderFiller, readEmail, emailWithoutEnding, emailEnding, emailSaid, readPhone, readInternationalPhone, readIdentifier, last4, maskEmail, callerTextNumber, textDestination, callerIsInternational, normalizeAndFindCapture, anythingElse, goodbye, sayName, sorryNotCaught, yesNoKeys, channelVerb, dateToWords, agentHoursText, hoursPhrase, scheduleOpenNow, zipCovered, readWhen, openSlots, slotToWords, todayIn, minutesUntil, amountToSpeech, phoneToSpeech, validateCardNumber, validateExpiration, consumeActionReceipt, authorizeFormActionRetry, formSignature, selectFormAction, confirmFormRevision, prepareFormAction, actionConfirmationValid, beginFormAction, finishFormAction, actionGateVerified, sourceNeedsLoad, beginSourceRefresh, completeSourceRefresh, pickProviderQuestion, matchInputs, readFormAnswer, readArgument, groundAmount, joinSpokenNumbers, findNumbers, assignNumbers, addressDraft, readInputProfile, formAcceptanceTrace, resolveFormInputs, formInputApplies, formInputFilled, nextFormInput, formInputChain, openFormInstance, validateFormIncompleteOutcome, formIncompleteOutcome, validateFormExhaustion, exhaustFormInput, formInitialReadings, orderFormReadings, proposedFormValues, applyFormValidation, formReadingDependencies, exclusiveFormReadings, enrichFormMatches, expandFormActivations, settleFormActivations, rememberFormArguments, resetFormInputs, hasFormValue, formPath, formValuesEqual, formReadingReady, formReadingRelevant, formPreparation, queueFormReadings, pendingFormReadings, formWorkLimit, answerResetsFormReplays, rejectFormReadings, invalidateFormInputs, acceptFormReadings, formInstanceApplies, formParentResume, closeFormInstance, checkOtp, clearOtp, maskDestination, validateOTP, OTP_EXPIRY_MS, validateDigits, validatePhone, validateEmail, urlToSpeech, textWithUrlToSpeech, joinSpokenDigits, spokenDigitsText, wholeSpokenNumber, numberAlone, registerSendable, sendables, chatTranscript, conversationCopy, CONVERSATION_KEY, WEB_LINK_KEY, };
|
|
44
45
|
/** The functions flows call by name, ready to spread into a host's approved functions. */
|
|
45
46
|
export const STANDARD_FUNCTIONS = {
|
|
46
47
|
continuationSafetyProtocol, cancelFormTask, contextualResponseProtocol, validateFormResponse, hasFormResponse,
|
|
@@ -48,7 +49,7 @@ export const STANDARD_FUNCTIONS = {
|
|
|
48
49
|
clearFormMisses, formNoOwner, missFormInput, formMustComplete, formInputPrompt, formUserDescriptionSource, formConcernLine, formAcknowledges, consumeFormFeedback, keepFormLine, deferFormClarification, takeFormClarification, formClarificationKept, clearFormLines, formConversationOutcome,
|
|
49
50
|
readMoneyAmount, isMoneyAmount, moneyIntentAllows, isPastPaymentStatement, isPartialMoneyAnswer, validateMoneyOptions, takeChoiceOffer, saysConfirmWord, confirmOutOfOrderLine, matchesChoice, isAnswer, isAgentRequest, isExitRequest, isGlobalExit, isOtherRequest, isSpelledFragment, isAmountAnswer, amountInAnswer, pickChoice, pickWholeChoice, withoutPromptEcho, isReaderFiller,
|
|
50
51
|
readEmail, emailWithoutEnding, emailEnding, emailSaid, readPhone, readInternationalPhone, readIdentifier, last4, maskEmail, callerTextNumber, textDestination, callerIsInternational,
|
|
51
|
-
normalizeAndFindCapture, anythingElse, goodbye, sayName, sorryNotCaught, yesNoKeys, channelVerb, dateToWords, amountToSpeech, phoneToSpeech, validateCardNumber, validateExpiration, consumeActionReceipt, authorizeFormActionRetry, formSignature, selectFormAction, confirmFormRevision, prepareFormAction, actionConfirmationValid, beginFormAction, finishFormAction, actionGateVerified, sourceNeedsLoad, beginSourceRefresh, completeSourceRefresh, pickProviderQuestion, matchInputs, readFormAnswer, readArgument, groundAmount, joinSpokenNumbers, findNumbers, assignNumbers, addressDraft, readInputProfile, formAcceptanceTrace, resolveFormInputs, formInputApplies, formInputFilled, nextFormInput, formInputChain, openFormInstance, validateFormIncompleteOutcome, formIncompleteOutcome, validateFormExhaustion, exhaustFormInput, formInitialReadings, orderFormReadings, proposedFormValues, applyFormValidation, formReadingDependencies, exclusiveFormReadings, enrichFormMatches, expandFormActivations, settleFormActivations, rememberFormArguments, resetFormInputs, hasFormValue, formPath, formValuesEqual, formReadingReady, formReadingRelevant, formPreparation, queueFormReadings, pendingFormReadings, formWorkLimit, answerResetsFormReplays, rejectFormReadings, invalidateFormInputs, acceptFormReadings, formInstanceApplies, formParentResume, closeFormInstance,
|
|
52
|
+
normalizeAndFindCapture, anythingElse, goodbye, sayName, sorryNotCaught, yesNoKeys, channelVerb, dateToWords, hoursPhrase, scheduleOpenNow, zipCovered, readWhen, openSlots, slotToWords, todayIn, minutesUntil, amountToSpeech, phoneToSpeech, validateCardNumber, validateExpiration, consumeActionReceipt, authorizeFormActionRetry, formSignature, selectFormAction, confirmFormRevision, prepareFormAction, actionConfirmationValid, beginFormAction, finishFormAction, actionGateVerified, sourceNeedsLoad, beginSourceRefresh, completeSourceRefresh, pickProviderQuestion, matchInputs, readFormAnswer, readArgument, groundAmount, joinSpokenNumbers, findNumbers, assignNumbers, addressDraft, readInputProfile, formAcceptanceTrace, resolveFormInputs, formInputApplies, formInputFilled, nextFormInput, formInputChain, openFormInstance, validateFormIncompleteOutcome, formIncompleteOutcome, validateFormExhaustion, exhaustFormInput, formInitialReadings, orderFormReadings, proposedFormValues, applyFormValidation, formReadingDependencies, exclusiveFormReadings, enrichFormMatches, expandFormActivations, settleFormActivations, rememberFormArguments, resetFormInputs, hasFormValue, formPath, formValuesEqual, formReadingReady, formReadingRelevant, formPreparation, queueFormReadings, pendingFormReadings, formWorkLimit, answerResetsFormReplays, rejectFormReadings, invalidateFormInputs, acceptFormReadings, formInstanceApplies, formParentResume, closeFormInstance,
|
|
52
53
|
validateOTP, validateDigits, validatePhone, validateEmail, urlToSpeech, textWithUrlToSpeech, joinSpokenDigits, wholeSpokenNumber, numberAlone,
|
|
53
54
|
registerSendable, sendables, chatTranscript, conversationCopy,
|
|
54
55
|
};
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The live agent's hours as one spoken sentence, or '' when there are no hours.
|
|
3
|
+
* → "Our agents are available Monday through Friday 9 AM to 7 PM, and Saturday 9 AM to 3 PM, Pacific time."
|
|
4
|
+
*/
|
|
5
|
+
export function agentHoursText(schedule: any, lang?: string): string;
|
|
6
|
+
/**
|
|
7
|
+
* Hours as a phrase that follows a number ("…at 1-800-440-0544, every day from 9 AM to 5 PM, Pacific time."), or ''
|
|
8
|
+
* when there are none (always open). Seven days alike read "every day".
|
|
9
|
+
*/
|
|
10
|
+
export function hoursPhrase(schedule: any, lang?: string): string;
|
|
11
|
+
/**
|
|
12
|
+
* Is a schedule open at `now`? The rule for the live agent's agentSchedule and every transfer department's schedule:
|
|
13
|
+
* - no schedule (or no range on any day) → always open
|
|
14
|
+
* - otherwise open only when `now`, in schedule.timezone (UTC when unset), falls inside one of that day's [open, close)
|
|
15
|
+
* A schedule that cannot be evaluated (an unknown zone) counts as open; `onError(tz, error)` is told.
|
|
16
|
+
*/
|
|
17
|
+
export function scheduleOpenNow(schedule: any, now?: Date, onError?: () => void): boolean;
|
|
18
|
+
/**
|
|
19
|
+
* Does a calendar's zip list cover `zip`? Entries are a zip ('91325'), a prefix with x's ('913xx') or a range
|
|
20
|
+
* ('91301-91311'). No list covers everywhere; no zip given is covered (nothing to filter by).
|
|
21
|
+
*/
|
|
22
|
+
export function zipCovered(zips: any, zip: any): boolean;
|
|
23
|
+
/**
|
|
24
|
+
* What a customer said about when, as a constraint for openSlots, or null when nothing in it is a time.
|
|
25
|
+
* readWhen('Saturday morning', { now, timezone }) → { dates: ['2026-12-12'], from: '00:00', to: '12:00' }
|
|
26
|
+
* English and Spanish: today, tomorrow, weekday names (plural = every one), this/next week, weekend, weekdays, a date
|
|
27
|
+
* ("the 12th", "Dec 12", "12 de diciembre", "12/12"), morning/afternoon/evening, at/after/before/between a time,
|
|
28
|
+
* later ({ later: true }: after the times already offered) and any time ({ any: true }). Dates run `days` ahead (60).
|
|
29
|
+
*/
|
|
30
|
+
export function readWhen(text: any, { now, timezone, days }?: {
|
|
31
|
+
now?: number | undefined;
|
|
32
|
+
timezone?: string | undefined;
|
|
33
|
+
days?: number | undefined;
|
|
34
|
+
}): {
|
|
35
|
+
from: any;
|
|
36
|
+
to: any;
|
|
37
|
+
at: string | null;
|
|
38
|
+
later: boolean;
|
|
39
|
+
any: boolean;
|
|
40
|
+
} | null;
|
|
41
|
+
/**
|
|
42
|
+
* Up to `count` open times, earliest first, as [{ key, calendar, date, start, end, from, to, label, label_es }]
|
|
43
|
+
* (start/end ISO; from/to wall time in the zone; label for a button or a list).
|
|
44
|
+
*
|
|
45
|
+
* hours the business schedule; a calendar with its own `schedule` uses that instead
|
|
46
|
+
* calendars [{ key, name?, schedule?, zips?, skills? }]; none = one unnamed calendar
|
|
47
|
+
* service { length, buffer?, time: 'exact' | 'window', step? (exact, default 30), windows? [{open, close}] (window),
|
|
48
|
+
* per? (jobs per window per calendar, default 1), avail: 'check' | 'accept', notice? (minutes),
|
|
49
|
+
* ahead? (days, default 30), skill? }
|
|
50
|
+
* busy [{ calendar, start, end }] existing bookings (ignored when avail is 'accept')
|
|
51
|
+
* preference readWhen's result, plus notBefore (epoch or ISO) for "later"
|
|
52
|
+
* zip, calendar the customer's zip; the calendar they picked
|
|
53
|
+
* A slot fits a preference when it starts inside its dates and from/to (a window when it overlaps from/to). The first
|
|
54
|
+
* calendar (in the order given) with room takes the slot; a time two calendars share is offered once.
|
|
55
|
+
*/
|
|
56
|
+
export function openSlots({ hours, calendars, service, busy, preference, now, zip, calendar, count }?: {
|
|
57
|
+
busy?: never[] | undefined;
|
|
58
|
+
preference?: null | undefined;
|
|
59
|
+
now?: number | undefined;
|
|
60
|
+
zip?: string | undefined;
|
|
61
|
+
calendar?: string | undefined;
|
|
62
|
+
count?: number | undefined;
|
|
63
|
+
}): {
|
|
64
|
+
key: string;
|
|
65
|
+
calendar: any;
|
|
66
|
+
date: string;
|
|
67
|
+
start: string;
|
|
68
|
+
end: string;
|
|
69
|
+
from: string;
|
|
70
|
+
to: string;
|
|
71
|
+
window: boolean;
|
|
72
|
+
}[];
|
|
73
|
+
/**
|
|
74
|
+
* A slot in words: "tomorrow at 9:15 AM", "Tuesday, December 8, between 8 AM and 12 PM" / "mañana a las 9:15", "el
|
|
75
|
+
* martes 8 de diciembre entre las 8:00 y las 12:00". `today` ('YYYY-MM-DD') turns today and tomorrow into words.
|
|
76
|
+
*/
|
|
77
|
+
export function slotToWords(slot: any, lang?: string, today?: string): string;
|
|
78
|
+
/** Today's date in `timezone` ('YYYY-MM-DD'), the `today` slotToWords takes; '' for an unknown zone. */
|
|
79
|
+
export function todayIn(timezone?: string, now?: number): string;
|
|
80
|
+
/** Whole minutes from `now` until `time` (ISO or epoch), negative once it has passed: a change cutoff. */
|
|
81
|
+
export function minutesUntil(time: any, now?: number): number;
|
|
82
|
+
//# sourceMappingURL=schedule.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"schedule.d.ts","sourceRoot":"","sources":["../../src/helpers/schedule.js"],"names":[],"mappings":"AAkGA;;;GAGG;AACH,qEAaC;AAED;;;GAGG;AACH,kEAaC;AAuCD;;;;;GAKG;AACH,0FAeC;AAID;;;GAGG;AACH,yDAiBC;AAyCD;;;;;;GAMG;AACH;;;;;;;;;;SA4JC;AAID;;;;;;;;;;;;;;GAcG;AACH;;;;;;;;;;;;;;;;IAgFC;AAED;;;GAGG;AACH,8EAgBC;AAED,wGAAwG;AACxG,iEAMC;AAED,0GAA0G;AAC1G,8DAEC"}
|