@canton-network/core-token-standard 1.1.1 → 1.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs CHANGED
@@ -1,12 +1,32 @@
1
1
  'use strict';
2
2
 
3
3
  var createClient = require('openapi-fetch');
4
- var require$$1 = require('lodash');
4
+ var jsonTypeValidation = require('@mojotech/json-type-validation');
5
+ var types = require('@daml/types');
5
6
 
6
7
  function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
7
8
 
9
+ function _interopNamespace(e) {
10
+ if (e && e.__esModule) return e;
11
+ var n = Object.create(null);
12
+ if (e) {
13
+ Object.keys(e).forEach(function (k) {
14
+ if (k !== 'default') {
15
+ var d = Object.getOwnPropertyDescriptor(e, k);
16
+ Object.defineProperty(n, k, d.get ? d : {
17
+ enumerable: true,
18
+ get: function () { return e[k]; }
19
+ });
20
+ }
21
+ });
22
+ }
23
+ n.default = e;
24
+ return Object.freeze(n);
25
+ }
26
+
8
27
  var createClient__default = /*#__PURE__*/_interopDefault(createClient);
9
- var require$$1__default = /*#__PURE__*/_interopDefault(require$$1);
28
+ var jsonTypeValidation__namespace = /*#__PURE__*/_interopNamespace(jsonTypeValidation);
29
+ var types__namespace = /*#__PURE__*/_interopNamespace(types);
10
30
 
11
31
  // Copyright (c) 2025-2026 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved.
12
32
  // SPDX-License-Identifier: Apache-2.0
@@ -75,8 +95,6 @@ const MERGE_DELEGATION_PROPOSAL_TEMPLATE_ID = '#splice-util-token-standard-walle
75
95
  const MERGE_DELEGATION_TEMPLATE_ID = '#splice-util-token-standard-wallet:Splice.Util.Token.Wallet.MergeDelegation:MergeDelegation';
76
96
  const MERGE_DELEGATION_BATCH_MERGE_UTILITY = '#splice-util-token-standard-wallet:Splice.Util.Token.Wallet.MergeDelegation:BatchMergeUtility';
77
97
 
