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