@dereekb/model 12.7.0 → 13.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/index.esm.js CHANGED
@@ -1,6 +1,7 @@
1
- import { ZIP_CODE_STRING_REGEX, US_STATE_CODE_STRING_REGEX, splitJoinRemainder, filterFalsyAndEmptyValues, isolateWebsitePathFunction, toRelativeSlashPathStartType, addPrefix, hasWebsiteDomain, toAbsoluteSlashPathStartType, removeHttpFromUrl, forEachKeyValue, iterableToArray, arrayToObject, MAP_IDENTITY, makeValuesGroupMap, cachedGetter, filterMaybeArrayValues, sortByNumberFunction, performAsyncTasks, pushArrayItemsIntoArray, stringToBoolean, splitCommaSeparatedString, mapPromiseOrValue, isISO8601DayString, isMinuteOfDay, isE164PhoneNumber, isE164PhoneNumberWithExtension, isUniqueKeyedFunction, isWebsiteUrl, isWebsiteUrlWithPrefix } from '@dereekb/util';
1
+ import { ZIP_CODE_STRING_REGEX, US_STATE_CODE_STRING_REGEX, splitJoinRemainder, filterFalsyAndEmptyValues, isolateWebsitePathFunction, toRelativeSlashPathStartType, addPrefix, hasWebsiteDomain, toAbsoluteSlashPathStartType, removeHttpFromUrl, forEachKeyValue, iterableToArray, arrayToObject, MAP_IDENTITY, makeValuesGroupMap, cachedGetter, filterMaybeArrayValues, sortByNumberFunction, performAsyncTasks, pushArrayItemsIntoArray, splitCommaSeparatedString, stringToBoolean, mapPromiseOrValue, isISO8601DayString, isMinuteOfDay, isE164PhoneNumber, isE164PhoneNumberWithExtension, isUniqueKeyedFunction, isWebsiteUrl, isWebsiteUrlWithPrefix } from '@dereekb/util';
2
2
  import { Expose, Transform, plainToInstance } from 'class-transformer';
3
3
  import { IsString, IsNotEmpty, MaxLength, IsOptional, Matches, MinLength, validate, registerDecorator, buildMessage } from 'class-validator';
4
+ import { BaseError } from 'make-error';
4
5
 
5
6
  /******************************************************************************
6
7
  Copyright (c) Microsoft Corporation.
@@ -42,37 +43,67 @@ const ADDRESS_STATE_CODE_MAX_LENGTH = 2;
42
43
  const ADDRESS_ZIP_MAX_LENGTH = 11;
43
44
  const ADDRESS_COUNTRY_MAX_LENGTH = 80;
44
45
  class AbstractUnitedStatesAddressWithoutStateParams {
45
- constructor() {
46
- this.line1 = void 0;
47
- this.line2 = void 0;
48
- this.city = void 0;
49
- this.zip = void 0;
50
- }
51
- }
52
- __decorate([Expose(), IsString(), IsNotEmpty(), MaxLength(ADDRESS_LINE_MAX_LENGTH), __metadata("design:type", String)], AbstractUnitedStatesAddressWithoutStateParams.prototype, "line1", void 0);
53
- __decorate([Expose(), IsOptional(), IsString(), MaxLength(ADDRESS_LINE_MAX_LENGTH), __metadata("design:type", String)], AbstractUnitedStatesAddressWithoutStateParams.prototype, "line2", void 0);
54
- __decorate([Expose(), IsString(), IsNotEmpty(), MaxLength(ADDRESS_CITY_MAX_LENGTH), __metadata("design:type", String)], AbstractUnitedStatesAddressWithoutStateParams.prototype, "city", void 0);
55
- __decorate([Expose(), IsString(), IsNotEmpty(), Matches(ZIP_CODE_STRING_REGEX), MaxLength(ADDRESS_ZIP_MAX_LENGTH), __metadata("design:type", String)], AbstractUnitedStatesAddressWithoutStateParams.prototype, "zip", void 0);
46
+ line1;
47
+ line2;
48
+ city;
49
+ zip;
50
+ }
51
+ __decorate([
52
+ Expose(),
53
+ IsString(),
54
+ IsNotEmpty(),
55
+ MaxLength(ADDRESS_LINE_MAX_LENGTH),
56
+ __metadata("design:type", String)
57
+ ], AbstractUnitedStatesAddressWithoutStateParams.prototype, "line1", void 0);
58
+ __decorate([
59
+ Expose(),
60
+ IsOptional(),
61
+ IsString(),
62
+ MaxLength(ADDRESS_LINE_MAX_LENGTH),
63
+ __metadata("design:type", String)
64
+ ], AbstractUnitedStatesAddressWithoutStateParams.prototype, "line2", void 0);
65
+ __decorate([
66
+ Expose(),
67
+ IsString(),
68
+ IsNotEmpty(),
69
+ MaxLength(ADDRESS_CITY_MAX_LENGTH),
70
+ __metadata("design:type", String)
71
+ ], AbstractUnitedStatesAddressWithoutStateParams.prototype, "city", void 0);
72
+ __decorate([
73
+ Expose(),
74
+ IsString(),
75
+ IsNotEmpty(),
76
+ Matches(ZIP_CODE_STRING_REGEX),
77
+ MaxLength(ADDRESS_ZIP_MAX_LENGTH),
78
+ __metadata("design:type", String)
79
+ ], AbstractUnitedStatesAddressWithoutStateParams.prototype, "zip", void 0);
56
80
  /**
57
81
  * UnitedStatesAddress that enforces a StateCode for the state value.
58
82
  */
59
83
  class UnitedStatesAddressWithStateCodeParams extends AbstractUnitedStatesAddressWithoutStateParams {
60
- constructor(...args) {
61
- super(...args);
62
- this.state = void 0;
63
- }
64
- }
65
- __decorate([Expose(), IsString(), Matches(US_STATE_CODE_STRING_REGEX), MinLength(ADDRESS_STATE_CODE_MAX_LENGTH), MaxLength(ADDRESS_STATE_CODE_MAX_LENGTH), __metadata("design:type", String)], UnitedStatesAddressWithStateCodeParams.prototype, "state", void 0);
84
+ state;
85
+ }
86
+ __decorate([
87
+ Expose(),
88
+ IsString(),
89
+ Matches(US_STATE_CODE_STRING_REGEX),
90
+ MinLength(ADDRESS_STATE_CODE_MAX_LENGTH),
91
+ MaxLength(ADDRESS_STATE_CODE_MAX_LENGTH),
92
+ __metadata("design:type", String)
93
+ ], UnitedStatesAddressWithStateCodeParams.prototype, "state", void 0);
66
94
  /**
67
95
  * UnitedStatesAddress that enforces a State for the state value.
68
96
  */
69
97
  class UnitedStatesAddressWithStateStringParams extends AbstractUnitedStatesAddressWithoutStateParams {
70
- constructor(...args) {
71
- super(...args);
72
- this.state = void 0;
73
- }
98
+ state;
74
99
  }
75
- __decorate([Expose(), IsString(), IsNotEmpty(), MaxLength(ADDRESS_STATE_MAX_LENGTH), __metadata("design:type", String)], UnitedStatesAddressWithStateStringParams.prototype, "state", void 0);
100
+ __decorate([
101
+ Expose(),
102
+ IsString(),
103
+ IsNotEmpty(),
104
+ MaxLength(ADDRESS_STATE_MAX_LENGTH),
105
+ __metadata("design:type", String)
106
+ ], UnitedStatesAddressWithStateStringParams.prototype, "state", void 0);
76
107
 
77
108
  const UNKNOWN_WEBSITE_LINK_TYPE = 'u';
78
109
  /**
@@ -84,24 +115,37 @@ const WEBSITE_LINK_TYPE_MAX_LENGTH = 32;
84
115
  */
85
116
  const WEBSITE_LINK_TYPE_REGEX = /^[a-zA-Z0-9]{1,32}$/;
86
117
  function isValidWebsiteLinkType(input) {
87
- return WEBSITE_LINK_TYPE_REGEX.test(input);
118
+ return WEBSITE_LINK_TYPE_REGEX.test(input);
88
119
  }
89
120
  /**
90
121
  * Default max length of WebsiteLink's data string.
91
122
  */
92
123
  const WEBSITE_LINK_ENCODED_DATA_MAX_LENGTH = 1000;