78
- var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
79
-
80
98
  function getAugmentedNamespace(n) {
81
99
  if (Object.prototype.hasOwnProperty.call(n, '__esModule')) return n;
82
100
  var f = n.default;
@@ -118,3108 +136,9 @@ var AllocationInstructionV1$1 = {};
118
136
 
119
137
  var module$8 = {};
120
138
 
121
- var lodash_isequal = {exports: {}};
122
-
123
- /**
124
- * Lodash (Custom Build) <https://lodash.com/>
125
- * Build: `lodash modularize exports="npm" -o ./`
126
- * Copyright JS Foundation and other contributors <https://js.foundation/>
127
- * Released under MIT license <https://lodash.com/license>
128
- * Based on Underscore.js 1.8.3 <http://underscorejs.org/LICENSE>
129
- * Copyright Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
130
- */
131
- lodash_isequal.exports;
132
-
133
- var hasRequiredLodash_isequal;
134
-
135
- function requireLodash_isequal () {
136
- if (hasRequiredLodash_isequal) return lodash_isequal.exports;
137
- hasRequiredLodash_isequal = 1;
138
- (function (module, exports$1) {
139
- /** Used as the size to enable large array optimizations. */
140
- var LARGE_ARRAY_SIZE = 200;
141
-
142
- /** Used to stand-in for `undefined` hash values. */
143
- var HASH_UNDEFINED = '__lodash_hash_undefined__';
144
-
145
- /** Used to compose bitmasks for value comparisons. */
146
- var COMPARE_PARTIAL_FLAG = 1,
147
- COMPARE_UNORDERED_FLAG = 2;
148
-
149
- /** Used as references for various `Number` constants. */
150
- var MAX_SAFE_INTEGER = 9007199254740991;
151
-
152
- /** `Object#toString` result references. */
153
- var argsTag = '[object Arguments]',
154
- arrayTag = '[object Array]',
155
- asyncTag = '[object AsyncFunction]',
156
- boolTag = '[object Boolean]',
157
- dateTag = '[object Date]',
158
- errorTag = '[object Error]',
159
- funcTag = '[object Function]',
160
- genTag = '[object GeneratorFunction]',
161
- mapTag = '[object Map]',
162
- numberTag = '[object Number]',
163
- nullTag = '[object Null]',
164
- objectTag = '[object Object]',
165
- promiseTag = '[object Promise]',
166
- proxyTag = '[object Proxy]',
167
- regexpTag = '[object RegExp]',
168
- setTag = '[object Set]',
169
- stringTag = '[object String]',
170
- symbolTag = '[object Symbol]',
171
- undefinedTag = '[object Undefined]',
172
- weakMapTag = '[object WeakMap]';
173
-
174
- var arrayBufferTag = '[object ArrayBuffer]',
175
- dataViewTag = '[object DataView]',
176
- float32Tag = '[object Float32Array]',
177
- float64Tag = '[object Float64Array]',
178
- int8Tag = '[object Int8Array]',
179
- int16Tag = '[object Int16Array]',
180
- int32Tag = '[object Int32Array]',
181
- uint8Tag = '[object Uint8Array]',
182
- uint8ClampedTag = '[object Uint8ClampedArray]',
183
- uint16Tag = '[object Uint16Array]',
184
- uint32Tag = '[object Uint32Array]';
185
-
186
- /**
187
- * Used to match `RegExp`
188
- * [syntax characters](http://ecma-international.org/ecma-262/7.0/#sec-patterns).
189
- */
190
- var reRegExpChar = /[\\^$.*+?()[\]{}|]/g;
191
-
192
- /** Used to detect host constructors (Safari). */
193
- var reIsHostCtor = /^\[object .+?Constructor\]$/;
194
-
195
- /** Used to detect unsigned integer values. */
196
- var reIsUint = /^(?:0|[1-9]\d*)$/;
197
-
198
- /** Used to identify `toStringTag` values of typed arrays. */
199
- var typedArrayTags = {};
200
- typedArrayTags[float32Tag] = typedArrayTags[float64Tag] =
201
- typedArrayTags[int8Tag] = typedArrayTags[int16Tag] =
202
- typedArrayTags[int32Tag] = typedArrayTags[uint8Tag] =
203
- typedArrayTags[uint8ClampedTag] = typedArrayTags[uint16Tag] =
204
- typedArrayTags[uint32Tag] = true;
205
- typedArrayTags[argsTag] = typedArrayTags[arrayTag] =
206
- typedArrayTags[arrayBufferTag] = typedArrayTags[boolTag] =
207
- typedArrayTags[dataViewTag] = typedArrayTags[dateTag] =
208
- typedArrayTags[errorTag] = typedArrayTags[funcTag] =
209
- typedArrayTags[mapTag] = typedArrayTags[numberTag] =
210
- typedArrayTags[objectTag] = typedArrayTags[regexpTag] =
211
- typedArrayTags[setTag] = typedArrayTags[stringTag] =
212
- typedArrayTags[weakMapTag] = false;
213
-
214
- /** Detect free variable `global` from Node.js. */
215
- var freeGlobal = typeof commonjsGlobal == 'object' && commonjsGlobal && commonjsGlobal.Object === Object && commonjsGlobal;
216
-
217
- /** Detect free variable `self`. */
218
- var freeSelf = typeof self == 'object' && self && self.Object === Object && self;
219
-
220
- /** Used as a reference to the global object. */
221
- var root = freeGlobal || freeSelf || Function('return this')();
222
-
223
- /** Detect free variable `exports`. */
224
- var freeExports = exports$1 && !exports$1.nodeType && exports$1;
225
-
226
- /** Detect free variable `module`. */
227
- var freeModule = freeExports && 'object' == 'object' && module && !module.nodeType && module;
228
-
229
- /** Detect the popular CommonJS extension `module.exports`. */
230
- var moduleExports = freeModule && freeModule.exports === freeExports;
231
-
232
- /** Detect free variable `process` from Node.js. */
233
- var freeProcess = moduleExports && freeGlobal.process;
234
-
235
- /** Used to access faster Node.js helpers. */
236
- var nodeUtil = (function() {
237
- try {
238
- return freeProcess && freeProcess.binding && freeProcess.binding('util');
239
- } catch (e) {}
240
- }());
241
-
242
- /* Node.js helper references. */
243
- var nodeIsTypedArray = nodeUtil && nodeUtil.isTypedArray;
244
-
245
- /**
246
- * A specialized version of `_.filter` for arrays without support for
247
- * iteratee shorthands.
248
- *
249
- * @private
250
- * @param {Array} [array] The array to iterate over.
251
- * @param {Function} predicate The function invoked per iteration.
252
- * @returns {Array} Returns the new filtered array.
253
- */
254
- function arrayFilter(array, predicate) {
255
- var index = -1,
256
- length = array == null ? 0 : array.length,
257
- resIndex = 0,
258
- result = [];
259
-
260
- while (++index < length) {
261
- var value = array[index];
262
- if (predicate(value, index, array)) {
263
- result[resIndex++] = value;
264
- }
265
- }
266
- return result;
267
- }
268
-
269
- /**
270
- * Appends the elements of `values` to `array`.
271
- *
272
- * @private
273
- * @param {Array} array The array to modify.
274
- * @param {Array} values The values to append.
275
- * @returns {Array} Returns `array`.
276
- */
277
- function arrayPush(array, values) {
278
- var index = -1,
279
- length = values.length,
280
- offset = array.length;
281
-
282
- while (++index < length) {
283
- array[offset + index] = values[index];
284
- }
285
- return array;
286
- }
287
-
288
- /**
289
- * A specialized version of `_.some` for arrays without support for iteratee
290
- * shorthands.
291
- *
292
- * @private
293
- * @param {Array} [array] The array to iterate over.
294
- * @param {Function} predicate The function invoked per iteration.
295
- * @returns {boolean} Returns `true` if any element passes the predicate check,
296
- * else `false`.
297
- */
298
- function arraySome(array, predicate) {
299
- var index = -1,
300
- length = array == null ? 0 : array.length;
301
-
302
- while (++index < length) {
303
- if (predicate(array[index], index, array)) {
304
- return true;
305
- }
306
- }
307
- return false;
308
- }
309
-
310
- /**
311
- * The base implementation of `_.times` without support for iteratee shorthands
312
- * or max array length checks.
313
- *
314
- * @private
315
- * @param {number} n The number of times to invoke `iteratee`.
316
- * @param {Function} iteratee The function invoked per iteration.
317
- * @returns {Array} Returns the array of results.
318
- */
319
- function baseTimes(n, iteratee) {
320
- var index = -1,
321
- result = Array(n);
322
-
323
- while (++index < n) {
324
- result[index] = iteratee(index);
325
- }
326
- return result;
327
- }
328
-
329
- /**
330
- * The base implementation of `_.unary` without support for storing metadata.
331
- *
332
- * @private
333
- * @param {Function} func The function to cap arguments for.
334
- * @returns {Function} Returns the new capped function.
335
- */
336
- function baseUnary(func) {
337
- return function(value) {
338
- return func(value);
339
- };
340
- }
341
-
342
- /**
343
- * Checks if a `cache` value for `key` exists.
344
- *
345
- * @private
346
- * @param {Object} cache The cache to query.
347
- * @param {string} key The key of the entry to check.
348
- * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
349
- */
350
- function cacheHas(cache, key) {
351
- return cache.has(key);
352
- }
353
-
354
- /**
355
- * Gets the value at `key` of `object`.
356
- *
357
- * @private
358
- * @param {Object} [object] The object to query.
359
- * @param {string} key The key of the property to get.
360
- * @returns {*} Returns the property value.
361
- */
362
- function getValue(object, key) {
363
- return object == null ? undefined : object[key];
364
- }
365
-
366
- /**
367
- * Converts `map` to its key-value pairs.
368
- *
369
- * @private
370
- * @param {Object} map The map to convert.
371
- * @returns {Array} Returns the key-value pairs.
372
- */
373
- function mapToArray(map) {
374
- var index = -1,
375
- result = Array(map.size);
376
-
377
- map.forEach(function(value, key) {
378
- result[++index] = [key, value];
379
- });
380
- return result;
381
- }
382
-
383
- /**
384
- * Creates a unary function that invokes `func` with its argument transformed.
385
- *
386
- * @private
387
- * @param {Function} func The function to wrap.
388
- * @param {Function} transform The argument transform.
389
- * @returns {Function} Returns the new function.
390
- */
391
- function overArg(func, transform) {
392
- return function(arg) {
393
- return func(transform(arg));
394
- };
395
- }
396
-
397
- /**
398
- * Converts `set` to an array of its values.
399
- *
400
- * @private
401
- * @param {Object} set The set to convert.
402
- * @returns {Array} Returns the values.
403
- */
404
- function setToArray(set) {
405
- var index = -1,
406
- result = Array(set.size);
407
-
408
- set.forEach(function(value) {
409
- result[++index] = value;
410
- });
411
- return result;
412
- }
413
-
414
- /** Used for built-in method references. */
415
- var arrayProto = Array.prototype,
416
- funcProto = Function.prototype,
417
- objectProto = Object.prototype;
418
-
419
- /** Used to detect overreaching core-js shims. */
420
- var coreJsData = root['__core-js_shared__'];
421
-
422
- /** Used to resolve the decompiled source of functions. */
423
- var funcToString = funcProto.toString;
424
-
425
- /** Used to check objects for own properties. */
426
- var hasOwnProperty = objectProto.hasOwnProperty;
427
-
428
- /** Used to detect methods masquerading as native. */
429
- var maskSrcKey = (function() {
430
- var uid = /[^.]+$/.exec(coreJsData && coreJsData.keys && coreJsData.keys.IE_PROTO || '');
431
- return uid ? ('Symbol(src)_1.' + uid) : '';
432
- }());
433
-
434
- /**
435
- * Used to resolve the
436
- * [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring)
437
- * of values.
438
- */
439
- var nativeObjectToString = objectProto.toString;
440
-
441
- /** Used to detect if a method is native. */
442
- var reIsNative = RegExp('^' +
443
- funcToString.call(hasOwnProperty).replace(reRegExpChar, '\\$&')
444
- .replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g, '$1.*?') + '$'
445
- );
446
-
447
- /** Built-in value references. */
448
- var Buffer = moduleExports ? root.Buffer : undefined,
449
- Symbol = root.Symbol,
450
- Uint8Array = root.Uint8Array,
451
- propertyIsEnumerable = objectProto.propertyIsEnumerable,
452
- splice = arrayProto.splice,
453
- symToStringTag = Symbol ? Symbol.toStringTag : undefined;
454
-
455
- /* Built-in method references for those with the same name as other `lodash` methods. */
456
- var nativeGetSymbols = Object.getOwnPropertySymbols,
457
- nativeIsBuffer = Buffer ? Buffer.isBuffer : undefined,
458
- nativeKeys = overArg(Object.keys, Object);
459
-
460
- /* Built-in method references that are verified to be native. */
461
- var DataView = getNative(root, 'DataView'),
462
- Map = getNative(root, 'Map'),
463
- Promise = getNative(root, 'Promise'),
464
- Set = getNative(root, 'Set'),
465
- WeakMap = getNative(root, 'WeakMap'),
466
- nativeCreate = getNative(Object, 'create');
467
-
468
- /** Used to detect maps, sets, and weakmaps. */
469
- var dataViewCtorString = toSource(DataView),
470
- mapCtorString = toSource(Map),
471
- promiseCtorString = toSource(Promise),
472
- setCtorString = toSource(Set),
473
- weakMapCtorString = toSource(WeakMap);
474
-
475
- /** Used to convert symbols to primitives and strings. */
476
- var symbolProto = Symbol ? Symbol.prototype : undefined,
477
- symbolValueOf = symbolProto ? symbolProto.valueOf : undefined;
478
-
479
- /**
480
- * Creates a hash object.
481
- *
482
- * @private
483
- * @constructor
484
- * @param {Array} [entries] The key-value pairs to cache.
485
- */
486
- function Hash(entries) {
487
- var index = -1,
488
- length = entries == null ? 0 : entries.length;
489
-
490
- this.clear();
491
- while (++index < length) {
492
- var entry = entries[index];
493
- this.set(entry[0], entry[1]);
494
- }
495
- }
496
-
497
- /**
498
- * Removes all key-value entries from the hash.
499
- *
500
- * @private
501
- * @name clear
502
- * @memberOf Hash
503
- */
504
- function hashClear() {
505
- this.__data__ = nativeCreate ? nativeCreate(null) : {};
506
- this.size = 0;
507
- }
508
-
509
- /**
510
- * Removes `key` and its value from the hash.
511
- *
512
- * @private
513
- * @name delete
514
- * @memberOf Hash
515
- * @param {Object} hash The hash to modify.
516
- * @param {string} key The key of the value to remove.
517
- * @returns {boolean} Returns `true` if the entry was removed, else `false`.
518
- */
519
- function hashDelete(key) {
520
- var result = this.has(key) && delete this.__data__[key];
521
- this.size -= result ? 1 : 0;
522
- return result;
523
- }
524
-
525
- /**
526
- * Gets the hash value for `key`.
527
- *
528
- * @private
529
- * @name get
530
- * @memberOf Hash
531
- * @param {string} key The key of the value to get.
532
- * @returns {*} Returns the entry value.
533
- */
534
- function hashGet(key) {
535
- var data = this.__data__;
536
- if (nativeCreate) {
537
- var result = data[key];
538
- return result === HASH_UNDEFINED ? undefined : result;
539
- }
540
- return hasOwnProperty.call(data, key) ? data[key] : undefined;
541
- }
542
-
543
- /**
544
- * Checks if a hash value for `key` exists.
545
- *
546
- * @private
547
- * @name has
548
- * @memberOf Hash
549
- * @param {string} key The key of the entry to check.
550
- * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
551
- */
552
- function hashHas(key) {
553
- var data = this.__data__;
554
- return nativeCreate ? (data[key] !== undefined) : hasOwnProperty.call(data, key);
555
- }
556
-
557
- /**
558
- * Sets the hash `key` to `value`.
559
- *
560
- * @private
561
- * @name set
562
- * @memberOf Hash
563
- * @param {string} key The key of the value to set.
564
- * @param {*} value The value to set.
565
- * @returns {Object} Returns the hash instance.
566
- */
567
- function hashSet(key, value) {
568
- var data = this.__data__;
569
- this.size += this.has(key) ? 0 : 1;
570
- data[key] = (nativeCreate && value === undefined) ? HASH_UNDEFINED : value;
571
- return this;
572
- }
573
-
574
- // Add methods to `Hash`.
575
- Hash.prototype.clear = hashClear;
576
- Hash.prototype['delete'] = hashDelete;
577
- Hash.prototype.get = hashGet;
578
- Hash.prototype.has = hashHas;
579
- Hash.prototype.set = hashSet;
580
-
581
- /**
582
- * Creates an list cache object.
583
- *
584
- * @private
585
- * @constructor
586
- * @param {Array} [entries] The key-value pairs to cache.
587
- */
588
- function ListCache(entries) {
589
- var index = -1,
590
- length = entries == null ? 0 : entries.length;
591
-
592
- this.clear();
593
- while (++index < length) {
594
- var entry = entries[index];
595
- this.set(entry[0], entry[1]);
596
- }
597
- }
598
-
599
- /**
600
- * Removes all key-value entries from the list cache.
601
- *
602
- * @private
603
- * @name clear
604
- * @memberOf ListCache
605
- */
606
- function listCacheClear() {
607
- this.__data__ = [];
608
- this.size = 0;
609
- }
610
-
611
- /**
612
- * Removes `key` and its value from the list cache.
613
- *
614
- * @private
615
- * @name delete
616
- * @memberOf ListCache
617
- * @param {string} key The key of the value to remove.
618
- * @returns {boolean} Returns `true` if the entry was removed, else `false`.
619
- */
620
- function listCacheDelete(key) {
621
- var data = this.__data__,
622
- index = assocIndexOf(data, key);
623
-
624
- if (index < 0) {
625
- return false;
626
- }
627
- var lastIndex = data.length - 1;
628
- if (index == lastIndex) {
629
- data.pop();
630
- } else {
631
- splice.call(data, index, 1);
632
- }
633
- --this.size;
634
- return true;
635
- }
636
-
637
- /**
638
- * Gets the list cache value for `key`.
639
- *
640
- * @private
641
- * @name get
642
- * @memberOf ListCache
643
- * @param {string} key The key of the value to get.
644
- * @returns {*} Returns the entry value.
645
- */
646
- function listCacheGet(key) {
647
- var data = this.__data__,
648
- index = assocIndexOf(data, key);
649
-
650
- return index < 0 ? undefined : data[index][1];
651
- }
652
-
653
- /**
654
- * Checks if a list cache value for `key` exists.
655
- *
656
- * @private
657
- * @name has
658
- * @memberOf ListCache
659
- * @param {string} key The key of the entry to check.
660
- * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
661
- */
662
- function listCacheHas(key) {
663
- return assocIndexOf(this.__data__, key) > -1;
664
- }
665
-
666
- /**
667
- * Sets the list cache `key` to `value`.
668
- *
669
- * @private
670
- * @name set
671
- * @memberOf ListCache
672
- * @param {string} key The key of the value to set.
673
- * @param {*} value The value to set.
674
- * @returns {Object} Returns the list cache instance.
675
- */
676
- function listCacheSet(key, value) {
677
- var data = this.__data__,
678
- index = assocIndexOf(data, key);
679
-
680
- if (index < 0) {
681
- ++this.size;
682
- data.push([key, value]);
683
- } else {
684
- data[index][1] = value;
685
- }
686
- return this;
687
- }
688
-
689
- // Add methods to `ListCache`.
690
- ListCache.prototype.clear = listCacheClear;
691
- ListCache.prototype['delete'] = listCacheDelete;
692
- ListCache.prototype.get = listCacheGet;
693
- ListCache.prototype.has = listCacheHas;
694
- ListCache.prototype.set = listCacheSet;
695
-
696
- /**
697
- * Creates a map cache object to store key-value pairs.
698
- *
699
- * @private
700
- * @constructor
701
- * @param {Array} [entries] The key-value pairs to cache.
702
- */
703
- function MapCache(entries) {
704
- var index = -1,
705
- length = entries == null ? 0 : entries.length;
706
-
707
- this.clear();
708
- while (++index < length) {
709
- var entry = entries[index];
710
- this.set(entry[0], entry[1]);
711
- }
712
- }
713
-
714
- /**
715
- * Removes all key-value entries from the map.
716
- *
717
- * @private
718
- * @name clear
719
- * @memberOf MapCache
720
- */
721
- function mapCacheClear() {
722
- this.size = 0;
723
- this.__data__ = {
724
- 'hash': new Hash,
725
- 'map': new (Map || ListCache),
726
- 'string': new Hash
727
- };
728
- }
729
-
730
- /**
731
- * Removes `key` and its value from the map.
732
- *
733
- * @private
734
- * @name delete
735
- * @memberOf MapCache
736
- * @param {string} key The key of the value to remove.
737
- * @returns {boolean} Returns `true` if the entry was removed, else `false`.
738
- */
739
- function mapCacheDelete(key) {
740
- var result = getMapData(this, key)['delete'](key);
741
- this.size -= result ? 1 : 0;
742
- return result;
743
- }
744
-
745
- /**
746
- * Gets the map value for `key`.
747
- *
748
- * @private
749
- * @name get
750
- * @memberOf MapCache
751
- * @param {string} key The key of the value to get.
752
- * @returns {*} Returns the entry value.
753
- */
754
- function mapCacheGet(key) {
755
- return getMapData(this, key).get(key);
756
- }
757
-
758
- /**
759
- * Checks if a map value for `key` exists.
760
- *
761
- * @private
762
- * @name has
763
- * @memberOf MapCache
764
- * @param {string} key The key of the entry to check.
765
- * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
766
- */
767
- function mapCacheHas(key) {
768
- return getMapData(this, key).has(key);
769
- }
770
-
771
- /**
772
- * Sets the map `key` to `value`.
773
- *
774
- * @private
775
- * @name set
776
- * @memberOf MapCache
777
- * @param {string} key The key of the value to set.
778
- * @param {*} value The value to set.
779
- * @returns {Object} Returns the map cache instance.
780
- */
781
- function mapCacheSet(key, value) {
782
- var data = getMapData(this, key),
783
- size = data.size;
784
-
785
- data.set(key, value);
786
- this.size += data.size == size ? 0 : 1;
787
- return this;
788
- }
789
-
790
- // Add methods to `MapCache`.
791
- MapCache.prototype.clear = mapCacheClear;
792
- MapCache.prototype['delete'] = mapCacheDelete;
793
- MapCache.prototype.get = mapCacheGet;
794
- MapCache.prototype.has = mapCacheHas;
795
- MapCache.prototype.set = mapCacheSet;
796
-
797
- /**
798
- *
799
- * Creates an array cache object to store unique values.
800
- *
801
- * @private
802
- * @constructor
803
- * @param {Array} [values] The values to cache.
804
- */
805
- function SetCache(values) {
806
- var index = -1,
807
- length = values == null ? 0 : values.length;
808
-
809
- this.__data__ = new MapCache;
810
- while (++index < length) {
811
- this.add(values[index]);
812
- }
813
- }
814
-
815
- /**
816
- * Adds `value` to the array cache.
817
- *
818
- * @private
819
- * @name add
820
- * @memberOf SetCache
821
- * @alias push
822
- * @param {*} value The value to cache.
823
- * @returns {Object} Returns the cache instance.
824
- */
825
- function setCacheAdd(value) {
826
- this.__data__.set(value, HASH_UNDEFINED);
827
- return this;
828
- }
829
-
830
- /**
831
- * Checks if `value` is in the array cache.
832
- *
833
- * @private
834
- * @name has
835
- * @memberOf SetCache
836
- * @param {*} value The value to search for.
837
- * @returns {number} Returns `true` if `value` is found, else `false`.
838
- */
839
- function setCacheHas(value) {
840
- return this.__data__.has(value);
841
- }
842
-
843
- // Add methods to `SetCache`.
844
- SetCache.prototype.add = SetCache.prototype.push = setCacheAdd;
845
- SetCache.prototype.has = setCacheHas;
846
-
847
- /**
848
- * Creates a stack cache object to store key-value pairs.
849
- *
850
- * @private
851
- * @constructor
852
- * @param {Array} [entries] The key-value pairs to cache.
853
- */
854
- function Stack(entries) {
855
- var data = this.__data__ = new ListCache(entries);
856
- this.size = data.size;
857
- }
858
-
859
- /**
860
- * Removes all key-value entries from the stack.
861
- *
862
- * @private
863
- * @name clear
864
- * @memberOf Stack
865
- */
866
- function stackClear() {
867
- this.__data__ = new ListCache;
868
- this.size = 0;
869
- }
870
-
871
- /**
872
- * Removes `key` and its value from the stack.
873
- *
874
- * @private
875
- * @name delete
876
- * @memberOf Stack
877
- * @param {string} key The key of the value to remove.
878
- * @returns {boolean} Returns `true` if the entry was removed, else `false`.
879
- */
880
- function stackDelete(key) {
881
- var data = this.__data__,
882
- result = data['delete'](key);
883
-
884
- this.size = data.size;
885
- return result;
886
- }
887
-
888
- /**
889
- * Gets the stack value for `key`.
890
- *
891
- * @private
892
- * @name get
893
- * @memberOf Stack
894
- * @param {string} key The key of the value to get.
895
- * @returns {*} Returns the entry value.
896
- */
897
- function stackGet(key) {
898
- return this.__data__.get(key);
899
- }
900
-
901
- /**
902
- * Checks if a stack value for `key` exists.
903
- *
904
- * @private
905
- * @name has
906
- * @memberOf Stack
907
- * @param {string} key The key of the entry to check.
908
- * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
909
- */
910
- function stackHas(key) {
911
- return this.__data__.has(key);
912
- }
913
-
914
- /**
915
- * Sets the stack `key` to `value`.
916
- *
917
- * @private
918
- * @name set
919
- * @memberOf Stack
920
- * @param {string} key The key of the value to set.
921
- * @param {*} value The value to set.
922
- * @returns {Object} Returns the stack cache instance.
923
- */
924
- function stackSet(key, value) {
925
- var data = this.__data__;
926
- if (data instanceof ListCache) {
927
- var pairs = data.__data__;
928
- if (!Map || (pairs.length < LARGE_ARRAY_SIZE - 1)) {
929
- pairs.push([key, value]);
930
- this.size = ++data.size;
931
- return this;
932
- }
933
- data = this.__data__ = new MapCache(pairs);
934
- }
935
- data.set(key, value);
936
- this.size = data.size;
937
- return this;
938
- }
139
+ var require$$0 = /*@__PURE__*/getAugmentedNamespace(jsonTypeValidation__namespace);
939
140
 
940
- // Add methods to `Stack`.
941
- Stack.prototype.clear = stackClear;
942
- Stack.prototype['delete'] = stackDelete;
943
- Stack.prototype.get = stackGet;
944
- Stack.prototype.has = stackHas;
945
- Stack.prototype.set = stackSet;
946
-
947
- /**
948
- * Creates an array of the enumerable property names of the array-like `value`.
949
- *
950
- * @private
951
- * @param {*} value The value to query.
952
- * @param {boolean} inherited Specify returning inherited property names.
953
- * @returns {Array} Returns the array of property names.
954
- */
955
- function arrayLikeKeys(value, inherited) {
956
- var isArr = isArray(value),
957
- isArg = !isArr && isArguments(value),
958
- isBuff = !isArr && !isArg && isBuffer(value),
959
- isType = !isArr && !isArg && !isBuff && isTypedArray(value),
960
- skipIndexes = isArr || isArg || isBuff || isType,
961
- result = skipIndexes ? baseTimes(value.length, String) : [],
962
- length = result.length;
963
-
964
- for (var key in value) {
965
- if ((hasOwnProperty.call(value, key)) &&
966
- !(skipIndexes && (
967
- // Safari 9 has enumerable `arguments.length` in strict mode.
968
- key == 'length' ||
969
- // Node.js 0.10 has enumerable non-index properties on buffers.
970
- (isBuff && (key == 'offset' || key == 'parent')) ||
971
- // PhantomJS 2 has enumerable non-index properties on typed arrays.
972
- (isType && (key == 'buffer' || key == 'byteLength' || key == 'byteOffset')) ||
973
- // Skip index properties.
974
- isIndex(key, length)
975
- ))) {
976
- result.push(key);
977
- }
978
- }
979
- return result;
980
- }
981
-
982
- /**
983
- * Gets the index at which the `key` is found in `array` of key-value pairs.
984
- *
985
- * @private
986
- * @param {Array} array The array to inspect.
987
- * @param {*} key The key to search for.
988
- * @returns {number} Returns the index of the matched value, else `-1`.
989
- */
990
- function assocIndexOf(array, key) {
991
- var length = array.length;
992
- while (length--) {
993
- if (eq(array[length][0], key)) {
994
- return length;
995
- }
996
- }
997
- return -1;
998
- }
999
-
1000
- /**
1001
- * The base implementation of `getAllKeys` and `getAllKeysIn` which uses
1002
- * `keysFunc` and `symbolsFunc` to get the enumerable property names and
1003
- * symbols of `object`.
1004
- *
1005
- * @private
1006
- * @param {Object} object The object to query.
1007
- * @param {Function} keysFunc The function to get the keys of `object`.
1008
- * @param {Function} symbolsFunc The function to get the symbols of `object`.
1009
- * @returns {Array} Returns the array of property names and symbols.
1010
- */
1011
- function baseGetAllKeys(object, keysFunc, symbolsFunc) {
1012
- var result = keysFunc(object);
1013
- return isArray(object) ? result : arrayPush(result, symbolsFunc(object));
1014
- }
1015
-
1016
- /**
1017
- * The base implementation of `getTag` without fallbacks for buggy environments.
1018
- *
1019
- * @private
1020
- * @param {*} value The value to query.
1021
- * @returns {string} Returns the `toStringTag`.
1022
- */
1023
- function baseGetTag(value) {
1024
- if (value == null) {
1025
- return value === undefined ? undefinedTag : nullTag;
1026
- }
1027
- return (symToStringTag && symToStringTag in Object(value))
1028
- ? getRawTag(value)
1029
- : objectToString(value);
1030
- }
1031
-
1032
- /**
1033
- * The base implementation of `_.isArguments`.
1034
- *
1035
- * @private
1036
- * @param {*} value The value to check.
1037
- * @returns {boolean} Returns `true` if `value` is an `arguments` object,
1038
- */
1039
- function baseIsArguments(value) {
1040
- return isObjectLike(value) && baseGetTag(value) == argsTag;
1041
- }
1042
-
1043
- /**
1044
- * The base implementation of `_.isEqual` which supports partial comparisons
1045
- * and tracks traversed objects.
1046
- *
1047
- * @private
1048
- * @param {*} value The value to compare.
1049
- * @param {*} other The other value to compare.
1050
- * @param {boolean} bitmask The bitmask flags.
1051
- * 1 - Unordered comparison
1052
- * 2 - Partial comparison
1053
- * @param {Function} [customizer] The function to customize comparisons.
1054
- * @param {Object} [stack] Tracks traversed `value` and `other` objects.
1055
- * @returns {boolean} Returns `true` if the values are equivalent, else `false`.
1056
- */
1057
- function baseIsEqual(value, other, bitmask, customizer, stack) {
1058
- if (value === other) {
1059
- return true;
1060
- }
1061
- if (value == null || other == null || (!isObjectLike(value) && !isObjectLike(other))) {
1062
- return value !== value && other !== other;
1063
- }
1064
- return baseIsEqualDeep(value, other, bitmask, customizer, baseIsEqual, stack);
1065
- }
1066
-
1067
- /**
1068
- * A specialized version of `baseIsEqual` for arrays and objects which performs
1069
- * deep comparisons and tracks traversed objects enabling objects with circular
1070
- * references to be compared.
1071
- *
1072
- * @private
1073
- * @param {Object} object The object to compare.
1074
- * @param {Object} other The other object to compare.
1075
- * @param {number} bitmask The bitmask flags. See `baseIsEqual` for more details.
1076
- * @param {Function} customizer The function to customize comparisons.
1077
- * @param {Function} equalFunc The function to determine equivalents of values.
1078
- * @param {Object} [stack] Tracks traversed `object` and `other` objects.
1079
- * @returns {boolean} Returns `true` if the objects are equivalent, else `false`.
1080
- */
1081
- function baseIsEqualDeep(object, other, bitmask, customizer, equalFunc, stack) {
1082
- var objIsArr = isArray(object),
1083
- othIsArr = isArray(other),
1084
- objTag = objIsArr ? arrayTag : getTag(object),
1085
- othTag = othIsArr ? arrayTag : getTag(other);
1086
-
1087
- objTag = objTag == argsTag ? objectTag : objTag;
1088
- othTag = othTag == argsTag ? objectTag : othTag;
1089
-
1090
- var objIsObj = objTag == objectTag,
1091
- othIsObj = othTag == objectTag,
1092
- isSameTag = objTag == othTag;
1093
-
1094
- if (isSameTag && isBuffer(object)) {
1095
- if (!isBuffer(other)) {
1096
- return false;
1097
- }
1098
- objIsArr = true;
1099
- objIsObj = false;
1100
- }
1101
- if (isSameTag && !objIsObj) {
1102
- stack || (stack = new Stack);
1103
- return (objIsArr || isTypedArray(object))
1104
- ? equalArrays(object, other, bitmask, customizer, equalFunc, stack)
1105
- : equalByTag(object, other, objTag, bitmask, customizer, equalFunc, stack);
1106
- }
1107
- if (!(bitmask & COMPARE_PARTIAL_FLAG)) {
1108
- var objIsWrapped = objIsObj && hasOwnProperty.call(object, '__wrapped__'),
1109
- othIsWrapped = othIsObj && hasOwnProperty.call(other, '__wrapped__');
1110
-
1111
- if (objIsWrapped || othIsWrapped) {
1112
- var objUnwrapped = objIsWrapped ? object.value() : object,
1113
- othUnwrapped = othIsWrapped ? other.value() : other;
1114
-
1115
- stack || (stack = new Stack);
1116
- return equalFunc(objUnwrapped, othUnwrapped, bitmask, customizer, stack);
1117
- }
1118
- }
1119
- if (!isSameTag) {
1120
- return false;
1121
- }
1122
- stack || (stack = new Stack);
1123
- return equalObjects(object, other, bitmask, customizer, equalFunc, stack);
1124
- }
1125
-
1126
- /**
1127
- * The base implementation of `_.isNative` without bad shim checks.
1128
- *
1129
- * @private
1130
- * @param {*} value The value to check.
1131
- * @returns {boolean} Returns `true` if `value` is a native function,
1132
- * else `false`.
1133
- */
1134
- function baseIsNative(value) {
1135
- if (!isObject(value) || isMasked(value)) {
1136
- return false;
1137
- }
1138
- var pattern = isFunction(value) ? reIsNative : reIsHostCtor;
1139
- return pattern.test(toSource(value));
1140
- }
1141
-
1142
- /**
1143
- * The base implementation of `_.isTypedArray` without Node.js optimizations.
1144
- *
1145
- * @private
1146
- * @param {*} value The value to check.
1147
- * @returns {boolean} Returns `true` if `value` is a typed array, else `false`.
1148
- */
1149
- function baseIsTypedArray(value) {
1150
- return isObjectLike(value) &&
1151
- isLength(value.length) && !!typedArrayTags[baseGetTag(value)];
1152
- }
1153
-
1154
- /**
1155
- * The base implementation of `_.keys` which doesn't treat sparse arrays as dense.
1156
- *
1157
- * @private
1158
- * @param {Object} object The object to query.
1159
- * @returns {Array} Returns the array of property names.
1160
- */
1161
- function baseKeys(object) {
1162
- if (!isPrototype(object)) {
1163
- return nativeKeys(object);
1164
- }
1165
- var result = [];
1166
- for (var key in Object(object)) {
1167
- if (hasOwnProperty.call(object, key) && key != 'constructor') {
1168
- result.push(key);
1169
- }
1170
- }
1171
- return result;
1172
- }
1173
-
1174
- /**
1175
- * A specialized version of `baseIsEqualDeep` for arrays with support for
1176
- * partial deep comparisons.
1177
- *
1178
- * @private
1179
- * @param {Array} array The array to compare.
1180
- * @param {Array} other The other array to compare.
1181
- * @param {number} bitmask The bitmask flags. See `baseIsEqual` for more details.
1182
- * @param {Function} customizer The function to customize comparisons.
1183
- * @param {Function} equalFunc The function to determine equivalents of values.
1184
- * @param {Object} stack Tracks traversed `array` and `other` objects.
1185
- * @returns {boolean} Returns `true` if the arrays are equivalent, else `false`.
1186
- */
1187
- function equalArrays(array, other, bitmask, customizer, equalFunc, stack) {
1188
- var isPartial = bitmask & COMPARE_PARTIAL_FLAG,
1189
- arrLength = array.length,
1190
- othLength = other.length;
1191
-
1192
- if (arrLength != othLength && !(isPartial && othLength > arrLength)) {
1193
- return false;
1194
- }
1195
- // Assume cyclic values are equal.
1196
- var stacked = stack.get(array);
1197
- if (stacked && stack.get(other)) {
1198
- return stacked == other;
1199
- }
1200
- var index = -1,
1201
- result = true,
1202
- seen = (bitmask & COMPARE_UNORDERED_FLAG) ? new SetCache : undefined;
1203
-
1204
- stack.set(array, other);
1205
- stack.set(other, array);
1206
-
1207
- // Ignore non-index properties.
1208
- while (++index < arrLength) {
1209
- var arrValue = array[index],
1210
- othValue = other[index];
1211
-
1212
- if (customizer) {
1213
- var compared = isPartial
1214
- ? customizer(othValue, arrValue, index, other, array, stack)
1215
- : customizer(arrValue, othValue, index, array, other, stack);
1216
- }
1217
- if (compared !== undefined) {
1218
- if (compared) {
1219
- continue;
1220
- }
1221
- result = false;
1222
- break;
1223
- }
1224
- // Recursively compare arrays (susceptible to call stack limits).
1225
- if (seen) {
1226
- if (!arraySome(other, function(othValue, othIndex) {
1227
- if (!cacheHas(seen, othIndex) &&
1228
- (arrValue === othValue || equalFunc(arrValue, othValue, bitmask, customizer, stack))) {
1229
- return seen.push(othIndex);
1230
- }
1231
- })) {
1232
- result = false;
1233
- break;
1234
- }
1235
- } else if (!(
1236
- arrValue === othValue ||
1237
- equalFunc(arrValue, othValue, bitmask, customizer, stack)
1238
- )) {
1239
- result = false;
1240
- break;
1241
- }
1242
- }
1243
- stack['delete'](array);
1244
- stack['delete'](other);
1245
- return result;
1246
- }
1247
-
1248
- /**
1249
- * A specialized version of `baseIsEqualDeep` for comparing objects of
1250
- * the same `toStringTag`.
1251
- *
1252
- * **Note:** This function only supports comparing values with tags of
1253
- * `Boolean`, `Date`, `Error`, `Number`, `RegExp`, or `String`.
1254
- *
1255
- * @private
1256
- * @param {Object} object The object to compare.
1257
- * @param {Object} other The other object to compare.
1258
- * @param {string} tag The `toStringTag` of the objects to compare.
1259
- * @param {number} bitmask The bitmask flags. See `baseIsEqual` for more details.
1260
- * @param {Function} customizer The function to customize comparisons.
1261
- * @param {Function} equalFunc The function to determine equivalents of values.
1262
- * @param {Object} stack Tracks traversed `object` and `other` objects.
1263
- * @returns {boolean} Returns `true` if the objects are equivalent, else `false`.
1264
- */
1265
- function equalByTag(object, other, tag, bitmask, customizer, equalFunc, stack) {
1266
- switch (tag) {
1267
- case dataViewTag:
1268
- if ((object.byteLength != other.byteLength) ||
1269
- (object.byteOffset != other.byteOffset)) {
1270
- return false;
1271
- }
1272
- object = object.buffer;
1273
- other = other.buffer;
1274
-
1275
- case arrayBufferTag:
1276
- if ((object.byteLength != other.byteLength) ||
1277
- !equalFunc(new Uint8Array(object), new Uint8Array(other))) {
1278
- return false;
1279
- }
1280
- return true;
1281
-
1282
- case boolTag:
1283
- case dateTag:
1284
- case numberTag:
1285
- // Coerce booleans to `1` or `0` and dates to milliseconds.
1286
- // Invalid dates are coerced to `NaN`.
1287
- return eq(+object, +other);
1288
-
1289
- case errorTag:
1290
- return object.name == other.name && object.message == other.message;
1291
-
1292
- case regexpTag:
1293
- case stringTag:
1294
- // Coerce regexes to strings and treat strings, primitives and objects,
1295
- // as equal. See http://www.ecma-international.org/ecma-262/7.0/#sec-regexp.prototype.tostring
1296
- // for more details.
1297
- return object == (other + '');
1298
-
1299
- case mapTag:
1300
- var convert = mapToArray;
1301
-
1302
- case setTag:
1303
- var isPartial = bitmask & COMPARE_PARTIAL_FLAG;
1304
- convert || (convert = setToArray);
1305
-
1306
- if (object.size != other.size && !isPartial) {
1307
- return false;
1308
- }
1309
- // Assume cyclic values are equal.
1310
- var stacked = stack.get(object);
1311
- if (stacked) {
1312
- return stacked == other;
1313
- }
1314
- bitmask |= COMPARE_UNORDERED_FLAG;
1315
-
1316
- // Recursively compare objects (susceptible to call stack limits).
1317
- stack.set(object, other);
1318
- var result = equalArrays(convert(object), convert(other), bitmask, customizer, equalFunc, stack);
1319
- stack['delete'](object);
1320
- return result;
1321
-
1322
- case symbolTag:
1323
- if (symbolValueOf) {
1324
- return symbolValueOf.call(object) == symbolValueOf.call(other);
1325
- }
1326
- }
1327
- return false;
1328
- }
1329
-
1330
- /**
1331
- * A specialized version of `baseIsEqualDeep` for objects with support for
1332
- * partial deep comparisons.
1333
- *
1334
- * @private
1335
- * @param {Object} object The object to compare.
1336
- * @param {Object} other The other object to compare.
1337
- * @param {number} bitmask The bitmask flags. See `baseIsEqual` for more details.
1338
- * @param {Function} customizer The function to customize comparisons.
1339
- * @param {Function} equalFunc The function to determine equivalents of values.
1340
- * @param {Object} stack Tracks traversed `object` and `other` objects.
1341
- * @returns {boolean} Returns `true` if the objects are equivalent, else `false`.
1342
- */
1343
- function equalObjects(object, other, bitmask, customizer, equalFunc, stack) {
1344
- var isPartial = bitmask & COMPARE_PARTIAL_FLAG,
1345
- objProps = getAllKeys(object),
1346
- objLength = objProps.length,
1347
- othProps = getAllKeys(other),
1348
- othLength = othProps.length;
1349
-
1350
- if (objLength != othLength && !isPartial) {
1351
- return false;
1352
- }
1353
- var index = objLength;
1354
- while (index--) {
1355
- var key = objProps[index];
1356
- if (!(isPartial ? key in other : hasOwnProperty.call(other, key))) {
1357
- return false;
1358
- }
1359
- }
1360
- // Assume cyclic values are equal.
1361
- var stacked = stack.get(object);
1362
- if (stacked && stack.get(other)) {
1363
- return stacked == other;
1364
- }
1365
- var result = true;
1366
- stack.set(object, other);
1367
- stack.set(other, object);
1368
-
1369
- var skipCtor = isPartial;
1370
- while (++index < objLength) {
1371
- key = objProps[index];
1372
- var objValue = object[key],
1373
- othValue = other[key];
1374
-
1375
- if (customizer) {
1376
- var compared = isPartial
1377
- ? customizer(othValue, objValue, key, other, object, stack)
1378
- : customizer(objValue, othValue, key, object, other, stack);
1379
- }
1380
- // Recursively compare objects (susceptible to call stack limits).
1381
- if (!(compared === undefined
1382
- ? (objValue === othValue || equalFunc(objValue, othValue, bitmask, customizer, stack))
1383
- : compared
1384
- )) {
1385
- result = false;
1386
- break;
1387
- }
1388
- skipCtor || (skipCtor = key == 'constructor');
1389
- }
1390
- if (result && !skipCtor) {
1391
- var objCtor = object.constructor,
1392
- othCtor = other.constructor;
1393
-
1394
- // Non `Object` object instances with different constructors are not equal.
1395
- if (objCtor != othCtor &&
1396
- ('constructor' in object && 'constructor' in other) &&
1397
- !(typeof objCtor == 'function' && objCtor instanceof objCtor &&
1398
- typeof othCtor == 'function' && othCtor instanceof othCtor)) {
1399
- result = false;
1400
- }
1401
- }
1402
- stack['delete'](object);
1403
- stack['delete'](other);
1404
- return result;
1405
- }
1406
-
1407
- /**
1408
- * Creates an array of own enumerable property names and symbols of `object`.
1409
- *
1410
- * @private
1411
- * @param {Object} object The object to query.
1412
- * @returns {Array} Returns the array of property names and symbols.
1413
- */
1414
- function getAllKeys(object) {
1415
- return baseGetAllKeys(object, keys, getSymbols);
1416
- }
1417
-
1418
- /**
1419
- * Gets the data for `map`.
1420
- *
1421
- * @private
1422
- * @param {Object} map The map to query.
1423
- * @param {string} key The reference key.
1424
- * @returns {*} Returns the map data.
1425
- */
1426
- function getMapData(map, key) {
1427
- var data = map.__data__;
1428
- return isKeyable(key)
1429
- ? data[typeof key == 'string' ? 'string' : 'hash']
1430
- : data.map;
1431
- }
1432
-
1433
- /**
1434
- * Gets the native function at `key` of `object`.
1435
- *
1436
- * @private
1437
- * @param {Object} object The object to query.
1438
- * @param {string} key The key of the method to get.
1439
- * @returns {*} Returns the function if it's native, else `undefined`.
1440
- */
1441
- function getNative(object, key) {
1442
- var value = getValue(object, key);
1443
- return baseIsNative(value) ? value : undefined;
1444
- }
1445
-
1446
- /**
1447
- * A specialized version of `baseGetTag` which ignores `Symbol.toStringTag` values.
1448
- *
1449
- * @private
1450
- * @param {*} value The value to query.
1451
- * @returns {string} Returns the raw `toStringTag`.
1452
- */
1453
- function getRawTag(value) {
1454
- var isOwn = hasOwnProperty.call(value, symToStringTag),
1455
- tag = value[symToStringTag];
1456
-
1457
- try {
1458
- value[symToStringTag] = undefined;
1459
- var unmasked = true;
1460
- } catch (e) {}
1461
-
1462
- var result = nativeObjectToString.call(value);
1463
- if (unmasked) {
1464
- if (isOwn) {
1465
- value[symToStringTag] = tag;
1466
- } else {
1467
- delete value[symToStringTag];
1468
- }
1469
- }
1470
- return result;
1471
- }
1472
-
1473
- /**
1474
- * Creates an array of the own enumerable symbols of `object`.
1475
- *
1476
- * @private
1477
- * @param {Object} object The object to query.
1478
- * @returns {Array} Returns the array of symbols.
1479
- */
1480
- var getSymbols = !nativeGetSymbols ? stubArray : function(object) {
1481
- if (object == null) {
1482
- return [];
1483
- }
1484
- object = Object(object);
1485
- return arrayFilter(nativeGetSymbols(object), function(symbol) {
1486
- return propertyIsEnumerable.call(object, symbol);
1487
- });
1488
- };
1489
-
1490
- /**
1491
- * Gets the `toStringTag` of `value`.
1492
- *
1493
- * @private
1494
- * @param {*} value The value to query.
1495
- * @returns {string} Returns the `toStringTag`.
1496
- */
1497
- var getTag = baseGetTag;
1498
-
1499
- // Fallback for data views, maps, sets, and weak maps in IE 11 and promises in Node.js < 6.
1500
- if ((DataView && getTag(new DataView(new ArrayBuffer(1))) != dataViewTag) ||
1501
- (Map && getTag(new Map) != mapTag) ||
1502
- (Promise && getTag(Promise.resolve()) != promiseTag) ||
1503
- (Set && getTag(new Set) != setTag) ||
1504
- (WeakMap && getTag(new WeakMap) != weakMapTag)) {
1505
- getTag = function(value) {
1506
- var result = baseGetTag(value),
1507
- Ctor = result == objectTag ? value.constructor : undefined,
1508
- ctorString = Ctor ? toSource(Ctor) : '';
1509
-
1510
- if (ctorString) {
1511
- switch (ctorString) {
1512
- case dataViewCtorString: return dataViewTag;
1513
- case mapCtorString: return mapTag;
1514
- case promiseCtorString: return promiseTag;
1515
- case setCtorString: return setTag;
1516
- case weakMapCtorString: return weakMapTag;
1517
- }
1518
- }
1519
- return result;
1520
- };
1521
- }
1522
-
1523
- /**
1524
- * Checks if `value` is a valid array-like index.
1525
- *
1526
- * @private
1527
- * @param {*} value The value to check.
1528
- * @param {number} [length=MAX_SAFE_INTEGER] The upper bounds of a valid index.
1529
- * @returns {boolean} Returns `true` if `value` is a valid index, else `false`.
1530
- */
1531
- function isIndex(value, length) {
1532
- length = length == null ? MAX_SAFE_INTEGER : length;
1533
- return !!length &&
1534
- (typeof value == 'number' || reIsUint.test(value)) &&
1535
- (value > -1 && value % 1 == 0 && value < length);
1536
- }
1537
-
1538
- /**
1539
- * Checks if `value` is suitable for use as unique object key.
1540
- *
1541
- * @private
1542
- * @param {*} value The value to check.
1543
- * @returns {boolean} Returns `true` if `value` is suitable, else `false`.
1544
- */
1545
- function isKeyable(value) {
1546
- var type = typeof value;
1547
- return (type == 'string' || type == 'number' || type == 'symbol' || type == 'boolean')
1548
- ? (value !== '__proto__')
1549
- : (value === null);
1550
- }
1551
-
1552
- /**
1553
- * Checks if `func` has its source masked.
1554
- *
1555
- * @private
1556
- * @param {Function} func The function to check.
1557
- * @returns {boolean} Returns `true` if `func` is masked, else `false`.
1558
- */
1559
- function isMasked(func) {
1560
- return !!maskSrcKey && (maskSrcKey in func);
1561
- }
1562
-
1563
- /**
1564
- * Checks if `value` is likely a prototype object.
1565
- *
1566
- * @private
1567
- * @param {*} value The value to check.
1568
- * @returns {boolean} Returns `true` if `value` is a prototype, else `false`.
1569
- */
1570
- function isPrototype(value) {
1571
- var Ctor = value && value.constructor,
1572
- proto = (typeof Ctor == 'function' && Ctor.prototype) || objectProto;
1573
-
1574
- return value === proto;
1575
- }
1576
-
1577
- /**
1578
- * Converts `value` to a string using `Object.prototype.toString`.
1579
- *
1580
- * @private
1581
- * @param {*} value The value to convert.
1582
- * @returns {string} Returns the converted string.
1583
- */
1584
- function objectToString(value) {
1585
- return nativeObjectToString.call(value);
1586
- }
1587
-
1588
- /**
1589
- * Converts `func` to its source code.
1590
- *
1591
- * @private
1592
- * @param {Function} func The function to convert.
1593
- * @returns {string} Returns the source code.
1594
- */
1595
- function toSource(func) {
1596
- if (func != null) {
1597
- try {
1598
- return funcToString.call(func);
1599
- } catch (e) {}
1600
- try {
1601
- return (func + '');
1602
- } catch (e) {}
1603
- }
1604
- return '';
1605
- }
1606
-
1607
- /**
1608
- * Performs a
1609
- * [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
1610
- * comparison between two values to determine if they are equivalent.
1611
- *
1612
- * @static
1613
- * @memberOf _
1614
- * @since 4.0.0
1615
- * @category Lang
1616
- * @param {*} value The value to compare.
1617
- * @param {*} other The other value to compare.
1618
- * @returns {boolean} Returns `true` if the values are equivalent, else `false`.
1619
- * @example
1620
- *
1621
- * var object = { 'a': 1 };
1622
- * var other = { 'a': 1 };
1623
- *
1624
- * _.eq(object, object);
1625
- * // => true
1626
- *
1627
- * _.eq(object, other);
1628
- * // => false
1629
- *
1630
- * _.eq('a', 'a');
1631
- * // => true
1632
- *
1633
- * _.eq('a', Object('a'));
1634
- * // => false
1635
- *
1636
- * _.eq(NaN, NaN);
1637
- * // => true
1638
- */
1639
- function eq(value, other) {
1640
- return value === other || (value !== value && other !== other);
1641
- }
1642
-
1643
- /**
1644
- * Checks if `value` is likely an `arguments` object.
1645
- *
1646
- * @static
1647
- * @memberOf _
1648
- * @since 0.1.0
1649
- * @category Lang
1650
- * @param {*} value The value to check.
1651
- * @returns {boolean} Returns `true` if `value` is an `arguments` object,
1652
- * else `false`.
1653
- * @example
1654
- *
1655
- * _.isArguments(function() { return arguments; }());
1656
- * // => true
1657
- *
1658
- * _.isArguments([1, 2, 3]);
1659
- * // => false
1660
- */
1661
- var isArguments = baseIsArguments(function() { return arguments; }()) ? baseIsArguments : function(value) {
1662
- return isObjectLike(value) && hasOwnProperty.call(value, 'callee') &&
1663
- !propertyIsEnumerable.call(value, 'callee');
1664
- };
1665
-
1666
- /**
1667
- * Checks if `value` is classified as an `Array` object.
1668
- *
1669
- * @static
1670
- * @memberOf _
1671
- * @since 0.1.0
1672
- * @category Lang
1673
- * @param {*} value The value to check.
1674
- * @returns {boolean} Returns `true` if `value` is an array, else `false`.
1675
- * @example
1676
- *
1677
- * _.isArray([1, 2, 3]);
1678
- * // => true
1679
- *
1680
- * _.isArray(document.body.children);
1681
- * // => false
1682
- *
1683
- * _.isArray('abc');
1684
- * // => false
1685
- *
1686
- * _.isArray(_.noop);
1687
- * // => false
1688
- */
1689
- var isArray = Array.isArray;
1690
-
1691
- /**
1692
- * Checks if `value` is array-like. A value is considered array-like if it's
1693
- * not a function and has a `value.length` that's an integer greater than or
1694
- * equal to `0` and less than or equal to `Number.MAX_SAFE_INTEGER`.
1695
- *
1696
- * @static
1697
- * @memberOf _
1698
- * @since 4.0.0
1699
- * @category Lang
1700
- * @param {*} value The value to check.
1701
- * @returns {boolean} Returns `true` if `value` is array-like, else `false`.
1702
- * @example
1703
- *
1704
- * _.isArrayLike([1, 2, 3]);
1705
- * // => true
1706
- *
1707
- * _.isArrayLike(document.body.children);
1708
- * // => true
1709
- *
1710
- * _.isArrayLike('abc');
1711
- * // => true
1712
- *
1713
- * _.isArrayLike(_.noop);
1714
- * // => false
1715
- */
1716
- function isArrayLike(value) {
1717
- return value != null && isLength(value.length) && !isFunction(value);
1718
- }
1719
-
1720
- /**
1721
- * Checks if `value` is a buffer.
1722
- *
1723
- * @static
1724
- * @memberOf _
1725
- * @since 4.3.0
1726
- * @category Lang
1727
- * @param {*} value The value to check.
1728
- * @returns {boolean} Returns `true` if `value` is a buffer, else `false`.
1729
- * @example
1730
- *
1731
- * _.isBuffer(new Buffer(2));
1732
- * // => true
1733
- *
1734
- * _.isBuffer(new Uint8Array(2));
1735
- * // => false
1736
- */
1737
- var isBuffer = nativeIsBuffer || stubFalse;
1738
-
1739
- /**
1740
- * Performs a deep comparison between two values to determine if they are
1741
- * equivalent.
1742
- *
1743
- * **Note:** This method supports comparing arrays, array buffers, booleans,
1744
- * date objects, error objects, maps, numbers, `Object` objects, regexes,
1745
- * sets, strings, symbols, and typed arrays. `Object` objects are compared
1746
- * by their own, not inherited, enumerable properties. Functions and DOM
1747
- * nodes are compared by strict equality, i.e. `===`.
1748
- *
1749
- * @static
1750
- * @memberOf _
1751
- * @since 0.1.0
1752
- * @category Lang
1753
- * @param {*} value The value to compare.
1754
- * @param {*} other The other value to compare.
1755
- * @returns {boolean} Returns `true` if the values are equivalent, else `false`.
1756
- * @example
1757
- *
1758
- * var object = { 'a': 1 };
1759
- * var other = { 'a': 1 };
1760
- *
1761
- * _.isEqual(object, other);
1762
- * // => true
1763
- *
1764
- * object === other;
1765
- * // => false
1766
- */
1767
- function isEqual(value, other) {
1768
- return baseIsEqual(value, other);
1769
- }
1770
-
1771
- /**
1772
- * Checks if `value` is classified as a `Function` object.
1773
- *
1774
- * @static
1775
- * @memberOf _
1776
- * @since 0.1.0
1777
- * @category Lang
1778
- * @param {*} value The value to check.
1779
- * @returns {boolean} Returns `true` if `value` is a function, else `false`.
1780
- * @example
1781
- *
1782
- * _.isFunction(_);
1783
- * // => true
1784
- *
1785
- * _.isFunction(/abc/);
1786
- * // => false
1787
- */
1788
- function isFunction(value) {
1789
- if (!isObject(value)) {
1790
- return false;
1791
- }
1792
- // The use of `Object#toString` avoids issues with the `typeof` operator
1793
- // in Safari 9 which returns 'object' for typed arrays and other constructors.
1794
- var tag = baseGetTag(value);
1795
- return tag == funcTag || tag == genTag || tag == asyncTag || tag == proxyTag;
1796
- }
1797
-
1798
- /**
1799
- * Checks if `value` is a valid array-like length.
1800
- *
1801
- * **Note:** This method is loosely based on
1802
- * [`ToLength`](http://ecma-international.org/ecma-262/7.0/#sec-tolength).
1803
- *
1804
- * @static
1805
- * @memberOf _
1806
- * @since 4.0.0
1807
- * @category Lang
1808
- * @param {*} value The value to check.
1809
- * @returns {boolean} Returns `true` if `value` is a valid length, else `false`.
1810
- * @example
1811
- *
1812
- * _.isLength(3);
1813
- * // => true
1814
- *
1815
- * _.isLength(Number.MIN_VALUE);
1816
- * // => false
1817
- *
1818
- * _.isLength(Infinity);
1819
- * // => false
1820
- *
1821
- * _.isLength('3');
1822
- * // => false
1823
- */
1824
- function isLength(value) {
1825
- return typeof value == 'number' &&
1826
- value > -1 && value % 1 == 0 && value <= MAX_SAFE_INTEGER;
1827
- }
1828
-
1829
- /**
1830
- * Checks if `value` is the
1831
- * [language type](http://www.ecma-international.org/ecma-262/7.0/#sec-ecmascript-language-types)
1832
- * of `Object`. (e.g. arrays, functions, objects, regexes, `new Number(0)`, and `new String('')`)
1833
- *
1834
- * @static
1835
- * @memberOf _
1836
- * @since 0.1.0
1837
- * @category Lang
1838
- * @param {*} value The value to check.
1839
- * @returns {boolean} Returns `true` if `value` is an object, else `false`.
1840
- * @example
1841
- *
1842
- * _.isObject({});
1843
- * // => true
1844
- *
1845
- * _.isObject([1, 2, 3]);
1846
- * // => true
1847
- *
1848
- * _.isObject(_.noop);
1849
- * // => true
1850
- *
1851
- * _.isObject(null);
1852
- * // => false
1853
- */
1854
- function isObject(value) {
1855
- var type = typeof value;
1856
- return value != null && (type == 'object' || type == 'function');
1857
- }
1858
-
1859
- /**
1860
- * Checks if `value` is object-like. A value is object-like if it's not `null`
1861
- * and has a `typeof` result of "object".
1862
- *
1863
- * @static
1864
- * @memberOf _
1865
- * @since 4.0.0
1866
- * @category Lang
1867
- * @param {*} value The value to check.
1868
- * @returns {boolean} Returns `true` if `value` is object-like, else `false`.
1869
- * @example
1870
- *
1871
- * _.isObjectLike({});
1872
- * // => true
1873
- *
1874
- * _.isObjectLike([1, 2, 3]);
1875
- * // => true
1876
- *
1877
- * _.isObjectLike(_.noop);
1878
- * // => false
1879
- *
1880
- * _.isObjectLike(null);
1881
- * // => false
1882
- */
1883
- function isObjectLike(value) {
1884
- return value != null && typeof value == 'object';
1885
- }
1886
-
1887
- /**
1888
- * Checks if `value` is classified as a typed array.
1889
- *
1890
- * @static
1891
- * @memberOf _
1892
- * @since 3.0.0
1893
- * @category Lang
1894
- * @param {*} value The value to check.
1895
- * @returns {boolean} Returns `true` if `value` is a typed array, else `false`.
1896
- * @example
1897
- *
1898
- * _.isTypedArray(new Uint8Array);
1899
- * // => true
1900
- *
1901
- * _.isTypedArray([]);
1902
- * // => false
1903
- */
1904
- var isTypedArray = nodeIsTypedArray ? baseUnary(nodeIsTypedArray) : baseIsTypedArray;
1905
-
1906
- /**
1907
- * Creates an array of the own enumerable property names of `object`.
1908
- *
1909
- * **Note:** Non-object values are coerced to objects. See the
1910
- * [ES spec](http://ecma-international.org/ecma-262/7.0/#sec-object.keys)
1911
- * for more details.
1912
- *
1913
- * @static
1914
- * @since 0.1.0
1915
- * @memberOf _
1916
- * @category Object
1917
- * @param {Object} object The object to query.
1918
- * @returns {Array} Returns the array of property names.
1919
- * @example
1920
- *
1921
- * function Foo() {
1922
- * this.a = 1;
1923
- * this.b = 2;
1924
- * }
1925
- *
1926
- * Foo.prototype.c = 3;
1927
- *
1928
- * _.keys(new Foo);
1929
- * // => ['a', 'b'] (iteration order is not guaranteed)
1930
- *
1931
- * _.keys('hi');
1932
- * // => ['0', '1']
1933
- */
1934
- function keys(object) {
1935
- return isArrayLike(object) ? arrayLikeKeys(object) : baseKeys(object);
1936
- }
1937
-
1938
- /**
1939
- * This method returns a new empty array.
1940
- *
1941
- * @static
1942
- * @memberOf _
1943
- * @since 4.13.0
1944
- * @category Util
1945
- * @returns {Array} Returns the new empty array.
1946
- * @example
1947
- *
1948
- * var arrays = _.times(2, _.stubArray);
1949
- *
1950
- * console.log(arrays);
1951
- * // => [[], []]
1952
- *
1953
- * console.log(arrays[0] === arrays[1]);
1954
- * // => false
1955
- */
1956
- function stubArray() {
1957
- return [];
1958
- }
1959
-
1960
- /**
1961
- * This method returns `false`.
1962
- *
1963
- * @static
1964
- * @memberOf _
1965
- * @since 4.13.0
1966
- * @category Util
1967
- * @returns {boolean} Returns `false`.
1968
- * @example
1969
- *
1970
- * _.times(2, _.stubFalse);
1971
- * // => [false, false]
1972
- */
1973
- function stubFalse() {
1974
- return false;
1975
- }
1976
-
1977
- module.exports = isEqual;
1978
- } (lodash_isequal, lodash_isequal.exports));
1979
- return lodash_isequal.exports;
1980
- }
1981
-
1982
- /**
1983
- * Wraps values in an `Ok` type.
1984
- *
1985
- * Example: `ok(5) // => {ok: true, result: 5}`
1986
- */
1987
-
1988
- var ok = function (result) { return ({ ok: true, result: result }); };
1989
- /**
1990
- * Typeguard for `Ok`.
1991
- */
1992
- var isOk = function (r) { return r.ok === true; };
1993
- /**
1994
- * Wraps errors in an `Err` type.
1995
- *
1996
- * Example: `err('on fire') // => {ok: false, error: 'on fire'}`
1997
- */
1998
- var err = function (error) { return ({ ok: false, error: error }); };
1999
- /**
2000
- * Typeguard for `Err`.
2001
- */
2002
- var isErr = function (r) { return r.ok === false; };
2003
- /**
2004
- * Create a `Promise` that either resolves with the result of `Ok` or rejects
2005
- * with the error of `Err`.
2006
- */
2007
- var asPromise = function (r) {
2008
- return r.ok === true ? Promise.resolve(r.result) : Promise.reject(r.error);
2009
- };
2010
- /**
2011
- * Unwraps a `Result` and returns either the result of an `Ok`, or
2012
- * `defaultValue`.
2013
- *
2014
- * Example:
2015
- * ```
2016
- * Result.withDefault(5, number().run(json))
2017
- * ```
2018
- *
2019
- * It would be nice if `Decoder` had an instance method that mirrored this
2020
- * function. Such a method would look something like this:
2021
- * ```
2022
- * class Decoder<A> {
2023
- * runWithDefault = (defaultValue: A, json: any): A =>
2024
- * Result.withDefault(defaultValue, this.run(json));
2025
- * }
2026
- *
2027
- * number().runWithDefault(5, json)
2028
- * ```
2029
- * Unfortunately, the type of `defaultValue: A` on the method causes issues
2030
- * with type inference on the `object` decoder in some situations. While these
2031
- * inference issues can be solved by providing the optional type argument for
2032
- * `object`s, the extra trouble and confusion doesn't seem worth it.
2033
- */
2034
- var withDefault = function (defaultValue, r) {
2035
- return r.ok === true ? r.result : defaultValue;
2036
- };
2037
- /**
2038
- * Return the successful result, or throw an error.
2039
- */
2040
- var withException = function (r) {
2041
- if (r.ok === true) {
2042
- return r.result;
2043
- }
2044
- else {
2045
- throw r.error;
2046
- }
2047
- };
2048
- /**
2049
- * Given an array of `Result`s, return the successful values.
2050
- */
2051
- var successes = function (results) {
2052
- return results.reduce(function (acc, r) { return (r.ok === true ? acc.concat(r.result) : acc); }, []);
2053
- };
2054
- /**
2055
- * Apply `f` to the result of an `Ok`, or pass the error through.
2056
- */
2057
- var map = function (f, r) {
2058
- return r.ok === true ? ok(f(r.result)) : r;
2059
- };
2060
- /**
2061
- * Apply `f` to the result of two `Ok`s, or pass an error through. If both
2062
- * `Result`s are errors then the first one is returned.
2063
- */
2064
- var map2 = function (f, ar, br) {
2065
- return ar.ok === false ? ar :
2066
- br.ok === false ? br :
2067
- ok(f(ar.result, br.result));
2068
- };
2069
- /**
2070
- * Apply `f` to the error of an `Err`, or pass the success through.
2071
- */
2072
- var mapError = function (f, r) {
2073
- return r.ok === true ? r : err(f(r.error));
2074
- };
2075
- /**
2076
- * Chain together a sequence of computations that may fail, similar to a
2077
- * `Promise`. If the first computation fails then the error will propagate
2078
- * through. If it succeeds, then `f` will be applied to the value, returning a
2079
- * new `Result`.
2080
- */
2081
- var andThen = function (f, r) {
2082
- return r.ok === true ? f(r.result) : r;
2083
- };
2084
-
2085
-
2086
- var result = Object.freeze({
2087
- ok: ok,
2088
- isOk: isOk,
2089
- err: err,
2090
- isErr: isErr,
2091
- asPromise: asPromise,
2092
- withDefault: withDefault,
2093
- withException: withException,
2094
- successes: successes,
2095
- map: map,
2096
- map2: map2,
2097
- mapError: mapError,
2098
- andThen: andThen
2099
- });
2100
-
2101
- /*! *****************************************************************************
2102
- Copyright (c) Microsoft Corporation. All rights reserved.
2103
- Licensed under the Apache License, Version 2.0 (the "License"); you may not use
2104
- this file except in compliance with the License. You may obtain a copy of the
2105
- License at http://www.apache.org/licenses/LICENSE-2.0
2106
-
2107
- THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
2108
- KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
2109
- WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
2110
- MERCHANTABLITY OR NON-INFRINGEMENT.
2111
-
2112
- See the Apache Version 2.0 License for specific language governing permissions
2113
- and limitations under the License.
2114
- ***************************************************************************** */
2115
- /* global Reflect, Promise */
2116
-
2117
-
2118
-
2119
- var __assign = function() {
2120
- __assign = Object.assign || function __assign(t) {
2121
- for (var s, i = 1, n = arguments.length; i < n; i++) {
2122
- s = arguments[i];
2123
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
2124
- }
2125
- return t;
2126
- };
2127
- return __assign.apply(this, arguments);
2128
- };
2129
-
2130
- function __rest(s, e) {
2131
- var t = {};
2132
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
2133
- t[p] = s[p];
2134
- if (s != null && typeof Object.getOwnPropertySymbols === "function")
2135
- for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) if (e.indexOf(p[i]) < 0)
2136
- t[p[i]] = s[p[i]];
2137
- return t;
2138
- }
2139
-
2140
- var isEqual = requireLodash_isequal(); // this syntax avoids TS1192
2141
- /**
2142
- * Type guard for `DecoderError`. One use case of the type guard is in the
2143
- * `catch` of a promise. Typescript types the error argument of `catch` as
2144
- * `any`, so when dealing with a decoder as a promise you may need to
2145
- * distinguish between a `DecoderError` and an error string.
2146
- */
2147
- var isDecoderError = function (a) {
2148
- return a.kind === 'DecoderError' && typeof a.at === 'string' && typeof a.message === 'string';
2149
- };
2150
- /*
2151
- * Helpers
2152
- */
2153
- var isJsonArray = function (json) { return Array.isArray(json); };
2154
- var isJsonObject = function (json) {
2155
- return typeof json === 'object' && json !== null && !isJsonArray(json);
2156
- };
2157
- var typeString = function (json) {
2158
- switch (typeof json) {
2159
- case 'string':
2160
- return 'a string';
2161
- case 'number':
2162
- return 'a number';
2163
- case 'boolean':
2164
- return 'a boolean';
2165
- case 'undefined':
2166
- return 'undefined';
2167
- case 'object':
2168
- if (json instanceof Array) {
2169
- return 'an array';
2170
- }
2171
- else if (json === null) {
2172
- return 'null';
2173
- }
2174
- else {
2175
- return 'an object';
2176
- }
2177
- default:
2178
- return JSON.stringify(json);
2179
- }
2180
- };
2181
- var expectedGot = function (expected, got) {
2182
- return "expected " + expected + ", got " + typeString(got);
2183
- };
2184
- var printPath = function (paths) {
2185
- return paths.map(function (path) { return (typeof path === 'string' ? "." + path : "[" + path + "]"); }).join('');
2186
- };
2187
- var prependAt = function (newAt, _a) {
2188
- var at = _a.at, rest = __rest(_a, ["at"]);
2189
- return (__assign({ at: newAt + (at || '') }, rest));
2190
- };
2191
- /**
2192
- * Decoders transform json objects with unknown structure into known and
2193
- * verified forms. You can create objects of type `Decoder<A>` with either the
2194
- * primitive decoder functions, such as `boolean()` and `string()`, or by
2195
- * applying higher-order decoders to the primitives, such as `array(boolean())`
2196
- * or `dict(string())`.
2197
- *
2198
- * Each of the decoder functions are available both as a static method on
2199
- * `Decoder` and as a function alias -- for example the string decoder is
2200
- * defined at `Decoder.string()`, but is also aliased to `string()`. Using the
2201
- * function aliases exported with the library is recommended.
2202
- *
2203
- * `Decoder` exposes a number of 'run' methods, which all decode json in the
2204
- * same way, but communicate success and failure in different ways. The `map`
2205
- * and `andThen` methods modify decoders without having to call a 'run' method.
2206
- *
2207
- * Alternatively, the main decoder `run()` method returns an object of type
2208
- * `Result<A, DecoderError>`. This library provides a number of helper
2209
- * functions for dealing with the `Result` type, so you can do all the same
2210
- * things with a `Result` as with the decoder methods.
2211
- */
2212
- var Decoder = /** @class */ (function () {
2213
- /**
2214
- * The Decoder class constructor is kept private to separate the internal
2215
- * `decode` function from the external `run` function. The distinction
2216
- * between the two functions is that `decode` returns a
2217
- * `Partial<DecoderError>` on failure, which contains an unfinished error
2218
- * report. When `run` is called on a decoder, the relevant series of `decode`
2219
- * calls is made, and then on failure the resulting `Partial<DecoderError>`
2220
- * is turned into a `DecoderError` by filling in the missing information.
2221
- *
2222
- * While hiding the constructor may seem restrictive, leveraging the
2223
- * provided decoder combinators and helper functions such as
2224
- * `andThen` and `map` should be enough to build specialized decoders as
2225
- * needed.
2226
- */
2227
- function Decoder(decode) {
2228
- var _this = this;
2229
- this.decode = decode;
2230
- /**
2231
- * Run the decoder and return a `Result` with either the decoded value or a
2232
- * `DecoderError` containing the json input, the location of the error, and
2233
- * the error message.
2234
- *
2235
- * Examples:
2236
- * ```
2237
- * number().run(12)
2238
- * // => {ok: true, result: 12}
2239
- *
2240
- * string().run(9001)
2241
- * // =>
2242
- * // {
2243
- * // ok: false,
2244
- * // error: {
2245
- * // kind: 'DecoderError',
2246
- * // input: 9001,
2247
- * // at: 'input',
2248
- * // message: 'expected a string, got 9001'
2249
- * // }
2250
- * // }
2251
- * ```
2252
- */
2253
- this.run = function (json) {
2254
- return mapError(function (error) { return ({
2255
- kind: 'DecoderError',
2256
- input: json,
2257
- at: 'input' + (error.at || ''),
2258
- message: error.message || ''
2259
- }); }, _this.decode(json));
2260
- };
2261
- /**
2262
- * Run the decoder as a `Promise`.
2263
- */
2264
- this.runPromise = function (json) { return asPromise(_this.run(json)); };
2265
- /**
2266
- * Run the decoder and return the value on success, or throw an exception
2267
- * with a formatted error string.
2268
- */
2269
- this.runWithException = function (json) { return withException(_this.run(json)); };
2270
- /**
2271
- * Construct a new decoder that applies a transformation to the decoded
2272
- * result. If the decoder succeeds then `f` will be applied to the value. If
2273
- * it fails the error will propagated through.
2274
- *
2275
- * Example:
2276
- * ```
2277
- * number().map(x => x * 5).run(10)
2278
- * // => {ok: true, result: 50}
2279
- * ```
2280
- */
2281
- this.map = function (f) {
2282
- return new Decoder(function (json) { return map(f, _this.decode(json)); });
2283
- };
2284
- /**
2285
- * Chain together a sequence of decoders. The first decoder will run, and
2286
- * then the function will determine what decoder to run second. If the result
2287
- * of the first decoder succeeds then `f` will be applied to the decoded
2288
- * value. If it fails the error will propagate through.
2289
- *
2290
- * This is a very powerful method -- it can act as both the `map` and `where`
2291
- * methods, can improve error messages for edge cases, and can be used to
2292
- * make a decoder for custom types.
2293
- *
2294
- * Example of adding an error message:
2295
- * ```
2296
- * const versionDecoder = valueAt(['version'], number());
2297
- * const infoDecoder3 = object({a: boolean()});
2298
- *
2299
- * const decoder = versionDecoder.andThen(version => {
2300
- * switch (version) {
2301
- * case 3:
2302
- * return infoDecoder3;
2303
- * default:
2304
- * return fail(`Unable to decode info, version ${version} is not supported.`);
2305
- * }
2306
- * });
2307
- *
2308
- * decoder.run({version: 3, a: true})
2309
- * // => {ok: true, result: {a: true}}
2310
- *
2311
- * decoder.run({version: 5, x: 'abc'})
2312
- * // =>
2313
- * // {
2314
- * // ok: false,
2315
- * // error: {... message: 'Unable to decode info, version 5 is not supported.'}
2316
- * // }
2317
- * ```
2318
- *
2319
- * Example of decoding a custom type:
2320
- * ```
2321
- * // nominal type for arrays with a length of at least one
2322
- * type NonEmptyArray<T> = T[] & { __nonEmptyArrayBrand__: void };
2323
- *
2324
- * const nonEmptyArrayDecoder = <T>(values: Decoder<T>): Decoder<NonEmptyArray<T>> =>
2325
- * array(values).andThen(arr =>
2326
- * arr.length > 0
2327
- * ? succeed(createNonEmptyArray(arr))
2328
- * : fail(`expected a non-empty array, got an empty array`)
2329
- * );
2330
- * ```
2331
- */
2332
- this.andThen = function (f) {
2333
- return new Decoder(function (json) {
2334
- return andThen(function (value) { return f(value).decode(json); }, _this.decode(json));
2335
- });
2336
- };
2337
- /**
2338
- * Add constraints to a decoder _without_ changing the resulting type. The
2339
- * `test` argument is a predicate function which returns true for valid
2340
- * inputs. When `test` fails on an input, the decoder fails with the given
2341
- * `errorMessage`.
2342
- *
2343
- * ```
2344
- * const chars = (length: number): Decoder<string> =>
2345
- * string().where(
2346
- * (s: string) => s.length === length,
2347
- * `expected a string of length ${length}`
2348
- * );
2349
- *
2350
- * chars(5).run('12345')
2351
- * // => {ok: true, result: '12345'}
2352
- *
2353
- * chars(2).run('HELLO')
2354
- * // => {ok: false, error: {... message: 'expected a string of length 2'}}
2355
- *
2356
- * chars(12).run(true)
2357
- * // => {ok: false, error: {... message: 'expected a string, got a boolean'}}
2358
- * ```
2359
- */
2360
- this.where = function (test, errorMessage) {
2361
- return _this.andThen(function (value) { return (test(value) ? Decoder.succeed(value) : Decoder.fail(errorMessage)); });
2362
- };
2363
- }
2364
- /**
2365
- * Decoder primitive that validates strings, and fails on all other input.
2366
- */
2367
- Decoder.string = function () {
2368
- return new Decoder(function (json) {
2369
- return typeof json === 'string'
2370
- ? ok(json)
2371
- : err({ message: expectedGot('a string', json) });
2372
- });
2373
- };
2374
- /**
2375
- * Decoder primitive that validates numbers, and fails on all other input.
2376
- */
2377
- Decoder.number = function () {
2378
- return new Decoder(function (json) {
2379
- return typeof json === 'number'
2380
- ? ok(json)
2381
- : err({ message: expectedGot('a number', json) });
2382
- });
2383
- };
2384
- /**
2385
- * Decoder primitive that validates booleans, and fails on all other input.
2386
- */
2387
- Decoder.boolean = function () {
2388
- return new Decoder(function (json) {
2389
- return typeof json === 'boolean'
2390
- ? ok(json)
2391
- : err({ message: expectedGot('a boolean', json) });
2392
- });
2393
- };
2394
- Decoder.constant = function (value) {
2395
- return new Decoder(function (json) {
2396
- return isEqual(json, value)
2397
- ? ok(value)
2398
- : err({ message: "expected " + JSON.stringify(value) + ", got " + JSON.stringify(json) });
2399
- });
2400
- };
2401
- Decoder.object = function (decoders) {
2402
- return new Decoder(function (json) {
2403
- if (isJsonObject(json) && decoders) {
2404
- var obj = {};
2405
- for (var key in decoders) {
2406
- if (decoders.hasOwnProperty(key)) {
2407
- var r = decoders[key].decode(json[key]);
2408
- if (r.ok === true) {
2409
- // tslint:disable-next-line:strict-type-predicates
2410
- if (r.result !== undefined) {
2411
- obj[key] = r.result;
2412
- }
2413
- }
2414
- else if (json[key] === undefined) {
2415
- return err({ message: "the key '" + key + "' is required but was not present" });
2416
- }
2417
- else {
2418
- return err(prependAt("." + key, r.error));
2419
- }
2420
- }
2421
- }
2422
- return ok(obj);
2423
- }
2424
- else if (isJsonObject(json)) {
2425
- return ok(json);
2426
- }
2427
- else {
2428
- return err({ message: expectedGot('an object', json) });
2429
- }
2430
- });
2431
- };
2432
- Decoder.array = function (decoder) {
2433
- return new Decoder(function (json) {
2434
- if (isJsonArray(json) && decoder) {
2435
- var decodeValue_1 = function (v, i) {
2436
- return mapError(function (err$$1) { return prependAt("[" + i + "]", err$$1); }, decoder.decode(v));
2437
- };
2438
- return json.reduce(function (acc, v, i) {
2439
- return map2(function (arr, result) { return arr.concat([result]); }, acc, decodeValue_1(v, i));
2440
- }, ok([]));
2441
- }
2442
- else if (isJsonArray(json)) {
2443
- return ok(json);
2444
- }
2445
- else {
2446
- return err({ message: expectedGot('an array', json) });
2447
- }
2448
- });
2449
- };
2450
- Decoder.tuple = function (decoders) {
2451
- return new Decoder(function (json) {
2452
- if (isJsonArray(json)) {
2453
- if (json.length !== decoders.length) {
2454
- return err({
2455
- message: "expected a tuple of length " + decoders.length + ", got one of length " + json.length
2456
- });
2457
- }
2458
- var result = [];
2459
- for (var i = 0; i < decoders.length; i++) {
2460
- var nth = decoders[i].decode(json[i]);
2461
- if (nth.ok) {
2462
- result[i] = nth.result;
2463
- }
2464
- else {
2465
- return err(prependAt("[" + i + "]", nth.error));
2466
- }
2467
- }
2468
- return ok(result);
2469
- }
2470
- else {
2471
- return err({ message: expectedGot("a tuple of length " + decoders.length, json) });
2472
- }
2473
- });
2474
- };
2475
- Decoder.union = function (ad, bd) {
2476
- var decoders = [];
2477
- for (var _i = 2; _i < arguments.length; _i++) {
2478
- decoders[_i - 2] = arguments[_i];
2479
- }
2480
- return Decoder.oneOf.apply(Decoder, [ad, bd].concat(decoders));
2481
- };
2482
- Decoder.intersection = function (ad, bd) {
2483
- var ds = [];
2484
- for (var _i = 2; _i < arguments.length; _i++) {
2485
- ds[_i - 2] = arguments[_i];
2486
- }
2487
- return new Decoder(function (json) {
2488
- return [ad, bd].concat(ds).reduce(function (acc, decoder) { return map2(Object.assign, acc, decoder.decode(json)); }, ok({}));
2489
- });
2490
- };
2491
- /**
2492
- * Escape hatch to bypass validation. Always succeeds and types the result as
2493
- * `any`. Useful for defining decoders incrementally, particularly for
2494
- * complex objects.
2495
- *
2496
- * Example:
2497
- * ```
2498
- * interface User {
2499
- * name: string;
2500
- * complexUserData: ComplexType;
2501
- * }
2502
- *
2503
- * const userDecoder: Decoder<User> = object({
2504
- * name: string(),
2505
- * complexUserData: anyJson()
2506
- * });
2507
- * ```
2508
- */
2509
- Decoder.anyJson = function () { return new Decoder(function (json) { return ok(json); }); };
2510
- /**
2511
- * Decoder identity function which always succeeds and types the result as
2512
- * `unknown`.
2513
- */
2514
- Decoder.unknownJson = function () {
2515
- return new Decoder(function (json) { return ok(json); });
2516
- };
2517
- /**
2518
- * Decoder for json objects where the keys are unknown strings, but the values
2519
- * should all be of the same type.
2520
- *
2521
- * Example:
2522
- * ```
2523
- * dict(number()).run({chocolate: 12, vanilla: 10, mint: 37});
2524
- * // => {ok: true, result: {chocolate: 12, vanilla: 10, mint: 37}}
2525
- * ```
2526
- */
2527
- Decoder.dict = function (decoder) {
2528
- return new Decoder(function (json) {
2529
- if (isJsonObject(json)) {
2530
- var obj = {};
2531
- for (var key in json) {
2532
- if (json.hasOwnProperty(key)) {
2533
- var r = decoder.decode(json[key]);
2534
- if (r.ok === true) {
2535
- obj[key] = r.result;
2536
- }
2537
- else {
2538
- return err(prependAt("." + key, r.error));
2539
- }
2540
- }
2541
- }
2542
- return ok(obj);
2543
- }
2544
- else {
2545
- return err({ message: expectedGot('an object', json) });
2546
- }
2547
- });
2548
- };
2549
- /**
2550
- * Decoder for values that may be `undefined`. This is primarily helpful for
2551
- * decoding interfaces with optional fields.
2552
- *
2553
- * Example:
2554
- * ```
2555
- * interface User {
2556
- * id: number;
2557
- * isOwner?: boolean;
2558
- * }
2559
- *
2560
- * const decoder: Decoder<User> = object({
2561
- * id: number(),
2562
- * isOwner: optional(boolean())
2563
- * });
2564
- * ```
2565
- */
2566
- Decoder.optional = function (decoder) {
2567
- return new Decoder(function (json) { return (json === undefined ? ok(undefined) : decoder.decode(json)); });
2568
- };
2569
- /**
2570
- * Decoder that attempts to run each decoder in `decoders` and either succeeds
2571
- * with the first successful decoder, or fails after all decoders have failed.
2572
- *
2573
- * Note that `oneOf` expects the decoders to all have the same return type,
2574
- * while `union` creates a decoder for the union type of all the input
2575
- * decoders.
2576
- *
2577
- * Examples:
2578
- * ```
2579
- * oneOf(string(), number().map(String))
2580
- * oneOf(constant('start'), constant('stop'), succeed('unknown'))
2581
- * ```
2582
- */
2583
- Decoder.oneOf = function () {
2584
- var decoders = [];
2585
- for (var _i = 0; _i < arguments.length; _i++) {
2586
- decoders[_i] = arguments[_i];
2587
- }
2588
- return new Decoder(function (json) {
2589
- var errors = [];
2590
- for (var i = 0; i < decoders.length; i++) {
2591
- var r = decoders[i].decode(json);
2592
- if (r.ok === true) {
2593
- return r;
2594
- }
2595
- else {
2596
- errors[i] = r.error;
2597
- }
2598
- }
2599
- var errorsList = errors
2600
- .map(function (error) { return "at error" + (error.at || '') + ": " + error.message; })
2601
- .join('", "');
2602
- return err({
2603
- message: "expected a value matching one of the decoders, got the errors [\"" + errorsList + "\"]"
2604
- });
2605
- });
2606
- };
2607
- /**
2608
- * Decoder that always succeeds with either the decoded value, or a fallback
2609
- * default value.
2610
- */
2611
- Decoder.withDefault = function (defaultValue, decoder) {
2612
- return new Decoder(function (json) {
2613
- return ok(withDefault(defaultValue, decoder.decode(json)));
2614
- });
2615
- };
2616
- /**
2617
- * Decoder that pulls a specific field out of a json structure, instead of
2618
- * decoding and returning the full structure. The `paths` array describes the
2619
- * object keys and array indices to traverse, so that values can be pulled out
2620
- * of a nested structure.
2621
- *
2622
- * Example:
2623
- * ```
2624
- * const decoder = valueAt(['a', 'b', 0], string());
2625
- *
2626
- * decoder.run({a: {b: ['surprise!']}})
2627
- * // => {ok: true, result: 'surprise!'}
2628
- *
2629
- * decoder.run({a: {x: 'cats'}})
2630
- * // => {ok: false, error: {... at: 'input.a.b[0]' message: 'path does not exist'}}
2631
- * ```
2632
- *
2633
- * Note that the `decoder` is ran on the value found at the last key in the
2634
- * path, even if the last key is not found. This allows the `optional`
2635
- * decoder to succeed when appropriate.
2636
- * ```
2637
- * const optionalDecoder = valueAt(['a', 'b', 'c'], optional(string()));
2638
- *
2639
- * optionalDecoder.run({a: {b: {c: 'surprise!'}}})
2640
- * // => {ok: true, result: 'surprise!'}
2641
- *
2642
- * optionalDecoder.run({a: {b: 'cats'}})
2643
- * // => {ok: false, error: {... at: 'input.a.b.c' message: 'expected an object, got "cats"'}
2644
- *
2645
- * optionalDecoder.run({a: {b: {z: 1}}})
2646
- * // => {ok: true, result: undefined}
2647
- * ```
2648
- */
2649
- Decoder.valueAt = function (paths, decoder) {
2650
- return new Decoder(function (json) {
2651
- var jsonAtPath = json;
2652
- for (var i = 0; i < paths.length; i++) {
2653
- if (jsonAtPath === undefined) {
2654
- return err({
2655
- at: printPath(paths.slice(0, i + 1)),
2656
- message: 'path does not exist'
2657
- });
2658
- }
2659
- else if (typeof paths[i] === 'string' && !isJsonObject(jsonAtPath)) {
2660
- return err({
2661
- at: printPath(paths.slice(0, i + 1)),
2662
- message: expectedGot('an object', jsonAtPath)
2663
- });
2664
- }
2665
- else if (typeof paths[i] === 'number' && !isJsonArray(jsonAtPath)) {
2666
- return err({
2667
- at: printPath(paths.slice(0, i + 1)),
2668
- message: expectedGot('an array', jsonAtPath)
2669
- });
2670
- }
2671
- else {
2672
- jsonAtPath = jsonAtPath[paths[i]];
2673
- }
2674
- }
2675
- return mapError(function (error) {
2676
- return jsonAtPath === undefined
2677
- ? { at: printPath(paths), message: 'path does not exist' }
2678
- : prependAt(printPath(paths), error);
2679
- }, decoder.decode(jsonAtPath));
2680
- });
2681
- };
2682
- /**
2683
- * Decoder that ignores the input json and always succeeds with `fixedValue`.
2684
- */
2685
- Decoder.succeed = function (fixedValue) {
2686
- return new Decoder(function (json) { return ok(fixedValue); });
2687
- };
2688
- /**
2689
- * Decoder that ignores the input json and always fails with `errorMessage`.
2690
- */
2691
- Decoder.fail = function (errorMessage) {
2692
- return new Decoder(function (json) { return err({ message: errorMessage }); });
2693
- };
2694
- /**
2695
- * Decoder that allows for validating recursive data structures. Unlike with
2696
- * functions, decoders assigned to variables can't reference themselves
2697
- * before they are fully defined. We can avoid prematurely referencing the
2698
- * decoder by wrapping it in a function that won't be called until use, at
2699
- * which point the decoder has been defined.
2700
- *
2701
- * Example:
2702
- * ```
2703
- * interface Comment {
2704
- * msg: string;
2705
- * replies: Comment[];
2706
- * }
2707
- *
2708
- * const decoder: Decoder<Comment> = object({
2709
- * msg: string(),
2710
- * replies: lazy(() => array(decoder))
2711
- * });
2712
- * ```
2713
- */
2714
- Decoder.lazy = function (mkDecoder) {
2715
- return new Decoder(function (json) { return mkDecoder().decode(json); });
2716
- };
2717
- return Decoder;
2718
- }());
2719
-
2720
- /* tslint:disable:variable-name */
2721
- /** See `Decoder.string` */
2722
- var string = Decoder.string;
2723
- /** See `Decoder.number` */
2724
- var number = Decoder.number;
2725
- /** See `Decoder.boolean` */
2726
- var boolean = Decoder.boolean;
2727
- /** See `Decoder.anyJson` */
2728
- var anyJson = Decoder.anyJson;
2729
- /** See `Decoder.unknownJson` */
2730
- var unknownJson = Decoder.unknownJson;
2731
- /** See `Decoder.constant` */
2732
- var constant = Decoder.constant;
2733
- /** See `Decoder.object` */
2734
- var object = Decoder.object;
2735
- /** See `Decoder.array` */
2736
- var array = Decoder.array;
2737
- /** See `Decoder.tuple` */
2738
- var tuple = Decoder.tuple;
2739
- /** See `Decoder.dict` */
2740
- var dict = Decoder.dict;
2741
- /** See `Decoder.optional` */
2742
- var optional = Decoder.optional;
2743
- /** See `Decoder.oneOf` */
2744
- var oneOf = Decoder.oneOf;
2745
- /** See `Decoder.union` */
2746
- var union = Decoder.union;
2747
- /** See `Decoder.intersection` */
2748
- var intersection = Decoder.intersection;
2749
- /** See `Decoder.withDefault` */
2750
- var withDefault$1 = Decoder.withDefault;
2751
- /** See `Decoder.valueAt` */
2752
- var valueAt = Decoder.valueAt;
2753
- /** See `Decoder.succeed` */
2754
- var succeed = Decoder.succeed;
2755
- /** See `Decoder.fail` */
2756
- var fail = Decoder.fail;
2757
- /** See `Decoder.lazy` */
2758
- var lazy = Decoder.lazy;
2759
-
2760
- var index_es5 = /*#__PURE__*/Object.freeze({
2761
- __proto__: null,
2762
- Decoder: Decoder,
2763
- Result: result,
2764
- anyJson: anyJson,
2765
- array: array,
2766
- boolean: boolean,
2767
- constant: constant,
2768
- dict: dict,
2769
- fail: fail,
2770
- intersection: intersection,
2771
- isDecoderError: isDecoderError,
2772
- lazy: lazy,
2773
- number: number,
2774
- object: object,
2775
- oneOf: oneOf,
2776
- optional: optional,
2777
- string: string,
2778
- succeed: succeed,
2779
- tuple: tuple,
2780
- union: union,
2781
- unknownJson: unknownJson,
2782
- valueAt: valueAt,
2783
- withDefault: withDefault$1
2784
- });
2785
-
2786
- var require$$0 = /*@__PURE__*/getAugmentedNamespace(index_es5);
2787
-
2788
- var types = {};
2789
-
2790
- var hasRequiredTypes$1;
2791
-
2792
- function requireTypes$1 () {
2793
- if (hasRequiredTypes$1) return types;
2794
- hasRequiredTypes$1 = 1;
2795
- (function (exports$1) {
2796
- var __assign = (types && types.__assign) || function () {
2797
- __assign = Object.assign || function(t) {
2798
- for (var s, i = 1, n = arguments.length; i < n; i++) {
2799
- s = arguments[i];
2800
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
2801
- t[p] = s[p];
2802
- }
2803
- return t;
2804
- };
2805
- return __assign.apply(this, arguments);
2806
- };
2807
- var __createBinding = (types && types.__createBinding) || (Object.create ? (function(o, m, k, k2) {
2808
- if (k2 === undefined) k2 = k;
2809
- var desc = Object.getOwnPropertyDescriptor(m, k);
2810
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
2811
- desc = { enumerable: true, get: function() { return m[k]; } };
2812
- }
2813
- Object.defineProperty(o, k2, desc);
2814
- }) : (function(o, m, k, k2) {
2815
- if (k2 === undefined) k2 = k;
2816
- o[k2] = m[k];
2817
- }));
2818
- var __setModuleDefault = (types && types.__setModuleDefault) || (Object.create ? (function(o, v) {
2819
- Object.defineProperty(o, "default", { enumerable: true, value: v });
2820
- }) : function(o, v) {
2821
- o["default"] = v;
2822
- });
2823
- var __importStar = (types && types.__importStar) || (function () {
2824
- var ownKeys = function(o) {
2825
- ownKeys = Object.getOwnPropertyNames || function (o) {
2826
- var ar = [];
2827
- for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
2828
- return ar;
2829
- };
2830
- return ownKeys(o);
2831
- };
2832
- return function (mod) {
2833
- if (mod && mod.__esModule) return mod;
2834
- var result = {};
2835
- if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
2836
- __setModuleDefault(result, mod);
2837
- return result;
2838
- };
2839
- })();
2840
- var __generator = (types && types.__generator) || function (thisArg, body) {
2841
- var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
2842
- return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
2843
- function verb(n) { return function (v) { return step([n, v]); }; }
2844
- function step(op) {
2845
- if (f) throw new TypeError("Generator is already executing.");
2846
- while (g && (g = 0, op[0] && (_ = 0)), _) try {
2847
- if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
2848
- if (y = 0, t) op = [op[0] & 2, t.value];
2849
- switch (op[0]) {
2850
- case 0: case 1: t = op; break;
2851
- case 4: _.label++; return { value: op[1], done: false };
2852
- case 5: _.label++; y = op[1]; op = [0]; continue;
2853
- case 7: op = _.ops.pop(); _.trys.pop(); continue;
2854
- default:
2855
- if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
2856
- if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
2857
- if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
2858
- if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
2859
- if (t[2]) _.ops.pop();
2860
- _.trys.pop(); continue;
2861
- }
2862
- op = body.call(thisArg, _);
2863
- } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
2864
- if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
2865
- }
2866
- };
2867
- var __importDefault = (types && types.__importDefault) || function (mod) {
2868
- return (mod && mod.__esModule) ? mod : { "default": mod };
2869
- };
2870
- Object.defineProperty(exports$1, "__esModule", { value: true });
2871
- exports$1.Map = exports$1.emptyMap = exports$1.TextMap = exports$1.Optional = exports$1.ContractId = exports$1.Date = exports$1.List = exports$1.Party = exports$1.Time = exports$1.Text = exports$1.Decimal = exports$1.Numeric = exports$1.Int = exports$1.Bool = exports$1.Unit = exports$1.lookupTemplate = exports$1.templateIdWithPackageId = exports$1.registerTemplate = void 0;
2872
- exports$1.assembleTemplate = assembleTemplate;
2873
- exports$1.assembleInterface = assembleInterface;
2874
- exports$1.memo = memo;
2875
- exports$1.lazyMemo = lazyMemo;
2876
- // Copyright (c) 2025 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved.
2877
- // SPDX-License-Identifier: Apache-2.0
2878
- var jtv = __importStar(require$$0);
2879
- var lodash_1 = __importDefault(require$$1__default.default);
2880
- function toInterfaceMixin() {
2881
- return {
2882
- toInterface: function (_, cid) {
2883
- return cid;
2884
- },
2885
- unsafeFromInterface: function (_, cid) {
2886
- return cid;
2887
- },
2888
- };
2889
- }
2890
- /**
2891
- * @internal
2892
- */
2893
- function assembleTemplate(template) {
2894
- return __assign(__assign({}, toInterfaceMixin()), template);
2895
- }
2896
- /**
2897
- * @internal
2898
- */
2899
- function assembleInterface(templateId, decoderSource, choices) {
2900
- return __assign({ templateId: templateId, sdkVersion: "3.3.0-snapshot.20250528.13806.0.v3cd439fb",
2901
- // `Interface<I> &` is a phantom intersection
2902
- decoder: lazyMemo(function () { return decoderSource().decoder; }), keyDecoder: jtv.succeed(undefined) }, choices);
2903
- }
2904
- /**
2905
- * @internal
2906
- */
2907
- var registeredTemplates = {};
2908
- /**
2909
- * @internal
2910
- */
2911
- var registerTemplate = function (template, packageSpecifiers) {
2912
- if (packageSpecifiers === void 0) { packageSpecifiers = []; }
2913
- var aliases = packageSpecifiers.map((0, exports$1.templateIdWithPackageId)(template));
2914
- new Set([template.templateId].concat(aliases)).forEach(function (templateId) {
2915
- if (templateId in registeredTemplates) {
2916
- console.warn("Trying to re-register template ".concat(templateId, "."));
2917
- }
2918
- else {
2919
- registeredTemplates[templateId] = template;
2920
- console.debug("Registered template ".concat(templateId, "."));
2921
- }
2922
- });
2923
- };
2924
- exports$1.registerTemplate = registerTemplate;
2925
- /**
2926
- * @internal
2927
- */
2928
- var templateIdWithPackageId = function (t) {
2929
- return function (pkgId) {
2930
- return [pkgId].concat(t.templateId.split(":").slice(1)).join(":");
2931
- };
2932
- };
2933
- exports$1.templateIdWithPackageId = templateIdWithPackageId;
2934
- /**
2935
- * @internal
2936
- */
2937
- var lookupTemplate = function (templateId) {
2938
- var template = registeredTemplates[templateId];
2939
- if (template === undefined) {
2940
- throw Error("Failed to look up template ".concat(templateId, ". Make sure your @daml/types version agrees with the used Daml SDK version."));
2941
- }
2942
- return template;
2943
- };
2944
- exports$1.lookupTemplate = lookupTemplate;
2945
- /**
2946
- * @internal Turn a thunk into a memoized version of itself. The memoized thunk
2947
- * invokes the original thunk only on its first invocation and caches the result
2948
- * for later uses. We use this to implement a version of `jtv.lazy` with
2949
- * memoization.
2950
- */
2951
- function memo(thunk) {
2952
- var memoized = function () {
2953
- var cache = thunk();
2954
- memoized = function () { return cache; };
2955
- return cache;
2956
- };
2957
- // NOTE(MH): Since we change `memoized` when the resultung thunk is invoked
2958
- // for the first time, we need to return it "by reference". Thus, we return
2959
- // a closure which contains a reference to `memoized`.
2960
- return function () { return memoized(); };
2961
- }
2962
- /**
2963
- * @internal Variation of `jtv.lazy` which memoizes the computed decoder on its
2964
- * first invocation.
2965
- */
2966
- function lazyMemo(mkDecoder) {
2967
- return jtv.lazy(memo(mkDecoder));
2968
- }
2969
- /**
2970
- * Companion object of the [[Unit]] type.
2971
- */
2972
- exports$1.Unit = {
2973
- decoder: jtv.object({}),
2974
- encode: function (t) { return t; },
2975
- };
2976
- /**
2977
- * Companion object of the [[Bool]] type.
2978
- */
2979
- exports$1.Bool = {
2980
- decoder: jtv.boolean(),
2981
- encode: function (b) { return b; },
2982
- };
2983
- /**
2984
- * Companion object of the [[Int]] type.
2985
- */
2986
- exports$1.Int = {
2987
- decoder: jtv.string(),
2988
- encode: function (i) { return i; },
2989
- };
2990
- /**
2991
- * Companion function of the [[Numeric]] type.
2992
- */
2993
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
2994
- var Numeric = function (_) { return ({
2995
- decoder: jtv.string(),
2996
- encode: function (n) { return n; },
2997
- }); };
2998
- exports$1.Numeric = Numeric;
2999
- /**
3000
- * Companion object of the [[Decimal]] type.
3001
- */
3002
- exports$1.Decimal = (0, exports$1.Numeric)(10);
3003
- /**
3004
- * Companion object of the [[Text]] type.
3005
- */
3006
- exports$1.Text = {
3007
- decoder: jtv.string(),
3008
- encode: function (t) { return t; },
3009
- };
3010
- /**
3011
- * Companion object of the [[Time]] type.
3012
- */
3013
- exports$1.Time = {
3014
- decoder: jtv.string(),
3015
- encode: function (t) { return t; },
3016
- };
3017
- /**
3018
- * Companion object of the [[Party]] type.
3019
- */
3020
- exports$1.Party = {
3021
- decoder: jtv.string(),
3022
- encode: function (p) { return p; },
3023
- };
3024
- /**
3025
- * Companion object of the [[List]] type.
3026
- */
3027
- var List = function (t) { return ({
3028
- decoder: jtv.array(t.decoder),
3029
- encode: function (l) { return l.map(function (element) { return t.encode(element); }); },
3030
- }); };
3031
- exports$1.List = List;
3032
- /**
3033
- * Companion object of the [[Date]] type.
3034
- */
3035
- exports$1.Date = {
3036
- decoder: jtv.string(),
3037
- encode: function (d) { return d; },
3038
- };
3039
- /**
3040
- * Companion object of the [[ContractId]] type.
3041
- */
3042
- var ContractId = function (_t) { return ({
3043
- decoder: jtv.string(),
3044
- encode: function (c) { return c; },
3045
- }); };
3046
- exports$1.ContractId = ContractId;
3047
- /**
3048
- * This class does the actual work behind the [[Optional]] companion function. In addition to
3049
- * implementing the [[Serializable]] interface it also stores the [[Serializable]] instance of the
3050
- * payload of the [[Optional]] and uses it to provide a decoder for the [[OptionalInner]] type.
3051
- *
3052
- * @typeparam T The type of the optionally present value.
3053
- */
3054
- var OptionalWorker = /** @class */ (function () {
3055
- function OptionalWorker(payload) {
3056
- if (payload instanceof OptionalWorker) {
3057
- var payloadInnerDecoder = payload.innerDecoder;
3058
- this.innerDecoder = jtv.oneOf(jtv.constant([]), jtv.tuple([payloadInnerDecoder]));
3059
- this.encode = function (o) {
3060
- if (o === null) {
3061
- // Top-level enclosing Optional where the type argument is also
3062
- // Optional and we represent None.
3063
- return null;
3064
- }
3065
- else {
3066
- // The current type is Optional<Optional<...>> and the current value
3067
- // is Some x. Therefore the nested value is represented as [] for
3068
- // x = None or as [y] for x = Some y. In both cases mapping the
3069
- // encoder of the type parameter does the right thing.
3070
- return o.map(function (nested) { return payload.encode(nested); });
3071
- }
3072
- };
3073
- }
3074
- else {
3075
- // NOTE(MH): `T` is not of the form `Optional<U>` here and hence `null`
3076
- // does not extend `T`. Thus, `OptionalInner<T> = T`.
3077
- this.innerDecoder = payload.decoder;
3078
- this.encode = function (o) {
3079
- if (o === null) {
3080
- // This branch is only reached if we are at the top-level and the
3081
- // entire type is a non-nested Optional, i.e. Optional<U> where U is
3082
- // not Optional. Recursive calls from the other branch would stop
3083
- // before reaching this case, as nested None are empty lists and
3084
- // never null.
3085
- return null;
3086
- }
3087
- else {
3088
- return payload.encode(o);
3089
- }
3090
- };
3091
- }
3092
- this.decoder = jtv
3093
- .optional(jtv.oneOf(jtv.constant(null), this.innerDecoder))
3094
- .map(function (x) { return (x === undefined ? null : x); });
3095
- }
3096
- return OptionalWorker;
3097
- }());
3098
- /**
3099
- * Companion function of the [[Optional]] type.
3100
- */
3101
- var Optional = function (t) {
3102
- return new OptionalWorker(t);
3103
- };
3104
- exports$1.Optional = Optional;
3105
- /**
3106
- * Companion object of the [[TextMap]] type.
3107
- */
3108
- var TextMap = function (t) { return ({
3109
- decoder: jtv.dict(t.decoder),
3110
- encode: function (tm) {
3111
- var out = {};
3112
- Object.keys(tm).forEach(function (k) {
3113
- out[k] = t.encode(tm[k]);
3114
- });
3115
- return out;
3116
- },
3117
- }); };
3118
- exports$1.TextMap = TextMap;
3119
- function it(arr) {
3120
- var i;
3121
- return __generator(this, function (_a) {
3122
- switch (_a.label) {
3123
- case 0:
3124
- i = 0;
3125
- _a.label = 1;
3126
- case 1:
3127
- if (!(i < arr.length)) return [3 /*break*/, 4];
3128
- return [4 /*yield*/, lodash_1.default.cloneDeep(arr[i])];
3129
- case 2:
3130
- _a.sent();
3131
- _a.label = 3;
3132
- case 3:
3133
- i++;
3134
- return [3 /*break*/, 1];
3135
- case 4: return [2 /*return*/, undefined];
3136
- }
3137
- });
3138
- }
3139
- // This code assumes that the decoder is only ever used in decoding values
3140
- // straight from the API responses, and said raw responses are never reused
3141
- // afterwards. This should be enforced by this class not being exported and the
3142
- // daml-ledger module not letting raw JSON responses escape without going
3143
- // through this.
3144
- //
3145
- // Without that assumption, the constructor would need to deep-copy its kvs
3146
- // argument.
3147
- var MapImpl = /** @class */ (function () {
3148
- function MapImpl(kvs) {
3149
- // sorting done so that generic object deep comparison would find equal
3150
- // maps equal (as defined by jest's expect().toEqual())
3151
- this._kvs = lodash_1.default.sortBy(kvs, function (kv) { return JSON.stringify(kv[0]); });
3152
- this._keys = this._kvs.map(function (e) { return e[0]; });
3153
- this._values = this._kvs.map(function (e) { return e[1]; });
3154
- }
3155
- MapImpl.prototype._idx = function (k) {
3156
- return this._keys.findIndex(function (l) { return lodash_1.default.isEqual(k, l); });
3157
- };
3158
- MapImpl.prototype.has = function (k) {
3159
- return this._idx(k) !== -1;
3160
- };
3161
- MapImpl.prototype.get = function (k) {
3162
- return lodash_1.default.cloneDeep(this._values[this._idx(k)]);
3163
- };
3164
- MapImpl.prototype.set = function (k, v) {
3165
- if (this.has(k)) {
3166
- var cpy = this._kvs.slice();
3167
- cpy[this._idx(k)] = lodash_1.default.cloneDeep([k, v]);
3168
- return new MapImpl(cpy);
3169
- }
3170
- else {
3171
- var head = lodash_1.default.cloneDeep([[k, v]]);
3172
- return new MapImpl(head.concat(this._kvs));
3173
- }
3174
- };
3175
- MapImpl.prototype.delete = function (k) {
3176
- var i = this._idx(k);
3177
- if (i !== -1) {
3178
- return new MapImpl(this._kvs.slice(0, i).concat(this._kvs.slice(i + 1)));
3179
- }
3180
- else {
3181
- return this;
3182
- }
3183
- };
3184
- MapImpl.prototype.keys = function () {
3185
- return it(this._keys);
3186
- };
3187
- MapImpl.prototype.values = function () {
3188
- return it(this._values);
3189
- };
3190
- MapImpl.prototype.entries = function () {
3191
- return it(this._kvs);
3192
- };
3193
- MapImpl.prototype.entriesArray = function () {
3194
- return lodash_1.default.cloneDeep(this._kvs);
3195
- };
3196
- MapImpl.prototype.forEach = function (f, u) {
3197
- var g = u ? f.bind(u) : f;
3198
- for (var _i = 0, _a = this._kvs; _i < _a.length; _i++) {
3199
- var _b = _a[_i], k = _b[0], v = _b[1];
3200
- g(v, k, this);
3201
- }
3202
- };
3203
- return MapImpl;
3204
- }());
3205
- var emptyMap = function () { return new MapImpl([]); };
3206
- exports$1.emptyMap = emptyMap;
3207
- /**
3208
- * Companion function of the [[GenMap]] type.
3209
- */
3210
- var Map = function (kd, vd) { return ({
3211
- decoder: jtv
3212
- .array(jtv.tuple([kd.decoder, vd.decoder]))
3213
- .map(function (kvs) { return new MapImpl(kvs); }),
3214
- encode: function (m) {
3215
- return m.entriesArray().map(function (e) { return [kd.encode(e[0]), vd.encode(e[1])]; });
3216
- },
3217
- }); };
3218
- exports$1.Map = Map;
3219
-
3220
- } (types));
3221
- return types;
3222
- }
141
+ var require$$1 = /*@__PURE__*/getAugmentedNamespace(types__namespace);
3223
142
 
