@tellescope/validation 1.92.0 → 1.94.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/lib/cjs/validation.d.ts +25 -4
- package/lib/cjs/validation.d.ts.map +1 -1
- package/lib/cjs/validation.js +72 -0
- package/lib/cjs/validation.js.map +1 -1
- package/lib/esm/validation.d.ts +25 -4
- package/lib/esm/validation.d.ts.map +1 -1
- package/lib/esm/validation.js +72 -0
- package/lib/esm/validation.js.map +1 -1
- package/lib/tsconfig.tsbuildinfo +1 -1
- package/package.json +6 -6
- package/src/validation.ts +75 -0
package/src/validation.ts
CHANGED
|
@@ -275,6 +275,7 @@ import {
|
|
|
275
275
|
AthenaFieldSync,
|
|
276
276
|
AthenaSubscription,
|
|
277
277
|
CompleteTicketsAutomationAction,
|
|
278
|
+
ChangeContactTypeAutomationAction,
|
|
278
279
|
} from "@tellescope/types-models"
|
|
279
280
|
import {
|
|
280
281
|
UserDisplayInfo,
|
|
@@ -1279,6 +1280,7 @@ export const phoneValidator: ValidatorDefinition<string> = {
|
|
|
1279
1280
|
if (typeof phone !== "string") throw new Error(`Expecting phone to be string but got ${phone}`)
|
|
1280
1281
|
|
|
1281
1282
|
let escaped = escape_phone_number(phone)
|
|
1283
|
+
if (escaped === '311') return escaped
|
|
1282
1284
|
if (escaped.length < 10) throw new Error(`Phone number must be at least 10 digits`)
|
|
1283
1285
|
|
|
1284
1286
|
escaped = escaped.startsWith('+') ? escaped
|
|
@@ -1307,6 +1309,7 @@ export const phoneValidatorOptional: ValidatorDefinition<string> = {
|
|
|
1307
1309
|
if (typeof phone !== "string") throw new Error(`Expecting phone to be string but got ${phone}`)
|
|
1308
1310
|
|
|
1309
1311
|
let escaped = escape_phone_number(phone)
|
|
1312
|
+
if (escaped === '311') return escaped
|
|
1310
1313
|
if (escaped.length < 10) throw new Error(`Phone number must be at least 10 digits`)
|
|
1311
1314
|
|
|
1312
1315
|
escaped = escaped.startsWith('+') ? escaped
|
|
@@ -1823,6 +1826,7 @@ export const insuranceOptionalValidator = objectValidator<EnduserInsurance>({
|
|
|
1823
1826
|
dateOfBirth: stringValidatorOptional, // required for Canvas, optional for Candid
|
|
1824
1827
|
}, { isOptional: true, emptyOk: true }),
|
|
1825
1828
|
payerType: stringValidatorOptional,
|
|
1829
|
+
groupNumber: stringValidatorOptional,
|
|
1826
1830
|
}, { isOptional: true, emptyOk: true })
|
|
1827
1831
|
|
|
1828
1832
|
// validate optional vs not at endpoint-level
|
|
@@ -2240,6 +2244,7 @@ const _AUTOMATION_ACTIONS: { [K in AutomationActionType]: any } = {
|
|
|
2240
2244
|
smartMeterPlaceOrder: '',
|
|
2241
2245
|
healthieSync: '',
|
|
2242
2246
|
completeTickets: '',
|
|
2247
|
+
changeContactType: '',
|
|
2243
2248
|
}
|
|
2244
2249
|
export const AUTOMATION_ACTIONS = Object.keys(_AUTOMATION_ACTIONS) as AutomationActionType[]
|
|
2245
2250
|
export const automationActionTypeValidator = exactMatchValidator<AutomationActionType>(AUTOMATION_ACTIONS)
|
|
@@ -2702,6 +2707,13 @@ export const automationActionValidator = orValidator<{ [K in AutomationActionTyp
|
|
|
2702
2707
|
journeyIds: listOfMongoIdStringValidatorOptionalOrEmptyOk,
|
|
2703
2708
|
}),
|
|
2704
2709
|
}),
|
|
2710
|
+
changeContactType: objectValidator<ChangeContactTypeAutomationAction>({
|
|
2711
|
+
continueOnError: booleanValidatorOptional,
|
|
2712
|
+
type: exactMatchValidator(['changeContactType']),
|
|
2713
|
+
info: objectValidator<ChangeContactTypeAutomationAction['info']>({
|
|
2714
|
+
type: stringValidatorOptional, // can be empty string for default contact type or id for others
|
|
2715
|
+
}),
|
|
2716
|
+
}),
|
|
2705
2717
|
})
|
|
2706
2718
|
|
|
2707
2719
|
export const journeyContextValidator = objectValidator<JourneyContext>({
|
|
@@ -2712,6 +2724,7 @@ export const journeyContextValidator = objectValidator<JourneyContext>({
|
|
|
2712
2724
|
orderId: mongoIdStringOptional,
|
|
2713
2725
|
observationId: mongoIdStringOptional,
|
|
2714
2726
|
phoneCallId: mongoIdStringOptional,
|
|
2727
|
+
smsId: mongoIdStringOptional,
|
|
2715
2728
|
})
|
|
2716
2729
|
|
|
2717
2730
|
export const relatedRecordValidator = objectValidator<RelatedRecord>({
|
|
@@ -2950,6 +2963,7 @@ export const formFieldOptionsValidator = objectValidator<FormFieldOptions>({
|
|
|
2950
2963
|
}, { isOptional: true, emptyOk: true }),
|
|
2951
2964
|
useDatePicker: booleanValidatorOptional,
|
|
2952
2965
|
sharedIntakeFields: listOfStringsValidatorOptionalOrEmptyOk,
|
|
2966
|
+
hiddenDefaultFields: listOfStringsValidatorOptionalOrEmptyOk,
|
|
2953
2967
|
copyResponse: booleanValidatorOptional,
|
|
2954
2968
|
disableGoBack: booleanValidatorOptional,
|
|
2955
2969
|
disableNext: booleanValidatorOptional,
|
|
@@ -2967,6 +2981,7 @@ export const formFieldOptionsValidator = objectValidator<FormFieldOptions>({
|
|
|
2967
2981
|
userFilterTags: listOfStringsValidatorOptionalOrEmptyOk,
|
|
2968
2982
|
prefillSignature: booleanValidatorOptional,
|
|
2969
2983
|
requirePredefinedInsurer: booleanValidatorOptional,
|
|
2984
|
+
includeGroupNumber: booleanValidatorOptional,
|
|
2970
2985
|
})
|
|
2971
2986
|
|
|
2972
2987
|
export const blockValidator = orValidator<{ [K in BlockType]: Block & { type: K } } >({
|
|
@@ -3451,12 +3466,14 @@ export const organizationSettingsValidator = objectValidator<OrganizationSetting
|
|
|
3451
3466
|
canMoveCalls: booleanValidatorOptional,
|
|
3452
3467
|
showDeleteCallRecordingOnTimeline: booleanValidatorOptional,
|
|
3453
3468
|
inboxRepliesMarkRead: booleanValidatorOptional,
|
|
3469
|
+
recordCallAudioPlayback: stringValidatorOptional,
|
|
3454
3470
|
}, { isOptional: true }),
|
|
3455
3471
|
tickets: objectValidator<OrganizationSettings['tickets']>({
|
|
3456
3472
|
defaultJourneyDueDateOffsetInMS: numberValidatorOptional,
|
|
3457
3473
|
disableSnooze: booleanValidatorOptional,
|
|
3458
3474
|
showCommunications: booleanValidatorOptional,
|
|
3459
3475
|
showJourneys: booleanValidatorOptional,
|
|
3476
|
+
requireDueDate: booleanValidatorOptional,
|
|
3460
3477
|
}, { isOptional: true }),
|
|
3461
3478
|
calendar: objectValidator<OrganizationSettings['calendar']>({
|
|
3462
3479
|
dayStart: objectValidator<Required<OrganizationSettings>['calendar']['dayStart']>({
|
|
@@ -3530,7 +3547,9 @@ const _AUTOMATION_TRIGGER_EVENT_TYPES: { [K in AutomationTriggerEventType]: any
|
|
|
3530
3547
|
"Purchase Made": true,
|
|
3531
3548
|
"Appointment No-Showed": true,
|
|
3532
3549
|
"Appointment Created": true,
|
|
3550
|
+
"Appointment Cancelled": true,
|
|
3533
3551
|
"Appointment Completed": true,
|
|
3552
|
+
"Appointment Rescheduled": true,
|
|
3534
3553
|
"Field Equals": true,
|
|
3535
3554
|
"No Recent Appointment": true,
|
|
3536
3555
|
"Medication Added": true,
|
|
@@ -3541,6 +3560,10 @@ const _AUTOMATION_TRIGGER_EVENT_TYPES: { [K in AutomationTriggerEventType]: any
|
|
|
3541
3560
|
"SMS Reply": true,
|
|
3542
3561
|
"Order Status Equals": true,
|
|
3543
3562
|
"Missed Call": true,
|
|
3563
|
+
"Order Created": true,
|
|
3564
|
+
"Problem Created": true,
|
|
3565
|
+
"Message Delivery Failure": true,
|
|
3566
|
+
"Incoming Message (No Care Team)": true,
|
|
3544
3567
|
}
|
|
3545
3568
|
export const AUTOMATION_TRIGGER_EVENT_TYPES = Object.keys(_AUTOMATION_TRIGGER_EVENT_TYPES) as AutomationTriggerEventType[]
|
|
3546
3569
|
|
|
@@ -3587,6 +3610,16 @@ export const automationTriggerEventValidator = orValidator<{ [K in AutomationTri
|
|
|
3587
3610
|
info: optionalEmptyObjectValidator,
|
|
3588
3611
|
conditions: optionalEmptyObjectValidator,
|
|
3589
3612
|
}),
|
|
3613
|
+
"Message Delivery Failure": objectValidator<AutomationTriggerEvents["Message Delivery Failure"]>({
|
|
3614
|
+
type: exactMatchValidator(['Message Delivery Failure']),
|
|
3615
|
+
info: optionalEmptyObjectValidator,
|
|
3616
|
+
conditions: optionalEmptyObjectValidator,
|
|
3617
|
+
}),
|
|
3618
|
+
"Incoming Message (No Care Team)": objectValidator<AutomationTriggerEvents["Incoming Message (No Care Team)"]>({
|
|
3619
|
+
type: exactMatchValidator(['Incoming Message (No Care Team)']),
|
|
3620
|
+
info: optionalEmptyObjectValidator,
|
|
3621
|
+
conditions: optionalEmptyObjectValidator,
|
|
3622
|
+
}),
|
|
3590
3623
|
"Appointment No-Showed": objectValidator<AutomationTriggerEvents["Appointment No-Showed"]>({
|
|
3591
3624
|
type: exactMatchValidator(['Appointment No-Showed']),
|
|
3592
3625
|
info: optionalEmptyObjectValidator,
|
|
@@ -3606,6 +3639,20 @@ export const automationTriggerEventValidator = orValidator<{ [K in AutomationTri
|
|
|
3606
3639
|
}),
|
|
3607
3640
|
conditions: optionalEmptyObjectValidator,
|
|
3608
3641
|
}),
|
|
3642
|
+
"Appointment Cancelled": objectValidator<AutomationTriggerEvents["Appointment Cancelled"]>({
|
|
3643
|
+
type: exactMatchValidator(['Appointment Cancelled']),
|
|
3644
|
+
info: objectValidator<AutomationTriggerEvents['Appointment Cancelled']['info']>({
|
|
3645
|
+
titles: listOfStringsValidatorOptionalOrEmptyOk,
|
|
3646
|
+
}),
|
|
3647
|
+
conditions: optionalEmptyObjectValidator,
|
|
3648
|
+
}),
|
|
3649
|
+
"Appointment Rescheduled": objectValidator<AutomationTriggerEvents["Appointment Rescheduled"]>({
|
|
3650
|
+
type: exactMatchValidator(['Appointment Rescheduled']),
|
|
3651
|
+
info: objectValidator<AutomationTriggerEvents['Appointment Rescheduled']['info']>({
|
|
3652
|
+
titles: listOfStringsValidatorOptionalOrEmptyOk,
|
|
3653
|
+
}),
|
|
3654
|
+
conditions: optionalEmptyObjectValidator,
|
|
3655
|
+
}),
|
|
3609
3656
|
"Medication Added": objectValidator<AutomationTriggerEvents["Medication Added"]>({
|
|
3610
3657
|
type: exactMatchValidator(['Medication Added']),
|
|
3611
3658
|
info: objectValidator<AutomationTriggerEvents['Medication Added']['info']>({
|
|
@@ -3669,6 +3716,20 @@ export const automationTriggerEventValidator = orValidator<{ [K in AutomationTri
|
|
|
3669
3716
|
}),
|
|
3670
3717
|
conditions: optionalEmptyObjectValidator,
|
|
3671
3718
|
}),
|
|
3719
|
+
"Order Created": objectValidator<AutomationTriggerEvents["Order Created"]>({
|
|
3720
|
+
type: exactMatchValidator(['Order Created']),
|
|
3721
|
+
info: objectValidator<AutomationTriggerEvents['Order Created']['info']>({
|
|
3722
|
+
titles: listOfStringsValidatorOptionalOrEmptyOk,
|
|
3723
|
+
}),
|
|
3724
|
+
conditions: optionalEmptyObjectValidator,
|
|
3725
|
+
}),
|
|
3726
|
+
"Problem Created": objectValidator<AutomationTriggerEvents["Problem Created"]>({
|
|
3727
|
+
type: exactMatchValidator(['Problem Created']),
|
|
3728
|
+
info: objectValidator<AutomationTriggerEvents['Problem Created']['info']>({
|
|
3729
|
+
titles: listOfStringsValidatorOptionalOrEmptyOk,
|
|
3730
|
+
}),
|
|
3731
|
+
conditions: optionalEmptyObjectValidator,
|
|
3732
|
+
}),
|
|
3672
3733
|
})
|
|
3673
3734
|
|
|
3674
3735
|
const _AUTOMATION_TRIGGER_ACTION_TYPES: { [K in AutomationTriggerActionType]: any } = {
|
|
@@ -3873,12 +3934,15 @@ export const accessPermissionsValidator = objectValidator<AccessPermissions>({
|
|
|
3873
3934
|
vital_configurations: accessPermissionValidator,
|
|
3874
3935
|
blocked_phones: accessPermissionValidator,
|
|
3875
3936
|
prescription_routes: accessPermissionValidator,
|
|
3937
|
+
enduser_problems: accessPermissionValidator,
|
|
3938
|
+
flowchart_notes: accessPermissionValidator,
|
|
3876
3939
|
|
|
3877
3940
|
// deprecated but for backwards compatibility
|
|
3878
3941
|
apiKeys: accessPermissionValidator,
|
|
3879
3942
|
})
|
|
3880
3943
|
|
|
3881
3944
|
export const organizationLimitsValidator = objectValidator<OrganizationLimits>({
|
|
3945
|
+
enduser_problems: accessPermissionValidator,
|
|
3882
3946
|
prescription_routes: accessPermissionValidator,
|
|
3883
3947
|
group_mms_conversations: accessPermissionValidator,
|
|
3884
3948
|
enduser_custom_types: numberValidatorOptional,
|
|
@@ -3950,6 +4014,7 @@ export const organizationLimitsValidator = objectValidator<OrganizationLimits>({
|
|
|
3950
4014
|
enduser_encounters: numberValidatorOptional,
|
|
3951
4015
|
vital_configurations: numberValidatorOptional,
|
|
3952
4016
|
blocked_phones: numberValidatorOptional,
|
|
4017
|
+
flowchart_notes: numberValidatorOptional,
|
|
3953
4018
|
}, { emptyOk: true })
|
|
3954
4019
|
|
|
3955
4020
|
const _LOGIN_FLOW_RESULTS = {
|
|
@@ -4470,6 +4535,15 @@ export const enduserProfileViewBlockValidator = orValidator<{ [K in EnduserProfi
|
|
|
4470
4535
|
)
|
|
4471
4536
|
}),
|
|
4472
4537
|
}),
|
|
4538
|
+
"Form Responses": objectValidator<EnduserProfileViewBlocks["Form Responses"]>({
|
|
4539
|
+
...sharedEnduserProfileViewBlockFields,
|
|
4540
|
+
type: exactMatchValidator(['Form Responses']),
|
|
4541
|
+
info: objectValidator<EnduserProfileViewBlocks['Form Responses']['info']>({
|
|
4542
|
+
title: stringValidator100,
|
|
4543
|
+
formId: mongoIdStringRequired,
|
|
4544
|
+
fieldIds: listOfMongoIdStringValidatorEmptyOk,
|
|
4545
|
+
}),
|
|
4546
|
+
}),
|
|
4473
4547
|
})
|
|
4474
4548
|
export const enduserProfileViewBlocksValidator = listValidator(enduserProfileViewBlockValidator)
|
|
4475
4549
|
|
|
@@ -4556,6 +4630,7 @@ export const phoneTreeActionValidator = orValidator<{ [K in PhoneTreeActionType]
|
|
|
4556
4630
|
type: exactMatchValidator(['Play Message']),
|
|
4557
4631
|
info: objectValidator<PhoneTreeActions["Play Message"]['info']>({
|
|
4558
4632
|
playback: phonePlaybackValidator,
|
|
4633
|
+
journeyId: mongoIdStringOptional,
|
|
4559
4634
|
}),
|
|
4560
4635
|
}),
|
|
4561
4636
|
"Dial Users": objectValidator<PhoneTreeActions["Dial Users"]>({
|