@dereekb/model 13.2.1 → 13.3.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/index.cjs.js +1857 -600
- package/index.esm.js +1858 -602
- package/package.json +2 -2
- package/src/lib/type/date.d.ts +11 -0
- package/src/lib/type/index.d.ts +1 -0
- package/index.cjs.js.map +0 -1
- package/index.esm.js.map +0 -1
package/index.cjs.js
CHANGED
|
@@ -6,62 +6,58 @@ var makeError = require('make-error');
|
|
|
6
6
|
|
|
7
7
|
/**
|
|
8
8
|
* Maximum character length for address line fields (line1, line2).
|
|
9
|
-
*/
|
|
10
|
-
const ADDRESS_LINE_MAX_LENGTH = 50;
|
|
9
|
+
*/ var ADDRESS_LINE_MAX_LENGTH = 50;
|
|
11
10
|
/**
|
|
12
11
|
* Maximum character length for city names.
|
|
13
|
-
*/
|
|
14
|
-
const ADDRESS_CITY_MAX_LENGTH = 80;
|
|
12
|
+
*/ var ADDRESS_CITY_MAX_LENGTH = 80;
|
|
15
13
|
/**
|
|
16
14
|
* Maximum character length for full state names (e.g., "Texas").
|
|
17
|
-
*/
|
|
18
|
-
const ADDRESS_STATE_MAX_LENGTH = 30;
|
|
15
|
+
*/ var ADDRESS_STATE_MAX_LENGTH = 30;
|
|
19
16
|
/**
|
|
20
17
|
* Maximum character length for two-letter state codes (e.g., "TX").
|
|
21
|
-
*/
|
|
22
|
-
const ADDRESS_STATE_CODE_MAX_LENGTH = 2;
|
|
18
|
+
*/ var ADDRESS_STATE_CODE_MAX_LENGTH = 2;
|
|
23
19
|
/**
|
|
24
20
|
* Maximum character length for ZIP codes, accommodating ZIP+4 format (e.g., "77834-1234").
|
|
25
|
-
*/
|
|
26
|
-
const ADDRESS_ZIP_MAX_LENGTH = 11;
|
|
21
|
+
*/ var ADDRESS_ZIP_MAX_LENGTH = 11;
|
|
27
22
|
/**
|
|
28
23
|
* Maximum character length for country names.
|
|
29
|
-
*/
|
|
30
|
-
const ADDRESS_COUNTRY_MAX_LENGTH = 80;
|
|
24
|
+
*/ var ADDRESS_COUNTRY_MAX_LENGTH = 80;
|
|
31
25
|
/**
|
|
32
26
|
* Base ArkType schema for United States address fields without the state.
|
|
33
|
-
*/
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
27
|
+
*/ var baseUnitedStatesAddressType = arktype.type({
|
|
28
|
+
line1: "0 < string <= ".concat(ADDRESS_LINE_MAX_LENGTH),
|
|
29
|
+
'line2?': "string <= ".concat(ADDRESS_LINE_MAX_LENGTH),
|
|
30
|
+
city: "0 < string <= ".concat(ADDRESS_CITY_MAX_LENGTH),
|
|
31
|
+
zip: [
|
|
32
|
+
/^\d{5}(-\d{4})?$/,
|
|
33
|
+
'&',
|
|
34
|
+
"string <= ".concat(ADDRESS_ZIP_MAX_LENGTH)
|
|
35
|
+
]
|
|
39
36
|
});
|
|
40
37
|
/**
|
|
41
38
|
* ArkType schema for a United States address with a two-letter state code (e.g., "TX").
|
|
42
|
-
*/
|
|
43
|
-
|
|
44
|
-
|
|
39
|
+
*/ var unitedStatesAddressWithStateCodeType = baseUnitedStatesAddressType.merge({
|
|
40
|
+
state: [
|
|
41
|
+
util.US_STATE_CODE_STRING_REGEX,
|
|
42
|
+
'&',
|
|
43
|
+
"".concat(ADDRESS_STATE_CODE_MAX_LENGTH, " <= string <= ").concat(ADDRESS_STATE_CODE_MAX_LENGTH)
|
|
44
|
+
]
|
|
45
45
|
});
|
|
46
46
|
/**
|
|
47
47
|
* ArkType schema for a United States address with a full state name (e.g., "Texas").
|
|
48
|
-
*/
|
|
49
|
-
|
|
50
|
-
state: `0 < string <= ${ADDRESS_STATE_MAX_LENGTH}`
|
|
48
|
+
*/ var unitedStatesAddressWithStateStringType = baseUnitedStatesAddressType.merge({
|
|
49
|
+
state: "0 < string <= ".concat(ADDRESS_STATE_MAX_LENGTH)
|
|
51
50
|
});
|
|
52
51
|
|
|
53
52
|
/**
|
|
54
53
|
* Fallback link type used when the actual type is not known.
|
|
55
|
-
*/
|
|
56
|
-
const UNKNOWN_WEBSITE_LINK_TYPE = 'u';
|
|
54
|
+
*/ var UNKNOWN_WEBSITE_LINK_TYPE = 'u';
|
|
57
55
|
/**
|
|
58
56
|
* Maximum character length for a {@link WebsiteLinkType} string.
|
|
59
|
-
*/
|
|
60
|
-
const WEBSITE_LINK_TYPE_MAX_LENGTH = 32;
|
|
57
|
+
*/ var WEBSITE_LINK_TYPE_MAX_LENGTH = 32;
|
|
61
58
|
/**
|
|
62
59
|
* Regex pattern that validates a {@link WebsiteLinkType} as 1-32 alphanumeric characters.
|
|
63
|
-
*/
|
|
64
|
-
const WEBSITE_LINK_TYPE_REGEX = /^[a-zA-Z0-9]{1,32}$/;
|
|
60
|
+
*/ var WEBSITE_LINK_TYPE_REGEX = /^[a-zA-Z0-9]{1,32}$/;
|
|
65
61
|
/**
|
|
66
62
|
* Checks whether the given string is a valid {@link WebsiteLinkType}.
|
|
67
63
|
*
|
|
@@ -74,64 +70,114 @@ const WEBSITE_LINK_TYPE_REGEX = /^[a-zA-Z0-9]{1,32}$/;
|
|
|
74
70
|
* isValidWebsiteLinkType(''); // false
|
|
75
71
|
* isValidWebsiteLinkType('a-b'); // false (hyphen not allowed)
|
|
76
72
|
* ```
|
|
77
|
-
*/
|
|
78
|
-
function isValidWebsiteLinkType(input) {
|
|
73
|
+
*/ function isValidWebsiteLinkType(input) {
|
|
79
74
|
return WEBSITE_LINK_TYPE_REGEX.test(input);
|
|
80
75
|
}
|
|
81
76
|
/**
|
|
82
77
|
* Maximum character length for the encoded data string in a {@link WebsiteLink}.
|
|
83
|
-
*/
|
|
84
|
-
const WEBSITE_LINK_ENCODED_DATA_MAX_LENGTH = 1000;
|
|
78
|
+
*/ var WEBSITE_LINK_ENCODED_DATA_MAX_LENGTH = 1000;
|
|
85
79
|
/**
|
|
86
80
|
* ArkType schema for a {@link WebsiteLink}.
|
|
87
|
-
*/
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
81
|
+
*/ var websiteLinkType = arktype.type({
|
|
82
|
+
t: [
|
|
83
|
+
WEBSITE_LINK_TYPE_REGEX,
|
|
84
|
+
'&',
|
|
85
|
+
"0 < string <= ".concat(WEBSITE_LINK_TYPE_MAX_LENGTH)
|
|
86
|
+
],
|
|
87
|
+
d: "0 < string <= ".concat(WEBSITE_LINK_ENCODED_DATA_MAX_LENGTH)
|
|
91
88
|
});
|
|
92
89
|
|
|
90
|
+
function _array_like_to_array$2(arr, len) {
|
|
91
|
+
if (len == null || len > arr.length) len = arr.length;
|
|
92
|
+
for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
|
|
93
|
+
return arr2;
|
|
94
|
+
}
|
|
95
|
+
function _array_with_holes$2(arr) {
|
|
96
|
+
if (Array.isArray(arr)) return arr;
|
|
97
|
+
}
|
|
98
|
+
function _iterable_to_array_limit$2(arr, i) {
|
|
99
|
+
var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"];
|
|
100
|
+
if (_i == null) return;
|
|
101
|
+
var _arr = [];
|
|
102
|
+
var _n = true;
|
|
103
|
+
var _d = false;
|
|
104
|
+
var _s, _e;
|
|
105
|
+
try {
|
|
106
|
+
for(_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true){
|
|
107
|
+
_arr.push(_s.value);
|
|
108
|
+
if (i && _arr.length === i) break;
|
|
109
|
+
}
|
|
110
|
+
} catch (err) {
|
|
111
|
+
_d = true;
|
|
112
|
+
_e = err;
|
|
113
|
+
} finally{
|
|
114
|
+
try {
|
|
115
|
+
if (!_n && _i["return"] != null) _i["return"]();
|
|
116
|
+
} finally{
|
|
117
|
+
if (_d) throw _e;
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
return _arr;
|
|
121
|
+
}
|
|
122
|
+
function _non_iterable_rest$2() {
|
|
123
|
+
throw new TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
124
|
+
}
|
|
125
|
+
function _sliced_to_array$2(arr, i) {
|
|
126
|
+
return _array_with_holes$2(arr) || _iterable_to_array_limit$2(arr, i) || _unsupported_iterable_to_array$2(arr, i) || _non_iterable_rest$2();
|
|
127
|
+
}
|
|
128
|
+
function _unsupported_iterable_to_array$2(o, minLen) {
|
|
129
|
+
if (!o) return;
|
|
130
|
+
if (typeof o === "string") return _array_like_to_array$2(o, minLen);
|
|
131
|
+
var n = Object.prototype.toString.call(o).slice(8, -1);
|
|
132
|
+
if (n === "Object" && o.constructor) n = o.constructor.name;
|
|
133
|
+
if (n === "Map" || n === "Set") return Array.from(n);
|
|
134
|
+
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array$2(o, minLen);
|
|
135
|
+
}
|
|
93
136
|
/**
|
|
94
137
|
* Maximum character length for a {@link WebsiteFileLinkType}. Matches {@link WEBSITE_LINK_TYPE_MAX_LENGTH}.
|
|
95
|
-
*/
|
|
96
|
-
const WEBSITE_FILE_LINK_TYPE_MAX_LENGTH = WEBSITE_LINK_TYPE_MAX_LENGTH;
|
|
138
|
+
*/ var WEBSITE_FILE_LINK_TYPE_MAX_LENGTH = WEBSITE_LINK_TYPE_MAX_LENGTH;
|
|
97
139
|
/**
|
|
98
140
|
* Validation regex for {@link WebsiteFileLinkType}. Matches {@link WEBSITE_LINK_TYPE_REGEX}.
|
|
99
|
-
*/
|
|
100
|
-
const WEBSITE_FILE_LINK_TYPE_REGEX = WEBSITE_LINK_TYPE_REGEX;
|
|
141
|
+
*/ var WEBSITE_FILE_LINK_TYPE_REGEX = WEBSITE_LINK_TYPE_REGEX;
|
|
101
142
|
/**
|
|
102
143
|
* Maximum character length for a {@link WebsiteFileLinkMimeType}.
|
|
103
|
-
*/
|
|
104
|
-
const WEBSITE_FILE_LINK_MIME_TYPE_MAX_LENGTH = 128;
|
|
144
|
+
*/ var WEBSITE_FILE_LINK_MIME_TYPE_MAX_LENGTH = 128;
|
|
105
145
|
/**
|
|
106
146
|
* Regex pattern that validates a MIME type string (e.g., "text/plain", "application/vnd.api+json").
|
|
107
|
-
*/
|
|
108
|
-
const WEBSITE_FILE_LINK_MIME_TYPE_REGEX = /^\w+\/[-+.\w]+$/;
|
|
147
|
+
*/ var WEBSITE_FILE_LINK_MIME_TYPE_REGEX = /^\w+\/[-+.\w]+$/;
|
|
109
148
|
/**
|
|
110
149
|
* Maximum character length for a {@link WebsiteFileLinkName}.
|
|
111
|
-
*/
|
|
112
|
-
const WEBSITE_FILE_LINK_NAME_MAX_LENGTH = 128;
|
|
150
|
+
*/ var WEBSITE_FILE_LINK_NAME_MAX_LENGTH = 128;
|
|
113
151
|
/**
|
|
114
152
|
* Maximum character length for {@link WebsiteFileLinkData}, derived from the total encoded data budget
|
|
115
153
|
* minus the separator characters, type, MIME type, and name fields.
|
|
116
|
-
*/
|
|
117
|
-
const 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;
|
|
154
|
+
*/ 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;
|
|
118
155
|
/**
|
|
119
156
|
* Regex pattern for file link data — disallows the pipe character since it is used as the encoding separator.
|
|
120
|
-
*/
|
|
121
|
-
const WEBSITE_FILE_LINK_DATA_REGEX = /^[^|]+$/;
|
|
157
|
+
*/ var WEBSITE_FILE_LINK_DATA_REGEX = /^[^|]+$/;
|
|
122
158
|
/**
|
|
123
159
|
* ArkType schema for a {@link WebsiteFileLink}.
|
|
124
|
-
*/
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
160
|
+
*/ var websiteFileLinkType = arktype.type({
|
|
161
|
+
'type?': [
|
|
162
|
+
WEBSITE_FILE_LINK_TYPE_REGEX,
|
|
163
|
+
'&',
|
|
164
|
+
"string <= ".concat(WEBSITE_LINK_TYPE_MAX_LENGTH)
|
|
165
|
+
],
|
|
166
|
+
'mime?': [
|
|
167
|
+
WEBSITE_FILE_LINK_MIME_TYPE_REGEX,
|
|
168
|
+
'&',
|
|
169
|
+
"string <= ".concat(WEBSITE_FILE_LINK_MIME_TYPE_MAX_LENGTH)
|
|
170
|
+
],
|
|
171
|
+
'name?': "string <= ".concat(WEBSITE_FILE_LINK_NAME_MAX_LENGTH),
|
|
172
|
+
data: [
|
|
173
|
+
WEBSITE_FILE_LINK_DATA_REGEX,
|
|
174
|
+
'&',
|
|
175
|
+
"0 < string <= ".concat(WEBSITE_FILE_LINK_DATA_MAX_LENGTH)
|
|
176
|
+
]
|
|
130
177
|
});
|
|
131
178
|
/**
|
|
132
179
|
* The {@link WebsiteLinkType} code used to identify a {@link WebsiteLink} as a file link.
|
|
133
|
-
*/
|
|
134
|
-
const WEBSITE_FILE_LINK_WEBSITE_LINK_TYPE = 'f';
|
|
180
|
+
*/ var WEBSITE_FILE_LINK_WEBSITE_LINK_TYPE = 'f';
|
|
135
181
|
/**
|
|
136
182
|
* Converts a {@link WebsiteFileLink} to a {@link WebsiteLink} by encoding its fields into the data string.
|
|
137
183
|
*
|
|
@@ -144,8 +190,7 @@ const WEBSITE_FILE_LINK_WEBSITE_LINK_TYPE = 'f';
|
|
|
144
190
|
* const link = websiteFileLinkToWebsiteLink(fileLink);
|
|
145
191
|
* // link.t === 'f'
|
|
146
192
|
* ```
|
|
147
|
-
*/
|
|
148
|
-
function websiteFileLinkToWebsiteLink(input) {
|
|
193
|
+
*/ function websiteFileLinkToWebsiteLink(input) {
|
|
149
194
|
return {
|
|
150
195
|
t: WEBSITE_FILE_LINK_WEBSITE_LINK_TYPE,
|
|
151
196
|
d: encodeWebsiteFileLinkToWebsiteLinkEncodedData(input)
|
|
@@ -163,15 +208,13 @@ function websiteFileLinkToWebsiteLink(input) {
|
|
|
163
208
|
* const fileLink = websiteLinkToWebsiteLinkFile(link);
|
|
164
209
|
* // fileLink.data === 'https://example.com/file.txt'
|
|
165
210
|
* ```
|
|
166
|
-
*/
|
|
167
|
-
|
|
168
|
-
const encodedData = input.d;
|
|
211
|
+
*/ function websiteLinkToWebsiteLinkFile(input) {
|
|
212
|
+
var encodedData = input.d;
|
|
169
213
|
return decodeWebsiteLinkEncodedDataToWebsiteFileLink(encodedData);
|
|
170
214
|
}
|
|
171
215
|
/**
|
|
172
216
|
* Separator character used when encoding/decoding file link fields into a single string.
|
|
173
|
-
*/
|
|
174
|
-
const WEBSITE_FILE_LINK_ENCODE_SEPARATOR = '|';
|
|
217
|
+
*/ var WEBSITE_FILE_LINK_ENCODE_SEPARATOR = '|';
|
|
175
218
|
/**
|
|
176
219
|
* Encodes a {@link WebsiteFileLink} into a pipe-separated string suitable for storage in a {@link WebsiteLink}'s data field.
|
|
177
220
|
*
|
|
@@ -190,9 +233,15 @@ const WEBSITE_FILE_LINK_ENCODE_SEPARATOR = '|';
|
|
|
190
233
|
* });
|
|
191
234
|
* // encoded === 't|test/test|https://example.com/|test-name'
|
|
192
235
|
* ```
|
|
193
|
-
*/
|
|
194
|
-
|
|
195
|
-
|
|
236
|
+
*/ function encodeWebsiteFileLinkToWebsiteLinkEncodedData(input) {
|
|
237
|
+
var encoded = [
|
|
238
|
+
input.type,
|
|
239
|
+
input.mime,
|
|
240
|
+
input.data,
|
|
241
|
+
input.name
|
|
242
|
+
].map(function(x) {
|
|
243
|
+
return x || '';
|
|
244
|
+
}).join(WEBSITE_FILE_LINK_ENCODE_SEPARATOR);
|
|
196
245
|
return encoded;
|
|
197
246
|
}
|
|
198
247
|
/**
|
|
@@ -211,14 +260,13 @@ function encodeWebsiteFileLinkToWebsiteLinkEncodedData(input) {
|
|
|
211
260
|
* // fileLink.data === 'https://example.com/'
|
|
212
261
|
* // fileLink.name === 'test-name'
|
|
213
262
|
* ```
|
|
214
|
-
*/
|
|
215
|
-
|
|
216
|
-
const [type, mime, data, name] = util.splitJoinRemainder(input, WEBSITE_FILE_LINK_ENCODE_SEPARATOR, 4);
|
|
263
|
+
*/ function decodeWebsiteLinkEncodedDataToWebsiteFileLink(input) {
|
|
264
|
+
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];
|
|
217
265
|
return util.filterFalsyAndEmptyValues({
|
|
218
|
-
type,
|
|
219
|
-
mime,
|
|
220
|
-
name,
|
|
221
|
-
data
|
|
266
|
+
type: _$type,
|
|
267
|
+
mime: mime,
|
|
268
|
+
name: name,
|
|
269
|
+
data: data
|
|
222
270
|
});
|
|
223
271
|
}
|
|
224
272
|
|
|
@@ -233,8 +281,7 @@ function decodeWebsiteLinkEncodedDataToWebsiteFileLink(input) {
|
|
|
233
281
|
* WEBSITE_LINK_ISOLATE_BASE_URL_PROFILE_ID('https://www.facebook.com/myuser');
|
|
234
282
|
* // returns 'myuser'
|
|
235
283
|
* ```
|
|
236
|
-
*/
|
|
237
|
-
const WEBSITE_LINK_ISOLATE_BASE_URL_PROFILE_ID = util.isolateWebsitePathFunction({
|
|
284
|
+
*/ var WEBSITE_LINK_ISOLATE_BASE_URL_PROFILE_ID = util.isolateWebsitePathFunction({
|
|
238
285
|
isolatePathComponents: 0,
|
|
239
286
|
removeTrailingSlash: true,
|
|
240
287
|
removeQueryParameters: true
|
|
@@ -256,13 +303,11 @@ const WEBSITE_LINK_ISOLATE_BASE_URL_PROFILE_ID = util.isolateWebsitePathFunction
|
|
|
256
303
|
* usernameFromUsernameOrWebsiteWithBaseUrlUsername('myuser', '@');
|
|
257
304
|
* // returns '@myuser'
|
|
258
305
|
* ```
|
|
259
|
-
*/
|
|
260
|
-
|
|
261
|
-
const username = util.toRelativeSlashPathStartType(WEBSITE_LINK_ISOLATE_BASE_URL_PROFILE_ID(usernameOrWebsiteUrlToWebsiteUrl(input)));
|
|
306
|
+
*/ function usernameFromUsernameOrWebsiteWithBaseUrlUsername(input, prefix) {
|
|
307
|
+
var username = util.toRelativeSlashPathStartType(WEBSITE_LINK_ISOLATE_BASE_URL_PROFILE_ID(usernameOrWebsiteUrlToWebsiteUrl(input)));
|
|
262
308
|
if (prefix) {
|
|
263
309
|
return util.addPrefix(prefix, username);
|
|
264
|
-
}
|
|
265
|
-
else {
|
|
310
|
+
} else {
|
|
266
311
|
return username;
|
|
267
312
|
}
|
|
268
313
|
}
|
|
@@ -274,8 +319,7 @@ function usernameFromUsernameOrWebsiteWithBaseUrlUsername(input, prefix) {
|
|
|
274
319
|
* @param input - a username or full profile URL
|
|
275
320
|
* @param isolateFn - custom function that extracts the relevant path segment from the URL
|
|
276
321
|
* @returns the isolated username
|
|
277
|
-
*/
|
|
278
|
-
function usernameFromUsernameOrWebsiteWithOneOffBaseUrlUsername(input, isolateFn) {
|
|
322
|
+
*/ function usernameFromUsernameOrWebsiteWithOneOffBaseUrlUsername(input, isolateFn) {
|
|
279
323
|
return util.toRelativeSlashPathStartType(isolateFn(usernameOrWebsiteUrlToWebsiteUrl(input)));
|
|
280
324
|
}
|
|
281
325
|
/**
|
|
@@ -285,15 +329,13 @@ function usernameFromUsernameOrWebsiteWithOneOffBaseUrlUsername(input, isolateFn
|
|
|
285
329
|
*
|
|
286
330
|
* @param input - a username or website URL
|
|
287
331
|
* @returns a normalized website URL
|
|
288
|
-
*/
|
|
289
|
-
function usernameOrWebsiteUrlToWebsiteUrl(input) {
|
|
332
|
+
*/ function usernameOrWebsiteUrlToWebsiteUrl(input) {
|
|
290
333
|
return util.hasWebsiteDomain(input) ? input : util.toAbsoluteSlashPathStartType(util.removeHttpFromUrl(input));
|
|
291
334
|
}
|
|
292
335
|
// MARK: Website
|
|
293
336
|
/**
|
|
294
337
|
* {@link WebsiteLinkType} code for generic website URLs.
|
|
295
|
-
*/
|
|
296
|
-
const WEBSITE_URL_WEBSITE_LINK_TYPE = 'w';
|
|
338
|
+
*/ var WEBSITE_URL_WEBSITE_LINK_TYPE = 'w';
|
|
297
339
|
/**
|
|
298
340
|
* Converts a generic website URL into a {@link WebsiteLink}, stripping the HTTP/HTTPS protocol.
|
|
299
341
|
*
|
|
@@ -305,8 +347,7 @@ const WEBSITE_URL_WEBSITE_LINK_TYPE = 'w';
|
|
|
305
347
|
* const link = websiteUrlToWebsiteLink('https://example.com/page');
|
|
306
348
|
* // link.t === 'w', link.d === 'example.com/page'
|
|
307
349
|
* ```
|
|
308
|
-
*/
|
|
309
|
-
function websiteUrlToWebsiteLink(input) {
|
|
350
|
+
*/ function websiteUrlToWebsiteLink(input) {
|
|
310
351
|
return {
|
|
311
352
|
t: WEBSITE_URL_WEBSITE_LINK_TYPE,
|
|
312
353
|
d: util.removeHttpFromUrl(input) // website urls are stored as-is without http/https
|
|
@@ -315,15 +356,13 @@ function websiteUrlToWebsiteLink(input) {
|
|
|
315
356
|
// MARK: Email
|
|
316
357
|
/**
|
|
317
358
|
* {@link WebsiteLinkType} code for email addresses.
|
|
318
|
-
*/
|
|
319
|
-
const EMAIL_URL_WEBSITE_LINK_TYPE = 'e';
|
|
359
|
+
*/ var EMAIL_URL_WEBSITE_LINK_TYPE = 'e';
|
|
320
360
|
/**
|
|
321
361
|
* Converts an email address into a {@link WebsiteLink}.
|
|
322
362
|
*
|
|
323
363
|
* @param input - the email address
|
|
324
364
|
* @returns a WebsiteLink storing the email as data
|
|
325
|
-
*/
|
|
326
|
-
function emailAddressToWebsiteLink(input) {
|
|
365
|
+
*/ function emailAddressToWebsiteLink(input) {
|
|
327
366
|
return {
|
|
328
367
|
t: EMAIL_URL_WEBSITE_LINK_TYPE,
|
|
329
368
|
d: input
|
|
@@ -332,25 +371,21 @@ function emailAddressToWebsiteLink(input) {
|
|
|
332
371
|
// MARK: Phone
|
|
333
372
|
/**
|
|
334
373
|
* {@link WebsiteLinkType} code for phone numbers.
|
|
335
|
-
*/
|
|
336
|
-
const PHONE_URL_WEBSITE_LINK_TYPE = 'p';
|
|
374
|
+
*/ var PHONE_URL_WEBSITE_LINK_TYPE = 'p';
|
|
337
375
|
/**
|
|
338
376
|
* Converts an E.164 phone number into a {@link WebsiteLink}.
|
|
339
377
|
*
|
|
340
378
|
* @param input - the phone number in E.164 format
|
|
341
379
|
* @returns a WebsiteLink storing the phone number as data
|
|
342
|
-
*/
|
|
343
|
-
function phoneNumberToWebsiteLink(input) {
|
|
380
|
+
*/ function phoneNumberToWebsiteLink(input) {
|
|
344
381
|
return {
|
|
345
382
|
t: PHONE_URL_WEBSITE_LINK_TYPE,
|
|
346
383
|
d: input
|
|
347
384
|
};
|
|
348
385
|
}
|
|
349
386
|
// MARK: Facebook
|
|
350
|
-
/** Base URL for Facebook profiles. */
|
|
351
|
-
|
|
352
|
-
/** {@link WebsiteLinkType} code for Facebook. */
|
|
353
|
-
const FACEBOOK_WEBSITE_LINK_TYPE = 'fb';
|
|
387
|
+
/** Base URL for Facebook profiles. */ var FACEBOOK_BASE_URL = "https://www.facebook.com";
|
|
388
|
+
/** {@link WebsiteLinkType} code for Facebook. */ var FACEBOOK_WEBSITE_LINK_TYPE = 'fb';
|
|
354
389
|
/**
|
|
355
390
|
* Converts a Facebook profile ID or URL into a {@link WebsiteLink}.
|
|
356
391
|
*
|
|
@@ -367,8 +402,7 @@ const FACEBOOK_WEBSITE_LINK_TYPE = 'fb';
|
|
|
367
402
|
* facebookProfileUrlToWebsiteLink('myuser');
|
|
368
403
|
* // { t: 'fb', d: 'myuser' }
|
|
369
404
|
* ```
|
|
370
|
-
*/
|
|
371
|
-
function facebookProfileUrlToWebsiteLink(input) {
|
|
405
|
+
*/ function facebookProfileUrlToWebsiteLink(input) {
|
|
372
406
|
return {
|
|
373
407
|
t: FACEBOOK_WEBSITE_LINK_TYPE,
|
|
374
408
|
d: usernameFromUsernameOrWebsiteWithBaseUrlUsername(input)
|
|
@@ -379,22 +413,18 @@ function facebookProfileUrlToWebsiteLink(input) {
|
|
|
379
413
|
*
|
|
380
414
|
* @param profileId - the Facebook profile ID or username
|
|
381
415
|
* @returns the full profile URL
|
|
382
|
-
*/
|
|
383
|
-
|
|
384
|
-
return `${FACEBOOK_BASE_URL}/${profileId}`;
|
|
416
|
+
*/ function facebookProfileUrl(profileId) {
|
|
417
|
+
return "".concat(FACEBOOK_BASE_URL, "/").concat(profileId);
|
|
385
418
|
}
|
|
386
419
|
// MARK: Instagram
|
|
387
|
-
/** Base URL for Instagram profiles. */
|
|
388
|
-
|
|
389
|
-
/** {@link WebsiteLinkType} code for Instagram. */
|
|
390
|
-
const INSTAGRAM_WEBSITE_LINK_TYPE = 'ig';
|
|
420
|
+
/** Base URL for Instagram profiles. */ var INSTAGRAM_BASE_URL = "https://www.instagram.com";
|
|
421
|
+
/** {@link WebsiteLinkType} code for Instagram. */ var INSTAGRAM_WEBSITE_LINK_TYPE = 'ig';
|
|
391
422
|
/**
|
|
392
423
|
* Converts an Instagram profile ID or URL into a {@link WebsiteLink}.
|
|
393
424
|
*
|
|
394
425
|
* @param input - an Instagram username or full profile URL
|
|
395
426
|
* @returns a WebsiteLink with the isolated username as data
|
|
396
|
-
*/
|
|
397
|
-
function instagramProfileUrlToWebsiteLink(input) {
|
|
427
|
+
*/ function instagramProfileUrlToWebsiteLink(input) {
|
|
398
428
|
return {
|
|
399
429
|
t: INSTAGRAM_WEBSITE_LINK_TYPE,
|
|
400
430
|
d: usernameFromUsernameOrWebsiteWithBaseUrlUsername(input)
|
|
@@ -405,22 +435,18 @@ function instagramProfileUrlToWebsiteLink(input) {
|
|
|
405
435
|
*
|
|
406
436
|
* @param profileId - the Instagram username
|
|
407
437
|
* @returns the full profile URL
|
|
408
|
-
*/
|
|
409
|
-
|
|
410
|
-
return `${INSTAGRAM_BASE_URL}/${profileId}`;
|
|
438
|
+
*/ function instagramProfileUrl(profileId) {
|
|
439
|
+
return "".concat(INSTAGRAM_BASE_URL, "/").concat(profileId);
|
|
411
440
|
}
|
|
412
441
|
// MARK: Twitter
|
|
413
|
-
/** Base URL for Twitter profiles. */
|
|
414
|
-
|
|
415
|
-
/** {@link WebsiteLinkType} code for Twitter. */
|
|
416
|
-
const TWITTER_WEBSITE_LINK_TYPE = 'tw';
|
|
442
|
+
/** Base URL for Twitter profiles. */ var TWITTER_BASE_URL = "https://www.twitter.com";
|
|
443
|
+
/** {@link WebsiteLinkType} code for Twitter. */ var TWITTER_WEBSITE_LINK_TYPE = 'tw';
|
|
417
444
|
/**
|
|
418
445
|
* Converts a Twitter profile ID or URL into a {@link WebsiteLink}.
|
|
419
446
|
*
|
|
420
447
|
* @param input - a Twitter username or full profile URL
|
|
421
448
|
* @returns a WebsiteLink with the isolated username as data
|
|
422
|
-
*/
|
|
423
|
-
function twitterProfileUrlToWebsiteLink(input) {
|
|
449
|
+
*/ function twitterProfileUrlToWebsiteLink(input) {
|
|
424
450
|
return {
|
|
425
451
|
t: TWITTER_WEBSITE_LINK_TYPE,
|
|
426
452
|
d: usernameFromUsernameOrWebsiteWithBaseUrlUsername(input)
|
|
@@ -431,17 +457,13 @@ function twitterProfileUrlToWebsiteLink(input) {
|
|
|
431
457
|
*
|
|
432
458
|
* @param profileId - the Twitter username
|
|
433
459
|
* @returns the full profile URL
|
|
434
|
-
*/
|
|
435
|
-
|
|
436
|
-
return `${TWITTER_BASE_URL}/${profileId}`;
|
|
460
|
+
*/ function twitterProfileUrl(profileId) {
|
|
461
|
+
return "".concat(TWITTER_BASE_URL, "/").concat(profileId);
|
|
437
462
|
}
|
|
438
463
|
// MARK: Tiktok
|
|
439
|
-
/** Base URL for TikTok profiles. */
|
|
440
|
-
|
|
441
|
-
/**
|
|
442
|
-
const TIKTOK_USERNAME_PREFIX = '@';
|
|
443
|
-
/** {@link WebsiteLinkType} code for TikTok. */
|
|
444
|
-
const TIKTOK_WEBSITE_LINK_TYPE = 'tt';
|
|
464
|
+
/** Base URL for TikTok profiles. */ var TIKTOK_BASE_URL = "https://tiktok.com";
|
|
465
|
+
/** TikTok usernames are prefixed with "@" in URLs and stored data. */ var TIKTOK_USERNAME_PREFIX = '@';
|
|
466
|
+
/** {@link WebsiteLinkType} code for TikTok. */ var TIKTOK_WEBSITE_LINK_TYPE = 'tt';
|
|
445
467
|
/**
|
|
446
468
|
* Converts a TikTok profile ID or URL into a {@link WebsiteLink}.
|
|
447
469
|
*
|
|
@@ -449,8 +471,7 @@ const TIKTOK_WEBSITE_LINK_TYPE = 'tt';
|
|
|
449
471
|
*
|
|
450
472
|
* @param input - a TikTok username (with or without "@") or full profile URL
|
|
451
473
|
* @returns a WebsiteLink with the "@"-prefixed username as data
|
|
452
|
-
*/
|
|
453
|
-
function tiktokProfileUrlToWebsiteLink(input) {
|
|
474
|
+
*/ function tiktokProfileUrlToWebsiteLink(input) {
|
|
454
475
|
return {
|
|
455
476
|
t: TIKTOK_WEBSITE_LINK_TYPE,
|
|
456
477
|
d: usernameFromUsernameOrWebsiteWithBaseUrlUsername(input, TIKTOK_USERNAME_PREFIX)
|
|
@@ -461,19 +482,15 @@ function tiktokProfileUrlToWebsiteLink(input) {
|
|
|
461
482
|
*
|
|
462
483
|
* @param profileId - the TikTok username (without "@" prefix)
|
|
463
484
|
* @returns the full profile URL with "@" prefix
|
|
464
|
-
*/
|
|
465
|
-
|
|
466
|
-
return `${TIKTOK_BASE_URL}/@${profileId}`;
|
|
485
|
+
*/ function tiktokProfileUrl(profileId) {
|
|
486
|
+
return "".concat(TIKTOK_BASE_URL, "/@").concat(profileId);
|
|
467
487
|
}
|
|
468
488
|
// MARK: Snapchat
|
|
469
|
-
/** Base URL for Snapchat profiles. */
|
|
470
|
-
|
|
471
|
-
/** {@link WebsiteLinkType} code for Snapchat. */
|
|
472
|
-
const SNAPCHAT_WEBSITE_LINK_TYPE = 'sc';
|
|
489
|
+
/** Base URL for Snapchat profiles. */ var SNAPCHAT_BASE_URL = "https://snapchat.com";
|
|
490
|
+
/** {@link WebsiteLinkType} code for Snapchat. */ var SNAPCHAT_WEBSITE_LINK_TYPE = 'sc';
|
|
473
491
|
/**
|
|
474
492
|
* Isolates a Snapchat username from a URL, ignoring the `/add/` base path segment.
|
|
475
|
-
*/
|
|
476
|
-
const SNAPCHAT_WEBSITE_LINK_ISOLATE_PROFILE_ID = util.isolateWebsitePathFunction({
|
|
493
|
+
*/ var SNAPCHAT_WEBSITE_LINK_ISOLATE_PROFILE_ID = util.isolateWebsitePathFunction({
|
|
477
494
|
ignoredBasePath: 'add',
|
|
478
495
|
isolatePathComponents: 0,
|
|
479
496
|
removeTrailingSlash: true,
|
|
@@ -486,8 +503,7 @@ const SNAPCHAT_WEBSITE_LINK_ISOLATE_PROFILE_ID = util.isolateWebsitePathFunction
|
|
|
486
503
|
*
|
|
487
504
|
* @param input - a Snapchat username or full profile URL
|
|
488
505
|
* @returns a WebsiteLink with the isolated username as data
|
|
489
|
-
*/
|
|
490
|
-
function snapchatProfileUrlToWebsiteLink(input) {
|
|
506
|
+
*/ function snapchatProfileUrlToWebsiteLink(input) {
|
|
491
507
|
return {
|
|
492
508
|
t: SNAPCHAT_WEBSITE_LINK_TYPE,
|
|
493
509
|
d: usernameFromUsernameOrWebsiteWithOneOffBaseUrlUsername(input, SNAPCHAT_WEBSITE_LINK_ISOLATE_PROFILE_ID)
|
|
@@ -498,19 +514,15 @@ function snapchatProfileUrlToWebsiteLink(input) {
|
|
|
498
514
|
*
|
|
499
515
|
* @param profileId - the Snapchat username
|
|
500
516
|
* @returns the full profile URL with `/add/` path
|
|
501
|
-
*/
|
|
502
|
-
|
|
503
|
-
return `${SNAPCHAT_BASE_URL}/add/${profileId}`;
|
|
517
|
+
*/ function snapchatProfileUrl(profileId) {
|
|
518
|
+
return "".concat(SNAPCHAT_BASE_URL, "/add/").concat(profileId);
|
|
504
519
|
}
|
|
505
520
|
// MARK: YouTube
|
|
506
|
-
/** Base URL for YouTube channels. */
|
|
507
|
-
|
|
508
|
-
/** {@link WebsiteLinkType} code for YouTube. */
|
|
509
|
-
const YOUTUBE_WEBSITE_LINK_TYPE = 'yt';
|
|
521
|
+
/** Base URL for YouTube channels. */ var YOUTUBE_BASE_URL = "https://youtube.com";
|
|
522
|
+
/** {@link WebsiteLinkType} code for YouTube. */ var YOUTUBE_WEBSITE_LINK_TYPE = 'yt';
|
|
510
523
|
/**
|
|
511
524
|
* Isolates a YouTube channel name from a URL, ignoring the `/c/` base path segment.
|
|
512
|
-
*/
|
|
513
|
-
const YOUTUBE_WEBSITE_LINK_ISOLATE_PROFILE_ID = util.isolateWebsitePathFunction({
|
|
525
|
+
*/ var YOUTUBE_WEBSITE_LINK_ISOLATE_PROFILE_ID = util.isolateWebsitePathFunction({
|
|
514
526
|
ignoredBasePath: 'c',
|
|
515
527
|
isolatePathComponents: 0,
|
|
516
528
|
removeTrailingSlash: true,
|
|
@@ -523,8 +535,7 @@ const YOUTUBE_WEBSITE_LINK_ISOLATE_PROFILE_ID = util.isolateWebsitePathFunction(
|
|
|
523
535
|
*
|
|
524
536
|
* @param input - a YouTube channel name or full channel URL
|
|
525
537
|
* @returns a WebsiteLink with the isolated channel name as data
|
|
526
|
-
*/
|
|
527
|
-
function youtubeProfileUrlToWebsiteLink(input) {
|
|
538
|
+
*/ function youtubeProfileUrlToWebsiteLink(input) {
|
|
528
539
|
return {
|
|
529
540
|
t: YOUTUBE_WEBSITE_LINK_TYPE,
|
|
530
541
|
d: usernameFromUsernameOrWebsiteWithOneOffBaseUrlUsername(input, YOUTUBE_WEBSITE_LINK_ISOLATE_PROFILE_ID)
|
|
@@ -535,22 +546,18 @@ function youtubeProfileUrlToWebsiteLink(input) {
|
|
|
535
546
|
*
|
|
536
547
|
* @param profileId - the YouTube channel name
|
|
537
548
|
* @returns the full channel URL with `/c/` path
|
|
538
|
-
*/
|
|
539
|
-
|
|
540
|
-
return `${YOUTUBE_BASE_URL}/c/${profileId}`;
|
|
549
|
+
*/ function youtubeProfileUrl(profileId) {
|
|
550
|
+
return "".concat(YOUTUBE_BASE_URL, "/c/").concat(profileId);
|
|
541
551
|
}
|
|
542
552
|
// MARK: PayPal
|
|
543
|
-
/** Base URL for PayPal.me profiles. */
|
|
544
|
-
|
|
545
|
-
/** {@link WebsiteLinkType} code for PayPal. */
|
|
546
|
-
const PAYPAL_WEBSITE_LINK_TYPE = 'pp';
|
|
553
|
+
/** Base URL for PayPal.me profiles. */ var PAYPAL_BASE_URL = "https://paypal.me";
|
|
554
|
+
/** {@link WebsiteLinkType} code for PayPal. */ var PAYPAL_WEBSITE_LINK_TYPE = 'pp';
|
|
547
555
|
/**
|
|
548
556
|
* Converts a PayPal profile ID or URL into a {@link WebsiteLink}.
|
|
549
557
|
*
|
|
550
558
|
* @param input - a PayPal username or full PayPal.me URL
|
|
551
559
|
* @returns a WebsiteLink with the isolated username as data
|
|
552
|
-
*/
|
|
553
|
-
function paypalProfileUrlToWebsiteLink(input) {
|
|
560
|
+
*/ function paypalProfileUrlToWebsiteLink(input) {
|
|
554
561
|
return {
|
|
555
562
|
t: PAYPAL_WEBSITE_LINK_TYPE,
|
|
556
563
|
d: usernameFromUsernameOrWebsiteWithBaseUrlUsername(input)
|
|
@@ -561,17 +568,13 @@ function paypalProfileUrlToWebsiteLink(input) {
|
|
|
561
568
|
*
|
|
562
569
|
* @param profileId - the PayPal username
|
|
563
570
|
* @returns the full PayPal.me URL
|
|
564
|
-
*/
|
|
565
|
-
|
|
566
|
-
return `${PAYPAL_BASE_URL}/${profileId}`;
|
|
571
|
+
*/ function paypalProfileUrl(profileId) {
|
|
572
|
+
return "".concat(PAYPAL_BASE_URL, "/").concat(profileId);
|
|
567
573
|
}
|
|
568
574
|
// MARK: Cashapp
|
|
569
|
-
/** Base URL for Cash App profiles. */
|
|
570
|
-
|
|
571
|
-
/** Cash App
|
|
572
|
-
const CASHAPP_USERNAME_PREFIX = '$';
|
|
573
|
-
/** {@link WebsiteLinkType} code for Cash App. */
|
|
574
|
-
const CASHAPP_WEBSITE_LINK_TYPE = 'ca';
|
|
575
|
+
/** Base URL for Cash App profiles. */ var CASHAPP_BASE_URL = "https://cash.app";
|
|
576
|
+
/** Cash App usernames are prefixed with "$" (cashtag). */ var CASHAPP_USERNAME_PREFIX = '$';
|
|
577
|
+
/** {@link WebsiteLinkType} code for Cash App. */ var CASHAPP_WEBSITE_LINK_TYPE = 'ca';
|
|
575
578
|
/**
|
|
576
579
|
* Converts a Cash App profile ID or URL into a {@link WebsiteLink}.
|
|
577
580
|
*
|
|
@@ -579,8 +582,7 @@ const CASHAPP_WEBSITE_LINK_TYPE = 'ca';
|
|
|
579
582
|
*
|
|
580
583
|
* @param input - a Cash App username (with or without "$") or full profile URL
|
|
581
584
|
* @returns a WebsiteLink with the "$"-prefixed username as data
|
|
582
|
-
*/
|
|
583
|
-
function cashappProfileUrlToWebsiteLink(input) {
|
|
585
|
+
*/ function cashappProfileUrlToWebsiteLink(input) {
|
|
584
586
|
return {
|
|
585
587
|
t: CASHAPP_WEBSITE_LINK_TYPE,
|
|
586
588
|
d: usernameFromUsernameOrWebsiteWithBaseUrlUsername(input, CASHAPP_USERNAME_PREFIX)
|
|
@@ -591,19 +593,15 @@ function cashappProfileUrlToWebsiteLink(input) {
|
|
|
591
593
|
*
|
|
592
594
|
* @param profileId - the Cash App username (without "$" prefix)
|
|
593
595
|
* @returns the full Cash App URL with "$" prefix
|
|
594
|
-
*/
|
|
595
|
-
|
|
596
|
-
return `${CASHAPP_BASE_URL}/$${profileId}`;
|
|
596
|
+
*/ function cashappProfileUrl(profileId) {
|
|
597
|
+
return "".concat(CASHAPP_BASE_URL, "/$").concat(profileId);
|
|
597
598
|
}
|
|
598
599
|
// MARK: Venmo
|
|
599
|
-
/** Base URL for Venmo profiles. */
|
|
600
|
-
|
|
601
|
-
/** {@link WebsiteLinkType} code for Venmo. */
|
|
602
|
-
const VENMO_WEBSITE_LINK_TYPE = 'vn';
|
|
600
|
+
/** Base URL for Venmo profiles. */ var VENMO_BASE_URL = "https://account.venmo.com";
|
|
601
|
+
/** {@link WebsiteLinkType} code for Venmo. */ var VENMO_WEBSITE_LINK_TYPE = 'vn';
|
|
603
602
|
/**
|
|
604
603
|
* Isolates a Venmo username from a URL, ignoring the `/u/` base path segment.
|
|
605
|
-
*/
|
|
606
|
-
const VENMO_WEBSITE_LINK_ISOLATE_PROFILE_ID = util.isolateWebsitePathFunction({
|
|
604
|
+
*/ var VENMO_WEBSITE_LINK_ISOLATE_PROFILE_ID = util.isolateWebsitePathFunction({
|
|
607
605
|
ignoredBasePath: 'u',
|
|
608
606
|
isolatePathComponents: 0,
|
|
609
607
|
removeTrailingSlash: true,
|
|
@@ -616,8 +614,7 @@ const VENMO_WEBSITE_LINK_ISOLATE_PROFILE_ID = util.isolateWebsitePathFunction({
|
|
|
616
614
|
*
|
|
617
615
|
* @param input - a Venmo username or full profile URL
|
|
618
616
|
* @returns a WebsiteLink with the isolated username as data
|
|
619
|
-
*/
|
|
620
|
-
function venmoProfileUrlToWebsiteLink(input) {
|
|
617
|
+
*/ function venmoProfileUrlToWebsiteLink(input) {
|
|
621
618
|
return {
|
|
622
619
|
t: VENMO_WEBSITE_LINK_TYPE,
|
|
623
620
|
d: usernameFromUsernameOrWebsiteWithOneOffBaseUrlUsername(input, VENMO_WEBSITE_LINK_ISOLATE_PROFILE_ID)
|
|
@@ -628,19 +625,15 @@ function venmoProfileUrlToWebsiteLink(input) {
|
|
|
628
625
|
*
|
|
629
626
|
* @param profileId - the Venmo username
|
|
630
627
|
* @returns the full profile URL with `/u/` path
|
|
631
|
-
*/
|
|
632
|
-
|
|
633
|
-
return `${VENMO_BASE_URL}/u/${profileId}`;
|
|
628
|
+
*/ function venmoProfileUrl(profileId) {
|
|
629
|
+
return "".concat(VENMO_BASE_URL, "/u/").concat(profileId);
|
|
634
630
|
}
|
|
635
631
|
// MARK: Spotify
|
|
636
|
-
/** Base URL for Spotify profiles. */
|
|
637
|
-
|
|
638
|
-
/** {@link WebsiteLinkType} code for Spotify. */
|
|
639
|
-
const SPOTIFY_WEBSITE_LINK_TYPE = 'sp';
|
|
632
|
+
/** Base URL for Spotify profiles. */ var SPOTIFY_BASE_URL = "https://open.spotify.com/";
|
|
633
|
+
/** {@link WebsiteLinkType} code for Spotify. */ var SPOTIFY_WEBSITE_LINK_TYPE = 'sp';
|
|
640
634
|
/**
|
|
641
635
|
* Isolates a Spotify username from a URL, ignoring the `/user/` base path segment.
|
|
642
|
-
*/
|
|
643
|
-
const SPOTIFY_WEBSITE_LINK_ISOLATE_PROFILE_ID = util.isolateWebsitePathFunction({
|
|
636
|
+
*/ var SPOTIFY_WEBSITE_LINK_ISOLATE_PROFILE_ID = util.isolateWebsitePathFunction({
|
|
644
637
|
ignoredBasePath: 'user',
|
|
645
638
|
isolatePathComponents: 0,
|
|
646
639
|
removeTrailingSlash: true,
|
|
@@ -653,8 +646,7 @@ const SPOTIFY_WEBSITE_LINK_ISOLATE_PROFILE_ID = util.isolateWebsitePathFunction(
|
|
|
653
646
|
*
|
|
654
647
|
* @param input - a Spotify username or full profile URL
|
|
655
648
|
* @returns a WebsiteLink with the isolated username as data
|
|
656
|
-
*/
|
|
657
|
-
function spotifyProfileUrlToWebsiteLink(input) {
|
|
649
|
+
*/ function spotifyProfileUrlToWebsiteLink(input) {
|
|
658
650
|
return {
|
|
659
651
|
t: SPOTIFY_WEBSITE_LINK_TYPE,
|
|
660
652
|
d: usernameFromUsernameOrWebsiteWithOneOffBaseUrlUsername(input, SPOTIFY_WEBSITE_LINK_ISOLATE_PROFILE_ID)
|
|
@@ -665,14 +657,90 @@ function spotifyProfileUrlToWebsiteLink(input) {
|
|
|
665
657
|
*
|
|
666
658
|
* @param profileId - the Spotify username
|
|
667
659
|
* @returns the full profile URL with `/user/` path
|
|
668
|
-
*/
|
|
669
|
-
|
|
670
|
-
return `${SPOTIFY_BASE_URL}/user/${profileId}`;
|
|
660
|
+
*/ function spotifyProfileUrl(profileId) {
|
|
661
|
+
return "".concat(SPOTIFY_BASE_URL, "/user/").concat(profileId);
|
|
671
662
|
}
|
|
672
663
|
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
664
|
+
function _array_like_to_array$1(arr, len) {
|
|
665
|
+
if (len == null || len > arr.length) len = arr.length;
|
|
666
|
+
for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
|
|
667
|
+
return arr2;
|
|
668
|
+
}
|
|
669
|
+
function _array_with_holes$1(arr) {
|
|
670
|
+
if (Array.isArray(arr)) return arr;
|
|
671
|
+
}
|
|
672
|
+
function _class_call_check$2(instance, Constructor) {
|
|
673
|
+
if (!(instance instanceof Constructor)) {
|
|
674
|
+
throw new TypeError("Cannot call a class as a function");
|
|
675
|
+
}
|
|
676
|
+
}
|
|
677
|
+
function _defineProperties$1(target, props) {
|
|
678
|
+
for(var i = 0; i < props.length; i++){
|
|
679
|
+
var descriptor = props[i];
|
|
680
|
+
descriptor.enumerable = descriptor.enumerable || false;
|
|
681
|
+
descriptor.configurable = true;
|
|
682
|
+
if ("value" in descriptor) descriptor.writable = true;
|
|
683
|
+
Object.defineProperty(target, descriptor.key, descriptor);
|
|
684
|
+
}
|
|
685
|
+
}
|
|
686
|
+
function _create_class$1(Constructor, protoProps, staticProps) {
|
|
687
|
+
if (protoProps) _defineProperties$1(Constructor.prototype, protoProps);
|
|
688
|
+
return Constructor;
|
|
689
|
+
}
|
|
690
|
+
function _define_property$3(obj, key, value) {
|
|
691
|
+
if (key in obj) {
|
|
692
|
+
Object.defineProperty(obj, key, {
|
|
693
|
+
value: value,
|
|
694
|
+
enumerable: true,
|
|
695
|
+
configurable: true,
|
|
696
|
+
writable: true
|
|
697
|
+
});
|
|
698
|
+
} else {
|
|
699
|
+
obj[key] = value;
|
|
700
|
+
}
|
|
701
|
+
return obj;
|
|
702
|
+
}
|
|
703
|
+
function _iterable_to_array_limit$1(arr, i) {
|
|
704
|
+
var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"];
|
|
705
|
+
if (_i == null) return;
|
|
706
|
+
var _arr = [];
|
|
707
|
+
var _n = true;
|
|
708
|
+
var _d = false;
|
|
709
|
+
var _s, _e;
|
|
710
|
+
try {
|
|
711
|
+
for(_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true){
|
|
712
|
+
_arr.push(_s.value);
|
|
713
|
+
if (i && _arr.length === i) break;
|
|
714
|
+
}
|
|
715
|
+
} catch (err) {
|
|
716
|
+
_d = true;
|
|
717
|
+
_e = err;
|
|
718
|
+
} finally{
|
|
719
|
+
try {
|
|
720
|
+
if (!_n && _i["return"] != null) _i["return"]();
|
|
721
|
+
} finally{
|
|
722
|
+
if (_d) throw _e;
|
|
723
|
+
}
|
|
724
|
+
}
|
|
725
|
+
return _arr;
|
|
726
|
+
}
|
|
727
|
+
function _non_iterable_rest$1() {
|
|
728
|
+
throw new TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
729
|
+
}
|
|
730
|
+
function _sliced_to_array$1(arr, i) {
|
|
731
|
+
return _array_with_holes$1(arr) || _iterable_to_array_limit$1(arr, i) || _unsupported_iterable_to_array$1(arr, i) || _non_iterable_rest$1();
|
|
732
|
+
}
|
|
733
|
+
function _unsupported_iterable_to_array$1(o, minLen) {
|
|
734
|
+
if (!o) return;
|
|
735
|
+
if (typeof o === "string") return _array_like_to_array$1(o, minLen);
|
|
736
|
+
var n = Object.prototype.toString.call(o).slice(8, -1);
|
|
737
|
+
if (n === "Object" && o.constructor) n = o.constructor.name;
|
|
738
|
+
if (n === "Map" || n === "Set") return Array.from(n);
|
|
739
|
+
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array$1(o, minLen);
|
|
740
|
+
}
|
|
741
|
+
var GRANTED_SYS_ADMIN_ROLE_KEY = 'sysadmin';
|
|
742
|
+
var GRANTED_OWNER_ROLE_KEY = 'owner';
|
|
743
|
+
var GRANTED_ADMIN_ROLE_KEY = 'admin';
|
|
676
744
|
/**
|
|
677
745
|
* Checks whether the given role represents an admin-level permission (either "admin" or "owner").
|
|
678
746
|
*
|
|
@@ -685,15 +753,14 @@ const GRANTED_ADMIN_ROLE_KEY = 'admin';
|
|
|
685
753
|
* isGrantedAdminLevelRole('owner'); // true
|
|
686
754
|
* isGrantedAdminLevelRole('read'); // false
|
|
687
755
|
* ```
|
|
688
|
-
*/
|
|
689
|
-
function isGrantedAdminLevelRole(role) {
|
|
756
|
+
*/ function isGrantedAdminLevelRole(role) {
|
|
690
757
|
return role === GRANTED_ADMIN_ROLE_KEY || role === GRANTED_OWNER_ROLE_KEY;
|
|
691
758
|
}
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
759
|
+
var GRANTED_READ_ROLE_KEY = 'read';
|
|
760
|
+
var GRANTED_UPDATE_ROLE_KEY = 'update';
|
|
761
|
+
var GRANTED_DELETE_ROLE_KEY = 'delete';
|
|
762
|
+
var FULL_ACCESS_ROLE_KEY = '__FULL__';
|
|
763
|
+
var NO_ACCESS_ROLE_KEY = '__EMPTY__';
|
|
697
764
|
/**
|
|
698
765
|
* Creates a {@link GrantedRoleMap} that explicitly denies all access.
|
|
699
766
|
*
|
|
@@ -704,19 +771,15 @@ const NO_ACCESS_ROLE_KEY = '__EMPTY__';
|
|
|
704
771
|
* const map = noAccessRoleMap();
|
|
705
772
|
* isNoAccessRoleMap(map); // true
|
|
706
773
|
* ```
|
|
707
|
-
*/
|
|
708
|
-
|
|
709
|
-
return {
|
|
710
|
-
[NO_ACCESS_ROLE_KEY]: true
|
|
711
|
-
};
|
|
774
|
+
*/ function noAccessRoleMap() {
|
|
775
|
+
return _define_property$3({}, NO_ACCESS_ROLE_KEY, true);
|
|
712
776
|
}
|
|
713
777
|
/**
|
|
714
778
|
* Type guard that checks whether a role map is a no-access map.
|
|
715
779
|
*
|
|
716
780
|
* @param input - the role map to check
|
|
717
781
|
* @returns true if the map has the no-access marker
|
|
718
|
-
*/
|
|
719
|
-
function isNoAccessRoleMap(input) {
|
|
782
|
+
*/ function isNoAccessRoleMap(input) {
|
|
720
783
|
return input[NO_ACCESS_ROLE_KEY] === true;
|
|
721
784
|
}
|
|
722
785
|
/**
|
|
@@ -729,19 +792,15 @@ function isNoAccessRoleMap(input) {
|
|
|
729
792
|
* const map = fullAccessRoleMap();
|
|
730
793
|
* isFullAccessRoleMap(map); // true
|
|
731
794
|
* ```
|
|
732
|
-
*/
|
|
733
|
-
|
|
734
|
-
return {
|
|
735
|
-
[FULL_ACCESS_ROLE_KEY]: true
|
|
736
|
-
};
|
|
795
|
+
*/ function fullAccessRoleMap() {
|
|
796
|
+
return _define_property$3({}, FULL_ACCESS_ROLE_KEY, true);
|
|
737
797
|
}
|
|
738
798
|
/**
|
|
739
799
|
* Type guard that checks whether a role map is a full-access map.
|
|
740
800
|
*
|
|
741
801
|
* @param input - the role map to check
|
|
742
802
|
* @returns true if the map has the full-access marker
|
|
743
|
-
*/
|
|
744
|
-
function isFullAccessRoleMap(input) {
|
|
803
|
+
*/ function isFullAccessRoleMap(input) {
|
|
745
804
|
return input[FULL_ACCESS_ROLE_KEY] === true;
|
|
746
805
|
}
|
|
747
806
|
/**
|
|
@@ -763,66 +822,124 @@ function isFullAccessRoleMap(input) {
|
|
|
763
822
|
* reader.containsRoles('any', ['read']); // true
|
|
764
823
|
* reader.containsRoles('all', ['read', 'delete']); // false
|
|
765
824
|
* ```
|
|
766
|
-
*/
|
|
767
|
-
function grantedRoleMapReader(map) {
|
|
825
|
+
*/ function grantedRoleMapReader(map) {
|
|
768
826
|
return new GrantedRoleMapReaderInstance(map);
|
|
769
827
|
}
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
828
|
+
var GrantedRoleMapReaderInstance = /*#__PURE__*/ function() {
|
|
829
|
+
function GrantedRoleMapReaderInstance(map) {
|
|
830
|
+
_class_call_check$2(this, GrantedRoleMapReaderInstance);
|
|
831
|
+
_define_property$3(this, "_map", void 0);
|
|
773
832
|
this._map = map;
|
|
774
833
|
}
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
834
|
+
_create_class$1(GrantedRoleMapReaderInstance, [
|
|
835
|
+
{
|
|
836
|
+
key: "hasNoAccess",
|
|
837
|
+
value: function hasNoAccess() {
|
|
838
|
+
return this._map[NO_ACCESS_ROLE_KEY];
|
|
839
|
+
}
|
|
840
|
+
},
|
|
841
|
+
{
|
|
842
|
+
key: "truthMap",
|
|
843
|
+
value: function truthMap(input) {
|
|
844
|
+
var _this = this;
|
|
845
|
+
var result = {};
|
|
846
|
+
util.forEachKeyValue(input, {
|
|
847
|
+
forEach: function forEach(param) {
|
|
848
|
+
var _param = _sliced_to_array$1(param, 2), role = _param[0], value = _param[1];
|
|
849
|
+
if (_this.hasRole(role)) {
|
|
850
|
+
result[role] = value;
|
|
851
|
+
}
|
|
852
|
+
}
|
|
853
|
+
});
|
|
854
|
+
return result;
|
|
855
|
+
}
|
|
856
|
+
},
|
|
857
|
+
{
|
|
858
|
+
key: "hasRole",
|
|
859
|
+
value: function hasRole(role) {
|
|
860
|
+
return this.hasRoles('any', role);
|
|
861
|
+
}
|
|
862
|
+
},
|
|
863
|
+
{
|
|
864
|
+
key: "hasRoles",
|
|
865
|
+
value: function hasRoles(setIncludes, inputRoles) {
|
|
866
|
+
if (this._map[FULL_ACCESS_ROLE_KEY]) {
|
|
867
|
+
return true;
|
|
868
|
+
} else {
|
|
869
|
+
return this.containsRoles(setIncludes, inputRoles);
|
|
784
870
|
}
|
|
785
871
|
}
|
|
786
|
-
}
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
else {
|
|
797
|
-
return this.containsRoles(setIncludes, inputRoles);
|
|
798
|
-
}
|
|
799
|
-
}
|
|
800
|
-
containsRoles(setIncludes, inputRoles) {
|
|
801
|
-
const roles = util.iterableToArray(inputRoles);
|
|
802
|
-
if (setIncludes === 'any') {
|
|
803
|
-
return this.containsAnyRole(roles);
|
|
804
|
-
}
|
|
805
|
-
else {
|
|
806
|
-
return this.containsEachRole(roles);
|
|
807
|
-
}
|
|
808
|
-
}
|
|
809
|
-
containsAnyRole(roles) {
|
|
810
|
-
for (const role of roles) {
|
|
811
|
-
if (this._map[role]) {
|
|
812
|
-
return true;
|
|
872
|
+
},
|
|
873
|
+
{
|
|
874
|
+
key: "containsRoles",
|
|
875
|
+
value: function containsRoles(setIncludes, inputRoles) {
|
|
876
|
+
var roles = util.iterableToArray(inputRoles);
|
|
877
|
+
if (setIncludes === 'any') {
|
|
878
|
+
return this.containsAnyRole(roles);
|
|
879
|
+
} else {
|
|
880
|
+
return this.containsEachRole(roles);
|
|
881
|
+
}
|
|
813
882
|
}
|
|
814
|
-
}
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
883
|
+
},
|
|
884
|
+
{
|
|
885
|
+
key: "containsAnyRole",
|
|
886
|
+
value: function containsAnyRole(roles) {
|
|
887
|
+
var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
|
|
888
|
+
try {
|
|
889
|
+
for(var _iterator = roles[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
|
|
890
|
+
var role = _step.value;
|
|
891
|
+
if (this._map[role]) {
|
|
892
|
+
return true;
|
|
893
|
+
}
|
|
894
|
+
}
|
|
895
|
+
} catch (err) {
|
|
896
|
+
_didIteratorError = true;
|
|
897
|
+
_iteratorError = err;
|
|
898
|
+
} finally{
|
|
899
|
+
try {
|
|
900
|
+
if (!_iteratorNormalCompletion && _iterator.return != null) {
|
|
901
|
+
_iterator.return();
|
|
902
|
+
}
|
|
903
|
+
} finally{
|
|
904
|
+
if (_didIteratorError) {
|
|
905
|
+
throw _iteratorError;
|
|
906
|
+
}
|
|
907
|
+
}
|
|
908
|
+
}
|
|
820
909
|
return false;
|
|
821
910
|
}
|
|
911
|
+
},
|
|
912
|
+
{
|
|
913
|
+
key: "containsEachRole",
|
|
914
|
+
value: function containsEachRole(roles) {
|
|
915
|
+
var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
|
|
916
|
+
try {
|
|
917
|
+
for(var _iterator = roles[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
|
|
918
|
+
var role = _step.value;
|
|
919
|
+
if (!this._map[role]) {
|
|
920
|
+
return false;
|
|
921
|
+
}
|
|
922
|
+
}
|
|
923
|
+
} catch (err) {
|
|
924
|
+
_didIteratorError = true;
|
|
925
|
+
_iteratorError = err;
|
|
926
|
+
} finally{
|
|
927
|
+
try {
|
|
928
|
+
if (!_iteratorNormalCompletion && _iterator.return != null) {
|
|
929
|
+
_iterator.return();
|
|
930
|
+
}
|
|
931
|
+
} finally{
|
|
932
|
+
if (_didIteratorError) {
|
|
933
|
+
throw _iteratorError;
|
|
934
|
+
}
|
|
935
|
+
}
|
|
936
|
+
}
|
|
937
|
+
return true;
|
|
938
|
+
}
|
|
822
939
|
}
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
}
|
|
940
|
+
]);
|
|
941
|
+
return GrantedRoleMapReaderInstance;
|
|
942
|
+
}();
|
|
826
943
|
/**
|
|
827
944
|
* Converts an array of role strings into a {@link GrantedRoleKeysMap} where each role is mapped to the given boolean value.
|
|
828
945
|
*
|
|
@@ -835,9 +952,13 @@ class GrantedRoleMapReaderInstance {
|
|
|
835
952
|
* const map = grantedRoleKeysMapFromArray(['read', 'update']);
|
|
836
953
|
* // { read: true, update: true }
|
|
837
954
|
* ```
|
|
838
|
-
*/
|
|
839
|
-
|
|
840
|
-
return util.arrayToObject(roles, (x)
|
|
955
|
+
*/ function grantedRoleKeysMapFromArray(roles) {
|
|
956
|
+
var value = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : true;
|
|
957
|
+
return util.arrayToObject(roles, function(x) {
|
|
958
|
+
return x;
|
|
959
|
+
}, function() {
|
|
960
|
+
return value;
|
|
961
|
+
});
|
|
841
962
|
}
|
|
842
963
|
|
|
843
964
|
/**
|
|
@@ -852,8 +973,7 @@ function grantedRoleKeysMapFromArray(roles, value = true) {
|
|
|
852
973
|
* const result = noAccessContextGrantedModelRoles(userContext);
|
|
853
974
|
* // result.roleMap contains the no-access marker
|
|
854
975
|
* ```
|
|
855
|
-
*/
|
|
856
|
-
function noAccessContextGrantedModelRoles(context, data) {
|
|
976
|
+
*/ function noAccessContextGrantedModelRoles(context, data) {
|
|
857
977
|
return contextGrantedModelRoles(context, data, noAccessRoleMap());
|
|
858
978
|
}
|
|
859
979
|
/**
|
|
@@ -868,8 +988,7 @@ function noAccessContextGrantedModelRoles(context, data) {
|
|
|
868
988
|
* const result = fullAccessGrantedModelRoles(adminContext, modelData);
|
|
869
989
|
* // result.roleMap contains the full-access marker
|
|
870
990
|
* ```
|
|
871
|
-
*/
|
|
872
|
-
function fullAccessGrantedModelRoles(context, data) {
|
|
991
|
+
*/ function fullAccessGrantedModelRoles(context, data) {
|
|
873
992
|
return contextGrantedModelRoles(context, data, fullAccessRoleMap());
|
|
874
993
|
}
|
|
875
994
|
/**
|
|
@@ -879,56 +998,303 @@ function fullAccessGrantedModelRoles(context, data) {
|
|
|
879
998
|
* @param data - the model data, if loaded
|
|
880
999
|
* @param roles - the granted role map
|
|
881
1000
|
* @returns a ContextGrantedModelRoles combining all inputs
|
|
882
|
-
*/
|
|
883
|
-
function contextGrantedModelRoles(context, data, roles) {
|
|
1001
|
+
*/ function contextGrantedModelRoles(context, data, roles) {
|
|
884
1002
|
return {
|
|
885
|
-
data,
|
|
886
|
-
context,
|
|
1003
|
+
data: data,
|
|
1004
|
+
context: context,
|
|
887
1005
|
roleMap: roles
|
|
888
1006
|
};
|
|
889
1007
|
}
|
|
890
1008
|
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
|
|
1009
|
+
function asyncGeneratorStep$3(gen, resolve, reject, _next, _throw, key, arg) {
|
|
1010
|
+
try {
|
|
1011
|
+
var info = gen[key](arg);
|
|
1012
|
+
var value = info.value;
|
|
1013
|
+
} catch (error) {
|
|
1014
|
+
reject(error);
|
|
1015
|
+
return;
|
|
898
1016
|
}
|
|
899
|
-
|
|
900
|
-
|
|
1017
|
+
if (info.done) {
|
|
1018
|
+
resolve(value);
|
|
1019
|
+
} else {
|
|
1020
|
+
Promise.resolve(value).then(_next, _throw);
|
|
901
1021
|
}
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
|
|
1022
|
+
}
|
|
1023
|
+
function _async_to_generator$3(fn) {
|
|
1024
|
+
return function() {
|
|
1025
|
+
var self = this, args = arguments;
|
|
1026
|
+
return new Promise(function(resolve, reject) {
|
|
1027
|
+
var gen = fn.apply(self, args);
|
|
1028
|
+
function _next(value) {
|
|
1029
|
+
asyncGeneratorStep$3(gen, resolve, reject, _next, _throw, "next", value);
|
|
1030
|
+
}
|
|
1031
|
+
function _throw(err) {
|
|
1032
|
+
asyncGeneratorStep$3(gen, resolve, reject, _next, _throw, "throw", err);
|
|
1033
|
+
}
|
|
1034
|
+
_next(undefined);
|
|
1035
|
+
});
|
|
1036
|
+
};
|
|
1037
|
+
}
|
|
1038
|
+
function _class_call_check$1(instance, Constructor) {
|
|
1039
|
+
if (!(instance instanceof Constructor)) {
|
|
1040
|
+
throw new TypeError("Cannot call a class as a function");
|
|
912
1041
|
}
|
|
913
|
-
|
|
914
|
-
|
|
915
|
-
|
|
916
|
-
|
|
917
|
-
|
|
918
|
-
|
|
919
|
-
|
|
920
|
-
|
|
921
|
-
|
|
922
|
-
|
|
1042
|
+
}
|
|
1043
|
+
function _defineProperties(target, props) {
|
|
1044
|
+
for(var i = 0; i < props.length; i++){
|
|
1045
|
+
var descriptor = props[i];
|
|
1046
|
+
descriptor.enumerable = descriptor.enumerable || false;
|
|
1047
|
+
descriptor.configurable = true;
|
|
1048
|
+
if ("value" in descriptor) descriptor.writable = true;
|
|
1049
|
+
Object.defineProperty(target, descriptor.key, descriptor);
|
|
1050
|
+
}
|
|
1051
|
+
}
|
|
1052
|
+
function _create_class(Constructor, protoProps, staticProps) {
|
|
1053
|
+
if (protoProps) _defineProperties(Constructor.prototype, protoProps);
|
|
1054
|
+
return Constructor;
|
|
1055
|
+
}
|
|
1056
|
+
function _define_property$2(obj, key, value) {
|
|
1057
|
+
if (key in obj) {
|
|
1058
|
+
Object.defineProperty(obj, key, {
|
|
1059
|
+
value: value,
|
|
1060
|
+
enumerable: true,
|
|
1061
|
+
configurable: true,
|
|
1062
|
+
writable: true
|
|
1063
|
+
});
|
|
1064
|
+
} else {
|
|
1065
|
+
obj[key] = value;
|
|
923
1066
|
}
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
|
|
1067
|
+
return obj;
|
|
1068
|
+
}
|
|
1069
|
+
function _ts_generator$3(thisArg, body) {
|
|
1070
|
+
var f, y, t, _ = {
|
|
1071
|
+
label: 0,
|
|
1072
|
+
sent: function() {
|
|
1073
|
+
if (t[0] & 1) throw t[1];
|
|
1074
|
+
return t[1];
|
|
1075
|
+
},
|
|
1076
|
+
trys: [],
|
|
1077
|
+
ops: []
|
|
1078
|
+
}, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype), d = Object.defineProperty;
|
|
1079
|
+
return d(g, "next", {
|
|
1080
|
+
value: verb(0)
|
|
1081
|
+
}), d(g, "throw", {
|
|
1082
|
+
value: verb(1)
|
|
1083
|
+
}), d(g, "return", {
|
|
1084
|
+
value: verb(2)
|
|
1085
|
+
}), typeof Symbol === "function" && d(g, Symbol.iterator, {
|
|
1086
|
+
value: function() {
|
|
1087
|
+
return this;
|
|
1088
|
+
}
|
|
1089
|
+
}), g;
|
|
1090
|
+
function verb(n) {
|
|
1091
|
+
return function(v) {
|
|
1092
|
+
return step([
|
|
1093
|
+
n,
|
|
1094
|
+
v
|
|
1095
|
+
]);
|
|
1096
|
+
};
|
|
927
1097
|
}
|
|
928
|
-
|
|
929
|
-
|
|
1098
|
+
function step(op) {
|
|
1099
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
1100
|
+
while(g && (g = 0, op[0] && (_ = 0)), _)try {
|
|
1101
|
+
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;
|
|
1102
|
+
if (y = 0, t) op = [
|
|
1103
|
+
op[0] & 2,
|
|
1104
|
+
t.value
|
|
1105
|
+
];
|
|
1106
|
+
switch(op[0]){
|
|
1107
|
+
case 0:
|
|
1108
|
+
case 1:
|
|
1109
|
+
t = op;
|
|
1110
|
+
break;
|
|
1111
|
+
case 4:
|
|
1112
|
+
_.label++;
|
|
1113
|
+
return {
|
|
1114
|
+
value: op[1],
|
|
1115
|
+
done: false
|
|
1116
|
+
};
|
|
1117
|
+
case 5:
|
|
1118
|
+
_.label++;
|
|
1119
|
+
y = op[1];
|
|
1120
|
+
op = [
|
|
1121
|
+
0
|
|
1122
|
+
];
|
|
1123
|
+
continue;
|
|
1124
|
+
case 7:
|
|
1125
|
+
op = _.ops.pop();
|
|
1126
|
+
_.trys.pop();
|
|
1127
|
+
continue;
|
|
1128
|
+
default:
|
|
1129
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
|
|
1130
|
+
_ = 0;
|
|
1131
|
+
continue;
|
|
1132
|
+
}
|
|
1133
|
+
if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) {
|
|
1134
|
+
_.label = op[1];
|
|
1135
|
+
break;
|
|
1136
|
+
}
|
|
1137
|
+
if (op[0] === 6 && _.label < t[1]) {
|
|
1138
|
+
_.label = t[1];
|
|
1139
|
+
t = op;
|
|
1140
|
+
break;
|
|
1141
|
+
}
|
|
1142
|
+
if (t && _.label < t[2]) {
|
|
1143
|
+
_.label = t[2];
|
|
1144
|
+
_.ops.push(op);
|
|
1145
|
+
break;
|
|
1146
|
+
}
|
|
1147
|
+
if (t[2]) _.ops.pop();
|
|
1148
|
+
_.trys.pop();
|
|
1149
|
+
continue;
|
|
1150
|
+
}
|
|
1151
|
+
op = body.call(thisArg, _);
|
|
1152
|
+
} catch (e) {
|
|
1153
|
+
op = [
|
|
1154
|
+
6,
|
|
1155
|
+
e
|
|
1156
|
+
];
|
|
1157
|
+
y = 0;
|
|
1158
|
+
} finally{
|
|
1159
|
+
f = t = 0;
|
|
1160
|
+
}
|
|
1161
|
+
if (op[0] & 5) throw op[1];
|
|
1162
|
+
return {
|
|
1163
|
+
value: op[0] ? op[1] : void 0,
|
|
1164
|
+
done: true
|
|
1165
|
+
};
|
|
930
1166
|
}
|
|
931
1167
|
}
|
|
1168
|
+
/**
|
|
1169
|
+
* Abstract ModelPermissionService implementation.
|
|
1170
|
+
*/ var AbstractModelPermissionService = /*#__PURE__*/ function() {
|
|
1171
|
+
function AbstractModelPermissionService(modelLoader) {
|
|
1172
|
+
_class_call_check$1(this, AbstractModelPermissionService);
|
|
1173
|
+
_define_property$2(this, "_modelLoader", void 0);
|
|
1174
|
+
this._modelLoader = modelLoader;
|
|
1175
|
+
}
|
|
1176
|
+
_create_class(AbstractModelPermissionService, [
|
|
1177
|
+
{
|
|
1178
|
+
key: "modelLoader",
|
|
1179
|
+
get: function get() {
|
|
1180
|
+
return this._modelLoader;
|
|
1181
|
+
}
|
|
1182
|
+
},
|
|
1183
|
+
{
|
|
1184
|
+
key: "roleMapForKeyContext",
|
|
1185
|
+
value: function roleMapForKeyContext(key, context) {
|
|
1186
|
+
return _async_to_generator$3(function() {
|
|
1187
|
+
var model, result;
|
|
1188
|
+
return _ts_generator$3(this, function(_state) {
|
|
1189
|
+
switch(_state.label){
|
|
1190
|
+
case 0:
|
|
1191
|
+
return [
|
|
1192
|
+
4,
|
|
1193
|
+
this.modelLoader.loadModelForKey(key, context)
|
|
1194
|
+
];
|
|
1195
|
+
case 1:
|
|
1196
|
+
model = _state.sent();
|
|
1197
|
+
if (!(model != null)) return [
|
|
1198
|
+
3,
|
|
1199
|
+
3
|
|
1200
|
+
];
|
|
1201
|
+
return [
|
|
1202
|
+
4,
|
|
1203
|
+
this.roleMapForModelContext(model, context)
|
|
1204
|
+
];
|
|
1205
|
+
case 2:
|
|
1206
|
+
result = _state.sent();
|
|
1207
|
+
return [
|
|
1208
|
+
3,
|
|
1209
|
+
4
|
|
1210
|
+
];
|
|
1211
|
+
case 3:
|
|
1212
|
+
result = noAccessContextGrantedModelRoles(context);
|
|
1213
|
+
_state.label = 4;
|
|
1214
|
+
case 4:
|
|
1215
|
+
return [
|
|
1216
|
+
2,
|
|
1217
|
+
result
|
|
1218
|
+
];
|
|
1219
|
+
}
|
|
1220
|
+
});
|
|
1221
|
+
}).call(this);
|
|
1222
|
+
}
|
|
1223
|
+
},
|
|
1224
|
+
{
|
|
1225
|
+
key: "roleMapForModelContext",
|
|
1226
|
+
value: function roleMapForModelContext(model, context) {
|
|
1227
|
+
return _async_to_generator$3(function() {
|
|
1228
|
+
var output, result;
|
|
1229
|
+
return _ts_generator$3(this, function(_state) {
|
|
1230
|
+
switch(_state.label){
|
|
1231
|
+
case 0:
|
|
1232
|
+
return [
|
|
1233
|
+
4,
|
|
1234
|
+
this.outputForModel(model, context)
|
|
1235
|
+
];
|
|
1236
|
+
case 1:
|
|
1237
|
+
output = _state.sent();
|
|
1238
|
+
if (!(output != null && this.isUsableOutputForRoles(output, context))) return [
|
|
1239
|
+
3,
|
|
1240
|
+
3
|
|
1241
|
+
];
|
|
1242
|
+
return [
|
|
1243
|
+
4,
|
|
1244
|
+
this.getRoleMapForOutput(output, context, model)
|
|
1245
|
+
];
|
|
1246
|
+
case 2:
|
|
1247
|
+
result = _state.sent();
|
|
1248
|
+
return [
|
|
1249
|
+
3,
|
|
1250
|
+
4
|
|
1251
|
+
];
|
|
1252
|
+
case 3:
|
|
1253
|
+
result = noAccessContextGrantedModelRoles(context, output);
|
|
1254
|
+
_state.label = 4;
|
|
1255
|
+
case 4:
|
|
1256
|
+
return [
|
|
1257
|
+
2,
|
|
1258
|
+
result
|
|
1259
|
+
];
|
|
1260
|
+
}
|
|
1261
|
+
});
|
|
1262
|
+
}).call(this);
|
|
1263
|
+
}
|
|
1264
|
+
},
|
|
1265
|
+
{
|
|
1266
|
+
key: "getRoleMapForOutput",
|
|
1267
|
+
value: function getRoleMapForOutput(output, context, model) {
|
|
1268
|
+
return _async_to_generator$3(function() {
|
|
1269
|
+
var roleMap;
|
|
1270
|
+
return _ts_generator$3(this, function(_state) {
|
|
1271
|
+
switch(_state.label){
|
|
1272
|
+
case 0:
|
|
1273
|
+
return [
|
|
1274
|
+
4,
|
|
1275
|
+
this.roleMapForModel(output, context, model)
|
|
1276
|
+
];
|
|
1277
|
+
case 1:
|
|
1278
|
+
roleMap = _state.sent();
|
|
1279
|
+
return [
|
|
1280
|
+
2,
|
|
1281
|
+
contextGrantedModelRoles(context, output, roleMap)
|
|
1282
|
+
];
|
|
1283
|
+
}
|
|
1284
|
+
});
|
|
1285
|
+
}).call(this);
|
|
1286
|
+
}
|
|
1287
|
+
},
|
|
1288
|
+
{
|
|
1289
|
+
key: "isUsableOutputForRoles",
|
|
1290
|
+
value: function isUsableOutputForRoles(output, context) {
|
|
1291
|
+
return true; // can override in parent functions to further filter roles.
|
|
1292
|
+
}
|
|
1293
|
+
}
|
|
1294
|
+
]);
|
|
1295
|
+
return AbstractModelPermissionService;
|
|
1296
|
+
}
|
|
1297
|
+
();
|
|
932
1298
|
|
|
933
1299
|
/**
|
|
934
1300
|
* Creates a factory that normalizes a {@link SyncEntityCommonTypeIdPairFactoryInput} into a full {@link SyncEntityCommonTypeIdPair}.
|
|
@@ -945,16 +1311,14 @@ class AbstractModelPermissionService {
|
|
|
945
1311
|
* factory('abc123'); // { commonType: 'user', commonId: 'abc123' }
|
|
946
1312
|
* factory({ commonType: 'user', commonId: 'abc123' }); // passed through as-is
|
|
947
1313
|
* ```
|
|
948
|
-
*/
|
|
949
|
-
function
|
|
950
|
-
return (input) => {
|
|
1314
|
+
*/ function syncEntityCommonTypeIdPairFactory(commonType) {
|
|
1315
|
+
return function(input) {
|
|
951
1316
|
if (typeof input === 'string') {
|
|
952
1317
|
return {
|
|
953
|
-
commonType,
|
|
1318
|
+
commonType: commonType,
|
|
954
1319
|
commonId: input
|
|
955
1320
|
};
|
|
956
|
-
}
|
|
957
|
-
else {
|
|
1321
|
+
} else {
|
|
958
1322
|
return input;
|
|
959
1323
|
}
|
|
960
1324
|
};
|
|
@@ -977,64 +1341,155 @@ function syncEntityCommonTypeIdPairFactory(commonType) {
|
|
|
977
1341
|
* const entity = factory({ commonType: 'user', commonId: 'abc123' });
|
|
978
1342
|
* // entity.id === 'abc123', entity.sourceInfo.id === 'api'
|
|
979
1343
|
* ```
|
|
980
|
-
*/
|
|
981
|
-
|
|
982
|
-
|
|
983
|
-
|
|
984
|
-
|
|
985
|
-
|
|
986
|
-
const id = idFactory(commonId);
|
|
1344
|
+
*/ function syncEntityFactory(config) {
|
|
1345
|
+
var inputIdFactory = config.idFactory, sourceInfo = config.sourceInfo;
|
|
1346
|
+
var idFactory = inputIdFactory !== null && inputIdFactory !== void 0 ? inputIdFactory : util.MAP_IDENTITY;
|
|
1347
|
+
return function(input) {
|
|
1348
|
+
var commonType = input.commonType, commonId = input.commonId;
|
|
1349
|
+
var id = idFactory(commonId);
|
|
987
1350
|
return {
|
|
988
|
-
commonType,
|
|
989
|
-
commonId,
|
|
990
|
-
id,
|
|
991
|
-
sourceInfo
|
|
1351
|
+
commonType: commonType,
|
|
1352
|
+
commonId: commonId,
|
|
1353
|
+
id: id,
|
|
1354
|
+
sourceInfo: sourceInfo
|
|
992
1355
|
};
|
|
993
1356
|
};
|
|
994
1357
|
}
|
|
995
1358
|
|
|
1359
|
+
function _assert_this_initialized(self) {
|
|
1360
|
+
if (self === void 0) {
|
|
1361
|
+
throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
|
|
1362
|
+
}
|
|
1363
|
+
return self;
|
|
1364
|
+
}
|
|
1365
|
+
function _call_super(_this, derived, args) {
|
|
1366
|
+
derived = _get_prototype_of(derived);
|
|
1367
|
+
return _possible_constructor_return(_this, _is_native_reflect_construct() ? Reflect.construct(derived, args || [], _get_prototype_of(_this).constructor) : derived.apply(_this, args));
|
|
1368
|
+
}
|
|
1369
|
+
function _class_call_check(instance, Constructor) {
|
|
1370
|
+
if (!(instance instanceof Constructor)) {
|
|
1371
|
+
throw new TypeError("Cannot call a class as a function");
|
|
1372
|
+
}
|
|
1373
|
+
}
|
|
1374
|
+
function _define_property$1(obj, key, value) {
|
|
1375
|
+
if (key in obj) {
|
|
1376
|
+
Object.defineProperty(obj, key, {
|
|
1377
|
+
value: value,
|
|
1378
|
+
enumerable: true,
|
|
1379
|
+
configurable: true,
|
|
1380
|
+
writable: true
|
|
1381
|
+
});
|
|
1382
|
+
} else {
|
|
1383
|
+
obj[key] = value;
|
|
1384
|
+
}
|
|
1385
|
+
return obj;
|
|
1386
|
+
}
|
|
1387
|
+
function _get_prototype_of(o) {
|
|
1388
|
+
_get_prototype_of = Object.setPrototypeOf ? Object.getPrototypeOf : function getPrototypeOf(o) {
|
|
1389
|
+
return o.__proto__ || Object.getPrototypeOf(o);
|
|
1390
|
+
};
|
|
1391
|
+
return _get_prototype_of(o);
|
|
1392
|
+
}
|
|
1393
|
+
function _inherits(subClass, superClass) {
|
|
1394
|
+
if (typeof superClass !== "function" && superClass !== null) {
|
|
1395
|
+
throw new TypeError("Super expression must either be null or a function");
|
|
1396
|
+
}
|
|
1397
|
+
subClass.prototype = Object.create(superClass && superClass.prototype, {
|
|
1398
|
+
constructor: {
|
|
1399
|
+
value: subClass,
|
|
1400
|
+
writable: true,
|
|
1401
|
+
configurable: true
|
|
1402
|
+
}
|
|
1403
|
+
});
|
|
1404
|
+
if (superClass) _set_prototype_of(subClass, superClass);
|
|
1405
|
+
}
|
|
1406
|
+
function _possible_constructor_return(self, call) {
|
|
1407
|
+
if (call && (_type_of(call) === "object" || typeof call === "function")) {
|
|
1408
|
+
return call;
|
|
1409
|
+
}
|
|
1410
|
+
return _assert_this_initialized(self);
|
|
1411
|
+
}
|
|
1412
|
+
function _set_prototype_of(o, p) {
|
|
1413
|
+
_set_prototype_of = Object.setPrototypeOf || function setPrototypeOf(o, p) {
|
|
1414
|
+
o.__proto__ = p;
|
|
1415
|
+
return o;
|
|
1416
|
+
};
|
|
1417
|
+
return _set_prototype_of(o, p);
|
|
1418
|
+
}
|
|
1419
|
+
function _type_of(obj) {
|
|
1420
|
+
"@swc/helpers - typeof";
|
|
1421
|
+
return obj && typeof Symbol !== "undefined" && obj.constructor === Symbol ? "symbol" : typeof obj;
|
|
1422
|
+
}
|
|
1423
|
+
function _is_native_reflect_construct() {
|
|
1424
|
+
try {
|
|
1425
|
+
var result = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function() {}));
|
|
1426
|
+
} catch (_) {}
|
|
1427
|
+
return (_is_native_reflect_construct = function() {
|
|
1428
|
+
return !!result;
|
|
1429
|
+
})();
|
|
1430
|
+
}
|
|
996
1431
|
/**
|
|
997
1432
|
* Error thrown when the common type is not known/registered.
|
|
998
|
-
*/
|
|
999
|
-
|
|
1000
|
-
commonType
|
|
1001
|
-
|
|
1002
|
-
|
|
1003
|
-
|
|
1433
|
+
*/ var UnregisteredSyncEntityCommonTypeError = /*#__PURE__*/ function(BaseError) {
|
|
1434
|
+
_inherits(UnregisteredSyncEntityCommonTypeError, BaseError);
|
|
1435
|
+
function UnregisteredSyncEntityCommonTypeError(commonType) {
|
|
1436
|
+
_class_call_check(this, UnregisteredSyncEntityCommonTypeError);
|
|
1437
|
+
var _this;
|
|
1438
|
+
_this = _call_super(this, UnregisteredSyncEntityCommonTypeError, [
|
|
1439
|
+
'The common type "'.concat(commonType, '" is not registered.')
|
|
1440
|
+
]), _define_property$1(_this, "commonType", void 0);
|
|
1441
|
+
_this.commonType = commonType;
|
|
1442
|
+
return _this;
|
|
1004
1443
|
}
|
|
1005
|
-
|
|
1444
|
+
return UnregisteredSyncEntityCommonTypeError;
|
|
1445
|
+
}(makeError.BaseError);
|
|
1006
1446
|
/**
|
|
1007
1447
|
* Error thrown when no primary sync source is found for an entity.
|
|
1008
|
-
*/
|
|
1009
|
-
|
|
1010
|
-
entity
|
|
1011
|
-
|
|
1012
|
-
|
|
1013
|
-
|
|
1448
|
+
*/ var NoPrimarySyncSourceError = /*#__PURE__*/ function(BaseError) {
|
|
1449
|
+
_inherits(NoPrimarySyncSourceError, BaseError);
|
|
1450
|
+
function NoPrimarySyncSourceError(entity) {
|
|
1451
|
+
_class_call_check(this, NoPrimarySyncSourceError);
|
|
1452
|
+
var _this;
|
|
1453
|
+
_this = _call_super(this, NoPrimarySyncSourceError, [
|
|
1454
|
+
'No primary sync source found for entity "'.concat(entity.commonType, ":").concat(entity.commonId, '".')
|
|
1455
|
+
]), _define_property$1(_this, "entity", void 0);
|
|
1456
|
+
_this.entity = entity;
|
|
1457
|
+
return _this;
|
|
1014
1458
|
}
|
|
1015
|
-
|
|
1459
|
+
return NoPrimarySyncSourceError;
|
|
1460
|
+
}(makeError.BaseError);
|
|
1016
1461
|
/**
|
|
1017
1462
|
* Error thrown when multiple primary sync sources are found for an entity.
|
|
1018
|
-
*/
|
|
1019
|
-
|
|
1020
|
-
entity
|
|
1021
|
-
|
|
1022
|
-
|
|
1023
|
-
|
|
1463
|
+
*/ var MultiplePrimarySyncSourceError = /*#__PURE__*/ function(BaseError) {
|
|
1464
|
+
_inherits(MultiplePrimarySyncSourceError, BaseError);
|
|
1465
|
+
function MultiplePrimarySyncSourceError(entity) {
|
|
1466
|
+
_class_call_check(this, MultiplePrimarySyncSourceError);
|
|
1467
|
+
var _this;
|
|
1468
|
+
_this = _call_super(this, MultiplePrimarySyncSourceError, [
|
|
1469
|
+
'Multiple primary sync sources found for entity "'.concat(entity.commonType, ":").concat(entity.commonId, '".')
|
|
1470
|
+
]), _define_property$1(_this, "entity", void 0);
|
|
1471
|
+
_this.entity = entity;
|
|
1472
|
+
return _this;
|
|
1024
1473
|
}
|
|
1025
|
-
|
|
1474
|
+
return MultiplePrimarySyncSourceError;
|
|
1475
|
+
}(makeError.BaseError);
|
|
1026
1476
|
/**
|
|
1027
1477
|
* Error thrown when a synchronization fails for an entity.
|
|
1028
|
-
*/
|
|
1029
|
-
|
|
1030
|
-
entity
|
|
1031
|
-
|
|
1032
|
-
|
|
1033
|
-
|
|
1034
|
-
|
|
1035
|
-
|
|
1478
|
+
*/ var SynchronizationFailedError = /*#__PURE__*/ function(BaseError) {
|
|
1479
|
+
_inherits(SynchronizationFailedError, BaseError);
|
|
1480
|
+
function SynchronizationFailedError(entity, error) {
|
|
1481
|
+
_class_call_check(this, SynchronizationFailedError);
|
|
1482
|
+
var _this;
|
|
1483
|
+
_this = _call_super(this, SynchronizationFailedError, [
|
|
1484
|
+
'Synchronization failed for entity "'.concat(entity.commonType, ":").concat(entity.commonId, '". Error: ').concat(error)
|
|
1485
|
+
]), _define_property$1(_this, "entity", void 0), _define_property$1(_this, "error", void 0);
|
|
1486
|
+
_this.entity = entity;
|
|
1487
|
+
_this.error = error;
|
|
1488
|
+
return _this;
|
|
1036
1489
|
}
|
|
1037
|
-
|
|
1490
|
+
return SynchronizationFailedError;
|
|
1491
|
+
}
|
|
1492
|
+
(makeError.BaseError);
|
|
1038
1493
|
|
|
1039
1494
|
/**
|
|
1040
1495
|
* Creates a {@link SyncEntitySynchronizer} from the given configuration.
|
|
@@ -1055,27 +1510,268 @@ class SynchronizationFailedError extends makeError.BaseError {
|
|
|
1055
1510
|
* const instance = await synchronizer.synchronizeInstance({ commonType: 'user', commonId: '123' });
|
|
1056
1511
|
* const result = await instance.synchronize();
|
|
1057
1512
|
* ```
|
|
1058
|
-
*/
|
|
1059
|
-
|
|
1060
|
-
|
|
1061
|
-
|
|
1062
|
-
|
|
1063
|
-
|
|
1513
|
+
*/ function syncEntitySynchronizer(config) {
|
|
1514
|
+
var map = new Map(config.commonTypeSynchronizers.map(function(x) {
|
|
1515
|
+
return [
|
|
1516
|
+
x.commonType,
|
|
1517
|
+
x
|
|
1518
|
+
];
|
|
1519
|
+
}));
|
|
1520
|
+
var commonTypes = Array.from(map.keys());
|
|
1521
|
+
var commonTypeSynchronizer = function commonTypeSynchronizer(input) {
|
|
1522
|
+
var synchronizer = map.get(input);
|
|
1064
1523
|
if (!synchronizer) {
|
|
1065
1524
|
throw new UnregisteredSyncEntityCommonTypeError(input);
|
|
1066
1525
|
}
|
|
1067
1526
|
return synchronizer;
|
|
1068
1527
|
};
|
|
1069
1528
|
return {
|
|
1070
|
-
commonTypes,
|
|
1071
|
-
commonTypeSynchronizer,
|
|
1072
|
-
synchronizeInstance: (input)
|
|
1073
|
-
|
|
1529
|
+
commonTypes: commonTypes,
|
|
1530
|
+
commonTypeSynchronizer: commonTypeSynchronizer,
|
|
1531
|
+
synchronizeInstance: function synchronizeInstance(input) {
|
|
1532
|
+
var synchronizer = commonTypeSynchronizer(input.commonType);
|
|
1074
1533
|
return synchronizer.synchronizeInstance(input);
|
|
1075
1534
|
}
|
|
1076
1535
|
};
|
|
1077
1536
|
}
|
|
1078
1537
|
|
|
1538
|
+
function _array_like_to_array(arr, len) {
|
|
1539
|
+
if (len == null || len > arr.length) len = arr.length;
|
|
1540
|
+
for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
|
|
1541
|
+
return arr2;
|
|
1542
|
+
}
|
|
1543
|
+
function _array_with_holes(arr) {
|
|
1544
|
+
if (Array.isArray(arr)) return arr;
|
|
1545
|
+
}
|
|
1546
|
+
function _array_without_holes(arr) {
|
|
1547
|
+
if (Array.isArray(arr)) return _array_like_to_array(arr);
|
|
1548
|
+
}
|
|
1549
|
+
function asyncGeneratorStep$2(gen, resolve, reject, _next, _throw, key, arg) {
|
|
1550
|
+
try {
|
|
1551
|
+
var info = gen[key](arg);
|
|
1552
|
+
var value = info.value;
|
|
1553
|
+
} catch (error) {
|
|
1554
|
+
reject(error);
|
|
1555
|
+
return;
|
|
1556
|
+
}
|
|
1557
|
+
if (info.done) {
|
|
1558
|
+
resolve(value);
|
|
1559
|
+
} else {
|
|
1560
|
+
Promise.resolve(value).then(_next, _throw);
|
|
1561
|
+
}
|
|
1562
|
+
}
|
|
1563
|
+
function _async_to_generator$2(fn) {
|
|
1564
|
+
return function() {
|
|
1565
|
+
var self = this, args = arguments;
|
|
1566
|
+
return new Promise(function(resolve, reject) {
|
|
1567
|
+
var gen = fn.apply(self, args);
|
|
1568
|
+
function _next(value) {
|
|
1569
|
+
asyncGeneratorStep$2(gen, resolve, reject, _next, _throw, "next", value);
|
|
1570
|
+
}
|
|
1571
|
+
function _throw(err) {
|
|
1572
|
+
asyncGeneratorStep$2(gen, resolve, reject, _next, _throw, "throw", err);
|
|
1573
|
+
}
|
|
1574
|
+
_next(undefined);
|
|
1575
|
+
});
|
|
1576
|
+
};
|
|
1577
|
+
}
|
|
1578
|
+
function _define_property(obj, key, value) {
|
|
1579
|
+
if (key in obj) {
|
|
1580
|
+
Object.defineProperty(obj, key, {
|
|
1581
|
+
value: value,
|
|
1582
|
+
enumerable: true,
|
|
1583
|
+
configurable: true,
|
|
1584
|
+
writable: true
|
|
1585
|
+
});
|
|
1586
|
+
} else {
|
|
1587
|
+
obj[key] = value;
|
|
1588
|
+
}
|
|
1589
|
+
return obj;
|
|
1590
|
+
}
|
|
1591
|
+
function _iterable_to_array(iter) {
|
|
1592
|
+
if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter);
|
|
1593
|
+
}
|
|
1594
|
+
function _iterable_to_array_limit(arr, i) {
|
|
1595
|
+
var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"];
|
|
1596
|
+
if (_i == null) return;
|
|
1597
|
+
var _arr = [];
|
|
1598
|
+
var _n = true;
|
|
1599
|
+
var _d = false;
|
|
1600
|
+
var _s, _e;
|
|
1601
|
+
try {
|
|
1602
|
+
for(_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true){
|
|
1603
|
+
_arr.push(_s.value);
|
|
1604
|
+
if (i && _arr.length === i) break;
|
|
1605
|
+
}
|
|
1606
|
+
} catch (err) {
|
|
1607
|
+
_d = true;
|
|
1608
|
+
_e = err;
|
|
1609
|
+
} finally{
|
|
1610
|
+
try {
|
|
1611
|
+
if (!_n && _i["return"] != null) _i["return"]();
|
|
1612
|
+
} finally{
|
|
1613
|
+
if (_d) throw _e;
|
|
1614
|
+
}
|
|
1615
|
+
}
|
|
1616
|
+
return _arr;
|
|
1617
|
+
}
|
|
1618
|
+
function _non_iterable_rest() {
|
|
1619
|
+
throw new TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
1620
|
+
}
|
|
1621
|
+
function _non_iterable_spread() {
|
|
1622
|
+
throw new TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
1623
|
+
}
|
|
1624
|
+
function _object_destructuring_empty(o) {
|
|
1625
|
+
if (o === null || o === void 0) throw new TypeError("Cannot destructure " + o);
|
|
1626
|
+
return o;
|
|
1627
|
+
}
|
|
1628
|
+
function _object_spread(target) {
|
|
1629
|
+
for(var i = 1; i < arguments.length; i++){
|
|
1630
|
+
var source = arguments[i] != null ? arguments[i] : {};
|
|
1631
|
+
var ownKeys = Object.keys(source);
|
|
1632
|
+
if (typeof Object.getOwnPropertySymbols === "function") {
|
|
1633
|
+
ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function(sym) {
|
|
1634
|
+
return Object.getOwnPropertyDescriptor(source, sym).enumerable;
|
|
1635
|
+
}));
|
|
1636
|
+
}
|
|
1637
|
+
ownKeys.forEach(function(key) {
|
|
1638
|
+
_define_property(target, key, source[key]);
|
|
1639
|
+
});
|
|
1640
|
+
}
|
|
1641
|
+
return target;
|
|
1642
|
+
}
|
|
1643
|
+
function ownKeys(object, enumerableOnly) {
|
|
1644
|
+
var keys = Object.keys(object);
|
|
1645
|
+
if (Object.getOwnPropertySymbols) {
|
|
1646
|
+
var symbols = Object.getOwnPropertySymbols(object);
|
|
1647
|
+
keys.push.apply(keys, symbols);
|
|
1648
|
+
}
|
|
1649
|
+
return keys;
|
|
1650
|
+
}
|
|
1651
|
+
function _object_spread_props(target, source) {
|
|
1652
|
+
source = source != null ? source : {};
|
|
1653
|
+
if (Object.getOwnPropertyDescriptors) {
|
|
1654
|
+
Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
|
|
1655
|
+
} else {
|
|
1656
|
+
ownKeys(Object(source)).forEach(function(key) {
|
|
1657
|
+
Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
|
|
1658
|
+
});
|
|
1659
|
+
}
|
|
1660
|
+
return target;
|
|
1661
|
+
}
|
|
1662
|
+
function _sliced_to_array(arr, i) {
|
|
1663
|
+
return _array_with_holes(arr) || _iterable_to_array_limit(arr, i) || _unsupported_iterable_to_array(arr, i) || _non_iterable_rest();
|
|
1664
|
+
}
|
|
1665
|
+
function _to_consumable_array(arr) {
|
|
1666
|
+
return _array_without_holes(arr) || _iterable_to_array(arr) || _unsupported_iterable_to_array(arr) || _non_iterable_spread();
|
|
1667
|
+
}
|
|
1668
|
+
function _unsupported_iterable_to_array(o, minLen) {
|
|
1669
|
+
if (!o) return;
|
|
1670
|
+
if (typeof o === "string") return _array_like_to_array(o, minLen);
|
|
1671
|
+
var n = Object.prototype.toString.call(o).slice(8, -1);
|
|
1672
|
+
if (n === "Object" && o.constructor) n = o.constructor.name;
|
|
1673
|
+
if (n === "Map" || n === "Set") return Array.from(n);
|
|
1674
|
+
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array(o, minLen);
|
|
1675
|
+
}
|
|
1676
|
+
function _ts_generator$2(thisArg, body) {
|
|
1677
|
+
var f, y, t, _ = {
|
|
1678
|
+
label: 0,
|
|
1679
|
+
sent: function() {
|
|
1680
|
+
if (t[0] & 1) throw t[1];
|
|
1681
|
+
return t[1];
|
|
1682
|
+
},
|
|
1683
|
+
trys: [],
|
|
1684
|
+
ops: []
|
|
1685
|
+
}, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype), d = Object.defineProperty;
|
|
1686
|
+
return d(g, "next", {
|
|
1687
|
+
value: verb(0)
|
|
1688
|
+
}), d(g, "throw", {
|
|
1689
|
+
value: verb(1)
|
|
1690
|
+
}), d(g, "return", {
|
|
1691
|
+
value: verb(2)
|
|
1692
|
+
}), typeof Symbol === "function" && d(g, Symbol.iterator, {
|
|
1693
|
+
value: function() {
|
|
1694
|
+
return this;
|
|
1695
|
+
}
|
|
1696
|
+
}), g;
|
|
1697
|
+
function verb(n) {
|
|
1698
|
+
return function(v) {
|
|
1699
|
+
return step([
|
|
1700
|
+
n,
|
|
1701
|
+
v
|
|
1702
|
+
]);
|
|
1703
|
+
};
|
|
1704
|
+
}
|
|
1705
|
+
function step(op) {
|
|
1706
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
1707
|
+
while(g && (g = 0, op[0] && (_ = 0)), _)try {
|
|
1708
|
+
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;
|
|
1709
|
+
if (y = 0, t) op = [
|
|
1710
|
+
op[0] & 2,
|
|
1711
|
+
t.value
|
|
1712
|
+
];
|
|
1713
|
+
switch(op[0]){
|
|
1714
|
+
case 0:
|
|
1715
|
+
case 1:
|
|
1716
|
+
t = op;
|
|
1717
|
+
break;
|
|
1718
|
+
case 4:
|
|
1719
|
+
_.label++;
|
|
1720
|
+
return {
|
|
1721
|
+
value: op[1],
|
|
1722
|
+
done: false
|
|
1723
|
+
};
|
|
1724
|
+
case 5:
|
|
1725
|
+
_.label++;
|
|
1726
|
+
y = op[1];
|
|
1727
|
+
op = [
|
|
1728
|
+
0
|
|
1729
|
+
];
|
|
1730
|
+
continue;
|
|
1731
|
+
case 7:
|
|
1732
|
+
op = _.ops.pop();
|
|
1733
|
+
_.trys.pop();
|
|
1734
|
+
continue;
|
|
1735
|
+
default:
|
|
1736
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
|
|
1737
|
+
_ = 0;
|
|
1738
|
+
continue;
|
|
1739
|
+
}
|
|
1740
|
+
if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) {
|
|
1741
|
+
_.label = op[1];
|
|
1742
|
+
break;
|
|
1743
|
+
}
|
|
1744
|
+
if (op[0] === 6 && _.label < t[1]) {
|
|
1745
|
+
_.label = t[1];
|
|
1746
|
+
t = op;
|
|
1747
|
+
break;
|
|
1748
|
+
}
|
|
1749
|
+
if (t && _.label < t[2]) {
|
|
1750
|
+
_.label = t[2];
|
|
1751
|
+
_.ops.push(op);
|
|
1752
|
+
break;
|
|
1753
|
+
}
|
|
1754
|
+
if (t[2]) _.ops.pop();
|
|
1755
|
+
_.trys.pop();
|
|
1756
|
+
continue;
|
|
1757
|
+
}
|
|
1758
|
+
op = body.call(thisArg, _);
|
|
1759
|
+
} catch (e) {
|
|
1760
|
+
op = [
|
|
1761
|
+
6,
|
|
1762
|
+
e
|
|
1763
|
+
];
|
|
1764
|
+
y = 0;
|
|
1765
|
+
} finally{
|
|
1766
|
+
f = t = 0;
|
|
1767
|
+
}
|
|
1768
|
+
if (op[0] & 5) throw op[1];
|
|
1769
|
+
return {
|
|
1770
|
+
value: op[0] ? op[1] : void 0,
|
|
1771
|
+
done: true
|
|
1772
|
+
};
|
|
1773
|
+
}
|
|
1774
|
+
}
|
|
1079
1775
|
/**
|
|
1080
1776
|
* Creates a {@link BasicSyncEntityCommonTypeSynchronizer} that orchestrates synchronization across multiple sources
|
|
1081
1777
|
* for a specific entity common type.
|
|
@@ -1090,68 +1786,81 @@ function syncEntitySynchronizer(config) {
|
|
|
1090
1786
|
* @throws {NoPrimarySyncSourceError} when no primary source is found
|
|
1091
1787
|
* @throws {MultiplePrimarySyncSourceError} when more than one primary source is found
|
|
1092
1788
|
* @throws {SynchronizationFailedError} when primary or secondary sync returns failed/error
|
|
1093
|
-
*/
|
|
1094
|
-
|
|
1095
|
-
|
|
1096
|
-
|
|
1097
|
-
|
|
1098
|
-
|
|
1099
|
-
|
|
1789
|
+
*/ function basicSyncEntityCommonTypeSynchronizerInstanceFactory(config) {
|
|
1790
|
+
var _sourcesByContextType_get, _sourcesByContextType_get1;
|
|
1791
|
+
var commonType = config.commonType, sources = config.sources, entitySourceContextLoader = config.entitySourceContextLoader, _config_dynamicSources = config.dynamicSources, dynamicSources = _config_dynamicSources === void 0 ? false : _config_dynamicSources;
|
|
1792
|
+
var syncEntityCommonTypeIdPairForType = syncEntityCommonTypeIdPairFactory(commonType);
|
|
1793
|
+
var sourcesByContextType = util.makeValuesGroupMap(sources, function(x) {
|
|
1794
|
+
return x.contextType;
|
|
1795
|
+
});
|
|
1796
|
+
var allGlobalSources = (_sourcesByContextType_get = sourcesByContextType.get('global')) !== null && _sourcesByContextType_get !== void 0 ? _sourcesByContextType_get : [];
|
|
1797
|
+
var allContextSources = (_sourcesByContextType_get1 = sourcesByContextType.get('context')) !== null && _sourcesByContextType_get1 !== void 0 ? _sourcesByContextType_get1 : [];
|
|
1100
1798
|
/**
|
|
1101
1799
|
* Loads the relevant sources for the given entity and context.
|
|
1102
1800
|
*
|
|
1103
1801
|
* @param entitySourceContext The contextual information for the entity.
|
|
1104
1802
|
* @returns The relevant sources for the entity.
|
|
1105
|
-
*/
|
|
1106
|
-
|
|
1107
|
-
const { globalSources, contextSources } = entitySourceContext;
|
|
1803
|
+
*/ function loadSources(entityCommonTypeIdPair, entitySourceContext) {
|
|
1804
|
+
var globalSources = entitySourceContext.globalSources, contextSources = entitySourceContext.contextSources;
|
|
1108
1805
|
// load/filter global sources
|
|
1109
|
-
|
|
1110
|
-
|
|
1111
|
-
|
|
1806
|
+
var globalMap = new Map(globalSources.map(function(x) {
|
|
1807
|
+
var sourceId;
|
|
1808
|
+
var flowType;
|
|
1112
1809
|
if (typeof x === 'string') {
|
|
1113
1810
|
sourceId = x;
|
|
1114
1811
|
flowType = 'unset';
|
|
1115
|
-
}
|
|
1116
|
-
else {
|
|
1812
|
+
} else {
|
|
1117
1813
|
sourceId = x.sourceId;
|
|
1118
1814
|
flowType = x.flowType;
|
|
1119
1815
|
}
|
|
1120
|
-
return [
|
|
1816
|
+
return [
|
|
1817
|
+
sourceId,
|
|
1818
|
+
{
|
|
1819
|
+
sourceId: sourceId,
|
|
1820
|
+
flowType: flowType
|
|
1821
|
+
}
|
|
1822
|
+
];
|
|
1121
1823
|
}));
|
|
1122
|
-
|
|
1123
|
-
|
|
1124
|
-
|
|
1824
|
+
var relevantGlobalSources = util.filterMaybeArrayValues(allGlobalSources.map(function(x) {
|
|
1825
|
+
var sourceContext = globalMap.get(x.info.id);
|
|
1826
|
+
var result;
|
|
1125
1827
|
if (sourceContext != null) {
|
|
1828
|
+
var _ref, _sourceContext_flowType;
|
|
1126
1829
|
result = {
|
|
1127
|
-
entityCommonTypeIdPair,
|
|
1128
|
-
flowType: sourceContext.flowType
|
|
1830
|
+
entityCommonTypeIdPair: entityCommonTypeIdPair,
|
|
1831
|
+
flowType: (_ref = (_sourceContext_flowType = sourceContext.flowType) !== null && _sourceContext_flowType !== void 0 ? _sourceContext_flowType : x.defaultFlowType) !== null && _ref !== void 0 ? _ref : 'unset',
|
|
1129
1832
|
source: x
|
|
1130
1833
|
};
|
|
1131
1834
|
}
|
|
1132
1835
|
return result;
|
|
1133
1836
|
}));
|
|
1134
1837
|
// load/filter context sources
|
|
1135
|
-
|
|
1136
|
-
|
|
1137
|
-
|
|
1138
|
-
|
|
1838
|
+
var contextMap = new Map(contextSources.map(function(x) {
|
|
1839
|
+
return [
|
|
1840
|
+
x.sourceId,
|
|
1841
|
+
x
|
|
1842
|
+
];
|
|
1843
|
+
}));
|
|
1844
|
+
var relevantContextSources = util.filterMaybeArrayValues(allContextSources.map(function(x) {
|
|
1845
|
+
var sourceContext = contextMap.get(x.info.id);
|
|
1846
|
+
var result;
|
|
1139
1847
|
if (sourceContext != null) {
|
|
1140
|
-
|
|
1848
|
+
var _ref, _sourceContext_flowType;
|
|
1849
|
+
var flowType = (_ref = (_sourceContext_flowType = sourceContext.flowType) !== null && _sourceContext_flowType !== void 0 ? _sourceContext_flowType : x.defaultFlowType) !== null && _ref !== void 0 ? _ref : 'unset';
|
|
1141
1850
|
result = {
|
|
1142
|
-
entityCommonTypeIdPair,
|
|
1143
|
-
flowType,
|
|
1851
|
+
entityCommonTypeIdPair: entityCommonTypeIdPair,
|
|
1852
|
+
flowType: flowType,
|
|
1144
1853
|
source: x,
|
|
1145
1854
|
context: sourceContext
|
|
1146
1855
|
};
|
|
1147
1856
|
}
|
|
1148
1857
|
return result;
|
|
1149
1858
|
}));
|
|
1150
|
-
|
|
1859
|
+
var allSources = _to_consumable_array(relevantGlobalSources).concat(_to_consumable_array(relevantContextSources));
|
|
1151
1860
|
// sort by order, with primary first
|
|
1152
|
-
allSources.sort(util.sortByNumberFunction((x)
|
|
1153
|
-
|
|
1154
|
-
switch
|
|
1861
|
+
allSources.sort(util.sortByNumberFunction(function(x) {
|
|
1862
|
+
var result;
|
|
1863
|
+
switch(x.flowType){
|
|
1155
1864
|
case 'primary':
|
|
1156
1865
|
result = 1;
|
|
1157
1866
|
break;
|
|
@@ -1167,123 +1876,458 @@ function basicSyncEntityCommonTypeSynchronizerInstanceFactory(config) {
|
|
|
1167
1876
|
}));
|
|
1168
1877
|
return allSources;
|
|
1169
1878
|
}
|
|
1170
|
-
|
|
1171
|
-
|
|
1172
|
-
|
|
1173
|
-
|
|
1174
|
-
|
|
1175
|
-
|
|
1176
|
-
|
|
1177
|
-
|
|
1178
|
-
|
|
1179
|
-
|
|
1180
|
-
|
|
1181
|
-
|
|
1182
|
-
|
|
1183
|
-
|
|
1184
|
-
|
|
1185
|
-
|
|
1186
|
-
|
|
1879
|
+
var synchronizeInstance = function synchronizeInstance(input) {
|
|
1880
|
+
return _async_to_generator$2(function() {
|
|
1881
|
+
var syncEntityCommonTypeIdPair, _loadRelevantSources, loadRelevantSources, synchronize, instance;
|
|
1882
|
+
return _ts_generator$2(this, function(_state) {
|
|
1883
|
+
syncEntityCommonTypeIdPair = syncEntityCommonTypeIdPairForType(input);
|
|
1884
|
+
_loadRelevantSources = function _loadRelevantSources() {
|
|
1885
|
+
return _async_to_generator$2(function() {
|
|
1886
|
+
var entitySourceContext, relevantSources;
|
|
1887
|
+
return _ts_generator$2(this, function(_state) {
|
|
1888
|
+
switch(_state.label){
|
|
1889
|
+
case 0:
|
|
1890
|
+
return [
|
|
1891
|
+
4,
|
|
1892
|
+
entitySourceContextLoader(syncEntityCommonTypeIdPair)
|
|
1893
|
+
];
|
|
1894
|
+
case 1:
|
|
1895
|
+
entitySourceContext = _state.sent();
|
|
1896
|
+
relevantSources = loadSources(syncEntityCommonTypeIdPair, entitySourceContext);
|
|
1897
|
+
return [
|
|
1898
|
+
2,
|
|
1899
|
+
relevantSources
|
|
1900
|
+
];
|
|
1901
|
+
}
|
|
1902
|
+
});
|
|
1903
|
+
})();
|
|
1904
|
+
};
|
|
1905
|
+
if (dynamicSources) {
|
|
1906
|
+
// if dynamic, reload each time and do not cache
|
|
1907
|
+
loadRelevantSources = _loadRelevantSources;
|
|
1908
|
+
} else {
|
|
1909
|
+
// if not dynamic, make a cached getter
|
|
1910
|
+
loadRelevantSources = util.cachedGetter(_loadRelevantSources);
|
|
1911
|
+
}
|
|
1912
|
+
/**
|
|
1187
1913
|
* Performs the synchonization
|
|
1188
|
-
*/
|
|
1189
|
-
|
|
1190
|
-
|
|
1191
|
-
|
|
1192
|
-
|
|
1193
|
-
|
|
1194
|
-
|
|
1195
|
-
|
|
1196
|
-
|
|
1197
|
-
|
|
1914
|
+
*/ synchronize = function synchronize(context) {
|
|
1915
|
+
return _async_to_generator$2(function() {
|
|
1916
|
+
var _sourcesByFlowType_get, _sourcesByFlowType_get1, _sourcesByFlowType_get2, relevantSources, syncEntityInstances, sourcesByFlowType, primarySources, secondarySources, replicaSources, result;
|
|
1917
|
+
function synchronizeInstance(source, deleted) {
|
|
1918
|
+
var _source = _sliced_to_array(source, 2), _$input = _source[0], sourceInstance = _source[1];
|
|
1919
|
+
var promise = deleted ? sourceInstance.synchronizeDelete() : sourceInstance.synchronize();
|
|
1920
|
+
return promise.catch(function(error) {
|
|
1921
|
+
var errorResult = {
|
|
1922
|
+
type: 'error',
|
|
1923
|
+
error: error,
|
|
1924
|
+
entity: _object_spread_props(_object_spread({}, syncEntityCommonTypeIdPair), {
|
|
1925
|
+
sourceInfo: _$input.source.info,
|
|
1926
|
+
id: ''
|
|
1927
|
+
})
|
|
1928
|
+
};
|
|
1929
|
+
return errorResult;
|
|
1930
|
+
});
|
|
1931
|
+
}
|
|
1932
|
+
function performSynchronizationOfSources(input) {
|
|
1933
|
+
return _async_to_generator$2(function() {
|
|
1934
|
+
var syncRecursionDepth, secondaryFlaggedDelete, result, primarySource, primarySyncResult, synchronizedEntityResults, primaryFlaggedDelete, _iteratorNormalCompletion, _didIteratorError, _iteratorError, _iterator, _step, secondarySource, secondarySyncResult, _, err, replicaTaskResults;
|
|
1935
|
+
return _ts_generator$2(this, function(_state) {
|
|
1936
|
+
switch(_state.label){
|
|
1937
|
+
case 0:
|
|
1938
|
+
syncRecursionDepth = input.syncRecursionDepth, secondaryFlaggedDelete = input.secondaryFlaggedDelete;
|
|
1939
|
+
// synchronize the primary source
|
|
1940
|
+
primarySource = primarySources[0];
|
|
1941
|
+
return [
|
|
1942
|
+
4,
|
|
1943
|
+
synchronizeInstance(primarySource, secondaryFlaggedDelete !== null && secondaryFlaggedDelete !== void 0 ? secondaryFlaggedDelete : false)
|
|
1944
|
+
];
|
|
1945
|
+
case 1:
|
|
1946
|
+
primarySyncResult = _state.sent();
|
|
1947
|
+
synchronizedEntityResults = [
|
|
1948
|
+
primarySyncResult
|
|
1949
|
+
];
|
|
1950
|
+
primaryFlaggedDelete = false;
|
|
1951
|
+
switch(primarySyncResult.type){
|
|
1952
|
+
case 'deleted':
|
|
1953
|
+
primaryFlaggedDelete = true;
|
|
1954
|
+
break;
|
|
1955
|
+
case 'failed':
|
|
1956
|
+
case 'error':
|
|
1957
|
+
throw new SynchronizationFailedError(syncEntityCommonTypeIdPair, primarySyncResult.error);
|
|
1958
|
+
}
|
|
1959
|
+
_iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
|
|
1960
|
+
_state.label = 2;
|
|
1961
|
+
case 2:
|
|
1962
|
+
_state.trys.push([
|
|
1963
|
+
2,
|
|
1964
|
+
13,
|
|
1965
|
+
14,
|
|
1966
|
+
15
|
|
1967
|
+
]);
|
|
1968
|
+
_iterator = secondarySources[Symbol.iterator]();
|
|
1969
|
+
_state.label = 3;
|
|
1970
|
+
case 3:
|
|
1971
|
+
if (!!(_iteratorNormalCompletion = (_step = _iterator.next()).done)) return [
|
|
1972
|
+
3,
|
|
1973
|
+
12
|
|
1974
|
+
];
|
|
1975
|
+
secondarySource = _step.value;
|
|
1976
|
+
return [
|
|
1977
|
+
4,
|
|
1978
|
+
synchronizeInstance(secondarySource, primaryFlaggedDelete)
|
|
1979
|
+
];
|
|
1980
|
+
case 4:
|
|
1981
|
+
secondarySyncResult = _state.sent();
|
|
1982
|
+
synchronizedEntityResults.push(secondarySyncResult);
|
|
1983
|
+
_ = secondarySyncResult.type;
|
|
1984
|
+
switch(_){
|
|
1985
|
+
case 'deleted':
|
|
1986
|
+
return [
|
|
1987
|
+
3,
|
|
1988
|
+
5
|
|
1989
|
+
];
|
|
1990
|
+
case 'failed':
|
|
1991
|
+
return [
|
|
1992
|
+
3,
|
|
1993
|
+
9
|
|
1994
|
+
];
|
|
1995
|
+
case 'error':
|
|
1996
|
+
return [
|
|
1997
|
+
3,
|
|
1998
|
+
9
|
|
1999
|
+
];
|
|
2000
|
+
case 'nochange':
|
|
2001
|
+
return [
|
|
2002
|
+
3,
|
|
2003
|
+
10
|
|
2004
|
+
];
|
|
2005
|
+
case 'synchronized':
|
|
2006
|
+
return [
|
|
2007
|
+
3,
|
|
2008
|
+
10
|
|
2009
|
+
];
|
|
2010
|
+
}
|
|
2011
|
+
return [
|
|
2012
|
+
3,
|
|
2013
|
+
10
|
|
2014
|
+
];
|
|
2015
|
+
case 5:
|
|
2016
|
+
if (!(primaryFlaggedDelete === false)) return [
|
|
2017
|
+
3,
|
|
2018
|
+
8
|
|
2019
|
+
];
|
|
2020
|
+
if (!(syncRecursionDepth === 1)) return [
|
|
2021
|
+
3,
|
|
2022
|
+
7
|
|
2023
|
+
];
|
|
2024
|
+
return [
|
|
2025
|
+
4,
|
|
2026
|
+
performSynchronizationOfSources({
|
|
2027
|
+
syncRecursionDepth: syncRecursionDepth + 1,
|
|
2028
|
+
secondaryFlaggedDelete: true
|
|
2029
|
+
})
|
|
2030
|
+
];
|
|
2031
|
+
case 6:
|
|
2032
|
+
result = _state.sent();
|
|
2033
|
+
return [
|
|
2034
|
+
3,
|
|
2035
|
+
7
|
|
2036
|
+
];
|
|
2037
|
+
case 7:
|
|
2038
|
+
return [
|
|
2039
|
+
3,
|
|
2040
|
+
11
|
|
2041
|
+
];
|
|
2042
|
+
case 8:
|
|
2043
|
+
return [
|
|
2044
|
+
3,
|
|
2045
|
+
11
|
|
2046
|
+
];
|
|
2047
|
+
case 9:
|
|
2048
|
+
throw new SynchronizationFailedError(syncEntityCommonTypeIdPair, secondarySyncResult.error);
|
|
2049
|
+
case 10:
|
|
2050
|
+
// continue normally
|
|
2051
|
+
return [
|
|
2052
|
+
3,
|
|
2053
|
+
11
|
|
2054
|
+
];
|
|
2055
|
+
case 11:
|
|
2056
|
+
_iteratorNormalCompletion = true;
|
|
2057
|
+
return [
|
|
2058
|
+
3,
|
|
2059
|
+
3
|
|
2060
|
+
];
|
|
2061
|
+
case 12:
|
|
2062
|
+
return [
|
|
2063
|
+
3,
|
|
2064
|
+
15
|
|
2065
|
+
];
|
|
2066
|
+
case 13:
|
|
2067
|
+
err = _state.sent();
|
|
2068
|
+
_didIteratorError = true;
|
|
2069
|
+
_iteratorError = err;
|
|
2070
|
+
return [
|
|
2071
|
+
3,
|
|
2072
|
+
15
|
|
2073
|
+
];
|
|
2074
|
+
case 14:
|
|
2075
|
+
try {
|
|
2076
|
+
if (!_iteratorNormalCompletion && _iterator.return != null) {
|
|
2077
|
+
_iterator.return();
|
|
2078
|
+
}
|
|
2079
|
+
} finally{
|
|
2080
|
+
if (_didIteratorError) {
|
|
2081
|
+
throw _iteratorError;
|
|
2082
|
+
}
|
|
2083
|
+
}
|
|
2084
|
+
return [
|
|
2085
|
+
7
|
|
2086
|
+
];
|
|
2087
|
+
case 15:
|
|
2088
|
+
if (!(result == null)) return [
|
|
2089
|
+
3,
|
|
2090
|
+
17
|
|
2091
|
+
];
|
|
2092
|
+
return [
|
|
2093
|
+
4,
|
|
2094
|
+
util.performAsyncTasks(replicaSources, function(x) {
|
|
2095
|
+
return synchronizeInstance(x, primaryFlaggedDelete);
|
|
2096
|
+
}, {
|
|
2097
|
+
sequential: false,
|
|
2098
|
+
maxParallelTasks: 3
|
|
2099
|
+
})
|
|
2100
|
+
];
|
|
2101
|
+
case 16:
|
|
2102
|
+
replicaTaskResults = _state.sent();
|
|
2103
|
+
// add all the results
|
|
2104
|
+
util.pushArrayItemsIntoArray(synchronizedEntityResults, replicaTaskResults.results.map(function(x) {
|
|
2105
|
+
return x[1];
|
|
2106
|
+
}));
|
|
2107
|
+
// compute final result
|
|
2108
|
+
result = {
|
|
2109
|
+
synchronizedEntityResults: synchronizedEntityResults
|
|
2110
|
+
};
|
|
2111
|
+
_state.label = 17;
|
|
2112
|
+
case 17:
|
|
2113
|
+
return [
|
|
2114
|
+
2,
|
|
2115
|
+
result
|
|
2116
|
+
];
|
|
2117
|
+
}
|
|
2118
|
+
});
|
|
2119
|
+
})();
|
|
2120
|
+
}
|
|
2121
|
+
return _ts_generator$2(this, function(_state) {
|
|
2122
|
+
switch(_state.label){
|
|
2123
|
+
case 0:
|
|
2124
|
+
_object_destructuring_empty(context !== null && context !== void 0 ? context : {});
|
|
2125
|
+
return [
|
|
2126
|
+
4,
|
|
2127
|
+
loadRelevantSources()
|
|
2128
|
+
];
|
|
2129
|
+
case 1:
|
|
2130
|
+
relevantSources = _state.sent();
|
|
2131
|
+
return [
|
|
2132
|
+
4,
|
|
2133
|
+
Promise.all(relevantSources.map(function(x) {
|
|
2134
|
+
return x.source.syncEntityInstance(x).then(function(y) {
|
|
2135
|
+
return [
|
|
2136
|
+
x,
|
|
2137
|
+
y
|
|
2138
|
+
];
|
|
2139
|
+
});
|
|
2140
|
+
}))
|
|
2141
|
+
];
|
|
2142
|
+
case 2:
|
|
2143
|
+
syncEntityInstances = _state.sent();
|
|
2144
|
+
sourcesByFlowType = util.makeValuesGroupMap(syncEntityInstances, function(x) {
|
|
2145
|
+
return x[0].flowType;
|
|
2146
|
+
});
|
|
2147
|
+
primarySources = (_sourcesByFlowType_get = sourcesByFlowType.get('primary')) !== null && _sourcesByFlowType_get !== void 0 ? _sourcesByFlowType_get : [];
|
|
2148
|
+
secondarySources = (_sourcesByFlowType_get1 = sourcesByFlowType.get('secondary')) !== null && _sourcesByFlowType_get1 !== void 0 ? _sourcesByFlowType_get1 : [];
|
|
2149
|
+
replicaSources = (_sourcesByFlowType_get2 = sourcesByFlowType.get('replica')) !== null && _sourcesByFlowType_get2 !== void 0 ? _sourcesByFlowType_get2 : [];
|
|
2150
|
+
// assert primary sources count
|
|
2151
|
+
switch(primarySources.length){
|
|
2152
|
+
case 0:
|
|
2153
|
+
throw new NoPrimarySyncSourceError(syncEntityCommonTypeIdPair);
|
|
2154
|
+
case 1:
|
|
2155
|
+
break;
|
|
2156
|
+
default:
|
|
2157
|
+
throw new MultiplePrimarySyncSourceError(syncEntityCommonTypeIdPair);
|
|
2158
|
+
}
|
|
2159
|
+
return [
|
|
2160
|
+
4,
|
|
2161
|
+
performSynchronizationOfSources({
|
|
2162
|
+
syncRecursionDepth: 0
|
|
2163
|
+
})
|
|
2164
|
+
];
|
|
2165
|
+
case 3:
|
|
2166
|
+
result = _state.sent();
|
|
2167
|
+
return [
|
|
2168
|
+
2,
|
|
2169
|
+
{
|
|
2170
|
+
targetPair: syncEntityCommonTypeIdPair,
|
|
2171
|
+
entitiesSynchronized: result.synchronizedEntityResults
|
|
2172
|
+
}
|
|
2173
|
+
];
|
|
2174
|
+
}
|
|
2175
|
+
});
|
|
2176
|
+
})();
|
|
2177
|
+
};
|
|
2178
|
+
instance = {
|
|
2179
|
+
entityPair: syncEntityCommonTypeIdPair,
|
|
2180
|
+
synchronize: synchronize
|
|
2181
|
+
};
|
|
2182
|
+
return [
|
|
2183
|
+
2,
|
|
2184
|
+
instance
|
|
2185
|
+
];
|
|
2186
|
+
});
|
|
2187
|
+
})();
|
|
2188
|
+
};
|
|
2189
|
+
var result = {
|
|
2190
|
+
commonType: commonType,
|
|
2191
|
+
synchronizeInstance: synchronizeInstance
|
|
2192
|
+
};
|
|
2193
|
+
return result;
|
|
2194
|
+
}
|
|
2195
|
+
|
|
2196
|
+
function asyncGeneratorStep$1(gen, resolve, reject, _next, _throw, key, arg) {
|
|
2197
|
+
try {
|
|
2198
|
+
var info = gen[key](arg);
|
|
2199
|
+
var value = info.value;
|
|
2200
|
+
} catch (error) {
|
|
2201
|
+
reject(error);
|
|
2202
|
+
return;
|
|
2203
|
+
}
|
|
2204
|
+
if (info.done) {
|
|
2205
|
+
resolve(value);
|
|
2206
|
+
} else {
|
|
2207
|
+
Promise.resolve(value).then(_next, _throw);
|
|
2208
|
+
}
|
|
2209
|
+
}
|
|
2210
|
+
function _async_to_generator$1(fn) {
|
|
2211
|
+
return function() {
|
|
2212
|
+
var self = this, args = arguments;
|
|
2213
|
+
return new Promise(function(resolve, reject) {
|
|
2214
|
+
var gen = fn.apply(self, args);
|
|
2215
|
+
function _next(value) {
|
|
2216
|
+
asyncGeneratorStep$1(gen, resolve, reject, _next, _throw, "next", value);
|
|
2217
|
+
}
|
|
2218
|
+
function _throw(err) {
|
|
2219
|
+
asyncGeneratorStep$1(gen, resolve, reject, _next, _throw, "throw", err);
|
|
2220
|
+
}
|
|
2221
|
+
_next(undefined);
|
|
2222
|
+
});
|
|
2223
|
+
};
|
|
2224
|
+
}
|
|
2225
|
+
function _instanceof(left, right) {
|
|
2226
|
+
if (right != null && typeof Symbol !== "undefined" && right[Symbol.hasInstance]) {
|
|
2227
|
+
return !!right[Symbol.hasInstance](left);
|
|
2228
|
+
} else {
|
|
2229
|
+
return left instanceof right;
|
|
2230
|
+
}
|
|
2231
|
+
}
|
|
2232
|
+
function _ts_generator$1(thisArg, body) {
|
|
2233
|
+
var f, y, t, _ = {
|
|
2234
|
+
label: 0,
|
|
2235
|
+
sent: function() {
|
|
2236
|
+
if (t[0] & 1) throw t[1];
|
|
2237
|
+
return t[1];
|
|
2238
|
+
},
|
|
2239
|
+
trys: [],
|
|
2240
|
+
ops: []
|
|
2241
|
+
}, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype), d = Object.defineProperty;
|
|
2242
|
+
return d(g, "next", {
|
|
2243
|
+
value: verb(0)
|
|
2244
|
+
}), d(g, "throw", {
|
|
2245
|
+
value: verb(1)
|
|
2246
|
+
}), d(g, "return", {
|
|
2247
|
+
value: verb(2)
|
|
2248
|
+
}), typeof Symbol === "function" && d(g, Symbol.iterator, {
|
|
2249
|
+
value: function() {
|
|
2250
|
+
return this;
|
|
2251
|
+
}
|
|
2252
|
+
}), g;
|
|
2253
|
+
function verb(n) {
|
|
2254
|
+
return function(v) {
|
|
2255
|
+
return step([
|
|
2256
|
+
n,
|
|
2257
|
+
v
|
|
2258
|
+
]);
|
|
2259
|
+
};
|
|
2260
|
+
}
|
|
2261
|
+
function step(op) {
|
|
2262
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
2263
|
+
while(g && (g = 0, op[0] && (_ = 0)), _)try {
|
|
2264
|
+
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;
|
|
2265
|
+
if (y = 0, t) op = [
|
|
2266
|
+
op[0] & 2,
|
|
2267
|
+
t.value
|
|
2268
|
+
];
|
|
2269
|
+
switch(op[0]){
|
|
1198
2270
|
case 0:
|
|
1199
|
-
throw new NoPrimarySyncSourceError(syncEntityCommonTypeIdPair);
|
|
1200
2271
|
case 1:
|
|
2272
|
+
t = op;
|
|
1201
2273
|
break;
|
|
1202
|
-
|
|
1203
|
-
|
|
1204
|
-
|
|
1205
|
-
|
|
1206
|
-
|
|
1207
|
-
const promise = deleted ? sourceInstance.synchronizeDelete() : sourceInstance.synchronize();
|
|
1208
|
-
return promise.catch((error) => {
|
|
1209
|
-
const errorResult = {
|
|
1210
|
-
type: 'error',
|
|
1211
|
-
error,
|
|
1212
|
-
entity: {
|
|
1213
|
-
...syncEntityCommonTypeIdPair,
|
|
1214
|
-
sourceInfo: input.source.info,
|
|
1215
|
-
id: ''
|
|
1216
|
-
}
|
|
2274
|
+
case 4:
|
|
2275
|
+
_.label++;
|
|
2276
|
+
return {
|
|
2277
|
+
value: op[1],
|
|
2278
|
+
done: false
|
|
1217
2279
|
};
|
|
1218
|
-
|
|
1219
|
-
|
|
1220
|
-
|
|
1221
|
-
|
|
1222
|
-
|
|
1223
|
-
|
|
1224
|
-
|
|
1225
|
-
|
|
1226
|
-
|
|
1227
|
-
|
|
1228
|
-
|
|
1229
|
-
|
|
1230
|
-
|
|
1231
|
-
|
|
2280
|
+
case 5:
|
|
2281
|
+
_.label++;
|
|
2282
|
+
y = op[1];
|
|
2283
|
+
op = [
|
|
2284
|
+
0
|
|
2285
|
+
];
|
|
2286
|
+
continue;
|
|
2287
|
+
case 7:
|
|
2288
|
+
op = _.ops.pop();
|
|
2289
|
+
_.trys.pop();
|
|
2290
|
+
continue;
|
|
2291
|
+
default:
|
|
2292
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
|
|
2293
|
+
_ = 0;
|
|
2294
|
+
continue;
|
|
2295
|
+
}
|
|
2296
|
+
if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) {
|
|
2297
|
+
_.label = op[1];
|
|
1232
2298
|
break;
|
|
1233
|
-
case 'failed':
|
|
1234
|
-
case 'error':
|
|
1235
|
-
throw new SynchronizationFailedError(syncEntityCommonTypeIdPair, primarySyncResult.error);
|
|
1236
|
-
}
|
|
1237
|
-
// synchronize all secondary sources, one after the other. If any secondary source returns deleted and the primary source was not flagged as deleted, then the synchronization will be restarted.
|
|
1238
|
-
for (const secondarySource of secondarySources) {
|
|
1239
|
-
const secondarySyncResult = await synchronizeInstance(secondarySource, primaryFlaggedDelete);
|
|
1240
|
-
synchronizedEntityResults.push(secondarySyncResult);
|
|
1241
|
-
switch (secondarySyncResult.type) {
|
|
1242
|
-
case 'deleted':
|
|
1243
|
-
if (primaryFlaggedDelete === false) {
|
|
1244
|
-
break;
|
|
1245
|
-
}
|
|
1246
|
-
break;
|
|
1247
|
-
case 'failed':
|
|
1248
|
-
case 'error':
|
|
1249
|
-
throw new SynchronizationFailedError(syncEntityCommonTypeIdPair, secondarySyncResult.error);
|
|
1250
2299
|
}
|
|
1251
|
-
|
|
1252
|
-
|
|
1253
|
-
|
|
1254
|
-
|
|
1255
|
-
|
|
1256
|
-
|
|
1257
|
-
|
|
1258
|
-
|
|
1259
|
-
|
|
1260
|
-
|
|
1261
|
-
|
|
1262
|
-
|
|
1263
|
-
|
|
1264
|
-
};
|
|
1265
|
-
}
|
|
1266
|
-
return result;
|
|
2300
|
+
if (op[0] === 6 && _.label < t[1]) {
|
|
2301
|
+
_.label = t[1];
|
|
2302
|
+
t = op;
|
|
2303
|
+
break;
|
|
2304
|
+
}
|
|
2305
|
+
if (t && _.label < t[2]) {
|
|
2306
|
+
_.label = t[2];
|
|
2307
|
+
_.ops.push(op);
|
|
2308
|
+
break;
|
|
2309
|
+
}
|
|
2310
|
+
if (t[2]) _.ops.pop();
|
|
2311
|
+
_.trys.pop();
|
|
2312
|
+
continue;
|
|
1267
2313
|
}
|
|
1268
|
-
|
|
1269
|
-
|
|
1270
|
-
|
|
1271
|
-
|
|
1272
|
-
|
|
1273
|
-
|
|
1274
|
-
|
|
1275
|
-
|
|
1276
|
-
|
|
2314
|
+
op = body.call(thisArg, _);
|
|
2315
|
+
} catch (e) {
|
|
2316
|
+
op = [
|
|
2317
|
+
6,
|
|
2318
|
+
e
|
|
2319
|
+
];
|
|
2320
|
+
y = 0;
|
|
2321
|
+
} finally{
|
|
2322
|
+
f = t = 0;
|
|
2323
|
+
}
|
|
2324
|
+
if (op[0] & 5) throw op[1];
|
|
2325
|
+
return {
|
|
2326
|
+
value: op[0] ? op[1] : void 0,
|
|
2327
|
+
done: true
|
|
1277
2328
|
};
|
|
1278
|
-
|
|
1279
|
-
};
|
|
1280
|
-
const result = {
|
|
1281
|
-
commonType,
|
|
1282
|
-
synchronizeInstance
|
|
1283
|
-
};
|
|
1284
|
-
return result;
|
|
2329
|
+
}
|
|
1285
2330
|
}
|
|
1286
|
-
|
|
1287
2331
|
/**
|
|
1288
2332
|
* Creates a function that validates input against an ArkType schema and then processes it.
|
|
1289
2333
|
*
|
|
@@ -1302,18 +2346,46 @@ function basicSyncEntityCommonTypeSynchronizerInstanceFactory(config) {
|
|
|
1302
2346
|
*
|
|
1303
2347
|
* const result = await processUser({ id: '123', name: 'John' });
|
|
1304
2348
|
* ```
|
|
1305
|
-
*/
|
|
1306
|
-
|
|
1307
|
-
|
|
1308
|
-
|
|
1309
|
-
|
|
1310
|
-
|
|
1311
|
-
|
|
1312
|
-
|
|
1313
|
-
|
|
1314
|
-
|
|
1315
|
-
|
|
1316
|
-
|
|
2349
|
+
*/ function transformAndValidateObject(config) {
|
|
2350
|
+
var transformToResult = transformAndValidateObjectResult(config);
|
|
2351
|
+
var handleValidationError = config.handleValidationError;
|
|
2352
|
+
return function(input, context) {
|
|
2353
|
+
return _async_to_generator$1(function() {
|
|
2354
|
+
var x, result;
|
|
2355
|
+
return _ts_generator$1(this, function(_state) {
|
|
2356
|
+
switch(_state.label){
|
|
2357
|
+
case 0:
|
|
2358
|
+
return [
|
|
2359
|
+
4,
|
|
2360
|
+
transformToResult(input, context)
|
|
2361
|
+
];
|
|
2362
|
+
case 1:
|
|
2363
|
+
x = _state.sent();
|
|
2364
|
+
if (x.success) {
|
|
2365
|
+
return [
|
|
2366
|
+
2,
|
|
2367
|
+
{
|
|
2368
|
+
object: x.object,
|
|
2369
|
+
result: x.result
|
|
2370
|
+
}
|
|
2371
|
+
];
|
|
2372
|
+
}
|
|
2373
|
+
return [
|
|
2374
|
+
4,
|
|
2375
|
+
handleValidationError(x.validationErrors)
|
|
2376
|
+
];
|
|
2377
|
+
case 2:
|
|
2378
|
+
result = _state.sent();
|
|
2379
|
+
return [
|
|
2380
|
+
2,
|
|
2381
|
+
{
|
|
2382
|
+
object: undefined,
|
|
2383
|
+
result: result
|
|
2384
|
+
}
|
|
2385
|
+
];
|
|
2386
|
+
}
|
|
2387
|
+
});
|
|
2388
|
+
})();
|
|
1317
2389
|
};
|
|
1318
2390
|
}
|
|
1319
2391
|
/**
|
|
@@ -1324,14 +2396,13 @@ function transformAndValidateObject(config) {
|
|
|
1324
2396
|
*
|
|
1325
2397
|
* @param defaults - default error handler
|
|
1326
2398
|
* @returns a factory function that creates TransformAndValidateObjectFunction instances
|
|
1327
|
-
*/
|
|
1328
|
-
|
|
1329
|
-
|
|
1330
|
-
|
|
1331
|
-
|
|
1332
|
-
|
|
1333
|
-
|
|
1334
|
-
handleValidationError: handleValidationError ?? defaultHandleValidationError
|
|
2399
|
+
*/ function transformAndValidateObjectFactory(defaults) {
|
|
2400
|
+
var defaultHandleValidationError = defaults.handleValidationError;
|
|
2401
|
+
return function(schema, fn, handleValidationError) {
|
|
2402
|
+
var config = {
|
|
2403
|
+
schema: schema,
|
|
2404
|
+
fn: fn,
|
|
2405
|
+
handleValidationError: handleValidationError !== null && handleValidationError !== void 0 ? handleValidationError : defaultHandleValidationError
|
|
1335
2406
|
};
|
|
1336
2407
|
return transformAndValidateObject(config);
|
|
1337
2408
|
};
|
|
@@ -1359,17 +2430,42 @@ function transformAndValidateObjectFactory(defaults) {
|
|
|
1359
2430
|
* console.log(result.validationErrors.summary);
|
|
1360
2431
|
* }
|
|
1361
2432
|
* ```
|
|
1362
|
-
*/
|
|
1363
|
-
|
|
1364
|
-
|
|
1365
|
-
|
|
1366
|
-
|
|
1367
|
-
|
|
1368
|
-
|
|
1369
|
-
|
|
1370
|
-
|
|
1371
|
-
|
|
1372
|
-
|
|
2433
|
+
*/ function transformAndValidateObjectResult(config) {
|
|
2434
|
+
var schema = config.schema, fn = config.fn;
|
|
2435
|
+
return function(input) {
|
|
2436
|
+
return _async_to_generator$1(function() {
|
|
2437
|
+
var out, object, result;
|
|
2438
|
+
return _ts_generator$1(this, function(_state) {
|
|
2439
|
+
switch(_state.label){
|
|
2440
|
+
case 0:
|
|
2441
|
+
out = schema(input);
|
|
2442
|
+
if (_instanceof(out, arktype.type.errors)) {
|
|
2443
|
+
return [
|
|
2444
|
+
2,
|
|
2445
|
+
{
|
|
2446
|
+
validationErrors: out,
|
|
2447
|
+
success: false
|
|
2448
|
+
}
|
|
2449
|
+
];
|
|
2450
|
+
}
|
|
2451
|
+
object = out;
|
|
2452
|
+
return [
|
|
2453
|
+
4,
|
|
2454
|
+
fn(object)
|
|
2455
|
+
];
|
|
2456
|
+
case 1:
|
|
2457
|
+
result = _state.sent();
|
|
2458
|
+
return [
|
|
2459
|
+
2,
|
|
2460
|
+
{
|
|
2461
|
+
object: object,
|
|
2462
|
+
result: result,
|
|
2463
|
+
success: true
|
|
2464
|
+
}
|
|
2465
|
+
];
|
|
2466
|
+
}
|
|
2467
|
+
});
|
|
2468
|
+
})();
|
|
1373
2469
|
};
|
|
1374
2470
|
}
|
|
1375
2471
|
|
|
@@ -1378,8 +2474,7 @@ function transformAndValidateObjectResult(config) {
|
|
|
1378
2474
|
*
|
|
1379
2475
|
* @param defaults - shared error handler defaults
|
|
1380
2476
|
* @returns a factory that produces functions returning {@link TransformAndValidateFunctionResult}
|
|
1381
|
-
*/
|
|
1382
|
-
function transformAndValidateFunctionResultFactory(defaults) {
|
|
2477
|
+
*/ function transformAndValidateFunctionResultFactory(defaults) {
|
|
1383
2478
|
return toTransformAndValidateFunctionResultFactory(transformAndValidateObjectFactory(defaults));
|
|
1384
2479
|
}
|
|
1385
2480
|
/**
|
|
@@ -1388,24 +2483,151 @@ function transformAndValidateFunctionResultFactory(defaults) {
|
|
|
1388
2483
|
*
|
|
1389
2484
|
* @param transformAndValidateObjectFactory - the base factory to wrap
|
|
1390
2485
|
* @returns a factory that produces functions returning results with `params` attached
|
|
1391
|
-
*/
|
|
1392
|
-
function
|
|
1393
|
-
|
|
1394
|
-
|
|
1395
|
-
return (input, context) => {
|
|
2486
|
+
*/ function toTransformAndValidateFunctionResultFactory(transformAndValidateObjectFactory) {
|
|
2487
|
+
return function(schema, fn, handleValidationError) {
|
|
2488
|
+
var transformAndValidateObjectFn = transformAndValidateObjectFactory(schema, fn, handleValidationError);
|
|
2489
|
+
return function(input, context) {
|
|
1396
2490
|
return toTransformAndValidateFunctionResult(transformAndValidateObjectFn(input, context));
|
|
1397
2491
|
};
|
|
1398
2492
|
};
|
|
1399
2493
|
}
|
|
1400
2494
|
function toTransformAndValidateFunctionResult(objectOutput) {
|
|
1401
|
-
return util.mapPromiseOrValue(objectOutput, (x)
|
|
1402
|
-
|
|
1403
|
-
|
|
2495
|
+
return util.mapPromiseOrValue(objectOutput, function(x) {
|
|
2496
|
+
var object = x.object, result = x.result;
|
|
2497
|
+
var fnResult = result;
|
|
1404
2498
|
fnResult.params = object;
|
|
1405
2499
|
return fnResult;
|
|
1406
2500
|
});
|
|
1407
2501
|
}
|
|
1408
2502
|
|
|
2503
|
+
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
|
|
2504
|
+
try {
|
|
2505
|
+
var info = gen[key](arg);
|
|
2506
|
+
var value = info.value;
|
|
2507
|
+
} catch (error) {
|
|
2508
|
+
reject(error);
|
|
2509
|
+
return;
|
|
2510
|
+
}
|
|
2511
|
+
if (info.done) {
|
|
2512
|
+
resolve(value);
|
|
2513
|
+
} else {
|
|
2514
|
+
Promise.resolve(value).then(_next, _throw);
|
|
2515
|
+
}
|
|
2516
|
+
}
|
|
2517
|
+
function _async_to_generator(fn) {
|
|
2518
|
+
return function() {
|
|
2519
|
+
var self = this, args = arguments;
|
|
2520
|
+
return new Promise(function(resolve, reject) {
|
|
2521
|
+
var gen = fn.apply(self, args);
|
|
2522
|
+
function _next(value) {
|
|
2523
|
+
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
|
|
2524
|
+
}
|
|
2525
|
+
function _throw(err) {
|
|
2526
|
+
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
|
|
2527
|
+
}
|
|
2528
|
+
_next(undefined);
|
|
2529
|
+
});
|
|
2530
|
+
};
|
|
2531
|
+
}
|
|
2532
|
+
function _ts_generator(thisArg, body) {
|
|
2533
|
+
var f, y, t, _ = {
|
|
2534
|
+
label: 0,
|
|
2535
|
+
sent: function() {
|
|
2536
|
+
if (t[0] & 1) throw t[1];
|
|
2537
|
+
return t[1];
|
|
2538
|
+
},
|
|
2539
|
+
trys: [],
|
|
2540
|
+
ops: []
|
|
2541
|
+
}, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype), d = Object.defineProperty;
|
|
2542
|
+
return d(g, "next", {
|
|
2543
|
+
value: verb(0)
|
|
2544
|
+
}), d(g, "throw", {
|
|
2545
|
+
value: verb(1)
|
|
2546
|
+
}), d(g, "return", {
|
|
2547
|
+
value: verb(2)
|
|
2548
|
+
}), typeof Symbol === "function" && d(g, Symbol.iterator, {
|
|
2549
|
+
value: function() {
|
|
2550
|
+
return this;
|
|
2551
|
+
}
|
|
2552
|
+
}), g;
|
|
2553
|
+
function verb(n) {
|
|
2554
|
+
return function(v) {
|
|
2555
|
+
return step([
|
|
2556
|
+
n,
|
|
2557
|
+
v
|
|
2558
|
+
]);
|
|
2559
|
+
};
|
|
2560
|
+
}
|
|
2561
|
+
function step(op) {
|
|
2562
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
2563
|
+
while(g && (g = 0, op[0] && (_ = 0)), _)try {
|
|
2564
|
+
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;
|
|
2565
|
+
if (y = 0, t) op = [
|
|
2566
|
+
op[0] & 2,
|
|
2567
|
+
t.value
|
|
2568
|
+
];
|
|
2569
|
+
switch(op[0]){
|
|
2570
|
+
case 0:
|
|
2571
|
+
case 1:
|
|
2572
|
+
t = op;
|
|
2573
|
+
break;
|
|
2574
|
+
case 4:
|
|
2575
|
+
_.label++;
|
|
2576
|
+
return {
|
|
2577
|
+
value: op[1],
|
|
2578
|
+
done: false
|
|
2579
|
+
};
|
|
2580
|
+
case 5:
|
|
2581
|
+
_.label++;
|
|
2582
|
+
y = op[1];
|
|
2583
|
+
op = [
|
|
2584
|
+
0
|
|
2585
|
+
];
|
|
2586
|
+
continue;
|
|
2587
|
+
case 7:
|
|
2588
|
+
op = _.ops.pop();
|
|
2589
|
+
_.trys.pop();
|
|
2590
|
+
continue;
|
|
2591
|
+
default:
|
|
2592
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
|
|
2593
|
+
_ = 0;
|
|
2594
|
+
continue;
|
|
2595
|
+
}
|
|
2596
|
+
if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) {
|
|
2597
|
+
_.label = op[1];
|
|
2598
|
+
break;
|
|
2599
|
+
}
|
|
2600
|
+
if (op[0] === 6 && _.label < t[1]) {
|
|
2601
|
+
_.label = t[1];
|
|
2602
|
+
t = op;
|
|
2603
|
+
break;
|
|
2604
|
+
}
|
|
2605
|
+
if (t && _.label < t[2]) {
|
|
2606
|
+
_.label = t[2];
|
|
2607
|
+
_.ops.push(op);
|
|
2608
|
+
break;
|
|
2609
|
+
}
|
|
2610
|
+
if (t[2]) _.ops.pop();
|
|
2611
|
+
_.trys.pop();
|
|
2612
|
+
continue;
|
|
2613
|
+
}
|
|
2614
|
+
op = body.call(thisArg, _);
|
|
2615
|
+
} catch (e) {
|
|
2616
|
+
op = [
|
|
2617
|
+
6,
|
|
2618
|
+
e
|
|
2619
|
+
];
|
|
2620
|
+
y = 0;
|
|
2621
|
+
} finally{
|
|
2622
|
+
f = t = 0;
|
|
2623
|
+
}
|
|
2624
|
+
if (op[0] & 5) throw op[1];
|
|
2625
|
+
return {
|
|
2626
|
+
value: op[0] ? op[1] : void 0,
|
|
2627
|
+
done: true
|
|
2628
|
+
};
|
|
2629
|
+
}
|
|
2630
|
+
}
|
|
1409
2631
|
/**
|
|
1410
2632
|
* Creates a factory for transform-and-validate functions that return only the result (discarding the parsed object).
|
|
1411
2633
|
*
|
|
@@ -1413,80 +2635,112 @@ function toTransformAndValidateFunctionResult(objectOutput) {
|
|
|
1413
2635
|
*
|
|
1414
2636
|
* @param defaults - shared error handler defaults
|
|
1415
2637
|
* @returns a factory that produces functions returning only the handler's result
|
|
1416
|
-
*/
|
|
1417
|
-
|
|
1418
|
-
|
|
1419
|
-
|
|
1420
|
-
|
|
1421
|
-
|
|
1422
|
-
|
|
1423
|
-
|
|
2638
|
+
*/ function transformAndValidateResultFactory(defaults) {
|
|
2639
|
+
var factory = transformAndValidateObjectFactory(defaults);
|
|
2640
|
+
return function(schema, fn, handleValidationError) {
|
|
2641
|
+
var transformAndValidateObjectFn = factory(schema, fn, handleValidationError);
|
|
2642
|
+
return function(input, context) {
|
|
2643
|
+
return _async_to_generator(function() {
|
|
2644
|
+
var result;
|
|
2645
|
+
return _ts_generator(this, function(_state) {
|
|
2646
|
+
switch(_state.label){
|
|
2647
|
+
case 0:
|
|
2648
|
+
return [
|
|
2649
|
+
4,
|
|
2650
|
+
transformAndValidateObjectFn(input, context)
|
|
2651
|
+
];
|
|
2652
|
+
case 1:
|
|
2653
|
+
result = _state.sent().result;
|
|
2654
|
+
return [
|
|
2655
|
+
2,
|
|
2656
|
+
result
|
|
2657
|
+
];
|
|
2658
|
+
}
|
|
2659
|
+
});
|
|
2660
|
+
})();
|
|
1424
2661
|
};
|
|
1425
2662
|
};
|
|
1426
2663
|
}
|
|
1427
2664
|
|
|
1428
2665
|
/**
|
|
1429
2666
|
* ArkType schema for a model key (non-empty string).
|
|
1430
|
-
*/
|
|
1431
|
-
const modelKeyType = arktype.type('string > 0');
|
|
2667
|
+
*/ var modelKeyType = arktype.type('string > 0');
|
|
1432
2668
|
/**
|
|
1433
2669
|
* ArkType schema for a model id (non-empty string).
|
|
1434
|
-
*/
|
|
1435
|
-
const modelIdType = arktype.type('string > 0');
|
|
2670
|
+
*/ var modelIdType = arktype.type('string > 0');
|
|
1436
2671
|
/**
|
|
1437
2672
|
* ArkType schema for target model params with a required `key` field.
|
|
1438
|
-
*/
|
|
1439
|
-
const targetModelParamsType = arktype.type({
|
|
2673
|
+
*/ var targetModelParamsType = arktype.type({
|
|
1440
2674
|
key: modelKeyType
|
|
1441
2675
|
});
|
|
1442
2676
|
/**
|
|
1443
2677
|
* ArkType schema for target model id params with a required `id` field.
|
|
1444
|
-
*/
|
|
1445
|
-
const targetModelIdParamsType = arktype.type({
|
|
2678
|
+
*/ var targetModelIdParamsType = arktype.type({
|
|
1446
2679
|
id: modelIdType
|
|
1447
2680
|
});
|
|
1448
2681
|
|
|
1449
2682
|
function clearable(definition) {
|
|
2683
|
+
var result;
|
|
1450
2684
|
if (typeof definition === 'string') {
|
|
1451
|
-
|
|
2685
|
+
result = "".concat(definition, " | null | undefined");
|
|
2686
|
+
} else {
|
|
2687
|
+
result = definition.or('null').or('undefined');
|
|
1452
2688
|
}
|
|
1453
|
-
return
|
|
2689
|
+
return result;
|
|
1454
2690
|
}
|
|
1455
2691
|
|
|
2692
|
+
/**
|
|
2693
|
+
* Matches "Date | string.date.parse".
|
|
2694
|
+
*
|
|
2695
|
+
* This is used for validating and parsing serialized data (e.g., API responses, JSON payloads)
|
|
2696
|
+
* and/or runtime Date objects into the corresponding runtime types.
|
|
2697
|
+
*
|
|
2698
|
+
* If we only used Date, or only used string.date.parse, then using the ArkType gets more specific to
|
|
2699
|
+
* those independent cases, and will cause validation errors if you end up passing the object of that type
|
|
2700
|
+
* rather than a freshly parsed JSON string POJO of that type.
|
|
2701
|
+
*/ var ARKTYPE_DATE_DTO_TYPE = 'Date | string.date.parse';
|
|
2702
|
+
|
|
1456
2703
|
/**
|
|
1457
2704
|
* ArkType schema for a valid ISO 8601 day string (e.g., "2024-01-15").
|
|
1458
|
-
*/
|
|
1459
|
-
|
|
2705
|
+
*/ var iso8601DayStringType = arktype.type('string > 0').narrow(function(val, ctx) {
|
|
2706
|
+
return val != null && util.isISO8601DayString(val) || ctx.mustBe('a valid ISO 8601 day string');
|
|
2707
|
+
});
|
|
1460
2708
|
|
|
1461
2709
|
/**
|
|
1462
2710
|
* ArkType schema for a valid minute of the day (0-1439).
|
|
1463
|
-
*/
|
|
1464
|
-
|
|
2711
|
+
*/ var minuteOfDayType = arktype.type('number').narrow(function(val, ctx) {
|
|
2712
|
+
return val != null && util.isMinuteOfDay(val) || ctx.mustBe('a valid minute of the day (0-1439)');
|
|
2713
|
+
});
|
|
1465
2714
|
|
|
1466
2715
|
/**
|
|
1467
2716
|
* ArkType schema for a valid E.164 phone number without an extension.
|
|
1468
|
-
*/
|
|
1469
|
-
|
|
2717
|
+
*/ var e164PhoneNumberType = arktype.type('string > 0').narrow(function(val, ctx) {
|
|
2718
|
+
return val != null && util.isE164PhoneNumber(val, false) || ctx.mustBe('a valid E.164 phone number without an extension');
|
|
2719
|
+
});
|
|
1470
2720
|
/**
|
|
1471
2721
|
* ArkType schema for a valid E.164 phone number, optionally with an extension.
|
|
1472
|
-
*/
|
|
1473
|
-
|
|
2722
|
+
*/ var e164PhoneNumberWithOptionalExtensionType = arktype.type('string > 0').narrow(function(val, ctx) {
|
|
2723
|
+
return val != null && util.isE164PhoneNumber(val, true) || ctx.mustBe('a valid E.164 phone number');
|
|
2724
|
+
});
|
|
1474
2725
|
/**
|
|
1475
2726
|
* ArkType schema for a valid E.164 phone number that includes an extension.
|
|
1476
|
-
*/
|
|
1477
|
-
|
|
2727
|
+
*/ var e164PhoneNumberWithExtensionType = arktype.type('string > 0').narrow(function(val, ctx) {
|
|
2728
|
+
return val != null && util.isE164PhoneNumberWithExtension(val) || ctx.mustBe('a valid E.164 phone number with an extension');
|
|
2729
|
+
});
|
|
1478
2730
|
|
|
1479
2731
|
/**
|
|
1480
2732
|
* ArkType schema for a valid {@link LatLngPoint} with lat in [-90, 90] and lng in [-180, 180].
|
|
1481
|
-
*/
|
|
1482
|
-
const latLngPointType = arktype.type({
|
|
2733
|
+
*/ var latLngPointType = arktype.type({
|
|
1483
2734
|
lat: '-90 <= number <= 90',
|
|
1484
2735
|
lng: '-180 <= number <= 180'
|
|
1485
|
-
}).narrow((val, ctx)
|
|
2736
|
+
}).narrow(function(val, ctx) {
|
|
2737
|
+
return val != null && util.isValidLatLngPoint(val) || ctx.mustBe('a valid LatLngPoint with lat in [-90, 90] and lng in [-180, 180]');
|
|
2738
|
+
});
|
|
1486
2739
|
/**
|
|
1487
2740
|
* ArkType schema for a valid {@link LatLngString} (comma-separated lat/lng, e.g. "30.5,-96.3").
|
|
1488
|
-
*/
|
|
1489
|
-
|
|
2741
|
+
*/ var latLngStringType = arktype.type('string > 0').narrow(function(val, ctx) {
|
|
2742
|
+
return val != null && util.isLatLngString(val) || ctx.mustBe('a valid lat,lng string (e.g. "30.5,-96.3")');
|
|
2743
|
+
});
|
|
1490
2744
|
|
|
1491
2745
|
/**
|
|
1492
2746
|
* Creates an ArkType schema that validates an array has no duplicate keys.
|
|
@@ -1498,20 +2752,23 @@ const latLngStringType = arktype.type('string > 0').narrow((val, ctx) => (val !=
|
|
|
1498
2752
|
* ```typescript
|
|
1499
2753
|
* const uniqueItemsType = uniqueKeyedType((item: Item) => item.id);
|
|
1500
2754
|
* ```
|
|
1501
|
-
*/
|
|
1502
|
-
|
|
1503
|
-
|
|
1504
|
-
|
|
2755
|
+
*/ function uniqueKeyedType(readKey) {
|
|
2756
|
+
var isUniqueKeyed = util.isUniqueKeyedFunction(readKey);
|
|
2757
|
+
return arktype.type('unknown[]').narrow(function(val, ctx) {
|
|
2758
|
+
return val != null && isUniqueKeyed(val) || ctx.mustBe('an array with unique keys');
|
|
2759
|
+
});
|
|
1505
2760
|
}
|
|
1506
2761
|
|
|
1507
2762
|
/**
|
|
1508
2763
|
* ArkType schema for a valid website URL (with or without protocol prefix).
|
|
1509
|
-
*/
|
|
1510
|
-
|
|
2764
|
+
*/ var websiteUrlType = arktype.type('string > 0').narrow(function(val, ctx) {
|
|
2765
|
+
return val != null && util.isWebsiteUrl(val) || ctx.mustBe('a valid website URL');
|
|
2766
|
+
});
|
|
1511
2767
|
/**
|
|
1512
2768
|
* ArkType schema for a valid website URL that starts with `http://` or `https://`.
|
|
1513
|
-
*/
|
|
1514
|
-
|
|
2769
|
+
*/ var websiteUrlWithPrefixType = arktype.type('string > 0').narrow(function(val, ctx) {
|
|
2770
|
+
return val != null && util.isWebsiteUrlWithPrefix(val) || ctx.mustBe('a valid website URL starting with http:// or https://');
|
|
2771
|
+
});
|
|
1515
2772
|
|
|
1516
2773
|
exports.ADDRESS_CITY_MAX_LENGTH = ADDRESS_CITY_MAX_LENGTH;
|
|
1517
2774
|
exports.ADDRESS_COUNTRY_MAX_LENGTH = ADDRESS_COUNTRY_MAX_LENGTH;
|
|
@@ -1519,6 +2776,7 @@ exports.ADDRESS_LINE_MAX_LENGTH = ADDRESS_LINE_MAX_LENGTH;
|
|
|
1519
2776
|
exports.ADDRESS_STATE_CODE_MAX_LENGTH = ADDRESS_STATE_CODE_MAX_LENGTH;
|
|
1520
2777
|
exports.ADDRESS_STATE_MAX_LENGTH = ADDRESS_STATE_MAX_LENGTH;
|
|
1521
2778
|
exports.ADDRESS_ZIP_MAX_LENGTH = ADDRESS_ZIP_MAX_LENGTH;
|
|
2779
|
+
exports.ARKTYPE_DATE_DTO_TYPE = ARKTYPE_DATE_DTO_TYPE;
|
|
1522
2780
|
exports.AbstractModelPermissionService = AbstractModelPermissionService;
|
|
1523
2781
|
exports.CASHAPP_BASE_URL = CASHAPP_BASE_URL;
|
|
1524
2782
|
exports.CASHAPP_USERNAME_PREFIX = CASHAPP_USERNAME_PREFIX;
|
|
@@ -1643,4 +2901,3 @@ exports.websiteUrlType = websiteUrlType;
|
|
|
1643
2901
|
exports.websiteUrlWithPrefixType = websiteUrlWithPrefixType;
|
|
1644
2902
|
exports.youtubeProfileUrl = youtubeProfileUrl;
|
|
1645
2903
|
exports.youtubeProfileUrlToWebsiteLink = youtubeProfileUrlToWebsiteLink;
|
|
1646
|
-
//# sourceMappingURL=index.cjs.js.map
|