3224
143
  var lib$1 = {};
3225
144
 
@@ -3241,7 +160,7 @@ function requireModule$7 () {
3241
160
  /* eslint-disable-next-line no-unused-vars */
3242
161
  var jtv = require$$0;
3243
162
  /* eslint-disable-next-line no-unused-vars */
3244
- var damlTypes = requireTypes$1();
163
+ var damlTypes = require$$1;
3245
164
 
3246
165
  exports$1.Archive = {
3247
166
  decoder: damlTypes.lazyMemo(function () {
@@ -3337,7 +256,7 @@ function requireModule$6 () {
3337
256
  /* eslint-disable-next-line no-unused-vars */
3338
257
  var jtv = require$$0;
3339
258
  /* eslint-disable-next-line no-unused-vars */
3340
- var damlTypes = requireTypes$1();
259
+ var damlTypes = require$$1;
3341
260
 
3342
261
  exports$1.RelTime = {
3343
262
  decoder: damlTypes.lazyMemo(function () {
@@ -3423,7 +342,7 @@ function requireModule$5 () {
3423
342
  /* eslint-disable-next-line no-unused-vars */
3424
343
  var jtv = require$$0;
3425
344
  /* eslint-disable-next-line no-unused-vars */
3426
- var damlTypes = requireTypes$1();
345
+ var damlTypes = require$$1;
3427
346
 
3428
347
  var pkg9e70a8b3510d617f8a136213f33d6a903a10ca0eeec76bb06ba55d1ed9680f69 = requireLib$2();
3429
348
  var pkgb70db8369e1c461d5c70f1c86f526a29e9776c655e6ffc2560f95b05ccb8b946 = requireLib$1();
@@ -3658,7 +577,7 @@ function requireModule$4 () {
3658
577
  /* eslint-disable-next-line no-unused-vars */
3659
578
  var jtv = require$$0;
3660
579
  /* eslint-disable-next-line no-unused-vars */
3661
- var damlTypes = requireTypes$1();
580
+ var damlTypes = require$$1;
3662
581
 
3663
582
  var pkg9e70a8b3510d617f8a136213f33d6a903a10ca0eeec76bb06ba55d1ed9680f69 = requireLib$2();
3664
583
  var pkgb70db8369e1c461d5c70f1c86f526a29e9776c655e6ffc2560f95b05ccb8b946 = requireLib$1();
@@ -3788,7 +707,7 @@ function requireModule$3 () {
3788
707
  /* eslint-disable-next-line no-unused-vars */
3789
708
  var jtv = require$$0;
3790
709
  /* eslint-disable-next-line no-unused-vars */
3791
- var damlTypes = requireTypes$1();
710
+ var damlTypes = require$$1;
3792
711
 
3793
712
  var pkg9e70a8b3510d617f8a136213f33d6a903a10ca0eeec76bb06ba55d1ed9680f69 = requireLib$2();
3794
713
 
@@ -4117,7 +1036,7 @@ function requireModule$2 () {
4117
1036
  /* eslint-disable-next-line no-unused-vars */
4118
1037
  var jtv = require$$0;
4119
1038
  /* eslint-disable-next-line no-unused-vars */
4120
- var damlTypes = requireTypes$1();
1039
+ var damlTypes = require$$1;
4121
1040
 
4122
1041
  var pkg9e70a8b3510d617f8a136213f33d6a903a10ca0eeec76bb06ba55d1ed9680f69 = requireLib$2();
4123
1042
 
@@ -4534,7 +1453,7 @@ function requireModule$1 () {
4534
1453
  /* eslint-disable-next-line no-unused-vars */
4535
1454
  var jtv = require$$0;
4536
1455
  /* eslint-disable-next-line no-unused-vars */
4537
- var damlTypes = requireTypes$1();
1456
+ var damlTypes = require$$1;
4538
1457
 
4539
1458
  var pkg9e70a8b3510d617f8a136213f33d6a903a10ca0eeec76bb06ba55d1ed9680f69 = requireLib$2();
4540
1459
 
@@ -4760,7 +1679,7 @@ function requireModule () {
4760
1679
  /* eslint-disable-next-line no-unused-vars */
4761
1680
  var jtv = require$$0;
4762
1681
  /* eslint-disable-next-line no-unused-vars */
4763
- var damlTypes = requireTypes$1();
1682
+ var damlTypes = require$$1;
4764
1683
 
4765
1684
  var pkg9e70a8b3510d617f8a136213f33d6a903a10ca0eeec76bb06ba55d1ed9680f69 = requireLib$2();
4766
1685