@tellescope/validation 1.39.4 → 1.40.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/src/validation.ts CHANGED
@@ -214,6 +214,9 @@ import {
214
214
  PhoneTreeEnduserCondition,
215
215
  WaitForTriggerAutomationEvent,
216
216
  ShareContentAutomationAction,
217
+ FormResponseAnswerDropdown,
218
+ NotifyTeamAutomationAction,
219
+ ListOfStringsWithQualifier,
217
220
  } from "@tellescope/types-models"
218
221
  import {
219
222
  UserDisplayInfo,
@@ -1326,7 +1329,8 @@ const _FORM_FIELD_TYPES: { [K in FormFieldType]: any } = {
1326
1329
  description: '',
1327
1330
  Address: '',
1328
1331
  Time: '',
1329
- Stripe: ''
1332
+ Stripe: '',
1333
+ Dropdown: '',
1330
1334
  }
1331
1335
  export const FORM_FIELD_TYPES = Object.keys(_FORM_FIELD_TYPES) as FormFieldType[]
1332
1336
  export const formFieldTypeValidator = exactMatchValidator<FormFieldType>(FORM_FIELD_TYPES)
@@ -1335,6 +1339,7 @@ export const FORM_FIELD_VALIDATORS_BY_TYPE: { [K in FormFieldType | 'userEmail'
1335
1339
  'Address': objectAnyFieldsAnyValuesValidator.validate(),
1336
1340
  'Time': stringValidator.validate({ maxLength: 100 }),
1337
1341
  'Stripe': stringValidator.validate({ maxLength: 100 }),
1342
+ Dropdown: listOfStringsValidator.validate({ emptyListOk: true }),
1338
1343
  'description': g => '',
1339
1344
  'Table Input': (g) => Array.isArray(g) ? g : [],
1340
1345
  'Question Group': (g) => Array.isArray(g) ? g : [],
@@ -1701,6 +1706,10 @@ export const formResponseAnswerValidator = orValidator<{ [K in FormFieldType]: F
1701
1706
  type: exactMatchValidator(['multiple_choice']),
1702
1707
  value: listOfStringsValidatorOptionalOrEmptyOk,
1703
1708
  }),
1709
+ Dropdown: objectValidator<FormResponseAnswerDropdown>({
1710
+ type: exactMatchValidator(['Dropdown']),
1711
+ value: listOfStringsValidatorOptionalOrEmptyOk,
1712
+ }),
1704
1713
  ranking: objectValidator<FormResponseAnswerRanking>({
1705
1714
  type: exactMatchValidator(['ranking']),
1706
1715
  value: listOfStringsValidatorOptionalOrEmptyOk,
@@ -1901,6 +1910,18 @@ export const chatRoomUserInfoValidator = objectAnyFieldsValidator(objectValidato
1901
1910
  unreadCount: nonNegNumberValidator,
1902
1911
  }))
1903
1912
 
1913
+ const _LIST_QUERY_QUALIFIERS: { [K in ListQueryQualifier]: any} = {
1914
+ "One Of": '',
1915
+ "All Of": "",
1916
+ }
1917
+ export const LIST_QUERY_QUALIFIERS = Object.keys(_LIST_QUERY_QUALIFIERS) as ListQueryQualifier[]
1918
+ export const listQueryQualifiersValidator = exactMatchValidator<ListQueryQualifier>(LIST_QUERY_QUALIFIERS)
1919
+
1920
+ export const listOfStringsWithQualifierValidator = objectValidator<ListOfStringsWithQualifier>({
1921
+ qualifier: listQueryQualifiersValidator,
1922
+ values: listOfStringsValidator,
1923
+ })
1924
+
1904
1925
  const _AUTOMATION_ENDUSER_STATUS: { [K in AutomatedActionStatus]: any } = {
1905
1926
  active: '',
1906
1927
  finished: '',
@@ -1932,6 +1953,7 @@ const _AUTOMATION_ACTIONS: { [K in AutomationActionType]: any } = {
1932
1953
  setEnduserStatus: '',
1933
1954
  setEnduserFields: '',
1934
1955
  shareContent: '',
1956
+ notifyTeam: '',
1935
1957
  }
1936
1958
  export const AUTOMATION_ACTIONS = Object.keys(_AUTOMATION_ACTIONS) as AutomationActionType[]
1937
1959
  export const automationActionTypeValidator = exactMatchValidator<AutomationActionType>(AUTOMATION_ACTIONS)
@@ -2114,6 +2136,17 @@ export const automationActionValidator = orValidator<{ [K in AutomationActionTyp
2114
2136
  type: exactMatchValidator(['sendSMS']),
2115
2137
  info: objectValidator<AutomationForMessage>({ senderId: mongoIdStringRequired, templateId: mongoIdStringRequired }, { emptyOk: false }),
2116
2138
  }),
2139
+ notifyTeam: objectValidator<NotifyTeamAutomationAction>({
2140
+ type: exactMatchValidator(['notifyTeam']),
2141
+ info: objectValidator<NotifyTeamAutomationAction['info']>(
2142
+ {
2143
+ templateId: mongoIdStringRequired,
2144
+ forAssigned: booleanValidator,
2145
+ roles: listOfStringsValidatorOptionalOrEmptyOk,
2146
+ },
2147
+ { emptyOk: false }
2148
+ ),
2149
+ }),
2117
2150
  sendForm: objectValidator<SendFormAutomationAction>({
2118
2151
  type: exactMatchValidator(['sendForm']),
2119
2152
  info: objectValidator<AutomationForFormRequest>({
@@ -2141,12 +2174,17 @@ export const automationActionValidator = orValidator<{ [K in AutomationActionTyp
2141
2174
  type: exactMatchValidator<'care-team-primary'>(['care-team-primary']),
2142
2175
  info: objectValidator<object>({}, { emptyOk: true }),
2143
2176
  }),
2177
+ 'by-tags': objectValidator<CreateTicketAssignmentStrategy>({
2178
+ type: exactMatchValidator<'by-tags'>(['by-tags']),
2179
+ info: listOfStringsWithQualifierValidator,
2180
+ }),
2144
2181
  'default': objectValidator<CreateTicketAssignmentStrategy>({
2145
2182
  type: exactMatchValidator<'default'>(['default']),
2146
2183
  info: objectValidator<object>({}, { emptyOk: true }),
2147
2184
  }),
2148
2185
  }),
2149
2186
  closeReasons: listOfStringsValidatorOptionalOrEmptyOk,
2187
+ restrictByState: booleanValidatorOptional,
2150
2188
  defaultAssignee: mongoIdStringRequired,
2151
2189
  forCarePlan: booleanValidatorOptional,
2152
2190
  hiddenFromTickets: booleanValidatorOptional,
@@ -2699,6 +2737,14 @@ export const customEnduserFieldValidator = orValidator<{ [K in CustomEnduserFiel
2699
2737
  })
2700
2738
  export const customEnduserFieldsValidatorOptionalOrEmpty = listValidatorOptionalOrEmptyOk(customEnduserFieldValidator)
2701
2739
 
2740
+ export const buildInFieldsValidator = listValidatorOptionalOrEmptyOk(objectValidator<EnduserBuiltInField>({
2741
+ field: stringValidator100,
2742
+ label: stringValidator100,
2743
+ hidden: booleanValidatorOptional,
2744
+ required: booleanValidatorOptional,
2745
+ requireConfirmation: booleanValidatorOptional,
2746
+ }))
2747
+
2702
2748
  export const organizationSettingsValidator = objectValidator<OrganizationSettings>({
2703
2749
  endusers: objectValidator<OrganizationSettings['endusers']>({
2704
2750
  disableMultipleChatRooms: booleanValidatorOptional,
@@ -2706,13 +2752,7 @@ export const organizationSettingsValidator = objectValidator<OrganizationSetting
2706
2752
  disableAdhocFields: booleanValidatorOptional,
2707
2753
  autoReplyEnabled: booleanValidatorOptional,
2708
2754
  customFields: customEnduserFieldsValidatorOptionalOrEmpty,
2709
- builtinFields: listValidatorOptionalOrEmptyOk(objectValidator<EnduserBuiltInField>({
2710
- field: stringValidator100,
2711
- label: stringValidator100,
2712
- hidden: booleanValidatorOptional,
2713
- required: booleanValidatorOptional,
2714
- requireConfirmation: booleanValidatorOptional,
2715
- })),
2755
+ builtinFields: buildInFieldsValidator,
2716
2756
  tags: listOfStringsValidatorOptionalOrEmptyOk,
2717
2757
  }, { isOptional: true }),
2718
2758
  calendar: objectValidator<OrganizationSettings['calendar']>({
@@ -2760,6 +2800,7 @@ export const automationTriggerEventValidator = orValidator<{ [K in AutomationTri
2760
2800
  type: exactMatchValidator(['Form Submitted']),
2761
2801
  info: objectValidator<AutomationTriggerEvents['Form Submitted']['info']>({
2762
2802
  formId: mongoIdStringRequired,
2803
+ publicIdentifier: stringValidatorOptionalEmptyOkay,
2763
2804
  }),
2764
2805
  conditions: orValidator({
2765
2806
  optional: optionalAnyObjectValidator,
@@ -2813,10 +2854,13 @@ export const automationTriggerEventValidator = orValidator<{ [K in AutomationTri
2813
2854
  }),
2814
2855
  })
2815
2856
 
2857
+
2858
+
2816
2859
  const _AUTOMATION_TRIGGER_ACTION_TYPES: { [K in AutomationTriggerActionType]: any } = {
2817
2860
  "Add To Journey": true,
2818
2861
  "Move To Step": true,
2819
2862
  "Add Tags": true,
2863
+ "Assign Care Team": true,
2820
2864
  }
2821
2865
  export const AUTOMATION_TRIGGER_ACTION_TYPES = Object.keys(_AUTOMATION_TRIGGER_ACTION_TYPES) as AutomationTriggerActionType[]
2822
2866
 
@@ -2837,6 +2881,12 @@ export const automationTriggerActionValidator = orValidator<{ [K in AutomationTr
2837
2881
  tags: listOfStringsValidator,
2838
2882
  }),
2839
2883
  }),
2884
+ "Assign Care Team": objectValidator<AutomationTriggerActions["Assign Care Team"]>({
2885
+ type: exactMatchValidator(['Assign Care Team']),
2886
+ info: objectValidator<AutomationTriggerActions['Assign Care Team']['info']>({
2887
+ tags: listOfStringsWithQualifierValidator,
2888
+ }),
2889
+ }),
2840
2890
  })
2841
2891
 
2842
2892
 
@@ -2906,6 +2956,7 @@ export const accessPermissionValidator = objectValidator<AccessForResource>({
2906
2956
  showInSidebar: booleanValidatorOptional,
2907
2957
  }, { isOptional: true })
2908
2958
  export const accessPermissionsValidator = objectValidator<AccessPermissions>({
2959
+ enduser_custom_types: accessPermissionValidator,
2909
2960
  superbill_providers: accessPermissionValidator,
2910
2961
  superbills: accessPermissionValidator,
2911
2962
  availability_blocks: accessPermissionValidator,
@@ -2971,6 +3022,7 @@ export const accessPermissionsValidator = objectValidator<AccessPermissions>({
2971
3022
  })
2972
3023
 
2973
3024
  export const organizationLimitsValidator = objectValidator<OrganizationLimits>({
3025
+ enduser_custom_types: numberValidatorOptional,
2974
3026
  referral_providers: numberValidatorOptional,
2975
3027
  superbill_providers: numberValidatorOptional,
2976
3028
  superbills: numberValidatorOptional,
@@ -3102,13 +3154,6 @@ export const integrationTitleValidator = exactMatchValidator<IntegrationsTitleTy
3102
3154
  ZOOM_TITLE,
3103
3155
  ])
3104
3156
 
3105
- const _LIST_QUERY_QUALIFIERS: { [K in ListQueryQualifier]: any} = {
3106
- "One Of": '',
3107
- "All Of": "",
3108
- }
3109
- export const LIST_QUERY_QUALIFIERS = Object.keys(_LIST_QUERY_QUALIFIERS) as ListQueryQualifier[]
3110
- export const listQueryQualifiersValidator = exactMatchValidator<ListQueryQualifier>(LIST_QUERY_QUALIFIERS)
3111
-
3112
3157
  const _VIDEO_INTEGRATION_TYPES: { [K in VideoIntegrationType]: any} = {
3113
3158
  Zoom: '',
3114
3159
  "No Integration": '',
@@ -3313,6 +3358,66 @@ export const analyticsQueryValidator = orValidator<{ [K in AnalyticsQueryType]:
3313
3358
  key: exactMatchValidator<AnalyticsQueryRangeKeyForType['Tickets']>(['Created At', 'Updated At']),
3314
3359
  }, { isOptional: true, emptyOk: true })
3315
3360
  }),
3361
+ "Emails": objectValidator<AnalyticsQueryForType['Emails']>({
3362
+ resource: exactMatchValidator<'Emails'>(['Emails']),
3363
+ filter: objectValidator<AnalyticsQueryFilterForType['Emails']>({ }, { isOptional: true, emptyOk: true }),
3364
+ info: orValidator<{ [K in keyof AnalyticsQueryInfoForType['Emails']]: AnalyticsQueryInfoForType['Emails'][K] }>({
3365
+ "Total": objectValidator<AnalyticsQueryInfoForType['Emails']['Total']>({
3366
+ method: exactMatchValidator<"Total">(['Total']),
3367
+ parameters: optionalEmptyObjectValidator,
3368
+ }),
3369
+ }),
3370
+ grouping: objectValidator<AnalyticsQueryGroupingForType['Emails']>({
3371
+ Gender: booleanValidatorOptional,
3372
+ "Assigned To": booleanValidatorOptional,
3373
+ Field: stringValidatorOptionalEmptyOkay,
3374
+ Tags: booleanValidatorOptional,
3375
+ }, { isOptional: true, emptyOk: true }),
3376
+ range: objectValidator<AnalyticsQueryRange<any>>({
3377
+ interval: exactMatchValidator<AnalyticsQueryRangeInterval>(['Daily', 'Weekly', 'Monthly']),
3378
+ key: exactMatchValidator<AnalyticsQueryRangeKeyForType['Emails']>(['Created At', 'Updated At']),
3379
+ }, { isOptional: true, emptyOk: true })
3380
+ }),
3381
+ "Phone Calls": objectValidator<AnalyticsQueryForType['Phone Calls']>({
3382
+ resource: exactMatchValidator<'Phone Calls'>(['Phone Calls']),
3383
+ filter: objectValidator<AnalyticsQueryFilterForType['Phone Calls']>({ }, { isOptional: true, emptyOk: true }),
3384
+ info: orValidator<{ [K in keyof AnalyticsQueryInfoForType['Phone Calls']]: AnalyticsQueryInfoForType['Phone Calls'][K] }>({
3385
+ "Total": objectValidator<AnalyticsQueryInfoForType['Phone Calls']['Total']>({
3386
+ method: exactMatchValidator<"Total">(['Total']),
3387
+ parameters: optionalEmptyObjectValidator,
3388
+ }),
3389
+ }),
3390
+ grouping: objectValidator<AnalyticsQueryGroupingForType['Phone Calls']>({
3391
+ Gender: booleanValidatorOptional,
3392
+ "Assigned To": booleanValidatorOptional,
3393
+ Field: stringValidatorOptionalEmptyOkay,
3394
+ Tags: booleanValidatorOptional,
3395
+ }, { isOptional: true, emptyOk: true }),
3396
+ range: objectValidator<AnalyticsQueryRange<any>>({
3397
+ interval: exactMatchValidator<AnalyticsQueryRangeInterval>(['Daily', 'Weekly', 'Monthly']),
3398
+ key: exactMatchValidator<AnalyticsQueryRangeKeyForType['Phone Calls']>(['Created At', 'Updated At']),
3399
+ }, { isOptional: true, emptyOk: true })
3400
+ }),
3401
+ "SMS Messages": objectValidator<AnalyticsQueryForType['SMS Messages']>({
3402
+ resource: exactMatchValidator<'SMS Messages'>(['SMS Messages']),
3403
+ filter: objectValidator<AnalyticsQueryFilterForType['SMS Messages']>({ }, { isOptional: true, emptyOk: true }),
3404
+ info: orValidator<{ [K in keyof AnalyticsQueryInfoForType['SMS Messages']]: AnalyticsQueryInfoForType['SMS Messages'][K] }>({
3405
+ "Total": objectValidator<AnalyticsQueryInfoForType['SMS Messages']['Total']>({
3406
+ method: exactMatchValidator<"Total">(['Total']),
3407
+ parameters: optionalEmptyObjectValidator,
3408
+ }),
3409
+ }),
3410
+ grouping: objectValidator<AnalyticsQueryGroupingForType['SMS Messages']>({
3411
+ Gender: booleanValidatorOptional,
3412
+ "Assigned To": booleanValidatorOptional,
3413
+ Field: stringValidatorOptionalEmptyOkay,
3414
+ Tags: booleanValidatorOptional,
3415
+ }, { isOptional: true, emptyOk: true }),
3416
+ range: objectValidator<AnalyticsQueryRange<any>>({
3417
+ interval: exactMatchValidator<AnalyticsQueryRangeInterval>(['Daily', 'Weekly', 'Monthly']),
3418
+ key: exactMatchValidator<AnalyticsQueryRangeKeyForType['SMS Messages']>(['Created At', 'Updated At']),
3419
+ }, { isOptional: true, emptyOk: true })
3420
+ }),
3316
3421
  })
3317
3422
  export const analyticsQueriesValidatorOptional = listValidatorOptionalOrEmptyOk(analyticsQueryValidator)
3318
3423
 
@@ -3329,6 +3434,9 @@ const _ANALYTICS_QUERY_TYPES: { [K in AnalyticsQueryType]: any } = {
3329
3434
  Purchases: true,
3330
3435
  "Purchase Credits": true,
3331
3436
  Tickets: true,
3437
+ "Phone Calls": true,
3438
+ "SMS Messages": true,
3439
+ Emails: true,
3332
3440
  }
3333
3441
  export const ANALYTICS_QUERY_TYPES = Object.keys(_ANALYTICS_QUERY_TYPES) as AnalyticsQueryType[]
3334
3442
  export const analyticsQueryTypeValidator = exactMatchValidator<AnalyticsQueryType>(ANALYTICS_QUERY_TYPES)
@@ -3456,5 +3564,6 @@ export const phoneTreeEnduserConditionValidator = exactMatchValidator<PhoneTreeE
3456
3564
 
3457
3565
  export const formCustomizationValidator = objectValidator<Form['customization']>({
3458
3566
  publicFormSubmitHTMLDescription: stringValidator5000OptionalEmptyOkay,
3567
+ publicLabelPrefix: stringValidator5000EmptyOkay,
3459
3568
  hideProgressBar: booleanValidatorOptional,
3460
3569
  })