@tellescope/validation 1.80.3 → 1.81.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/src/validation.ts CHANGED
@@ -264,6 +264,12 @@ import {
264
264
  Diagnosis,
265
265
  FormResponseAnswerAppointmentBooking,
266
266
  CanvasCoding,
267
+ VitalConfigurationRange,
268
+ VitalComparisons,
269
+ PagerDutyCreateIncidentAutomationAction,
270
+ SenderAssignmentStrategyType,
271
+ SenderAssignmentStrategy,
272
+ SenderAssignmentStrategies,
267
273
  } from "@tellescope/types-models"
268
274
  import {
269
275
  UserDisplayInfo,
@@ -305,6 +311,8 @@ import {
305
311
  INSURANCE_RELATIONSHIPS,
306
312
  NO_ACCESS,
307
313
  OUTLOOK_INTEGRATIONS_TITLE,
314
+ PAGER_DUTY_TITLE,
315
+ SMART_METER_TITLE,
308
316
  SQUARE_INTEGRATIONS_TITLE,
309
317
  ZENDESK_INTEGRATIONS_TITLE,
310
318
  ZOHO_TITLE,
@@ -866,6 +874,13 @@ export const stringValidator5000: ValidatorDefinition<string> = {
866
874
  getExample: getExampleString,
867
875
  getType: getTypeString,
868
876
  }
877
+ export const stringValidator20000ptional: ValidatorDefinition<string> = {
878
+ validate: (o={}) => build_validator(
879
+ escapeString(o), { ...o, maxLength: 20000, listOf: false, isOptional: true, emptyStringOk: true, }
880
+ ),
881
+ getExample: getExampleString,
882
+ getType: getTypeString,
883
+ }
869
884
  export const stringValidator5000EmptyOkay: ValidatorDefinition<string> = {
870
885
  validate: (o={}) => build_validator(
871
886
  escapeString(o), { ...o, maxLength: 5000, listOf: false, emptyStringOk: true }
@@ -1453,8 +1468,10 @@ export const FORM_FIELD_VALIDATORS_BY_TYPE: { [K in FormFieldType | 'userEmail'
1453
1468
  'description': g => '',
1454
1469
  'Table Input': (g) => Array.isArray(g) ? g : [],
1455
1470
  'Question Group': (g) => Array.isArray(g) ? g : [],
1456
- 'string': stringValidator.validate({ maxLength: 1000, emptyStringOk: true, errorMessage: "Response must not exceed 1000 characters" }),
1457
- 'stringLong': stringValidator.validate({ maxLength: 10000, emptyStringOk: true, errorMessage: "Response must not exceed 10000 characters" }),
1471
+ // need to keep consistent with other validation
1472
+ 'string': stringValidator.validate({ maxLength: 5000, emptyStringOk: true, errorMessage: "Response must not exceed 5000 characters" }),
1473
+ 'stringLong': stringValidator.validate({ maxLength: 20000, emptyStringOk: true, errorMessage: "Response must not exceed 20000 characters" }),
1474
+
1458
1475
  'number': numberValidator.validate({ errorMessage: "Response must be a number" }),
1459
1476
  'email': emailValidator.validate(),
1460
1477
 
@@ -1853,9 +1870,10 @@ export const formResponseAnswerValidator = orValidator<{ [K in FormFieldType]: F
1853
1870
  type: exactMatchValidator(['Stripe']),
1854
1871
  value: stringValidator1000Optional,
1855
1872
  }),
1873
+ // need to keep consistent with other validation
1856
1874
  stringLong: objectValidator<FormResponseAnswerStringLong>({
1857
1875
  type: exactMatchValidator(['stringLong']),
1858
- value: stringValidator5000Optional,
1876
+ value: stringValidator20000ptional,
1859
1877
  }),
1860
1878
  date: objectValidator<FormResponseAnswerDate>({
1861
1879
  type: exactMatchValidator(['date']),
@@ -2190,6 +2208,7 @@ const _AUTOMATION_ACTIONS: { [K in AutomationActionType]: any } = {
2190
2208
  iterableCustomEvent: '',
2191
2209
  zendeskCreateTicket: '',
2192
2210
  zusSync: '',
2211
+ pagerDutyCreateIncident: '',
2193
2212
  }
2194
2213
  export const AUTOMATION_ACTIONS = Object.keys(_AUTOMATION_ACTIONS) as AutomationActionType[]
2195
2214
  export const automationActionTypeValidator = exactMatchValidator<AutomationActionType>(AUTOMATION_ACTIONS)
@@ -2392,6 +2411,25 @@ export const ticketActionValidator = orValidator<{ [K in TicketActionType]: Tick
2392
2411
  })
2393
2412
  export const ticketActionsValidator = listValidatorOptionalOrEmptyOk(ticketActionValidator)
2394
2413
 
2414
+ export const senderAssignmentStrategyValidatorOptional = orValidator<{
2415
+ [K in SenderAssignmentStrategyType]: SenderAssignmentStrategy
2416
+ }>({
2417
+ 'Care Team Primary': objectValidator<SenderAssignmentStrategies['Care Team Primary']>({
2418
+ type: exactMatchValidator<'Care Team Primary'>(['Care Team Primary']),
2419
+ info: objectValidator<object>({}, { emptyOk: true }),
2420
+ }),
2421
+ 'Default': objectValidator<SenderAssignmentStrategies['Default']>({
2422
+ type: exactMatchValidator<'Default'>(['Default']),
2423
+ info: objectValidator<object>({}, { emptyOk: true }),
2424
+ }),
2425
+ }, { isOptional: true })
2426
+
2427
+ export const automationForMessageValidator = objectValidator<AutomationForMessage>({
2428
+ senderId: mongoIdStringRequired,
2429
+ templateId: mongoIdStringRequired,
2430
+ assignment: senderAssignmentStrategyValidatorOptional,
2431
+ }, { emptyOk: false })
2432
+
2395
2433
  export const automationActionValidator = orValidator<{ [K in AutomationActionType]: AutomationAction & { type: K } } >({
2396
2434
  setEnduserStatus: objectValidator<SetEnduserStatusAutomationAction>({
2397
2435
  type: exactMatchValidator(['setEnduserStatus']),
@@ -2399,11 +2437,11 @@ export const automationActionValidator = orValidator<{ [K in AutomationActionTyp
2399
2437
  }),
2400
2438
  sendEmail: objectValidator<SendEmailAutomationAction>({
2401
2439
  type: exactMatchValidator(['sendEmail']),
2402
- info: objectValidator<AutomationForMessage>({ senderId: mongoIdStringRequired, templateId: mongoIdStringRequired }, { emptyOk: false }),
2440
+ info: automationForMessageValidator
2403
2441
  }),
2404
2442
  sendSMS: objectValidator<SendSMSAutomationAction>({
2405
2443
  type: exactMatchValidator(['sendSMS']),
2406
- info: objectValidator<AutomationForMessage>({ senderId: mongoIdStringRequired, templateId: mongoIdStringRequired }, { emptyOk: false }),
2444
+ info: automationForMessageValidator,
2407
2445
  }),
2408
2446
  notifyTeam: objectValidator<NotifyTeamAutomationAction>({
2409
2447
  type: exactMatchValidator(['notifyTeam']),
@@ -2422,6 +2460,7 @@ export const automationActionValidator = orValidator<{ [K in AutomationActionTyp
2422
2460
  senderId: mongoIdStringRequired,
2423
2461
  formId: mongoIdStringRequired,
2424
2462
  channel: communicationsChannelValidatorOptional,
2463
+ assignment: senderAssignmentStrategyValidatorOptional,
2425
2464
  }, { emptyOk: false }),
2426
2465
  }),
2427
2466
  shareContent: objectValidator<ShareContentAutomationAction>({
@@ -2553,6 +2592,14 @@ export const automationActionValidator = orValidator<{ [K in AutomationActionTyp
2553
2592
  type: exactMatchValidator(['zusSync']),
2554
2593
  info: objectValidator<ZusSyncAutomationAction['info']>({ }, { emptyOk: true }),
2555
2594
  }),
2595
+ pagerDutyCreateIncident: objectValidator<PagerDutyCreateIncidentAutomationAction>({
2596
+ type: exactMatchValidator(['pagerDutyCreateIncident']),
2597
+ info: objectValidator<PagerDutyCreateIncidentAutomationAction['info']>({
2598
+ title: stringValidator,
2599
+ type: stringValidator,
2600
+ serviceId: stringValidator,
2601
+ }),
2602
+ }),
2556
2603
  })
2557
2604
 
2558
2605
  export const journeyContextValidator = objectValidator<JourneyContext>({
@@ -2796,6 +2843,7 @@ export const formFieldOptionsValidator = objectValidator<FormFieldOptions>({
2796
2843
  billingProvider: stringValidatorOptional,
2797
2844
  addressFields: listOfStringsValidatorOptionalOrEmptyOk,
2798
2845
  autoAdvance: booleanValidatorOptional,
2846
+ userTags: listOfStringsValidatorOptionalOrEmptyOk,
2799
2847
  })
2800
2848
 
2801
2849
  export const blockValidator = orValidator<{ [K in BlockType]: Block & { type: K } } >({
@@ -3256,6 +3304,7 @@ export const organizationSettingsValidator = objectValidator<OrganizationSetting
3256
3304
  defaultPhoneNumber: stringValidatorOptional,
3257
3305
  showBulkFormInput: booleanValidatorOptional,
3258
3306
  autofillSignature: booleanValidatorOptional,
3307
+ showFullVitalsTab: booleanValidatorOptional,
3259
3308
  }, { isOptional: true }),
3260
3309
  tickets: objectValidator<OrganizationSettings['tickets']>({
3261
3310
  defaultJourneyDueDateOffsetInMS: numberValidatorOptional,
@@ -3302,6 +3351,31 @@ export const calendarEventPortalSettingsValidator = objectValidator<CalendarEven
3302
3351
  hideUsers: booleanValidatorOptional,
3303
3352
  })
3304
3353
 
3354
+ export const vitalComparisonValidator = orValidator({
3355
+ "Less Than": objectValidator<VitalComparisons['Less Than']>({
3356
+ type: exactMatchValidator(['Less Than']),
3357
+ value: numberValidator,
3358
+ }),
3359
+ "Greater Than": objectValidator<VitalComparisons['Greater Than']>({
3360
+ type: exactMatchValidator(['Greater Than']),
3361
+ value: numberValidator,
3362
+ }),
3363
+ "Between": objectValidator<VitalComparisons['Between']>({
3364
+ type: exactMatchValidator(['Between']),
3365
+ value: objectValidator<VitalComparisons['Between']['value']>({
3366
+ lower: numberValidator,
3367
+ upper: numberValidator,
3368
+ }),
3369
+ }),
3370
+ })
3371
+
3372
+ export const vitalConfigurationRangeValidator = objectValidator<VitalConfigurationRange>({
3373
+ classification: stringValidator100,
3374
+ trendIntervalInMS: numberValidatorOptional,
3375
+ comparison: vitalComparisonValidator,
3376
+ })
3377
+ export const vitalConfigurationRangesValidator = listValidator(vitalConfigurationRangeValidator)
3378
+
3305
3379
  const _AUTOMATION_TRIGGER_EVENT_TYPES: { [K in AutomationTriggerEventType]: any } = {
3306
3380
  "Form Submitted": true,
3307
3381
  "Form Unsubmitted": true,
@@ -3313,6 +3387,8 @@ const _AUTOMATION_TRIGGER_EVENT_TYPES: { [K in AutomationTriggerEventType]: any
3313
3387
  "Medication Added": true,
3314
3388
  "On Birthday": true,
3315
3389
  "Has Not Engaged": true,
3390
+ "Vital Count": true,
3391
+ 'Vital Update': true,
3316
3392
  }
3317
3393
  export const AUTOMATION_TRIGGER_EVENT_TYPES = Object.keys(_AUTOMATION_TRIGGER_EVENT_TYPES) as AutomationTriggerEventType[]
3318
3394
 
@@ -3390,6 +3466,24 @@ export const automationTriggerEventValidator = orValidator<{ [K in AutomationTri
3390
3466
  }),
3391
3467
  conditions: optionalEmptyObjectValidator,
3392
3468
  }),
3469
+ "Vital Count": objectValidator<AutomationTriggerEvents["Vital Count"]>({
3470
+ type: exactMatchValidator(['Vital Count']),
3471
+ info: objectValidator<AutomationTriggerEvents['Vital Count']['info']>({
3472
+ minutes: nonNegNumberValidator,
3473
+ units: listOfStringsValidatorEmptyOk,
3474
+ comparison: vitalComparisonValidator,
3475
+ periodInMS: numberValidator,
3476
+ }),
3477
+ conditions: optionalEmptyObjectValidator,
3478
+ }),
3479
+ "Vital Update": objectValidator<AutomationTriggerEvents["Vital Update"]>({
3480
+ type: exactMatchValidator(['Vital Update']),
3481
+ info: objectValidator<AutomationTriggerEvents['Vital Update']['info']>({
3482
+ configurationIds: listOfMongoIdStringValidator,
3483
+ classifications: listOfStringsValidator,
3484
+ }),
3485
+ conditions: optionalEmptyObjectValidator,
3486
+ }),
3393
3487
  })
3394
3488
 
3395
3489
  const _AUTOMATION_TRIGGER_ACTION_TYPES: { [K in AutomationTriggerActionType]: any } = {
@@ -3591,6 +3685,7 @@ export const accessPermissionsValidator = objectValidator<AccessPermissions>({
3591
3685
  group_mms_conversations: accessPermissionValidator,
3592
3686
  enduser_orders: accessPermissionValidator,
3593
3687
  enduser_encounters: accessPermissionValidator,
3688
+ vital_configurations: accessPermissionValidator,
3594
3689
 
3595
3690
  // deprecated but for backwards compatibility
3596
3691
  apiKeys: accessPermissionValidator,
@@ -3665,6 +3760,7 @@ export const organizationLimitsValidator = objectValidator<OrganizationLimits>({
3665
3760
  ticket_queues: numberValidatorOptional,
3666
3761
  enduser_orders: numberValidatorOptional,
3667
3762
  enduser_encounters: numberValidatorOptional,
3763
+ vital_configurations: numberValidatorOptional,
3668
3764
  }, { emptyOk: true })
3669
3765
 
3670
3766
  const _LOGIN_FLOW_RESULTS = {
@@ -3725,6 +3821,8 @@ export type IntegrationsTitleType = (
3725
3821
  | typeof CANVAS_TITLE
3726
3822
  | typeof CANDID_TITLE
3727
3823
  | typeof GOGO_MEDS_TITLE
3824
+ | typeof PAGER_DUTY_TITLE
3825
+ | typeof SMART_METER_TITLE
3728
3826
  )
3729
3827
  export const integrationTitleValidator = exactMatchValidator<IntegrationsTitleType>([
3730
3828
  SQUARE_INTEGRATIONS_TITLE,
@@ -3736,7 +3834,9 @@ export const integrationTitleValidator = exactMatchValidator<IntegrationsTitleTy
3736
3834
  ZUS_TITLE,
3737
3835
  CANVAS_TITLE,
3738
3836
  CANDID_TITLE,
3739
- GOGO_MEDS_TITLE
3837
+ GOGO_MEDS_TITLE,
3838
+ PAGER_DUTY_TITLE,
3839
+ SMART_METER_TITLE,
3740
3840
  ])
3741
3841
 
3742
3842
  const _VIDEO_INTEGRATION_TYPES: { [K in VideoIntegrationType]: any} = {
@@ -4439,4 +4539,4 @@ export const canvasCodingValidator = objectValidator<CanvasCoding>({
4439
4539
  code: stringValidator,
4440
4540
  display: stringValidator,
4441
4541
  system: stringValidator,
4442
- }, { })
4542
+ }, { })