93
124
  class WebsiteLink {
94
- constructor(template) {
95
- this.t = void 0;
96
- this.d = void 0;
97
- if (template != null) {
98
- this.t = template.t;
99
- this.d = template.d;
125
+ t;
126
+ d;
127
+ constructor(template) {
128
+ if (template != null) {
129
+ this.t = template.t;
130
+ this.d = template.d;
131
+ }
100
132
  }
101
- }
102
133
  }
103
- __decorate([Expose(), IsString(), IsNotEmpty(), Matches(WEBSITE_LINK_TYPE_REGEX), MaxLength(WEBSITE_LINK_TYPE_MAX_LENGTH), __metadata("design:type", String)], WebsiteLink.prototype, "t", void 0);
104
- __decorate([Expose(), IsString(), IsNotEmpty(), MaxLength(WEBSITE_LINK_ENCODED_DATA_MAX_LENGTH), __metadata("design:type", String)], WebsiteLink.prototype, "d", void 0);
134
+ __decorate([
135
+ Expose(),
136
+ IsString(),
137
+ IsNotEmpty(),
138
+ Matches(WEBSITE_LINK_TYPE_REGEX),
139
+ MaxLength(WEBSITE_LINK_TYPE_MAX_LENGTH),
140
+ __metadata("design:type", String)
141
+ ], WebsiteLink.prototype, "t", void 0);
142
+ __decorate([
143
+ Expose(),
144
+ IsString(),
145
+ IsNotEmpty(),
146
+ MaxLength(WEBSITE_LINK_ENCODED_DATA_MAX_LENGTH),
147
+ __metadata("design:type", String)
148
+ ], WebsiteLink.prototype, "d", void 0);
105
149
 
106
150
  /**
107
151
  * Max length of WebsiteLink's data type.
@@ -129,47 +173,73 @@ const WEBSITE_FILE_LINK_NAME_MAX_LENGTH = 128;
129
173
  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;
130
174
  const WEBSITE_FILE_LINK_DATA_REGEX = /^[^|]+$/;
131
175
  class WebsiteFileLink {
132
- constructor(template) {
133
- this.type = void 0;
134
- this.mime = void 0;
135
- this.name = void 0;
136
- this.data = void 0;
137
- if (template != null) {
138
- this.type = template.type;
139
- this.mime = template.mime;
140
- this.name = template.name;
141
- this.data = template.data;
176
+ type;
177
+ mime;
178
+ name;
179
+ data;
180
+ constructor(template) {
181
+ if (template != null) {
182
+ this.type = template.type;
183
+ this.mime = template.mime;
184
+ this.name = template.name;
185
+ this.data = template.data;
186
+ }
142
187
  }
143
- }
144
188
  }
145
- __decorate([Expose(), IsOptional(), IsString(), Matches(WEBSITE_FILE_LINK_TYPE_REGEX), MaxLength(WEBSITE_LINK_TYPE_MAX_LENGTH), __metadata("design:type", String)], WebsiteFileLink.prototype, "type", void 0);
146
- __decorate([Expose(), IsOptional(), IsString(), Matches(WEBSITE_FILE_LINK_MIME_TYPE_REGEX), MaxLength(WEBSITE_FILE_LINK_MIME_TYPE_MAX_LENGTH), __metadata("design:type", String)], WebsiteFileLink.prototype, "mime", void 0);
147
- __decorate([Expose(), IsOptional(), IsString(), MaxLength(WEBSITE_FILE_LINK_NAME_MAX_LENGTH), __metadata("design:type", String)], WebsiteFileLink.prototype, "name", void 0);
148
- __decorate([IsString(), IsNotEmpty(), Matches(WEBSITE_FILE_LINK_DATA_REGEX), MaxLength(WEBSITE_FILE_LINK_DATA_MAX_LENGTH), __metadata("design:type", String)], WebsiteFileLink.prototype, "data", void 0);
189
+ __decorate([
190
+ Expose(),
191
+ IsOptional(),
192
+ IsString(),
193
+ Matches(WEBSITE_FILE_LINK_TYPE_REGEX),
194
+ MaxLength(WEBSITE_LINK_TYPE_MAX_LENGTH),
195
+ __metadata("design:type", String)
196
+ ], WebsiteFileLink.prototype, "type", void 0);
197
+ __decorate([
198
+ Expose(),
199
+ IsOptional(),
200
+ IsString(),
201
+ Matches(WEBSITE_FILE_LINK_MIME_TYPE_REGEX),
202
+ MaxLength(WEBSITE_FILE_LINK_MIME_TYPE_MAX_LENGTH),
203
+ __metadata("design:type", String)
204
+ ], WebsiteFileLink.prototype, "mime", void 0);
205
+ __decorate([
206
+ Expose(),
207
+ IsOptional(),
208
+ IsString(),
209
+ MaxLength(WEBSITE_FILE_LINK_NAME_MAX_LENGTH),
210
+ __metadata("design:type", String)
211
+ ], WebsiteFileLink.prototype, "name", void 0);
212
+ __decorate([
213
+ IsString(),
214
+ IsNotEmpty(),
215
+ Matches(WEBSITE_FILE_LINK_DATA_REGEX),
216
+ MaxLength(WEBSITE_FILE_LINK_DATA_MAX_LENGTH),
217
+ __metadata("design:type", String)
218
+ ], WebsiteFileLink.prototype, "data", void 0);
149
219
  const WEBSITE_FILE_LINK_WEBSITE_LINK_TYPE = 'f';
150
220
  function websiteFileLinkToWebsiteLink(input) {
151
- return {
152
- t: WEBSITE_FILE_LINK_WEBSITE_LINK_TYPE,
153
- d: encodeWebsiteFileLinkToWebsiteLinkEncodedData(input)
154
- };
221
+ return {
222
+ t: WEBSITE_FILE_LINK_WEBSITE_LINK_TYPE,
223
+ d: encodeWebsiteFileLinkToWebsiteLinkEncodedData(input)
224
+ };
155
225
  }
156
226
  function websiteLinkToWebsiteLinkFile(input) {
157
- const encodedData = input.d;
158
- return decodeWebsiteLinkEncodedDataToWebsiteFileLink(encodedData);
227
+ const encodedData = input.d;
228
+ return decodeWebsiteLinkEncodedDataToWebsiteFileLink(encodedData);
159
229
  }
160
230
  const WEBSITE_FILE_LINK_ENCODE_SEPARATOR = '|';
161
231
  function encodeWebsiteFileLinkToWebsiteLinkEncodedData(input) {
162
- const encoded = [input.type, input.mime, input.data, input.name].map(x => x || '').join(WEBSITE_FILE_LINK_ENCODE_SEPARATOR);
163
- return encoded;
232
+ const encoded = [input.type, input.mime, input.data, input.name].map((x) => x || '').join(WEBSITE_FILE_LINK_ENCODE_SEPARATOR);
233
+ return encoded;
164
234
  }
165
235
  function decodeWebsiteLinkEncodedDataToWebsiteFileLink(input) {
166
- const [type, mime, data, name] = splitJoinRemainder(input, WEBSITE_FILE_LINK_ENCODE_SEPARATOR, 4);
167
- return filterFalsyAndEmptyValues({
168
- type,
169
- mime,
170
- name,
171
- data
172
- });
236
+ const [type, mime, data, name] = splitJoinRemainder(input, WEBSITE_FILE_LINK_ENCODE_SEPARATOR, 4);
237
+ return filterFalsyAndEmptyValues({
238
+ type,
239
+ mime,
240
+ name,
241
+ data
242
+ });
173
243
  }
174
244
 
175
245
  /**
@@ -179,193 +249,194 @@ function decodeWebsiteLinkEncodedDataToWebsiteFileLink(input) {
179
249
  * - https://facebook.com/facebook
180
250
  */
181
251
  const WEBSITE_LINK_ISOLATE_BASE_URL_PROFILE_ID = isolateWebsitePathFunction({
182
- isolatePathComponents: 0,
183
- removeTrailingSlash: true,
184
- removeQueryParameters: true
252
+ isolatePathComponents: 0,
253
+ removeTrailingSlash: true,
254
+ removeQueryParameters: true
185
255
  });
186
256
  function usernameFromUsernameOrWebsiteWithBaseUrlUsername(input, prefix) {
187
- const username = toRelativeSlashPathStartType(WEBSITE_LINK_ISOLATE_BASE_URL_PROFILE_ID(usernameOrWebsiteUrlToWebsiteUrl(input)));
188
- if (prefix) {
189
- return addPrefix(prefix, username);
190
- } else {
191
- return username;
192
- }
257
+ const username = toRelativeSlashPathStartType(WEBSITE_LINK_ISOLATE_BASE_URL_PROFILE_ID(usernameOrWebsiteUrlToWebsiteUrl(input)));
258
+ if (prefix) {
259
+ return addPrefix(prefix, username);
260
+ }
261
+ else {
262
+ return username;
263
+ }
193
264
  }
194
265
  function usernameFromUsernameOrWebsiteWithOneOffBaseUrlUsername(input, isolateFn) {
195
- return toRelativeSlashPathStartType(isolateFn(usernameOrWebsiteUrlToWebsiteUrl(input)));
266
+ return toRelativeSlashPathStartType(isolateFn(usernameOrWebsiteUrlToWebsiteUrl(input)));
196
267
  }
197
268
  function usernameOrWebsiteUrlToWebsiteUrl(input) {
198
- return hasWebsiteDomain(input) ? input : toAbsoluteSlashPathStartType(removeHttpFromUrl(input));
269
+ return hasWebsiteDomain(input) ? input : toAbsoluteSlashPathStartType(removeHttpFromUrl(input));
199
270
  }
200
271
  // MARK: Website
201
272
  const WEBSITE_URL_WEBSITE_LINK_TYPE = 'w';
202
273
  function websiteUrlToWebsiteLink(input) {
203
- return {
204
- t: WEBSITE_URL_WEBSITE_LINK_TYPE,
205
- d: removeHttpFromUrl(input) // website urls are stored as-is without http/https
206
- };
274
+ return {
275
+ t: WEBSITE_URL_WEBSITE_LINK_TYPE,
276
+ d: removeHttpFromUrl(input) // website urls are stored as-is without http/https
277
+ };
207
278
  }
208
279
  // MARK: Email
209
280
  const EMAIL_URL_WEBSITE_LINK_TYPE = 'e';
210
281
  function emailAddressToWebsiteLink(input) {
211
- return {
212
- t: EMAIL_URL_WEBSITE_LINK_TYPE,
213
- d: input
214
- };
282
+ return {
283
+ t: EMAIL_URL_WEBSITE_LINK_TYPE,
284
+ d: input
285
+ };
215
286
  }
216
287
  // MARK: Phone
217
288
  const PHONE_URL_WEBSITE_LINK_TYPE = 'p';
218
289
  function phoneNumberToWebsiteLink(input) {
219
- return {
220
- t: PHONE_URL_WEBSITE_LINK_TYPE,
221
- d: input
222
- };
290
+ return {
291
+ t: PHONE_URL_WEBSITE_LINK_TYPE,
292
+ d: input
293
+ };
223
294
  }
224
295
  // MARK: Facebook
225
296
  const FACEBOOK_BASE_URL = `https://www.facebook.com`;
226
297
  const FACEBOOK_WEBSITE_LINK_TYPE = 'fb';
227
298
  function facebookProfileUrlToWebsiteLink(input) {
228
- return {
229
- t: FACEBOOK_WEBSITE_LINK_TYPE,
230
- d: usernameFromUsernameOrWebsiteWithBaseUrlUsername(input)
231
- };
299
+ return {
300
+ t: FACEBOOK_WEBSITE_LINK_TYPE,
301
+ d: usernameFromUsernameOrWebsiteWithBaseUrlUsername(input)
302
+ };
232
303
  }
233
304
  function facebookProfileUrl(profileId) {
234
- return `${FACEBOOK_BASE_URL}/${profileId}`;
305
+ return `${FACEBOOK_BASE_URL}/${profileId}`;
235
306
  }
236
307
  // MARK: Instagram
237
308
  const INSTAGRAM_BASE_URL = `https://www.instagram.com`;
238
309
  const INSTAGRAM_WEBSITE_LINK_TYPE = 'ig';
239
310
  function instagramProfileUrlToWebsiteLink(input) {
240
- return {
241
- t: INSTAGRAM_WEBSITE_LINK_TYPE,
242
- d: usernameFromUsernameOrWebsiteWithBaseUrlUsername(input)
243
- };
311
+ return {
312
+ t: INSTAGRAM_WEBSITE_LINK_TYPE,
313
+ d: usernameFromUsernameOrWebsiteWithBaseUrlUsername(input)
314
+ };
244
315
  }
245
316
  function instagramProfileUrl(profileId) {
246
- return `${INSTAGRAM_BASE_URL}/${profileId}`;
317
+ return `${INSTAGRAM_BASE_URL}/${profileId}`;
247
318
  }
248
319
  // MARK: Twitter
249
320
  const TWITTER_BASE_URL = `https://www.twitter.com`;
250
321
  const TWITTER_WEBSITE_LINK_TYPE = 'tw';
251
322
  function twitterProfileUrlToWebsiteLink(input) {
252
- return {
253
- t: TWITTER_WEBSITE_LINK_TYPE,
254
- d: usernameFromUsernameOrWebsiteWithBaseUrlUsername(input)
255
- };
323
+ return {
324
+ t: TWITTER_WEBSITE_LINK_TYPE,
325
+ d: usernameFromUsernameOrWebsiteWithBaseUrlUsername(input)
326
+ };
256
327
  }
257
328
  function twitterProfileUrl(profileId) {
258
- return `${TWITTER_BASE_URL}/${profileId}`;
329
+ return `${TWITTER_BASE_URL}/${profileId}`;
259
330
  }
260
331
  // MARK: Tiktok
261
332
  const TIKTOK_BASE_URL = `https://tiktok.com`;
262
333
  const TIKTOK_USERNAME_PREFIX = '@';
263
334
  const TIKTOK_WEBSITE_LINK_TYPE = 'tt';
264
335
  function tiktokProfileUrlToWebsiteLink(input) {
265
- return {
266
- t: TIKTOK_WEBSITE_LINK_TYPE,
267
- d: usernameFromUsernameOrWebsiteWithBaseUrlUsername(input, TIKTOK_USERNAME_PREFIX)
268
- };
336
+ return {
337
+ t: TIKTOK_WEBSITE_LINK_TYPE,
338
+ d: usernameFromUsernameOrWebsiteWithBaseUrlUsername(input, TIKTOK_USERNAME_PREFIX)
339
+ };
269
340
  }
270
341
  function tiktokProfileUrl(profileId) {
271
- return `${TIKTOK_BASE_URL}/@${profileId}`;
342
+ return `${TIKTOK_BASE_URL}/@${profileId}`;
272
343
  }
273
344
  // MARK: Snapchat
274
345
  const SNAPCHAT_BASE_URL = `https://snapchat.com`;
275
346
  const SNAPCHAT_WEBSITE_LINK_TYPE = 'sc';
276
347
  const SNAPCHAT_WEBSITE_LINK_ISOLATE_PROFILE_ID = isolateWebsitePathFunction({
277
- ignoredBasePath: 'add',
278
- isolatePathComponents: 0,
279
- removeTrailingSlash: true,
280
- removeQueryParameters: true
348
+ ignoredBasePath: 'add',
349
+ isolatePathComponents: 0,
350
+ removeTrailingSlash: true,
351
+ removeQueryParameters: true
281
352
  });
282
353
  function snapchatProfileUrlToWebsiteLink(input) {
283
- return {
284
- t: SNAPCHAT_WEBSITE_LINK_TYPE,
285
- d: usernameFromUsernameOrWebsiteWithOneOffBaseUrlUsername(input, SNAPCHAT_WEBSITE_LINK_ISOLATE_PROFILE_ID)
286
- };
354
+ return {
355
+ t: SNAPCHAT_WEBSITE_LINK_TYPE,
356
+ d: usernameFromUsernameOrWebsiteWithOneOffBaseUrlUsername(input, SNAPCHAT_WEBSITE_LINK_ISOLATE_PROFILE_ID)
357
+ };
287
358
  }
288
359
  function snapchatProfileUrl(profileId) {
289
- return `${SNAPCHAT_BASE_URL}/add/${profileId}`;
360
+ return `${SNAPCHAT_BASE_URL}/add/${profileId}`;
290
361
  }
291
362
  // MARK: YouTube
292
363
  const YOUTUBE_BASE_URL = `https://youtube.com`;
293
364
  const YOUTUBE_WEBSITE_LINK_TYPE = 'yt';
294
365
  const YOUTUBE_WEBSITE_LINK_ISOLATE_PROFILE_ID = isolateWebsitePathFunction({
295
- ignoredBasePath: 'c',
296
- isolatePathComponents: 0,
297
- removeTrailingSlash: true,
298
- removeQueryParameters: true
366
+ ignoredBasePath: 'c',
367
+ isolatePathComponents: 0,
368
+ removeTrailingSlash: true,
369
+ removeQueryParameters: true
299
370
  });
300
371
  function youtubeProfileUrlToWebsiteLink(input) {
301
- return {
302
- t: YOUTUBE_WEBSITE_LINK_TYPE,
303
- d: usernameFromUsernameOrWebsiteWithOneOffBaseUrlUsername(input, YOUTUBE_WEBSITE_LINK_ISOLATE_PROFILE_ID)
304
- };
372
+ return {
373
+ t: YOUTUBE_WEBSITE_LINK_TYPE,
374
+ d: usernameFromUsernameOrWebsiteWithOneOffBaseUrlUsername(input, YOUTUBE_WEBSITE_LINK_ISOLATE_PROFILE_ID)
375
+ };
305
376
  }
306
377
  function youtubeProfileUrl(profileId) {
307
- return `${YOUTUBE_BASE_URL}/c/${profileId}`;
378
+ return `${YOUTUBE_BASE_URL}/c/${profileId}`;
308
379
  }
309
380
  // MARK: PayPal
310
381
  const PAYPAL_BASE_URL = `https://paypal.me`;
311
382
  const PAYPAL_WEBSITE_LINK_TYPE = 'pp';
312
383
  function paypalProfileUrlToWebsiteLink(input) {
313
- return {
314
- t: PAYPAL_WEBSITE_LINK_TYPE,
315
- d: usernameFromUsernameOrWebsiteWithBaseUrlUsername(input)
316
- };
384
+ return {
385
+ t: PAYPAL_WEBSITE_LINK_TYPE,
386
+ d: usernameFromUsernameOrWebsiteWithBaseUrlUsername(input)
387
+ };
317
388
  }
318
389
  function paypalProfileUrl(profileId) {
319
- return `${PAYPAL_BASE_URL}/${profileId}`;
390
+ return `${PAYPAL_BASE_URL}/${profileId}`;
320
391
  }
321
392
  // MARK: Cashapp
322
393
  const CASHAPP_BASE_URL = `https://cash.app`;
323
394
  const CASHAPP_USERNAME_PREFIX = '$';
324
395
  const CASHAPP_WEBSITE_LINK_TYPE = 'ca';
325
396
  function cashappProfileUrlToWebsiteLink(input) {
326
- return {
327
- t: CASHAPP_WEBSITE_LINK_TYPE,
328
- d: usernameFromUsernameOrWebsiteWithBaseUrlUsername(input, CASHAPP_USERNAME_PREFIX)
329
- };
397
+ return {
398
+ t: CASHAPP_WEBSITE_LINK_TYPE,
399
+ d: usernameFromUsernameOrWebsiteWithBaseUrlUsername(input, CASHAPP_USERNAME_PREFIX)
400
+ };
330
401
  }
331
402
  function cashappProfileUrl(profileId) {
332
- return `${CASHAPP_BASE_URL}/$${profileId}`;
403
+ return `${CASHAPP_BASE_URL}/$${profileId}`;
333
404
  }
334
405
  // MARK: Venmo
335
406
  const VENMO_BASE_URL = `https://account.venmo.com`;
336
407
  const VENMO_WEBSITE_LINK_TYPE = 'vn';
337
408
  const VENMO_WEBSITE_LINK_ISOLATE_PROFILE_ID = isolateWebsitePathFunction({
338
- ignoredBasePath: 'u',
339
- isolatePathComponents: 0,
340
- removeTrailingSlash: true,
341
- removeQueryParameters: true
409
+ ignoredBasePath: 'u',
410
+ isolatePathComponents: 0,
411
+ removeTrailingSlash: true,
412
+ removeQueryParameters: true
342
413
  });
343
414
  function venmoProfileUrlToWebsiteLink(input) {
344
- return {
345
- t: VENMO_WEBSITE_LINK_TYPE,
346
- d: usernameFromUsernameOrWebsiteWithOneOffBaseUrlUsername(input, VENMO_WEBSITE_LINK_ISOLATE_PROFILE_ID)
347
- };
415
+ return {
416
+ t: VENMO_WEBSITE_LINK_TYPE,
417
+ d: usernameFromUsernameOrWebsiteWithOneOffBaseUrlUsername(input, VENMO_WEBSITE_LINK_ISOLATE_PROFILE_ID)
418
+ };
348
419
  }
349
420
  function venmoProfileUrl(profileId) {
350
- return `${VENMO_BASE_URL}/u/${profileId}`;
421
+ return `${VENMO_BASE_URL}/u/${profileId}`;
351
422
  }
352
423
  // MARK: Spotify
353
424
  const SPOTIFY_BASE_URL = `https://open.spotify.com/`;
354
425
  const SPOTIFY_WEBSITE_LINK_TYPE = 'sp';
355
426
  const SPOTIFY_WEBSITE_LINK_ISOLATE_PROFILE_ID = isolateWebsitePathFunction({
356
- ignoredBasePath: 'user',
357
- isolatePathComponents: 0,
358
- removeTrailingSlash: true,
359
- removeQueryParameters: true
427
+ ignoredBasePath: 'user',
428
+ isolatePathComponents: 0,
429
+ removeTrailingSlash: true,
430
+ removeQueryParameters: true
360
431
  });
361
432
  function spotifyProfileUrlToWebsiteLink(input) {
362
- return {
363
- t: SPOTIFY_WEBSITE_LINK_TYPE,
364
- d: usernameFromUsernameOrWebsiteWithOneOffBaseUrlUsername(input, SPOTIFY_WEBSITE_LINK_ISOLATE_PROFILE_ID)
365
- };
433
+ return {
434
+ t: SPOTIFY_WEBSITE_LINK_TYPE,
435
+ d: usernameFromUsernameOrWebsiteWithOneOffBaseUrlUsername(input, SPOTIFY_WEBSITE_LINK_ISOLATE_PROFILE_ID)
436
+ };
366
437
  }
367
438
  function spotifyProfileUrl(profileId) {
368
- return `${SPOTIFY_BASE_URL}/user/${profileId}`;
439
+ return `${SPOTIFY_BASE_URL}/user/${profileId}`;
369
440
  }
370
441
 
371
442
  const GRANTED_SYS_ADMIN_ROLE_KEY = 'sysadmin';
@@ -378,7 +449,7 @@ const GRANTED_ADMIN_ROLE_KEY = 'admin';
378
449
  * @returns
379
450
  */
380
451
  function isGrantedAdminLevelRole(role) {
381
- return role === GRANTED_ADMIN_ROLE_KEY || role === GRANTED_OWNER_ROLE_KEY;
452
+ return role === GRANTED_ADMIN_ROLE_KEY || role === GRANTED_OWNER_ROLE_KEY;
382
453
  }
383
454
  const GRANTED_READ_ROLE_KEY = 'read';
384
455
  const GRANTED_UPDATE_ROLE_KEY = 'update';
@@ -386,20 +457,20 @@ const GRANTED_DELETE_ROLE_KEY = 'delete';
386
457
  const FULL_ACCESS_ROLE_KEY = '__FULL__';
387
458
  const NO_ACCESS_ROLE_KEY = '__EMPTY__';
388
459
  function noAccessRoleMap() {
389
- return {
390
- [NO_ACCESS_ROLE_KEY]: true
391
- };
460
+ return {
461
+ [NO_ACCESS_ROLE_KEY]: true
462
+ };
392
463
  }
393
464
  function isNoAccessRoleMap(input) {
394
- return input[NO_ACCESS_ROLE_KEY] === true;
465
+ return input[NO_ACCESS_ROLE_KEY] === true;
395
466
  }
396
467
  function fullAccessRoleMap() {
397
- return {
398
- [FULL_ACCESS_ROLE_KEY]: true
399
- };
468
+ return {
469
+ [FULL_ACCESS_ROLE_KEY]: true
470
+ };
400
471
  }
401
472
  function isFullAccessRoleMap(input) {
402
- return input[FULL_ACCESS_ROLE_KEY] === true;
473
+ return input[FULL_ACCESS_ROLE_KEY] === true;
403
474
  }
404
475
  /**
405
476
  * Creates a GrantedRoleMapReader.
@@ -408,61 +479,63 @@ function isFullAccessRoleMap(input) {
408
479
  * @returns
409
480
  */
410
481
  function grantedRoleMapReader(map) {
411
- return new GrantedRoleMapReaderInstance(map);
482
+ return new GrantedRoleMapReaderInstance(map);
412
483
  }
413
484
  class GrantedRoleMapReaderInstance {
414
- constructor(map) {
415
- this._map = void 0;
416
- this._map = map;
417
- }
418
- hasNoAccess() {
419
- return this._map[NO_ACCESS_ROLE_KEY];
420
- }
421
- truthMap(input) {
422
- const result = {};
423
- forEachKeyValue(input, {
424
- forEach: ([role, value]) => {
425
- if (this.hasRole(role)) {
426
- result[role] = value;
427
- }
428
- }
429
- });
430
- return result;
431
- }
432
- hasRole(role) {
433
- return this.hasRoles('any', role);
434
- }
435
- hasRoles(setIncludes, inputRoles) {
436
- if (this._map[FULL_ACCESS_ROLE_KEY]) {
437
- return true;
438
- } else {
439
- return this.containsRoles(setIncludes, inputRoles);
485
+ _map;
486
+ constructor(map) {
487
+ this._map = map;
440
488
  }
441
- }
442
- containsRoles(setIncludes, inputRoles) {
443
- const roles = iterableToArray(inputRoles);
444
- if (setIncludes === 'any') {
445
- return this.containsAnyRole(roles);
446
- } else {
447
- return this.containsEachRole(roles);
489
+ hasNoAccess() {
490
+ return this._map[NO_ACCESS_ROLE_KEY];
448
491
  }
449
- }
450
- containsAnyRole(roles) {
451
- for (const role of roles) {
452
- if (this._map[role]) {
453
- return true;
454
- }
492
+ truthMap(input) {
493
+ const result = {};
494
+ forEachKeyValue(input, {
495
+ forEach: ([role, value]) => {
496
+ if (this.hasRole(role)) {
497
+ result[role] = value;
498
+ }
499
+ }
500
+ });
501
+ return result;
502
+ }
503
+ hasRole(role) {
504
+ return this.hasRoles('any', role);
505
+ }
506
+ hasRoles(setIncludes, inputRoles) {
507
+ if (this._map[FULL_ACCESS_ROLE_KEY]) {
508
+ return true;
509
+ }
510
+ else {
511
+ return this.containsRoles(setIncludes, inputRoles);
512
+ }
513
+ }
514
+ containsRoles(setIncludes, inputRoles) {
515
+ const roles = iterableToArray(inputRoles);
516
+ if (setIncludes === 'any') {
517
+ return this.containsAnyRole(roles);
518
+ }
519
+ else {
520
+ return this.containsEachRole(roles);
521
+ }
455
522
  }
456
- return false;
457
- }
458
- containsEachRole(roles) {
459
- for (const role of roles) {
460
- if (!this._map[role]) {
523
+ containsAnyRole(roles) {
524
+ for (const role of roles) {
525
+ if (this._map[role]) {
526
+ return true;
527
+ }
528
+ }
461
529
  return false;
462
- }
463
530
  }
464
- return true;
465
- }
531
+ containsEachRole(roles) {
532
+ for (const role of roles) {
533
+ if (!this._map[role]) {
534
+ return false;
535
+ }
536
+ }
537
+ return true;
538
+ }
466
539
  }
467
540
  /**
468
541
  * Converts the input array of roles to a GrantedRoleKeysMap.
@@ -471,74 +544,77 @@ class GrantedRoleMapReaderInstance {
471
544
  * @returns
472
545
  */
473
546
  function grantedRoleKeysMapFromArray(roles, value = true) {
474
- return arrayToObject(roles, x => x, () => value);
547
+ return arrayToObject(roles, (x) => x, () => value);
475
548
  }
476
549
 
477
550
  function noAccessContextGrantedModelRoles(context, data) {
478
- return contextGrantedModelRoles(context, data, noAccessRoleMap());
551
+ return contextGrantedModelRoles(context, data, noAccessRoleMap());
479
552
  }
480
553
  function fullAccessGrantedModelRoles(context, data) {
481
- return contextGrantedModelRoles(context, data, fullAccessRoleMap());
554
+ return contextGrantedModelRoles(context, data, fullAccessRoleMap());
482
555
  }
483
556
  function contextGrantedModelRoles(context, data, roles) {
484
- return {
485
- data,
486
- context,
487
- roleMap: roles
488
- };
557
+ return {
558
+ data,
559
+ context,
560
+ roleMap: roles
561
+ };
489
562
  }
490
563
 
491
564
  /**
492
565
  * Abstract ModelPermissionService implementation.
493
566
  */
494
567
  class AbstractModelPermissionService {
495
- constructor(modelLoader) {
496
- this._modelLoader = void 0;
497
- this._modelLoader = modelLoader;
498
- }
499
- get modelLoader() {
500
- return this._modelLoader;
501
- }
502
- async roleMapForKeyContext(key, context) {
503
- const model = await this.modelLoader.loadModelForKey(key, context);
504
- let result;
505
- if (model != null) {
506
- result = await this.roleMapForModelContext(model, context);
507
- } else {
508
- result = noAccessContextGrantedModelRoles(context);
568
+ _modelLoader;
569
+ constructor(modelLoader) {
570
+ this._modelLoader = modelLoader;
509
571
  }
510
- return result;
511
- }
512
- async roleMapForModelContext(model, context) {
513
- const output = await this.outputForModel(model, context);
514
- let result;
515
- if (output != null && this.isUsableOutputForRoles(output, context)) {
516
- result = await this.getRoleMapForOutput(output, context, model);
517
- } else {
518
- result = noAccessContextGrantedModelRoles(context, output);
572
+ get modelLoader() {
573
+ return this._modelLoader;
574
+ }
575
+ async roleMapForKeyContext(key, context) {
576
+ const model = await this.modelLoader.loadModelForKey(key, context);
577
+ let result;
578
+ if (model != null) {
579
+ result = await this.roleMapForModelContext(model, context);
580
+ }
581
+ else {
582
+ result = noAccessContextGrantedModelRoles(context);
583
+ }
584
+ return result;
585
+ }
586
+ async roleMapForModelContext(model, context) {
587
+ const output = await this.outputForModel(model, context);
588
+ let result;
589
+ if (output != null && this.isUsableOutputForRoles(output, context)) {
590
+ result = await this.getRoleMapForOutput(output, context, model);
591
+ }
592
+ else {
593
+ result = noAccessContextGrantedModelRoles(context, output);
594
+ }
595
+ return result;
596
+ }
597
+ async getRoleMapForOutput(output, context, model) {
598
+ const roleMap = await this.roleMapForModel(output, context, model);
599
+ return contextGrantedModelRoles(context, output, roleMap);
600
+ }
601
+ isUsableOutputForRoles(output, context) {
602
+ return true; // can override in parent functions to further filter roles.
519
603
  }
520
- return result;
521
- }
522
- async getRoleMapForOutput(output, context, model) {
523
- const roleMap = await this.roleMapForModel(output, context, model);
524
- return contextGrantedModelRoles(context, output, roleMap);
525
- }
526
- isUsableOutputForRoles(output, context) {
527
- return true; // can override in parent functions to further filter roles.
528
- }
529
604
  }
530
605
 
531
606
  function syncEntityCommonTypeIdPairFactory(commonType) {
532
- return input => {
533
- if (typeof input === 'string') {
534
- return {
535
- commonType,
536
- commonId: input
537
- };
538
- } else {
539
- return input;
540
- }
541
- };
607
+ return (input) => {
608
+ if (typeof input === 'string') {
609
+ return {
610
+ commonType,
611
+ commonId: input
612
+ };
613
+ }
614
+ else {
615
+ return input;
616
+ }
617
+ };
542
618
  }
543
619
  /**
544
620
  * Creates a SyncEntityFactory.
@@ -547,2215 +623,552 @@ function syncEntityCommonTypeIdPairFactory(commonType) {
547
623
  * @returns
548
624
  */
549
625
  function syncEntityFactory(config) {
550
- const {
551
- idFactory: inputIdFactory,
552
- sourceInfo
553
- } = config;
554
- const idFactory = inputIdFactory ?? MAP_IDENTITY;
555
- return input => {
556
- const {
557
- commonType,
558
- commonId
559
- } = input;
560
- const id = idFactory(commonId);
561
- return {
562
- commonType,
563
- commonId,
564
- id,
565
- sourceInfo
626
+ const { idFactory: inputIdFactory, sourceInfo } = config;
627
+ const idFactory = inputIdFactory ?? MAP_IDENTITY;
628
+ return (input) => {
629
+ const { commonType, commonId } = input;
630
+ const id = idFactory(commonId);
631
+ return {
632
+ commonType,
633
+ commonId,
634
+ id,
635
+ sourceInfo
636
+ };
566
637
  };
567
- };
568
638
  }
569
639
 
570
- var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
640
+ /**
641
+ * Error thrown when the common type is not known/registered.
642
+ */
643
+ class UnregisteredSyncEntityCommonTypeError extends BaseError {
644
+ commonType;
645
+ constructor(commonType) {
646
+ super(`The common type "${commonType}" is not registered.`);
647
+ this.commonType = commonType;
648
+ }
649
+ }
650
+ /**
651
+ * Error thrown when no primary sync source is found for an entity.
652
+ */
653
+ class NoPrimarySyncSourceError extends BaseError {
654
+ entity;
655
+ constructor(entity) {
656
+ super(`No primary sync source found for entity "${entity.commonType}:${entity.commonId}".`);
657
+ this.entity = entity;
658
+ }
659
+ }
660
+ /**
661
+ * Error thrown when multiple primary sync sources are found for an entity.
662
+ */
663
+ class MultiplePrimarySyncSourceError extends BaseError {
664
+ entity;
665
+ constructor(entity) {
666
+ super(`Multiple primary sync sources found for entity "${entity.commonType}:${entity.commonId}".`);
667
+ this.entity = entity;
668
+ }
669
+ }
670
+ /**
671
+ * Error thrown when a synchronization fails for an entity.
672
+ */
673
+ class SynchronizationFailedError extends BaseError {
674
+ entity;
675
+ error;
676
+ constructor(entity, error) {
677
+ super(`Synchronization failed for entity "${entity.commonType}:${entity.commonId}". Error: ${error}`);
678
+ this.entity = entity;
679
+ this.error = error;
680
+ }
681
+ }
571
682
 
572
- var check = function (it) {
573
- return it && it.Math === Math && it;
574
- };
683
+ function syncEntitySynchronizer(config) {
684
+ const map = new Map(config.commonTypeSynchronizers.map((x) => [x.commonType, x]));
685
+ const commonTypes = Array.from(map.keys());
686
+ const commonTypeSynchronizer = (input) => {
687
+ const synchronizer = map.get(input);
688
+ if (!synchronizer) {
689
+ throw new UnregisteredSyncEntityCommonTypeError(input);
690
+ }
691
+ return synchronizer;
692
+ };
693
+ return {
694
+ commonTypes,
695
+ commonTypeSynchronizer,
696
+ synchronizeInstance: (input) => {
697
+ const synchronizer = commonTypeSynchronizer(input.commonType);
698
+ return synchronizer.synchronizeInstance(input);
699
+ }
700
+ };
701
+ }
575
702
 
576
- // https://github.com/zloirock/core-js/issues/86#issuecomment-115759028
577
- var global$b =
578
- // eslint-disable-next-line es/no-global-this -- safe
579
- check(typeof globalThis == 'object' && globalThis) ||
580
- check(typeof window == 'object' && window) ||
581
- // eslint-disable-next-line no-restricted-globals -- safe
582
- check(typeof self == 'object' && self) ||
583
- check(typeof commonjsGlobal == 'object' && commonjsGlobal) ||
584
- check(typeof commonjsGlobal == 'object' && commonjsGlobal) ||
585
- // eslint-disable-next-line no-new-func -- fallback
586
- (function () { return this; })() || Function('return this')();
703
+ function basicSyncEntityCommonTypeSynchronizerInstanceFactory(config) {
704
+ const { commonType, sources, entitySourceContextLoader, dynamicSources = false } = config;
705
+ const syncEntityCommonTypeIdPairForType = syncEntityCommonTypeIdPairFactory(commonType);
706
+ const sourcesByContextType = makeValuesGroupMap(sources, (x) => x.contextType);
707
+ const allGlobalSources = sourcesByContextType.get('global') ?? [];
708
+ const allContextSources = sourcesByContextType.get('context') ?? [];
709
+ /**
710
+ * Loads the relevant sources for the given entity and context.
711
+ *
712
+ * @param entitySourceContext The contextual information for the entity.
713
+ * @returns The relevant sources for the entity.
714
+ */
715
+ function loadSources(entityCommonTypeIdPair, entitySourceContext) {
716
+ const { globalSources, contextSources } = entitySourceContext;
717
+ // load/filter global sources
718
+ const globalMap = new Map(globalSources.map((x) => {
719
+ let sourceId;
720
+ let flowType;
721
+ if (typeof x === 'string') {
722
+ sourceId = x;
723
+ flowType = 'unset';
724
+ }
725
+ else {
726
+ sourceId = x.sourceId;
727
+ flowType = x.flowType;
728
+ }
729
+ return [sourceId, { sourceId, flowType }];
730
+ }));
731
+ const relevantGlobalSources = filterMaybeArrayValues(allGlobalSources.map((x) => {
732
+ const sourceContext = globalMap.get(x.info.id);
733
+ let result;
734
+ if (sourceContext != null) {
735
+ result = {
736
+ entityCommonTypeIdPair,
737
+ flowType: sourceContext.flowType ?? x.defaultFlowType ?? 'unset',
738
+ source: x
739
+ };
740
+ }
741
+ return result;
742
+ }));
743
+ // load/filter context sources
744
+ const contextMap = new Map(contextSources.map((x) => [x.sourceId, x]));
745
+ const relevantContextSources = filterMaybeArrayValues(allContextSources.map((x) => {
746
+ const sourceContext = contextMap.get(x.info.id);
747
+ let result;
748
+ if (sourceContext != null) {
749
+ const flowType = sourceContext.flowType ?? x.defaultFlowType ?? 'unset';
750
+ result = {
751
+ entityCommonTypeIdPair,
752
+ flowType,
753
+ source: x,
754
+ context: sourceContext
755
+ };
756
+ }
757
+ return result;
758
+ }));
759
+ const allSources = [...relevantGlobalSources, ...relevantContextSources];
760
+ // sort by order, with primary first
761
+ allSources.sort(sortByNumberFunction((x) => {
762
+ let result;
763
+ switch (x.flowType) {
764
+ case 'primary':
765
+ result = 1;
766
+ break;
767
+ case 'secondary':
768
+ result = 2;
769
+ break;
770
+ case 'unset':
771
+ default:
772
+ result = 3;
773
+ break;
774
+ }
775
+ return result;
776
+ }));
777
+ return allSources;
778
+ }
779
+ const synchronizeInstance = async (input) => {
780
+ const syncEntityCommonTypeIdPair = syncEntityCommonTypeIdPairForType(input);
781
+ const _loadRelevantSources = async () => {
782
+ const entitySourceContext = await entitySourceContextLoader(syncEntityCommonTypeIdPair);
783
+ const relevantSources = loadSources(syncEntityCommonTypeIdPair, entitySourceContext);
784
+ return relevantSources;
785
+ };
786
+ let loadRelevantSources;
787
+ if (dynamicSources) {
788
+ // if dynamic, reload each time and do not cache
789
+ loadRelevantSources = _loadRelevantSources;
790
+ }
791
+ else {
792
+ // if not dynamic, make a cached getter
793
+ loadRelevantSources = cachedGetter(_loadRelevantSources);
794
+ }
795
+ /**
796
+ * Performs the synchonization
797
+ */
798
+ const synchronize = async (context) => {
799
+ const relevantSources = await loadRelevantSources();
800
+ const syncEntityInstances = await Promise.all(relevantSources.map((x) => x.source.syncEntityInstance(x).then((y) => [x, y])));
801
+ const sourcesByFlowType = makeValuesGroupMap(syncEntityInstances, (x) => x[0].flowType);
802
+ const primarySources = sourcesByFlowType.get('primary') ?? [];
803
+ const secondarySources = sourcesByFlowType.get('secondary') ?? [];
804
+ const replicaSources = sourcesByFlowType.get('replica') ?? [];
805
+ // assert primary sources count
806
+ switch (primarySources.length) {
807
+ case 0:
808
+ throw new NoPrimarySyncSourceError(syncEntityCommonTypeIdPair);
809
+ case 1:
810
+ break;
811
+ default:
812
+ throw new MultiplePrimarySyncSourceError(syncEntityCommonTypeIdPair);
813
+ }
814
+ function synchronizeInstance(source, deleted) {
815
+ const [input, sourceInstance] = source;
816
+ const promise = deleted ? sourceInstance.synchronizeDelete() : sourceInstance.synchronize();
817
+ return promise.catch((error) => {
818
+ const errorResult = {
819
+ type: 'error',
820
+ error,
821
+ entity: {
822
+ ...syncEntityCommonTypeIdPair,
823
+ sourceInfo: input.source.info,
824
+ id: ''
825
+ }
826
+ };
827
+ return errorResult;
828
+ });
829
+ }
830
+ async function performSynchronizationOfSources(input) {
831
+ const { secondaryFlaggedDelete } = input;
832
+ let result;
833
+ // synchronize the primary source
834
+ const primarySource = primarySources[0];
835
+ const primarySyncResult = await synchronizeInstance(primarySource, secondaryFlaggedDelete ?? false);
836
+ const synchronizedEntityResults = [primarySyncResult];
837
+ let primaryFlaggedDelete = false;
838
+ switch (primarySyncResult.type) {
839
+ case 'deleted':
840
+ primaryFlaggedDelete = true;
841
+ break;
842
+ case 'failed':
843
+ case 'error':
844
+ throw new SynchronizationFailedError(syncEntityCommonTypeIdPair, primarySyncResult.error);
845
+ }
846
+ // 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.
847
+ for (const secondarySource of secondarySources) {
848
+ const secondarySyncResult = await synchronizeInstance(secondarySource, primaryFlaggedDelete);
849
+ synchronizedEntityResults.push(secondarySyncResult);
850
+ switch (secondarySyncResult.type) {
851
+ case 'deleted':
852
+ if (primaryFlaggedDelete === false) {
853
+ break;
854
+ }
855
+ break;
856
+ case 'failed':
857
+ case 'error':
858
+ throw new SynchronizationFailedError(syncEntityCommonTypeIdPair, secondarySyncResult.error);
859
+ }
860
+ }
861
+ // if result was already set, then it was completed in a recursive result
862
+ if (result == null) {
863
+ // synchronize all replica sources concurrently
864
+ const replicaTaskResults = await performAsyncTasks(replicaSources, (x) => synchronizeInstance(x, primaryFlaggedDelete), {
865
+ sequential: false,
866
+ maxParallelTasks: 3
867
+ });
868
+ // add all the results
869
+ pushArrayItemsIntoArray(synchronizedEntityResults, replicaTaskResults.results.map((x) => x[1]));
870
+ // compute final result
871
+ result = {
872
+ synchronizedEntityResults
873
+ };
874
+ }
875
+ return result;
876
+ }
877
+ const result = await performSynchronizationOfSources({ });
878
+ return {
879
+ targetPair: syncEntityCommonTypeIdPair,
880
+ entitiesSynchronized: result.synchronizedEntityResults
881
+ };
882
+ };
883
+ const instance = {
884
+ entityPair: syncEntityCommonTypeIdPair,
885
+ synchronize
886
+ };
887
+ return instance;
888
+ };
889
+ const result = {
890
+ commonType,
891
+ synchronizeInstance
892
+ };
893
+ return result;
894
+ }
587
895
 
588
- var objectGetOwnPropertyDescriptor = {};
896
+ // MARK: String
897
+ function transformStringToBoolean(defaultValue) {
898
+ return (params) => stringToBoolean(params.value, defaultValue);
899
+ }
900
+ // MARK: Comma Separated Values
901
+ function transformCommaSeparatedValueToArray(mapFn) {
902
+ return (params) => {
903
+ let result;
904
+ if (params.value) {
905
+ if (Array.isArray(params.value)) {
906
+ result = params.value;
907
+ }
908
+ else {
909
+ result = splitCommaSeparatedString(params.value, mapFn);
910
+ }
911
+ }
912
+ return result;
913
+ };
914
+ }
915
+ const transformCommaSeparatedNumberValueToArray = transformCommaSeparatedValueToArray((x) => Number(x));
916
+ const transformCommaSeparatedStringValueToArray = transformCommaSeparatedValueToArray((x) => x);
589
917
 
590
- var fails$b = function (exec) {
591
- try {
592
- return !!exec();
593
- } catch (error) {
594
- return true;
595
- }
596
- };
918
+ // MARK: Transform Annotations
919
+ function TransformCommaSeparatedValueToArray(mapFn) {
920
+ return Transform(transformCommaSeparatedValueToArray(mapFn));
921
+ }
922
+ const TransformCommaSeparatedStringValueToArray = () => Transform(transformCommaSeparatedStringValueToArray);
923
+ const TransformCommaSeparatedNumberValueToArray = () => Transform(transformCommaSeparatedNumberValueToArray);
924
+ const TransformStringValueToBoolean = () => Transform(transformStringToBoolean());
597
925
 
598
- var fails$a = fails$b;
926
+ function transformAndValidateObject(config) {
927
+ const transformToResult = transformAndValidateObjectResult(config);
928
+ const { handleValidationError } = config;
929
+ return (input, context) => transformToResult(input, context).then(async (x) => {
930
+ const object = x.object;
931
+ let result;
932
+ if (x.success) {
933
+ result = x.result;
934
+ }
935
+ else {
936
+ result = await handleValidationError(x.validationErrors);
937
+ }
938
+ return {
939
+ object,
940
+ result
941
+ };
942
+ });
943
+ }
944
+ /**
945
+ * Creates a new TransformAndValidateObjectFactory.
946
+ *
947
+ * @param defaults
948
+ * @returns
949
+ */
950
+ function transformAndValidateObjectFactory(defaults) {
951
+ const { handleValidationError: defaultHandleValidationError, optionsForContext, defaultValidationOptions } = defaults;
952
+ return (classType, fn, handleValidationError) => {
953
+ const config = {
954
+ classType,
955
+ fn,
956
+ handleValidationError: handleValidationError ?? defaultHandleValidationError,
957
+ optionsForContext,
958
+ defaultValidationOptions
959
+ };
960
+ return transformAndValidateObject(config);
961
+ };
962
+ }
963
+ /**
964
+ * Factory function that wraps the input class type and handler function to first transform the input object to a the given class, and then validate it.
965
+ *
966
+ * @param classType
967
+ * @param fn
968
+ * @returns
969
+ */
970
+ function transformAndValidateObjectResult(config) {
971
+ const { defaultValidationOptions, classType, fn, optionsForContext: inputOptionsForContext } = config;
972
+ const optionsForContext = inputOptionsForContext ?? (() => ({}));
973
+ return async (input, context) => {
974
+ const { transform: transformOptions, validate: validateOptions } = optionsForContext(context);
975
+ const object = plainToInstance(classType, input, {
976
+ ...transformOptions,
977
+ // Note: Each variable on the target class must be marked with the @Expose() annotation.
978
+ excludeExtraneousValues: true
979
+ });
980
+ const validationErrors = await validate(object, {
981
+ forbidUnknownValues: false, // allow classes without annotations by default
982
+ ...defaultValidationOptions,
983
+ ...validateOptions
984
+ });
985
+ if (validationErrors.length) {
986
+ return { object, validationErrors, success: false };
987
+ }
988
+ else {
989
+ const result = await fn(object);
990
+ return { object, result, success: true };
991
+ }
992
+ };
993
+ }
599
994
 
600
- // Detect IE8's incomplete defineProperty implementation
601
- var descriptors = !fails$a(function () {
602
- // eslint-disable-next-line es/no-object-defineproperty -- required for testing
603
- return Object.defineProperty({}, 1, { get: function () { return 7; } })[1] !== 7;
604
- });
995
+ function transformAndValidateFunctionResultFactory(defaults) {
996
+ return toTransformAndValidateFunctionResultFactory(transformAndValidateObjectFactory(defaults));
997
+ }
998
+ function toTransformAndValidateFunctionResultFactory(transformAndValidateObjectFactory) {
999
+ return (classType, fn, handleValidationError) => {
1000
+ const transformAndValidateObjectFn = transformAndValidateObjectFactory(classType, fn, handleValidationError);
1001
+ return (input, context) => {
1002
+ return toTransformAndValidateFunctionResult(transformAndValidateObjectFn(input, context));
1003
+ };
1004
+ };
1005
+ }
1006
+ function toTransformAndValidateFunctionResult(objectOutput) {
1007
+ return mapPromiseOrValue(objectOutput, (x) => {
1008
+ const { object, result } = x;
1009
+ const fnResult = result;
1010
+ fnResult.params = object;
1011
+ return fnResult;
1012
+ });
1013
+ }
605
1014
 
606
- var fails$9 = fails$b;
1015
+ function transformAndValidateResultFactory(defaults) {
1016
+ const factory = transformAndValidateObjectFactory(defaults);
1017
+ return (classType, fn, handleValidationError) => {
1018
+ const transformAndValidateObjectFn = factory(classType, fn, handleValidationError);
1019
+ return async (input, context) => {
1020
+ const { result } = await transformAndValidateObjectFn(input, context);
1021
+ return result;
1022
+ };
1023
+ };
1024
+ }
607
1025
 
608
- var functionBindNative = !fails$9(function () {
609
- // eslint-disable-next-line es/no-function-prototype-bind -- safe
610
- var test = (function () { /* empty */ }).bind();
611
- // eslint-disable-next-line no-prototype-builtins -- safe
612
- return typeof test != 'function' || test.hasOwnProperty('prototype');
613
- });
1026
+ /**
1027
+ * isISO8601DayString validator
1028
+ */
1029
+ function IsISO8601DayString(validationOptions) {
1030
+ return function (object, propertyName) {
1031
+ registerDecorator({
1032
+ name: 'isISO8601DayString',
1033
+ target: object.constructor,
1034
+ propertyName: propertyName,
1035
+ options: validationOptions,
1036
+ validator: {
1037
+ validate: isISO8601DayString,
1038
+ defaultMessage: buildMessage((eachPrefix, args) => eachPrefix + `$property value of "${args?.value}" is not a ISO8601DayString.`, validationOptions)
1039
+ }
1040
+ });
1041
+ };
1042
+ }
614
1043
 
615
- var NATIVE_BIND$1 = functionBindNative;
1044
+ /**
1045
+ * isMinuteOfDay validator
1046
+ */
1047
+ function IsMinuteOfDay(validationOptions) {
1048
+ return function (object, propertyName) {
1049
+ registerDecorator({
1050
+ name: 'isMinuteOfDay',
1051
+ target: object.constructor,
1052
+ propertyName: propertyName,
1053
+ options: validationOptions,
1054
+ validator: {
1055
+ validate: isMinuteOfDay,
1056
+ defaultMessage: buildMessage((eachPrefix, args) => eachPrefix + `$property value of "${args?.value}" is not a valid minute of the day.`, validationOptions)
1057
+ }
1058
+ });
1059
+ };
1060
+ }
616
1061
 
617
- var call$7 = Function.prototype.call;
1062
+ /**
1063
+ * isE164PhoneNumber validator that does not allowed extensions.
1064
+ */
1065
+ function IsE164PhoneNumber(validationOptions) {
1066
+ return function (object, propertyName) {
1067
+ registerDecorator({
1068
+ name: 'isE164PhoneNumber',
1069
+ target: object.constructor,
1070
+ propertyName: propertyName,
1071
+ options: validationOptions,
1072
+ validator: {
1073
+ validate: (x) => isE164PhoneNumber(x, false),
1074
+ defaultMessage: buildMessage((eachPrefix, args) => eachPrefix + `$property value of "${args?.value}" is not a E164PhoneNumber with no extension.`, validationOptions)
1075
+ }
1076
+ });
1077
+ };
1078
+ }
1079
+ /**
1080
+ * isE164PhoneNumber validator that allows extensions.
1081
+ *
1082
+ * @param validationOptions
1083
+ * @returns
1084
+ */
1085
+ function IsE164PhoneNumberWithOptionalExtension(validationOptions) {
1086
+ return function (object, propertyName) {
1087
+ registerDecorator({
1088
+ name: 'isE164PhoneNumber',
1089
+ target: object.constructor,
1090
+ propertyName: propertyName,
1091
+ options: validationOptions,
1092
+ validator: {
1093
+ validate: (x) => isE164PhoneNumber(x, true),
1094
+ defaultMessage: buildMessage((eachPrefix, args) => eachPrefix + `$property value of "${args?.value}" is not an E164PhoneNumber or has an invalid extension.`, validationOptions)
1095
+ }
1096
+ });
1097
+ };
1098
+ }
1099
+ /**
1100
+ * isE164PhoneNumberWithExtension validator
1101
+ *
1102
+ * @param validationOptions
1103
+ * @returns
1104
+ */
1105
+ function IsE164PhoneNumberWithExtension(validationOptions) {
1106
+ return function (object, propertyName) {
1107
+ registerDecorator({
1108
+ name: 'isE164PhoneNumberWithExtension',
1109
+ target: object.constructor,
1110
+ propertyName: propertyName,
1111
+ options: validationOptions,
1112
+ validator: {
1113
+ validate: isE164PhoneNumberWithExtension,
1114
+ defaultMessage: buildMessage((eachPrefix, args) => eachPrefix + `$property value of "${args?.value}" is not a E164PhoneNumberWithExtension.`, validationOptions)
1115
+ }
1116
+ });
1117
+ };
1118
+ }
618
1119
 
619
- var functionCall = NATIVE_BIND$1 ? call$7.bind(call$7) : function () {
620
- return call$7.apply(call$7, arguments);
621
- };
1120
+ /**
1121
+ * isUniqueKeyedFunction validator
1122
+ */
1123
+ function IsUniqueKeyed(readKey, validationOptions) {
1124
+ const isUniqueKeyed = isUniqueKeyedFunction(readKey);
1125
+ return function (object, propertyName) {
1126
+ registerDecorator({
1127
+ name: 'isUniqueKeyed',
1128
+ target: object.constructor,
1129
+ propertyName: propertyName,
1130
+ options: validationOptions,
1131
+ validator: {
1132
+ validate: isUniqueKeyed,
1133
+ defaultMessage: buildMessage((eachPrefix, args) => eachPrefix + `$property value has one or more values with the same key. Keys must be unique.`, validationOptions)
1134
+ }
1135
+ });
1136
+ };
1137
+ }
622
1138
 
623
- var objectPropertyIsEnumerable = {};
624
-
625
- var $propertyIsEnumerable = {}.propertyIsEnumerable;
626
- // eslint-disable-next-line es/no-object-getownpropertydescriptor -- safe
627
- var getOwnPropertyDescriptor$1 = Object.getOwnPropertyDescriptor;
628
-
629
- // Nashorn ~ JDK8 bug
630
- var NASHORN_BUG = getOwnPropertyDescriptor$1 && !$propertyIsEnumerable.call({ 1: 2 }, 1);
631
-
632
- // `Object.prototype.propertyIsEnumerable` method implementation
633
- // https://tc39.es/ecma262/#sec-object.prototype.propertyisenumerable
634
- objectPropertyIsEnumerable.f = NASHORN_BUG ? function propertyIsEnumerable(V) {
635
- var descriptor = getOwnPropertyDescriptor$1(this, V);
636
- return !!descriptor && descriptor.enumerable;
637
- } : $propertyIsEnumerable;
638
-
639
- var createPropertyDescriptor$3 = function (bitmap, value) {
640
- return {
641
- enumerable: !(bitmap & 1),
642
- configurable: !(bitmap & 2),
643
- writable: !(bitmap & 4),
644
- value: value
645
- };
646
- };
647
-
648
- var NATIVE_BIND = functionBindNative;
649
-
650
- var FunctionPrototype$1 = Function.prototype;
651
- var call$6 = FunctionPrototype$1.call;
652
- var uncurryThisWithBind = NATIVE_BIND && FunctionPrototype$1.bind.bind(call$6, call$6);
653
-
654
- var functionUncurryThis = NATIVE_BIND ? uncurryThisWithBind : function (fn) {
655
- return function () {
656
- return call$6.apply(fn, arguments);
657
- };
658
- };
659
-
660
- var uncurryThis$8 = functionUncurryThis;
661
-
662
- var toString$1 = uncurryThis$8({}.toString);
663
- var stringSlice$1 = uncurryThis$8(''.slice);
664
-
665
- var classofRaw = function (it) {
666
- return stringSlice$1(toString$1(it), 8, -1);
667
- };
668
-
669
- var uncurryThis$7 = functionUncurryThis;
670
- var fails$8 = fails$b;
671
- var classof = classofRaw;
672
-
673
- var $Object$3 = Object;
674
- var split = uncurryThis$7(''.split);
675
-
676
- // fallback for non-array-like ES3 and non-enumerable old V8 strings
677
- var indexedObject = fails$8(function () {
678
- // throws an error in rhino, see https://github.com/mozilla/rhino/issues/346
679
- // eslint-disable-next-line no-prototype-builtins -- safe
680
- return !$Object$3('z').propertyIsEnumerable(0);
681
- }) ? function (it) {
682
- return classof(it) === 'String' ? split(it, '') : $Object$3(it);
683
- } : $Object$3;
684
-
685
- // we can't use just `it == null` since of `document.all` special case
686
- // https://tc39.es/ecma262/#sec-IsHTMLDDA-internal-slot-aec
687
- var isNullOrUndefined$2 = function (it) {
688
- return it === null || it === undefined;
689
- };
690
-
691
- var isNullOrUndefined$1 = isNullOrUndefined$2;
692
-
693
- var $TypeError$7 = TypeError;
694
-
695
- // `RequireObjectCoercible` abstract operation
696
- // https://tc39.es/ecma262/#sec-requireobjectcoercible
697
- var requireObjectCoercible$2 = function (it) {
698
- if (isNullOrUndefined$1(it)) throw new $TypeError$7("Can't call method on " + it);
699
- return it;
700
- };
701
-
702
- // toObject with fallback for non-array-like ES3 strings
703
- var IndexedObject = indexedObject;
704
- var requireObjectCoercible$1 = requireObjectCoercible$2;
705
-
706
- var toIndexedObject$4 = function (it) {
707
- return IndexedObject(requireObjectCoercible$1(it));
708
- };
709
-
710
- // https://tc39.es/ecma262/#sec-IsHTMLDDA-internal-slot
711
- var documentAll = typeof document == 'object' && document.all;
712
-
713
- // `IsCallable` abstract operation
714
- // https://tc39.es/ecma262/#sec-iscallable
715
- // eslint-disable-next-line unicorn/no-typeof-undefined -- required for testing
716
- var isCallable$d = typeof documentAll == 'undefined' && documentAll !== undefined ? function (argument) {
717
- return typeof argument == 'function' || argument === documentAll;
718
- } : function (argument) {
719
- return typeof argument == 'function';
720
- };
721
-
722
- var isCallable$c = isCallable$d;
723
-
724
- var isObject$6 = function (it) {
725
- return typeof it == 'object' ? it !== null : isCallable$c(it);
726
- };
727
-
728
- var global$a = global$b;
729
- var isCallable$b = isCallable$d;
730
-
731
- var aFunction = function (argument) {
732
- return isCallable$b(argument) ? argument : undefined;
733
- };
734
-
735
- var getBuiltIn$3 = function (namespace, method) {
736
- return arguments.length < 2 ? aFunction(global$a[namespace]) : global$a[namespace] && global$a[namespace][method];
737
- };
738
-
739
- var uncurryThis$6 = functionUncurryThis;
740
-
741
- var objectIsPrototypeOf = uncurryThis$6({}.isPrototypeOf);
742
-
743
- var engineUserAgent = typeof navigator != 'undefined' && String(navigator.userAgent) || '';
744
-
745
- var global$9 = global$b;
746
- var userAgent = engineUserAgent;
747
-
748
- var process = global$9.process;
749
- var Deno = global$9.Deno;
750
- var versions = process && process.versions || Deno && Deno.version;
751
- var v8 = versions && versions.v8;
752
- var match, version;
753
-
754
- if (v8) {
755
- match = v8.split('.');
756
- // in old Chrome, versions of V8 isn't V8 = Chrome / 10
757
- // but their correct versions are not interesting for us
758
- version = match[0] > 0 && match[0] < 4 ? 1 : +(match[0] + match[1]);
759
- }
760
-
761
- // BrowserFS NodeJS `process` polyfill incorrectly set `.v8` to `0.0`
762
- // so check `userAgent` even if `.v8` exists, but 0
763
- if (!version && userAgent) {
764
- match = userAgent.match(/Edge\/(\d+)/);
765
- if (!match || match[1] >= 74) {
766
- match = userAgent.match(/Chrome\/(\d+)/);
767
- if (match) version = +match[1];
768
- }
769
- }
770
-
771
- var engineV8Version = version;
772
-
773
- /* eslint-disable es/no-symbol -- required for testing */
774
- var V8_VERSION = engineV8Version;
775
- var fails$7 = fails$b;
776
- var global$8 = global$b;
777
-
778
- var $String$3 = global$8.String;
779
-
780
- // eslint-disable-next-line es/no-object-getownpropertysymbols -- required for testing
781
- var symbolConstructorDetection = !!Object.getOwnPropertySymbols && !fails$7(function () {
782
- var symbol = Symbol('symbol detection');
783
- // Chrome 38 Symbol has incorrect toString conversion
784
- // `get-own-property-symbols` polyfill symbols converted to object are not Symbol instances
785
- // nb: Do not call `String` directly to avoid this being optimized out to `symbol+''` which will,
786
- // of course, fail.
787
- return !$String$3(symbol) || !(Object(symbol) instanceof Symbol) ||
788
- // Chrome 38-40 symbols are not inherited from DOM collections prototypes to instances
789
- !Symbol.sham && V8_VERSION && V8_VERSION < 41;
790
- });
791
-
792
- /* eslint-disable es/no-symbol -- required for testing */
793
- var NATIVE_SYMBOL$1 = symbolConstructorDetection;
794
-
795
- var useSymbolAsUid = NATIVE_SYMBOL$1
796
- && !Symbol.sham
797
- && typeof Symbol.iterator == 'symbol';
798
-
799
- var getBuiltIn$2 = getBuiltIn$3;
800
- var isCallable$a = isCallable$d;
801
- var isPrototypeOf$1 = objectIsPrototypeOf;
802
- var USE_SYMBOL_AS_UID$1 = useSymbolAsUid;
803
-
804
- var $Object$2 = Object;
805
-
806
- var isSymbol$2 = USE_SYMBOL_AS_UID$1 ? function (it) {
807
- return typeof it == 'symbol';
808
- } : function (it) {
809
- var $Symbol = getBuiltIn$2('Symbol');
810
- return isCallable$a($Symbol) && isPrototypeOf$1($Symbol.prototype, $Object$2(it));
811
- };
812
-
813
- var $String$2 = String;
814
-
815
- var tryToString$1 = function (argument) {
816
- try {
817
- return $String$2(argument);
818
- } catch (error) {
819
- return 'Object';
820
- }
821
- };
822
-
823
- var isCallable$9 = isCallable$d;
824
- var tryToString = tryToString$1;
825
-
826
- var $TypeError$6 = TypeError;
827
-
828
- // `Assert: IsCallable(argument) is true`
829
- var aCallable$2 = function (argument) {
830
- if (isCallable$9(argument)) return argument;
831
- throw new $TypeError$6(tryToString(argument) + ' is not a function');
832
- };
833
-
834
- var aCallable$1 = aCallable$2;
835
- var isNullOrUndefined = isNullOrUndefined$2;
836
-
837
- // `GetMethod` abstract operation
838
- // https://tc39.es/ecma262/#sec-getmethod
839
- var getMethod$3 = function (V, P) {
840
- var func = V[P];
841
- return isNullOrUndefined(func) ? undefined : aCallable$1(func);
842
- };
843
-
844
- var call$5 = functionCall;
845
- var isCallable$8 = isCallable$d;
846
- var isObject$5 = isObject$6;
847
-
848
- var $TypeError$5 = TypeError;
849
-
850
- // `OrdinaryToPrimitive` abstract operation
851
- // https://tc39.es/ecma262/#sec-ordinarytoprimitive
852
- var ordinaryToPrimitive$1 = function (input, pref) {
853
- var fn, val;
854
- if (pref === 'string' && isCallable$8(fn = input.toString) && !isObject$5(val = call$5(fn, input))) return val;
855
- if (isCallable$8(fn = input.valueOf) && !isObject$5(val = call$5(fn, input))) return val;
856
- if (pref !== 'string' && isCallable$8(fn = input.toString) && !isObject$5(val = call$5(fn, input))) return val;
857
- throw new $TypeError$5("Can't convert object to primitive value");
858
- };
859
-
860
- var sharedStore = {exports: {}};
861
-
862
- var isPure = false;
863
-
864
- var global$7 = global$b;
865
-
866
- // eslint-disable-next-line es/no-object-defineproperty -- safe
867
- var defineProperty$2 = Object.defineProperty;
868
-
869
- var defineGlobalProperty$3 = function (key, value) {
870
- try {
871
- defineProperty$2(global$7, key, { value: value, configurable: true, writable: true });
872
- } catch (error) {
873
- global$7[key] = value;
874
- } return value;
875
- };
876
-
877
- var globalThis$1 = global$b;
878
- var defineGlobalProperty$2 = defineGlobalProperty$3;
879
-
880
- var SHARED = '__core-js_shared__';
881
- var store$3 = sharedStore.exports = globalThis$1[SHARED] || defineGlobalProperty$2(SHARED, {});
882
-
883
- (store$3.versions || (store$3.versions = [])).push({
884
- version: '3.36.1',
885
- mode: 'global',
886
- copyright: '© 2014-2024 Denis Pushkarev (zloirock.ru)',
887
- license: 'https://github.com/zloirock/core-js/blob/v3.36.1/LICENSE',
888
- source: 'https://github.com/zloirock/core-js'
889
- });
890
-
891
- var sharedStoreExports = sharedStore.exports;
892
-
893
- var store$2 = sharedStoreExports;
894
-
895
- var shared$3 = function (key, value) {
896
- return store$2[key] || (store$2[key] = value || {});
897
- };
898
-
899
- var requireObjectCoercible = requireObjectCoercible$2;
900
-
901
- var $Object$1 = Object;
902
-
903
- // `ToObject` abstract operation
904
- // https://tc39.es/ecma262/#sec-toobject
905
- var toObject$2 = function (argument) {
906
- return $Object$1(requireObjectCoercible(argument));
907
- };
908
-
909
- var uncurryThis$5 = functionUncurryThis;
910
- var toObject$1 = toObject$2;
911
-
912
- var hasOwnProperty = uncurryThis$5({}.hasOwnProperty);
913
-
914
- // `HasOwnProperty` abstract operation
915
- // https://tc39.es/ecma262/#sec-hasownproperty
916
- // eslint-disable-next-line es/no-object-hasown -- safe
917
- var hasOwnProperty_1 = Object.hasOwn || function hasOwn(it, key) {
918
- return hasOwnProperty(toObject$1(it), key);
919
- };
920
-
921
- var uncurryThis$4 = functionUncurryThis;
922
-
923
- var id = 0;
924
- var postfix = Math.random();
925
- var toString = uncurryThis$4(1.0.toString);
926
-
927
- var uid$2 = function (key) {
928
- return 'Symbol(' + (key === undefined ? '' : key) + ')_' + toString(++id + postfix, 36);
929
- };
930
-
931
- var global$6 = global$b;
932
- var shared$2 = shared$3;
933
- var hasOwn$8 = hasOwnProperty_1;
934
- var uid$1 = uid$2;
935
- var NATIVE_SYMBOL = symbolConstructorDetection;
936
- var USE_SYMBOL_AS_UID = useSymbolAsUid;
937
-
938
- var Symbol$1 = global$6.Symbol;
939
- var WellKnownSymbolsStore = shared$2('wks');
940
- var createWellKnownSymbol = USE_SYMBOL_AS_UID ? Symbol$1['for'] || Symbol$1 : Symbol$1 && Symbol$1.withoutSetter || uid$1;
941
-
942
- var wellKnownSymbol$4 = function (name) {
943
- if (!hasOwn$8(WellKnownSymbolsStore, name)) {
944
- WellKnownSymbolsStore[name] = NATIVE_SYMBOL && hasOwn$8(Symbol$1, name)
945
- ? Symbol$1[name]
946
- : createWellKnownSymbol('Symbol.' + name);
947
- } return WellKnownSymbolsStore[name];
948
- };
949
-
950
- var call$4 = functionCall;
951
- var isObject$4 = isObject$6;
952
- var isSymbol$1 = isSymbol$2;
953
- var getMethod$2 = getMethod$3;
954
- var ordinaryToPrimitive = ordinaryToPrimitive$1;
955
- var wellKnownSymbol$3 = wellKnownSymbol$4;
956
-
957
- var $TypeError$4 = TypeError;
958
- var TO_PRIMITIVE = wellKnownSymbol$3('toPrimitive');
959
-
960
- // `ToPrimitive` abstract operation
961
- // https://tc39.es/ecma262/#sec-toprimitive
962
- var toPrimitive$1 = function (input, pref) {
963
- if (!isObject$4(input) || isSymbol$1(input)) return input;
964
- var exoticToPrim = getMethod$2(input, TO_PRIMITIVE);
965
- var result;
966
- if (exoticToPrim) {
967
- if (pref === undefined) pref = 'default';
968
- result = call$4(exoticToPrim, input, pref);
969
- if (!isObject$4(result) || isSymbol$1(result)) return result;
970
- throw new $TypeError$4("Can't convert object to primitive value");
971
- }
972
- if (pref === undefined) pref = 'number';
973
- return ordinaryToPrimitive(input, pref);
974
- };
975
-
976
- var toPrimitive = toPrimitive$1;
977
- var isSymbol = isSymbol$2;
978
-
979
- // `ToPropertyKey` abstract operation
980
- // https://tc39.es/ecma262/#sec-topropertykey
981
- var toPropertyKey$2 = function (argument) {
982
- var key = toPrimitive(argument, 'string');
983
- return isSymbol(key) ? key : key + '';
984
- };
985
-
986
- var global$5 = global$b;
987
- var isObject$3 = isObject$6;
988
-
989
- var document$1 = global$5.document;
990
- // typeof document.createElement is 'object' in old IE
991
- var EXISTS$1 = isObject$3(document$1) && isObject$3(document$1.createElement);
992
-
993
- var documentCreateElement$1 = function (it) {
994
- return EXISTS$1 ? document$1.createElement(it) : {};
995
- };
996
-
997
- var DESCRIPTORS$9 = descriptors;
998
- var fails$6 = fails$b;
999
- var createElement = documentCreateElement$1;
1000
-
1001
- // Thanks to IE8 for its funny defineProperty
1002
- var ie8DomDefine = !DESCRIPTORS$9 && !fails$6(function () {
1003
- // eslint-disable-next-line es/no-object-defineproperty -- required for testing
1004
- return Object.defineProperty(createElement('div'), 'a', {
1005
- get: function () { return 7; }
1006
- }).a !== 7;
1007
- });
1008
-
1009
- var DESCRIPTORS$8 = descriptors;
1010
- var call$3 = functionCall;
1011
- var propertyIsEnumerableModule = objectPropertyIsEnumerable;
1012
- var createPropertyDescriptor$2 = createPropertyDescriptor$3;
1013
- var toIndexedObject$3 = toIndexedObject$4;
1014
- var toPropertyKey$1 = toPropertyKey$2;
1015
- var hasOwn$7 = hasOwnProperty_1;
1016
- var IE8_DOM_DEFINE$1 = ie8DomDefine;
1017
-
1018
- // eslint-disable-next-line es/no-object-getownpropertydescriptor -- safe
1019
- var $getOwnPropertyDescriptor$1 = Object.getOwnPropertyDescriptor;
1020
-
1021
- // `Object.getOwnPropertyDescriptor` method
1022
- // https://tc39.es/ecma262/#sec-object.getownpropertydescriptor
1023
- objectGetOwnPropertyDescriptor.f = DESCRIPTORS$8 ? $getOwnPropertyDescriptor$1 : function getOwnPropertyDescriptor(O, P) {
1024
- O = toIndexedObject$3(O);
1025
- P = toPropertyKey$1(P);
1026
- if (IE8_DOM_DEFINE$1) try {
1027
- return $getOwnPropertyDescriptor$1(O, P);
1028
- } catch (error) { /* empty */ }
1029
- if (hasOwn$7(O, P)) return createPropertyDescriptor$2(!call$3(propertyIsEnumerableModule.f, O, P), O[P]);
1030
- };
1031
-
1032
- var objectDefineProperty = {};
1033
-
1034
- var DESCRIPTORS$7 = descriptors;
1035
- var fails$5 = fails$b;
1036
-
1037
- // V8 ~ Chrome 36-
1038
- // https://bugs.chromium.org/p/v8/issues/detail?id=3334
1039
- var v8PrototypeDefineBug = DESCRIPTORS$7 && fails$5(function () {
1040
- // eslint-disable-next-line es/no-object-defineproperty -- required for testing
1041
- return Object.defineProperty(function () { /* empty */ }, 'prototype', {
1042
- value: 42,
1043
- writable: false
1044
- }).prototype !== 42;
1045
- });
1046
-
1047
- var isObject$2 = isObject$6;
1048
-
1049
- var $String$1 = String;
1050
- var $TypeError$3 = TypeError;
1051
-
1052
- // `Assert: Type(argument) is Object`
1053
- var anObject$8 = function (argument) {
1054
- if (isObject$2(argument)) return argument;
1055
- throw new $TypeError$3($String$1(argument) + ' is not an object');
1056
- };
1057
-
1058
- var DESCRIPTORS$6 = descriptors;
1059
- var IE8_DOM_DEFINE = ie8DomDefine;
1060
- var V8_PROTOTYPE_DEFINE_BUG$1 = v8PrototypeDefineBug;
1061
- var anObject$7 = anObject$8;
1062
- var toPropertyKey = toPropertyKey$2;
1063
-
1064
- var $TypeError$2 = TypeError;
1065
- // eslint-disable-next-line es/no-object-defineproperty -- safe
1066
- var $defineProperty = Object.defineProperty;
1067
- // eslint-disable-next-line es/no-object-getownpropertydescriptor -- safe
1068
- var $getOwnPropertyDescriptor = Object.getOwnPropertyDescriptor;
1069
- var ENUMERABLE = 'enumerable';
1070
- var CONFIGURABLE$1 = 'configurable';
1071
- var WRITABLE = 'writable';
1072
-
1073
- // `Object.defineProperty` method
1074
- // https://tc39.es/ecma262/#sec-object.defineproperty
1075
- objectDefineProperty.f = DESCRIPTORS$6 ? V8_PROTOTYPE_DEFINE_BUG$1 ? function defineProperty(O, P, Attributes) {
1076
- anObject$7(O);
1077
- P = toPropertyKey(P);
1078
- anObject$7(Attributes);
1079
- if (typeof O === 'function' && P === 'prototype' && 'value' in Attributes && WRITABLE in Attributes && !Attributes[WRITABLE]) {
1080
- var current = $getOwnPropertyDescriptor(O, P);
1081
- if (current && current[WRITABLE]) {
1082
- O[P] = Attributes.value;
1083
- Attributes = {
1084
- configurable: CONFIGURABLE$1 in Attributes ? Attributes[CONFIGURABLE$1] : current[CONFIGURABLE$1],
1085
- enumerable: ENUMERABLE in Attributes ? Attributes[ENUMERABLE] : current[ENUMERABLE],
1086
- writable: false
1087
- };
1088
- }
1089
- } return $defineProperty(O, P, Attributes);
1090
- } : $defineProperty : function defineProperty(O, P, Attributes) {
1091
- anObject$7(O);
1092
- P = toPropertyKey(P);
1093
- anObject$7(Attributes);
1094
- if (IE8_DOM_DEFINE) try {
1095
- return $defineProperty(O, P, Attributes);
1096
- } catch (error) { /* empty */ }
1097
- if ('get' in Attributes || 'set' in Attributes) throw new $TypeError$2('Accessors not supported');
1098
- if ('value' in Attributes) O[P] = Attributes.value;
1099
- return O;
1100
- };
1101
-
1102
- var DESCRIPTORS$5 = descriptors;
1103
- var definePropertyModule$4 = objectDefineProperty;
1104
- var createPropertyDescriptor$1 = createPropertyDescriptor$3;
1105
-
1106
- var createNonEnumerableProperty$3 = DESCRIPTORS$5 ? function (object, key, value) {
1107
- return definePropertyModule$4.f(object, key, createPropertyDescriptor$1(1, value));
1108
- } : function (object, key, value) {
1109
- object[key] = value;
1110
- return object;
1111
- };
1112
-
1113
- var makeBuiltIn$3 = {exports: {}};
1114
-
1115
- var DESCRIPTORS$4 = descriptors;
1116
- var hasOwn$6 = hasOwnProperty_1;
1117
-
1118
- var FunctionPrototype = Function.prototype;
1119
- // eslint-disable-next-line es/no-object-getownpropertydescriptor -- safe
1120
- var getDescriptor = DESCRIPTORS$4 && Object.getOwnPropertyDescriptor;
1121
-
1122
- var EXISTS = hasOwn$6(FunctionPrototype, 'name');
1123
- // additional protection from minified / mangled / dropped function names
1124
- var PROPER = EXISTS && (function something() { /* empty */ }).name === 'something';
1125
- var CONFIGURABLE = EXISTS && (!DESCRIPTORS$4 || (DESCRIPTORS$4 && getDescriptor(FunctionPrototype, 'name').configurable));
1126
-
1127
- var functionName = {
1128
- EXISTS: EXISTS,
1129
- PROPER: PROPER,
1130
- CONFIGURABLE: CONFIGURABLE
1131
- };
1132
-
1133
- var uncurryThis$3 = functionUncurryThis;
1134
- var isCallable$7 = isCallable$d;
1135
- var store$1 = sharedStoreExports;
1136
-
1137
- var functionToString = uncurryThis$3(Function.toString);
1138
-
1139
- // this helper broken in `core-js@3.4.1-3.4.4`, so we can't use `shared` helper
1140
- if (!isCallable$7(store$1.inspectSource)) {
1141
- store$1.inspectSource = function (it) {
1142
- return functionToString(it);
1143
- };
1144
- }
1145
-
1146
- var inspectSource$1 = store$1.inspectSource;
1147
-
1148
- var global$4 = global$b;
1149
- var isCallable$6 = isCallable$d;
1150
-
1151
- var WeakMap$1 = global$4.WeakMap;
1152
-
1153
- var weakMapBasicDetection = isCallable$6(WeakMap$1) && /native code/.test(String(WeakMap$1));
1154
-
1155
- var shared$1 = shared$3;
1156
- var uid = uid$2;
1157
-
1158
- var keys = shared$1('keys');
1159
-
1160
- var sharedKey$3 = function (key) {
1161
- return keys[key] || (keys[key] = uid(key));
1162
- };
1163
-
1164
- var hiddenKeys$4 = {};
1165
-
1166
- var NATIVE_WEAK_MAP = weakMapBasicDetection;
1167
- var global$3 = global$b;
1168
- var isObject$1 = isObject$6;
1169
- var createNonEnumerableProperty$2 = createNonEnumerableProperty$3;
1170
- var hasOwn$5 = hasOwnProperty_1;
1171
- var shared = sharedStoreExports;
1172
- var sharedKey$2 = sharedKey$3;
1173
- var hiddenKeys$3 = hiddenKeys$4;
1174
-
1175
- var OBJECT_ALREADY_INITIALIZED = 'Object already initialized';
1176
- var TypeError$1 = global$3.TypeError;
1177
- var WeakMap = global$3.WeakMap;
1178
- var set, get, has;
1179
-
1180
- var enforce = function (it) {
1181
- return has(it) ? get(it) : set(it, {});
1182
- };
1183
-
1184
- var getterFor = function (TYPE) {
1185
- return function (it) {
1186
- var state;
1187
- if (!isObject$1(it) || (state = get(it)).type !== TYPE) {
1188
- throw new TypeError$1('Incompatible receiver, ' + TYPE + ' required');
1189
- } return state;
1190
- };
1191
- };
1192
-
1193
- if (NATIVE_WEAK_MAP || shared.state) {
1194
- var store = shared.state || (shared.state = new WeakMap());
1195
- /* eslint-disable no-self-assign -- prototype methods protection */
1196
- store.get = store.get;
1197
- store.has = store.has;
1198
- store.set = store.set;
1199
- /* eslint-enable no-self-assign -- prototype methods protection */
1200
- set = function (it, metadata) {
1201
- if (store.has(it)) throw new TypeError$1(OBJECT_ALREADY_INITIALIZED);
1202
- metadata.facade = it;
1203
- store.set(it, metadata);
1204
- return metadata;
1205
- };
1206
- get = function (it) {
1207
- return store.get(it) || {};
1208
- };
1209
- has = function (it) {
1210
- return store.has(it);
1211
- };
1212
- } else {
1213
- var STATE = sharedKey$2('state');
1214
- hiddenKeys$3[STATE] = true;
1215
- set = function (it, metadata) {
1216
- if (hasOwn$5(it, STATE)) throw new TypeError$1(OBJECT_ALREADY_INITIALIZED);
1217
- metadata.facade = it;
1218
- createNonEnumerableProperty$2(it, STATE, metadata);
1219
- return metadata;
1220
- };
1221
- get = function (it) {
1222
- return hasOwn$5(it, STATE) ? it[STATE] : {};
1223
- };
1224
- has = function (it) {
1225
- return hasOwn$5(it, STATE);
1226
- };
1227
- }
1228
-
1229
- var internalState = {
1230
- set: set,
1231
- get: get,
1232
- has: has,
1233
- enforce: enforce,
1234
- getterFor: getterFor
1235
- };
1236
-
1237
- var uncurryThis$2 = functionUncurryThis;
1238
- var fails$4 = fails$b;
1239
- var isCallable$5 = isCallable$d;
1240
- var hasOwn$4 = hasOwnProperty_1;
1241
- var DESCRIPTORS$3 = descriptors;
1242
- var CONFIGURABLE_FUNCTION_NAME = functionName.CONFIGURABLE;
1243
- var inspectSource = inspectSource$1;
1244
- var InternalStateModule$1 = internalState;
1245
-
1246
- var enforceInternalState = InternalStateModule$1.enforce;
1247
- var getInternalState = InternalStateModule$1.get;
1248
- var $String = String;
1249
- // eslint-disable-next-line es/no-object-defineproperty -- safe
1250
- var defineProperty$1 = Object.defineProperty;
1251
- var stringSlice = uncurryThis$2(''.slice);
1252
- var replace = uncurryThis$2(''.replace);
1253
- var join = uncurryThis$2([].join);
1254
-
1255
- var CONFIGURABLE_LENGTH = DESCRIPTORS$3 && !fails$4(function () {
1256
- return defineProperty$1(function () { /* empty */ }, 'length', { value: 8 }).length !== 8;
1257
- });
1258
-
1259
- var TEMPLATE = String(String).split('String');
1260
-
1261
- var makeBuiltIn$2 = makeBuiltIn$3.exports = function (value, name, options) {
1262
- if (stringSlice($String(name), 0, 7) === 'Symbol(') {
1263
- name = '[' + replace($String(name), /^Symbol\(([^)]*)\).*$/, '$1') + ']';
1264
- }
1265
- if (options && options.getter) name = 'get ' + name;
1266
- if (options && options.setter) name = 'set ' + name;
1267
- if (!hasOwn$4(value, 'name') || (CONFIGURABLE_FUNCTION_NAME && value.name !== name)) {
1268
- if (DESCRIPTORS$3) defineProperty$1(value, 'name', { value: name, configurable: true });
1269
- else value.name = name;
1270
- }
1271
- if (CONFIGURABLE_LENGTH && options && hasOwn$4(options, 'arity') && value.length !== options.arity) {
1272
- defineProperty$1(value, 'length', { value: options.arity });
1273
- }
1274
- try {
1275
- if (options && hasOwn$4(options, 'constructor') && options.constructor) {
1276
- if (DESCRIPTORS$3) defineProperty$1(value, 'prototype', { writable: false });
1277
- // in V8 ~ Chrome 53, prototypes of some methods, like `Array.prototype.values`, are non-writable
1278
- } else if (value.prototype) value.prototype = undefined;
1279
- } catch (error) { /* empty */ }
1280
- var state = enforceInternalState(value);
1281
- if (!hasOwn$4(state, 'source')) {
1282
- state.source = join(TEMPLATE, typeof name == 'string' ? name : '');
1283
- } return value;
1284
- };
1285
-
1286
- // add fake Function#toString for correct work wrapped methods / constructors with methods like LoDash isNative
1287
- // eslint-disable-next-line no-extend-native -- required
1288
- Function.prototype.toString = makeBuiltIn$2(function toString() {
1289
- return isCallable$5(this) && getInternalState(this).source || inspectSource(this);
1290
- }, 'toString');
1291
-
1292
- var makeBuiltInExports = makeBuiltIn$3.exports;
1293
-
1294
- var isCallable$4 = isCallable$d;
1295
- var definePropertyModule$3 = objectDefineProperty;
1296
- var makeBuiltIn$1 = makeBuiltInExports;
1297
- var defineGlobalProperty$1 = defineGlobalProperty$3;
1298
-
1299
- var defineBuiltIn$3 = function (O, key, value, options) {
1300
- if (!options) options = {};
1301
- var simple = options.enumerable;
1302
- var name = options.name !== undefined ? options.name : key;
1303
- if (isCallable$4(value)) makeBuiltIn$1(value, name, options);
1304
- if (options.global) {
1305
- if (simple) O[key] = value;
1306
- else defineGlobalProperty$1(key, value);
1307
- } else {
1308
- try {
1309
- if (!options.unsafe) delete O[key];
1310
- else if (O[key]) simple = true;
1311
- } catch (error) { /* empty */ }
1312
- if (simple) O[key] = value;
1313
- else definePropertyModule$3.f(O, key, {
1314
- value: value,
1315
- enumerable: false,
1316
- configurable: !options.nonConfigurable,
1317
- writable: !options.nonWritable
1318
- });
1319
- } return O;
1320
- };
1321
-
1322
- var objectGetOwnPropertyNames = {};
1323
-
1324
- var ceil = Math.ceil;
1325
- var floor = Math.floor;
1326
-
1327
- // `Math.trunc` method
1328
- // https://tc39.es/ecma262/#sec-math.trunc
1329
- // eslint-disable-next-line es/no-math-trunc -- safe
1330
- var mathTrunc = Math.trunc || function trunc(x) {
1331
- var n = +x;
1332
- return (n > 0 ? floor : ceil)(n);
1333
- };
1334
-
1335
- var trunc = mathTrunc;
1336
-
1337
- // `ToIntegerOrInfinity` abstract operation
1338
- // https://tc39.es/ecma262/#sec-tointegerorinfinity
1339
- var toIntegerOrInfinity$2 = function (argument) {
1340
- var number = +argument;
1341
- // eslint-disable-next-line no-self-compare -- NaN check
1342
- return number !== number || number === 0 ? 0 : trunc(number);
1343
- };
1344
-
1345
- var toIntegerOrInfinity$1 = toIntegerOrInfinity$2;
1346
-
1347
- var max = Math.max;
1348
- var min$1 = Math.min;
1349
-
1350
- // Helper for a popular repeating case of the spec:
1351
- // Let integer be ? ToInteger(index).
1352
- // If integer < 0, let result be max((length + integer), 0); else let result be min(integer, length).
1353
- var toAbsoluteIndex$1 = function (index, length) {
1354
- var integer = toIntegerOrInfinity$1(index);
1355
- return integer < 0 ? max(integer + length, 0) : min$1(integer, length);
1356
- };
1357
-
1358
- var toIntegerOrInfinity = toIntegerOrInfinity$2;
1359
-
1360
- var min = Math.min;
1361
-
1362
- // `ToLength` abstract operation
1363
- // https://tc39.es/ecma262/#sec-tolength
1364
- var toLength$1 = function (argument) {
1365
- var len = toIntegerOrInfinity(argument);
1366
- return len > 0 ? min(len, 0x1FFFFFFFFFFFFF) : 0; // 2 ** 53 - 1 == 9007199254740991
1367
- };
1368
-
1369
- var toLength = toLength$1;
1370
-
1371
- // `LengthOfArrayLike` abstract operation
1372
- // https://tc39.es/ecma262/#sec-lengthofarraylike
1373
- var lengthOfArrayLike$1 = function (obj) {
1374
- return toLength(obj.length);
1375
- };
1376
-
1377
- var toIndexedObject$2 = toIndexedObject$4;
1378
- var toAbsoluteIndex = toAbsoluteIndex$1;
1379
- var lengthOfArrayLike = lengthOfArrayLike$1;
1380
-
1381
- // `Array.prototype.{ indexOf, includes }` methods implementation
1382
- var createMethod = function (IS_INCLUDES) {
1383
- return function ($this, el, fromIndex) {
1384
- var O = toIndexedObject$2($this);
1385
- var length = lengthOfArrayLike(O);
1386
- if (length === 0) return !IS_INCLUDES && -1;
1387
- var index = toAbsoluteIndex(fromIndex, length);
1388
- var value;
1389
- // Array#includes uses SameValueZero equality algorithm
1390
- // eslint-disable-next-line no-self-compare -- NaN check
1391
- if (IS_INCLUDES && el !== el) while (length > index) {
1392
- value = O[index++];
1393
- // eslint-disable-next-line no-self-compare -- NaN check
1394
- if (value !== value) return true;
1395
- // Array#indexOf ignores holes, Array#includes - not
1396
- } else for (;length > index; index++) {
1397
- if ((IS_INCLUDES || index in O) && O[index] === el) return IS_INCLUDES || index || 0;
1398
- } return !IS_INCLUDES && -1;
1399
- };
1400
- };
1401
-
1402
- var arrayIncludes = {
1403
- // `Array.prototype.includes` method
1404
- // https://tc39.es/ecma262/#sec-array.prototype.includes
1405
- includes: createMethod(true),
1406
- // `Array.prototype.indexOf` method
1407
- // https://tc39.es/ecma262/#sec-array.prototype.indexof
1408
- indexOf: createMethod(false)
1409
- };
1410
-
1411
- var uncurryThis$1 = functionUncurryThis;
1412
- var hasOwn$3 = hasOwnProperty_1;
1413
- var toIndexedObject$1 = toIndexedObject$4;
1414
- var indexOf = arrayIncludes.indexOf;
1415
- var hiddenKeys$2 = hiddenKeys$4;
1416
-
1417
- var push = uncurryThis$1([].push);
1418
-
1419
- var objectKeysInternal = function (object, names) {
1420
- var O = toIndexedObject$1(object);
1421
- var i = 0;
1422
- var result = [];
1423
- var key;
1424
- for (key in O) !hasOwn$3(hiddenKeys$2, key) && hasOwn$3(O, key) && push(result, key);
1425
- // Don't enum bug & hidden keys
1426
- while (names.length > i) if (hasOwn$3(O, key = names[i++])) {
1427
- ~indexOf(result, key) || push(result, key);
1428
- }
1429
- return result;
1430
- };
1431
-
1432
- // IE8- don't enum bug keys
1433
- var enumBugKeys$3 = [
1434
- 'constructor',
1435
- 'hasOwnProperty',
1436
- 'isPrototypeOf',
1437
- 'propertyIsEnumerable',
1438
- 'toLocaleString',
1439
- 'toString',
1440
- 'valueOf'
1441
- ];
1442
-
1443
- var internalObjectKeys$1 = objectKeysInternal;
1444
- var enumBugKeys$2 = enumBugKeys$3;
1445
-
1446
- var hiddenKeys$1 = enumBugKeys$2.concat('length', 'prototype');
1447
-
1448
- // `Object.getOwnPropertyNames` method
1449
- // https://tc39.es/ecma262/#sec-object.getownpropertynames
1450
- // eslint-disable-next-line es/no-object-getownpropertynames -- safe
1451
- objectGetOwnPropertyNames.f = Object.getOwnPropertyNames || function getOwnPropertyNames(O) {
1452
- return internalObjectKeys$1(O, hiddenKeys$1);
1453
- };
1454
-
1455
- var objectGetOwnPropertySymbols = {};
1456
-
1457
- // eslint-disable-next-line es/no-object-getownpropertysymbols -- safe
1458
- objectGetOwnPropertySymbols.f = Object.getOwnPropertySymbols;
1459
-
1460
- var getBuiltIn$1 = getBuiltIn$3;
1461
- var uncurryThis = functionUncurryThis;
1462
- var getOwnPropertyNamesModule = objectGetOwnPropertyNames;
1463
- var getOwnPropertySymbolsModule = objectGetOwnPropertySymbols;
1464
- var anObject$6 = anObject$8;
1465
-
1466
- var concat = uncurryThis([].concat);
1467
-
1468
- // all object keys, includes non-enumerable and symbols
1469
- var ownKeys$1 = getBuiltIn$1('Reflect', 'ownKeys') || function ownKeys(it) {
1470
- var keys = getOwnPropertyNamesModule.f(anObject$6(it));
1471
- var getOwnPropertySymbols = getOwnPropertySymbolsModule.f;
1472
- return getOwnPropertySymbols ? concat(keys, getOwnPropertySymbols(it)) : keys;
1473
- };
1474
-
1475
- var hasOwn$2 = hasOwnProperty_1;
1476
- var ownKeys = ownKeys$1;
1477
- var getOwnPropertyDescriptorModule = objectGetOwnPropertyDescriptor;
1478
- var definePropertyModule$2 = objectDefineProperty;
1479
-
1480
- var copyConstructorProperties$1 = function (target, source, exceptions) {
1481
- var keys = ownKeys(source);
1482
- var defineProperty = definePropertyModule$2.f;
1483
- var getOwnPropertyDescriptor = getOwnPropertyDescriptorModule.f;
1484
- for (var i = 0; i < keys.length; i++) {
1485
- var key = keys[i];
1486
- if (!hasOwn$2(target, key) && !(exceptions && hasOwn$2(exceptions, key))) {
1487
- defineProperty(target, key, getOwnPropertyDescriptor(source, key));
1488
- }
1489
- }
1490
- };
1491
-
1492
- var fails$3 = fails$b;
1493
- var isCallable$3 = isCallable$d;
1494
-
1495
- var replacement = /#|\.prototype\./;
1496
-
1497
- var isForced$1 = function (feature, detection) {
1498
- var value = data[normalize(feature)];
1499
- return value === POLYFILL ? true
1500
- : value === NATIVE ? false
1501
- : isCallable$3(detection) ? fails$3(detection)
1502
- : !!detection;
1503
- };
1504
-
1505
- var normalize = isForced$1.normalize = function (string) {
1506
- return String(string).replace(replacement, '.').toLowerCase();
1507
- };
1508
-
1509
- var data = isForced$1.data = {};
1510
- var NATIVE = isForced$1.NATIVE = 'N';
1511
- var POLYFILL = isForced$1.POLYFILL = 'P';
1512
-
1513
- var isForced_1 = isForced$1;
1514
-
1515
- var global$2 = global$b;
1516
- var getOwnPropertyDescriptor = objectGetOwnPropertyDescriptor.f;
1517
- var createNonEnumerableProperty$1 = createNonEnumerableProperty$3;
1518
- var defineBuiltIn$2 = defineBuiltIn$3;
1519
- var defineGlobalProperty = defineGlobalProperty$3;
1520
- var copyConstructorProperties = copyConstructorProperties$1;
1521
- var isForced = isForced_1;
1522
-
1523
- /*
1524
- options.target - name of the target object
1525
- options.global - target is the global object
1526
- options.stat - export as static methods of target
1527
- options.proto - export as prototype methods of target
1528
- options.real - real prototype method for the `pure` version
1529
- options.forced - export even if the native feature is available
1530
- options.bind - bind methods to the target, required for the `pure` version
1531
- options.wrap - wrap constructors to preventing global pollution, required for the `pure` version
1532
- options.unsafe - use the simple assignment of property instead of delete + defineProperty
1533
- options.sham - add a flag to not completely full polyfills
1534
- options.enumerable - export as enumerable property
1535
- options.dontCallGetSet - prevent calling a getter on target
1536
- options.name - the .name of the function if it does not match the key
1537
- */
1538
- var _export = function (options, source) {
1539
- var TARGET = options.target;
1540
- var GLOBAL = options.global;
1541
- var STATIC = options.stat;
1542
- var FORCED, target, key, targetProperty, sourceProperty, descriptor;
1543
- if (GLOBAL) {
1544
- target = global$2;
1545
- } else if (STATIC) {
1546
- target = global$2[TARGET] || defineGlobalProperty(TARGET, {});
1547
- } else {
1548
- target = global$2[TARGET] && global$2[TARGET].prototype;
1549
- }
1550
- if (target) for (key in source) {
1551
- sourceProperty = source[key];
1552
- if (options.dontCallGetSet) {
1553
- descriptor = getOwnPropertyDescriptor(target, key);
1554
- targetProperty = descriptor && descriptor.value;
1555
- } else targetProperty = target[key];
1556
- FORCED = isForced(GLOBAL ? key : TARGET + (STATIC ? '.' : '#') + key, options.forced);
1557
- // contained in target
1558
- if (!FORCED && targetProperty !== undefined) {
1559
- if (typeof sourceProperty == typeof targetProperty) continue;
1560
- copyConstructorProperties(sourceProperty, targetProperty);
1561
- }
1562
- // add a flag to not completely full polyfills
1563
- if (options.sham || (targetProperty && targetProperty.sham)) {
1564
- createNonEnumerableProperty$1(sourceProperty, 'sham', true);
1565
- }
1566
- defineBuiltIn$2(target, key, sourceProperty, options);
1567
- }
1568
- };
1569
-
1570
- var isPrototypeOf = objectIsPrototypeOf;
1571
-
1572
- var $TypeError$1 = TypeError;
1573
-
1574
- var anInstance$1 = function (it, Prototype) {
1575
- if (isPrototypeOf(Prototype, it)) return it;
1576
- throw new $TypeError$1('Incorrect invocation');
1577
- };
1578
-
1579
- var fails$2 = fails$b;
1580
-
1581
- var correctPrototypeGetter = !fails$2(function () {
1582
- function F() { /* empty */ }
1583
- F.prototype.constructor = null;
1584
- // eslint-disable-next-line es/no-object-getprototypeof -- required for testing
1585
- return Object.getPrototypeOf(new F()) !== F.prototype;
1586
- });
1587
-
1588
- var hasOwn$1 = hasOwnProperty_1;
1589
- var isCallable$2 = isCallable$d;
1590
- var toObject = toObject$2;
1591
- var sharedKey$1 = sharedKey$3;
1592
- var CORRECT_PROTOTYPE_GETTER = correctPrototypeGetter;
1593
-
1594
- var IE_PROTO$1 = sharedKey$1('IE_PROTO');
1595
- var $Object = Object;
1596
- var ObjectPrototype = $Object.prototype;
1597
-
1598
- // `Object.getPrototypeOf` method
1599
- // https://tc39.es/ecma262/#sec-object.getprototypeof
1600
- // eslint-disable-next-line es/no-object-getprototypeof -- safe
1601
- var objectGetPrototypeOf = CORRECT_PROTOTYPE_GETTER ? $Object.getPrototypeOf : function (O) {
1602
- var object = toObject(O);
1603
- if (hasOwn$1(object, IE_PROTO$1)) return object[IE_PROTO$1];
1604
- var constructor = object.constructor;
1605
- if (isCallable$2(constructor) && object instanceof constructor) {
1606
- return constructor.prototype;
1607
- } return object instanceof $Object ? ObjectPrototype : null;
1608
- };
1609
-
1610
- var makeBuiltIn = makeBuiltInExports;
1611
- var defineProperty = objectDefineProperty;
1612
-
1613
- var defineBuiltInAccessor$1 = function (target, name, descriptor) {
1614
- if (descriptor.get) makeBuiltIn(descriptor.get, name, { getter: true });
1615
- if (descriptor.set) makeBuiltIn(descriptor.set, name, { setter: true });
1616
- return defineProperty.f(target, name, descriptor);
1617
- };
1618
-
1619
- var DESCRIPTORS$2 = descriptors;
1620
- var definePropertyModule$1 = objectDefineProperty;
1621
- var createPropertyDescriptor = createPropertyDescriptor$3;
1622
-
1623
- var createProperty$1 = function (object, key, value) {
1624
- if (DESCRIPTORS$2) definePropertyModule$1.f(object, key, createPropertyDescriptor(0, value));
1625
- else object[key] = value;
1626
- };
1627
-
1628
- var objectDefineProperties = {};
1629
-
1630
- var internalObjectKeys = objectKeysInternal;
1631
- var enumBugKeys$1 = enumBugKeys$3;
1632
-
1633
- // `Object.keys` method
1634
- // https://tc39.es/ecma262/#sec-object.keys
1635
- // eslint-disable-next-line es/no-object-keys -- safe
1636
- var objectKeys$1 = Object.keys || function keys(O) {
1637
- return internalObjectKeys(O, enumBugKeys$1);
1638
- };
1639
-
1640
- var DESCRIPTORS$1 = descriptors;
1641
- var V8_PROTOTYPE_DEFINE_BUG = v8PrototypeDefineBug;
1642
- var definePropertyModule = objectDefineProperty;
1643
- var anObject$5 = anObject$8;
1644
- var toIndexedObject = toIndexedObject$4;
1645
- var objectKeys = objectKeys$1;
1646
-
1647
- // `Object.defineProperties` method
1648
- // https://tc39.es/ecma262/#sec-object.defineproperties
1649
- // eslint-disable-next-line es/no-object-defineproperties -- safe
1650
- objectDefineProperties.f = DESCRIPTORS$1 && !V8_PROTOTYPE_DEFINE_BUG ? Object.defineProperties : function defineProperties(O, Properties) {
1651
- anObject$5(O);
1652
- var props = toIndexedObject(Properties);
1653
- var keys = objectKeys(Properties);
1654
- var length = keys.length;
1655
- var index = 0;
1656
- var key;
1657
- while (length > index) definePropertyModule.f(O, key = keys[index++], props[key]);
1658
- return O;
1659
- };
1660
-
1661
- var getBuiltIn = getBuiltIn$3;
1662
-
1663
- var html$1 = getBuiltIn('document', 'documentElement');
1664
-
1665
- /* global ActiveXObject -- old IE, WSH */
1666
- var anObject$4 = anObject$8;
1667
- var definePropertiesModule = objectDefineProperties;
1668
- var enumBugKeys = enumBugKeys$3;
1669
- var hiddenKeys = hiddenKeys$4;
1670
- var html = html$1;
1671
- var documentCreateElement = documentCreateElement$1;
1672
- var sharedKey = sharedKey$3;
1673
-
1674
- var GT = '>';
1675
- var LT = '<';
1676
- var PROTOTYPE = 'prototype';
1677
- var SCRIPT = 'script';
1678
- var IE_PROTO = sharedKey('IE_PROTO');
1679
-
1680
- var EmptyConstructor = function () { /* empty */ };
1681
-
1682
- var scriptTag = function (content) {
1683
- return LT + SCRIPT + GT + content + LT + '/' + SCRIPT + GT;
1684
- };
1685
-
1686
- // Create object with fake `null` prototype: use ActiveX Object with cleared prototype
1687
- var NullProtoObjectViaActiveX = function (activeXDocument) {
1688
- activeXDocument.write(scriptTag(''));
1689
- activeXDocument.close();
1690
- var temp = activeXDocument.parentWindow.Object;
1691
- activeXDocument = null; // avoid memory leak
1692
- return temp;
1693
- };
1694
-
1695
- // Create object with fake `null` prototype: use iframe Object with cleared prototype
1696
- var NullProtoObjectViaIFrame = function () {
1697
- // Thrash, waste and sodomy: IE GC bug
1698
- var iframe = documentCreateElement('iframe');
1699
- var JS = 'java' + SCRIPT + ':';
1700
- var iframeDocument;
1701
- iframe.style.display = 'none';
1702
- html.appendChild(iframe);
1703
- // https://github.com/zloirock/core-js/issues/475
1704
- iframe.src = String(JS);
1705
- iframeDocument = iframe.contentWindow.document;
1706
- iframeDocument.open();
1707
- iframeDocument.write(scriptTag('document.F=Object'));
1708
- iframeDocument.close();
1709
- return iframeDocument.F;
1710
- };
1711
-
1712
- // Check for document.domain and active x support
1713
- // No need to use active x approach when document.domain is not set
1714
- // see https://github.com/es-shims/es5-shim/issues/150
1715
- // variation of https://github.com/kitcambridge/es5-shim/commit/4f738ac066346
1716
- // avoid IE GC bug
1717
- var activeXDocument;
1718
- var NullProtoObject = function () {
1719
- try {
1720
- activeXDocument = new ActiveXObject('htmlfile');
1721
- } catch (error) { /* ignore */ }
1722
- NullProtoObject = typeof document != 'undefined'
1723
- ? document.domain && activeXDocument
1724
- ? NullProtoObjectViaActiveX(activeXDocument) // old IE
1725
- : NullProtoObjectViaIFrame()
1726
- : NullProtoObjectViaActiveX(activeXDocument); // WSH
1727
- var length = enumBugKeys.length;
1728
- while (length--) delete NullProtoObject[PROTOTYPE][enumBugKeys[length]];
1729
- return NullProtoObject();
1730
- };
1731
-
1732
- hiddenKeys[IE_PROTO] = true;
1733
-
1734
- // `Object.create` method
1735
- // https://tc39.es/ecma262/#sec-object.create
1736
- // eslint-disable-next-line es/no-object-create -- safe
1737
- var objectCreate = Object.create || function create(O, Properties) {
1738
- var result;
1739
- if (O !== null) {
1740
- EmptyConstructor[PROTOTYPE] = anObject$4(O);
1741
- result = new EmptyConstructor();
1742
- EmptyConstructor[PROTOTYPE] = null;
1743
- // add "__proto__" for Object.getPrototypeOf polyfill
1744
- result[IE_PROTO] = O;
1745
- } else result = NullProtoObject();
1746
- return Properties === undefined ? result : definePropertiesModule.f(result, Properties);
1747
- };
1748
-
1749
- var fails$1 = fails$b;
1750
- var isCallable$1 = isCallable$d;
1751
- var isObject = isObject$6;
1752
- var getPrototypeOf$1 = objectGetPrototypeOf;
1753
- var defineBuiltIn$1 = defineBuiltIn$3;
1754
- var wellKnownSymbol$2 = wellKnownSymbol$4;
1755
-
1756
- var ITERATOR$1 = wellKnownSymbol$2('iterator');
1757
- var BUGGY_SAFARI_ITERATORS = false;
1758
-
1759
- // `%IteratorPrototype%` object
1760
- // https://tc39.es/ecma262/#sec-%iteratorprototype%-object
1761
- var IteratorPrototype$2, PrototypeOfArrayIteratorPrototype, arrayIterator;
1762
-
1763
- /* eslint-disable es/no-array-prototype-keys -- safe */
1764
- if ([].keys) {
1765
- arrayIterator = [].keys();
1766
- // Safari 8 has buggy iterators w/o `next`
1767
- if (!('next' in arrayIterator)) BUGGY_SAFARI_ITERATORS = true;
1768
- else {
1769
- PrototypeOfArrayIteratorPrototype = getPrototypeOf$1(getPrototypeOf$1(arrayIterator));
1770
- if (PrototypeOfArrayIteratorPrototype !== Object.prototype) IteratorPrototype$2 = PrototypeOfArrayIteratorPrototype;
1771
- }
1772
- }
1773
-
1774
- var NEW_ITERATOR_PROTOTYPE = !isObject(IteratorPrototype$2) || fails$1(function () {
1775
- var test = {};
1776
- // FF44- legacy iterators case
1777
- return IteratorPrototype$2[ITERATOR$1].call(test) !== test;
1778
- });
1779
-
1780
- if (NEW_ITERATOR_PROTOTYPE) IteratorPrototype$2 = {};
1781
-
1782
- // `%IteratorPrototype%[@@iterator]()` method
1783
- // https://tc39.es/ecma262/#sec-%iteratorprototype%-@@iterator
1784
- if (!isCallable$1(IteratorPrototype$2[ITERATOR$1])) {
1785
- defineBuiltIn$1(IteratorPrototype$2, ITERATOR$1, function () {
1786
- return this;
1787
- });
1788
- }
1789
-
1790
- var iteratorsCore = {
1791
- IteratorPrototype: IteratorPrototype$2,
1792
- BUGGY_SAFARI_ITERATORS: BUGGY_SAFARI_ITERATORS
1793
- };
1794
-
1795
- var $$1 = _export;
1796
- var global$1 = global$b;
1797
- var anInstance = anInstance$1;
1798
- var anObject$3 = anObject$8;
1799
- var isCallable = isCallable$d;
1800
- var getPrototypeOf = objectGetPrototypeOf;
1801
- var defineBuiltInAccessor = defineBuiltInAccessor$1;
1802
- var createProperty = createProperty$1;
1803
- var fails = fails$b;
1804
- var hasOwn = hasOwnProperty_1;
1805
- var wellKnownSymbol$1 = wellKnownSymbol$4;
1806
- var IteratorPrototype$1 = iteratorsCore.IteratorPrototype;
1807
- var DESCRIPTORS = descriptors;
1808
-
1809
- var CONSTRUCTOR = 'constructor';
1810
- var ITERATOR = 'Iterator';
1811
- var TO_STRING_TAG$1 = wellKnownSymbol$1('toStringTag');
1812
-
1813
- var $TypeError = TypeError;
1814
- var NativeIterator = global$1[ITERATOR];
1815
-
1816
- // FF56- have non-standard global helper `Iterator`
1817
- var FORCED = !isCallable(NativeIterator)
1818
- || NativeIterator.prototype !== IteratorPrototype$1
1819
- // FF44- non-standard `Iterator` passes previous tests
1820
- || !fails(function () { NativeIterator({}); });
1821
-
1822
- var IteratorConstructor = function Iterator() {
1823
- anInstance(this, IteratorPrototype$1);
1824
- if (getPrototypeOf(this) === IteratorPrototype$1) throw new $TypeError('Abstract class Iterator not directly constructable');
1825
- };
1826
-
1827
- var defineIteratorPrototypeAccessor = function (key, value) {
1828
- if (DESCRIPTORS) {
1829
- defineBuiltInAccessor(IteratorPrototype$1, key, {
1830
- configurable: true,
1831
- get: function () {
1832
- return value;
1833
- },
1834
- set: function (replacement) {
1835
- anObject$3(this);
1836
- if (this === IteratorPrototype$1) throw new $TypeError("You can't redefine this property");
1837
- if (hasOwn(this, key)) this[key] = replacement;
1838
- else createProperty(this, key, replacement);
1839
- }
1840
- });
1841
- } else IteratorPrototype$1[key] = value;
1842
- };
1843
-
1844
- if (!hasOwn(IteratorPrototype$1, TO_STRING_TAG$1)) defineIteratorPrototypeAccessor(TO_STRING_TAG$1, ITERATOR);
1845
-
1846
- if (FORCED || !hasOwn(IteratorPrototype$1, CONSTRUCTOR) || IteratorPrototype$1[CONSTRUCTOR] === Object) {
1847
- defineIteratorPrototypeAccessor(CONSTRUCTOR, IteratorConstructor);
1848
- }
1849
-
1850
- IteratorConstructor.prototype = IteratorPrototype$1;
1851
-
1852
- // `Iterator` constructor
1853
- // https://github.com/tc39/proposal-iterator-helpers
1854
- $$1({ global: true, constructor: true, forced: FORCED }, {
1855
- Iterator: IteratorConstructor
1856
- });
1857
-
1858
- // `GetIteratorDirect(obj)` abstract operation
1859
- // https://tc39.es/proposal-iterator-helpers/#sec-getiteratordirect
1860
- var getIteratorDirect$1 = function (obj) {
1861
- return {
1862
- iterator: obj,
1863
- next: obj.next,
1864
- done: false
1865
- };
1866
- };
1867
-
1868
- var defineBuiltIn = defineBuiltIn$3;
1869
-
1870
- var defineBuiltIns$1 = function (target, src, options) {
1871
- for (var key in src) defineBuiltIn(target, key, src[key], options);
1872
- return target;
1873
- };
1874
-
1875
- // `CreateIterResultObject` abstract operation
1876
- // https://tc39.es/ecma262/#sec-createiterresultobject
1877
- var createIterResultObject$1 = function (value, done) {
1878
- return { value: value, done: done };
1879
- };
1880
-
1881
- var call$2 = functionCall;
1882
- var anObject$2 = anObject$8;
1883
- var getMethod$1 = getMethod$3;
1884
-
1885
- var iteratorClose$2 = function (iterator, kind, value) {
1886
- var innerResult, innerError;
1887
- anObject$2(iterator);
1888
- try {
1889
- innerResult = getMethod$1(iterator, 'return');
1890
- if (!innerResult) {
1891
- if (kind === 'throw') throw value;
1892
- return value;
1893
- }
1894
- innerResult = call$2(innerResult, iterator);
1895
- } catch (error) {
1896
- innerError = true;
1897
- innerResult = error;
1898
- }
1899
- if (kind === 'throw') throw value;
1900
- if (innerError) throw innerResult;
1901
- anObject$2(innerResult);
1902
- return value;
1903
- };
1904
-
1905
- var call$1 = functionCall;
1906
- var create = objectCreate;
1907
- var createNonEnumerableProperty = createNonEnumerableProperty$3;
1908
- var defineBuiltIns = defineBuiltIns$1;
1909
- var wellKnownSymbol = wellKnownSymbol$4;
1910
- var InternalStateModule = internalState;
1911
- var getMethod = getMethod$3;
1912
- var IteratorPrototype = iteratorsCore.IteratorPrototype;
1913
- var createIterResultObject = createIterResultObject$1;
1914
- var iteratorClose$1 = iteratorClose$2;
1915
-
1916
- var TO_STRING_TAG = wellKnownSymbol('toStringTag');
1917
- var ITERATOR_HELPER = 'IteratorHelper';
1918
- var WRAP_FOR_VALID_ITERATOR = 'WrapForValidIterator';
1919
- var setInternalState = InternalStateModule.set;
1920
-
1921
- var createIteratorProxyPrototype = function (IS_ITERATOR) {
1922
- var getInternalState = InternalStateModule.getterFor(IS_ITERATOR ? WRAP_FOR_VALID_ITERATOR : ITERATOR_HELPER);
1923
-
1924
- return defineBuiltIns(create(IteratorPrototype), {
1925
- next: function next() {
1926
- var state = getInternalState(this);
1927
- // for simplification:
1928
- // for `%WrapForValidIteratorPrototype%.next` our `nextHandler` returns `IterResultObject`
1929
- // for `%IteratorHelperPrototype%.next` - just a value
1930
- if (IS_ITERATOR) return state.nextHandler();
1931
- try {
1932
- var result = state.done ? undefined : state.nextHandler();
1933
- return createIterResultObject(result, state.done);
1934
- } catch (error) {
1935
- state.done = true;
1936
- throw error;
1937
- }
1938
- },
1939
- 'return': function () {
1940
- var state = getInternalState(this);
1941
- var iterator = state.iterator;
1942
- state.done = true;
1943
- if (IS_ITERATOR) {
1944
- var returnMethod = getMethod(iterator, 'return');
1945
- return returnMethod ? call$1(returnMethod, iterator) : createIterResultObject(undefined, true);
1946
- }
1947
- if (state.inner) try {
1948
- iteratorClose$1(state.inner.iterator, 'normal');
1949
- } catch (error) {
1950
- return iteratorClose$1(iterator, 'throw', error);
1951
- }
1952
- iteratorClose$1(iterator, 'normal');
1953
- return createIterResultObject(undefined, true);
1954
- }
1955
- });
1956
- };
1957
-
1958
- var WrapForValidIteratorPrototype = createIteratorProxyPrototype(true);
1959
- var IteratorHelperPrototype = createIteratorProxyPrototype(false);
1960
-
1961
- createNonEnumerableProperty(IteratorHelperPrototype, TO_STRING_TAG, 'Iterator Helper');
1962
-
1963
- var iteratorCreateProxy = function (nextHandler, IS_ITERATOR) {
1964
- var IteratorProxy = function Iterator(record, state) {
1965
- if (state) {
1966
- state.iterator = record.iterator;
1967
- state.next = record.next;
1968
- } else state = record;
1969
- state.type = IS_ITERATOR ? WRAP_FOR_VALID_ITERATOR : ITERATOR_HELPER;
1970
- state.nextHandler = nextHandler;
1971
- state.counter = 0;
1972
- state.done = false;
1973
- setInternalState(this, state);
1974
- };
1975
-
1976
- IteratorProxy.prototype = IS_ITERATOR ? WrapForValidIteratorPrototype : IteratorHelperPrototype;
1977
-
1978
- return IteratorProxy;
1979
- };
1980
-
1981
- var anObject$1 = anObject$8;
1982
- var iteratorClose = iteratorClose$2;
1983
-
1984
- // call something on iterator step with safe closing on error
1985
- var callWithSafeIterationClosing$1 = function (iterator, fn, value, ENTRIES) {
1986
- try {
1987
- return ENTRIES ? fn(anObject$1(value)[0], value[1]) : fn(value);
1988
- } catch (error) {
1989
- iteratorClose(iterator, 'throw', error);
1990
- }
1991
- };
1992
-
1993
- var call = functionCall;
1994
- var aCallable = aCallable$2;
1995
- var anObject = anObject$8;
1996
- var getIteratorDirect = getIteratorDirect$1;
1997
- var createIteratorProxy = iteratorCreateProxy;
1998
- var callWithSafeIterationClosing = callWithSafeIterationClosing$1;
1999
-
2000
- var IteratorProxy = createIteratorProxy(function () {
2001
- var iterator = this.iterator;
2002
- var result = anObject(call(this.next, iterator));
2003
- var done = this.done = !!result.done;
2004
- if (!done) return callWithSafeIterationClosing(iterator, this.mapper, [result.value, this.counter++], true);
2005
- });
2006
-
2007
- // `Iterator.prototype.map` method
2008
- // https://github.com/tc39/proposal-iterator-helpers
2009
- var iteratorMap = function map(mapper) {
2010
- anObject(this);
2011
- aCallable(mapper);
2012
- return new IteratorProxy(getIteratorDirect(this), {
2013
- mapper: mapper
2014
- });
2015
- };
2016
-
2017
- var $ = _export;
2018
- var map = iteratorMap;
2019
- var IS_PURE = isPure;
2020
-
2021
- // `Iterator.prototype.map` method
2022
- // https://github.com/tc39/proposal-iterator-helpers
2023
- $({ target: 'Iterator', proto: true, real: true, forced: IS_PURE }, {
2024
- map: map
2025
- });
2026
-
2027
- var makeError = {exports: {}};
2028
-
2029
- (function (module, exports) {
2030
-
2031
- // ===================================================================
2032
-
2033
- var construct = typeof Reflect !== "undefined" ? Reflect.construct : undefined;
2034
- var defineProperty = Object.defineProperty;
2035
-
2036
- // -------------------------------------------------------------------
2037
-
2038
- var captureStackTrace = Error.captureStackTrace;
2039
- if (captureStackTrace === undefined) {
2040
- captureStackTrace = function captureStackTrace(error) {
2041
- var container = new Error();
2042
-
2043
- defineProperty(error, "stack", {
2044
- configurable: true,
2045
- get: function getStack() {
2046
- var stack = container.stack;
2047
-
2048
- // Replace property with value for faster future accesses.
2049
- defineProperty(this, "stack", {
2050
- configurable: true,
2051
- value: stack,
2052
- writable: true,
2053
- });
2054
-
2055
- return stack;
2056
- },
2057
- set: function setStack(stack) {
2058
- defineProperty(error, "stack", {
2059
- configurable: true,
2060
- value: stack,
2061
- writable: true,
2062
- });
2063
- },
2064
- });
2065
- };
2066
- }
2067
-
2068
- // -------------------------------------------------------------------
2069
-
2070
- function BaseError(message) {
2071
- if (message !== undefined) {
2072
- defineProperty(this, "message", {
2073
- configurable: true,
2074
- value: message,
2075
- writable: true,
2076
- });
2077
- }
2078
-
2079
- var cname = this.constructor.name;
2080
- if (cname !== undefined && cname !== this.name) {
2081
- defineProperty(this, "name", {
2082
- configurable: true,
2083
- value: cname,
2084
- writable: true,
2085
- });
2086
- }
2087
-
2088
- captureStackTrace(this, this.constructor);
2089
- }
2090
-
2091
- BaseError.prototype = Object.create(Error.prototype, {
2092
- // See: https://github.com/JsCommunity/make-error/issues/4
2093
- constructor: {
2094
- configurable: true,
2095
- value: BaseError,
2096
- writable: true,
2097
- },
2098
- });
2099
-
2100
- // -------------------------------------------------------------------
2101
-
2102
- // Sets the name of a function if possible (depends of the JS engine).
2103
- var setFunctionName = (function() {
2104
- function setFunctionName(fn, name) {
2105
- return defineProperty(fn, "name", {
2106
- configurable: true,
2107
- value: name,
2108
- });
2109
- }
2110
- try {
2111
- var f = function() {};
2112
- setFunctionName(f, "foo");
2113
- if (f.name === "foo") {
2114
- return setFunctionName;
2115
- }
2116
- } catch (_) {}
2117
- })();
2118
-
2119
- // -------------------------------------------------------------------
2120
-
2121
- function makeError(constructor, super_) {
2122
- if (super_ == null || super_ === Error) {
2123
- super_ = BaseError;
2124
- } else if (typeof super_ !== "function") {
2125
- throw new TypeError("super_ should be a function");
2126
- }
2127
-
2128
- var name;
2129
- if (typeof constructor === "string") {
2130
- name = constructor;
2131
- constructor =
2132
- construct !== undefined
2133
- ? function() {
2134
- return construct(super_, arguments, this.constructor);
2135
- }
2136
- : function() {
2137
- super_.apply(this, arguments);
2138
- };
2139
-
2140
- // If the name can be set, do it once and for all.
2141
- if (setFunctionName !== undefined) {
2142
- setFunctionName(constructor, name);
2143
- name = undefined;
2144
- }
2145
- } else if (typeof constructor !== "function") {
2146
- throw new TypeError("constructor should be either a string or a function");
2147
- }
2148
-
2149
- // Also register the super constructor also as `constructor.super_` just
2150
- // like Node's `util.inherits()`.
2151
- //
2152
- // eslint-disable-next-line dot-notation
2153
- constructor.super_ = constructor["super"] = super_;
2154
-
2155
- var properties = {
2156
- constructor: {
2157
- configurable: true,
2158
- value: constructor,
2159
- writable: true,
2160
- },
2161
- };
2162
-
2163
- // If the name could not be set on the constructor, set it on the
2164
- // prototype.
2165
- if (name !== undefined) {
2166
- properties.name = {
2167
- configurable: true,
2168
- value: name,
2169
- writable: true,
2170
- };
2171
- }
2172
- constructor.prototype = Object.create(super_.prototype, properties);
2173
-
2174
- return constructor;
2175
- }
2176
- exports = module.exports = makeError;
2177
- exports.BaseError = BaseError;
2178
- } (makeError, makeError.exports));
2179
-
2180
- var makeErrorExports = makeError.exports;
2181
-
2182
- /**
2183
- * Error thrown when the common type is not known/registered.
2184
- */
2185
- class UnregisteredSyncEntityCommonTypeError extends makeErrorExports.BaseError {
2186
- constructor(commonType) {
2187
- super(`The common type "${commonType}" is not registered.`);
2188
- this.commonType = void 0;
2189
- this.commonType = commonType;
2190
- }
2191
- }
2192
- /**
2193
- * Error thrown when no primary sync source is found for an entity.
2194
- */
2195
- class NoPrimarySyncSourceError extends makeErrorExports.BaseError {
2196
- constructor(entity) {
2197
- super(`No primary sync source found for entity "${entity.commonType}:${entity.commonId}".`);
2198
- this.entity = void 0;
2199
- this.entity = entity;
2200
- }
2201
- }
2202
1139
  /**
2203
- * Error thrown when multiple primary sync sources are found for an entity.
2204
- */
2205
- class MultiplePrimarySyncSourceError extends makeErrorExports.BaseError {
2206
- constructor(entity) {
2207
- super(`Multiple primary sync sources found for entity "${entity.commonType}:${entity.commonId}".`);
2208
- this.entity = void 0;
2209
- this.entity = entity;
2210
- }
2211
- }
2212
- /**
2213
- * Error thrown when a synchronization fails for an entity.
1140
+ * isWebsiteUrl validator
2214
1141
  */
2215
- class SynchronizationFailedError extends makeErrorExports.BaseError {
2216
- constructor(entity, error) {
2217
- super(`Synchronization failed for entity "${entity.commonType}:${entity.commonId}". Error: ${error}`);
2218
- this.entity = void 0;
2219
- this.error = void 0;
2220
- this.entity = entity;
2221
- this.error = error;
2222
- }
2223
- }
2224
-
2225
- function syncEntitySynchronizer(config) {
2226
- const map = new Map(config.commonTypeSynchronizers.map(x => [x.commonType, x]));
2227
- const commonTypes = Array.from(map.keys());
2228
- const commonTypeSynchronizer = input => {
2229
- const synchronizer = map.get(input);
2230
- if (!synchronizer) {
2231
- throw new UnregisteredSyncEntityCommonTypeError(input);
2232
- }
2233
- return synchronizer;
2234
- };
2235
- return {
2236
- commonTypes,
2237
- commonTypeSynchronizer,
2238
- synchronizeInstance: input => {
2239
- const synchronizer = commonTypeSynchronizer(input.commonType);
2240
- return synchronizer.synchronizeInstance(input);
2241
- }
2242
- };
2243
- }
2244
-
2245
- function basicSyncEntityCommonTypeSynchronizerInstanceFactory(config) {
2246
- const {
2247
- commonType,
2248
- sources,
2249
- entitySourceContextLoader,
2250
- dynamicSources = false
2251
- } = config;
2252
- const syncEntityCommonTypeIdPairForType = syncEntityCommonTypeIdPairFactory(commonType);
2253
- const sourcesByContextType = makeValuesGroupMap(sources, x => x.contextType);
2254
- const allGlobalSources = sourcesByContextType.get('global') ?? [];
2255
- const allContextSources = sourcesByContextType.get('context') ?? [];
2256
- /**
2257
- * Loads the relevant sources for the given entity and context.
2258
- *
2259
- * @param entitySourceContext The contextual information for the entity.
2260
- * @returns The relevant sources for the entity.
2261
- */
2262
- function loadSources(entityCommonTypeIdPair, entitySourceContext) {
2263
- const {
2264
- globalSources,
2265
- contextSources
2266
- } = entitySourceContext;
2267
- // load/filter global sources
2268
- const globalMap = new Map(globalSources.map(x => {
2269
- let sourceId;
2270
- let flowType;
2271
- if (typeof x === 'string') {
2272
- sourceId = x;
2273
- flowType = 'unset';
2274
- } else {
2275
- sourceId = x.sourceId;
2276
- flowType = x.flowType;
2277
- }
2278
- return [sourceId, {
2279
- sourceId,
2280
- flowType
2281
- }];
2282
- }));
2283
- const relevantGlobalSources = filterMaybeArrayValues(allGlobalSources.map(x => {
2284
- const sourceContext = globalMap.get(x.info.id);
2285
- let result;
2286
- if (sourceContext != null) {
2287
- result = {
2288
- entityCommonTypeIdPair,
2289
- flowType: sourceContext.flowType ?? x.defaultFlowType ?? 'unset',
2290
- source: x
2291
- };
2292
- }
2293
- return result;
2294
- }));
2295
- // load/filter context sources
2296
- const contextMap = new Map(contextSources.map(x => [x.sourceId, x]));
2297
- const relevantContextSources = filterMaybeArrayValues(allContextSources.map(x => {
2298
- const sourceContext = contextMap.get(x.info.id);
2299
- let result;
2300
- if (sourceContext != null) {
2301
- const flowType = sourceContext.flowType ?? x.defaultFlowType ?? 'unset';
2302
- result = {
2303
- entityCommonTypeIdPair,
2304
- flowType,
2305
- source: x,
2306
- context: sourceContext
2307
- };
2308
- }
2309
- return result;
2310
- }));
2311
- const allSources = [...relevantGlobalSources, ...relevantContextSources];
2312
- // sort by order, with primary first
2313
- allSources.sort(sortByNumberFunction(x => {
2314
- let result;
2315
- switch (x.flowType) {
2316
- case 'primary':
2317
- result = 1;
2318
- break;
2319
- case 'secondary':
2320
- result = 2;
2321
- break;
2322
- case 'unset':
2323
- default:
2324
- result = 3;
2325
- break;
2326
- }
2327
- return result;
2328
- }));
2329
- return allSources;
2330
- }
2331
- const synchronizeInstance = async input => {
2332
- const syncEntityCommonTypeIdPair = syncEntityCommonTypeIdPairForType(input);
2333
- const _loadRelevantSources = async () => {
2334
- const entitySourceContext = await entitySourceContextLoader(syncEntityCommonTypeIdPair);
2335
- const relevantSources = loadSources(syncEntityCommonTypeIdPair, entitySourceContext);
2336
- return relevantSources;
2337
- };
2338
- let loadRelevantSources;
2339
- if (dynamicSources) {
2340
- // if dynamic, reload each time and do not cache
2341
- loadRelevantSources = _loadRelevantSources;
2342
- } else {
2343
- // if not dynamic, make a cached getter
2344
- loadRelevantSources = cachedGetter(_loadRelevantSources);
2345
- }
2346
- /**
2347
- * Performs the synchonization
2348
- */
2349
- const synchronize = async context => {
2350
- const relevantSources = await loadRelevantSources();
2351
- const syncEntityInstances = await Promise.all(relevantSources.map(x => x.source.syncEntityInstance(x).then(y => [x, y])));
2352
- const sourcesByFlowType = makeValuesGroupMap(syncEntityInstances, x => x[0].flowType);
2353
- const primarySources = sourcesByFlowType.get('primary') ?? [];
2354
- const secondarySources = sourcesByFlowType.get('secondary') ?? [];
2355
- const replicaSources = sourcesByFlowType.get('replica') ?? [];
2356
- // assert primary sources count
2357
- switch (primarySources.length) {
2358
- case 0:
2359
- throw new NoPrimarySyncSourceError(syncEntityCommonTypeIdPair);
2360
- case 1:
2361
- break;
2362
- default:
2363
- throw new MultiplePrimarySyncSourceError(syncEntityCommonTypeIdPair);
2364
- }
2365
- function synchronizeInstance(source, deleted) {
2366
- const [input, sourceInstance] = source;
2367
- const promise = deleted ? sourceInstance.synchronizeDelete() : sourceInstance.synchronize();
2368
- return promise.catch(error => {
2369
- const errorResult = {
2370
- type: 'error',
2371
- error,
2372
- entity: {
2373
- ...syncEntityCommonTypeIdPair,
2374
- sourceInfo: input.source.info,
2375
- id: ''
1142
+ function IsWebsiteUrl(validationOptions) {
1143
+ return function (object, propertyName) {
1144
+ registerDecorator({
1145
+ name: 'isWebsiteUrl',
1146
+ target: object.constructor,
1147
+ propertyName: propertyName,
1148
+ options: validationOptions,
1149
+ validator: {
1150
+ validate: isWebsiteUrl,
1151
+ defaultMessage: buildMessage((eachPrefix, args) => eachPrefix + `$property value of "${args?.value}" is not a valid website url.`, validationOptions)
2376
1152
  }
2377
- };
2378
- return errorResult;
2379
1153
  });
2380
- }
2381
- async function performSynchronizationOfSources(input) {
2382
- const {
2383
- syncRecursionDepth,
2384
- secondaryFlaggedDelete
2385
- } = input;
2386
- let result;
2387
- // synchronize the primary source
2388
- const primarySource = primarySources[0];
2389
- const primarySyncResult = await synchronizeInstance(primarySource, secondaryFlaggedDelete ?? false);
2390
- const synchronizedEntityResults = [primarySyncResult];
2391
- let primaryFlaggedDelete = false;
2392
- switch (primarySyncResult.type) {
2393
- case 'deleted':
2394
- primaryFlaggedDelete = true;
2395
- break;
2396
- case 'failed':
2397
- case 'error':
2398
- throw new SynchronizationFailedError(syncEntityCommonTypeIdPair, primarySyncResult.error);
2399
- }
2400
- // 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.
2401
- for (const secondarySource of secondarySources) {
2402
- const secondarySyncResult = await synchronizeInstance(secondarySource, primaryFlaggedDelete);
2403
- synchronizedEntityResults.push(secondarySyncResult);
2404
- switch (secondarySyncResult.type) {
2405
- case 'deleted':
2406
- if (primaryFlaggedDelete === false) {
2407
- if (syncRecursionDepth === 1) {
2408
- result = await performSynchronizationOfSources({
2409
- syncRecursionDepth: syncRecursionDepth + 1,
2410
- secondaryFlaggedDelete: true
2411
- });
2412
- }
2413
- break;
2414
- }
2415
- break;
2416
- case 'failed':
2417
- case 'error':
2418
- throw new SynchronizationFailedError(syncEntityCommonTypeIdPair, secondarySyncResult.error);
2419
- }
2420
- }
2421
- // if result was already set, then it was completed in a recursive result
2422
- if (result == null) {
2423
- // synchronize all replica sources concurrently
2424
- const replicaTaskResults = await performAsyncTasks(replicaSources, x => synchronizeInstance(x, primaryFlaggedDelete), {
2425
- sequential: false,
2426
- maxParallelTasks: 3
2427
- });
2428
- // add all the results
2429
- pushArrayItemsIntoArray(synchronizedEntityResults, replicaTaskResults.results.map(x => x[1]));
2430
- // compute final result
2431
- result = {
2432
- synchronizedEntityResults
2433
- };
2434
- }
2435
- return result;
2436
- }
2437
- const result = await performSynchronizationOfSources({
2438
- syncRecursionDepth: 0
2439
- });
2440
- return {
2441
- targetPair: syncEntityCommonTypeIdPair,
2442
- entitiesSynchronized: result.synchronizedEntityResults
2443
- };
2444
- };
2445
- const instance = {
2446
- entityPair: syncEntityCommonTypeIdPair,
2447
- synchronize
2448
- };
2449
- return instance;
2450
- };
2451
- const result = {
2452
- commonType,
2453
- synchronizeInstance
2454
- };
2455
- return result;
2456
- }
2457
-
2458
- // MARK: String
2459
- function transformStringToBoolean(defaultValue) {
2460
- return params => stringToBoolean(params.value, defaultValue);
2461
- }
2462
- // MARK: Comma Separated Values
2463
- function transformCommaSeparatedValueToArray(mapFn) {
2464
- return params => {
2465
- let result;
2466
- if (params.value) {
2467
- if (Array.isArray(params.value)) {
2468
- result = params.value;
2469
- } else {
2470
- result = splitCommaSeparatedString(params.value, mapFn);
2471
- }
2472
- }
2473
- return result;
2474
- };
2475
- }
2476
- const transformCommaSeparatedNumberValueToArray = transformCommaSeparatedValueToArray(x => Number(x));
2477
- const transformCommaSeparatedStringValueToArray = transformCommaSeparatedValueToArray(x => x);
2478
-
2479
- // MARK: Transform Annotations
2480
- function TransformCommaSeparatedValueToArray(mapFn) {
2481
- return Transform(transformCommaSeparatedValueToArray(mapFn));
2482
- }
2483
- const TransformCommaSeparatedStringValueToArray = () => Transform(transformCommaSeparatedStringValueToArray);
2484
- const TransformCommaSeparatedNumberValueToArray = () => Transform(transformCommaSeparatedNumberValueToArray);
2485
- const TransformStringValueToBoolean = () => Transform(transformStringToBoolean());
2486
-
2487
- function transformAndValidateObject(config) {
2488
- const transformToResult = transformAndValidateObjectResult(config);
2489
- const {
2490
- handleValidationError
2491
- } = config;
2492
- return (input, context) => transformToResult(input, context).then(async x => {
2493
- const object = x.object;
2494
- let result;
2495
- if (x.success) {
2496
- result = x.result;
2497
- } else {
2498
- result = await handleValidationError(x.validationErrors);
2499
- }
2500
- return {
2501
- object,
2502
- result
2503
- };
2504
- });
2505
- }
2506
- /**
2507
- * Creates a new TransformAndValidateObjectFactory.
2508
- *
2509
- * @param defaults
2510
- * @returns
2511
- */
2512
- function transformAndValidateObjectFactory(defaults) {
2513
- const {
2514
- handleValidationError: defaultHandleValidationError,
2515
- optionsForContext,
2516
- defaultValidationOptions
2517
- } = defaults;
2518
- return (classType, fn, handleValidationError) => {
2519
- const config = {
2520
- classType,
2521
- fn,
2522
- handleValidationError: handleValidationError ?? defaultHandleValidationError,
2523
- optionsForContext,
2524
- defaultValidationOptions
2525
- };
2526
- return transformAndValidateObject(config);
2527
- };
2528
- }
2529
- /**
2530
- * Factory function that wraps the input class type and handler function to first transform the input object to a the given class, and then validate it.
2531
- *
2532
- * @param classType
2533
- * @param fn
2534
- * @returns
2535
- */
2536
- function transformAndValidateObjectResult(config) {
2537
- const {
2538
- defaultValidationOptions,
2539
- classType,
2540
- fn,
2541
- optionsForContext: inputOptionsForContext
2542
- } = config;
2543
- const optionsForContext = inputOptionsForContext ?? (() => ({}));
2544
- return async (input, context) => {
2545
- const {
2546
- transform: transformOptions,
2547
- validate: validateOptions
2548
- } = optionsForContext(context);
2549
- const object = plainToInstance(classType, input, {
2550
- ...transformOptions,
2551
- // Note: Each variable on the target class must be marked with the @Expose() annotation.
2552
- excludeExtraneousValues: true
2553
- });
2554
- const validationErrors = await validate(object, {
2555
- forbidUnknownValues: false,
2556
- // allow classes without annotations by default
2557
- ...defaultValidationOptions,
2558
- ...validateOptions
2559
- });
2560
- if (validationErrors.length) {
2561
- return {
2562
- object,
2563
- validationErrors,
2564
- success: false
2565
- };
2566
- } else {
2567
- const result = await fn(object);
2568
- return {
2569
- object,
2570
- result,
2571
- success: true
2572
- };
2573
- }
2574
- };
2575
- }
2576
-
2577
- function transformAndValidateFunctionResultFactory(defaults) {
2578
- return toTransformAndValidateFunctionResultFactory(transformAndValidateObjectFactory(defaults));
2579
- }
2580
- function toTransformAndValidateFunctionResultFactory(transformAndValidateObjectFactory) {
2581
- return (classType, fn, handleValidationError) => {
2582
- const transformAndValidateObjectFn = transformAndValidateObjectFactory(classType, fn, handleValidationError);
2583
- return (input, context) => {
2584
- return toTransformAndValidateFunctionResult(transformAndValidateObjectFn(input, context));
2585
- };
2586
- };
2587
- }
2588
- function toTransformAndValidateFunctionResult(objectOutput) {
2589
- return mapPromiseOrValue(objectOutput, x => {
2590
- const {
2591
- object,
2592
- result
2593
- } = x;
2594
- const fnResult = result;
2595
- fnResult.params = object;
2596
- return fnResult;
2597
- });
2598
- }
2599
-
2600
- function transformAndValidateResultFactory(defaults) {
2601
- const factory = transformAndValidateObjectFactory(defaults);
2602
- return (classType, fn, handleValidationError) => {
2603
- const transformAndValidateObjectFn = factory(classType, fn, handleValidationError);
2604
- return async (input, context) => {
2605
- const {
2606
- result
2607
- } = await transformAndValidateObjectFn(input, context);
2608
- return result;
2609
1154
  };
2610
- };
2611
- }
2612
-
2613
- /**
2614
- * isISO8601DayString validator
2615
- */
2616
- function IsISO8601DayString(validationOptions) {
2617
- return function (object, propertyName) {
2618
- registerDecorator({
2619
- name: 'isISO8601DayString',
2620
- target: object.constructor,
2621
- propertyName: propertyName,
2622
- options: validationOptions,
2623
- validator: {
2624
- validate: isISO8601DayString,
2625
- defaultMessage: buildMessage((eachPrefix, args) => eachPrefix + `$property value of "${args?.value}" is not a ISO8601DayString.`, validationOptions)
2626
- }
2627
- });
2628
- };
2629
- }
2630
-
2631
- /**
2632
- * isMinuteOfDay validator
2633
- */
2634
- function IsMinuteOfDay(validationOptions) {
2635
- return function (object, propertyName) {
2636
- registerDecorator({
2637
- name: 'isMinuteOfDay',
2638
- target: object.constructor,
2639
- propertyName: propertyName,
2640
- options: validationOptions,
2641
- validator: {
2642
- validate: isMinuteOfDay,
2643
- defaultMessage: buildMessage((eachPrefix, args) => eachPrefix + `$property value of "${args?.value}" is not a valid minute of the day.`, validationOptions)
2644
- }
2645
- });
2646
- };
2647
- }
2648
-
2649
- /**
2650
- * isE164PhoneNumber validator that does not allowed extensions.
2651
- */
2652
- function IsE164PhoneNumber(validationOptions) {
2653
- return function (object, propertyName) {
2654
- registerDecorator({
2655
- name: 'isE164PhoneNumber',
2656
- target: object.constructor,
2657
- propertyName: propertyName,
2658
- options: validationOptions,
2659
- validator: {
2660
- validate: x => isE164PhoneNumber(x, false),
2661
- defaultMessage: buildMessage((eachPrefix, args) => eachPrefix + `$property value of "${args?.value}" is not a E164PhoneNumber with no extension.`, validationOptions)
2662
- }
2663
- });
2664
- };
2665
- }
2666
- /**
2667
- * isE164PhoneNumber validator that allows extensions.
2668
- *
2669
- * @param validationOptions
2670
- * @returns
2671
- */
2672
- function IsE164PhoneNumberWithOptionalExtension(validationOptions) {
2673
- return function (object, propertyName) {
2674
- registerDecorator({
2675
- name: 'isE164PhoneNumber',
2676
- target: object.constructor,
2677
- propertyName: propertyName,
2678
- options: validationOptions,
2679
- validator: {
2680
- validate: x => isE164PhoneNumber(x, true),
2681
- defaultMessage: buildMessage((eachPrefix, args) => eachPrefix + `$property value of "${args?.value}" is not an E164PhoneNumber or has an invalid extension.`, validationOptions)
2682
- }
2683
- });
2684
- };
2685
- }
2686
- /**
2687
- * isE164PhoneNumberWithExtension validator
2688
- *
2689
- * @param validationOptions
2690
- * @returns
2691
- */
2692
- function IsE164PhoneNumberWithExtension(validationOptions) {
2693
- return function (object, propertyName) {
2694
- registerDecorator({
2695
- name: 'isE164PhoneNumberWithExtension',
2696
- target: object.constructor,
2697
- propertyName: propertyName,
2698
- options: validationOptions,
2699
- validator: {
2700
- validate: isE164PhoneNumberWithExtension,
2701
- defaultMessage: buildMessage((eachPrefix, args) => eachPrefix + `$property value of "${args?.value}" is not a E164PhoneNumberWithExtension.`, validationOptions)
2702
- }
2703
- });
2704
- };
2705
- }
2706
-
2707
- /**
2708
- * isUniqueKeyedFunction validator
2709
- */
2710
- function IsUniqueKeyed(readKey, validationOptions) {
2711
- const isUniqueKeyed = isUniqueKeyedFunction(readKey);
2712
- return function (object, propertyName) {
2713
- registerDecorator({
2714
- name: 'isUniqueKeyed',
2715
- target: object.constructor,
2716
- propertyName: propertyName,
2717
- options: validationOptions,
2718
- validator: {
2719
- validate: isUniqueKeyed,
2720
- defaultMessage: buildMessage((eachPrefix, args) => eachPrefix + `$property value has one or more values with the same key. Keys must be unique.`, validationOptions)
2721
- }
2722
- });
2723
- };
2724
- }
2725
-
2726
- /**
2727
- * isWebsiteUrl validator
2728
- */
2729
- function IsWebsiteUrl(validationOptions) {
2730
- return function (object, propertyName) {
2731
- registerDecorator({
2732
- name: 'isWebsiteUrl',
2733
- target: object.constructor,
2734
- propertyName: propertyName,
2735
- options: validationOptions,
2736
- validator: {
2737
- validate: isWebsiteUrl,
2738
- defaultMessage: buildMessage((eachPrefix, args) => eachPrefix + `$property value of "${args?.value}" is not a valid website url.`, validationOptions)
2739
- }
2740
- });
2741
- };
2742
1155
  }
2743
1156
  /**
2744
1157
  * isWebsiteUrlWithPrefix validator
2745
1158
  */
2746
1159
  function IsWebsiteUrlWithPrefix(validationOptions) {
2747
- return function (object, propertyName) {
2748
- registerDecorator({
2749
- name: 'isWebsiteUrlWithPrefix',
2750
- target: object.constructor,
2751
- propertyName: propertyName,
2752
- options: validationOptions,
2753
- validator: {
2754
- validate: isWebsiteUrlWithPrefix,
2755
- defaultMessage: buildMessage((eachPrefix, args) => eachPrefix + `$property value of "${args?.value}" is not a valid website url that starts with a http/https prefix.`, validationOptions)
2756
- }
2757
- });
2758
- };
1160
+ return function (object, propertyName) {
1161
+ registerDecorator({
1162
+ name: 'isWebsiteUrlWithPrefix',
1163
+ target: object.constructor,
1164
+ propertyName: propertyName,
1165
+ options: validationOptions,
1166
+ validator: {
1167
+ validate: isWebsiteUrlWithPrefix,
1168
+ defaultMessage: buildMessage((eachPrefix, args) => eachPrefix + `$property value of "${args?.value}" is not a valid website url that starts with a http/https prefix.`, validationOptions)
1169
+ }
1170
+ });
1171
+ };
2759
1172
  }
2760
1173
 
2761
1174
  export { ADDRESS_CITY_MAX_LENGTH, ADDRESS_COUNTRY_MAX_LENGTH, ADDRESS_LINE_MAX_LENGTH, ADDRESS_STATE_CODE_MAX_LENGTH, ADDRESS_STATE_MAX_LENGTH, ADDRESS_ZIP_MAX_LENGTH, AbstractModelPermissionService, AbstractUnitedStatesAddressWithoutStateParams, CASHAPP_BASE_URL, CASHAPP_USERNAME_PREFIX, CASHAPP_WEBSITE_LINK_TYPE, EMAIL_URL_WEBSITE_LINK_TYPE, FACEBOOK_BASE_URL, FACEBOOK_WEBSITE_LINK_TYPE, FULL_ACCESS_ROLE_KEY, GRANTED_ADMIN_ROLE_KEY, GRANTED_DELETE_ROLE_KEY, GRANTED_OWNER_ROLE_KEY, GRANTED_READ_ROLE_KEY, GRANTED_SYS_ADMIN_ROLE_KEY, GRANTED_UPDATE_ROLE_KEY, GrantedRoleMapReaderInstance, INSTAGRAM_BASE_URL, INSTAGRAM_WEBSITE_LINK_TYPE, IsE164PhoneNumber, IsE164PhoneNumberWithExtension, IsE164PhoneNumberWithOptionalExtension, IsISO8601DayString, IsMinuteOfDay, IsUniqueKeyed, IsWebsiteUrl, IsWebsiteUrlWithPrefix, NO_ACCESS_ROLE_KEY, PAYPAL_BASE_URL, PAYPAL_WEBSITE_LINK_TYPE, PHONE_URL_WEBSITE_LINK_TYPE, SNAPCHAT_BASE_URL, SNAPCHAT_WEBSITE_LINK_ISOLATE_PROFILE_ID, SNAPCHAT_WEBSITE_LINK_TYPE, SPOTIFY_BASE_URL, SPOTIFY_WEBSITE_LINK_ISOLATE_PROFILE_ID, SPOTIFY_WEBSITE_LINK_TYPE, TIKTOK_BASE_URL, TIKTOK_USERNAME_PREFIX, TIKTOK_WEBSITE_LINK_TYPE, TWITTER_BASE_URL, TWITTER_WEBSITE_LINK_TYPE, TransformCommaSeparatedNumberValueToArray, TransformCommaSeparatedStringValueToArray, TransformCommaSeparatedValueToArray, TransformStringValueToBoolean, UNKNOWN_WEBSITE_LINK_TYPE, UnitedStatesAddressWithStateCodeParams, UnitedStatesAddressWithStateStringParams, VENMO_BASE_URL, VENMO_WEBSITE_LINK_ISOLATE_PROFILE_ID, VENMO_WEBSITE_LINK_TYPE, WEBSITE_FILE_LINK_DATA_MAX_LENGTH, WEBSITE_FILE_LINK_DATA_REGEX, WEBSITE_FILE_LINK_ENCODE_SEPARATOR, WEBSITE_FILE_LINK_MIME_TYPE_MAX_LENGTH, WEBSITE_FILE_LINK_MIME_TYPE_REGEX, WEBSITE_FILE_LINK_NAME_MAX_LENGTH, WEBSITE_FILE_LINK_TYPE_MAX_LENGTH, WEBSITE_FILE_LINK_TYPE_REGEX, WEBSITE_FILE_LINK_WEBSITE_LINK_TYPE, WEBSITE_LINK_ENCODED_DATA_MAX_LENGTH, WEBSITE_LINK_ISOLATE_BASE_URL_PROFILE_ID, WEBSITE_LINK_TYPE_MAX_LENGTH, WEBSITE_LINK_TYPE_REGEX, WEBSITE_URL_WEBSITE_LINK_TYPE, WebsiteFileLink, WebsiteLink, YOUTUBE_BASE_URL, YOUTUBE_WEBSITE_LINK_ISOLATE_PROFILE_ID, YOUTUBE_WEBSITE_LINK_TYPE, basicSyncEntityCommonTypeSynchronizerInstanceFactory, cashappProfileUrl, cashappProfileUrlToWebsiteLink, contextGrantedModelRoles, decodeWebsiteLinkEncodedDataToWebsiteFileLink, emailAddressToWebsiteLink, encodeWebsiteFileLinkToWebsiteLinkEncodedData, facebookProfileUrl, facebookProfileUrlToWebsiteLink, fullAccessGrantedModelRoles, fullAccessRoleMap, grantedRoleKeysMapFromArray, grantedRoleMapReader, instagramProfileUrl, instagramProfileUrlToWebsiteLink, isFullAccessRoleMap, isGrantedAdminLevelRole, isNoAccessRoleMap, isValidWebsiteLinkType, noAccessContextGrantedModelRoles, noAccessRoleMap, paypalProfileUrl, paypalProfileUrlToWebsiteLink, phoneNumberToWebsiteLink, snapchatProfileUrl, snapchatProfileUrlToWebsiteLink, spotifyProfileUrl, spotifyProfileUrlToWebsiteLink, syncEntityCommonTypeIdPairFactory, syncEntityFactory, syncEntitySynchronizer, tiktokProfileUrl, tiktokProfileUrlToWebsiteLink, toTransformAndValidateFunctionResult, toTransformAndValidateFunctionResultFactory, transformAndValidateFunctionResultFactory, transformAndValidateObject, transformAndValidateObjectFactory, transformAndValidateObjectResult, transformAndValidateResultFactory, transformCommaSeparatedNumberValueToArray, transformCommaSeparatedStringValueToArray, transformCommaSeparatedValueToArray, transformStringToBoolean, twitterProfileUrl, twitterProfileUrlToWebsiteLink, usernameFromUsernameOrWebsiteWithBaseUrlUsername, usernameFromUsernameOrWebsiteWithOneOffBaseUrlUsername, usernameOrWebsiteUrlToWebsiteUrl, venmoProfileUrl, venmoProfileUrlToWebsiteLink, websiteFileLinkToWebsiteLink, websiteLinkToWebsiteLinkFile, websiteUrlToWebsiteLink, youtubeProfileUrl, youtubeProfileUrlToWebsiteLink };