@dereekb/model 13.38.0 → 13.39.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/package.json +7 -7
- package/index.cjs.default.js +0 -1
- package/index.cjs.js +0 -3330
- package/index.cjs.mjs +0 -2
package/index.cjs.js
DELETED
|
@@ -1,3330 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
var util = require('@dereekb/util');
|
|
4
|
-
var arktype = require('arktype');
|
|
5
|
-
var makeError = require('make-error');
|
|
6
|
-
|
|
7
|
-
/**
|
|
8
|
-
* ArkType schema for a model key (non-empty string).
|
|
9
|
-
*/ var modelKeyType = arktype.type('string > 0');
|
|
10
|
-
/**
|
|
11
|
-
* ArkType schema for a model id (non-empty string).
|
|
12
|
-
*/ var modelIdType = arktype.type('string > 0');
|
|
13
|
-
/**
|
|
14
|
-
* ArkType schema for target model params with a required `key` field.
|
|
15
|
-
*/ var targetModelParamsType = arktype.type({
|
|
16
|
-
key: modelKeyType
|
|
17
|
-
});
|
|
18
|
-
/**
|
|
19
|
-
* ArkType schema for target model id params with a required `id` field.
|
|
20
|
-
*/ var targetModelIdParamsType = arktype.type({
|
|
21
|
-
id: modelIdType
|
|
22
|
-
});
|
|
23
|
-
|
|
24
|
-
function _array_like_to_array$3(arr, len) {
|
|
25
|
-
if (len == null || len > arr.length) len = arr.length;
|
|
26
|
-
for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
|
|
27
|
-
return arr2;
|
|
28
|
-
}
|
|
29
|
-
function _array_with_holes$3(arr) {
|
|
30
|
-
if (Array.isArray(arr)) return arr;
|
|
31
|
-
}
|
|
32
|
-
function _iterable_to_array_limit$3(arr, i) {
|
|
33
|
-
var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"];
|
|
34
|
-
if (_i == null) return;
|
|
35
|
-
var _arr = [];
|
|
36
|
-
var _n = true;
|
|
37
|
-
var _d = false;
|
|
38
|
-
var _s, _e;
|
|
39
|
-
try {
|
|
40
|
-
for(_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true){
|
|
41
|
-
_arr.push(_s.value);
|
|
42
|
-
if (i && _arr.length === i) break;
|
|
43
|
-
}
|
|
44
|
-
} catch (err) {
|
|
45
|
-
_d = true;
|
|
46
|
-
_e = err;
|
|
47
|
-
} finally{
|
|
48
|
-
try {
|
|
49
|
-
if (!_n && _i["return"] != null) _i["return"]();
|
|
50
|
-
} finally{
|
|
51
|
-
if (_d) throw _e;
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
return _arr;
|
|
55
|
-
}
|
|
56
|
-
function _non_iterable_rest$3() {
|
|
57
|
-
throw new TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
58
|
-
}
|
|
59
|
-
function _sliced_to_array$3(arr, i) {
|
|
60
|
-
return _array_with_holes$3(arr) || _iterable_to_array_limit$3(arr, i) || _unsupported_iterable_to_array$3(arr, i) || _non_iterable_rest$3();
|
|
61
|
-
}
|
|
62
|
-
function _type_of$1(obj) {
|
|
63
|
-
"@swc/helpers - typeof";
|
|
64
|
-
return obj && typeof Symbol !== "undefined" && obj.constructor === Symbol ? "symbol" : typeof obj;
|
|
65
|
-
}
|
|
66
|
-
function _unsupported_iterable_to_array$3(o, minLen) {
|
|
67
|
-
if (!o) return;
|
|
68
|
-
if (typeof o === "string") return _array_like_to_array$3(o, minLen);
|
|
69
|
-
var n = Object.prototype.toString.call(o).slice(8, -1);
|
|
70
|
-
if (n === "Object" && o.constructor) n = o.constructor.name;
|
|
71
|
-
if (n === "Map" || n === "Set") return Array.from(n);
|
|
72
|
-
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array$3(o, minLen);
|
|
73
|
-
}
|
|
74
|
-
/**
|
|
75
|
-
* Singleton ArkType schema that accepts any empty object (`{}`).
|
|
76
|
-
*
|
|
77
|
-
* Used as the canonical "no params" type for model API actions that require an ArkType schema but have no meaningful input fields.
|
|
78
|
-
*
|
|
79
|
-
* @example
|
|
80
|
-
* ```typescript
|
|
81
|
-
* export const doSomethingParamsType = emptyType<DoSomethingParams>();
|
|
82
|
-
* ```
|
|
83
|
-
*/ var EMPTY_ARKTYPE_TYPE = arktype.type({});
|
|
84
|
-
/**
|
|
85
|
-
* Returns the shared {@link EMPTY_ARKTYPE_TYPE} cast to the requested type, providing a typed empty-object schema
|
|
86
|
-
* without creating a new ArkType instance each time.
|
|
87
|
-
*
|
|
88
|
-
* @returns The singleton empty type schema typed as `Type<T>`
|
|
89
|
-
*
|
|
90
|
-
* @example
|
|
91
|
-
* ```typescript
|
|
92
|
-
* export interface ResyncAllParams {} // has no params currently
|
|
93
|
-
* export const resyncAllParamsType = emptyType<ResyncAllParams>();
|
|
94
|
-
* ```
|
|
95
|
-
*/ function emptyType() {
|
|
96
|
-
return EMPTY_ARKTYPE_TYPE;
|
|
97
|
-
}
|
|
98
|
-
function clearable(definition) {
|
|
99
|
-
var result;
|
|
100
|
-
if (typeof definition === 'string') {
|
|
101
|
-
result = "".concat(definition, " | null | undefined");
|
|
102
|
-
} else {
|
|
103
|
-
result = definition.or('null').or('undefined');
|
|
104
|
-
}
|
|
105
|
-
return result;
|
|
106
|
-
}
|
|
107
|
-
/**
|
|
108
|
-
* JSON Schema export helper that compensates for arktype's lossy export of narrow predicates,
|
|
109
|
-
* morphs, and `undefined`. Without this:.
|
|
110
|
-
*
|
|
111
|
-
* - narrowed strings like `type('string > 0').narrow(...)` export as the empty schema `{}`
|
|
112
|
-
* because arktype drops the narrow predicate and has no JSON-shaped base to fall back on.
|
|
113
|
-
* - {@link clearable} (a `T | null | undefined` union) exports as `anyOf: [<T>, {}, {type:"null"}]`
|
|
114
|
-
* because `undefined` has no JSON Schema equivalent.
|
|
115
|
-
*
|
|
116
|
-
* The fallback config:
|
|
117
|
-
* - `predicate` / `morph` — drop the lossy wrapper, keep the JSON-shaped base (e.g. a narrowed
|
|
118
|
-
* `string > 0` becomes `{type:"string", minLength:1}`).
|
|
119
|
-
* - `default` — emit `false` (matches nothing). This is a no-op inside `anyOf`, and
|
|
120
|
-
* {@link pruneFalseUnionBranches} strips it so `T | null | undefined` reads as `T | null`.
|
|
121
|
-
*
|
|
122
|
-
* The result is round-tripped through `JSON.parse(JSON.stringify(...))` to invoke arktype's
|
|
123
|
-
* boxed-node `toJSON()` callbacks before pruning; `structuredClone` would not call them.
|
|
124
|
-
*
|
|
125
|
-
* @param t - The arktype Type to export.
|
|
126
|
-
* @returns The pruned JSON Schema fragment as a plain object.
|
|
127
|
-
*/ function arktypeToJsonSchemaForExport(t) {
|
|
128
|
-
var raw = t.toJsonSchema({
|
|
129
|
-
fallback: {
|
|
130
|
-
predicate: function predicate(ctx) {
|
|
131
|
-
return ctx.base;
|
|
132
|
-
},
|
|
133
|
-
morph: function morph(ctx) {
|
|
134
|
-
return ctx.base;
|
|
135
|
-
},
|
|
136
|
-
// `false` is a valid JSON Schema value ("matches nothing"), but arktype's TS types
|
|
137
|
-
// reject `false` as the fallback return — cast through `unknown` to keep runtime behavior.
|
|
138
|
-
default: function _default() {
|
|
139
|
-
return false;
|
|
140
|
-
}
|
|
141
|
-
}
|
|
142
|
-
});
|
|
143
|
-
// structuredClone would skip arktype's boxed-node toJSON() callbacks, so JSON round-trip is required here.
|
|
144
|
-
return pruneFalseUnionBranches(JSON.parse(JSON.stringify(raw))); // NOSONAR typescript:S7784
|
|
145
|
-
}
|
|
146
|
-
/**
|
|
147
|
-
* Walks a JSON Schema and removes `false` entries from `anyOf` / `oneOf` arrays. `false`
|
|
148
|
-
* schemas match nothing, so dropping them does not change what the schema accepts — it
|
|
149
|
-
* just keeps the rendered output clean when {@link arktypeToJsonSchemaForExport}'s
|
|
150
|
-
* `() => false` fallback emitted no-op branches for unjsonifiable types like `undefined`.
|
|
151
|
-
*
|
|
152
|
-
* @param value - JSON Schema fragment to clean.
|
|
153
|
-
* @returns A structurally equivalent fragment with `false` branches dropped from any
|
|
154
|
-
* `anyOf` / `oneOf` arrays.
|
|
155
|
-
*/ function pruneFalseUnionBranches(value) {
|
|
156
|
-
var result = value;
|
|
157
|
-
if (Array.isArray(value)) {
|
|
158
|
-
result = value.map(pruneFalseUnionBranches);
|
|
159
|
-
} else if (value && (typeof value === "undefined" ? "undefined" : _type_of$1(value)) === 'object') {
|
|
160
|
-
var out = {};
|
|
161
|
-
var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
|
|
162
|
-
try {
|
|
163
|
-
for(var _iterator = Object.entries(value)[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
|
|
164
|
-
var _step_value = _sliced_to_array$3(_step.value, 2), key = _step_value[0], raw = _step_value[1];
|
|
165
|
-
if ((key === 'anyOf' || key === 'oneOf') && Array.isArray(raw)) {
|
|
166
|
-
var filtered = raw.filter(function(v) {
|
|
167
|
-
return v !== false;
|
|
168
|
-
}).map(pruneFalseUnionBranches);
|
|
169
|
-
if (filtered.length > 0) {
|
|
170
|
-
out[key] = filtered;
|
|
171
|
-
}
|
|
172
|
-
} else {
|
|
173
|
-
out[key] = pruneFalseUnionBranches(raw);
|
|
174
|
-
}
|
|
175
|
-
}
|
|
176
|
-
} catch (err) {
|
|
177
|
-
_didIteratorError = true;
|
|
178
|
-
_iteratorError = err;
|
|
179
|
-
} finally{
|
|
180
|
-
try {
|
|
181
|
-
if (!_iteratorNormalCompletion && _iterator.return != null) {
|
|
182
|
-
_iterator.return();
|
|
183
|
-
}
|
|
184
|
-
} finally{
|
|
185
|
-
if (_didIteratorError) {
|
|
186
|
-
throw _iteratorError;
|
|
187
|
-
}
|
|
188
|
-
}
|
|
189
|
-
}
|
|
190
|
-
result = out;
|
|
191
|
-
}
|
|
192
|
-
return result;
|
|
193
|
-
}
|
|
194
|
-
|
|
195
|
-
/**
|
|
196
|
-
* Matches "Date | string.date.parse".
|
|
197
|
-
*
|
|
198
|
-
* This is used for validating and parsing serialized data (e.g., API responses, JSON payloads)
|
|
199
|
-
* and/or runtime Date objects into the corresponding runtime types.
|
|
200
|
-
*
|
|
201
|
-
* If we only used Date, or only used string.date.parse, then using the ArkType gets more specific to
|
|
202
|
-
* those independent cases, and will cause validation errors if you end up passing the object of that type
|
|
203
|
-
* rather than a freshly parsed JSON string POJO of that type.
|
|
204
|
-
*/ var ARKTYPE_DATE_DTO_TYPE = 'Date | string.date.parse';
|
|
205
|
-
|
|
206
|
-
/**
|
|
207
|
-
* Maximum character length for address line fields (line1, line2).
|
|
208
|
-
*/ var ADDRESS_LINE_MAX_LENGTH = 50;
|
|
209
|
-
/**
|
|
210
|
-
* Maximum character length for city names.
|
|
211
|
-
*/ var ADDRESS_CITY_MAX_LENGTH = 80;
|
|
212
|
-
/**
|
|
213
|
-
* Maximum character length for full state names (e.g., "Texas").
|
|
214
|
-
*/ var ADDRESS_STATE_MAX_LENGTH = 30;
|
|
215
|
-
/**
|
|
216
|
-
* Maximum character length for two-letter state codes (e.g., "TX").
|
|
217
|
-
*/ var ADDRESS_STATE_CODE_MAX_LENGTH = 2;
|
|
218
|
-
/**
|
|
219
|
-
* Maximum character length for ZIP codes, accommodating ZIP+4 format (e.g., "77834-1234").
|
|
220
|
-
*/ var ADDRESS_ZIP_MAX_LENGTH = 11;
|
|
221
|
-
/**
|
|
222
|
-
* Maximum character length for country names.
|
|
223
|
-
*/ var ADDRESS_COUNTRY_MAX_LENGTH = 80;
|
|
224
|
-
/**
|
|
225
|
-
* Base ArkType schema for United States address fields without the state.
|
|
226
|
-
*/ var baseUnitedStatesAddressType = arktype.type({
|
|
227
|
-
line1: "0 < string <= ".concat(ADDRESS_LINE_MAX_LENGTH),
|
|
228
|
-
'line2?': clearable("string <= ".concat(ADDRESS_LINE_MAX_LENGTH)),
|
|
229
|
-
city: "0 < string <= ".concat(ADDRESS_CITY_MAX_LENGTH),
|
|
230
|
-
zip: [
|
|
231
|
-
/^\d{5}(-\d{4})?$/,
|
|
232
|
-
'&',
|
|
233
|
-
"string <= ".concat(ADDRESS_ZIP_MAX_LENGTH)
|
|
234
|
-
]
|
|
235
|
-
});
|
|
236
|
-
/**
|
|
237
|
-
* ArkType schema for a United States address with a two-letter state code (e.g., "TX").
|
|
238
|
-
*/ var unitedStatesAddressWithStateCodeType = baseUnitedStatesAddressType.merge({
|
|
239
|
-
state: [
|
|
240
|
-
util.US_STATE_CODE_STRING_REGEX,
|
|
241
|
-
'&',
|
|
242
|
-
"".concat(ADDRESS_STATE_CODE_MAX_LENGTH, " <= string <= ").concat(ADDRESS_STATE_CODE_MAX_LENGTH)
|
|
243
|
-
]
|
|
244
|
-
});
|
|
245
|
-
/**
|
|
246
|
-
* ArkType schema for a United States address with a full state name (e.g., "Texas").
|
|
247
|
-
*/ var unitedStatesAddressWithStateStringType = baseUnitedStatesAddressType.merge({
|
|
248
|
-
state: "0 < string <= ".concat(ADDRESS_STATE_MAX_LENGTH)
|
|
249
|
-
});
|
|
250
|
-
|
|
251
|
-
/**
|
|
252
|
-
* Fallback link type used when the actual type is not known.
|
|
253
|
-
*/ var UNKNOWN_WEBSITE_LINK_TYPE = 'u';
|
|
254
|
-
/**
|
|
255
|
-
* Maximum character length for a {@link WebsiteLinkType} string.
|
|
256
|
-
*/ var WEBSITE_LINK_TYPE_MAX_LENGTH = 32;
|
|
257
|
-
/**
|
|
258
|
-
* Regex pattern that validates a {@link WebsiteLinkType} as 1-32 alphanumeric characters.
|
|
259
|
-
*/ var WEBSITE_LINK_TYPE_REGEX = /^[a-zA-Z0-9]{1,32}$/;
|
|
260
|
-
/**
|
|
261
|
-
* Checks whether the given string is a valid {@link WebsiteLinkType}.
|
|
262
|
-
*
|
|
263
|
-
* @param input - Value to test against the website link type pattern.
|
|
264
|
-
* @returns True if it matches the alphanumeric 1-32 character pattern.
|
|
265
|
-
*
|
|
266
|
-
* @example
|
|
267
|
-
* ```typescript
|
|
268
|
-
* isValidWebsiteLinkType('fb'); // true
|
|
269
|
-
* isValidWebsiteLinkType(''); // false
|
|
270
|
-
* isValidWebsiteLinkType('a-b'); // false (hyphen not allowed)
|
|
271
|
-
* ```
|
|
272
|
-
*/ function isValidWebsiteLinkType(input) {
|
|
273
|
-
return WEBSITE_LINK_TYPE_REGEX.test(input);
|
|
274
|
-
}
|
|
275
|
-
/**
|
|
276
|
-
* Maximum character length for the encoded data string in a {@link WebsiteLink}.
|
|
277
|
-
*/ var WEBSITE_LINK_ENCODED_DATA_MAX_LENGTH = 1000;
|
|
278
|
-
/**
|
|
279
|
-
* ArkType schema for a {@link WebsiteLink}.
|
|
280
|
-
*/ var websiteLinkType = arktype.type({
|
|
281
|
-
t: [
|
|
282
|
-
WEBSITE_LINK_TYPE_REGEX,
|
|
283
|
-
'&',
|
|
284
|
-
"0 < string <= ".concat(WEBSITE_LINK_TYPE_MAX_LENGTH)
|
|
285
|
-
],
|
|
286
|
-
d: "0 < string <= ".concat(WEBSITE_LINK_ENCODED_DATA_MAX_LENGTH)
|
|
287
|
-
});
|
|
288
|
-
|
|
289
|
-
function _array_like_to_array$2(arr, len) {
|
|
290
|
-
if (len == null || len > arr.length) len = arr.length;
|
|
291
|
-
for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
|
|
292
|
-
return arr2;
|
|
293
|
-
}
|
|
294
|
-
function _array_with_holes$2(arr) {
|
|
295
|
-
if (Array.isArray(arr)) return arr;
|
|
296
|
-
}
|
|
297
|
-
function _iterable_to_array_limit$2(arr, i) {
|
|
298
|
-
var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"];
|
|
299
|
-
if (_i == null) return;
|
|
300
|
-
var _arr = [];
|
|
301
|
-
var _n = true;
|
|
302
|
-
var _d = false;
|
|
303
|
-
var _s, _e;
|
|
304
|
-
try {
|
|
305
|
-
for(_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true){
|
|
306
|
-
_arr.push(_s.value);
|
|
307
|
-
if (i && _arr.length === i) break;
|
|
308
|
-
}
|
|
309
|
-
} catch (err) {
|
|
310
|
-
_d = true;
|
|
311
|
-
_e = err;
|
|
312
|
-
} finally{
|
|
313
|
-
try {
|
|
314
|
-
if (!_n && _i["return"] != null) _i["return"]();
|
|
315
|
-
} finally{
|
|
316
|
-
if (_d) throw _e;
|
|
317
|
-
}
|
|
318
|
-
}
|
|
319
|
-
return _arr;
|
|
320
|
-
}
|
|
321
|
-
function _non_iterable_rest$2() {
|
|
322
|
-
throw new TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
323
|
-
}
|
|
324
|
-
function _sliced_to_array$2(arr, i) {
|
|
325
|
-
return _array_with_holes$2(arr) || _iterable_to_array_limit$2(arr, i) || _unsupported_iterable_to_array$2(arr, i) || _non_iterable_rest$2();
|
|
326
|
-
}
|
|
327
|
-
function _unsupported_iterable_to_array$2(o, minLen) {
|
|
328
|
-
if (!o) return;
|
|
329
|
-
if (typeof o === "string") return _array_like_to_array$2(o, minLen);
|
|
330
|
-
var n = Object.prototype.toString.call(o).slice(8, -1);
|
|
331
|
-
if (n === "Object" && o.constructor) n = o.constructor.name;
|
|
332
|
-
if (n === "Map" || n === "Set") return Array.from(n);
|
|
333
|
-
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array$2(o, minLen);
|
|
334
|
-
}
|
|
335
|
-
/**
|
|
336
|
-
* Maximum character length for a {@link WebsiteFileLinkType}. Matches {@link WEBSITE_LINK_TYPE_MAX_LENGTH}.
|
|
337
|
-
*/ var WEBSITE_FILE_LINK_TYPE_MAX_LENGTH = WEBSITE_LINK_TYPE_MAX_LENGTH;
|
|
338
|
-
/**
|
|
339
|
-
* Validation regex for {@link WebsiteFileLinkType}. Matches {@link WEBSITE_LINK_TYPE_REGEX}.
|
|
340
|
-
*/ var WEBSITE_FILE_LINK_TYPE_REGEX = WEBSITE_LINK_TYPE_REGEX;
|
|
341
|
-
/**
|
|
342
|
-
* Maximum character length for a {@link WebsiteFileLinkMimeType}.
|
|
343
|
-
*/ var WEBSITE_FILE_LINK_MIME_TYPE_MAX_LENGTH = 128;
|
|
344
|
-
/**
|
|
345
|
-
* Regex pattern that validates a MIME type string (e.g., "text/plain", "application/vnd.api+json").
|
|
346
|
-
*/ var WEBSITE_FILE_LINK_MIME_TYPE_REGEX = /^\w+\/[-+.\w]+$/;
|
|
347
|
-
/**
|
|
348
|
-
* Maximum character length for a {@link WebsiteFileLinkName}.
|
|
349
|
-
*/ var WEBSITE_FILE_LINK_NAME_MAX_LENGTH = 128;
|
|
350
|
-
/**
|
|
351
|
-
* Maximum character length for {@link WebsiteFileLinkData}, derived from the total encoded data budget
|
|
352
|
-
* minus the separator characters, type, MIME type, and name fields.
|
|
353
|
-
*/ var WEBSITE_FILE_LINK_DATA_MAX_LENGTH = WEBSITE_LINK_ENCODED_DATA_MAX_LENGTH - 3 - WEBSITE_FILE_LINK_TYPE_MAX_LENGTH - WEBSITE_FILE_LINK_MIME_TYPE_MAX_LENGTH - WEBSITE_FILE_LINK_NAME_MAX_LENGTH;
|
|
354
|
-
/**
|
|
355
|
-
* Regex pattern for file link data — disallows the pipe character since it is used as the encoding separator.
|
|
356
|
-
*/ var WEBSITE_FILE_LINK_DATA_REGEX = /^[^|]+$/;
|
|
357
|
-
/**
|
|
358
|
-
* ArkType schema for a {@link WebsiteFileLinkType} value.
|
|
359
|
-
*/ var websiteFileLinkTypeValueType = arktype.type([
|
|
360
|
-
WEBSITE_FILE_LINK_TYPE_REGEX,
|
|
361
|
-
'&',
|
|
362
|
-
"string <= ".concat(WEBSITE_LINK_TYPE_MAX_LENGTH)
|
|
363
|
-
]);
|
|
364
|
-
/**
|
|
365
|
-
* ArkType schema for a {@link WebsiteFileLinkMimeType} value.
|
|
366
|
-
*/ var websiteFileLinkMimeValueType = arktype.type([
|
|
367
|
-
WEBSITE_FILE_LINK_MIME_TYPE_REGEX,
|
|
368
|
-
'&',
|
|
369
|
-
"string <= ".concat(WEBSITE_FILE_LINK_MIME_TYPE_MAX_LENGTH)
|
|
370
|
-
]);
|
|
371
|
-
/**
|
|
372
|
-
* ArkType schema for a {@link WebsiteFileLink}.
|
|
373
|
-
*/ var websiteFileLinkType = arktype.type({
|
|
374
|
-
'type?': clearable(websiteFileLinkTypeValueType),
|
|
375
|
-
'mime?': clearable(websiteFileLinkMimeValueType),
|
|
376
|
-
'name?': clearable("string <= ".concat(WEBSITE_FILE_LINK_NAME_MAX_LENGTH)),
|
|
377
|
-
data: [
|
|
378
|
-
WEBSITE_FILE_LINK_DATA_REGEX,
|
|
379
|
-
'&',
|
|
380
|
-
"0 < string <= ".concat(WEBSITE_FILE_LINK_DATA_MAX_LENGTH)
|
|
381
|
-
]
|
|
382
|
-
});
|
|
383
|
-
/**
|
|
384
|
-
* The {@link WebsiteLinkType} code used to identify a {@link WebsiteLink} as a file link.
|
|
385
|
-
*/ var WEBSITE_FILE_LINK_WEBSITE_LINK_TYPE = 'f';
|
|
386
|
-
/**
|
|
387
|
-
* Converts a {@link WebsiteFileLink} to a {@link WebsiteLink} by encoding its fields into the data string.
|
|
388
|
-
*
|
|
389
|
-
* @param input - The file link to convert.
|
|
390
|
-
* @returns A WebsiteLink with type "f" and pipe-encoded data.
|
|
391
|
-
*
|
|
392
|
-
* @example
|
|
393
|
-
* ```typescript
|
|
394
|
-
* const fileLink: WebsiteFileLink = { type: 't', mime: 'text/plain', data: 'https://example.com/file.txt', name: 'file' };
|
|
395
|
-
* const link = websiteFileLinkToWebsiteLink(fileLink);
|
|
396
|
-
* // link.t === 'f'
|
|
397
|
-
* ```
|
|
398
|
-
*/ function websiteFileLinkToWebsiteLink(input) {
|
|
399
|
-
return {
|
|
400
|
-
t: WEBSITE_FILE_LINK_WEBSITE_LINK_TYPE,
|
|
401
|
-
d: encodeWebsiteFileLinkToWebsiteLinkEncodedData(input)
|
|
402
|
-
};
|
|
403
|
-
}
|
|
404
|
-
/**
|
|
405
|
-
* Converts a {@link WebsiteLink} back to a {@link WebsiteFileLink} by decoding the pipe-separated data string.
|
|
406
|
-
*
|
|
407
|
-
* @param input - A WebsiteLink whose data field contains an encoded file link.
|
|
408
|
-
* @returns The decoded file link with type, MIME, name, and data fields.
|
|
409
|
-
*
|
|
410
|
-
* @example
|
|
411
|
-
* ```typescript
|
|
412
|
-
* const link: WebsiteLink = { t: 'f', d: 't|text/plain|https://example.com/file.txt|file' };
|
|
413
|
-
* const fileLink = websiteLinkToWebsiteLinkFile(link);
|
|
414
|
-
* // fileLink.data === 'https://example.com/file.txt'
|
|
415
|
-
* ```
|
|
416
|
-
*/ function websiteLinkToWebsiteLinkFile(input) {
|
|
417
|
-
var encodedData = input.d;
|
|
418
|
-
return decodeWebsiteLinkEncodedDataToWebsiteFileLink(encodedData);
|
|
419
|
-
}
|
|
420
|
-
/**
|
|
421
|
-
* Separator character used when encoding/decoding file link fields into a single string.
|
|
422
|
-
*/ var WEBSITE_FILE_LINK_ENCODE_SEPARATOR = '|';
|
|
423
|
-
/**
|
|
424
|
-
* Encodes a {@link WebsiteFileLink} into a pipe-separated string suitable for storage in a {@link WebsiteLink}'s data field.
|
|
425
|
-
*
|
|
426
|
-
* Fields are encoded in order: type, MIME, data, name. Empty/undefined fields become empty strings.
|
|
427
|
-
*
|
|
428
|
-
* @param input - The file link to encode.
|
|
429
|
-
* @returns A pipe-separated encoded string.
|
|
430
|
-
*
|
|
431
|
-
* @example
|
|
432
|
-
* ```typescript
|
|
433
|
-
* const encoded = encodeWebsiteFileLinkToWebsiteLinkEncodedData({
|
|
434
|
-
* type: 't',
|
|
435
|
-
* mime: 'test/test',
|
|
436
|
-
* name: 'test-name',
|
|
437
|
-
* data: 'https://example.com/'
|
|
438
|
-
* });
|
|
439
|
-
* // encoded === 't|test/test|https://example.com/|test-name'
|
|
440
|
-
* ```
|
|
441
|
-
*/ function encodeWebsiteFileLinkToWebsiteLinkEncodedData(input) {
|
|
442
|
-
return [
|
|
443
|
-
input.type,
|
|
444
|
-
input.mime,
|
|
445
|
-
input.data,
|
|
446
|
-
input.name
|
|
447
|
-
].map(function(x) {
|
|
448
|
-
return x || '';
|
|
449
|
-
}).join(WEBSITE_FILE_LINK_ENCODE_SEPARATOR);
|
|
450
|
-
}
|
|
451
|
-
/**
|
|
452
|
-
* Decodes a pipe-separated encoded string back into a {@link WebsiteFileLink}.
|
|
453
|
-
*
|
|
454
|
-
* Empty fields in the encoded string are omitted from the result (falsy values are filtered out).
|
|
455
|
-
*
|
|
456
|
-
* @param input - The pipe-separated encoded string.
|
|
457
|
-
* @returns The decoded file link.
|
|
458
|
-
*
|
|
459
|
-
* @example
|
|
460
|
-
* ```typescript
|
|
461
|
-
* const fileLink = decodeWebsiteLinkEncodedDataToWebsiteFileLink('t|test/test|https://example.com/|test-name');
|
|
462
|
-
* // fileLink.type === 't'
|
|
463
|
-
* // fileLink.mime === 'test/test'
|
|
464
|
-
* // fileLink.data === 'https://example.com/'
|
|
465
|
-
* // fileLink.name === 'test-name'
|
|
466
|
-
* ```
|
|
467
|
-
*/ function decodeWebsiteLinkEncodedDataToWebsiteFileLink(input) {
|
|
468
|
-
var _splitJoinRemainder = _sliced_to_array$2(util.splitJoinRemainder(input, WEBSITE_FILE_LINK_ENCODE_SEPARATOR, 4), 4), _$type = _splitJoinRemainder[0], mime = _splitJoinRemainder[1], data = _splitJoinRemainder[2], name = _splitJoinRemainder[3];
|
|
469
|
-
return util.filterFalsyAndEmptyValues({
|
|
470
|
-
type: _$type,
|
|
471
|
-
mime: mime,
|
|
472
|
-
name: name,
|
|
473
|
-
data: data
|
|
474
|
-
});
|
|
475
|
-
}
|
|
476
|
-
|
|
477
|
-
/**
|
|
478
|
-
* Isolates a username from a URL where the username is the first path segment after the domain.
|
|
479
|
-
*
|
|
480
|
-
* Strips trailing slashes and query parameters. Used by social platforms like Facebook, Instagram, and Twitter
|
|
481
|
-
* where the profile URL pattern is `https://domain.com/{username}`.
|
|
482
|
-
*
|
|
483
|
-
* @example
|
|
484
|
-
* ```typescript
|
|
485
|
-
* WEBSITE_LINK_ISOLATE_BASE_URL_PROFILE_ID('https://www.facebook.com/myuser');
|
|
486
|
-
* // returns 'myuser'
|
|
487
|
-
* ```
|
|
488
|
-
*/ var WEBSITE_LINK_ISOLATE_BASE_URL_PROFILE_ID = util.isolateWebsitePathFunction({
|
|
489
|
-
isolatePathComponents: 0,
|
|
490
|
-
removeTrailingSlash: true,
|
|
491
|
-
removeQueryParameters: true
|
|
492
|
-
});
|
|
493
|
-
/**
|
|
494
|
-
* Extracts a username from either a raw username string or a full profile URL where the username is the first path segment.
|
|
495
|
-
*
|
|
496
|
-
* Optionally prepends a prefix (e.g., "@" for TikTok, "$" for Cash App).
|
|
497
|
-
*
|
|
498
|
-
* @param input - A username or full profile URL.
|
|
499
|
-
* @param prefix - Optional prefix to prepend to the extracted username.
|
|
500
|
-
* @returns The isolated username, optionally prefixed.
|
|
501
|
-
*
|
|
502
|
-
* @example
|
|
503
|
-
* ```typescript
|
|
504
|
-
* usernameFromUsernameOrWebsiteWithBaseUrlUsername('https://facebook.com/myuser');
|
|
505
|
-
* // returns 'myuser'
|
|
506
|
-
*
|
|
507
|
-
* usernameFromUsernameOrWebsiteWithBaseUrlUsername('myuser', '@');
|
|
508
|
-
* // returns '@myuser'
|
|
509
|
-
* ```
|
|
510
|
-
*/ function usernameFromUsernameOrWebsiteWithBaseUrlUsername(input, prefix) {
|
|
511
|
-
var username = util.toRelativeSlashPathStartType(WEBSITE_LINK_ISOLATE_BASE_URL_PROFILE_ID(usernameOrWebsiteUrlToWebsiteUrl(input)));
|
|
512
|
-
return prefix ? util.addPrefix(prefix, username) : username;
|
|
513
|
-
}
|
|
514
|
-
/**
|
|
515
|
-
* Extracts a username from either a raw username string or a full profile URL using a custom path isolation function.
|
|
516
|
-
*
|
|
517
|
-
* Used for platforms with non-standard URL patterns (e.g., Snapchat's `/add/{username}`, YouTube's `/c/{username}`).
|
|
518
|
-
*
|
|
519
|
-
* @param input - A username or full profile URL.
|
|
520
|
-
* @param isolateFn - Custom function that extracts the relevant path segment from the URL.
|
|
521
|
-
* @returns The isolated username.
|
|
522
|
-
*/ function usernameFromUsernameOrWebsiteWithOneOffBaseUrlUsername(input, isolateFn) {
|
|
523
|
-
return util.toRelativeSlashPathStartType(isolateFn(usernameOrWebsiteUrlToWebsiteUrl(input)));
|
|
524
|
-
}
|
|
525
|
-
/**
|
|
526
|
-
* Normalizes a string that may be either a plain username or a full website URL into a consistent URL format.
|
|
527
|
-
*
|
|
528
|
-
* If the input has a website domain, it is returned as-is. Otherwise, it is treated as a path and converted to an absolute slash path.
|
|
529
|
-
*
|
|
530
|
-
* @param input - A username or website URL.
|
|
531
|
-
* @returns A normalized website URL.
|
|
532
|
-
*/ function usernameOrWebsiteUrlToWebsiteUrl(input) {
|
|
533
|
-
return util.hasWebsiteDomain(input) ? input : util.toAbsoluteSlashPathStartType(util.removeHttpFromUrl(input));
|
|
534
|
-
}
|
|
535
|
-
// MARK: Website
|
|
536
|
-
/**
|
|
537
|
-
* {@link WebsiteLinkType} code for generic website URLs.
|
|
538
|
-
*/ var WEBSITE_URL_WEBSITE_LINK_TYPE = 'w';
|
|
539
|
-
/**
|
|
540
|
-
* Converts a generic website URL into a {@link WebsiteLink}, stripping the HTTP/HTTPS protocol.
|
|
541
|
-
*
|
|
542
|
-
* @param input - The full website URL.
|
|
543
|
-
* @returns A WebsiteLink with the protocol removed from the data.
|
|
544
|
-
*
|
|
545
|
-
* @example
|
|
546
|
-
* ```typescript
|
|
547
|
-
* const link = websiteUrlToWebsiteLink('https://example.com/page');
|
|
548
|
-
* // link.t === 'w', link.d === 'example.com/page'
|
|
549
|
-
* ```
|
|
550
|
-
*/ function websiteUrlToWebsiteLink(input) {
|
|
551
|
-
return {
|
|
552
|
-
t: WEBSITE_URL_WEBSITE_LINK_TYPE,
|
|
553
|
-
d: util.removeHttpFromUrl(input) // website urls are stored as-is without http/https
|
|
554
|
-
};
|
|
555
|
-
}
|
|
556
|
-
// MARK: Email
|
|
557
|
-
/**
|
|
558
|
-
* {@link WebsiteLinkType} code for email addresses.
|
|
559
|
-
*/ var EMAIL_URL_WEBSITE_LINK_TYPE = 'e';
|
|
560
|
-
/**
|
|
561
|
-
* Converts an email address into a {@link WebsiteLink}.
|
|
562
|
-
*
|
|
563
|
-
* @param input - The email address.
|
|
564
|
-
* @returns A WebsiteLink storing the email as data.
|
|
565
|
-
*/ function emailAddressToWebsiteLink(input) {
|
|
566
|
-
return {
|
|
567
|
-
t: EMAIL_URL_WEBSITE_LINK_TYPE,
|
|
568
|
-
d: input
|
|
569
|
-
};
|
|
570
|
-
}
|
|
571
|
-
// MARK: Phone
|
|
572
|
-
/**
|
|
573
|
-
* {@link WebsiteLinkType} code for phone numbers.
|
|
574
|
-
*/ var PHONE_URL_WEBSITE_LINK_TYPE = 'p';
|
|
575
|
-
/**
|
|
576
|
-
* Converts an E.164 phone number into a {@link WebsiteLink}.
|
|
577
|
-
*
|
|
578
|
-
* @param input - The phone number in E.164 format.
|
|
579
|
-
* @returns A WebsiteLink storing the phone number as data.
|
|
580
|
-
*/ function phoneNumberToWebsiteLink(input) {
|
|
581
|
-
return {
|
|
582
|
-
t: PHONE_URL_WEBSITE_LINK_TYPE,
|
|
583
|
-
d: input
|
|
584
|
-
};
|
|
585
|
-
}
|
|
586
|
-
// MARK: Facebook
|
|
587
|
-
/**
|
|
588
|
-
* Base URL for Facebook profiles.
|
|
589
|
-
*/ var FACEBOOK_BASE_URL = "https://www.facebook.com";
|
|
590
|
-
/**
|
|
591
|
-
* {@link WebsiteLinkType} code for Facebook.
|
|
592
|
-
*/ var FACEBOOK_WEBSITE_LINK_TYPE = 'fb';
|
|
593
|
-
/**
|
|
594
|
-
* Converts a Facebook profile ID or URL into a {@link WebsiteLink}.
|
|
595
|
-
*
|
|
596
|
-
* Accepts either a raw username or a full Facebook profile URL.
|
|
597
|
-
*
|
|
598
|
-
* @param input - A Facebook profile ID or full profile URL.
|
|
599
|
-
* @returns A WebsiteLink with the isolated username as data.
|
|
600
|
-
*
|
|
601
|
-
* @example
|
|
602
|
-
* ```typescript
|
|
603
|
-
* facebookProfileUrlToWebsiteLink('https://www.facebook.com/myuser');
|
|
604
|
-
* // { t: 'fb', d: 'myuser' }
|
|
605
|
-
*
|
|
606
|
-
* facebookProfileUrlToWebsiteLink('myuser');
|
|
607
|
-
* // { t: 'fb', d: 'myuser' }
|
|
608
|
-
* ```
|
|
609
|
-
*/ function facebookProfileUrlToWebsiteLink(input) {
|
|
610
|
-
return {
|
|
611
|
-
t: FACEBOOK_WEBSITE_LINK_TYPE,
|
|
612
|
-
d: usernameFromUsernameOrWebsiteWithBaseUrlUsername(input)
|
|
613
|
-
};
|
|
614
|
-
}
|
|
615
|
-
/**
|
|
616
|
-
* Constructs a full Facebook profile URL from a profile ID.
|
|
617
|
-
*
|
|
618
|
-
* @param profileId - The Facebook profile ID or username.
|
|
619
|
-
* @returns The full profile URL.
|
|
620
|
-
*/ function facebookProfileUrl(profileId) {
|
|
621
|
-
return "".concat(FACEBOOK_BASE_URL, "/").concat(profileId);
|
|
622
|
-
}
|
|
623
|
-
// MARK: Instagram
|
|
624
|
-
/**
|
|
625
|
-
* Base URL for Instagram profiles.
|
|
626
|
-
*/ var INSTAGRAM_BASE_URL = "https://www.instagram.com";
|
|
627
|
-
/**
|
|
628
|
-
* {@link WebsiteLinkType} code for Instagram.
|
|
629
|
-
*/ var INSTAGRAM_WEBSITE_LINK_TYPE = 'ig';
|
|
630
|
-
/**
|
|
631
|
-
* Converts an Instagram profile ID or URL into a {@link WebsiteLink}.
|
|
632
|
-
*
|
|
633
|
-
* @param input - An Instagram username or full profile URL.
|
|
634
|
-
* @returns A WebsiteLink with the isolated username as data.
|
|
635
|
-
*/ function instagramProfileUrlToWebsiteLink(input) {
|
|
636
|
-
return {
|
|
637
|
-
t: INSTAGRAM_WEBSITE_LINK_TYPE,
|
|
638
|
-
d: usernameFromUsernameOrWebsiteWithBaseUrlUsername(input)
|
|
639
|
-
};
|
|
640
|
-
}
|
|
641
|
-
/**
|
|
642
|
-
* Constructs a full Instagram profile URL from a profile ID.
|
|
643
|
-
*
|
|
644
|
-
* @param profileId - The Instagram username.
|
|
645
|
-
* @returns The full profile URL.
|
|
646
|
-
*/ function instagramProfileUrl(profileId) {
|
|
647
|
-
return "".concat(INSTAGRAM_BASE_URL, "/").concat(profileId);
|
|
648
|
-
}
|
|
649
|
-
// MARK: Twitter
|
|
650
|
-
/**
|
|
651
|
-
* Base URL for Twitter profiles.
|
|
652
|
-
*/ var TWITTER_BASE_URL = "https://www.twitter.com";
|
|
653
|
-
/**
|
|
654
|
-
* {@link WebsiteLinkType} code for Twitter.
|
|
655
|
-
*/ var TWITTER_WEBSITE_LINK_TYPE = 'tw';
|
|
656
|
-
/**
|
|
657
|
-
* Converts a Twitter profile ID or URL into a {@link WebsiteLink}.
|
|
658
|
-
*
|
|
659
|
-
* @param input - A Twitter username or full profile URL.
|
|
660
|
-
* @returns A WebsiteLink with the isolated username as data.
|
|
661
|
-
*/ function twitterProfileUrlToWebsiteLink(input) {
|
|
662
|
-
return {
|
|
663
|
-
t: TWITTER_WEBSITE_LINK_TYPE,
|
|
664
|
-
d: usernameFromUsernameOrWebsiteWithBaseUrlUsername(input)
|
|
665
|
-
};
|
|
666
|
-
}
|
|
667
|
-
/**
|
|
668
|
-
* Constructs a full Twitter profile URL from a profile ID.
|
|
669
|
-
*
|
|
670
|
-
* @param profileId - The Twitter username.
|
|
671
|
-
* @returns The full profile URL.
|
|
672
|
-
*/ function twitterProfileUrl(profileId) {
|
|
673
|
-
return "".concat(TWITTER_BASE_URL, "/").concat(profileId);
|
|
674
|
-
}
|
|
675
|
-
// MARK: Tiktok
|
|
676
|
-
/**
|
|
677
|
-
* Base URL for TikTok profiles.
|
|
678
|
-
*/ var TIKTOK_BASE_URL = "https://tiktok.com";
|
|
679
|
-
/**
|
|
680
|
-
* TikTok usernames are prefixed with "@" in URLs and stored data.
|
|
681
|
-
*/ var TIKTOK_USERNAME_PREFIX = '@';
|
|
682
|
-
/**
|
|
683
|
-
* {@link WebsiteLinkType} code for TikTok.
|
|
684
|
-
*/ var TIKTOK_WEBSITE_LINK_TYPE = 'tt';
|
|
685
|
-
/**
|
|
686
|
-
* Converts a TikTok profile ID or URL into a {@link WebsiteLink}.
|
|
687
|
-
*
|
|
688
|
-
* Automatically prepends the "@" prefix if not already present.
|
|
689
|
-
*
|
|
690
|
-
* @param input - A TikTok username (with or without "@") or full profile URL.
|
|
691
|
-
* @returns A WebsiteLink with the "@"-prefixed username as data.
|
|
692
|
-
*/ function tiktokProfileUrlToWebsiteLink(input) {
|
|
693
|
-
return {
|
|
694
|
-
t: TIKTOK_WEBSITE_LINK_TYPE,
|
|
695
|
-
d: usernameFromUsernameOrWebsiteWithBaseUrlUsername(input, TIKTOK_USERNAME_PREFIX)
|
|
696
|
-
};
|
|
697
|
-
}
|
|
698
|
-
/**
|
|
699
|
-
* Constructs a full TikTok profile URL from a profile ID.
|
|
700
|
-
*
|
|
701
|
-
* @param profileId - The TikTok username (without "@" prefix)
|
|
702
|
-
* @returns The full profile URL with "@" prefix.
|
|
703
|
-
*/ function tiktokProfileUrl(profileId) {
|
|
704
|
-
return "".concat(TIKTOK_BASE_URL, "/@").concat(profileId);
|
|
705
|
-
}
|
|
706
|
-
// MARK: Snapchat
|
|
707
|
-
/**
|
|
708
|
-
* Base URL for Snapchat profiles.
|
|
709
|
-
*/ var SNAPCHAT_BASE_URL = "https://snapchat.com";
|
|
710
|
-
/**
|
|
711
|
-
* {@link WebsiteLinkType} code for Snapchat.
|
|
712
|
-
*/ var SNAPCHAT_WEBSITE_LINK_TYPE = 'sc';
|
|
713
|
-
/**
|
|
714
|
-
* Isolates a Snapchat username from a URL, ignoring the `/add/` base path segment.
|
|
715
|
-
*/ var SNAPCHAT_WEBSITE_LINK_ISOLATE_PROFILE_ID = util.isolateWebsitePathFunction({
|
|
716
|
-
ignoredBasePath: 'add',
|
|
717
|
-
isolatePathComponents: 0,
|
|
718
|
-
removeTrailingSlash: true,
|
|
719
|
-
removeQueryParameters: true
|
|
720
|
-
});
|
|
721
|
-
/**
|
|
722
|
-
* Converts a Snapchat profile ID or URL into a {@link WebsiteLink}.
|
|
723
|
-
*
|
|
724
|
-
* Handles Snapchat's `/add/{username}` URL pattern.
|
|
725
|
-
*
|
|
726
|
-
* @param input - A Snapchat username or full profile URL.
|
|
727
|
-
* @returns A WebsiteLink with the isolated username as data.
|
|
728
|
-
*/ function snapchatProfileUrlToWebsiteLink(input) {
|
|
729
|
-
return {
|
|
730
|
-
t: SNAPCHAT_WEBSITE_LINK_TYPE,
|
|
731
|
-
d: usernameFromUsernameOrWebsiteWithOneOffBaseUrlUsername(input, SNAPCHAT_WEBSITE_LINK_ISOLATE_PROFILE_ID)
|
|
732
|
-
};
|
|
733
|
-
}
|
|
734
|
-
/**
|
|
735
|
-
* Constructs a full Snapchat profile URL from a profile ID.
|
|
736
|
-
*
|
|
737
|
-
* @param profileId - The Snapchat username.
|
|
738
|
-
* @returns The full profile URL with `/add/` path.
|
|
739
|
-
*/ function snapchatProfileUrl(profileId) {
|
|
740
|
-
return "".concat(SNAPCHAT_BASE_URL, "/add/").concat(profileId);
|
|
741
|
-
}
|
|
742
|
-
// MARK: YouTube
|
|
743
|
-
/**
|
|
744
|
-
* Base URL for YouTube channels.
|
|
745
|
-
*/ var YOUTUBE_BASE_URL = "https://youtube.com";
|
|
746
|
-
/**
|
|
747
|
-
* {@link WebsiteLinkType} code for YouTube.
|
|
748
|
-
*/ var YOUTUBE_WEBSITE_LINK_TYPE = 'yt';
|
|
749
|
-
/**
|
|
750
|
-
* Isolates a YouTube channel name from a URL, ignoring the `/c/` base path segment.
|
|
751
|
-
*/ var YOUTUBE_WEBSITE_LINK_ISOLATE_PROFILE_ID = util.isolateWebsitePathFunction({
|
|
752
|
-
ignoredBasePath: 'c',
|
|
753
|
-
isolatePathComponents: 0,
|
|
754
|
-
removeTrailingSlash: true,
|
|
755
|
-
removeQueryParameters: true
|
|
756
|
-
});
|
|
757
|
-
/**
|
|
758
|
-
* Converts a YouTube channel ID or URL into a {@link WebsiteLink}.
|
|
759
|
-
*
|
|
760
|
-
* Handles YouTube's `/c/{channel}` URL pattern.
|
|
761
|
-
*
|
|
762
|
-
* @param input - A YouTube channel name or full channel URL.
|
|
763
|
-
* @returns A WebsiteLink with the isolated channel name as data.
|
|
764
|
-
*/ function youtubeProfileUrlToWebsiteLink(input) {
|
|
765
|
-
return {
|
|
766
|
-
t: YOUTUBE_WEBSITE_LINK_TYPE,
|
|
767
|
-
d: usernameFromUsernameOrWebsiteWithOneOffBaseUrlUsername(input, YOUTUBE_WEBSITE_LINK_ISOLATE_PROFILE_ID)
|
|
768
|
-
};
|
|
769
|
-
}
|
|
770
|
-
/**
|
|
771
|
-
* Constructs a full YouTube channel URL from a profile ID.
|
|
772
|
-
*
|
|
773
|
-
* @param profileId - The YouTube channel name.
|
|
774
|
-
* @returns The full channel URL with `/c/` path.
|
|
775
|
-
*/ function youtubeProfileUrl(profileId) {
|
|
776
|
-
return "".concat(YOUTUBE_BASE_URL, "/c/").concat(profileId);
|
|
777
|
-
}
|
|
778
|
-
// MARK: PayPal
|
|
779
|
-
/**
|
|
780
|
-
* Base URL for PayPal.me profiles.
|
|
781
|
-
*/ var PAYPAL_BASE_URL = "https://paypal.me";
|
|
782
|
-
/**
|
|
783
|
-
* {@link WebsiteLinkType} code for PayPal.
|
|
784
|
-
*/ var PAYPAL_WEBSITE_LINK_TYPE = 'pp';
|
|
785
|
-
/**
|
|
786
|
-
* Converts a PayPal profile ID or URL into a {@link WebsiteLink}.
|
|
787
|
-
*
|
|
788
|
-
* @param input - A PayPal username or full PayPal.me URL.
|
|
789
|
-
* @returns A WebsiteLink with the isolated username as data.
|
|
790
|
-
*/ function paypalProfileUrlToWebsiteLink(input) {
|
|
791
|
-
return {
|
|
792
|
-
t: PAYPAL_WEBSITE_LINK_TYPE,
|
|
793
|
-
d: usernameFromUsernameOrWebsiteWithBaseUrlUsername(input)
|
|
794
|
-
};
|
|
795
|
-
}
|
|
796
|
-
/**
|
|
797
|
-
* Constructs a full PayPal.me profile URL from a profile ID.
|
|
798
|
-
*
|
|
799
|
-
* @param profileId - The PayPal username.
|
|
800
|
-
* @returns The full PayPal.me URL.
|
|
801
|
-
*/ function paypalProfileUrl(profileId) {
|
|
802
|
-
return "".concat(PAYPAL_BASE_URL, "/").concat(profileId);
|
|
803
|
-
}
|
|
804
|
-
// MARK: Cashapp
|
|
805
|
-
/**
|
|
806
|
-
* Base URL for Cash App profiles.
|
|
807
|
-
*/ var CASHAPP_BASE_URL = "https://cash.app";
|
|
808
|
-
/**
|
|
809
|
-
* Cash App usernames are prefixed with "$" (cashtag).
|
|
810
|
-
*/ var CASHAPP_USERNAME_PREFIX = '$';
|
|
811
|
-
/**
|
|
812
|
-
* {@link WebsiteLinkType} code for Cash App.
|
|
813
|
-
*/ var CASHAPP_WEBSITE_LINK_TYPE = 'ca';
|
|
814
|
-
/**
|
|
815
|
-
* Converts a Cash App profile ID or URL into a {@link WebsiteLink}.
|
|
816
|
-
*
|
|
817
|
-
* Automatically prepends the "$" prefix if not already present.
|
|
818
|
-
*
|
|
819
|
-
* @param input - A Cash App username (with or without "$") or full profile URL.
|
|
820
|
-
* @returns A WebsiteLink with the "$"-prefixed username as data.
|
|
821
|
-
*/ function cashappProfileUrlToWebsiteLink(input) {
|
|
822
|
-
return {
|
|
823
|
-
t: CASHAPP_WEBSITE_LINK_TYPE,
|
|
824
|
-
d: usernameFromUsernameOrWebsiteWithBaseUrlUsername(input, CASHAPP_USERNAME_PREFIX)
|
|
825
|
-
};
|
|
826
|
-
}
|
|
827
|
-
/**
|
|
828
|
-
* Constructs a full Cash App profile URL from a profile ID.
|
|
829
|
-
*
|
|
830
|
-
* @param profileId - The Cash App username (without "$" prefix)
|
|
831
|
-
* @returns The full Cash App URL with "$" prefix.
|
|
832
|
-
*/ function cashappProfileUrl(profileId) {
|
|
833
|
-
return "".concat(CASHAPP_BASE_URL, "/$").concat(profileId);
|
|
834
|
-
}
|
|
835
|
-
// MARK: Venmo
|
|
836
|
-
/**
|
|
837
|
-
* Base URL for Venmo profiles.
|
|
838
|
-
*/ var VENMO_BASE_URL = "https://account.venmo.com";
|
|
839
|
-
/**
|
|
840
|
-
* {@link WebsiteLinkType} code for Venmo.
|
|
841
|
-
*/ var VENMO_WEBSITE_LINK_TYPE = 'vn';
|
|
842
|
-
/**
|
|
843
|
-
* Isolates a Venmo username from a URL, ignoring the `/u/` base path segment.
|
|
844
|
-
*/ var VENMO_WEBSITE_LINK_ISOLATE_PROFILE_ID = util.isolateWebsitePathFunction({
|
|
845
|
-
ignoredBasePath: 'u',
|
|
846
|
-
isolatePathComponents: 0,
|
|
847
|
-
removeTrailingSlash: true,
|
|
848
|
-
removeQueryParameters: true
|
|
849
|
-
});
|
|
850
|
-
/**
|
|
851
|
-
* Converts a Venmo profile ID or URL into a {@link WebsiteLink}.
|
|
852
|
-
*
|
|
853
|
-
* Handles Venmo's `/u/{username}` URL pattern.
|
|
854
|
-
*
|
|
855
|
-
* @param input - A Venmo username or full profile URL.
|
|
856
|
-
* @returns A WebsiteLink with the isolated username as data.
|
|
857
|
-
*/ function venmoProfileUrlToWebsiteLink(input) {
|
|
858
|
-
return {
|
|
859
|
-
t: VENMO_WEBSITE_LINK_TYPE,
|
|
860
|
-
d: usernameFromUsernameOrWebsiteWithOneOffBaseUrlUsername(input, VENMO_WEBSITE_LINK_ISOLATE_PROFILE_ID)
|
|
861
|
-
};
|
|
862
|
-
}
|
|
863
|
-
/**
|
|
864
|
-
* Constructs a full Venmo profile URL from a profile ID.
|
|
865
|
-
*
|
|
866
|
-
* @param profileId - The Venmo username.
|
|
867
|
-
* @returns The full profile URL with `/u/` path.
|
|
868
|
-
*/ function venmoProfileUrl(profileId) {
|
|
869
|
-
return "".concat(VENMO_BASE_URL, "/u/").concat(profileId);
|
|
870
|
-
}
|
|
871
|
-
// MARK: Spotify
|
|
872
|
-
/**
|
|
873
|
-
* Base URL for Spotify profiles.
|
|
874
|
-
*/ var SPOTIFY_BASE_URL = "https://open.spotify.com/";
|
|
875
|
-
/**
|
|
876
|
-
* {@link WebsiteLinkType} code for Spotify.
|
|
877
|
-
*/ var SPOTIFY_WEBSITE_LINK_TYPE = 'sp';
|
|
878
|
-
/**
|
|
879
|
-
* Isolates a Spotify username from a URL, ignoring the `/user/` base path segment.
|
|
880
|
-
*/ var SPOTIFY_WEBSITE_LINK_ISOLATE_PROFILE_ID = util.isolateWebsitePathFunction({
|
|
881
|
-
ignoredBasePath: 'user',
|
|
882
|
-
isolatePathComponents: 0,
|
|
883
|
-
removeTrailingSlash: true,
|
|
884
|
-
removeQueryParameters: true
|
|
885
|
-
});
|
|
886
|
-
/**
|
|
887
|
-
* Converts a Spotify profile ID or URL into a {@link WebsiteLink}.
|
|
888
|
-
*
|
|
889
|
-
* Handles Spotify's `/user/{username}` URL pattern.
|
|
890
|
-
*
|
|
891
|
-
* @param input - A Spotify username or full profile URL.
|
|
892
|
-
* @returns A WebsiteLink with the isolated username as data.
|
|
893
|
-
*/ function spotifyProfileUrlToWebsiteLink(input) {
|
|
894
|
-
return {
|
|
895
|
-
t: SPOTIFY_WEBSITE_LINK_TYPE,
|
|
896
|
-
d: usernameFromUsernameOrWebsiteWithOneOffBaseUrlUsername(input, SPOTIFY_WEBSITE_LINK_ISOLATE_PROFILE_ID)
|
|
897
|
-
};
|
|
898
|
-
}
|
|
899
|
-
/**
|
|
900
|
-
* Constructs a full Spotify profile URL from a profile ID.
|
|
901
|
-
*
|
|
902
|
-
* @param profileId - The Spotify username.
|
|
903
|
-
* @returns The full profile URL with `/user/` path.
|
|
904
|
-
*/ function spotifyProfileUrl(profileId) {
|
|
905
|
-
return "".concat(SPOTIFY_BASE_URL, "/user/").concat(profileId);
|
|
906
|
-
}
|
|
907
|
-
|
|
908
|
-
function _array_like_to_array$1(arr, len) {
|
|
909
|
-
if (len == null || len > arr.length) len = arr.length;
|
|
910
|
-
for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
|
|
911
|
-
return arr2;
|
|
912
|
-
}
|
|
913
|
-
function _array_with_holes$1(arr) {
|
|
914
|
-
if (Array.isArray(arr)) return arr;
|
|
915
|
-
}
|
|
916
|
-
function _class_call_check$2(instance, Constructor) {
|
|
917
|
-
if (!(instance instanceof Constructor)) {
|
|
918
|
-
throw new TypeError("Cannot call a class as a function");
|
|
919
|
-
}
|
|
920
|
-
}
|
|
921
|
-
function _defineProperties$1(target, props) {
|
|
922
|
-
for(var i = 0; i < props.length; i++){
|
|
923
|
-
var descriptor = props[i];
|
|
924
|
-
descriptor.enumerable = descriptor.enumerable || false;
|
|
925
|
-
descriptor.configurable = true;
|
|
926
|
-
if ("value" in descriptor) descriptor.writable = true;
|
|
927
|
-
Object.defineProperty(target, descriptor.key, descriptor);
|
|
928
|
-
}
|
|
929
|
-
}
|
|
930
|
-
function _create_class$1(Constructor, protoProps, staticProps) {
|
|
931
|
-
if (protoProps) _defineProperties$1(Constructor.prototype, protoProps);
|
|
932
|
-
return Constructor;
|
|
933
|
-
}
|
|
934
|
-
function _define_property$3(obj, key, value) {
|
|
935
|
-
if (key in obj) {
|
|
936
|
-
Object.defineProperty(obj, key, {
|
|
937
|
-
value: value,
|
|
938
|
-
enumerable: true,
|
|
939
|
-
configurable: true,
|
|
940
|
-
writable: true
|
|
941
|
-
});
|
|
942
|
-
} else {
|
|
943
|
-
obj[key] = value;
|
|
944
|
-
}
|
|
945
|
-
return obj;
|
|
946
|
-
}
|
|
947
|
-
function _iterable_to_array_limit$1(arr, i) {
|
|
948
|
-
var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"];
|
|
949
|
-
if (_i == null) return;
|
|
950
|
-
var _arr = [];
|
|
951
|
-
var _n = true;
|
|
952
|
-
var _d = false;
|
|
953
|
-
var _s, _e;
|
|
954
|
-
try {
|
|
955
|
-
for(_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true){
|
|
956
|
-
_arr.push(_s.value);
|
|
957
|
-
if (i && _arr.length === i) break;
|
|
958
|
-
}
|
|
959
|
-
} catch (err) {
|
|
960
|
-
_d = true;
|
|
961
|
-
_e = err;
|
|
962
|
-
} finally{
|
|
963
|
-
try {
|
|
964
|
-
if (!_n && _i["return"] != null) _i["return"]();
|
|
965
|
-
} finally{
|
|
966
|
-
if (_d) throw _e;
|
|
967
|
-
}
|
|
968
|
-
}
|
|
969
|
-
return _arr;
|
|
970
|
-
}
|
|
971
|
-
function _non_iterable_rest$1() {
|
|
972
|
-
throw new TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
973
|
-
}
|
|
974
|
-
function _sliced_to_array$1(arr, i) {
|
|
975
|
-
return _array_with_holes$1(arr) || _iterable_to_array_limit$1(arr, i) || _unsupported_iterable_to_array$1(arr, i) || _non_iterable_rest$1();
|
|
976
|
-
}
|
|
977
|
-
function _unsupported_iterable_to_array$1(o, minLen) {
|
|
978
|
-
if (!o) return;
|
|
979
|
-
if (typeof o === "string") return _array_like_to_array$1(o, minLen);
|
|
980
|
-
var n = Object.prototype.toString.call(o).slice(8, -1);
|
|
981
|
-
if (n === "Object" && o.constructor) n = o.constructor.name;
|
|
982
|
-
if (n === "Map" || n === "Set") return Array.from(n);
|
|
983
|
-
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array$1(o, minLen);
|
|
984
|
-
}
|
|
985
|
-
var GRANTED_SYS_ADMIN_ROLE_KEY = 'sysadmin';
|
|
986
|
-
var GRANTED_OWNER_ROLE_KEY = 'owner';
|
|
987
|
-
var GRANTED_ADMIN_ROLE_KEY = 'admin';
|
|
988
|
-
/**
|
|
989
|
-
* Checks whether the given role represents an admin-level permission (either "admin" or "owner").
|
|
990
|
-
*
|
|
991
|
-
* @param role - The role to check.
|
|
992
|
-
* @returns True if the role is an admin or owner role.
|
|
993
|
-
*
|
|
994
|
-
* @example
|
|
995
|
-
* ```typescript
|
|
996
|
-
* isGrantedAdminLevelRole('admin'); // true
|
|
997
|
-
* isGrantedAdminLevelRole('owner'); // true
|
|
998
|
-
* isGrantedAdminLevelRole('read'); // false
|
|
999
|
-
* ```
|
|
1000
|
-
*/ function isGrantedAdminLevelRole(role) {
|
|
1001
|
-
return role === GRANTED_ADMIN_ROLE_KEY || role === GRANTED_OWNER_ROLE_KEY;
|
|
1002
|
-
}
|
|
1003
|
-
var GRANTED_READ_ROLE_KEY = 'read';
|
|
1004
|
-
var GRANTED_UPDATE_ROLE_KEY = 'update';
|
|
1005
|
-
var GRANTED_DELETE_ROLE_KEY = 'delete';
|
|
1006
|
-
var FULL_ACCESS_ROLE_KEY = '__FULL__';
|
|
1007
|
-
var NO_ACCESS_ROLE_KEY = '__EMPTY__';
|
|
1008
|
-
/**
|
|
1009
|
-
* Creates a {@link GrantedRoleMap} that explicitly denies all access.
|
|
1010
|
-
*
|
|
1011
|
-
* @returns A role map with only the no-access marker set.
|
|
1012
|
-
*
|
|
1013
|
-
* @example
|
|
1014
|
-
* ```typescript
|
|
1015
|
-
* const map = noAccessRoleMap();
|
|
1016
|
-
* isNoAccessRoleMap(map); // true
|
|
1017
|
-
* ```
|
|
1018
|
-
*/ function noAccessRoleMap() {
|
|
1019
|
-
return _define_property$3({}, NO_ACCESS_ROLE_KEY, true);
|
|
1020
|
-
}
|
|
1021
|
-
/**
|
|
1022
|
-
* Type guard that checks whether a role map is a no-access map.
|
|
1023
|
-
*
|
|
1024
|
-
* @param input - The role map to check.
|
|
1025
|
-
* @returns True if the map has the no-access marker.
|
|
1026
|
-
*/ function isNoAccessRoleMap(input) {
|
|
1027
|
-
return input[NO_ACCESS_ROLE_KEY] === true;
|
|
1028
|
-
}
|
|
1029
|
-
/**
|
|
1030
|
-
* Creates a {@link GrantedRoleMap} that grants full access to all roles.
|
|
1031
|
-
*
|
|
1032
|
-
* @returns A role map with the full-access marker set.
|
|
1033
|
-
*
|
|
1034
|
-
* @example
|
|
1035
|
-
* ```typescript
|
|
1036
|
-
* const map = fullAccessRoleMap();
|
|
1037
|
-
* isFullAccessRoleMap(map); // true
|
|
1038
|
-
* ```
|
|
1039
|
-
*/ function fullAccessRoleMap() {
|
|
1040
|
-
return _define_property$3({}, FULL_ACCESS_ROLE_KEY, true);
|
|
1041
|
-
}
|
|
1042
|
-
/**
|
|
1043
|
-
* Type guard that checks whether a role map is a full-access map.
|
|
1044
|
-
*
|
|
1045
|
-
* @param input - The role map to check.
|
|
1046
|
-
* @returns True if the map has the full-access marker.
|
|
1047
|
-
*/ function isFullAccessRoleMap(input) {
|
|
1048
|
-
return input[FULL_ACCESS_ROLE_KEY] === true;
|
|
1049
|
-
}
|
|
1050
|
-
/**
|
|
1051
|
-
* Creates a {@link GrantedRoleMapReader} for querying granted roles from a role map.
|
|
1052
|
-
*
|
|
1053
|
-
* The reader handles full-access and no-access maps as special cases, and provides methods
|
|
1054
|
-
* for checking individual roles or sets of roles.
|
|
1055
|
-
*
|
|
1056
|
-
* @param map - The granted role map to read from.
|
|
1057
|
-
* @returns A reader instance for querying the map.
|
|
1058
|
-
*
|
|
1059
|
-
* @example
|
|
1060
|
-
* ```typescript
|
|
1061
|
-
* const roleMap: GrantedRoleMap = { read: true, first: true };
|
|
1062
|
-
* const reader = grantedRoleMapReader(roleMap);
|
|
1063
|
-
*
|
|
1064
|
-
* reader.hasRole('read'); // true
|
|
1065
|
-
* reader.hasRole('delete'); // false
|
|
1066
|
-
* reader.containsRoles('any', ['read']); // true
|
|
1067
|
-
* reader.containsRoles('all', ['read', 'delete']); // false
|
|
1068
|
-
* ```
|
|
1069
|
-
*/ function grantedRoleMapReader(map) {
|
|
1070
|
-
return new GrantedRoleMapReaderInstance(map);
|
|
1071
|
-
}
|
|
1072
|
-
var GrantedRoleMapReaderInstance = /*#__PURE__*/ function() {
|
|
1073
|
-
function GrantedRoleMapReaderInstance(map) {
|
|
1074
|
-
_class_call_check$2(this, GrantedRoleMapReaderInstance);
|
|
1075
|
-
_define_property$3(this, "_map", void 0);
|
|
1076
|
-
this._map = map;
|
|
1077
|
-
}
|
|
1078
|
-
_create_class$1(GrantedRoleMapReaderInstance, [
|
|
1079
|
-
{
|
|
1080
|
-
key: "hasNoAccess",
|
|
1081
|
-
value: function hasNoAccess() {
|
|
1082
|
-
return this._map[NO_ACCESS_ROLE_KEY];
|
|
1083
|
-
}
|
|
1084
|
-
},
|
|
1085
|
-
{
|
|
1086
|
-
key: "truthMap",
|
|
1087
|
-
value: function truthMap(input) {
|
|
1088
|
-
var _this = this;
|
|
1089
|
-
var result = {};
|
|
1090
|
-
util.forEachKeyValue(input, {
|
|
1091
|
-
forEach: function forEach(param) {
|
|
1092
|
-
var _param = _sliced_to_array$1(param, 2), role = _param[0], value = _param[1];
|
|
1093
|
-
if (_this.hasRole(role)) {
|
|
1094
|
-
result[role] = value;
|
|
1095
|
-
}
|
|
1096
|
-
}
|
|
1097
|
-
});
|
|
1098
|
-
return result;
|
|
1099
|
-
}
|
|
1100
|
-
},
|
|
1101
|
-
{
|
|
1102
|
-
key: "hasRole",
|
|
1103
|
-
value: function hasRole(role) {
|
|
1104
|
-
return this.hasRoles('any', role);
|
|
1105
|
-
}
|
|
1106
|
-
},
|
|
1107
|
-
{
|
|
1108
|
-
key: "hasRoles",
|
|
1109
|
-
value: function hasRoles(setIncludes, inputRoles) {
|
|
1110
|
-
return this._map[FULL_ACCESS_ROLE_KEY] ? true : this.containsRoles(setIncludes, inputRoles);
|
|
1111
|
-
}
|
|
1112
|
-
},
|
|
1113
|
-
{
|
|
1114
|
-
key: "containsRoles",
|
|
1115
|
-
value: function containsRoles(setIncludes, inputRoles) {
|
|
1116
|
-
var roles = util.iterableToArray(inputRoles);
|
|
1117
|
-
return setIncludes === 'any' ? this.containsAnyRole(roles) : this.containsEachRole(roles);
|
|
1118
|
-
}
|
|
1119
|
-
},
|
|
1120
|
-
{
|
|
1121
|
-
key: "containsAnyRole",
|
|
1122
|
-
value: function containsAnyRole(roles) {
|
|
1123
|
-
var result = false;
|
|
1124
|
-
var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
|
|
1125
|
-
try {
|
|
1126
|
-
for(var _iterator = roles[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
|
|
1127
|
-
var role = _step.value;
|
|
1128
|
-
if (this._map[role]) {
|
|
1129
|
-
result = true;
|
|
1130
|
-
break;
|
|
1131
|
-
}
|
|
1132
|
-
}
|
|
1133
|
-
} catch (err) {
|
|
1134
|
-
_didIteratorError = true;
|
|
1135
|
-
_iteratorError = err;
|
|
1136
|
-
} finally{
|
|
1137
|
-
try {
|
|
1138
|
-
if (!_iteratorNormalCompletion && _iterator.return != null) {
|
|
1139
|
-
_iterator.return();
|
|
1140
|
-
}
|
|
1141
|
-
} finally{
|
|
1142
|
-
if (_didIteratorError) {
|
|
1143
|
-
throw _iteratorError;
|
|
1144
|
-
}
|
|
1145
|
-
}
|
|
1146
|
-
}
|
|
1147
|
-
return result;
|
|
1148
|
-
}
|
|
1149
|
-
},
|
|
1150
|
-
{
|
|
1151
|
-
key: "containsEachRole",
|
|
1152
|
-
value: function containsEachRole(roles) {
|
|
1153
|
-
var result = true;
|
|
1154
|
-
var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
|
|
1155
|
-
try {
|
|
1156
|
-
for(var _iterator = roles[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
|
|
1157
|
-
var role = _step.value;
|
|
1158
|
-
if (!this._map[role]) {
|
|
1159
|
-
result = false;
|
|
1160
|
-
break;
|
|
1161
|
-
}
|
|
1162
|
-
}
|
|
1163
|
-
} catch (err) {
|
|
1164
|
-
_didIteratorError = true;
|
|
1165
|
-
_iteratorError = err;
|
|
1166
|
-
} finally{
|
|
1167
|
-
try {
|
|
1168
|
-
if (!_iteratorNormalCompletion && _iterator.return != null) {
|
|
1169
|
-
_iterator.return();
|
|
1170
|
-
}
|
|
1171
|
-
} finally{
|
|
1172
|
-
if (_didIteratorError) {
|
|
1173
|
-
throw _iteratorError;
|
|
1174
|
-
}
|
|
1175
|
-
}
|
|
1176
|
-
}
|
|
1177
|
-
return result;
|
|
1178
|
-
}
|
|
1179
|
-
}
|
|
1180
|
-
]);
|
|
1181
|
-
return GrantedRoleMapReaderInstance;
|
|
1182
|
-
}();
|
|
1183
|
-
/**
|
|
1184
|
-
* Converts an array of role strings into a {@link GrantedRoleKeysMap} where each role is mapped to the given boolean value.
|
|
1185
|
-
*
|
|
1186
|
-
* @param roles - Role keys to include in the resulting map.
|
|
1187
|
-
* @param value - Truthiness to assign to every role entry (defaults to true).
|
|
1188
|
-
* @returns Map keyed by role with the supplied truthiness for each entry.
|
|
1189
|
-
*
|
|
1190
|
-
* @example
|
|
1191
|
-
* ```typescript
|
|
1192
|
-
* const map = grantedRoleKeysMapFromArray(['read', 'update']);
|
|
1193
|
-
* // { read: true, update: true }
|
|
1194
|
-
* ```
|
|
1195
|
-
*/ function grantedRoleKeysMapFromArray(roles) {
|
|
1196
|
-
var value = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : true;
|
|
1197
|
-
return util.arrayToObject(roles, function(x) {
|
|
1198
|
-
return x;
|
|
1199
|
-
}, function() {
|
|
1200
|
-
return value;
|
|
1201
|
-
});
|
|
1202
|
-
}
|
|
1203
|
-
|
|
1204
|
-
/**
|
|
1205
|
-
* Creates a {@link ContextGrantedModelRoles} with a no-access role map, indicating the context has no permissions.
|
|
1206
|
-
*
|
|
1207
|
-
* @param context - The context that was evaluated.
|
|
1208
|
-
* @param data - Optional model data, if it was loaded.
|
|
1209
|
-
* @returns A ContextGrantedModelRoles with no access.
|
|
1210
|
-
*
|
|
1211
|
-
* @example
|
|
1212
|
-
* ```typescript
|
|
1213
|
-
* const result = noAccessContextGrantedModelRoles(userContext);
|
|
1214
|
-
* // result.roleMap contains the no-access marker
|
|
1215
|
-
* ```
|
|
1216
|
-
*/ function noAccessContextGrantedModelRoles(context, data) {
|
|
1217
|
-
return contextGrantedModelRoles(context, data, noAccessRoleMap());
|
|
1218
|
-
}
|
|
1219
|
-
/**
|
|
1220
|
-
* Creates a {@link ContextGrantedModelRoles} with a full-access role map, granting all permissions.
|
|
1221
|
-
*
|
|
1222
|
-
* @param context - The context that was evaluated.
|
|
1223
|
-
* @param data - Optional model data.
|
|
1224
|
-
* @returns A ContextGrantedModelRoles with full access.
|
|
1225
|
-
*
|
|
1226
|
-
* @example
|
|
1227
|
-
* ```typescript
|
|
1228
|
-
* const result = fullAccessGrantedModelRoles(adminContext, modelData);
|
|
1229
|
-
* // result.roleMap contains the full-access marker
|
|
1230
|
-
* ```
|
|
1231
|
-
*/ function fullAccessGrantedModelRoles(context, data) {
|
|
1232
|
-
return contextGrantedModelRoles(context, data, fullAccessRoleMap());
|
|
1233
|
-
}
|
|
1234
|
-
/**
|
|
1235
|
-
* Creates a {@link ContextGrantedModelRoles} with the given role map, data, and context.
|
|
1236
|
-
*
|
|
1237
|
-
* @param context - The context that was evaluated.
|
|
1238
|
-
* @param data - The model data, if loaded.
|
|
1239
|
-
* @param roles - The granted role map.
|
|
1240
|
-
* @returns A ContextGrantedModelRoles combining all inputs.
|
|
1241
|
-
*/ function contextGrantedModelRoles(context, data, roles) {
|
|
1242
|
-
return {
|
|
1243
|
-
data: data,
|
|
1244
|
-
context: context,
|
|
1245
|
-
roleMap: roles
|
|
1246
|
-
};
|
|
1247
|
-
}
|
|
1248
|
-
|
|
1249
|
-
function asyncGeneratorStep$3(gen, resolve, reject, _next, _throw, key, arg) {
|
|
1250
|
-
try {
|
|
1251
|
-
var info = gen[key](arg);
|
|
1252
|
-
var value = info.value;
|
|
1253
|
-
} catch (error) {
|
|
1254
|
-
reject(error);
|
|
1255
|
-
return;
|
|
1256
|
-
}
|
|
1257
|
-
if (info.done) {
|
|
1258
|
-
resolve(value);
|
|
1259
|
-
} else {
|
|
1260
|
-
Promise.resolve(value).then(_next, _throw);
|
|
1261
|
-
}
|
|
1262
|
-
}
|
|
1263
|
-
function _async_to_generator$3(fn) {
|
|
1264
|
-
return function() {
|
|
1265
|
-
var self = this, args = arguments;
|
|
1266
|
-
return new Promise(function(resolve, reject) {
|
|
1267
|
-
var gen = fn.apply(self, args);
|
|
1268
|
-
function _next(value) {
|
|
1269
|
-
asyncGeneratorStep$3(gen, resolve, reject, _next, _throw, "next", value);
|
|
1270
|
-
}
|
|
1271
|
-
function _throw(err) {
|
|
1272
|
-
asyncGeneratorStep$3(gen, resolve, reject, _next, _throw, "throw", err);
|
|
1273
|
-
}
|
|
1274
|
-
_next(undefined);
|
|
1275
|
-
});
|
|
1276
|
-
};
|
|
1277
|
-
}
|
|
1278
|
-
function _class_call_check$1(instance, Constructor) {
|
|
1279
|
-
if (!(instance instanceof Constructor)) {
|
|
1280
|
-
throw new TypeError("Cannot call a class as a function");
|
|
1281
|
-
}
|
|
1282
|
-
}
|
|
1283
|
-
function _defineProperties(target, props) {
|
|
1284
|
-
for(var i = 0; i < props.length; i++){
|
|
1285
|
-
var descriptor = props[i];
|
|
1286
|
-
descriptor.enumerable = descriptor.enumerable || false;
|
|
1287
|
-
descriptor.configurable = true;
|
|
1288
|
-
if ("value" in descriptor) descriptor.writable = true;
|
|
1289
|
-
Object.defineProperty(target, descriptor.key, descriptor);
|
|
1290
|
-
}
|
|
1291
|
-
}
|
|
1292
|
-
function _create_class(Constructor, protoProps, staticProps) {
|
|
1293
|
-
if (protoProps) _defineProperties(Constructor.prototype, protoProps);
|
|
1294
|
-
return Constructor;
|
|
1295
|
-
}
|
|
1296
|
-
function _define_property$2(obj, key, value) {
|
|
1297
|
-
if (key in obj) {
|
|
1298
|
-
Object.defineProperty(obj, key, {
|
|
1299
|
-
value: value,
|
|
1300
|
-
enumerable: true,
|
|
1301
|
-
configurable: true,
|
|
1302
|
-
writable: true
|
|
1303
|
-
});
|
|
1304
|
-
} else {
|
|
1305
|
-
obj[key] = value;
|
|
1306
|
-
}
|
|
1307
|
-
return obj;
|
|
1308
|
-
}
|
|
1309
|
-
function _ts_generator$3(thisArg, body) {
|
|
1310
|
-
var f, y, t, _ = {
|
|
1311
|
-
label: 0,
|
|
1312
|
-
sent: function() {
|
|
1313
|
-
if (t[0] & 1) throw t[1];
|
|
1314
|
-
return t[1];
|
|
1315
|
-
},
|
|
1316
|
-
trys: [],
|
|
1317
|
-
ops: []
|
|
1318
|
-
}, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype), d = Object.defineProperty;
|
|
1319
|
-
return d(g, "next", {
|
|
1320
|
-
value: verb(0)
|
|
1321
|
-
}), d(g, "throw", {
|
|
1322
|
-
value: verb(1)
|
|
1323
|
-
}), d(g, "return", {
|
|
1324
|
-
value: verb(2)
|
|
1325
|
-
}), typeof Symbol === "function" && d(g, Symbol.iterator, {
|
|
1326
|
-
value: function() {
|
|
1327
|
-
return this;
|
|
1328
|
-
}
|
|
1329
|
-
}), g;
|
|
1330
|
-
function verb(n) {
|
|
1331
|
-
return function(v) {
|
|
1332
|
-
return step([
|
|
1333
|
-
n,
|
|
1334
|
-
v
|
|
1335
|
-
]);
|
|
1336
|
-
};
|
|
1337
|
-
}
|
|
1338
|
-
function step(op) {
|
|
1339
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
1340
|
-
while(g && (g = 0, op[0] && (_ = 0)), _)try {
|
|
1341
|
-
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
1342
|
-
if (y = 0, t) op = [
|
|
1343
|
-
op[0] & 2,
|
|
1344
|
-
t.value
|
|
1345
|
-
];
|
|
1346
|
-
switch(op[0]){
|
|
1347
|
-
case 0:
|
|
1348
|
-
case 1:
|
|
1349
|
-
t = op;
|
|
1350
|
-
break;
|
|
1351
|
-
case 4:
|
|
1352
|
-
_.label++;
|
|
1353
|
-
return {
|
|
1354
|
-
value: op[1],
|
|
1355
|
-
done: false
|
|
1356
|
-
};
|
|
1357
|
-
case 5:
|
|
1358
|
-
_.label++;
|
|
1359
|
-
y = op[1];
|
|
1360
|
-
op = [
|
|
1361
|
-
0
|
|
1362
|
-
];
|
|
1363
|
-
continue;
|
|
1364
|
-
case 7:
|
|
1365
|
-
op = _.ops.pop();
|
|
1366
|
-
_.trys.pop();
|
|
1367
|
-
continue;
|
|
1368
|
-
default:
|
|
1369
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
|
|
1370
|
-
_ = 0;
|
|
1371
|
-
continue;
|
|
1372
|
-
}
|
|
1373
|
-
if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) {
|
|
1374
|
-
_.label = op[1];
|
|
1375
|
-
break;
|
|
1376
|
-
}
|
|
1377
|
-
if (op[0] === 6 && _.label < t[1]) {
|
|
1378
|
-
_.label = t[1];
|
|
1379
|
-
t = op;
|
|
1380
|
-
break;
|
|
1381
|
-
}
|
|
1382
|
-
if (t && _.label < t[2]) {
|
|
1383
|
-
_.label = t[2];
|
|
1384
|
-
_.ops.push(op);
|
|
1385
|
-
break;
|
|
1386
|
-
}
|
|
1387
|
-
if (t[2]) _.ops.pop();
|
|
1388
|
-
_.trys.pop();
|
|
1389
|
-
continue;
|
|
1390
|
-
}
|
|
1391
|
-
op = body.call(thisArg, _);
|
|
1392
|
-
} catch (e) {
|
|
1393
|
-
op = [
|
|
1394
|
-
6,
|
|
1395
|
-
e
|
|
1396
|
-
];
|
|
1397
|
-
y = 0;
|
|
1398
|
-
} finally{
|
|
1399
|
-
f = t = 0;
|
|
1400
|
-
}
|
|
1401
|
-
if (op[0] & 5) throw op[1];
|
|
1402
|
-
return {
|
|
1403
|
-
value: op[0] ? op[1] : void 0,
|
|
1404
|
-
done: true
|
|
1405
|
-
};
|
|
1406
|
-
}
|
|
1407
|
-
}
|
|
1408
|
-
/**
|
|
1409
|
-
* Abstract ModelPermissionService implementation.
|
|
1410
|
-
*/ var AbstractModelPermissionService = /*#__PURE__*/ function() {
|
|
1411
|
-
function AbstractModelPermissionService(modelLoader) {
|
|
1412
|
-
_class_call_check$1(this, AbstractModelPermissionService);
|
|
1413
|
-
_define_property$2(this, "_modelLoader", void 0);
|
|
1414
|
-
this._modelLoader = modelLoader;
|
|
1415
|
-
}
|
|
1416
|
-
_create_class(AbstractModelPermissionService, [
|
|
1417
|
-
{
|
|
1418
|
-
key: "modelLoader",
|
|
1419
|
-
get: function get() {
|
|
1420
|
-
return this._modelLoader;
|
|
1421
|
-
}
|
|
1422
|
-
},
|
|
1423
|
-
{
|
|
1424
|
-
key: "roleMapForKeyContext",
|
|
1425
|
-
value: function roleMapForKeyContext(key, context) {
|
|
1426
|
-
return _async_to_generator$3(function() {
|
|
1427
|
-
var model, result;
|
|
1428
|
-
return _ts_generator$3(this, function(_state) {
|
|
1429
|
-
switch(_state.label){
|
|
1430
|
-
case 0:
|
|
1431
|
-
return [
|
|
1432
|
-
4,
|
|
1433
|
-
this.modelLoader.loadModelForKey(key, context)
|
|
1434
|
-
];
|
|
1435
|
-
case 1:
|
|
1436
|
-
model = _state.sent();
|
|
1437
|
-
if (!(model == null)) return [
|
|
1438
|
-
3,
|
|
1439
|
-
2
|
|
1440
|
-
];
|
|
1441
|
-
result = noAccessContextGrantedModelRoles(context);
|
|
1442
|
-
return [
|
|
1443
|
-
3,
|
|
1444
|
-
4
|
|
1445
|
-
];
|
|
1446
|
-
case 2:
|
|
1447
|
-
return [
|
|
1448
|
-
4,
|
|
1449
|
-
this.roleMapForModelContext(model, context)
|
|
1450
|
-
];
|
|
1451
|
-
case 3:
|
|
1452
|
-
result = _state.sent();
|
|
1453
|
-
_state.label = 4;
|
|
1454
|
-
case 4:
|
|
1455
|
-
return [
|
|
1456
|
-
2,
|
|
1457
|
-
result
|
|
1458
|
-
];
|
|
1459
|
-
}
|
|
1460
|
-
});
|
|
1461
|
-
}).call(this);
|
|
1462
|
-
}
|
|
1463
|
-
},
|
|
1464
|
-
{
|
|
1465
|
-
key: "roleMapForModelContext",
|
|
1466
|
-
value: function roleMapForModelContext(model, context) {
|
|
1467
|
-
return _async_to_generator$3(function() {
|
|
1468
|
-
var output, result;
|
|
1469
|
-
return _ts_generator$3(this, function(_state) {
|
|
1470
|
-
switch(_state.label){
|
|
1471
|
-
case 0:
|
|
1472
|
-
return [
|
|
1473
|
-
4,
|
|
1474
|
-
this.outputForModel(model, context)
|
|
1475
|
-
];
|
|
1476
|
-
case 1:
|
|
1477
|
-
output = _state.sent();
|
|
1478
|
-
if (!(output != null && this.isUsableOutputForRoles(output, context))) return [
|
|
1479
|
-
3,
|
|
1480
|
-
3
|
|
1481
|
-
];
|
|
1482
|
-
return [
|
|
1483
|
-
4,
|
|
1484
|
-
this.getRoleMapForOutput(output, context, model)
|
|
1485
|
-
];
|
|
1486
|
-
case 2:
|
|
1487
|
-
result = _state.sent();
|
|
1488
|
-
return [
|
|
1489
|
-
3,
|
|
1490
|
-
4
|
|
1491
|
-
];
|
|
1492
|
-
case 3:
|
|
1493
|
-
result = noAccessContextGrantedModelRoles(context, output);
|
|
1494
|
-
_state.label = 4;
|
|
1495
|
-
case 4:
|
|
1496
|
-
return [
|
|
1497
|
-
2,
|
|
1498
|
-
result
|
|
1499
|
-
];
|
|
1500
|
-
}
|
|
1501
|
-
});
|
|
1502
|
-
}).call(this);
|
|
1503
|
-
}
|
|
1504
|
-
},
|
|
1505
|
-
{
|
|
1506
|
-
key: "getRoleMapForOutput",
|
|
1507
|
-
value: function getRoleMapForOutput(output, context, model) {
|
|
1508
|
-
return _async_to_generator$3(function() {
|
|
1509
|
-
var roleMap;
|
|
1510
|
-
return _ts_generator$3(this, function(_state) {
|
|
1511
|
-
switch(_state.label){
|
|
1512
|
-
case 0:
|
|
1513
|
-
return [
|
|
1514
|
-
4,
|
|
1515
|
-
this.roleMapForModel(output, context, model)
|
|
1516
|
-
];
|
|
1517
|
-
case 1:
|
|
1518
|
-
roleMap = _state.sent();
|
|
1519
|
-
return [
|
|
1520
|
-
2,
|
|
1521
|
-
contextGrantedModelRoles(context, output, roleMap)
|
|
1522
|
-
];
|
|
1523
|
-
}
|
|
1524
|
-
});
|
|
1525
|
-
}).call(this);
|
|
1526
|
-
}
|
|
1527
|
-
},
|
|
1528
|
-
{
|
|
1529
|
-
key: "isUsableOutputForRoles",
|
|
1530
|
-
value: function isUsableOutputForRoles(_output, _context) {
|
|
1531
|
-
return true; // can override in parent functions to further filter roles.
|
|
1532
|
-
}
|
|
1533
|
-
}
|
|
1534
|
-
]);
|
|
1535
|
-
return AbstractModelPermissionService;
|
|
1536
|
-
}
|
|
1537
|
-
();
|
|
1538
|
-
|
|
1539
|
-
/**
|
|
1540
|
-
* Creates a factory that normalizes a {@link SyncEntityCommonTypeIdPairFactoryInput} into a full {@link SyncEntityCommonTypeIdPair}.
|
|
1541
|
-
*
|
|
1542
|
-
* If the input is a string, it is treated as a commonId and paired with the given commonType.
|
|
1543
|
-
* If the input is already a pair, it is returned as-is.
|
|
1544
|
-
*
|
|
1545
|
-
* @param commonType - The default common type to use when input is a plain string.
|
|
1546
|
-
* @returns A factory function that produces SyncEntityCommonTypeIdPair instances.
|
|
1547
|
-
*
|
|
1548
|
-
* @example
|
|
1549
|
-
* ```typescript
|
|
1550
|
-
* const factory = syncEntityCommonTypeIdPairFactory('user');
|
|
1551
|
-
* factory('abc123'); // { commonType: 'user', commonId: 'abc123' }
|
|
1552
|
-
* factory({ commonType: 'user', commonId: 'abc123' }); // passed through as-is
|
|
1553
|
-
* ```
|
|
1554
|
-
*
|
|
1555
|
-
* @__NO_SIDE_EFFECTS__
|
|
1556
|
-
*/ function syncEntityCommonTypeIdPairFactory(commonType) {
|
|
1557
|
-
return function(input) {
|
|
1558
|
-
var result;
|
|
1559
|
-
if (typeof input === 'string') {
|
|
1560
|
-
result = {
|
|
1561
|
-
commonType: commonType,
|
|
1562
|
-
commonId: input
|
|
1563
|
-
};
|
|
1564
|
-
} else {
|
|
1565
|
-
result = input;
|
|
1566
|
-
}
|
|
1567
|
-
return result;
|
|
1568
|
-
};
|
|
1569
|
-
}
|
|
1570
|
-
/**
|
|
1571
|
-
* Creates a {@link SyncEntityFactory} that produces {@link SyncEntity} instances from a common type/id pair.
|
|
1572
|
-
*
|
|
1573
|
-
* The factory attaches the configured source info and optionally transforms the commonId into an entity id
|
|
1574
|
-
* using the provided idFactory (defaults to identity).
|
|
1575
|
-
*
|
|
1576
|
-
* @param config - Source info and optional id factory.
|
|
1577
|
-
* @returns A factory that creates SyncEntity instances.
|
|
1578
|
-
*
|
|
1579
|
-
* @example
|
|
1580
|
-
* ```typescript
|
|
1581
|
-
* const factory = syncEntityFactory({
|
|
1582
|
-
* sourceInfo: { id: 'api', name: 'External API' }
|
|
1583
|
-
* });
|
|
1584
|
-
*
|
|
1585
|
-
* const entity = factory({ commonType: 'user', commonId: 'abc123' });
|
|
1586
|
-
* // entity.id === 'abc123', entity.sourceInfo.id === 'api'
|
|
1587
|
-
* ```
|
|
1588
|
-
*
|
|
1589
|
-
* @__NO_SIDE_EFFECTS__
|
|
1590
|
-
*/ function syncEntityFactory(config) {
|
|
1591
|
-
var inputIdFactory = config.idFactory, sourceInfo = config.sourceInfo;
|
|
1592
|
-
var idFactory = inputIdFactory !== null && inputIdFactory !== void 0 ? inputIdFactory : util.MAP_IDENTITY;
|
|
1593
|
-
return function(input) {
|
|
1594
|
-
var commonType = input.commonType, commonId = input.commonId;
|
|
1595
|
-
var id = idFactory(commonId);
|
|
1596
|
-
return {
|
|
1597
|
-
commonType: commonType,
|
|
1598
|
-
commonId: commonId,
|
|
1599
|
-
id: id,
|
|
1600
|
-
sourceInfo: sourceInfo
|
|
1601
|
-
};
|
|
1602
|
-
};
|
|
1603
|
-
}
|
|
1604
|
-
|
|
1605
|
-
function _assert_this_initialized(self) {
|
|
1606
|
-
if (self === void 0) {
|
|
1607
|
-
throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
|
|
1608
|
-
}
|
|
1609
|
-
return self;
|
|
1610
|
-
}
|
|
1611
|
-
function _call_super(_this, derived, args) {
|
|
1612
|
-
derived = _get_prototype_of(derived);
|
|
1613
|
-
return _possible_constructor_return(_this, _is_native_reflect_construct() ? Reflect.construct(derived, args || [], _get_prototype_of(_this).constructor) : derived.apply(_this, args));
|
|
1614
|
-
}
|
|
1615
|
-
function _class_call_check(instance, Constructor) {
|
|
1616
|
-
if (!(instance instanceof Constructor)) {
|
|
1617
|
-
throw new TypeError("Cannot call a class as a function");
|
|
1618
|
-
}
|
|
1619
|
-
}
|
|
1620
|
-
function _define_property$1(obj, key, value) {
|
|
1621
|
-
if (key in obj) {
|
|
1622
|
-
Object.defineProperty(obj, key, {
|
|
1623
|
-
value: value,
|
|
1624
|
-
enumerable: true,
|
|
1625
|
-
configurable: true,
|
|
1626
|
-
writable: true
|
|
1627
|
-
});
|
|
1628
|
-
} else {
|
|
1629
|
-
obj[key] = value;
|
|
1630
|
-
}
|
|
1631
|
-
return obj;
|
|
1632
|
-
}
|
|
1633
|
-
function _get_prototype_of(o) {
|
|
1634
|
-
_get_prototype_of = Object.setPrototypeOf ? Object.getPrototypeOf : function getPrototypeOf(o) {
|
|
1635
|
-
return o.__proto__ || Object.getPrototypeOf(o);
|
|
1636
|
-
};
|
|
1637
|
-
return _get_prototype_of(o);
|
|
1638
|
-
}
|
|
1639
|
-
function _inherits(subClass, superClass) {
|
|
1640
|
-
if (typeof superClass !== "function" && superClass !== null) {
|
|
1641
|
-
throw new TypeError("Super expression must either be null or a function");
|
|
1642
|
-
}
|
|
1643
|
-
subClass.prototype = Object.create(superClass && superClass.prototype, {
|
|
1644
|
-
constructor: {
|
|
1645
|
-
value: subClass,
|
|
1646
|
-
writable: true,
|
|
1647
|
-
configurable: true
|
|
1648
|
-
}
|
|
1649
|
-
});
|
|
1650
|
-
if (superClass) _set_prototype_of(subClass, superClass);
|
|
1651
|
-
}
|
|
1652
|
-
function _possible_constructor_return(self, call) {
|
|
1653
|
-
if (call && (_type_of(call) === "object" || typeof call === "function")) {
|
|
1654
|
-
return call;
|
|
1655
|
-
}
|
|
1656
|
-
return _assert_this_initialized(self);
|
|
1657
|
-
}
|
|
1658
|
-
function _set_prototype_of(o, p) {
|
|
1659
|
-
_set_prototype_of = Object.setPrototypeOf || function setPrototypeOf(o, p) {
|
|
1660
|
-
o.__proto__ = p;
|
|
1661
|
-
return o;
|
|
1662
|
-
};
|
|
1663
|
-
return _set_prototype_of(o, p);
|
|
1664
|
-
}
|
|
1665
|
-
function _type_of(obj) {
|
|
1666
|
-
"@swc/helpers - typeof";
|
|
1667
|
-
return obj && typeof Symbol !== "undefined" && obj.constructor === Symbol ? "symbol" : typeof obj;
|
|
1668
|
-
}
|
|
1669
|
-
function _is_native_reflect_construct() {
|
|
1670
|
-
try {
|
|
1671
|
-
var result = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function() {}));
|
|
1672
|
-
} catch (_) {}
|
|
1673
|
-
return (_is_native_reflect_construct = function() {
|
|
1674
|
-
return !!result;
|
|
1675
|
-
})();
|
|
1676
|
-
}
|
|
1677
|
-
/**
|
|
1678
|
-
* Error thrown when the common type is not known/registered.
|
|
1679
|
-
*/ var UnregisteredSyncEntityCommonTypeError = /*#__PURE__*/ function(BaseError) {
|
|
1680
|
-
_inherits(UnregisteredSyncEntityCommonTypeError, BaseError);
|
|
1681
|
-
function UnregisteredSyncEntityCommonTypeError(commonType) {
|
|
1682
|
-
_class_call_check(this, UnregisteredSyncEntityCommonTypeError);
|
|
1683
|
-
var _this;
|
|
1684
|
-
_this = _call_super(this, UnregisteredSyncEntityCommonTypeError, [
|
|
1685
|
-
'The common type "'.concat(commonType, '" is not registered.')
|
|
1686
|
-
]), _define_property$1(_this, "commonType", void 0);
|
|
1687
|
-
_this.commonType = commonType;
|
|
1688
|
-
return _this;
|
|
1689
|
-
}
|
|
1690
|
-
return UnregisteredSyncEntityCommonTypeError;
|
|
1691
|
-
}(makeError.BaseError);
|
|
1692
|
-
/**
|
|
1693
|
-
* Error thrown when no primary sync source is found for an entity.
|
|
1694
|
-
*/ var NoPrimarySyncSourceError = /*#__PURE__*/ function(BaseError) {
|
|
1695
|
-
_inherits(NoPrimarySyncSourceError, BaseError);
|
|
1696
|
-
function NoPrimarySyncSourceError(entity) {
|
|
1697
|
-
_class_call_check(this, NoPrimarySyncSourceError);
|
|
1698
|
-
var _this;
|
|
1699
|
-
_this = _call_super(this, NoPrimarySyncSourceError, [
|
|
1700
|
-
'No primary sync source found for entity "'.concat(entity.commonType, ":").concat(entity.commonId, '".')
|
|
1701
|
-
]), _define_property$1(_this, "entity", void 0);
|
|
1702
|
-
_this.entity = entity;
|
|
1703
|
-
return _this;
|
|
1704
|
-
}
|
|
1705
|
-
return NoPrimarySyncSourceError;
|
|
1706
|
-
}(makeError.BaseError);
|
|
1707
|
-
/**
|
|
1708
|
-
* Error thrown when multiple primary sync sources are found for an entity.
|
|
1709
|
-
*/ var MultiplePrimarySyncSourceError = /*#__PURE__*/ function(BaseError) {
|
|
1710
|
-
_inherits(MultiplePrimarySyncSourceError, BaseError);
|
|
1711
|
-
function MultiplePrimarySyncSourceError(entity) {
|
|
1712
|
-
_class_call_check(this, MultiplePrimarySyncSourceError);
|
|
1713
|
-
var _this;
|
|
1714
|
-
_this = _call_super(this, MultiplePrimarySyncSourceError, [
|
|
1715
|
-
'Multiple primary sync sources found for entity "'.concat(entity.commonType, ":").concat(entity.commonId, '".')
|
|
1716
|
-
]), _define_property$1(_this, "entity", void 0);
|
|
1717
|
-
_this.entity = entity;
|
|
1718
|
-
return _this;
|
|
1719
|
-
}
|
|
1720
|
-
return MultiplePrimarySyncSourceError;
|
|
1721
|
-
}(makeError.BaseError);
|
|
1722
|
-
/**
|
|
1723
|
-
* Error thrown when a synchronization fails for an entity.
|
|
1724
|
-
*/ var SynchronizationFailedError = /*#__PURE__*/ function(BaseError) {
|
|
1725
|
-
_inherits(SynchronizationFailedError, BaseError);
|
|
1726
|
-
function SynchronizationFailedError(entity, error) {
|
|
1727
|
-
_class_call_check(this, SynchronizationFailedError);
|
|
1728
|
-
var _this;
|
|
1729
|
-
_this = _call_super(this, SynchronizationFailedError, [
|
|
1730
|
-
'Synchronization failed for entity "'.concat(entity.commonType, ":").concat(entity.commonId, '". Error: ').concat(error)
|
|
1731
|
-
]), _define_property$1(_this, "entity", void 0), _define_property$1(_this, "error", void 0);
|
|
1732
|
-
_this.entity = entity;
|
|
1733
|
-
_this.error = error;
|
|
1734
|
-
return _this;
|
|
1735
|
-
}
|
|
1736
|
-
return SynchronizationFailedError;
|
|
1737
|
-
}
|
|
1738
|
-
(makeError.BaseError);
|
|
1739
|
-
|
|
1740
|
-
/**
|
|
1741
|
-
* Creates a {@link SyncEntitySynchronizer} from the given configuration.
|
|
1742
|
-
*
|
|
1743
|
-
* Registers common type synchronizers and provides lookup by common type. Throws
|
|
1744
|
-
* {@link UnregisteredSyncEntityCommonTypeError} if an unregistered common type is requested.
|
|
1745
|
-
*
|
|
1746
|
-
* @param config - Contains the list of common type synchronizers to register.
|
|
1747
|
-
* @returns A synchronizer that delegates to the appropriate common type synchronizer.
|
|
1748
|
-
* @throws {UnregisteredSyncEntityCommonTypeError} When requesting an unregistered common type.
|
|
1749
|
-
*
|
|
1750
|
-
* @example
|
|
1751
|
-
* ```typescript
|
|
1752
|
-
* const synchronizer = syncEntitySynchronizer({
|
|
1753
|
-
* commonTypeSynchronizers: [userSynchronizer, orderSynchronizer]
|
|
1754
|
-
* });
|
|
1755
|
-
*
|
|
1756
|
-
* const instance = await synchronizer.synchronizeInstance({ commonType: 'user', commonId: '123' });
|
|
1757
|
-
* const result = await instance.synchronize();
|
|
1758
|
-
* ```
|
|
1759
|
-
*/ function syncEntitySynchronizer(config) {
|
|
1760
|
-
var map = new Map(config.commonTypeSynchronizers.map(function(x) {
|
|
1761
|
-
return [
|
|
1762
|
-
x.commonType,
|
|
1763
|
-
x
|
|
1764
|
-
];
|
|
1765
|
-
}));
|
|
1766
|
-
var commonTypes = Array.from(map.keys());
|
|
1767
|
-
var commonTypeSynchronizer = function commonTypeSynchronizer(input) {
|
|
1768
|
-
var synchronizer = map.get(input);
|
|
1769
|
-
if (!synchronizer) {
|
|
1770
|
-
throw new UnregisteredSyncEntityCommonTypeError(input);
|
|
1771
|
-
}
|
|
1772
|
-
return synchronizer;
|
|
1773
|
-
};
|
|
1774
|
-
return {
|
|
1775
|
-
commonTypes: commonTypes,
|
|
1776
|
-
commonTypeSynchronizer: commonTypeSynchronizer,
|
|
1777
|
-
synchronizeInstance: function synchronizeInstance(input) {
|
|
1778
|
-
var synchronizer = commonTypeSynchronizer(input.commonType);
|
|
1779
|
-
return synchronizer.synchronizeInstance(input);
|
|
1780
|
-
}
|
|
1781
|
-
};
|
|
1782
|
-
}
|
|
1783
|
-
|
|
1784
|
-
function _array_like_to_array(arr, len) {
|
|
1785
|
-
if (len == null || len > arr.length) len = arr.length;
|
|
1786
|
-
for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
|
|
1787
|
-
return arr2;
|
|
1788
|
-
}
|
|
1789
|
-
function _array_with_holes(arr) {
|
|
1790
|
-
if (Array.isArray(arr)) return arr;
|
|
1791
|
-
}
|
|
1792
|
-
function _array_without_holes(arr) {
|
|
1793
|
-
if (Array.isArray(arr)) return _array_like_to_array(arr);
|
|
1794
|
-
}
|
|
1795
|
-
function asyncGeneratorStep$2(gen, resolve, reject, _next, _throw, key, arg) {
|
|
1796
|
-
try {
|
|
1797
|
-
var info = gen[key](arg);
|
|
1798
|
-
var value = info.value;
|
|
1799
|
-
} catch (error) {
|
|
1800
|
-
reject(error);
|
|
1801
|
-
return;
|
|
1802
|
-
}
|
|
1803
|
-
if (info.done) {
|
|
1804
|
-
resolve(value);
|
|
1805
|
-
} else {
|
|
1806
|
-
Promise.resolve(value).then(_next, _throw);
|
|
1807
|
-
}
|
|
1808
|
-
}
|
|
1809
|
-
function _async_to_generator$2(fn) {
|
|
1810
|
-
return function() {
|
|
1811
|
-
var self = this, args = arguments;
|
|
1812
|
-
return new Promise(function(resolve, reject) {
|
|
1813
|
-
var gen = fn.apply(self, args);
|
|
1814
|
-
function _next(value) {
|
|
1815
|
-
asyncGeneratorStep$2(gen, resolve, reject, _next, _throw, "next", value);
|
|
1816
|
-
}
|
|
1817
|
-
function _throw(err) {
|
|
1818
|
-
asyncGeneratorStep$2(gen, resolve, reject, _next, _throw, "throw", err);
|
|
1819
|
-
}
|
|
1820
|
-
_next(undefined);
|
|
1821
|
-
});
|
|
1822
|
-
};
|
|
1823
|
-
}
|
|
1824
|
-
function _define_property(obj, key, value) {
|
|
1825
|
-
if (key in obj) {
|
|
1826
|
-
Object.defineProperty(obj, key, {
|
|
1827
|
-
value: value,
|
|
1828
|
-
enumerable: true,
|
|
1829
|
-
configurable: true,
|
|
1830
|
-
writable: true
|
|
1831
|
-
});
|
|
1832
|
-
} else {
|
|
1833
|
-
obj[key] = value;
|
|
1834
|
-
}
|
|
1835
|
-
return obj;
|
|
1836
|
-
}
|
|
1837
|
-
function _iterable_to_array(iter) {
|
|
1838
|
-
if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter);
|
|
1839
|
-
}
|
|
1840
|
-
function _iterable_to_array_limit(arr, i) {
|
|
1841
|
-
var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"];
|
|
1842
|
-
if (_i == null) return;
|
|
1843
|
-
var _arr = [];
|
|
1844
|
-
var _n = true;
|
|
1845
|
-
var _d = false;
|
|
1846
|
-
var _s, _e;
|
|
1847
|
-
try {
|
|
1848
|
-
for(_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true){
|
|
1849
|
-
_arr.push(_s.value);
|
|
1850
|
-
if (i && _arr.length === i) break;
|
|
1851
|
-
}
|
|
1852
|
-
} catch (err) {
|
|
1853
|
-
_d = true;
|
|
1854
|
-
_e = err;
|
|
1855
|
-
} finally{
|
|
1856
|
-
try {
|
|
1857
|
-
if (!_n && _i["return"] != null) _i["return"]();
|
|
1858
|
-
} finally{
|
|
1859
|
-
if (_d) throw _e;
|
|
1860
|
-
}
|
|
1861
|
-
}
|
|
1862
|
-
return _arr;
|
|
1863
|
-
}
|
|
1864
|
-
function _non_iterable_rest() {
|
|
1865
|
-
throw new TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
1866
|
-
}
|
|
1867
|
-
function _non_iterable_spread() {
|
|
1868
|
-
throw new TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
1869
|
-
}
|
|
1870
|
-
function _object_spread(target) {
|
|
1871
|
-
for(var i = 1; i < arguments.length; i++){
|
|
1872
|
-
var source = arguments[i] != null ? arguments[i] : {};
|
|
1873
|
-
var ownKeys = Object.keys(source);
|
|
1874
|
-
if (typeof Object.getOwnPropertySymbols === "function") {
|
|
1875
|
-
ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function(sym) {
|
|
1876
|
-
return Object.getOwnPropertyDescriptor(source, sym).enumerable;
|
|
1877
|
-
}));
|
|
1878
|
-
}
|
|
1879
|
-
ownKeys.forEach(function(key) {
|
|
1880
|
-
_define_property(target, key, source[key]);
|
|
1881
|
-
});
|
|
1882
|
-
}
|
|
1883
|
-
return target;
|
|
1884
|
-
}
|
|
1885
|
-
function ownKeys(object, enumerableOnly) {
|
|
1886
|
-
var keys = Object.keys(object);
|
|
1887
|
-
if (Object.getOwnPropertySymbols) {
|
|
1888
|
-
var symbols = Object.getOwnPropertySymbols(object);
|
|
1889
|
-
keys.push.apply(keys, symbols);
|
|
1890
|
-
}
|
|
1891
|
-
return keys;
|
|
1892
|
-
}
|
|
1893
|
-
function _object_spread_props(target, source) {
|
|
1894
|
-
source = source != null ? source : {};
|
|
1895
|
-
if (Object.getOwnPropertyDescriptors) {
|
|
1896
|
-
Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
|
|
1897
|
-
} else {
|
|
1898
|
-
ownKeys(Object(source)).forEach(function(key) {
|
|
1899
|
-
Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
|
|
1900
|
-
});
|
|
1901
|
-
}
|
|
1902
|
-
return target;
|
|
1903
|
-
}
|
|
1904
|
-
function _sliced_to_array(arr, i) {
|
|
1905
|
-
return _array_with_holes(arr) || _iterable_to_array_limit(arr, i) || _unsupported_iterable_to_array(arr, i) || _non_iterable_rest();
|
|
1906
|
-
}
|
|
1907
|
-
function _to_consumable_array(arr) {
|
|
1908
|
-
return _array_without_holes(arr) || _iterable_to_array(arr) || _unsupported_iterable_to_array(arr) || _non_iterable_spread();
|
|
1909
|
-
}
|
|
1910
|
-
function _unsupported_iterable_to_array(o, minLen) {
|
|
1911
|
-
if (!o) return;
|
|
1912
|
-
if (typeof o === "string") return _array_like_to_array(o, minLen);
|
|
1913
|
-
var n = Object.prototype.toString.call(o).slice(8, -1);
|
|
1914
|
-
if (n === "Object" && o.constructor) n = o.constructor.name;
|
|
1915
|
-
if (n === "Map" || n === "Set") return Array.from(n);
|
|
1916
|
-
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array(o, minLen);
|
|
1917
|
-
}
|
|
1918
|
-
function _ts_generator$2(thisArg, body) {
|
|
1919
|
-
var f, y, t, _ = {
|
|
1920
|
-
label: 0,
|
|
1921
|
-
sent: function() {
|
|
1922
|
-
if (t[0] & 1) throw t[1];
|
|
1923
|
-
return t[1];
|
|
1924
|
-
},
|
|
1925
|
-
trys: [],
|
|
1926
|
-
ops: []
|
|
1927
|
-
}, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype), d = Object.defineProperty;
|
|
1928
|
-
return d(g, "next", {
|
|
1929
|
-
value: verb(0)
|
|
1930
|
-
}), d(g, "throw", {
|
|
1931
|
-
value: verb(1)
|
|
1932
|
-
}), d(g, "return", {
|
|
1933
|
-
value: verb(2)
|
|
1934
|
-
}), typeof Symbol === "function" && d(g, Symbol.iterator, {
|
|
1935
|
-
value: function() {
|
|
1936
|
-
return this;
|
|
1937
|
-
}
|
|
1938
|
-
}), g;
|
|
1939
|
-
function verb(n) {
|
|
1940
|
-
return function(v) {
|
|
1941
|
-
return step([
|
|
1942
|
-
n,
|
|
1943
|
-
v
|
|
1944
|
-
]);
|
|
1945
|
-
};
|
|
1946
|
-
}
|
|
1947
|
-
function step(op) {
|
|
1948
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
1949
|
-
while(g && (g = 0, op[0] && (_ = 0)), _)try {
|
|
1950
|
-
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
1951
|
-
if (y = 0, t) op = [
|
|
1952
|
-
op[0] & 2,
|
|
1953
|
-
t.value
|
|
1954
|
-
];
|
|
1955
|
-
switch(op[0]){
|
|
1956
|
-
case 0:
|
|
1957
|
-
case 1:
|
|
1958
|
-
t = op;
|
|
1959
|
-
break;
|
|
1960
|
-
case 4:
|
|
1961
|
-
_.label++;
|
|
1962
|
-
return {
|
|
1963
|
-
value: op[1],
|
|
1964
|
-
done: false
|
|
1965
|
-
};
|
|
1966
|
-
case 5:
|
|
1967
|
-
_.label++;
|
|
1968
|
-
y = op[1];
|
|
1969
|
-
op = [
|
|
1970
|
-
0
|
|
1971
|
-
];
|
|
1972
|
-
continue;
|
|
1973
|
-
case 7:
|
|
1974
|
-
op = _.ops.pop();
|
|
1975
|
-
_.trys.pop();
|
|
1976
|
-
continue;
|
|
1977
|
-
default:
|
|
1978
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
|
|
1979
|
-
_ = 0;
|
|
1980
|
-
continue;
|
|
1981
|
-
}
|
|
1982
|
-
if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) {
|
|
1983
|
-
_.label = op[1];
|
|
1984
|
-
break;
|
|
1985
|
-
}
|
|
1986
|
-
if (op[0] === 6 && _.label < t[1]) {
|
|
1987
|
-
_.label = t[1];
|
|
1988
|
-
t = op;
|
|
1989
|
-
break;
|
|
1990
|
-
}
|
|
1991
|
-
if (t && _.label < t[2]) {
|
|
1992
|
-
_.label = t[2];
|
|
1993
|
-
_.ops.push(op);
|
|
1994
|
-
break;
|
|
1995
|
-
}
|
|
1996
|
-
if (t[2]) _.ops.pop();
|
|
1997
|
-
_.trys.pop();
|
|
1998
|
-
continue;
|
|
1999
|
-
}
|
|
2000
|
-
op = body.call(thisArg, _);
|
|
2001
|
-
} catch (e) {
|
|
2002
|
-
op = [
|
|
2003
|
-
6,
|
|
2004
|
-
e
|
|
2005
|
-
];
|
|
2006
|
-
y = 0;
|
|
2007
|
-
} finally{
|
|
2008
|
-
f = t = 0;
|
|
2009
|
-
}
|
|
2010
|
-
if (op[0] & 5) throw op[1];
|
|
2011
|
-
return {
|
|
2012
|
-
value: op[0] ? op[1] : void 0,
|
|
2013
|
-
done: true
|
|
2014
|
-
};
|
|
2015
|
-
}
|
|
2016
|
-
}
|
|
2017
|
-
/**
|
|
2018
|
-
* Creates a {@link BasicSyncEntityCommonTypeSynchronizer} that orchestrates synchronization across multiple sources
|
|
2019
|
-
* for a specific entity common type.
|
|
2020
|
-
*
|
|
2021
|
-
* The synchronizer follows a primary/secondary/replica flow:
|
|
2022
|
-
* 1. The primary source is synchronized first (exactly one required).
|
|
2023
|
-
* 2. Secondary sources are synchronized sequentially; if a secondary reports deletion while primary did not, the sync restarts once.
|
|
2024
|
-
* 3. Replica sources are synchronized concurrently (up to 3 in parallel).
|
|
2025
|
-
*
|
|
2026
|
-
* @param config - Common type, sources, and context loader.
|
|
2027
|
-
* @returns A synchronizer for the configured common type.
|
|
2028
|
-
* @throws {NoPrimarySyncSourceError} When no primary source is found.
|
|
2029
|
-
* @throws {MultiplePrimarySyncSourceError} When more than one primary source is found.
|
|
2030
|
-
* @throws {SynchronizationFailedError} When primary or secondary sync returns failed/error.
|
|
2031
|
-
*
|
|
2032
|
-
* @__NO_SIDE_EFFECTS__
|
|
2033
|
-
*/ function basicSyncEntityCommonTypeSynchronizerInstanceFactory(config) {
|
|
2034
|
-
var _sourcesByContextType_get, _sourcesByContextType_get1;
|
|
2035
|
-
var commonType = config.commonType, sources = config.sources, entitySourceContextLoader = config.entitySourceContextLoader, _config_dynamicSources = config.dynamicSources, dynamicSources = _config_dynamicSources === void 0 ? false : _config_dynamicSources;
|
|
2036
|
-
var syncEntityCommonTypeIdPairForType = syncEntityCommonTypeIdPairFactory(commonType);
|
|
2037
|
-
var sourcesByContextType = util.makeValuesGroupMap(sources, function(x) {
|
|
2038
|
-
return x.contextType;
|
|
2039
|
-
});
|
|
2040
|
-
var allGlobalSources = (_sourcesByContextType_get = sourcesByContextType.get('global')) !== null && _sourcesByContextType_get !== void 0 ? _sourcesByContextType_get : [];
|
|
2041
|
-
var allContextSources = (_sourcesByContextType_get1 = sourcesByContextType.get('context')) !== null && _sourcesByContextType_get1 !== void 0 ? _sourcesByContextType_get1 : [];
|
|
2042
|
-
/**
|
|
2043
|
-
* Loads the relevant sources for the given entity and context.
|
|
2044
|
-
*
|
|
2045
|
-
* @param entityCommonTypeIdPair - The common type/id pair identifying the entity.
|
|
2046
|
-
* @param entitySourceContext - The contextual information for the entity.
|
|
2047
|
-
* @returns The relevant sources for the entity.
|
|
2048
|
-
*/ function loadSources(entityCommonTypeIdPair, entitySourceContext) {
|
|
2049
|
-
var globalSources = entitySourceContext.globalSources, contextSources = entitySourceContext.contextSources;
|
|
2050
|
-
// load/filter global sources
|
|
2051
|
-
var globalMap = new Map(globalSources.map(function(x) {
|
|
2052
|
-
var sourceId;
|
|
2053
|
-
var flowType;
|
|
2054
|
-
if (typeof x === 'string') {
|
|
2055
|
-
sourceId = x;
|
|
2056
|
-
flowType = 'unset';
|
|
2057
|
-
} else {
|
|
2058
|
-
sourceId = x.sourceId;
|
|
2059
|
-
flowType = x.flowType;
|
|
2060
|
-
}
|
|
2061
|
-
return [
|
|
2062
|
-
sourceId,
|
|
2063
|
-
{
|
|
2064
|
-
sourceId: sourceId,
|
|
2065
|
-
flowType: flowType
|
|
2066
|
-
}
|
|
2067
|
-
];
|
|
2068
|
-
}));
|
|
2069
|
-
var relevantGlobalSources = util.filterMaybeArrayValues(allGlobalSources.map(function(x) {
|
|
2070
|
-
var sourceContext = globalMap.get(x.info.id);
|
|
2071
|
-
var result;
|
|
2072
|
-
if (sourceContext != null) {
|
|
2073
|
-
var _ref, _sourceContext_flowType;
|
|
2074
|
-
result = {
|
|
2075
|
-
entityCommonTypeIdPair: entityCommonTypeIdPair,
|
|
2076
|
-
flowType: (_ref = (_sourceContext_flowType = sourceContext.flowType) !== null && _sourceContext_flowType !== void 0 ? _sourceContext_flowType : x.defaultFlowType) !== null && _ref !== void 0 ? _ref : 'unset',
|
|
2077
|
-
source: x
|
|
2078
|
-
};
|
|
2079
|
-
}
|
|
2080
|
-
return result;
|
|
2081
|
-
}));
|
|
2082
|
-
// load/filter context sources
|
|
2083
|
-
var contextMap = new Map(contextSources.map(function(x) {
|
|
2084
|
-
return [
|
|
2085
|
-
x.sourceId,
|
|
2086
|
-
x
|
|
2087
|
-
];
|
|
2088
|
-
}));
|
|
2089
|
-
var relevantContextSources = util.filterMaybeArrayValues(allContextSources.map(function(x) {
|
|
2090
|
-
var sourceContext = contextMap.get(x.info.id);
|
|
2091
|
-
var result;
|
|
2092
|
-
if (sourceContext != null) {
|
|
2093
|
-
var _ref, _sourceContext_flowType;
|
|
2094
|
-
var flowType = (_ref = (_sourceContext_flowType = sourceContext.flowType) !== null && _sourceContext_flowType !== void 0 ? _sourceContext_flowType : x.defaultFlowType) !== null && _ref !== void 0 ? _ref : 'unset';
|
|
2095
|
-
result = {
|
|
2096
|
-
entityCommonTypeIdPair: entityCommonTypeIdPair,
|
|
2097
|
-
flowType: flowType,
|
|
2098
|
-
source: x,
|
|
2099
|
-
context: sourceContext
|
|
2100
|
-
};
|
|
2101
|
-
}
|
|
2102
|
-
return result;
|
|
2103
|
-
}));
|
|
2104
|
-
var allSources = _to_consumable_array(relevantGlobalSources).concat(_to_consumable_array(relevantContextSources));
|
|
2105
|
-
// sort by order, with primary first
|
|
2106
|
-
allSources.sort(util.sortByNumberFunction(function(x) {
|
|
2107
|
-
var result;
|
|
2108
|
-
switch(x.flowType){
|
|
2109
|
-
case 'primary':
|
|
2110
|
-
result = 1;
|
|
2111
|
-
break;
|
|
2112
|
-
case 'secondary':
|
|
2113
|
-
result = 2;
|
|
2114
|
-
break;
|
|
2115
|
-
case 'unset':
|
|
2116
|
-
default:
|
|
2117
|
-
result = 3;
|
|
2118
|
-
break;
|
|
2119
|
-
}
|
|
2120
|
-
return result;
|
|
2121
|
-
}));
|
|
2122
|
-
return allSources;
|
|
2123
|
-
}
|
|
2124
|
-
var synchronizeInstance = function synchronizeInstance(input) {
|
|
2125
|
-
return _async_to_generator$2(function() {
|
|
2126
|
-
var syncEntityCommonTypeIdPair, _loadRelevantSources, loadRelevantSources, synchronize, instance;
|
|
2127
|
-
return _ts_generator$2(this, function(_state) {
|
|
2128
|
-
syncEntityCommonTypeIdPair = syncEntityCommonTypeIdPairForType(input);
|
|
2129
|
-
_loadRelevantSources = function _loadRelevantSources() {
|
|
2130
|
-
return _async_to_generator$2(function() {
|
|
2131
|
-
var entitySourceContext, relevantSources;
|
|
2132
|
-
return _ts_generator$2(this, function(_state) {
|
|
2133
|
-
switch(_state.label){
|
|
2134
|
-
case 0:
|
|
2135
|
-
return [
|
|
2136
|
-
4,
|
|
2137
|
-
entitySourceContextLoader(syncEntityCommonTypeIdPair)
|
|
2138
|
-
];
|
|
2139
|
-
case 1:
|
|
2140
|
-
entitySourceContext = _state.sent();
|
|
2141
|
-
relevantSources = loadSources(syncEntityCommonTypeIdPair, entitySourceContext);
|
|
2142
|
-
return [
|
|
2143
|
-
2,
|
|
2144
|
-
relevantSources
|
|
2145
|
-
];
|
|
2146
|
-
}
|
|
2147
|
-
});
|
|
2148
|
-
})();
|
|
2149
|
-
};
|
|
2150
|
-
if (dynamicSources) {
|
|
2151
|
-
// if dynamic, reload each time and do not cache
|
|
2152
|
-
loadRelevantSources = _loadRelevantSources;
|
|
2153
|
-
} else {
|
|
2154
|
-
// if not dynamic, make a cached getter
|
|
2155
|
-
loadRelevantSources = util.cachedGetter(_loadRelevantSources);
|
|
2156
|
-
}
|
|
2157
|
-
/**
|
|
2158
|
-
* Performs the synchronization for this entity instance.
|
|
2159
|
-
*
|
|
2160
|
-
* @param context - Optional synchronization context with additional configuration.
|
|
2161
|
-
* @returns The result of the synchronization operation.
|
|
2162
|
-
*/ synchronize = function synchronize(context) {
|
|
2163
|
-
return _async_to_generator$2(function() {
|
|
2164
|
-
var _sourcesByFlowType_get, _sourcesByFlowType_get1, _sourcesByFlowType_get2, relevantSources, syncEntityInstances, sourcesByFlowType, primarySources, secondarySources, replicaSources, result;
|
|
2165
|
-
function synchronizeInstance(source, deleted) {
|
|
2166
|
-
var _source = _sliced_to_array(source, 2), _$input = _source[0], sourceInstance = _source[1];
|
|
2167
|
-
var promise = deleted ? sourceInstance.synchronizeDelete() : sourceInstance.synchronize();
|
|
2168
|
-
return promise.catch(function(error) {
|
|
2169
|
-
var errorResult = {
|
|
2170
|
-
type: 'error',
|
|
2171
|
-
error: error,
|
|
2172
|
-
entity: _object_spread_props(_object_spread({}, syncEntityCommonTypeIdPair), {
|
|
2173
|
-
sourceInfo: _$input.source.info,
|
|
2174
|
-
id: ''
|
|
2175
|
-
})
|
|
2176
|
-
};
|
|
2177
|
-
return errorResult;
|
|
2178
|
-
});
|
|
2179
|
-
}
|
|
2180
|
-
function performSynchronizationOfSources(input) {
|
|
2181
|
-
return _async_to_generator$2(function() {
|
|
2182
|
-
var syncRecursionDepth, secondaryFlaggedDelete, result, primarySource, primarySyncResult, synchronizedEntityResults, primaryFlaggedDelete, _iteratorNormalCompletion, _didIteratorError, _iteratorError, _iterator, _step, secondarySource, secondarySyncResult, _, err, replicaTaskResults;
|
|
2183
|
-
return _ts_generator$2(this, function(_state) {
|
|
2184
|
-
switch(_state.label){
|
|
2185
|
-
case 0:
|
|
2186
|
-
syncRecursionDepth = input.syncRecursionDepth, secondaryFlaggedDelete = input.secondaryFlaggedDelete;
|
|
2187
|
-
// synchronize the primary source
|
|
2188
|
-
primarySource = primarySources[0];
|
|
2189
|
-
return [
|
|
2190
|
-
4,
|
|
2191
|
-
synchronizeInstance(primarySource, secondaryFlaggedDelete !== null && secondaryFlaggedDelete !== void 0 ? secondaryFlaggedDelete : false)
|
|
2192
|
-
];
|
|
2193
|
-
case 1:
|
|
2194
|
-
primarySyncResult = _state.sent();
|
|
2195
|
-
synchronizedEntityResults = [
|
|
2196
|
-
primarySyncResult
|
|
2197
|
-
];
|
|
2198
|
-
primaryFlaggedDelete = false;
|
|
2199
|
-
switch(primarySyncResult.type){
|
|
2200
|
-
case 'deleted':
|
|
2201
|
-
primaryFlaggedDelete = true;
|
|
2202
|
-
break;
|
|
2203
|
-
case 'failed':
|
|
2204
|
-
case 'error':
|
|
2205
|
-
throw new SynchronizationFailedError(syncEntityCommonTypeIdPair, primarySyncResult.error);
|
|
2206
|
-
}
|
|
2207
|
-
_iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
|
|
2208
|
-
_state.label = 2;
|
|
2209
|
-
case 2:
|
|
2210
|
-
_state.trys.push([
|
|
2211
|
-
2,
|
|
2212
|
-
13,
|
|
2213
|
-
14,
|
|
2214
|
-
15
|
|
2215
|
-
]);
|
|
2216
|
-
_iterator = secondarySources[Symbol.iterator]();
|
|
2217
|
-
_state.label = 3;
|
|
2218
|
-
case 3:
|
|
2219
|
-
if (!!(_iteratorNormalCompletion = (_step = _iterator.next()).done)) return [
|
|
2220
|
-
3,
|
|
2221
|
-
12
|
|
2222
|
-
];
|
|
2223
|
-
secondarySource = _step.value;
|
|
2224
|
-
return [
|
|
2225
|
-
4,
|
|
2226
|
-
synchronizeInstance(secondarySource, primaryFlaggedDelete)
|
|
2227
|
-
];
|
|
2228
|
-
case 4:
|
|
2229
|
-
secondarySyncResult = _state.sent();
|
|
2230
|
-
synchronizedEntityResults.push(secondarySyncResult);
|
|
2231
|
-
_ = secondarySyncResult.type;
|
|
2232
|
-
switch(_){
|
|
2233
|
-
case 'deleted':
|
|
2234
|
-
return [
|
|
2235
|
-
3,
|
|
2236
|
-
5
|
|
2237
|
-
];
|
|
2238
|
-
case 'failed':
|
|
2239
|
-
return [
|
|
2240
|
-
3,
|
|
2241
|
-
9
|
|
2242
|
-
];
|
|
2243
|
-
case 'error':
|
|
2244
|
-
return [
|
|
2245
|
-
3,
|
|
2246
|
-
9
|
|
2247
|
-
];
|
|
2248
|
-
case 'nochange':
|
|
2249
|
-
return [
|
|
2250
|
-
3,
|
|
2251
|
-
10
|
|
2252
|
-
];
|
|
2253
|
-
case 'synchronized':
|
|
2254
|
-
return [
|
|
2255
|
-
3,
|
|
2256
|
-
10
|
|
2257
|
-
];
|
|
2258
|
-
}
|
|
2259
|
-
return [
|
|
2260
|
-
3,
|
|
2261
|
-
10
|
|
2262
|
-
];
|
|
2263
|
-
case 5:
|
|
2264
|
-
if (!(primaryFlaggedDelete === false)) return [
|
|
2265
|
-
3,
|
|
2266
|
-
8
|
|
2267
|
-
];
|
|
2268
|
-
if (!(syncRecursionDepth === 1)) return [
|
|
2269
|
-
3,
|
|
2270
|
-
7
|
|
2271
|
-
];
|
|
2272
|
-
return [
|
|
2273
|
-
4,
|
|
2274
|
-
performSynchronizationOfSources({
|
|
2275
|
-
syncRecursionDepth: syncRecursionDepth + 1,
|
|
2276
|
-
secondaryFlaggedDelete: true
|
|
2277
|
-
})
|
|
2278
|
-
];
|
|
2279
|
-
case 6:
|
|
2280
|
-
result = _state.sent();
|
|
2281
|
-
return [
|
|
2282
|
-
3,
|
|
2283
|
-
7
|
|
2284
|
-
];
|
|
2285
|
-
case 7:
|
|
2286
|
-
return [
|
|
2287
|
-
3,
|
|
2288
|
-
11
|
|
2289
|
-
];
|
|
2290
|
-
case 8:
|
|
2291
|
-
return [
|
|
2292
|
-
3,
|
|
2293
|
-
11
|
|
2294
|
-
];
|
|
2295
|
-
case 9:
|
|
2296
|
-
throw new SynchronizationFailedError(syncEntityCommonTypeIdPair, secondarySyncResult.error);
|
|
2297
|
-
case 10:
|
|
2298
|
-
// continue normally
|
|
2299
|
-
return [
|
|
2300
|
-
3,
|
|
2301
|
-
11
|
|
2302
|
-
];
|
|
2303
|
-
case 11:
|
|
2304
|
-
_iteratorNormalCompletion = true;
|
|
2305
|
-
return [
|
|
2306
|
-
3,
|
|
2307
|
-
3
|
|
2308
|
-
];
|
|
2309
|
-
case 12:
|
|
2310
|
-
return [
|
|
2311
|
-
3,
|
|
2312
|
-
15
|
|
2313
|
-
];
|
|
2314
|
-
case 13:
|
|
2315
|
-
err = _state.sent();
|
|
2316
|
-
_didIteratorError = true;
|
|
2317
|
-
_iteratorError = err;
|
|
2318
|
-
return [
|
|
2319
|
-
3,
|
|
2320
|
-
15
|
|
2321
|
-
];
|
|
2322
|
-
case 14:
|
|
2323
|
-
try {
|
|
2324
|
-
if (!_iteratorNormalCompletion && _iterator.return != null) {
|
|
2325
|
-
_iterator.return();
|
|
2326
|
-
}
|
|
2327
|
-
} finally{
|
|
2328
|
-
if (_didIteratorError) {
|
|
2329
|
-
throw _iteratorError;
|
|
2330
|
-
}
|
|
2331
|
-
}
|
|
2332
|
-
return [
|
|
2333
|
-
7
|
|
2334
|
-
];
|
|
2335
|
-
case 15:
|
|
2336
|
-
if (!(result == null)) return [
|
|
2337
|
-
3,
|
|
2338
|
-
17
|
|
2339
|
-
];
|
|
2340
|
-
return [
|
|
2341
|
-
4,
|
|
2342
|
-
util.performAsyncTasks(replicaSources, function(x) {
|
|
2343
|
-
return synchronizeInstance(x, primaryFlaggedDelete);
|
|
2344
|
-
}, {
|
|
2345
|
-
sequential: false,
|
|
2346
|
-
maxParallelTasks: 3
|
|
2347
|
-
})
|
|
2348
|
-
];
|
|
2349
|
-
case 16:
|
|
2350
|
-
replicaTaskResults = _state.sent();
|
|
2351
|
-
// add all the results
|
|
2352
|
-
util.pushArrayItemsIntoArray(synchronizedEntityResults, replicaTaskResults.results.map(function(x) {
|
|
2353
|
-
return x[1];
|
|
2354
|
-
}));
|
|
2355
|
-
// compute final result
|
|
2356
|
-
result = {
|
|
2357
|
-
synchronizedEntityResults: synchronizedEntityResults
|
|
2358
|
-
};
|
|
2359
|
-
_state.label = 17;
|
|
2360
|
-
case 17:
|
|
2361
|
-
return [
|
|
2362
|
-
2,
|
|
2363
|
-
result
|
|
2364
|
-
];
|
|
2365
|
-
}
|
|
2366
|
-
});
|
|
2367
|
-
})();
|
|
2368
|
-
}
|
|
2369
|
-
return _ts_generator$2(this, function(_state) {
|
|
2370
|
-
switch(_state.label){
|
|
2371
|
-
case 0:
|
|
2372
|
-
return [
|
|
2373
|
-
4,
|
|
2374
|
-
loadRelevantSources()
|
|
2375
|
-
];
|
|
2376
|
-
case 1:
|
|
2377
|
-
relevantSources = _state.sent();
|
|
2378
|
-
return [
|
|
2379
|
-
4,
|
|
2380
|
-
Promise.all(relevantSources.map(function(x) {
|
|
2381
|
-
return x.source.syncEntityInstance(x).then(function(y) {
|
|
2382
|
-
return [
|
|
2383
|
-
x,
|
|
2384
|
-
y
|
|
2385
|
-
];
|
|
2386
|
-
});
|
|
2387
|
-
}))
|
|
2388
|
-
];
|
|
2389
|
-
case 2:
|
|
2390
|
-
syncEntityInstances = _state.sent();
|
|
2391
|
-
sourcesByFlowType = util.makeValuesGroupMap(syncEntityInstances, function(x) {
|
|
2392
|
-
return x[0].flowType;
|
|
2393
|
-
});
|
|
2394
|
-
primarySources = (_sourcesByFlowType_get = sourcesByFlowType.get('primary')) !== null && _sourcesByFlowType_get !== void 0 ? _sourcesByFlowType_get : [];
|
|
2395
|
-
secondarySources = (_sourcesByFlowType_get1 = sourcesByFlowType.get('secondary')) !== null && _sourcesByFlowType_get1 !== void 0 ? _sourcesByFlowType_get1 : [];
|
|
2396
|
-
replicaSources = (_sourcesByFlowType_get2 = sourcesByFlowType.get('replica')) !== null && _sourcesByFlowType_get2 !== void 0 ? _sourcesByFlowType_get2 : [];
|
|
2397
|
-
// assert primary sources count
|
|
2398
|
-
switch(primarySources.length){
|
|
2399
|
-
case 0:
|
|
2400
|
-
throw new NoPrimarySyncSourceError(syncEntityCommonTypeIdPair);
|
|
2401
|
-
case 1:
|
|
2402
|
-
break;
|
|
2403
|
-
default:
|
|
2404
|
-
throw new MultiplePrimarySyncSourceError(syncEntityCommonTypeIdPair);
|
|
2405
|
-
}
|
|
2406
|
-
return [
|
|
2407
|
-
4,
|
|
2408
|
-
performSynchronizationOfSources({
|
|
2409
|
-
syncRecursionDepth: 0
|
|
2410
|
-
})
|
|
2411
|
-
];
|
|
2412
|
-
case 3:
|
|
2413
|
-
result = _state.sent();
|
|
2414
|
-
return [
|
|
2415
|
-
2,
|
|
2416
|
-
{
|
|
2417
|
-
targetPair: syncEntityCommonTypeIdPair,
|
|
2418
|
-
entitiesSynchronized: result.synchronizedEntityResults
|
|
2419
|
-
}
|
|
2420
|
-
];
|
|
2421
|
-
}
|
|
2422
|
-
});
|
|
2423
|
-
})();
|
|
2424
|
-
};
|
|
2425
|
-
instance = {
|
|
2426
|
-
entityPair: syncEntityCommonTypeIdPair,
|
|
2427
|
-
synchronize: synchronize
|
|
2428
|
-
};
|
|
2429
|
-
return [
|
|
2430
|
-
2,
|
|
2431
|
-
instance
|
|
2432
|
-
];
|
|
2433
|
-
});
|
|
2434
|
-
})();
|
|
2435
|
-
};
|
|
2436
|
-
var result = {
|
|
2437
|
-
commonType: commonType,
|
|
2438
|
-
synchronizeInstance: synchronizeInstance
|
|
2439
|
-
};
|
|
2440
|
-
return result;
|
|
2441
|
-
}
|
|
2442
|
-
|
|
2443
|
-
function asyncGeneratorStep$1(gen, resolve, reject, _next, _throw, key, arg) {
|
|
2444
|
-
try {
|
|
2445
|
-
var info = gen[key](arg);
|
|
2446
|
-
var value = info.value;
|
|
2447
|
-
} catch (error) {
|
|
2448
|
-
reject(error);
|
|
2449
|
-
return;
|
|
2450
|
-
}
|
|
2451
|
-
if (info.done) {
|
|
2452
|
-
resolve(value);
|
|
2453
|
-
} else {
|
|
2454
|
-
Promise.resolve(value).then(_next, _throw);
|
|
2455
|
-
}
|
|
2456
|
-
}
|
|
2457
|
-
function _async_to_generator$1(fn) {
|
|
2458
|
-
return function() {
|
|
2459
|
-
var self = this, args = arguments;
|
|
2460
|
-
return new Promise(function(resolve, reject) {
|
|
2461
|
-
var gen = fn.apply(self, args);
|
|
2462
|
-
function _next(value) {
|
|
2463
|
-
asyncGeneratorStep$1(gen, resolve, reject, _next, _throw, "next", value);
|
|
2464
|
-
}
|
|
2465
|
-
function _throw(err) {
|
|
2466
|
-
asyncGeneratorStep$1(gen, resolve, reject, _next, _throw, "throw", err);
|
|
2467
|
-
}
|
|
2468
|
-
_next(undefined);
|
|
2469
|
-
});
|
|
2470
|
-
};
|
|
2471
|
-
}
|
|
2472
|
-
function _instanceof(left, right) {
|
|
2473
|
-
"@swc/helpers - instanceof";
|
|
2474
|
-
if (right != null && typeof Symbol !== "undefined" && right[Symbol.hasInstance]) {
|
|
2475
|
-
return !!right[Symbol.hasInstance](left);
|
|
2476
|
-
} else {
|
|
2477
|
-
return left instanceof right;
|
|
2478
|
-
}
|
|
2479
|
-
}
|
|
2480
|
-
function _ts_generator$1(thisArg, body) {
|
|
2481
|
-
var f, y, t, _ = {
|
|
2482
|
-
label: 0,
|
|
2483
|
-
sent: function() {
|
|
2484
|
-
if (t[0] & 1) throw t[1];
|
|
2485
|
-
return t[1];
|
|
2486
|
-
},
|
|
2487
|
-
trys: [],
|
|
2488
|
-
ops: []
|
|
2489
|
-
}, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype), d = Object.defineProperty;
|
|
2490
|
-
return d(g, "next", {
|
|
2491
|
-
value: verb(0)
|
|
2492
|
-
}), d(g, "throw", {
|
|
2493
|
-
value: verb(1)
|
|
2494
|
-
}), d(g, "return", {
|
|
2495
|
-
value: verb(2)
|
|
2496
|
-
}), typeof Symbol === "function" && d(g, Symbol.iterator, {
|
|
2497
|
-
value: function() {
|
|
2498
|
-
return this;
|
|
2499
|
-
}
|
|
2500
|
-
}), g;
|
|
2501
|
-
function verb(n) {
|
|
2502
|
-
return function(v) {
|
|
2503
|
-
return step([
|
|
2504
|
-
n,
|
|
2505
|
-
v
|
|
2506
|
-
]);
|
|
2507
|
-
};
|
|
2508
|
-
}
|
|
2509
|
-
function step(op) {
|
|
2510
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
2511
|
-
while(g && (g = 0, op[0] && (_ = 0)), _)try {
|
|
2512
|
-
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
2513
|
-
if (y = 0, t) op = [
|
|
2514
|
-
op[0] & 2,
|
|
2515
|
-
t.value
|
|
2516
|
-
];
|
|
2517
|
-
switch(op[0]){
|
|
2518
|
-
case 0:
|
|
2519
|
-
case 1:
|
|
2520
|
-
t = op;
|
|
2521
|
-
break;
|
|
2522
|
-
case 4:
|
|
2523
|
-
_.label++;
|
|
2524
|
-
return {
|
|
2525
|
-
value: op[1],
|
|
2526
|
-
done: false
|
|
2527
|
-
};
|
|
2528
|
-
case 5:
|
|
2529
|
-
_.label++;
|
|
2530
|
-
y = op[1];
|
|
2531
|
-
op = [
|
|
2532
|
-
0
|
|
2533
|
-
];
|
|
2534
|
-
continue;
|
|
2535
|
-
case 7:
|
|
2536
|
-
op = _.ops.pop();
|
|
2537
|
-
_.trys.pop();
|
|
2538
|
-
continue;
|
|
2539
|
-
default:
|
|
2540
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
|
|
2541
|
-
_ = 0;
|
|
2542
|
-
continue;
|
|
2543
|
-
}
|
|
2544
|
-
if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) {
|
|
2545
|
-
_.label = op[1];
|
|
2546
|
-
break;
|
|
2547
|
-
}
|
|
2548
|
-
if (op[0] === 6 && _.label < t[1]) {
|
|
2549
|
-
_.label = t[1];
|
|
2550
|
-
t = op;
|
|
2551
|
-
break;
|
|
2552
|
-
}
|
|
2553
|
-
if (t && _.label < t[2]) {
|
|
2554
|
-
_.label = t[2];
|
|
2555
|
-
_.ops.push(op);
|
|
2556
|
-
break;
|
|
2557
|
-
}
|
|
2558
|
-
if (t[2]) _.ops.pop();
|
|
2559
|
-
_.trys.pop();
|
|
2560
|
-
continue;
|
|
2561
|
-
}
|
|
2562
|
-
op = body.call(thisArg, _);
|
|
2563
|
-
} catch (e) {
|
|
2564
|
-
op = [
|
|
2565
|
-
6,
|
|
2566
|
-
e
|
|
2567
|
-
];
|
|
2568
|
-
y = 0;
|
|
2569
|
-
} finally{
|
|
2570
|
-
f = t = 0;
|
|
2571
|
-
}
|
|
2572
|
-
if (op[0] & 5) throw op[1];
|
|
2573
|
-
return {
|
|
2574
|
-
value: op[0] ? op[1] : void 0,
|
|
2575
|
-
done: true
|
|
2576
|
-
};
|
|
2577
|
-
}
|
|
2578
|
-
}
|
|
2579
|
-
/**
|
|
2580
|
-
* Creates a function that validates input against an ArkType schema and then processes it.
|
|
2581
|
-
*
|
|
2582
|
-
* On validation success, calls the configured handler function. On validation failure, delegates to the error handler.
|
|
2583
|
-
*
|
|
2584
|
-
* @param config - Schema, handler function, and validation error handler.
|
|
2585
|
-
* @returns Wrapped function that runs validation then either invokes the handler or routes failures to the error handler.
|
|
2586
|
-
*
|
|
2587
|
-
* @example
|
|
2588
|
-
* ```typescript
|
|
2589
|
-
* const processUser = transformAndValidateObject({
|
|
2590
|
-
* schema: userType,
|
|
2591
|
-
* fn: async (user) => ({ id: user.id }),
|
|
2592
|
-
* handleValidationError: async (errors) => { throw new Error(errors.summary); }
|
|
2593
|
-
* });
|
|
2594
|
-
*
|
|
2595
|
-
* const result = await processUser({ id: '123', name: 'John' });
|
|
2596
|
-
* ```
|
|
2597
|
-
*/ function transformAndValidateObject(config) {
|
|
2598
|
-
var transformToResult = transformAndValidateObjectResult(config);
|
|
2599
|
-
var handleValidationError = config.handleValidationError;
|
|
2600
|
-
return function(input, context) {
|
|
2601
|
-
return _async_to_generator$1(function() {
|
|
2602
|
-
var x, output, result;
|
|
2603
|
-
return _ts_generator$1(this, function(_state) {
|
|
2604
|
-
switch(_state.label){
|
|
2605
|
-
case 0:
|
|
2606
|
-
return [
|
|
2607
|
-
4,
|
|
2608
|
-
transformToResult(input, context)
|
|
2609
|
-
];
|
|
2610
|
-
case 1:
|
|
2611
|
-
x = _state.sent();
|
|
2612
|
-
if (!x.success) return [
|
|
2613
|
-
3,
|
|
2614
|
-
2
|
|
2615
|
-
];
|
|
2616
|
-
output = {
|
|
2617
|
-
object: x.object,
|
|
2618
|
-
result: x.result
|
|
2619
|
-
};
|
|
2620
|
-
return [
|
|
2621
|
-
3,
|
|
2622
|
-
4
|
|
2623
|
-
];
|
|
2624
|
-
case 2:
|
|
2625
|
-
return [
|
|
2626
|
-
4,
|
|
2627
|
-
handleValidationError(x.validationErrors)
|
|
2628
|
-
];
|
|
2629
|
-
case 3:
|
|
2630
|
-
result = _state.sent();
|
|
2631
|
-
output = {
|
|
2632
|
-
object: undefined,
|
|
2633
|
-
result: result
|
|
2634
|
-
};
|
|
2635
|
-
_state.label = 4;
|
|
2636
|
-
case 4:
|
|
2637
|
-
return [
|
|
2638
|
-
2,
|
|
2639
|
-
output
|
|
2640
|
-
];
|
|
2641
|
-
}
|
|
2642
|
-
});
|
|
2643
|
-
})();
|
|
2644
|
-
};
|
|
2645
|
-
}
|
|
2646
|
-
/**
|
|
2647
|
-
* Creates a reusable factory for generating transform-and-validate functions with shared defaults.
|
|
2648
|
-
*
|
|
2649
|
-
* The factory pre-configures error handling so individual function calls
|
|
2650
|
-
* only need to specify the schema and handler.
|
|
2651
|
-
*
|
|
2652
|
-
* @param defaults - Default error handler.
|
|
2653
|
-
* @returns A factory function that creates TransformAndValidateObjectFunction instances.
|
|
2654
|
-
*
|
|
2655
|
-
* @__NO_SIDE_EFFECTS__
|
|
2656
|
-
*/ function transformAndValidateObjectFactory(defaults) {
|
|
2657
|
-
var defaultHandleValidationError = defaults.handleValidationError;
|
|
2658
|
-
return function(schema, fn, handleValidationError) {
|
|
2659
|
-
var config = {
|
|
2660
|
-
schema: schema,
|
|
2661
|
-
fn: fn,
|
|
2662
|
-
handleValidationError: handleValidationError !== null && handleValidationError !== void 0 ? handleValidationError : defaultHandleValidationError
|
|
2663
|
-
};
|
|
2664
|
-
return transformAndValidateObject(config);
|
|
2665
|
-
};
|
|
2666
|
-
}
|
|
2667
|
-
/**
|
|
2668
|
-
* Creates a function that validates input against an ArkType schema and returns a discriminated result.
|
|
2669
|
-
*
|
|
2670
|
-
* Returns `{ success: true, object, result }` on valid input, or `{ success: false, validationErrors }` on failure.
|
|
2671
|
-
* The caller is responsible for handling the error case.
|
|
2672
|
-
*
|
|
2673
|
-
* @param config - Schema and handler function.
|
|
2674
|
-
* @returns Wrapped function that yields a discriminated result so the caller can branch on success or validation failure.
|
|
2675
|
-
*
|
|
2676
|
-
* @example
|
|
2677
|
-
* ```typescript
|
|
2678
|
-
* const validateUser = transformAndValidateObjectResult({
|
|
2679
|
-
* schema: userType,
|
|
2680
|
-
* fn: async (user) => ({ saved: true })
|
|
2681
|
-
* });
|
|
2682
|
-
*
|
|
2683
|
-
* const result = await validateUser({ name: 'John' });
|
|
2684
|
-
* if (result.success) {
|
|
2685
|
-
* console.log(result.result);
|
|
2686
|
-
* } else {
|
|
2687
|
-
* console.log(result.validationErrors.summary);
|
|
2688
|
-
* }
|
|
2689
|
-
* ```
|
|
2690
|
-
*/ function transformAndValidateObjectResult(config) {
|
|
2691
|
-
var schema = config.schema, fn = config.fn;
|
|
2692
|
-
return function(input) {
|
|
2693
|
-
return _async_to_generator$1(function() {
|
|
2694
|
-
var out, output, object, result;
|
|
2695
|
-
return _ts_generator$1(this, function(_state) {
|
|
2696
|
-
switch(_state.label){
|
|
2697
|
-
case 0:
|
|
2698
|
-
out = schema(input);
|
|
2699
|
-
if (!_instanceof(out, arktype.type.errors)) return [
|
|
2700
|
-
3,
|
|
2701
|
-
1
|
|
2702
|
-
];
|
|
2703
|
-
output = {
|
|
2704
|
-
validationErrors: out,
|
|
2705
|
-
success: false
|
|
2706
|
-
};
|
|
2707
|
-
return [
|
|
2708
|
-
3,
|
|
2709
|
-
3
|
|
2710
|
-
];
|
|
2711
|
-
case 1:
|
|
2712
|
-
object = out;
|
|
2713
|
-
return [
|
|
2714
|
-
4,
|
|
2715
|
-
fn(object)
|
|
2716
|
-
];
|
|
2717
|
-
case 2:
|
|
2718
|
-
result = _state.sent();
|
|
2719
|
-
output = {
|
|
2720
|
-
object: object,
|
|
2721
|
-
result: result,
|
|
2722
|
-
success: true
|
|
2723
|
-
};
|
|
2724
|
-
_state.label = 3;
|
|
2725
|
-
case 3:
|
|
2726
|
-
return [
|
|
2727
|
-
2,
|
|
2728
|
-
output
|
|
2729
|
-
];
|
|
2730
|
-
}
|
|
2731
|
-
});
|
|
2732
|
-
})();
|
|
2733
|
-
};
|
|
2734
|
-
}
|
|
2735
|
-
|
|
2736
|
-
/**
|
|
2737
|
-
* Creates a factory for transform-and-validate functions that return the result with the parsed object attached as `params`.
|
|
2738
|
-
*
|
|
2739
|
-
* @param defaults - Shared error handler defaults.
|
|
2740
|
-
* @returns A factory that produces functions returning {@link TransformAndValidateFunctionResult}
|
|
2741
|
-
*
|
|
2742
|
-
* @__NO_SIDE_EFFECTS__
|
|
2743
|
-
*/ function transformAndValidateFunctionResultFactory(defaults) {
|
|
2744
|
-
return toTransformAndValidateFunctionResultFactory(transformAndValidateObjectFactory(defaults));
|
|
2745
|
-
}
|
|
2746
|
-
/**
|
|
2747
|
-
* Wraps an existing {@link TransformAndValidateObjectFactory} to produce functions that attach the parsed object
|
|
2748
|
-
* as `params` on the result.
|
|
2749
|
-
*
|
|
2750
|
-
* @param transformAndValidateObjectFactory - The base factory to wrap.
|
|
2751
|
-
* @returns A factory that produces functions returning results with `params` attached.
|
|
2752
|
-
*
|
|
2753
|
-
* @__NO_SIDE_EFFECTS__
|
|
2754
|
-
*/ function toTransformAndValidateFunctionResultFactory(transformAndValidateObjectFactory) {
|
|
2755
|
-
return function(schema, fn, handleValidationError) {
|
|
2756
|
-
var transformAndValidateObjectFn = transformAndValidateObjectFactory(schema, fn, handleValidationError);
|
|
2757
|
-
return function(input, context) {
|
|
2758
|
-
return toTransformAndValidateFunctionResult(transformAndValidateObjectFn(input, context));
|
|
2759
|
-
};
|
|
2760
|
-
};
|
|
2761
|
-
}
|
|
2762
|
-
function toTransformAndValidateFunctionResult(objectOutput) {
|
|
2763
|
-
return util.mapPromiseOrValue(objectOutput, function(x) {
|
|
2764
|
-
var object = x.object, result = x.result;
|
|
2765
|
-
var fnResult = result;
|
|
2766
|
-
fnResult.params = object;
|
|
2767
|
-
return fnResult;
|
|
2768
|
-
});
|
|
2769
|
-
}
|
|
2770
|
-
|
|
2771
|
-
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
|
|
2772
|
-
try {
|
|
2773
|
-
var info = gen[key](arg);
|
|
2774
|
-
var value = info.value;
|
|
2775
|
-
} catch (error) {
|
|
2776
|
-
reject(error);
|
|
2777
|
-
return;
|
|
2778
|
-
}
|
|
2779
|
-
if (info.done) {
|
|
2780
|
-
resolve(value);
|
|
2781
|
-
} else {
|
|
2782
|
-
Promise.resolve(value).then(_next, _throw);
|
|
2783
|
-
}
|
|
2784
|
-
}
|
|
2785
|
-
function _async_to_generator(fn) {
|
|
2786
|
-
return function() {
|
|
2787
|
-
var self = this, args = arguments;
|
|
2788
|
-
return new Promise(function(resolve, reject) {
|
|
2789
|
-
var gen = fn.apply(self, args);
|
|
2790
|
-
function _next(value) {
|
|
2791
|
-
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
|
|
2792
|
-
}
|
|
2793
|
-
function _throw(err) {
|
|
2794
|
-
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
|
|
2795
|
-
}
|
|
2796
|
-
_next(undefined);
|
|
2797
|
-
});
|
|
2798
|
-
};
|
|
2799
|
-
}
|
|
2800
|
-
function _ts_generator(thisArg, body) {
|
|
2801
|
-
var f, y, t, _ = {
|
|
2802
|
-
label: 0,
|
|
2803
|
-
sent: function() {
|
|
2804
|
-
if (t[0] & 1) throw t[1];
|
|
2805
|
-
return t[1];
|
|
2806
|
-
},
|
|
2807
|
-
trys: [],
|
|
2808
|
-
ops: []
|
|
2809
|
-
}, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype), d = Object.defineProperty;
|
|
2810
|
-
return d(g, "next", {
|
|
2811
|
-
value: verb(0)
|
|
2812
|
-
}), d(g, "throw", {
|
|
2813
|
-
value: verb(1)
|
|
2814
|
-
}), d(g, "return", {
|
|
2815
|
-
value: verb(2)
|
|
2816
|
-
}), typeof Symbol === "function" && d(g, Symbol.iterator, {
|
|
2817
|
-
value: function() {
|
|
2818
|
-
return this;
|
|
2819
|
-
}
|
|
2820
|
-
}), g;
|
|
2821
|
-
function verb(n) {
|
|
2822
|
-
return function(v) {
|
|
2823
|
-
return step([
|
|
2824
|
-
n,
|
|
2825
|
-
v
|
|
2826
|
-
]);
|
|
2827
|
-
};
|
|
2828
|
-
}
|
|
2829
|
-
function step(op) {
|
|
2830
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
2831
|
-
while(g && (g = 0, op[0] && (_ = 0)), _)try {
|
|
2832
|
-
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
2833
|
-
if (y = 0, t) op = [
|
|
2834
|
-
op[0] & 2,
|
|
2835
|
-
t.value
|
|
2836
|
-
];
|
|
2837
|
-
switch(op[0]){
|
|
2838
|
-
case 0:
|
|
2839
|
-
case 1:
|
|
2840
|
-
t = op;
|
|
2841
|
-
break;
|
|
2842
|
-
case 4:
|
|
2843
|
-
_.label++;
|
|
2844
|
-
return {
|
|
2845
|
-
value: op[1],
|
|
2846
|
-
done: false
|
|
2847
|
-
};
|
|
2848
|
-
case 5:
|
|
2849
|
-
_.label++;
|
|
2850
|
-
y = op[1];
|
|
2851
|
-
op = [
|
|
2852
|
-
0
|
|
2853
|
-
];
|
|
2854
|
-
continue;
|
|
2855
|
-
case 7:
|
|
2856
|
-
op = _.ops.pop();
|
|
2857
|
-
_.trys.pop();
|
|
2858
|
-
continue;
|
|
2859
|
-
default:
|
|
2860
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
|
|
2861
|
-
_ = 0;
|
|
2862
|
-
continue;
|
|
2863
|
-
}
|
|
2864
|
-
if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) {
|
|
2865
|
-
_.label = op[1];
|
|
2866
|
-
break;
|
|
2867
|
-
}
|
|
2868
|
-
if (op[0] === 6 && _.label < t[1]) {
|
|
2869
|
-
_.label = t[1];
|
|
2870
|
-
t = op;
|
|
2871
|
-
break;
|
|
2872
|
-
}
|
|
2873
|
-
if (t && _.label < t[2]) {
|
|
2874
|
-
_.label = t[2];
|
|
2875
|
-
_.ops.push(op);
|
|
2876
|
-
break;
|
|
2877
|
-
}
|
|
2878
|
-
if (t[2]) _.ops.pop();
|
|
2879
|
-
_.trys.pop();
|
|
2880
|
-
continue;
|
|
2881
|
-
}
|
|
2882
|
-
op = body.call(thisArg, _);
|
|
2883
|
-
} catch (e) {
|
|
2884
|
-
op = [
|
|
2885
|
-
6,
|
|
2886
|
-
e
|
|
2887
|
-
];
|
|
2888
|
-
y = 0;
|
|
2889
|
-
} finally{
|
|
2890
|
-
f = t = 0;
|
|
2891
|
-
}
|
|
2892
|
-
if (op[0] & 5) throw op[1];
|
|
2893
|
-
return {
|
|
2894
|
-
value: op[0] ? op[1] : void 0,
|
|
2895
|
-
done: true
|
|
2896
|
-
};
|
|
2897
|
-
}
|
|
2898
|
-
}
|
|
2899
|
-
/**
|
|
2900
|
-
* Creates a factory for transform-and-validate functions that return only the result (discarding the parsed object).
|
|
2901
|
-
*
|
|
2902
|
-
* Useful when you only need the processed output and don't need access to the validated input.
|
|
2903
|
-
*
|
|
2904
|
-
* @param defaults - Shared error handler defaults.
|
|
2905
|
-
* @returns A factory that produces functions returning only the handler's result.
|
|
2906
|
-
*
|
|
2907
|
-
* @__NO_SIDE_EFFECTS__
|
|
2908
|
-
*/ function transformAndValidateResultFactory(defaults) {
|
|
2909
|
-
var factory = transformAndValidateObjectFactory(defaults);
|
|
2910
|
-
return function(schema, fn, handleValidationError) {
|
|
2911
|
-
var transformAndValidateObjectFn = factory(schema, fn, handleValidationError);
|
|
2912
|
-
return function(input, context) {
|
|
2913
|
-
return _async_to_generator(function() {
|
|
2914
|
-
var result;
|
|
2915
|
-
return _ts_generator(this, function(_state) {
|
|
2916
|
-
switch(_state.label){
|
|
2917
|
-
case 0:
|
|
2918
|
-
return [
|
|
2919
|
-
4,
|
|
2920
|
-
transformAndValidateObjectFn(input, context)
|
|
2921
|
-
];
|
|
2922
|
-
case 1:
|
|
2923
|
-
result = _state.sent().result;
|
|
2924
|
-
return [
|
|
2925
|
-
2,
|
|
2926
|
-
result
|
|
2927
|
-
];
|
|
2928
|
-
}
|
|
2929
|
-
});
|
|
2930
|
-
})();
|
|
2931
|
-
};
|
|
2932
|
-
};
|
|
2933
|
-
}
|
|
2934
|
-
|
|
2935
|
-
/**
|
|
2936
|
-
* ArkType schema for a valid ISO 8601 day string (e.g., "2024-01-15").
|
|
2937
|
-
*
|
|
2938
|
-
* @dbxUtil
|
|
2939
|
-
* @dbxUtilCategory validator
|
|
2940
|
-
* @dbxUtilKind const
|
|
2941
|
-
* @dbxUtilTags validator, arktype, date, iso8601, day, string
|
|
2942
|
-
*
|
|
2943
|
-
* @example
|
|
2944
|
-
* ```ts
|
|
2945
|
-
* type({ startsOn: iso8601DayStringType });
|
|
2946
|
-
* ```
|
|
2947
|
-
*/ var iso8601DayStringType = arktype.type('string > 0').narrow(function(val, ctx) {
|
|
2948
|
-
return val != null && util.isISO8601DayString(val) || ctx.mustBe('a valid ISO 8601 day string');
|
|
2949
|
-
});
|
|
2950
|
-
|
|
2951
|
-
/**
|
|
2952
|
-
* A number greater than or equal to 0.
|
|
2953
|
-
*
|
|
2954
|
-
* @dbxUtil
|
|
2955
|
-
* @dbxUtilCategory validator
|
|
2956
|
-
* @dbxUtilKind const
|
|
2957
|
-
* @dbxUtilTags validator, arktype, number, non-negative
|
|
2958
|
-
* @dbxUtilRelated non-negative-integer
|
|
2959
|
-
*
|
|
2960
|
-
* @example
|
|
2961
|
-
* ```ts
|
|
2962
|
-
* type({ price: NON_NEGATIVE_NUMBER });
|
|
2963
|
-
* ```
|
|
2964
|
-
*/ var NON_NEGATIVE_NUMBER = 'number >= 0';
|
|
2965
|
-
/**
|
|
2966
|
-
* A non-negative integer.
|
|
2967
|
-
*
|
|
2968
|
-
* @dbxUtil
|
|
2969
|
-
* @dbxUtilCategory validator
|
|
2970
|
-
* @dbxUtilKind const
|
|
2971
|
-
* @dbxUtilTags validator, arktype, number, non-negative, integer
|
|
2972
|
-
* @dbxUtilRelated non-negative-number
|
|
2973
|
-
*
|
|
2974
|
-
* @example
|
|
2975
|
-
* ```ts
|
|
2976
|
-
* type({ count: NON_NEGATIVE_INTEGER });
|
|
2977
|
-
* ```
|
|
2978
|
-
*/ var NON_NEGATIVE_INTEGER = 'number.integer >= 0';
|
|
2979
|
-
/**
|
|
2980
|
-
* ArkType schema for a valid minute of the day (0-1439).
|
|
2981
|
-
*
|
|
2982
|
-
* @dbxUtil
|
|
2983
|
-
* @dbxUtilCategory validator
|
|
2984
|
-
* @dbxUtilKind const
|
|
2985
|
-
* @dbxUtilTags validator, arktype, number, minute-of-day, time
|
|
2986
|
-
*
|
|
2987
|
-
* @example
|
|
2988
|
-
* ```ts
|
|
2989
|
-
* type({ startMinute: minuteOfDayType });
|
|
2990
|
-
* ```
|
|
2991
|
-
*/ var minuteOfDayType = arktype.type('number').narrow(function(val, ctx) {
|
|
2992
|
-
return val != null && util.isMinuteOfDay(val) || ctx.mustBe('a valid minute of the day (0-1439)');
|
|
2993
|
-
});
|
|
2994
|
-
|
|
2995
|
-
/**
|
|
2996
|
-
* ArkType schema for a valid E.164 phone number without an extension.
|
|
2997
|
-
*
|
|
2998
|
-
* @dbxUtil
|
|
2999
|
-
* @dbxUtilCategory validator
|
|
3000
|
-
* @dbxUtilKind const
|
|
3001
|
-
* @dbxUtilTags validator, arktype, phone, e164, string
|
|
3002
|
-
* @dbxUtilRelated e164-phone-number-with-optional-extension-type, e164-phone-number-with-extension-type
|
|
3003
|
-
*
|
|
3004
|
-
* @example
|
|
3005
|
-
* ```ts
|
|
3006
|
-
* type({ phone: e164PhoneNumberType });
|
|
3007
|
-
* ```
|
|
3008
|
-
*/ var e164PhoneNumberType = arktype.type('string > 0').narrow(function(val, ctx) {
|
|
3009
|
-
return val != null && util.isE164PhoneNumber(val, false) || ctx.mustBe('a valid E.164 phone number without an extension');
|
|
3010
|
-
});
|
|
3011
|
-
/**
|
|
3012
|
-
* ArkType schema for a valid E.164 phone number, optionally with an extension.
|
|
3013
|
-
*
|
|
3014
|
-
* @dbxUtil
|
|
3015
|
-
* @dbxUtilCategory validator
|
|
3016
|
-
* @dbxUtilKind const
|
|
3017
|
-
* @dbxUtilTags validator, arktype, phone, e164, extension, string
|
|
3018
|
-
* @dbxUtilRelated e164-phone-number-type, e164-phone-number-with-extension-type
|
|
3019
|
-
*
|
|
3020
|
-
* @example
|
|
3021
|
-
* ```ts
|
|
3022
|
-
* type({ phone: e164PhoneNumberWithOptionalExtensionType });
|
|
3023
|
-
* ```
|
|
3024
|
-
*/ var e164PhoneNumberWithOptionalExtensionType = arktype.type('string > 0').narrow(function(val, ctx) {
|
|
3025
|
-
return val != null && util.isE164PhoneNumber(val, true) || ctx.mustBe('a valid E.164 phone number');
|
|
3026
|
-
});
|
|
3027
|
-
/**
|
|
3028
|
-
* ArkType schema for a valid E.164 phone number that includes an extension.
|
|
3029
|
-
*
|
|
3030
|
-
* @dbxUtil
|
|
3031
|
-
* @dbxUtilCategory validator
|
|
3032
|
-
* @dbxUtilKind const
|
|
3033
|
-
* @dbxUtilTags validator, arktype, phone, e164, extension, string
|
|
3034
|
-
* @dbxUtilRelated e164-phone-number-type, e164-phone-number-with-optional-extension-type
|
|
3035
|
-
*
|
|
3036
|
-
* @example
|
|
3037
|
-
* ```ts
|
|
3038
|
-
* type({ phone: e164PhoneNumberWithExtensionType });
|
|
3039
|
-
* ```
|
|
3040
|
-
*/ var e164PhoneNumberWithExtensionType = arktype.type('string > 0').narrow(function(val, ctx) {
|
|
3041
|
-
return val != null && util.isE164PhoneNumberWithExtension(val) || ctx.mustBe('a valid E.164 phone number with an extension');
|
|
3042
|
-
});
|
|
3043
|
-
|
|
3044
|
-
/**
|
|
3045
|
-
* ArkType schema for a valid {@link LatLngPoint} with lat in [-90, 90] and lng in [-180, 180].
|
|
3046
|
-
*
|
|
3047
|
-
* @dbxUtil
|
|
3048
|
-
* @dbxUtilCategory validator
|
|
3049
|
-
* @dbxUtilKind const
|
|
3050
|
-
* @dbxUtilTags validator, arktype, lat-lng, point, geo, coordinates
|
|
3051
|
-
* @dbxUtilRelated lat-lng-string-type
|
|
3052
|
-
*
|
|
3053
|
-
* @example
|
|
3054
|
-
* ```ts
|
|
3055
|
-
* type({ location: latLngPointType });
|
|
3056
|
-
* ```
|
|
3057
|
-
*/ var latLngPointType = arktype.type({
|
|
3058
|
-
lat: '-90 <= number <= 90',
|
|
3059
|
-
lng: '-180 <= number <= 180'
|
|
3060
|
-
}).narrow(function(val, ctx) {
|
|
3061
|
-
return val != null && util.isValidLatLngPoint(val) || ctx.mustBe('a valid LatLngPoint with lat in [-90, 90] and lng in [-180, 180]');
|
|
3062
|
-
});
|
|
3063
|
-
/**
|
|
3064
|
-
* ArkType schema for a valid {@link LatLngString} (comma-separated lat/lng, e.g. "30.5,-96.3").
|
|
3065
|
-
*
|
|
3066
|
-
* @dbxUtil
|
|
3067
|
-
* @dbxUtilCategory validator
|
|
3068
|
-
* @dbxUtilKind const
|
|
3069
|
-
* @dbxUtilTags validator, arktype, lat-lng, geo, coordinates, string
|
|
3070
|
-
* @dbxUtilRelated lat-lng-point-type
|
|
3071
|
-
*
|
|
3072
|
-
* @example
|
|
3073
|
-
* ```ts
|
|
3074
|
-
* type({ location: latLngStringType });
|
|
3075
|
-
* ```
|
|
3076
|
-
*/ var latLngStringType = arktype.type('string > 0').narrow(function(val, ctx) {
|
|
3077
|
-
return val != null && util.isLatLngString(val) || ctx.mustBe('a valid lat,lng string (e.g. "30.5,-96.3")');
|
|
3078
|
-
});
|
|
3079
|
-
|
|
3080
|
-
/**
|
|
3081
|
-
* A string with at least one character (non-empty).
|
|
3082
|
-
*
|
|
3083
|
-
* @dbxUtil
|
|
3084
|
-
* @dbxUtilCategory validator
|
|
3085
|
-
* @dbxUtilKind const
|
|
3086
|
-
* @dbxUtilTags validator, arktype, string, non-empty, required
|
|
3087
|
-
* @dbxUtilRelated email-string, non-empty-string-with-max-length
|
|
3088
|
-
*
|
|
3089
|
-
* @example
|
|
3090
|
-
* ```ts
|
|
3091
|
-
* type({ name: NON_EMPTY_STRING });
|
|
3092
|
-
* ```
|
|
3093
|
-
*/ var NON_EMPTY_STRING = 'string > 0';
|
|
3094
|
-
/**
|
|
3095
|
-
* A valid email address string.
|
|
3096
|
-
*
|
|
3097
|
-
* @dbxUtil
|
|
3098
|
-
* @dbxUtilCategory validator
|
|
3099
|
-
* @dbxUtilKind const
|
|
3100
|
-
* @dbxUtilTags validator, arktype, string, email
|
|
3101
|
-
*
|
|
3102
|
-
* @example
|
|
3103
|
-
* ```ts
|
|
3104
|
-
* type({ email: EMAIL_STRING });
|
|
3105
|
-
* ```
|
|
3106
|
-
*/ var EMAIL_STRING = 'string.email';
|
|
3107
|
-
/**
|
|
3108
|
-
* Creates an ArkType string definition for a non-empty string with a maximum length.
|
|
3109
|
-
*
|
|
3110
|
-
* Composes {@link NON_EMPTY_STRING} with an upper-bound length constraint, producing a
|
|
3111
|
-
* DSL fragment that can be interpolated directly into an ArkType `type({ ... })` schema.
|
|
3112
|
-
*
|
|
3113
|
-
* @param maxLength - The maximum number of characters allowed (inclusive).
|
|
3114
|
-
* @returns The ArkType string definition.
|
|
3115
|
-
*
|
|
3116
|
-
* @dbxUtil
|
|
3117
|
-
* @dbxUtilCategory validator
|
|
3118
|
-
* @dbxUtilKind factory
|
|
3119
|
-
* @dbxUtilTags validator, arktype, string, non-empty, max-length, bounded
|
|
3120
|
-
* @dbxUtilRelated non-empty-string
|
|
3121
|
-
*
|
|
3122
|
-
* @example
|
|
3123
|
-
* ```ts
|
|
3124
|
-
* const userType = type({
|
|
3125
|
-
* displayName: nonEmptyStringWithMaxLength(64)
|
|
3126
|
-
* });
|
|
3127
|
-
* ```
|
|
3128
|
-
*
|
|
3129
|
-
* @__NO_SIDE_EFFECTS__
|
|
3130
|
-
*/ function nonEmptyStringWithMaxLength(maxLength) {
|
|
3131
|
-
return "".concat(NON_EMPTY_STRING, " & string <= ").concat(maxLength);
|
|
3132
|
-
}
|
|
3133
|
-
|
|
3134
|
-
/**
|
|
3135
|
-
* Creates an ArkType schema that validates an array has no duplicate keys.
|
|
3136
|
-
*
|
|
3137
|
-
* @param readKey - Function that extracts the key from each array element.
|
|
3138
|
-
* @returns An ArkType schema that narrows `T[]` to ensure uniqueness.
|
|
3139
|
-
*
|
|
3140
|
-
* @dbxUtil
|
|
3141
|
-
* @dbxUtilCategory validator
|
|
3142
|
-
* @dbxUtilKind factory
|
|
3143
|
-
* @dbxUtilTags validator, arktype, array, unique, uniqueness, keyed
|
|
3144
|
-
*
|
|
3145
|
-
* @example
|
|
3146
|
-
* ```typescript
|
|
3147
|
-
* const uniqueItemsType = uniqueKeyedType((item: Item) => item.id);
|
|
3148
|
-
* ```
|
|
3149
|
-
*
|
|
3150
|
-
* @__NO_SIDE_EFFECTS__
|
|
3151
|
-
*/ function uniqueKeyedType(readKey) {
|
|
3152
|
-
var isUniqueKeyed = util.isUniqueKeyedFunction(readKey);
|
|
3153
|
-
return arktype.type('unknown[]').narrow(function(val, ctx) {
|
|
3154
|
-
return val != null && isUniqueKeyed(val) || ctx.mustBe('an array with unique keys');
|
|
3155
|
-
});
|
|
3156
|
-
}
|
|
3157
|
-
|
|
3158
|
-
/**
|
|
3159
|
-
* ArkType schema for a valid website URL (with or without protocol prefix).
|
|
3160
|
-
*
|
|
3161
|
-
* @dbxUtil
|
|
3162
|
-
* @dbxUtilCategory validator
|
|
3163
|
-
* @dbxUtilKind const
|
|
3164
|
-
* @dbxUtilTags validator, arktype, url, website, string
|
|
3165
|
-
* @dbxUtilRelated website-url-with-prefix-type
|
|
3166
|
-
*
|
|
3167
|
-
* @example
|
|
3168
|
-
* ```ts
|
|
3169
|
-
* type({ website: websiteUrlType });
|
|
3170
|
-
* ```
|
|
3171
|
-
*/ var websiteUrlType = arktype.type('string > 0').narrow(function(val, ctx) {
|
|
3172
|
-
return val != null && util.isWebsiteUrl(val) || ctx.mustBe('a valid website URL');
|
|
3173
|
-
});
|
|
3174
|
-
/**
|
|
3175
|
-
* ArkType schema for a valid website URL that starts with `http://` or `https://`.
|
|
3176
|
-
*
|
|
3177
|
-
* @dbxUtil
|
|
3178
|
-
* @dbxUtilCategory validator
|
|
3179
|
-
* @dbxUtilKind const
|
|
3180
|
-
* @dbxUtilTags validator, arktype, url, website, prefix, https, string
|
|
3181
|
-
* @dbxUtilRelated website-url-type
|
|
3182
|
-
*
|
|
3183
|
-
* @example
|
|
3184
|
-
* ```ts
|
|
3185
|
-
* type({ website: websiteUrlWithPrefixType });
|
|
3186
|
-
* ```
|
|
3187
|
-
*/ var websiteUrlWithPrefixType = arktype.type('string > 0').narrow(function(val, ctx) {
|
|
3188
|
-
return val != null && util.isWebsiteUrlWithPrefix(val) || ctx.mustBe('a valid website URL starting with http:// or https://');
|
|
3189
|
-
});
|
|
3190
|
-
|
|
3191
|
-
exports.ADDRESS_CITY_MAX_LENGTH = ADDRESS_CITY_MAX_LENGTH;
|
|
3192
|
-
exports.ADDRESS_COUNTRY_MAX_LENGTH = ADDRESS_COUNTRY_MAX_LENGTH;
|
|
3193
|
-
exports.ADDRESS_LINE_MAX_LENGTH = ADDRESS_LINE_MAX_LENGTH;
|
|
3194
|
-
exports.ADDRESS_STATE_CODE_MAX_LENGTH = ADDRESS_STATE_CODE_MAX_LENGTH;
|
|
3195
|
-
exports.ADDRESS_STATE_MAX_LENGTH = ADDRESS_STATE_MAX_LENGTH;
|
|
3196
|
-
exports.ADDRESS_ZIP_MAX_LENGTH = ADDRESS_ZIP_MAX_LENGTH;
|
|
3197
|
-
exports.ARKTYPE_DATE_DTO_TYPE = ARKTYPE_DATE_DTO_TYPE;
|
|
3198
|
-
exports.AbstractModelPermissionService = AbstractModelPermissionService;
|
|
3199
|
-
exports.CASHAPP_BASE_URL = CASHAPP_BASE_URL;
|
|
3200
|
-
exports.CASHAPP_USERNAME_PREFIX = CASHAPP_USERNAME_PREFIX;
|
|
3201
|
-
exports.CASHAPP_WEBSITE_LINK_TYPE = CASHAPP_WEBSITE_LINK_TYPE;
|
|
3202
|
-
exports.EMAIL_STRING = EMAIL_STRING;
|
|
3203
|
-
exports.EMAIL_URL_WEBSITE_LINK_TYPE = EMAIL_URL_WEBSITE_LINK_TYPE;
|
|
3204
|
-
exports.EMPTY_ARKTYPE_TYPE = EMPTY_ARKTYPE_TYPE;
|
|
3205
|
-
exports.FACEBOOK_BASE_URL = FACEBOOK_BASE_URL;
|
|
3206
|
-
exports.FACEBOOK_WEBSITE_LINK_TYPE = FACEBOOK_WEBSITE_LINK_TYPE;
|
|
3207
|
-
exports.FULL_ACCESS_ROLE_KEY = FULL_ACCESS_ROLE_KEY;
|
|
3208
|
-
exports.GRANTED_ADMIN_ROLE_KEY = GRANTED_ADMIN_ROLE_KEY;
|
|
3209
|
-
exports.GRANTED_DELETE_ROLE_KEY = GRANTED_DELETE_ROLE_KEY;
|
|
3210
|
-
exports.GRANTED_OWNER_ROLE_KEY = GRANTED_OWNER_ROLE_KEY;
|
|
3211
|
-
exports.GRANTED_READ_ROLE_KEY = GRANTED_READ_ROLE_KEY;
|
|
3212
|
-
exports.GRANTED_SYS_ADMIN_ROLE_KEY = GRANTED_SYS_ADMIN_ROLE_KEY;
|
|
3213
|
-
exports.GRANTED_UPDATE_ROLE_KEY = GRANTED_UPDATE_ROLE_KEY;
|
|
3214
|
-
exports.GrantedRoleMapReaderInstance = GrantedRoleMapReaderInstance;
|
|
3215
|
-
exports.INSTAGRAM_BASE_URL = INSTAGRAM_BASE_URL;
|
|
3216
|
-
exports.INSTAGRAM_WEBSITE_LINK_TYPE = INSTAGRAM_WEBSITE_LINK_TYPE;
|
|
3217
|
-
exports.NON_EMPTY_STRING = NON_EMPTY_STRING;
|
|
3218
|
-
exports.NON_NEGATIVE_INTEGER = NON_NEGATIVE_INTEGER;
|
|
3219
|
-
exports.NON_NEGATIVE_NUMBER = NON_NEGATIVE_NUMBER;
|
|
3220
|
-
exports.NO_ACCESS_ROLE_KEY = NO_ACCESS_ROLE_KEY;
|
|
3221
|
-
exports.PAYPAL_BASE_URL = PAYPAL_BASE_URL;
|
|
3222
|
-
exports.PAYPAL_WEBSITE_LINK_TYPE = PAYPAL_WEBSITE_LINK_TYPE;
|
|
3223
|
-
exports.PHONE_URL_WEBSITE_LINK_TYPE = PHONE_URL_WEBSITE_LINK_TYPE;
|
|
3224
|
-
exports.SNAPCHAT_BASE_URL = SNAPCHAT_BASE_URL;
|
|
3225
|
-
exports.SNAPCHAT_WEBSITE_LINK_ISOLATE_PROFILE_ID = SNAPCHAT_WEBSITE_LINK_ISOLATE_PROFILE_ID;
|
|
3226
|
-
exports.SNAPCHAT_WEBSITE_LINK_TYPE = SNAPCHAT_WEBSITE_LINK_TYPE;
|
|
3227
|
-
exports.SPOTIFY_BASE_URL = SPOTIFY_BASE_URL;
|
|
3228
|
-
exports.SPOTIFY_WEBSITE_LINK_ISOLATE_PROFILE_ID = SPOTIFY_WEBSITE_LINK_ISOLATE_PROFILE_ID;
|
|
3229
|
-
exports.SPOTIFY_WEBSITE_LINK_TYPE = SPOTIFY_WEBSITE_LINK_TYPE;
|
|
3230
|
-
exports.TIKTOK_BASE_URL = TIKTOK_BASE_URL;
|
|
3231
|
-
exports.TIKTOK_USERNAME_PREFIX = TIKTOK_USERNAME_PREFIX;
|
|
3232
|
-
exports.TIKTOK_WEBSITE_LINK_TYPE = TIKTOK_WEBSITE_LINK_TYPE;
|
|
3233
|
-
exports.TWITTER_BASE_URL = TWITTER_BASE_URL;
|
|
3234
|
-
exports.TWITTER_WEBSITE_LINK_TYPE = TWITTER_WEBSITE_LINK_TYPE;
|
|
3235
|
-
exports.UNKNOWN_WEBSITE_LINK_TYPE = UNKNOWN_WEBSITE_LINK_TYPE;
|
|
3236
|
-
exports.VENMO_BASE_URL = VENMO_BASE_URL;
|
|
3237
|
-
exports.VENMO_WEBSITE_LINK_ISOLATE_PROFILE_ID = VENMO_WEBSITE_LINK_ISOLATE_PROFILE_ID;
|
|
3238
|
-
exports.VENMO_WEBSITE_LINK_TYPE = VENMO_WEBSITE_LINK_TYPE;
|
|
3239
|
-
exports.WEBSITE_FILE_LINK_DATA_MAX_LENGTH = WEBSITE_FILE_LINK_DATA_MAX_LENGTH;
|
|
3240
|
-
exports.WEBSITE_FILE_LINK_DATA_REGEX = WEBSITE_FILE_LINK_DATA_REGEX;
|
|
3241
|
-
exports.WEBSITE_FILE_LINK_ENCODE_SEPARATOR = WEBSITE_FILE_LINK_ENCODE_SEPARATOR;
|
|
3242
|
-
exports.WEBSITE_FILE_LINK_MIME_TYPE_MAX_LENGTH = WEBSITE_FILE_LINK_MIME_TYPE_MAX_LENGTH;
|
|
3243
|
-
exports.WEBSITE_FILE_LINK_MIME_TYPE_REGEX = WEBSITE_FILE_LINK_MIME_TYPE_REGEX;
|
|
3244
|
-
exports.WEBSITE_FILE_LINK_NAME_MAX_LENGTH = WEBSITE_FILE_LINK_NAME_MAX_LENGTH;
|
|
3245
|
-
exports.WEBSITE_FILE_LINK_TYPE_MAX_LENGTH = WEBSITE_FILE_LINK_TYPE_MAX_LENGTH;
|
|
3246
|
-
exports.WEBSITE_FILE_LINK_TYPE_REGEX = WEBSITE_FILE_LINK_TYPE_REGEX;
|
|
3247
|
-
exports.WEBSITE_FILE_LINK_WEBSITE_LINK_TYPE = WEBSITE_FILE_LINK_WEBSITE_LINK_TYPE;
|
|
3248
|
-
exports.WEBSITE_LINK_ENCODED_DATA_MAX_LENGTH = WEBSITE_LINK_ENCODED_DATA_MAX_LENGTH;
|
|
3249
|
-
exports.WEBSITE_LINK_ISOLATE_BASE_URL_PROFILE_ID = WEBSITE_LINK_ISOLATE_BASE_URL_PROFILE_ID;
|
|
3250
|
-
exports.WEBSITE_LINK_TYPE_MAX_LENGTH = WEBSITE_LINK_TYPE_MAX_LENGTH;
|
|
3251
|
-
exports.WEBSITE_LINK_TYPE_REGEX = WEBSITE_LINK_TYPE_REGEX;
|
|
3252
|
-
exports.WEBSITE_URL_WEBSITE_LINK_TYPE = WEBSITE_URL_WEBSITE_LINK_TYPE;
|
|
3253
|
-
exports.YOUTUBE_BASE_URL = YOUTUBE_BASE_URL;
|
|
3254
|
-
exports.YOUTUBE_WEBSITE_LINK_ISOLATE_PROFILE_ID = YOUTUBE_WEBSITE_LINK_ISOLATE_PROFILE_ID;
|
|
3255
|
-
exports.YOUTUBE_WEBSITE_LINK_TYPE = YOUTUBE_WEBSITE_LINK_TYPE;
|
|
3256
|
-
exports.arktypeToJsonSchemaForExport = arktypeToJsonSchemaForExport;
|
|
3257
|
-
exports.basicSyncEntityCommonTypeSynchronizerInstanceFactory = basicSyncEntityCommonTypeSynchronizerInstanceFactory;
|
|
3258
|
-
exports.cashappProfileUrl = cashappProfileUrl;
|
|
3259
|
-
exports.cashappProfileUrlToWebsiteLink = cashappProfileUrlToWebsiteLink;
|
|
3260
|
-
exports.clearable = clearable;
|
|
3261
|
-
exports.contextGrantedModelRoles = contextGrantedModelRoles;
|
|
3262
|
-
exports.decodeWebsiteLinkEncodedDataToWebsiteFileLink = decodeWebsiteLinkEncodedDataToWebsiteFileLink;
|
|
3263
|
-
exports.e164PhoneNumberType = e164PhoneNumberType;
|
|
3264
|
-
exports.e164PhoneNumberWithExtensionType = e164PhoneNumberWithExtensionType;
|
|
3265
|
-
exports.e164PhoneNumberWithOptionalExtensionType = e164PhoneNumberWithOptionalExtensionType;
|
|
3266
|
-
exports.emailAddressToWebsiteLink = emailAddressToWebsiteLink;
|
|
3267
|
-
exports.emptyType = emptyType;
|
|
3268
|
-
exports.encodeWebsiteFileLinkToWebsiteLinkEncodedData = encodeWebsiteFileLinkToWebsiteLinkEncodedData;
|
|
3269
|
-
exports.facebookProfileUrl = facebookProfileUrl;
|
|
3270
|
-
exports.facebookProfileUrlToWebsiteLink = facebookProfileUrlToWebsiteLink;
|
|
3271
|
-
exports.fullAccessGrantedModelRoles = fullAccessGrantedModelRoles;
|
|
3272
|
-
exports.fullAccessRoleMap = fullAccessRoleMap;
|
|
3273
|
-
exports.grantedRoleKeysMapFromArray = grantedRoleKeysMapFromArray;
|
|
3274
|
-
exports.grantedRoleMapReader = grantedRoleMapReader;
|
|
3275
|
-
exports.instagramProfileUrl = instagramProfileUrl;
|
|
3276
|
-
exports.instagramProfileUrlToWebsiteLink = instagramProfileUrlToWebsiteLink;
|
|
3277
|
-
exports.isFullAccessRoleMap = isFullAccessRoleMap;
|
|
3278
|
-
exports.isGrantedAdminLevelRole = isGrantedAdminLevelRole;
|
|
3279
|
-
exports.isNoAccessRoleMap = isNoAccessRoleMap;
|
|
3280
|
-
exports.isValidWebsiteLinkType = isValidWebsiteLinkType;
|
|
3281
|
-
exports.iso8601DayStringType = iso8601DayStringType;
|
|
3282
|
-
exports.latLngPointType = latLngPointType;
|
|
3283
|
-
exports.latLngStringType = latLngStringType;
|
|
3284
|
-
exports.minuteOfDayType = minuteOfDayType;
|
|
3285
|
-
exports.modelIdType = modelIdType;
|
|
3286
|
-
exports.modelKeyType = modelKeyType;
|
|
3287
|
-
exports.noAccessContextGrantedModelRoles = noAccessContextGrantedModelRoles;
|
|
3288
|
-
exports.noAccessRoleMap = noAccessRoleMap;
|
|
3289
|
-
exports.nonEmptyStringWithMaxLength = nonEmptyStringWithMaxLength;
|
|
3290
|
-
exports.paypalProfileUrl = paypalProfileUrl;
|
|
3291
|
-
exports.paypalProfileUrlToWebsiteLink = paypalProfileUrlToWebsiteLink;
|
|
3292
|
-
exports.phoneNumberToWebsiteLink = phoneNumberToWebsiteLink;
|
|
3293
|
-
exports.pruneFalseUnionBranches = pruneFalseUnionBranches;
|
|
3294
|
-
exports.snapchatProfileUrl = snapchatProfileUrl;
|
|
3295
|
-
exports.snapchatProfileUrlToWebsiteLink = snapchatProfileUrlToWebsiteLink;
|
|
3296
|
-
exports.spotifyProfileUrl = spotifyProfileUrl;
|
|
3297
|
-
exports.spotifyProfileUrlToWebsiteLink = spotifyProfileUrlToWebsiteLink;
|
|
3298
|
-
exports.syncEntityCommonTypeIdPairFactory = syncEntityCommonTypeIdPairFactory;
|
|
3299
|
-
exports.syncEntityFactory = syncEntityFactory;
|
|
3300
|
-
exports.syncEntitySynchronizer = syncEntitySynchronizer;
|
|
3301
|
-
exports.targetModelIdParamsType = targetModelIdParamsType;
|
|
3302
|
-
exports.targetModelParamsType = targetModelParamsType;
|
|
3303
|
-
exports.tiktokProfileUrl = tiktokProfileUrl;
|
|
3304
|
-
exports.tiktokProfileUrlToWebsiteLink = tiktokProfileUrlToWebsiteLink;
|
|
3305
|
-
exports.toTransformAndValidateFunctionResult = toTransformAndValidateFunctionResult;
|
|
3306
|
-
exports.toTransformAndValidateFunctionResultFactory = toTransformAndValidateFunctionResultFactory;
|
|
3307
|
-
exports.transformAndValidateFunctionResultFactory = transformAndValidateFunctionResultFactory;
|
|
3308
|
-
exports.transformAndValidateObject = transformAndValidateObject;
|
|
3309
|
-
exports.transformAndValidateObjectFactory = transformAndValidateObjectFactory;
|
|
3310
|
-
exports.transformAndValidateObjectResult = transformAndValidateObjectResult;
|
|
3311
|
-
exports.transformAndValidateResultFactory = transformAndValidateResultFactory;
|
|
3312
|
-
exports.twitterProfileUrl = twitterProfileUrl;
|
|
3313
|
-
exports.twitterProfileUrlToWebsiteLink = twitterProfileUrlToWebsiteLink;
|
|
3314
|
-
exports.uniqueKeyedType = uniqueKeyedType;
|
|
3315
|
-
exports.unitedStatesAddressWithStateCodeType = unitedStatesAddressWithStateCodeType;
|
|
3316
|
-
exports.unitedStatesAddressWithStateStringType = unitedStatesAddressWithStateStringType;
|
|
3317
|
-
exports.usernameFromUsernameOrWebsiteWithBaseUrlUsername = usernameFromUsernameOrWebsiteWithBaseUrlUsername;
|
|
3318
|
-
exports.usernameFromUsernameOrWebsiteWithOneOffBaseUrlUsername = usernameFromUsernameOrWebsiteWithOneOffBaseUrlUsername;
|
|
3319
|
-
exports.usernameOrWebsiteUrlToWebsiteUrl = usernameOrWebsiteUrlToWebsiteUrl;
|
|
3320
|
-
exports.venmoProfileUrl = venmoProfileUrl;
|
|
3321
|
-
exports.venmoProfileUrlToWebsiteLink = venmoProfileUrlToWebsiteLink;
|
|
3322
|
-
exports.websiteFileLinkToWebsiteLink = websiteFileLinkToWebsiteLink;
|
|
3323
|
-
exports.websiteFileLinkType = websiteFileLinkType;
|
|
3324
|
-
exports.websiteLinkToWebsiteLinkFile = websiteLinkToWebsiteLinkFile;
|
|
3325
|
-
exports.websiteLinkType = websiteLinkType;
|
|
3326
|
-
exports.websiteUrlToWebsiteLink = websiteUrlToWebsiteLink;
|
|
3327
|
-
exports.websiteUrlType = websiteUrlType;
|
|
3328
|
-
exports.websiteUrlWithPrefixType = websiteUrlWithPrefixType;
|
|
3329
|
-
exports.youtubeProfileUrl = youtubeProfileUrl;
|
|
3330
|
-
exports.youtubeProfileUrlToWebsiteLink = youtubeProfileUrlToWebsiteLink;
|