@tellescope/validation 1.39.2 → 1.40.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
@@ -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,
@@ -746,6 +749,13 @@ export const stringValidatorOptionalEmptyOkay: ValidatorDefinition<string> = {
746
749
  getExample: getExampleString,
747
750
  getType: getTypeString,
748
751
  }
752
+ export const stringValidator5000OptionalEmptyOkay: ValidatorDefinition<string> = {
753
+ validate: (o={}) => build_validator(
754
+ escapeString(o), { ...o, maxLength: o.maxLength ?? 5000, listOf: false, isOptional: true }
755
+ ),
756
+ getExample: getExampleString,
757
+ getType: getTypeString,
758
+ }
749
759
  export const stringValidator100: ValidatorDefinition<string> = {
750
760
  validate: (o={}) => build_validator(
751
761
  escapeString(o), { ...o, maxLength: 100, listOf: false }
@@ -1319,7 +1329,8 @@ const _FORM_FIELD_TYPES: { [K in FormFieldType]: any } = {
1319
1329
  description: '',
1320
1330
  Address: '',
1321
1331
  Time: '',
1322
- Stripe: ''
1332
+ Stripe: '',
1333
+ Dropdown: '',
1323
1334
  }
1324
1335
  export const FORM_FIELD_TYPES = Object.keys(_FORM_FIELD_TYPES) as FormFieldType[]
1325
1336
  export const formFieldTypeValidator = exactMatchValidator<FormFieldType>(FORM_FIELD_TYPES)
@@ -1328,6 +1339,7 @@ export const FORM_FIELD_VALIDATORS_BY_TYPE: { [K in FormFieldType | 'userEmail'
1328
1339
  'Address': objectAnyFieldsAnyValuesValidator.validate(),
1329
1340
  'Time': stringValidator.validate({ maxLength: 100 }),
1330
1341
  'Stripe': stringValidator.validate({ maxLength: 100 }),
1342
+ Dropdown: listOfStringsValidator.validate({ emptyListOk: true }),
1331
1343
  'description': g => '',
1332
1344
  'Table Input': (g) => Array.isArray(g) ? g : [],
1333
1345
  'Question Group': (g) => Array.isArray(g) ? g : [],
@@ -1694,6 +1706,10 @@ export const formResponseAnswerValidator = orValidator<{ [K in FormFieldType]: F
1694
1706
  type: exactMatchValidator(['multiple_choice']),
1695
1707
  value: listOfStringsValidatorOptionalOrEmptyOk,
1696
1708
  }),
1709
+ Dropdown: objectValidator<FormResponseAnswerDropdown>({
1710
+ type: exactMatchValidator(['Dropdown']),
1711
+ value: listOfStringsValidatorOptionalOrEmptyOk,
1712
+ }),
1697
1713
  ranking: objectValidator<FormResponseAnswerRanking>({
1698
1714
  type: exactMatchValidator(['ranking']),
1699
1715
  value: listOfStringsValidatorOptionalOrEmptyOk,
@@ -1894,6 +1910,18 @@ export const chatRoomUserInfoValidator = objectAnyFieldsValidator(objectValidato
1894
1910
  unreadCount: nonNegNumberValidator,
1895
1911
  }))
1896
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
+
1897
1925
  const _AUTOMATION_ENDUSER_STATUS: { [K in AutomatedActionStatus]: any } = {
1898
1926
  active: '',
1899
1927
  finished: '',
@@ -1925,6 +1953,7 @@ const _AUTOMATION_ACTIONS: { [K in AutomationActionType]: any } = {
1925
1953
  setEnduserStatus: '',
1926
1954
  setEnduserFields: '',
1927
1955
  shareContent: '',
1956
+ notifyTeam: '',
1928
1957
  }
1929
1958
  export const AUTOMATION_ACTIONS = Object.keys(_AUTOMATION_ACTIONS) as AutomationActionType[]
1930
1959
  export const automationActionTypeValidator = exactMatchValidator<AutomationActionType>(AUTOMATION_ACTIONS)
@@ -2107,6 +2136,17 @@ export const automationActionValidator = orValidator<{ [K in AutomationActionTyp
2107
2136
  type: exactMatchValidator(['sendSMS']),
2108
2137
  info: objectValidator<AutomationForMessage>({ senderId: mongoIdStringRequired, templateId: mongoIdStringRequired }, { emptyOk: false }),
2109
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
+ }),
2110
2150
  sendForm: objectValidator<SendFormAutomationAction>({
2111
2151
  type: exactMatchValidator(['sendForm']),
2112
2152
  info: objectValidator<AutomationForFormRequest>({
@@ -2134,12 +2174,17 @@ export const automationActionValidator = orValidator<{ [K in AutomationActionTyp
2134
2174
  type: exactMatchValidator<'care-team-primary'>(['care-team-primary']),
2135
2175
  info: objectValidator<object>({}, { emptyOk: true }),
2136
2176
  }),
2177
+ 'by-tags': objectValidator<CreateTicketAssignmentStrategy>({
2178
+ type: exactMatchValidator<'by-tags'>(['by-tags']),
2179
+ info: listOfStringsWithQualifierValidator,
2180
+ }),
2137
2181
  'default': objectValidator<CreateTicketAssignmentStrategy>({
2138
2182
  type: exactMatchValidator<'default'>(['default']),
2139
2183
  info: objectValidator<object>({}, { emptyOk: true }),
2140
2184
  }),
2141
2185
  }),
2142
2186
  closeReasons: listOfStringsValidatorOptionalOrEmptyOk,
2187
+ restrictByState: booleanValidatorOptional,
2143
2188
  defaultAssignee: mongoIdStringRequired,
2144
2189
  forCarePlan: booleanValidatorOptional,
2145
2190
  hiddenFromTickets: booleanValidatorOptional,
@@ -2692,6 +2737,14 @@ export const customEnduserFieldValidator = orValidator<{ [K in CustomEnduserFiel
2692
2737
  })
2693
2738
  export const customEnduserFieldsValidatorOptionalOrEmpty = listValidatorOptionalOrEmptyOk(customEnduserFieldValidator)
2694
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
+
2695
2748
  export const organizationSettingsValidator = objectValidator<OrganizationSettings>({
2696
2749
  endusers: objectValidator<OrganizationSettings['endusers']>({
2697
2750
  disableMultipleChatRooms: booleanValidatorOptional,
@@ -2699,13 +2752,7 @@ export const organizationSettingsValidator = objectValidator<OrganizationSetting
2699
2752
  disableAdhocFields: booleanValidatorOptional,
2700
2753
  autoReplyEnabled: booleanValidatorOptional,
2701
2754
  customFields: customEnduserFieldsValidatorOptionalOrEmpty,
2702
- builtinFields: listValidatorOptionalOrEmptyOk(objectValidator<EnduserBuiltInField>({
2703
- field: stringValidator100,
2704
- label: stringValidator100,
2705
- hidden: booleanValidatorOptional,
2706
- required: booleanValidatorOptional,
2707
- requireConfirmation: booleanValidatorOptional,
2708
- })),
2755
+ builtinFields: buildInFieldsValidator,
2709
2756
  tags: listOfStringsValidatorOptionalOrEmptyOk,
2710
2757
  }, { isOptional: true }),
2711
2758
  calendar: objectValidator<OrganizationSettings['calendar']>({
@@ -2753,6 +2800,7 @@ export const automationTriggerEventValidator = orValidator<{ [K in AutomationTri
2753
2800
  type: exactMatchValidator(['Form Submitted']),
2754
2801
  info: objectValidator<AutomationTriggerEvents['Form Submitted']['info']>({
2755
2802
  formId: mongoIdStringRequired,
2803
+ publicIdentifier: stringValidatorOptionalEmptyOkay,
2756
2804
  }),
2757
2805
  conditions: orValidator({
2758
2806
  optional: optionalAnyObjectValidator,
@@ -2806,10 +2854,13 @@ export const automationTriggerEventValidator = orValidator<{ [K in AutomationTri
2806
2854
  }),
2807
2855
  })
2808
2856
 
2857
+
2858
+
2809
2859
  const _AUTOMATION_TRIGGER_ACTION_TYPES: { [K in AutomationTriggerActionType]: any } = {
2810
2860
  "Add To Journey": true,
2811
2861
  "Move To Step": true,
2812
2862
  "Add Tags": true,
2863
+ "Assign Care Team": true,
2813
2864
  }
2814
2865
  export const AUTOMATION_TRIGGER_ACTION_TYPES = Object.keys(_AUTOMATION_TRIGGER_ACTION_TYPES) as AutomationTriggerActionType[]
2815
2866
 
@@ -2830,6 +2881,12 @@ export const automationTriggerActionValidator = orValidator<{ [K in AutomationTr
2830
2881
  tags: listOfStringsValidator,
2831
2882
  }),
2832
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
+ }),
2833
2890
  })
2834
2891
 
2835
2892
 
@@ -2899,6 +2956,7 @@ export const accessPermissionValidator = objectValidator<AccessForResource>({
2899
2956
  showInSidebar: booleanValidatorOptional,
2900
2957
  }, { isOptional: true })
2901
2958
  export const accessPermissionsValidator = objectValidator<AccessPermissions>({
2959
+ enduser_custom_types: accessPermissionValidator,
2902
2960
  superbill_providers: accessPermissionValidator,
2903
2961
  superbills: accessPermissionValidator,
2904
2962
  availability_blocks: accessPermissionValidator,
@@ -2964,6 +3022,7 @@ export const accessPermissionsValidator = objectValidator<AccessPermissions>({
2964
3022
  })
2965
3023
 
2966
3024
  export const organizationLimitsValidator = objectValidator<OrganizationLimits>({
3025
+ enduser_custom_types: numberValidatorOptional,
2967
3026
  referral_providers: numberValidatorOptional,
2968
3027
  superbill_providers: numberValidatorOptional,
2969
3028
  superbills: numberValidatorOptional,
@@ -3095,13 +3154,6 @@ export const integrationTitleValidator = exactMatchValidator<IntegrationsTitleTy
3095
3154
  ZOOM_TITLE,
3096
3155
  ])
3097
3156
 
3098
- const _LIST_QUERY_QUALIFIERS: { [K in ListQueryQualifier]: any} = {
3099
- "One Of": '',
3100
- "All Of": "",
3101
- }
3102
- export const LIST_QUERY_QUALIFIERS = Object.keys(_LIST_QUERY_QUALIFIERS) as ListQueryQualifier[]
3103
- export const listQueryQualifiersValidator = exactMatchValidator<ListQueryQualifier>(LIST_QUERY_QUALIFIERS)
3104
-
3105
3157
  const _VIDEO_INTEGRATION_TYPES: { [K in VideoIntegrationType]: any} = {
3106
3158
  Zoom: '',
3107
3159
  "No Integration": '',
@@ -3445,4 +3497,10 @@ const _PHONE_TREE_ENDUSER_CONDITIONS: { [K in PhoneTreeEnduserCondition]: any }
3445
3497
  Unassigned: '',
3446
3498
  }
3447
3499
  export const PHONE_TREE_ENDUSER_CONDITIONS = Object.keys(_PHONE_TREE_ENDUSER_CONDITIONS) as PhoneTreeEnduserCondition[]
3448
- export const phoneTreeEnduserConditionValidator = exactMatchValidator<PhoneTreeEnduserCondition>(PHONE_TREE_ENDUSER_CONDITIONS)
3500
+ export const phoneTreeEnduserConditionValidator = exactMatchValidator<PhoneTreeEnduserCondition>(PHONE_TREE_ENDUSER_CONDITIONS)
3501
+
3502
+ export const formCustomizationValidator = objectValidator<Form['customization']>({
3503
+ publicFormSubmitHTMLDescription: stringValidator5000OptionalEmptyOkay,
3504
+ publicLabelPrefix: stringValidator5000EmptyOkay,
3505
+ hideProgressBar: booleanValidatorOptional,
3506
+ })