@tellescope/validation 1.6.1 → 1.7.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 -9
- package/lib/cjs/validation.d.ts.map +1 -1
- package/lib/cjs/validation.js +135 -73
- package/lib/cjs/validation.js.map +1 -1
- package/lib/esm/validation.d.ts +25 -9
- package/lib/esm/validation.d.ts.map +1 -1
- package/lib/esm/validation.js +130 -68
- package/lib/esm/validation.js.map +1 -1
- package/lib/tsconfig.tsbuildinfo +1 -1
- package/package.json +6 -6
- package/src/validation.ts +147 -69
package/lib/esm/validation.js
CHANGED
|
@@ -724,8 +724,8 @@ export var numberValidatorBuilder = function (_a) {
|
|
|
724
724
|
});
|
|
725
725
|
};
|
|
726
726
|
export var nonNegNumberValidator = numberValidatorBuilder({ lower: 0, upper: 10000000000000 }); // max is 2286 in UTC MS
|
|
727
|
-
export var numberValidator = numberValidatorBuilder({ lower: -
|
|
728
|
-
export var numberValidatorOptional = numberValidatorBuilder({ lower: -
|
|
727
|
+
export var numberValidator = numberValidatorBuilder({ lower: -10000000000000, upper: 10000000000000 }); // max is 2286 in UTC MS
|
|
728
|
+
export var numberValidatorOptional = numberValidatorBuilder({ lower: -10000000000000, upper: 10000000000000, isOptional: true, emptyStringOk: true }); // max is 2286 in UTC MS
|
|
729
729
|
export var fileSizeValidator = numberValidatorBuilder({ lower: 0, upper: MAX_FILE_SIZE });
|
|
730
730
|
export var numberOrStringValidatorOptional = orValidator({
|
|
731
731
|
number: numberValidatorOptional,
|
|
@@ -805,6 +805,66 @@ export var exactMatchValidatorOptional = function (matches) { return ({
|
|
|
805
805
|
getType: getTypeString,
|
|
806
806
|
}); };
|
|
807
807
|
export var exactMatchListValidator = function (matches) { return listValidator(exactMatchValidator(matches)); };
|
|
808
|
+
export var VALID_STATES = [
|
|
809
|
+
"AK",
|
|
810
|
+
"AL",
|
|
811
|
+
"AR",
|
|
812
|
+
"AS",
|
|
813
|
+
"AZ",
|
|
814
|
+
"CA",
|
|
815
|
+
"CO",
|
|
816
|
+
"CT",
|
|
817
|
+
"DC",
|
|
818
|
+
"DE",
|
|
819
|
+
"FL",
|
|
820
|
+
"GA",
|
|
821
|
+
"GU",
|
|
822
|
+
"HI",
|
|
823
|
+
"IA",
|
|
824
|
+
"ID",
|
|
825
|
+
"IL",
|
|
826
|
+
"IN",
|
|
827
|
+
"KS",
|
|
828
|
+
"KY",
|
|
829
|
+
"LA",
|
|
830
|
+
"MA",
|
|
831
|
+
"MD",
|
|
832
|
+
"ME",
|
|
833
|
+
"MI",
|
|
834
|
+
"MN",
|
|
835
|
+
"MO",
|
|
836
|
+
"MP",
|
|
837
|
+
"MS",
|
|
838
|
+
"MT",
|
|
839
|
+
"NC",
|
|
840
|
+
"ND",
|
|
841
|
+
"NE",
|
|
842
|
+
"NH",
|
|
843
|
+
"NJ",
|
|
844
|
+
"NM",
|
|
845
|
+
"NV",
|
|
846
|
+
"NY",
|
|
847
|
+
"OH",
|
|
848
|
+
"OK",
|
|
849
|
+
"OR",
|
|
850
|
+
"PA",
|
|
851
|
+
"PR",
|
|
852
|
+
"RI",
|
|
853
|
+
"SC",
|
|
854
|
+
"SD",
|
|
855
|
+
"TN",
|
|
856
|
+
"TX",
|
|
857
|
+
"UM",
|
|
858
|
+
"UT",
|
|
859
|
+
"VA",
|
|
860
|
+
"VI",
|
|
861
|
+
"VT",
|
|
862
|
+
"WA",
|
|
863
|
+
"WI",
|
|
864
|
+
"WV",
|
|
865
|
+
"WY",
|
|
866
|
+
];
|
|
867
|
+
export var stateValidator = exactMatchValidator(VALID_STATES);
|
|
808
868
|
export var journeysValidator = {
|
|
809
869
|
validate: function (options) {
|
|
810
870
|
if (options === void 0) { options = {}; }
|
|
@@ -988,10 +1048,12 @@ var _FORM_FIELD_TYPES = {
|
|
|
988
1048
|
"Question Group": '',
|
|
989
1049
|
"Table Input": '',
|
|
990
1050
|
description: '',
|
|
1051
|
+
Address: '',
|
|
991
1052
|
};
|
|
992
1053
|
export var FORM_FIELD_TYPES = Object.keys(_FORM_FIELD_TYPES);
|
|
993
1054
|
export var formFieldTypeValidator = exactMatchValidator(FORM_FIELD_TYPES);
|
|
994
1055
|
export var FORM_FIELD_VALIDATORS_BY_TYPE = {
|
|
1056
|
+
'Address': objectAnyFieldsAnyValuesValidator.validate(),
|
|
995
1057
|
'description': function (g) { return ''; },
|
|
996
1058
|
'Table Input': function (g) { return Array.isArray(g) ? g : []; },
|
|
997
1059
|
'Question Group': function (g) { return Array.isArray(g) ? g : []; },
|
|
@@ -1250,6 +1312,16 @@ export var formResponseAnswerValidator = orValidator({
|
|
|
1250
1312
|
id: mongoIdStringRequired,
|
|
1251
1313
|
}))
|
|
1252
1314
|
}),
|
|
1315
|
+
"Address": objectValidator({
|
|
1316
|
+
type: exactMatchValidator(['Address']),
|
|
1317
|
+
value: objectValidator({
|
|
1318
|
+
addressLineOne: stringValidator1000,
|
|
1319
|
+
addressLineTwo: stringValidator1000Optional,
|
|
1320
|
+
city: stringValidator1000,
|
|
1321
|
+
state: stateValidator,
|
|
1322
|
+
zipCode: stringValidator100
|
|
1323
|
+
})
|
|
1324
|
+
}),
|
|
1253
1325
|
"Table Input": objectValidator({
|
|
1254
1326
|
type: exactMatchValidator(['Table Input']),
|
|
1255
1327
|
value: listValidatorOptionalOrEmptyOk(// optional to support optional Table Input questions
|
|
@@ -1763,12 +1835,24 @@ export var integrationAuthenticationsValidator = objectValidator({
|
|
|
1763
1835
|
email: emailValidatorOptional,
|
|
1764
1836
|
}),
|
|
1765
1837
|
});
|
|
1838
|
+
var _TABLE_INPUT_TYPES = {
|
|
1839
|
+
Date: '',
|
|
1840
|
+
Text: '',
|
|
1841
|
+
Select: '',
|
|
1842
|
+
};
|
|
1843
|
+
export var TABLE_INPUT_TYPES = Object.keys(_TABLE_INPUT_TYPES);
|
|
1844
|
+
export var tableInputTypesValidator = exactMatchValidator(TABLE_INPUT_TYPES);
|
|
1766
1845
|
export var tableInputChoiceValidator = orValidator({
|
|
1767
1846
|
Text: objectValidator({
|
|
1768
1847
|
type: exactMatchValidator(['Text']),
|
|
1769
1848
|
label: stringValidator1000,
|
|
1770
1849
|
info: optionalEmptyObjectValidator,
|
|
1771
1850
|
}),
|
|
1851
|
+
Date: objectValidator({
|
|
1852
|
+
type: exactMatchValidator(['Date']),
|
|
1853
|
+
label: stringValidator1000,
|
|
1854
|
+
info: optionalEmptyObjectValidator,
|
|
1855
|
+
}),
|
|
1772
1856
|
Select: objectValidator({
|
|
1773
1857
|
type: exactMatchValidator(['Select']),
|
|
1774
1858
|
label: stringValidator1000,
|
|
@@ -1985,66 +2069,6 @@ export var genericUnitWithQuantityValidator = objectValidator({
|
|
|
1985
2069
|
value: stringValidator5000EmptyOkay,
|
|
1986
2070
|
unit: stringValidator1000,
|
|
1987
2071
|
});
|
|
1988
|
-
export var VALID_STATES = [
|
|
1989
|
-
"AK",
|
|
1990
|
-
"AL",
|
|
1991
|
-
"AR",
|
|
1992
|
-
"AS",
|
|
1993
|
-
"AZ",
|
|
1994
|
-
"CA",
|
|
1995
|
-
"CO",
|
|
1996
|
-
"CT",
|
|
1997
|
-
"DC",
|
|
1998
|
-
"DE",
|
|
1999
|
-
"FL",
|
|
2000
|
-
"GA",
|
|
2001
|
-
"GU",
|
|
2002
|
-
"HI",
|
|
2003
|
-
"IA",
|
|
2004
|
-
"ID",
|
|
2005
|
-
"IL",
|
|
2006
|
-
"IN",
|
|
2007
|
-
"KS",
|
|
2008
|
-
"KY",
|
|
2009
|
-
"LA",
|
|
2010
|
-
"MA",
|
|
2011
|
-
"MD",
|
|
2012
|
-
"ME",
|
|
2013
|
-
"MI",
|
|
2014
|
-
"MN",
|
|
2015
|
-
"MO",
|
|
2016
|
-
"MP",
|
|
2017
|
-
"MS",
|
|
2018
|
-
"MT",
|
|
2019
|
-
"NC",
|
|
2020
|
-
"ND",
|
|
2021
|
-
"NE",
|
|
2022
|
-
"NH",
|
|
2023
|
-
"NJ",
|
|
2024
|
-
"NM",
|
|
2025
|
-
"NV",
|
|
2026
|
-
"NY",
|
|
2027
|
-
"OH",
|
|
2028
|
-
"OK",
|
|
2029
|
-
"OR",
|
|
2030
|
-
"PA",
|
|
2031
|
-
"PR",
|
|
2032
|
-
"RI",
|
|
2033
|
-
"SC",
|
|
2034
|
-
"SD",
|
|
2035
|
-
"TN",
|
|
2036
|
-
"TX",
|
|
2037
|
-
"UM",
|
|
2038
|
-
"UT",
|
|
2039
|
-
"VA",
|
|
2040
|
-
"VI",
|
|
2041
|
-
"VT",
|
|
2042
|
-
"WA",
|
|
2043
|
-
"WI",
|
|
2044
|
-
"WV",
|
|
2045
|
-
"WY",
|
|
2046
|
-
];
|
|
2047
|
-
export var stateValidator = exactMatchValidator(VALID_STATES);
|
|
2048
2072
|
export var stateCredentialValidator = objectValidator({
|
|
2049
2073
|
expiresAt: dateValidatorOptional,
|
|
2050
2074
|
state: stateValidator,
|
|
@@ -2119,6 +2143,38 @@ export var organizationSettingsValidator = objectValidator({
|
|
|
2119
2143
|
export var calendarEventPortalSettingsValidator = objectValidator({
|
|
2120
2144
|
hideUsers: booleanValidatorOptional,
|
|
2121
2145
|
});
|
|
2146
|
+
var _AUTOMATION_TRIGGER_EVENT_TYPES = {
|
|
2147
|
+
"Form Submitted": true,
|
|
2148
|
+
};
|
|
2149
|
+
export var AUTOMATION_TRIGGER_EVENT_TYPES = Object.keys(_AUTOMATION_TRIGGER_EVENT_TYPES);
|
|
2150
|
+
export var automationTriggerEventValidator = orValidator({
|
|
2151
|
+
"Form Submitted": objectValidator({
|
|
2152
|
+
type: exactMatchValidator(['Form Submitted']),
|
|
2153
|
+
info: objectValidator({
|
|
2154
|
+
formId: mongoIdStringRequired,
|
|
2155
|
+
}),
|
|
2156
|
+
conditions: optionalEmptyObjectValidator,
|
|
2157
|
+
// info: objectValidator<AutomationTriggerEvents['Form Submitted']['conditions']>({ }),
|
|
2158
|
+
}),
|
|
2159
|
+
});
|
|
2160
|
+
var _AUTOMATION_TRIGGER_ACTION_TYPES = {
|
|
2161
|
+
"Add To Journey": true,
|
|
2162
|
+
};
|
|
2163
|
+
export var AUTOMATION_TRIGGER_ACTION_TYPES = Object.keys(_AUTOMATION_TRIGGER_ACTION_TYPES);
|
|
2164
|
+
export var automationTriggerActionValidator = orValidator({
|
|
2165
|
+
"Add To Journey": objectValidator({
|
|
2166
|
+
type: exactMatchValidator(['Add To Journey']),
|
|
2167
|
+
info: objectValidator({
|
|
2168
|
+
journeyId: mongoIdStringRequired,
|
|
2169
|
+
}),
|
|
2170
|
+
}),
|
|
2171
|
+
});
|
|
2172
|
+
var _AUTOMATION_TRIGGER_STATUSES = {
|
|
2173
|
+
Active: true,
|
|
2174
|
+
Inactive: true,
|
|
2175
|
+
};
|
|
2176
|
+
export var AUTOMATION_TRIGGER_STATUSES = Object.keys(_AUTOMATION_TRIGGER_STATUSES);
|
|
2177
|
+
export var automatioNTriggerStatusValidator = exactMatchValidator(AUTOMATION_TRIGGER_STATUSES);
|
|
2122
2178
|
// for each model name, this should be optional, but when a model name is provided, all CRUD fields should be required
|
|
2123
2179
|
// if this changes (e.g. CRUD fields are made optional), must merge better in authentication.ts in API
|
|
2124
2180
|
export var accessPermissionValidator = objectValidator({
|
|
@@ -2182,10 +2238,12 @@ export var accessPermissionsValidator = objectValidator({
|
|
|
2182
2238
|
phone_calls: accessPermissionValidator,
|
|
2183
2239
|
background_errors: accessPermissionValidator,
|
|
2184
2240
|
enduser_views: accessPermissionValidator,
|
|
2241
|
+
automation_triggers: accessPermissionValidator,
|
|
2185
2242
|
// deprecated but for backwards compatibility
|
|
2186
2243
|
apiKeys: accessPermissionValidator,
|
|
2187
2244
|
});
|
|
2188
2245
|
export var organizationLimitsValidator = objectValidator({
|
|
2246
|
+
automation_triggers: numberValidatorOptional,
|
|
2189
2247
|
background_errors: numberValidatorOptional,
|
|
2190
2248
|
enduser_views: numberValidatorOptional,
|
|
2191
2249
|
availability_blocks: numberValidatorOptional,
|
|
@@ -2292,11 +2350,21 @@ export var integrationTitleValidator = exactMatchValidator([
|
|
|
2292
2350
|
SQUARE_INTEGRATIONS_TITLE,
|
|
2293
2351
|
OUTLOOK_INTEGRATIONS_TITLE,
|
|
2294
2352
|
]);
|
|
2353
|
+
var _LIST_QUERY_QUALIFIERS = {
|
|
2354
|
+
"One Of": '',
|
|
2355
|
+
"All Of": "",
|
|
2356
|
+
};
|
|
2357
|
+
export var LIST_QUERY_QUALIFIERS = Object.keys(_LIST_QUERY_QUALIFIERS);
|
|
2358
|
+
export var listQueryQualifiersValidator = exactMatchValidator(LIST_QUERY_QUALIFIERS);
|
|
2295
2359
|
export var analyticsQueryValidator = orValidator({
|
|
2296
2360
|
Endusers: objectValidator({
|
|
2297
2361
|
resource: exactMatchValidator(['Endusers']),
|
|
2298
2362
|
filter: objectValidator({
|
|
2299
2363
|
activeSince: dateOptionalOrEmptyStringValidator,
|
|
2364
|
+
"Submitted Forms": objectValidator({
|
|
2365
|
+
qualifier: listQueryQualifiersValidator,
|
|
2366
|
+
formIds: listOfMongoIdStringValidator,
|
|
2367
|
+
}, { isOptional: true })
|
|
2300
2368
|
}, { isOptional: true, emptyOk: true }),
|
|
2301
2369
|
info: orValidator({
|
|
2302
2370
|
"Total": objectValidator({
|
|
@@ -2307,12 +2375,6 @@ export var analyticsQueryValidator = orValidator({
|
|
|
2307
2375
|
method: exactMatchValidator(['Percentage']),
|
|
2308
2376
|
parameters: optionalEmptyObjectValidator,
|
|
2309
2377
|
}),
|
|
2310
|
-
"Submitted Forms": objectValidator({
|
|
2311
|
-
method: exactMatchValidator(['Submitted Forms']),
|
|
2312
|
-
parameters: objectValidator({
|
|
2313
|
-
formIds: listOfMongoIdStringValidator,
|
|
2314
|
-
}),
|
|
2315
|
-
}),
|
|
2316
2378
|
})
|
|
2317
2379
|
}),
|
|
2318
2380
|
"Calendar Events": objectValidator({
|