@dimo-network/data-sdk 1.3.3 → 1.5.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.github/workflows/npm-publish.yml +6 -3
- package/README.md +82 -0
- package/dist/api/Method.js +7 -2
- package/dist/api/Method.test.js +10 -5
- package/dist/api/resources/Agents/index.d.ts +5 -0
- package/dist/api/resources/Agents/index.js +63 -0
- package/dist/api/resources/DimoRestResources.d.ts +3 -2
- package/dist/api/resources/DimoRestResources.js +3 -2
- package/dist/api/resources/{VehicleEvents → VehicleTriggers}/index.d.ts +2 -2
- package/dist/api/resources/{VehicleEvents → VehicleTriggers}/index.js +13 -19
- package/dist/cjs/index.js +607 -503
- package/dist/cjs/index.js.map +1 -1
- package/dist/dimo.d.ts +3 -2
- package/dist/dimo.js +5 -3
- package/dist/dimo.test.js +4 -0
- package/dist/environments/index.d.ts +4 -2
- package/dist/environments/index.js +4 -2
- package/dist/esm/index.js +606 -503
- package/dist/esm/index.js.map +1 -1
- package/dist/types/api/resources/Agents/index.d.ts +5 -0
- package/dist/types/api/resources/DimoRestResources.d.ts +3 -2
- package/dist/types/api/resources/{VehicleEvents → VehicleTriggers}/index.d.ts +2 -2
- package/dist/types/dimo.d.ts +3 -2
- package/dist/types/environments/index.d.ts +4 -2
- package/package.json +4 -3
package/dist/esm/index.js
CHANGED
|
@@ -5,7 +5,7 @@ import http from 'http';
|
|
|
5
5
|
import https from 'https';
|
|
6
6
|
import Url from 'url';
|
|
7
7
|
import require$$6 from 'fs';
|
|
8
|
-
import
|
|
8
|
+
import crypto$2 from 'crypto';
|
|
9
9
|
import require$$4 from 'assert';
|
|
10
10
|
import require$$1$3 from 'tty';
|
|
11
11
|
import require$$0$2 from 'os';
|
|
@@ -26,7 +26,6 @@ function bind(fn, thisArg) {
|
|
|
26
26
|
|
|
27
27
|
const {toString} = Object.prototype;
|
|
28
28
|
const {getPrototypeOf} = Object;
|
|
29
|
-
const {iterator, toStringTag} = Symbol;
|
|
30
29
|
|
|
31
30
|
const kindOf = (cache => thing => {
|
|
32
31
|
const str = toString.call(thing);
|
|
@@ -153,28 +152,7 @@ const isPlainObject = (val) => {
|
|
|
153
152
|
}
|
|
154
153
|
|
|
155
154
|
const prototype = getPrototypeOf(val);
|
|
156
|
-
return (prototype === null || prototype === Object.prototype || Object.getPrototypeOf(prototype) === null) && !(toStringTag in val) && !(iterator in val);
|
|
157
|
-
};
|
|
158
|
-
|
|
159
|
-
/**
|
|
160
|
-
* Determine if a value is an empty object (safely handles Buffers)
|
|
161
|
-
*
|
|
162
|
-
* @param {*} val The value to test
|
|
163
|
-
*
|
|
164
|
-
* @returns {boolean} True if value is an empty object, otherwise false
|
|
165
|
-
*/
|
|
166
|
-
const isEmptyObject = (val) => {
|
|
167
|
-
// Early return for non-objects or Buffers to prevent RangeError
|
|
168
|
-
if (!isObject$1(val) || isBuffer(val)) {
|
|
169
|
-
return false;
|
|
170
|
-
}
|
|
171
|
-
|
|
172
|
-
try {
|
|
173
|
-
return Object.keys(val).length === 0 && Object.getPrototypeOf(val) === Object.prototype;
|
|
174
|
-
} catch (e) {
|
|
175
|
-
// Fallback for any other objects that might cause RangeError with Object.keys()
|
|
176
|
-
return false;
|
|
177
|
-
}
|
|
155
|
+
return (prototype === null || prototype === Object.prototype || Object.getPrototypeOf(prototype) === null) && !(Symbol.toStringTag in val) && !(Symbol.iterator in val);
|
|
178
156
|
};
|
|
179
157
|
|
|
180
158
|
/**
|
|
@@ -299,11 +277,6 @@ function forEach(obj, fn, {allOwnKeys = false} = {}) {
|
|
|
299
277
|
fn.call(null, obj[i], i, obj);
|
|
300
278
|
}
|
|
301
279
|
} else {
|
|
302
|
-
// Buffer check
|
|
303
|
-
if (isBuffer(obj)) {
|
|
304
|
-
return;
|
|
305
|
-
}
|
|
306
|
-
|
|
307
280
|
// Iterate over object keys
|
|
308
281
|
const keys = allOwnKeys ? Object.getOwnPropertyNames(obj) : Object.keys(obj);
|
|
309
282
|
const len = keys.length;
|
|
@@ -317,10 +290,6 @@ function forEach(obj, fn, {allOwnKeys = false} = {}) {
|
|
|
317
290
|
}
|
|
318
291
|
|
|
319
292
|
function findKey(obj, key) {
|
|
320
|
-
if (isBuffer(obj)){
|
|
321
|
-
return null;
|
|
322
|
-
}
|
|
323
|
-
|
|
324
293
|
key = key.toLowerCase();
|
|
325
294
|
const keys = Object.keys(obj);
|
|
326
295
|
let i = keys.length;
|
|
@@ -534,13 +503,13 @@ const isTypedArray = (TypedArray => {
|
|
|
534
503
|
* @returns {void}
|
|
535
504
|
*/
|
|
536
505
|
const forEachEntry = (obj, fn) => {
|
|
537
|
-
const generator = obj && obj[iterator];
|
|
506
|
+
const generator = obj && obj[Symbol.iterator];
|
|
538
507
|
|
|
539
|
-
const
|
|
508
|
+
const iterator = generator.call(obj);
|
|
540
509
|
|
|
541
510
|
let result;
|
|
542
511
|
|
|
543
|
-
while ((result =
|
|
512
|
+
while ((result = iterator.next()) && !result.done) {
|
|
544
513
|
const pair = result.value;
|
|
545
514
|
fn.call(obj, pair[0], pair[1]);
|
|
546
515
|
}
|
|
@@ -661,7 +630,7 @@ const toFiniteNumber = (value, defaultValue) => {
|
|
|
661
630
|
* @returns {boolean}
|
|
662
631
|
*/
|
|
663
632
|
function isSpecCompliantForm(thing) {
|
|
664
|
-
return !!(thing && isFunction(thing.append) && thing[toStringTag] === 'FormData' && thing[iterator]);
|
|
633
|
+
return !!(thing && isFunction(thing.append) && thing[Symbol.toStringTag] === 'FormData' && thing[Symbol.iterator]);
|
|
665
634
|
}
|
|
666
635
|
|
|
667
636
|
const toJSONObject = (obj) => {
|
|
@@ -674,11 +643,6 @@ const toJSONObject = (obj) => {
|
|
|
674
643
|
return;
|
|
675
644
|
}
|
|
676
645
|
|
|
677
|
-
//Buffer check
|
|
678
|
-
if (isBuffer(source)) {
|
|
679
|
-
return source;
|
|
680
|
-
}
|
|
681
|
-
|
|
682
646
|
if(!('toJSON' in source)) {
|
|
683
647
|
stack[i] = source;
|
|
684
648
|
const target = isArray(source) ? [] : {};
|
|
@@ -735,10 +699,6 @@ const asap = typeof queueMicrotask !== 'undefined' ?
|
|
|
735
699
|
|
|
736
700
|
// *********************
|
|
737
701
|
|
|
738
|
-
|
|
739
|
-
const isIterable$1 = (thing) => thing != null && isFunction(thing[iterator]);
|
|
740
|
-
|
|
741
|
-
|
|
742
702
|
var utils$4 = {
|
|
743
703
|
isArray,
|
|
744
704
|
isArrayBuffer,
|
|
@@ -750,7 +710,6 @@ var utils$4 = {
|
|
|
750
710
|
isBoolean: isBoolean$1,
|
|
751
711
|
isObject: isObject$1,
|
|
752
712
|
isPlainObject,
|
|
753
|
-
isEmptyObject,
|
|
754
713
|
isReadableStream,
|
|
755
714
|
isRequest: isRequest$1,
|
|
756
715
|
isResponse,
|
|
@@ -795,8 +754,7 @@ var utils$4 = {
|
|
|
795
754
|
isAsyncFn,
|
|
796
755
|
isThenable,
|
|
797
756
|
setImmediate: _setImmediate,
|
|
798
|
-
asap
|
|
799
|
-
isIterable: isIterable$1
|
|
757
|
+
asap
|
|
800
758
|
};
|
|
801
759
|
|
|
802
760
|
/**
|
|
@@ -908,11 +866,7 @@ function getAugmentedNamespace(n) {
|
|
|
908
866
|
var f = n.default;
|
|
909
867
|
if (typeof f == "function") {
|
|
910
868
|
var a = function a () {
|
|
911
|
-
|
|
912
|
-
try {
|
|
913
|
-
isInstance = this instanceof a;
|
|
914
|
-
} catch {}
|
|
915
|
-
if (isInstance) {
|
|
869
|
+
if (this instanceof a) {
|
|
916
870
|
return Reflect.construct(f, arguments, this.constructor);
|
|
917
871
|
}
|
|
918
872
|
return f.apply(this, arguments);
|
|
@@ -13633,7 +13587,7 @@ function requireGetIntrinsic () {
|
|
|
13633
13587
|
if (!allowMissing) {
|
|
13634
13588
|
throw new $TypeError('base intrinsic for ' + name + ' exists, but the property is not available.');
|
|
13635
13589
|
}
|
|
13636
|
-
return void
|
|
13590
|
+
return void 0;
|
|
13637
13591
|
}
|
|
13638
13592
|
if ($gOPD && (i + 1) >= parts.length) {
|
|
13639
13593
|
var desc = $gOPD(value, part);
|
|
@@ -13731,11 +13685,12 @@ var hasRequiredPopulate;
|
|
|
13731
13685
|
function requirePopulate () {
|
|
13732
13686
|
if (hasRequiredPopulate) return populate;
|
|
13733
13687
|
hasRequiredPopulate = 1;
|
|
13734
|
-
|
|
13735
13688
|
// populates missing values
|
|
13736
|
-
populate = function
|
|
13737
|
-
|
|
13738
|
-
|
|
13689
|
+
populate = function(dst, src) {
|
|
13690
|
+
|
|
13691
|
+
Object.keys(src).forEach(function(prop)
|
|
13692
|
+
{
|
|
13693
|
+
dst[prop] = dst[prop] || src[prop];
|
|
13739
13694
|
});
|
|
13740
13695
|
|
|
13741
13696
|
return dst;
|
|
@@ -13749,7 +13704,6 @@ var hasRequiredForm_data;
|
|
|
13749
13704
|
function requireForm_data () {
|
|
13750
13705
|
if (hasRequiredForm_data) return form_data;
|
|
13751
13706
|
hasRequiredForm_data = 1;
|
|
13752
|
-
|
|
13753
13707
|
var CombinedStream = requireCombined_stream();
|
|
13754
13708
|
var util = require$$1$1;
|
|
13755
13709
|
var path = require$$1$2;
|
|
@@ -13758,20 +13712,24 @@ function requireForm_data () {
|
|
|
13758
13712
|
var parseUrl = Url.parse;
|
|
13759
13713
|
var fs = require$$6;
|
|
13760
13714
|
var Stream$1 = Stream.Stream;
|
|
13761
|
-
var crypto = require$$8;
|
|
13762
13715
|
var mime = requireMimeTypes();
|
|
13763
13716
|
var asynckit = requireAsynckit();
|
|
13764
13717
|
var setToStringTag = /*@__PURE__*/ requireEsSetTostringtag();
|
|
13765
|
-
var hasOwn = /*@__PURE__*/ requireHasown();
|
|
13766
13718
|
var populate = requirePopulate();
|
|
13767
13719
|
|
|
13720
|
+
// Public API
|
|
13721
|
+
form_data = FormData;
|
|
13722
|
+
|
|
13723
|
+
// make it a Stream
|
|
13724
|
+
util.inherits(FormData, CombinedStream);
|
|
13725
|
+
|
|
13768
13726
|
/**
|
|
13769
13727
|
* Create readable "multipart/form-data" streams.
|
|
13770
13728
|
* Can be used to submit forms
|
|
13771
13729
|
* and file uploads to other web applications.
|
|
13772
13730
|
*
|
|
13773
13731
|
* @constructor
|
|
13774
|
-
* @param {
|
|
13732
|
+
* @param {Object} options - Properties to be added/overriden for FormData and CombinedStream
|
|
13775
13733
|
*/
|
|
13776
13734
|
function FormData(options) {
|
|
13777
13735
|
if (!(this instanceof FormData)) {
|
|
@@ -13784,39 +13742,35 @@ function requireForm_data () {
|
|
|
13784
13742
|
|
|
13785
13743
|
CombinedStream.call(this);
|
|
13786
13744
|
|
|
13787
|
-
options = options || {};
|
|
13788
|
-
for (var option in options) {
|
|
13745
|
+
options = options || {};
|
|
13746
|
+
for (var option in options) {
|
|
13789
13747
|
this[option] = options[option];
|
|
13790
13748
|
}
|
|
13791
13749
|
}
|
|
13792
13750
|
|
|
13793
|
-
// make it a Stream
|
|
13794
|
-
util.inherits(FormData, CombinedStream);
|
|
13795
|
-
|
|
13796
13751
|
FormData.LINE_BREAK = '\r\n';
|
|
13797
13752
|
FormData.DEFAULT_CONTENT_TYPE = 'application/octet-stream';
|
|
13798
13753
|
|
|
13799
|
-
FormData.prototype.append = function
|
|
13800
|
-
|
|
13754
|
+
FormData.prototype.append = function(field, value, options) {
|
|
13755
|
+
|
|
13756
|
+
options = options || {};
|
|
13801
13757
|
|
|
13802
13758
|
// allow filename as single option
|
|
13803
|
-
if (typeof options
|
|
13804
|
-
options = {
|
|
13759
|
+
if (typeof options == 'string') {
|
|
13760
|
+
options = {filename: options};
|
|
13805
13761
|
}
|
|
13806
13762
|
|
|
13807
13763
|
var append = CombinedStream.prototype.append.bind(this);
|
|
13808
13764
|
|
|
13809
13765
|
// all that streamy business can't handle numbers
|
|
13810
|
-
if (typeof value
|
|
13811
|
-
value =
|
|
13766
|
+
if (typeof value == 'number') {
|
|
13767
|
+
value = '' + value;
|
|
13812
13768
|
}
|
|
13813
13769
|
|
|
13814
13770
|
// https://github.com/felixge/node-form-data/issues/38
|
|
13815
13771
|
if (Array.isArray(value)) {
|
|
13816
|
-
|
|
13817
|
-
|
|
13818
|
-
* the way web server expects it
|
|
13819
|
-
*/
|
|
13772
|
+
// Please convert your array into string
|
|
13773
|
+
// the way web server expects it
|
|
13820
13774
|
this._error(new Error('Arrays are not supported.'));
|
|
13821
13775
|
return;
|
|
13822
13776
|
}
|
|
@@ -13832,17 +13786,15 @@ function requireForm_data () {
|
|
|
13832
13786
|
this._trackLength(header, value, options);
|
|
13833
13787
|
};
|
|
13834
13788
|
|
|
13835
|
-
FormData.prototype._trackLength = function
|
|
13789
|
+
FormData.prototype._trackLength = function(header, value, options) {
|
|
13836
13790
|
var valueLength = 0;
|
|
13837
13791
|
|
|
13838
|
-
|
|
13839
|
-
|
|
13840
|
-
|
|
13841
|
-
|
|
13842
|
-
* incoming file to finish to get its size.
|
|
13843
|
-
*/
|
|
13792
|
+
// used w/ getLengthSync(), when length is known.
|
|
13793
|
+
// e.g. for streaming directly from a remote server,
|
|
13794
|
+
// w/ a known file a size, and not wanting to wait for
|
|
13795
|
+
// incoming file to finish to get its size.
|
|
13844
13796
|
if (options.knownLength != null) {
|
|
13845
|
-
valueLength +=
|
|
13797
|
+
valueLength += +options.knownLength;
|
|
13846
13798
|
} else if (Buffer.isBuffer(value)) {
|
|
13847
13799
|
valueLength = value.length;
|
|
13848
13800
|
} else if (typeof value === 'string') {
|
|
@@ -13852,10 +13804,12 @@ function requireForm_data () {
|
|
|
13852
13804
|
this._valueLength += valueLength;
|
|
13853
13805
|
|
|
13854
13806
|
// @check why add CRLF? does this account for custom/multiple CRLFs?
|
|
13855
|
-
this._overheadLength +=
|
|
13807
|
+
this._overheadLength +=
|
|
13808
|
+
Buffer.byteLength(header) +
|
|
13809
|
+
FormData.LINE_BREAK.length;
|
|
13856
13810
|
|
|
13857
13811
|
// empty or either doesn't have path or not an http response or not a stream
|
|
13858
|
-
if (!value || (!value.path && !(value.readable &&
|
|
13812
|
+
if (!value || ( !value.path && !(value.readable && Object.prototype.hasOwnProperty.call(value, 'httpVersion')) && !(value instanceof Stream$1))) {
|
|
13859
13813
|
return;
|
|
13860
13814
|
}
|
|
13861
13815
|
|
|
@@ -13865,8 +13819,9 @@ function requireForm_data () {
|
|
|
13865
13819
|
}
|
|
13866
13820
|
};
|
|
13867
13821
|
|
|
13868
|
-
FormData.prototype._lengthRetriever = function
|
|
13869
|
-
if (
|
|
13822
|
+
FormData.prototype._lengthRetriever = function(value, callback) {
|
|
13823
|
+
if (Object.prototype.hasOwnProperty.call(value, 'fd')) {
|
|
13824
|
+
|
|
13870
13825
|
// take read range into a account
|
|
13871
13826
|
// `end` = Infinity –> read file till the end
|
|
13872
13827
|
//
|
|
@@ -13875,52 +13830,54 @@ function requireForm_data () {
|
|
|
13875
13830
|
// Fix it when node fixes it.
|
|
13876
13831
|
// https://github.com/joyent/node/issues/7819
|
|
13877
13832
|
if (value.end != undefined && value.end != Infinity && value.start != undefined) {
|
|
13833
|
+
|
|
13878
13834
|
// when end specified
|
|
13879
13835
|
// no need to calculate range
|
|
13880
13836
|
// inclusive, starts with 0
|
|
13881
|
-
callback(null, value.end + 1 - (value.start ? value.start : 0));
|
|
13837
|
+
callback(null, value.end + 1 - (value.start ? value.start : 0));
|
|
13882
13838
|
|
|
13883
|
-
|
|
13839
|
+
// not that fast snoopy
|
|
13884
13840
|
} else {
|
|
13885
13841
|
// still need to fetch file size from fs
|
|
13886
|
-
fs.stat(value.path, function
|
|
13842
|
+
fs.stat(value.path, function(err, stat) {
|
|
13843
|
+
|
|
13844
|
+
var fileSize;
|
|
13845
|
+
|
|
13887
13846
|
if (err) {
|
|
13888
13847
|
callback(err);
|
|
13889
13848
|
return;
|
|
13890
13849
|
}
|
|
13891
13850
|
|
|
13892
13851
|
// update final size based on the range options
|
|
13893
|
-
|
|
13852
|
+
fileSize = stat.size - (value.start ? value.start : 0);
|
|
13894
13853
|
callback(null, fileSize);
|
|
13895
13854
|
});
|
|
13896
13855
|
}
|
|
13897
13856
|
|
|
13898
|
-
|
|
13899
|
-
} else if (
|
|
13900
|
-
callback(null,
|
|
13857
|
+
// or http response
|
|
13858
|
+
} else if (Object.prototype.hasOwnProperty.call(value, 'httpVersion')) {
|
|
13859
|
+
callback(null, +value.headers['content-length']);
|
|
13901
13860
|
|
|
13902
|
-
|
|
13903
|
-
} else if (
|
|
13861
|
+
// or request stream http://github.com/mikeal/request
|
|
13862
|
+
} else if (Object.prototype.hasOwnProperty.call(value, 'httpModule')) {
|
|
13904
13863
|
// wait till response come back
|
|
13905
|
-
value.on('response', function
|
|
13864
|
+
value.on('response', function(response) {
|
|
13906
13865
|
value.pause();
|
|
13907
|
-
callback(null,
|
|
13866
|
+
callback(null, +response.headers['content-length']);
|
|
13908
13867
|
});
|
|
13909
13868
|
value.resume();
|
|
13910
13869
|
|
|
13911
|
-
|
|
13870
|
+
// something else
|
|
13912
13871
|
} else {
|
|
13913
|
-
callback('Unknown stream');
|
|
13872
|
+
callback('Unknown stream');
|
|
13914
13873
|
}
|
|
13915
13874
|
};
|
|
13916
13875
|
|
|
13917
|
-
FormData.prototype._multiPartHeader = function
|
|
13918
|
-
|
|
13919
|
-
|
|
13920
|
-
|
|
13921
|
-
|
|
13922
|
-
*/
|
|
13923
|
-
if (typeof options.header === 'string') {
|
|
13876
|
+
FormData.prototype._multiPartHeader = function(field, value, options) {
|
|
13877
|
+
// custom header specified (as string)?
|
|
13878
|
+
// it becomes responsible for boundary
|
|
13879
|
+
// (e.g. to handle extra CRLFs on .NET servers)
|
|
13880
|
+
if (typeof options.header == 'string') {
|
|
13924
13881
|
return options.header;
|
|
13925
13882
|
}
|
|
13926
13883
|
|
|
@@ -13928,7 +13885,7 @@ function requireForm_data () {
|
|
|
13928
13885
|
var contentType = this._getContentType(value, options);
|
|
13929
13886
|
|
|
13930
13887
|
var contents = '';
|
|
13931
|
-
var headers
|
|
13888
|
+
var headers = {
|
|
13932
13889
|
// add custom disposition as third element or keep it two elements if not
|
|
13933
13890
|
'Content-Disposition': ['form-data', 'name="' + field + '"'].concat(contentDisposition || []),
|
|
13934
13891
|
// if no content type. allow it to be empty array
|
|
@@ -13936,18 +13893,18 @@ function requireForm_data () {
|
|
|
13936
13893
|
};
|
|
13937
13894
|
|
|
13938
13895
|
// allow custom headers.
|
|
13939
|
-
if (typeof options.header
|
|
13896
|
+
if (typeof options.header == 'object') {
|
|
13940
13897
|
populate(headers, options.header);
|
|
13941
13898
|
}
|
|
13942
13899
|
|
|
13943
13900
|
var header;
|
|
13944
|
-
for (var prop in headers) {
|
|
13945
|
-
if (
|
|
13901
|
+
for (var prop in headers) {
|
|
13902
|
+
if (Object.prototype.hasOwnProperty.call(headers, prop)) {
|
|
13946
13903
|
header = headers[prop];
|
|
13947
13904
|
|
|
13948
13905
|
// skip nullish headers.
|
|
13949
13906
|
if (header == null) {
|
|
13950
|
-
continue;
|
|
13907
|
+
continue;
|
|
13951
13908
|
}
|
|
13952
13909
|
|
|
13953
13910
|
// convert all headers to arrays.
|
|
@@ -13965,45 +13922,49 @@ function requireForm_data () {
|
|
|
13965
13922
|
return '--' + this.getBoundary() + FormData.LINE_BREAK + contents + FormData.LINE_BREAK;
|
|
13966
13923
|
};
|
|
13967
13924
|
|
|
13968
|
-
FormData.prototype._getContentDisposition = function
|
|
13969
|
-
|
|
13925
|
+
FormData.prototype._getContentDisposition = function(value, options) {
|
|
13926
|
+
|
|
13927
|
+
var filename
|
|
13928
|
+
, contentDisposition
|
|
13929
|
+
;
|
|
13970
13930
|
|
|
13971
13931
|
if (typeof options.filepath === 'string') {
|
|
13972
13932
|
// custom filepath for relative paths
|
|
13973
13933
|
filename = path.normalize(options.filepath).replace(/\\/g, '/');
|
|
13974
|
-
} else if (options.filename ||
|
|
13975
|
-
|
|
13976
|
-
|
|
13977
|
-
|
|
13978
|
-
|
|
13979
|
-
|
|
13980
|
-
filename = path.basename(options.filename || (value && (value.name || value.path)));
|
|
13981
|
-
} else if (value && value.readable && hasOwn(value, 'httpVersion')) {
|
|
13934
|
+
} else if (options.filename || value.name || value.path) {
|
|
13935
|
+
// custom filename take precedence
|
|
13936
|
+
// formidable and the browser add a name property
|
|
13937
|
+
// fs- and request- streams have path property
|
|
13938
|
+
filename = path.basename(options.filename || value.name || value.path);
|
|
13939
|
+
} else if (value.readable && Object.prototype.hasOwnProperty.call(value, 'httpVersion')) {
|
|
13982
13940
|
// or try http response
|
|
13983
13941
|
filename = path.basename(value.client._httpMessage.path || '');
|
|
13984
13942
|
}
|
|
13985
13943
|
|
|
13986
13944
|
if (filename) {
|
|
13987
|
-
|
|
13945
|
+
contentDisposition = 'filename="' + filename + '"';
|
|
13988
13946
|
}
|
|
13947
|
+
|
|
13948
|
+
return contentDisposition;
|
|
13989
13949
|
};
|
|
13990
13950
|
|
|
13991
|
-
FormData.prototype._getContentType = function
|
|
13951
|
+
FormData.prototype._getContentType = function(value, options) {
|
|
13952
|
+
|
|
13992
13953
|
// use custom content-type above all
|
|
13993
13954
|
var contentType = options.contentType;
|
|
13994
13955
|
|
|
13995
13956
|
// or try `name` from formidable, browser
|
|
13996
|
-
if (!contentType && value
|
|
13957
|
+
if (!contentType && value.name) {
|
|
13997
13958
|
contentType = mime.lookup(value.name);
|
|
13998
13959
|
}
|
|
13999
13960
|
|
|
14000
13961
|
// or try `path` from fs-, request- streams
|
|
14001
|
-
if (!contentType && value
|
|
13962
|
+
if (!contentType && value.path) {
|
|
14002
13963
|
contentType = mime.lookup(value.path);
|
|
14003
13964
|
}
|
|
14004
13965
|
|
|
14005
13966
|
// or if it's http-reponse
|
|
14006
|
-
if (!contentType && value
|
|
13967
|
+
if (!contentType && value.readable && Object.prototype.hasOwnProperty.call(value, 'httpVersion')) {
|
|
14007
13968
|
contentType = value.headers['content-type'];
|
|
14008
13969
|
}
|
|
14009
13970
|
|
|
@@ -14013,18 +13974,18 @@ function requireForm_data () {
|
|
|
14013
13974
|
}
|
|
14014
13975
|
|
|
14015
13976
|
// fallback to the default content type if `value` is not simple value
|
|
14016
|
-
if (!contentType &&
|
|
13977
|
+
if (!contentType && typeof value == 'object') {
|
|
14017
13978
|
contentType = FormData.DEFAULT_CONTENT_TYPE;
|
|
14018
13979
|
}
|
|
14019
13980
|
|
|
14020
13981
|
return contentType;
|
|
14021
13982
|
};
|
|
14022
13983
|
|
|
14023
|
-
FormData.prototype._multiPartFooter = function
|
|
14024
|
-
return function
|
|
13984
|
+
FormData.prototype._multiPartFooter = function() {
|
|
13985
|
+
return function(next) {
|
|
14025
13986
|
var footer = FormData.LINE_BREAK;
|
|
14026
13987
|
|
|
14027
|
-
var lastPart = this._streams.length === 0;
|
|
13988
|
+
var lastPart = (this._streams.length === 0);
|
|
14028
13989
|
if (lastPart) {
|
|
14029
13990
|
footer += this._lastBoundary();
|
|
14030
13991
|
}
|
|
@@ -14033,18 +13994,18 @@ function requireForm_data () {
|
|
|
14033
13994
|
}.bind(this);
|
|
14034
13995
|
};
|
|
14035
13996
|
|
|
14036
|
-
FormData.prototype._lastBoundary = function
|
|
13997
|
+
FormData.prototype._lastBoundary = function() {
|
|
14037
13998
|
return '--' + this.getBoundary() + '--' + FormData.LINE_BREAK;
|
|
14038
13999
|
};
|
|
14039
14000
|
|
|
14040
|
-
FormData.prototype.getHeaders = function
|
|
14001
|
+
FormData.prototype.getHeaders = function(userHeaders) {
|
|
14041
14002
|
var header;
|
|
14042
14003
|
var formHeaders = {
|
|
14043
14004
|
'content-type': 'multipart/form-data; boundary=' + this.getBoundary()
|
|
14044
14005
|
};
|
|
14045
14006
|
|
|
14046
|
-
for (header in userHeaders) {
|
|
14047
|
-
if (
|
|
14007
|
+
for (header in userHeaders) {
|
|
14008
|
+
if (Object.prototype.hasOwnProperty.call(userHeaders, header)) {
|
|
14048
14009
|
formHeaders[header.toLowerCase()] = userHeaders[header];
|
|
14049
14010
|
}
|
|
14050
14011
|
}
|
|
@@ -14052,14 +14013,11 @@ function requireForm_data () {
|
|
|
14052
14013
|
return formHeaders;
|
|
14053
14014
|
};
|
|
14054
14015
|
|
|
14055
|
-
FormData.prototype.setBoundary = function
|
|
14056
|
-
if (typeof boundary !== 'string') {
|
|
14057
|
-
throw new TypeError('FormData boundary must be a string');
|
|
14058
|
-
}
|
|
14016
|
+
FormData.prototype.setBoundary = function(boundary) {
|
|
14059
14017
|
this._boundary = boundary;
|
|
14060
14018
|
};
|
|
14061
14019
|
|
|
14062
|
-
FormData.prototype.getBoundary = function
|
|
14020
|
+
FormData.prototype.getBoundary = function() {
|
|
14063
14021
|
if (!this._boundary) {
|
|
14064
14022
|
this._generateBoundary();
|
|
14065
14023
|
}
|
|
@@ -14067,55 +14025,60 @@ function requireForm_data () {
|
|
|
14067
14025
|
return this._boundary;
|
|
14068
14026
|
};
|
|
14069
14027
|
|
|
14070
|
-
FormData.prototype.getBuffer = function
|
|
14071
|
-
var dataBuffer = new Buffer.alloc(0);
|
|
14028
|
+
FormData.prototype.getBuffer = function() {
|
|
14029
|
+
var dataBuffer = new Buffer.alloc(0);
|
|
14072
14030
|
var boundary = this.getBoundary();
|
|
14073
14031
|
|
|
14074
14032
|
// Create the form content. Add Line breaks to the end of data.
|
|
14075
14033
|
for (var i = 0, len = this._streams.length; i < len; i++) {
|
|
14076
14034
|
if (typeof this._streams[i] !== 'function') {
|
|
14035
|
+
|
|
14077
14036
|
// Add content to the buffer.
|
|
14078
|
-
if
|
|
14079
|
-
dataBuffer = Buffer.concat([dataBuffer, this._streams[i]]);
|
|
14080
|
-
}
|
|
14081
|
-
dataBuffer = Buffer.concat([dataBuffer, Buffer.from(this._streams[i])]);
|
|
14037
|
+
if(Buffer.isBuffer(this._streams[i])) {
|
|
14038
|
+
dataBuffer = Buffer.concat( [dataBuffer, this._streams[i]]);
|
|
14039
|
+
}else {
|
|
14040
|
+
dataBuffer = Buffer.concat( [dataBuffer, Buffer.from(this._streams[i])]);
|
|
14082
14041
|
}
|
|
14083
14042
|
|
|
14084
14043
|
// Add break after content.
|
|
14085
|
-
if (typeof this._streams[i] !== 'string' || this._streams[i].substring(2, boundary.length + 2) !== boundary) {
|
|
14086
|
-
dataBuffer = Buffer.concat([dataBuffer, Buffer.from(FormData.LINE_BREAK)]);
|
|
14044
|
+
if (typeof this._streams[i] !== 'string' || this._streams[i].substring( 2, boundary.length + 2 ) !== boundary) {
|
|
14045
|
+
dataBuffer = Buffer.concat( [dataBuffer, Buffer.from(FormData.LINE_BREAK)] );
|
|
14087
14046
|
}
|
|
14088
14047
|
}
|
|
14089
14048
|
}
|
|
14090
14049
|
|
|
14091
14050
|
// Add the footer and return the Buffer object.
|
|
14092
|
-
return Buffer.concat([dataBuffer, Buffer.from(this._lastBoundary())]);
|
|
14051
|
+
return Buffer.concat( [dataBuffer, Buffer.from(this._lastBoundary())] );
|
|
14093
14052
|
};
|
|
14094
14053
|
|
|
14095
|
-
FormData.prototype._generateBoundary = function
|
|
14054
|
+
FormData.prototype._generateBoundary = function() {
|
|
14096
14055
|
// This generates a 50 character boundary similar to those used by Firefox.
|
|
14097
|
-
|
|
14098
14056
|
// They are optimized for boyer-moore parsing.
|
|
14099
|
-
|
|
14057
|
+
var boundary = '--------------------------';
|
|
14058
|
+
for (var i = 0; i < 24; i++) {
|
|
14059
|
+
boundary += Math.floor(Math.random() * 10).toString(16);
|
|
14060
|
+
}
|
|
14061
|
+
|
|
14062
|
+
this._boundary = boundary;
|
|
14100
14063
|
};
|
|
14101
14064
|
|
|
14102
14065
|
// Note: getLengthSync DOESN'T calculate streams length
|
|
14103
|
-
// As workaround one can calculate file size manually
|
|
14104
|
-
|
|
14066
|
+
// As workaround one can calculate file size manually
|
|
14067
|
+
// and add it as knownLength option
|
|
14068
|
+
FormData.prototype.getLengthSync = function() {
|
|
14105
14069
|
var knownLength = this._overheadLength + this._valueLength;
|
|
14106
14070
|
|
|
14107
|
-
// Don't get confused, there are 3 "internal" streams for each keyval pair
|
|
14071
|
+
// Don't get confused, there are 3 "internal" streams for each keyval pair
|
|
14072
|
+
// so it basically checks if there is any value added to the form
|
|
14108
14073
|
if (this._streams.length) {
|
|
14109
14074
|
knownLength += this._lastBoundary().length;
|
|
14110
14075
|
}
|
|
14111
14076
|
|
|
14112
14077
|
// https://github.com/form-data/form-data/issues/40
|
|
14113
14078
|
if (!this.hasKnownLength()) {
|
|
14114
|
-
|
|
14115
|
-
|
|
14116
|
-
|
|
14117
|
-
* Please use getLength(callback) to get proper length
|
|
14118
|
-
*/
|
|
14079
|
+
// Some async length retrievers are present
|
|
14080
|
+
// therefore synchronous length calculation is false.
|
|
14081
|
+
// Please use getLength(callback) to get proper length
|
|
14119
14082
|
this._error(new Error('Cannot calculate proper length in synchronous way.'));
|
|
14120
14083
|
}
|
|
14121
14084
|
|
|
@@ -14125,7 +14088,7 @@ function requireForm_data () {
|
|
|
14125
14088
|
// Public API to check if length of added values is known
|
|
14126
14089
|
// https://github.com/form-data/form-data/issues/196
|
|
14127
14090
|
// https://github.com/form-data/form-data/issues/262
|
|
14128
|
-
FormData.prototype.hasKnownLength = function
|
|
14091
|
+
FormData.prototype.hasKnownLength = function() {
|
|
14129
14092
|
var hasKnownLength = true;
|
|
14130
14093
|
|
|
14131
14094
|
if (this._valuesToMeasure.length) {
|
|
@@ -14135,7 +14098,7 @@ function requireForm_data () {
|
|
|
14135
14098
|
return hasKnownLength;
|
|
14136
14099
|
};
|
|
14137
14100
|
|
|
14138
|
-
FormData.prototype.getLength = function
|
|
14101
|
+
FormData.prototype.getLength = function(cb) {
|
|
14139
14102
|
var knownLength = this._overheadLength + this._valueLength;
|
|
14140
14103
|
|
|
14141
14104
|
if (this._streams.length) {
|
|
@@ -14147,13 +14110,13 @@ function requireForm_data () {
|
|
|
14147
14110
|
return;
|
|
14148
14111
|
}
|
|
14149
14112
|
|
|
14150
|
-
asynckit.parallel(this._valuesToMeasure, this._lengthRetriever, function
|
|
14113
|
+
asynckit.parallel(this._valuesToMeasure, this._lengthRetriever, function(err, values) {
|
|
14151
14114
|
if (err) {
|
|
14152
14115
|
cb(err);
|
|
14153
14116
|
return;
|
|
14154
14117
|
}
|
|
14155
14118
|
|
|
14156
|
-
values.forEach(function
|
|
14119
|
+
values.forEach(function(length) {
|
|
14157
14120
|
knownLength += length;
|
|
14158
14121
|
});
|
|
14159
14122
|
|
|
@@ -14161,26 +14124,31 @@ function requireForm_data () {
|
|
|
14161
14124
|
});
|
|
14162
14125
|
};
|
|
14163
14126
|
|
|
14164
|
-
FormData.prototype.submit = function
|
|
14165
|
-
var request
|
|
14166
|
-
|
|
14167
|
-
|
|
14127
|
+
FormData.prototype.submit = function(params, cb) {
|
|
14128
|
+
var request
|
|
14129
|
+
, options
|
|
14130
|
+
, defaults = {method: 'post'}
|
|
14131
|
+
;
|
|
14168
14132
|
|
|
14169
|
-
// parse provided url if it's string
|
|
14170
|
-
|
|
14171
|
-
|
|
14172
|
-
|
|
14133
|
+
// parse provided url if it's string
|
|
14134
|
+
// or treat it as options object
|
|
14135
|
+
if (typeof params == 'string') {
|
|
14136
|
+
|
|
14137
|
+
params = parseUrl(params);
|
|
14173
14138
|
options = populate({
|
|
14174
14139
|
port: params.port,
|
|
14175
14140
|
path: params.pathname,
|
|
14176
14141
|
host: params.hostname,
|
|
14177
14142
|
protocol: params.protocol
|
|
14178
14143
|
}, defaults);
|
|
14179
|
-
|
|
14144
|
+
|
|
14145
|
+
// use custom params
|
|
14146
|
+
} else {
|
|
14147
|
+
|
|
14180
14148
|
options = populate(params, defaults);
|
|
14181
14149
|
// if no port provided use default one
|
|
14182
14150
|
if (!options.port) {
|
|
14183
|
-
options.port = options.protocol
|
|
14151
|
+
options.port = options.protocol == 'https:' ? 443 : 80;
|
|
14184
14152
|
}
|
|
14185
14153
|
}
|
|
14186
14154
|
|
|
@@ -14188,14 +14156,14 @@ function requireForm_data () {
|
|
|
14188
14156
|
options.headers = this.getHeaders(params.headers);
|
|
14189
14157
|
|
|
14190
14158
|
// https if specified, fallback to http in any other case
|
|
14191
|
-
if (options.protocol
|
|
14159
|
+
if (options.protocol == 'https:') {
|
|
14192
14160
|
request = https$1.request(options);
|
|
14193
14161
|
} else {
|
|
14194
14162
|
request = http$1.request(options);
|
|
14195
14163
|
}
|
|
14196
14164
|
|
|
14197
14165
|
// get content length and fire away
|
|
14198
|
-
this.getLength(function
|
|
14166
|
+
this.getLength(function(err, length) {
|
|
14199
14167
|
if (err && err !== 'Unknown stream') {
|
|
14200
14168
|
this._error(err);
|
|
14201
14169
|
return;
|
|
@@ -14214,7 +14182,7 @@ function requireForm_data () {
|
|
|
14214
14182
|
request.removeListener('error', callback);
|
|
14215
14183
|
request.removeListener('response', onResponse);
|
|
14216
14184
|
|
|
14217
|
-
return cb.call(this, error, responce);
|
|
14185
|
+
return cb.call(this, error, responce);
|
|
14218
14186
|
};
|
|
14219
14187
|
|
|
14220
14188
|
onResponse = callback.bind(this, null);
|
|
@@ -14227,7 +14195,7 @@ function requireForm_data () {
|
|
|
14227
14195
|
return request;
|
|
14228
14196
|
};
|
|
14229
14197
|
|
|
14230
|
-
FormData.prototype._error = function
|
|
14198
|
+
FormData.prototype._error = function(err) {
|
|
14231
14199
|
if (!this.error) {
|
|
14232
14200
|
this.error = err;
|
|
14233
14201
|
this.pause();
|
|
@@ -14239,9 +14207,6 @@ function requireForm_data () {
|
|
|
14239
14207
|
return '[object FormData]';
|
|
14240
14208
|
};
|
|
14241
14209
|
setToStringTag(FormData, 'FormData');
|
|
14242
|
-
|
|
14243
|
-
// Public API
|
|
14244
|
-
form_data = FormData;
|
|
14245
14210
|
return form_data;
|
|
14246
14211
|
}
|
|
14247
14212
|
|
|
@@ -14363,10 +14328,6 @@ function toFormData$1(obj, formData, options) {
|
|
|
14363
14328
|
return value.toISOString();
|
|
14364
14329
|
}
|
|
14365
14330
|
|
|
14366
|
-
if (utils$4.isBoolean(value)) {
|
|
14367
|
-
return value.toString();
|
|
14368
|
-
}
|
|
14369
|
-
|
|
14370
14331
|
if (!useBlob && utils$4.isBlob(value)) {
|
|
14371
14332
|
throw new AxiosError$1('Blob is not supported. Use a Buffer instead.');
|
|
14372
14333
|
}
|
|
@@ -14669,7 +14630,7 @@ const generateString = (size = 16, alphabet = ALPHABET.ALPHA_DIGIT) => {
|
|
|
14669
14630
|
let str = '';
|
|
14670
14631
|
const {length} = alphabet;
|
|
14671
14632
|
const randomValues = new Uint32Array(size);
|
|
14672
|
-
|
|
14633
|
+
crypto$2.randomFillSync(randomValues);
|
|
14673
14634
|
for (let i = 0; i < size; i++) {
|
|
14674
14635
|
str += alphabet[randomValues[i] % length];
|
|
14675
14636
|
}
|
|
@@ -14749,7 +14710,7 @@ var platform = {
|
|
|
14749
14710
|
};
|
|
14750
14711
|
|
|
14751
14712
|
function toURLEncodedForm(data, options) {
|
|
14752
|
-
return toFormData$1(data, new platform.classes.URLSearchParams(), {
|
|
14713
|
+
return toFormData$1(data, new platform.classes.URLSearchParams(), Object.assign({
|
|
14753
14714
|
visitor: function(value, key, path, helpers) {
|
|
14754
14715
|
if (platform.isNode && utils$4.isBuffer(value)) {
|
|
14755
14716
|
this.append(key, value.toString('base64'));
|
|
@@ -14757,9 +14718,8 @@ function toURLEncodedForm(data, options) {
|
|
|
14757
14718
|
}
|
|
14758
14719
|
|
|
14759
14720
|
return helpers.defaultVisitor.apply(this, arguments);
|
|
14760
|
-
}
|
|
14761
|
-
|
|
14762
|
-
});
|
|
14721
|
+
}
|
|
14722
|
+
}, options));
|
|
14763
14723
|
}
|
|
14764
14724
|
|
|
14765
14725
|
/**
|
|
@@ -15151,18 +15111,10 @@ let AxiosHeaders$1 = class AxiosHeaders {
|
|
|
15151
15111
|
setHeaders(header, valueOrRewrite);
|
|
15152
15112
|
} else if(utils$4.isString(header) && (header = header.trim()) && !isValidHeaderName(header)) {
|
|
15153
15113
|
setHeaders(parseHeaders(header), valueOrRewrite);
|
|
15154
|
-
} else if (utils$4.
|
|
15155
|
-
|
|
15156
|
-
|
|
15157
|
-
if (!utils$4.isArray(entry)) {
|
|
15158
|
-
throw TypeError('Object iterator must return a key-value pair');
|
|
15159
|
-
}
|
|
15160
|
-
|
|
15161
|
-
obj[key = entry[0]] = (dest = obj[key]) ?
|
|
15162
|
-
(utils$4.isArray(dest) ? [...dest, entry[1]] : [dest, entry[1]]) : entry[1];
|
|
15114
|
+
} else if (utils$4.isHeaders(header)) {
|
|
15115
|
+
for (const [key, value] of header.entries()) {
|
|
15116
|
+
setHeader(value, key, rewrite);
|
|
15163
15117
|
}
|
|
15164
|
-
|
|
15165
|
-
setHeaders(obj, valueOrRewrite);
|
|
15166
15118
|
} else {
|
|
15167
15119
|
header != null && setHeader(valueOrRewrite, header, rewrite);
|
|
15168
15120
|
}
|
|
@@ -15304,10 +15256,6 @@ let AxiosHeaders$1 = class AxiosHeaders {
|
|
|
15304
15256
|
return Object.entries(this.toJSON()).map(([header, value]) => header + ': ' + value).join('\n');
|
|
15305
15257
|
}
|
|
15306
15258
|
|
|
15307
|
-
getSetCookie() {
|
|
15308
|
-
return this.get("set-cookie") || [];
|
|
15309
|
-
}
|
|
15310
|
-
|
|
15311
15259
|
get [Symbol.toStringTag]() {
|
|
15312
15260
|
return 'AxiosHeaders';
|
|
15313
15261
|
}
|
|
@@ -15472,7 +15420,7 @@ function combineURLs(baseURL, relativeURL) {
|
|
|
15472
15420
|
*/
|
|
15473
15421
|
function buildFullPath(baseURL, requestedURL, allowAbsoluteUrls) {
|
|
15474
15422
|
let isRelativeUrl = !isAbsoluteURL(requestedURL);
|
|
15475
|
-
if (baseURL &&
|
|
15423
|
+
if (baseURL && isRelativeUrl || allowAbsoluteUrls == false) {
|
|
15476
15424
|
return combineURLs(baseURL, requestedURL);
|
|
15477
15425
|
}
|
|
15478
15426
|
return requestedURL;
|
|
@@ -15950,7 +15898,7 @@ function requireCommon () {
|
|
|
15950
15898
|
|
|
15951
15899
|
const split = (typeof namespaces === 'string' ? namespaces : '')
|
|
15952
15900
|
.trim()
|
|
15953
|
-
.replace(
|
|
15901
|
+
.replace(' ', ',')
|
|
15954
15902
|
.split(',')
|
|
15955
15903
|
.filter(Boolean);
|
|
15956
15904
|
|
|
@@ -16302,7 +16250,7 @@ function requireBrowser () {
|
|
|
16302
16250
|
function load() {
|
|
16303
16251
|
let r;
|
|
16304
16252
|
try {
|
|
16305
|
-
r = exports.storage.getItem('debug')
|
|
16253
|
+
r = exports.storage.getItem('debug');
|
|
16306
16254
|
} catch (error) {
|
|
16307
16255
|
// Swallow
|
|
16308
16256
|
// XXX (@Qix-) should we be logging these?
|
|
@@ -17530,7 +17478,7 @@ function requireFollowRedirects () {
|
|
|
17530
17478
|
var followRedirectsExports = requireFollowRedirects();
|
|
17531
17479
|
var followRedirects = /*@__PURE__*/getDefaultExportFromCjs(followRedirectsExports);
|
|
17532
17480
|
|
|
17533
|
-
const VERSION$1 = "1.
|
|
17481
|
+
const VERSION$1 = "1.8.2";
|
|
17534
17482
|
|
|
17535
17483
|
function parseProtocol(url) {
|
|
17536
17484
|
const match = /^([-+\w]{1,25})(:?\/\/|:)/.exec(url);
|
|
@@ -17808,7 +17756,7 @@ const formDataToStream = (form, headersHandler, options) => {
|
|
|
17808
17756
|
}
|
|
17809
17757
|
|
|
17810
17758
|
const boundaryBytes = textEncoder.encode('--' + boundary + CRLF);
|
|
17811
|
-
const footerBytes = textEncoder.encode('--' + boundary + '--' + CRLF);
|
|
17759
|
+
const footerBytes = textEncoder.encode('--' + boundary + '--' + CRLF + CRLF);
|
|
17812
17760
|
let contentLength = footerBytes.byteLength;
|
|
17813
17761
|
|
|
17814
17762
|
const parts = Array.from(form.entries()).map(([name, value]) => {
|
|
@@ -17948,7 +17896,7 @@ function throttle(fn, freq) {
|
|
|
17948
17896
|
clearTimeout(timer);
|
|
17949
17897
|
timer = null;
|
|
17950
17898
|
}
|
|
17951
|
-
fn(
|
|
17899
|
+
fn.apply(null, args);
|
|
17952
17900
|
};
|
|
17953
17901
|
|
|
17954
17902
|
const throttled = (...args) => {
|
|
@@ -18822,7 +18770,7 @@ function mergeConfig$1(config1, config2) {
|
|
|
18822
18770
|
headers: (a, b , prop) => mergeDeepProperties(headersToObject(a), headersToObject(b),prop, true)
|
|
18823
18771
|
};
|
|
18824
18772
|
|
|
18825
|
-
utils$4.forEach(Object.keys({
|
|
18773
|
+
utils$4.forEach(Object.keys(Object.assign({}, config1, config2)), function computeConfigValue(prop) {
|
|
18826
18774
|
const merge = mergeMap[prop] || mergeDeepProperties;
|
|
18827
18775
|
const configValue = merge(config1[prop], config2[prop], prop);
|
|
18828
18776
|
(utils$4.isUndefined(configValue) && merge !== mergeDirectKeys) || (config[prop] = configValue);
|
|
@@ -18838,7 +18786,7 @@ var resolveConfig = (config) => {
|
|
|
18838
18786
|
|
|
18839
18787
|
newConfig.headers = headers = AxiosHeaders$1.from(headers);
|
|
18840
18788
|
|
|
18841
|
-
newConfig.url = buildURL(buildFullPath(newConfig.baseURL, newConfig.url
|
|
18789
|
+
newConfig.url = buildURL(buildFullPath(newConfig.baseURL, newConfig.url), config.params, config.paramsSerializer);
|
|
18842
18790
|
|
|
18843
18791
|
// HTTP basic authentication
|
|
18844
18792
|
if (auth) {
|
|
@@ -19355,7 +19303,7 @@ var fetchAdapter = isFetchSupported && (async (config) => {
|
|
|
19355
19303
|
credentials: isCredentialsSupported ? withCredentials : undefined
|
|
19356
19304
|
});
|
|
19357
19305
|
|
|
19358
|
-
let response = await fetch(request
|
|
19306
|
+
let response = await fetch(request);
|
|
19359
19307
|
|
|
19360
19308
|
const isStreamResponse = supportsResponseStream && (responseType === 'stream' || responseType === 'response');
|
|
19361
19309
|
|
|
@@ -19401,7 +19349,7 @@ var fetchAdapter = isFetchSupported && (async (config) => {
|
|
|
19401
19349
|
} catch (err) {
|
|
19402
19350
|
unsubscribe && unsubscribe();
|
|
19403
19351
|
|
|
19404
|
-
if (err && err.name === 'TypeError' && /
|
|
19352
|
+
if (err && err.name === 'TypeError' && /fetch/i.test(err.message)) {
|
|
19405
19353
|
throw Object.assign(
|
|
19406
19354
|
new AxiosError$1('Network Error', AxiosError$1.ERR_NETWORK, config, request),
|
|
19407
19355
|
{
|
|
@@ -19667,7 +19615,7 @@ const validators = validator$1.validators;
|
|
|
19667
19615
|
*/
|
|
19668
19616
|
let Axios$1 = class Axios {
|
|
19669
19617
|
constructor(instanceConfig) {
|
|
19670
|
-
this.defaults = instanceConfig
|
|
19618
|
+
this.defaults = instanceConfig;
|
|
19671
19619
|
this.interceptors = {
|
|
19672
19620
|
request: new InterceptorManager(),
|
|
19673
19621
|
response: new InterceptorManager()
|
|
@@ -19798,8 +19746,8 @@ let Axios$1 = class Axios {
|
|
|
19798
19746
|
|
|
19799
19747
|
if (!synchronousRequestInterceptors) {
|
|
19800
19748
|
const chain = [dispatchRequest.bind(this), undefined];
|
|
19801
|
-
chain.unshift(
|
|
19802
|
-
chain.push(
|
|
19749
|
+
chain.unshift.apply(chain, requestInterceptorChain);
|
|
19750
|
+
chain.push.apply(chain, responseInterceptorChain);
|
|
19803
19751
|
len = chain.length;
|
|
19804
19752
|
|
|
19805
19753
|
promise = Promise.resolve(config);
|
|
@@ -20214,6 +20162,7 @@ const {
|
|
|
20214
20162
|
/** @format */
|
|
20215
20163
|
const DimoEnvironment = {
|
|
20216
20164
|
Production: {
|
|
20165
|
+
Agents: 'https://agents.dimo.zone',
|
|
20217
20166
|
Attestation: 'https://attestation-api.dimo.zone',
|
|
20218
20167
|
Auth: 'https://auth.dimo.zone',
|
|
20219
20168
|
Identity: 'https://identity-api.dimo.zone/query',
|
|
@@ -20224,9 +20173,10 @@ const DimoEnvironment = {
|
|
|
20224
20173
|
Trips: 'https://trips-api.dimo.zone',
|
|
20225
20174
|
Valuations: 'https://valuations-api.dimo.zone',
|
|
20226
20175
|
VehicleSignalDecoding: 'https://vehicle-signal-decoding.dimo.zone',
|
|
20227
|
-
|
|
20176
|
+
VehicleTriggers: 'https://vehicle-triggers-api.dimo.zone',
|
|
20228
20177
|
},
|
|
20229
20178
|
Dev: {
|
|
20179
|
+
Agents: 'https://agents.dev.dimo.zone',
|
|
20230
20180
|
Attestation: 'https://attestation-api.dev.dimo.zone',
|
|
20231
20181
|
Auth: 'https://auth.dev.dimo.zone',
|
|
20232
20182
|
Identity: 'https://identity-api.dev.dimo.zone/query',
|
|
@@ -20237,7 +20187,7 @@ const DimoEnvironment = {
|
|
|
20237
20187
|
Trips: 'https://trips-api.dev.dimo.zone',
|
|
20238
20188
|
Valuations: 'https://valuations-api.dev.dimo.zone',
|
|
20239
20189
|
VehicleSignalDecoding: 'https://vehicle-signal-decoding.dev.dimo.zone',
|
|
20240
|
-
|
|
20190
|
+
VehicleTriggers: 'https://vehicle-triggers-api.dev.dimo.zone',
|
|
20241
20191
|
},
|
|
20242
20192
|
};
|
|
20243
20193
|
|
|
@@ -20682,6 +20632,7 @@ class Telemetry extends Resource$1 {
|
|
|
20682
20632
|
/** @format */
|
|
20683
20633
|
// import { Stream } from './streamr';
|
|
20684
20634
|
class DIMO {
|
|
20635
|
+
agents;
|
|
20685
20636
|
attestation;
|
|
20686
20637
|
auth;
|
|
20687
20638
|
devicedefinitions;
|
|
@@ -20691,13 +20642,14 @@ class DIMO {
|
|
|
20691
20642
|
tokenexchange;
|
|
20692
20643
|
trips;
|
|
20693
20644
|
valuations;
|
|
20694
|
-
|
|
20645
|
+
vehicleTriggers;
|
|
20695
20646
|
constructor(env) {
|
|
20696
20647
|
this.identity = new Identity(DimoEnvironment[env].Identity, env);
|
|
20697
20648
|
this.telemetry = new Telemetry(DimoEnvironment[env].Telemetry, env);
|
|
20698
20649
|
/**
|
|
20699
20650
|
* Set up all REST Endpoints
|
|
20700
20651
|
*/
|
|
20652
|
+
this.agents = new Agents(DimoEnvironment[env].Agents, env);
|
|
20701
20653
|
this.attestation = new Attestation(DimoEnvironment[env].Attestation, env);
|
|
20702
20654
|
this.auth = new Auth(DimoEnvironment[env].Auth, env);
|
|
20703
20655
|
this.devicedefinitions = new DeviceDefinitions(DimoEnvironment[env].DeviceDefinitions, env);
|
|
@@ -20705,7 +20657,7 @@ class DIMO {
|
|
|
20705
20657
|
this.tokenexchange = new TokenExchange(DimoEnvironment[env].TokenExchange, env);
|
|
20706
20658
|
this.trips = new Trips(DimoEnvironment[env].Trips, env);
|
|
20707
20659
|
this.valuations = new Valuations(DimoEnvironment[env].Valuations, env);
|
|
20708
|
-
this.
|
|
20660
|
+
this.vehicleTriggers = new VehicleTriggers(DimoEnvironment[env].VehicleTriggers, env);
|
|
20709
20661
|
}
|
|
20710
20662
|
// Helper Function
|
|
20711
20663
|
async authenticate() {
|
|
@@ -22914,7 +22866,7 @@ const keccak256 = (() => {
|
|
|
22914
22866
|
|
|
22915
22867
|
var util;
|
|
22916
22868
|
(function (util) {
|
|
22917
|
-
util.assertEqual = (
|
|
22869
|
+
util.assertEqual = (val) => val;
|
|
22918
22870
|
function assertIs(_arg) { }
|
|
22919
22871
|
util.assertIs = assertIs;
|
|
22920
22872
|
function assertNever(_x) {
|
|
@@ -22961,9 +22913,11 @@ var util;
|
|
|
22961
22913
|
};
|
|
22962
22914
|
util.isInteger = typeof Number.isInteger === "function"
|
|
22963
22915
|
? (val) => Number.isInteger(val) // eslint-disable-line ban/ban
|
|
22964
|
-
: (val) => typeof val === "number" &&
|
|
22916
|
+
: (val) => typeof val === "number" && isFinite(val) && Math.floor(val) === val;
|
|
22965
22917
|
function joinValues(array, separator = " | ") {
|
|
22966
|
-
return array
|
|
22918
|
+
return array
|
|
22919
|
+
.map((val) => (typeof val === "string" ? `'${val}'` : val))
|
|
22920
|
+
.join(separator);
|
|
22967
22921
|
}
|
|
22968
22922
|
util.joinValues = joinValues;
|
|
22969
22923
|
util.jsonStringifyReplacer = (_, value) => {
|
|
@@ -23012,7 +22966,7 @@ const getParsedType = (data) => {
|
|
|
23012
22966
|
case "string":
|
|
23013
22967
|
return ZodParsedType.string;
|
|
23014
22968
|
case "number":
|
|
23015
|
-
return
|
|
22969
|
+
return isNaN(data) ? ZodParsedType.nan : ZodParsedType.number;
|
|
23016
22970
|
case "boolean":
|
|
23017
22971
|
return ZodParsedType.boolean;
|
|
23018
22972
|
case "function":
|
|
@@ -23028,7 +22982,10 @@ const getParsedType = (data) => {
|
|
|
23028
22982
|
if (data === null) {
|
|
23029
22983
|
return ZodParsedType.null;
|
|
23030
22984
|
}
|
|
23031
|
-
if (data.then &&
|
|
22985
|
+
if (data.then &&
|
|
22986
|
+
typeof data.then === "function" &&
|
|
22987
|
+
data.catch &&
|
|
22988
|
+
typeof data.catch === "function") {
|
|
23032
22989
|
return ZodParsedType.promise;
|
|
23033
22990
|
}
|
|
23034
22991
|
if (typeof Map !== "undefined" && data instanceof Map) {
|
|
@@ -23160,9 +23117,8 @@ class ZodError extends Error {
|
|
|
23160
23117
|
const formErrors = [];
|
|
23161
23118
|
for (const sub of this.issues) {
|
|
23162
23119
|
if (sub.path.length > 0) {
|
|
23163
|
-
|
|
23164
|
-
fieldErrors[
|
|
23165
|
-
fieldErrors[firstEl].push(mapper(sub));
|
|
23120
|
+
fieldErrors[sub.path[0]] = fieldErrors[sub.path[0]] || [];
|
|
23121
|
+
fieldErrors[sub.path[0]].push(mapper(sub));
|
|
23166
23122
|
}
|
|
23167
23123
|
else {
|
|
23168
23124
|
formErrors.push(mapper(sub));
|
|
@@ -23245,11 +23201,17 @@ const errorMap = (issue, _ctx) => {
|
|
|
23245
23201
|
else if (issue.type === "string")
|
|
23246
23202
|
message = `String must contain ${issue.exact ? "exactly" : issue.inclusive ? `at least` : `over`} ${issue.minimum} character(s)`;
|
|
23247
23203
|
else if (issue.type === "number")
|
|
23248
|
-
message = `Number must be ${issue.exact
|
|
23249
|
-
|
|
23250
|
-
|
|
23204
|
+
message = `Number must be ${issue.exact
|
|
23205
|
+
? `exactly equal to `
|
|
23206
|
+
: issue.inclusive
|
|
23207
|
+
? `greater than or equal to `
|
|
23208
|
+
: `greater than `}${issue.minimum}`;
|
|
23251
23209
|
else if (issue.type === "date")
|
|
23252
|
-
message = `Date must be ${issue.exact
|
|
23210
|
+
message = `Date must be ${issue.exact
|
|
23211
|
+
? `exactly equal to `
|
|
23212
|
+
: issue.inclusive
|
|
23213
|
+
? `greater than or equal to `
|
|
23214
|
+
: `greater than `}${new Date(Number(issue.minimum))}`;
|
|
23253
23215
|
else
|
|
23254
23216
|
message = "Invalid input";
|
|
23255
23217
|
break;
|
|
@@ -23259,11 +23221,23 @@ const errorMap = (issue, _ctx) => {
|
|
|
23259
23221
|
else if (issue.type === "string")
|
|
23260
23222
|
message = `String must contain ${issue.exact ? `exactly` : issue.inclusive ? `at most` : `under`} ${issue.maximum} character(s)`;
|
|
23261
23223
|
else if (issue.type === "number")
|
|
23262
|
-
message = `Number must be ${issue.exact
|
|
23224
|
+
message = `Number must be ${issue.exact
|
|
23225
|
+
? `exactly`
|
|
23226
|
+
: issue.inclusive
|
|
23227
|
+
? `less than or equal to`
|
|
23228
|
+
: `less than`} ${issue.maximum}`;
|
|
23263
23229
|
else if (issue.type === "bigint")
|
|
23264
|
-
message = `BigInt must be ${issue.exact
|
|
23230
|
+
message = `BigInt must be ${issue.exact
|
|
23231
|
+
? `exactly`
|
|
23232
|
+
: issue.inclusive
|
|
23233
|
+
? `less than or equal to`
|
|
23234
|
+
: `less than`} ${issue.maximum}`;
|
|
23265
23235
|
else if (issue.type === "date")
|
|
23266
|
-
message = `Date must be ${issue.exact
|
|
23236
|
+
message = `Date must be ${issue.exact
|
|
23237
|
+
? `exactly`
|
|
23238
|
+
: issue.inclusive
|
|
23239
|
+
? `smaller than or equal to`
|
|
23240
|
+
: `smaller than`} ${new Date(Number(issue.maximum))}`;
|
|
23267
23241
|
else
|
|
23268
23242
|
message = "Invalid input";
|
|
23269
23243
|
break;
|
|
@@ -23385,7 +23359,8 @@ class ParseStatus {
|
|
|
23385
23359
|
status.dirty();
|
|
23386
23360
|
if (value.status === "dirty")
|
|
23387
23361
|
status.dirty();
|
|
23388
|
-
if (key.value !== "__proto__" &&
|
|
23362
|
+
if (key.value !== "__proto__" &&
|
|
23363
|
+
(typeof value.value !== "undefined" || pair.alwaysSet)) {
|
|
23389
23364
|
finalObject[key.value] = value.value;
|
|
23390
23365
|
}
|
|
23391
23366
|
}
|
|
@@ -23402,13 +23377,43 @@ const isDirty = (x) => x.status === "dirty";
|
|
|
23402
23377
|
const isValid$2 = (x) => x.status === "valid";
|
|
23403
23378
|
const isAsync = (x) => typeof Promise !== "undefined" && x instanceof Promise;
|
|
23404
23379
|
|
|
23380
|
+
/******************************************************************************
|
|
23381
|
+
Copyright (c) Microsoft Corporation.
|
|
23382
|
+
|
|
23383
|
+
Permission to use, copy, modify, and/or distribute this software for any
|
|
23384
|
+
purpose with or without fee is hereby granted.
|
|
23385
|
+
|
|
23386
|
+
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
|
23387
|
+
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
|
23388
|
+
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
|
23389
|
+
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
|
23390
|
+
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
23391
|
+
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
23392
|
+
PERFORMANCE OF THIS SOFTWARE.
|
|
23393
|
+
***************************************************************************** */
|
|
23394
|
+
|
|
23395
|
+
function __classPrivateFieldGet(receiver, state, kind, f) {
|
|
23396
|
+
if (typeof state === "function" ? receiver !== state || true : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
|
23397
|
+
return state.get(receiver);
|
|
23398
|
+
}
|
|
23399
|
+
|
|
23400
|
+
function __classPrivateFieldSet(receiver, state, value, kind, f) {
|
|
23401
|
+
if (typeof state === "function" ? receiver !== state || true : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
|
|
23402
|
+
return (state.set(receiver, value)), value;
|
|
23403
|
+
}
|
|
23404
|
+
|
|
23405
|
+
typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
|
|
23406
|
+
var e = new Error(message);
|
|
23407
|
+
return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
|
|
23408
|
+
};
|
|
23409
|
+
|
|
23405
23410
|
var errorUtil;
|
|
23406
23411
|
(function (errorUtil) {
|
|
23407
23412
|
errorUtil.errToObj = (message) => typeof message === "string" ? { message } : message || {};
|
|
23408
|
-
|
|
23409
|
-
errorUtil.toString = (message) => typeof message === "string" ? message : message?.message;
|
|
23413
|
+
errorUtil.toString = (message) => typeof message === "string" ? message : message === null || message === void 0 ? void 0 : message.message;
|
|
23410
23414
|
})(errorUtil || (errorUtil = {}));
|
|
23411
23415
|
|
|
23416
|
+
var _ZodEnum_cache, _ZodNativeEnum_cache;
|
|
23412
23417
|
class ParseInputLazyPath {
|
|
23413
23418
|
constructor(parent, value, path, key) {
|
|
23414
23419
|
this._cachedPath = [];
|
|
@@ -23419,7 +23424,7 @@ class ParseInputLazyPath {
|
|
|
23419
23424
|
}
|
|
23420
23425
|
get path() {
|
|
23421
23426
|
if (!this._cachedPath.length) {
|
|
23422
|
-
if (
|
|
23427
|
+
if (this._key instanceof Array) {
|
|
23423
23428
|
this._cachedPath.push(...this._path, ...this._key);
|
|
23424
23429
|
}
|
|
23425
23430
|
else {
|
|
@@ -23459,16 +23464,17 @@ function processCreateParams(params) {
|
|
|
23459
23464
|
if (errorMap)
|
|
23460
23465
|
return { errorMap: errorMap, description };
|
|
23461
23466
|
const customMap = (iss, ctx) => {
|
|
23467
|
+
var _a, _b;
|
|
23462
23468
|
const { message } = params;
|
|
23463
23469
|
if (iss.code === "invalid_enum_value") {
|
|
23464
|
-
return { message: message
|
|
23470
|
+
return { message: message !== null && message !== void 0 ? message : ctx.defaultError };
|
|
23465
23471
|
}
|
|
23466
23472
|
if (typeof ctx.data === "undefined") {
|
|
23467
|
-
return { message: message
|
|
23473
|
+
return { message: (_a = message !== null && message !== void 0 ? message : required_error) !== null && _a !== void 0 ? _a : ctx.defaultError };
|
|
23468
23474
|
}
|
|
23469
23475
|
if (iss.code !== "invalid_type")
|
|
23470
23476
|
return { message: ctx.defaultError };
|
|
23471
|
-
return { message: message
|
|
23477
|
+
return { message: (_b = message !== null && message !== void 0 ? message : invalid_type_error) !== null && _b !== void 0 ? _b : ctx.defaultError };
|
|
23472
23478
|
};
|
|
23473
23479
|
return { errorMap: customMap, description };
|
|
23474
23480
|
}
|
|
@@ -23520,13 +23526,14 @@ class ZodType {
|
|
|
23520
23526
|
throw result.error;
|
|
23521
23527
|
}
|
|
23522
23528
|
safeParse(data, params) {
|
|
23529
|
+
var _a;
|
|
23523
23530
|
const ctx = {
|
|
23524
23531
|
common: {
|
|
23525
23532
|
issues: [],
|
|
23526
|
-
async: params
|
|
23527
|
-
contextualErrorMap: params
|
|
23533
|
+
async: (_a = params === null || params === void 0 ? void 0 : params.async) !== null && _a !== void 0 ? _a : false,
|
|
23534
|
+
contextualErrorMap: params === null || params === void 0 ? void 0 : params.errorMap,
|
|
23528
23535
|
},
|
|
23529
|
-
path: params
|
|
23536
|
+
path: (params === null || params === void 0 ? void 0 : params.path) || [],
|
|
23530
23537
|
schemaErrorMap: this._def.errorMap,
|
|
23531
23538
|
parent: null,
|
|
23532
23539
|
data,
|
|
@@ -23536,6 +23543,7 @@ class ZodType {
|
|
|
23536
23543
|
return handleResult(ctx, result);
|
|
23537
23544
|
}
|
|
23538
23545
|
"~validate"(data) {
|
|
23546
|
+
var _a, _b;
|
|
23539
23547
|
const ctx = {
|
|
23540
23548
|
common: {
|
|
23541
23549
|
issues: [],
|
|
@@ -23559,7 +23567,7 @@ class ZodType {
|
|
|
23559
23567
|
};
|
|
23560
23568
|
}
|
|
23561
23569
|
catch (err) {
|
|
23562
|
-
if (err
|
|
23570
|
+
if ((_b = (_a = err === null || err === void 0 ? void 0 : err.message) === null || _a === void 0 ? void 0 : _a.toLowerCase()) === null || _b === void 0 ? void 0 : _b.includes("encountered")) {
|
|
23563
23571
|
this["~standard"].async = true;
|
|
23564
23572
|
}
|
|
23565
23573
|
ctx.common = {
|
|
@@ -23586,17 +23594,19 @@ class ZodType {
|
|
|
23586
23594
|
const ctx = {
|
|
23587
23595
|
common: {
|
|
23588
23596
|
issues: [],
|
|
23589
|
-
contextualErrorMap: params
|
|
23597
|
+
contextualErrorMap: params === null || params === void 0 ? void 0 : params.errorMap,
|
|
23590
23598
|
async: true,
|
|
23591
23599
|
},
|
|
23592
|
-
path: params
|
|
23600
|
+
path: (params === null || params === void 0 ? void 0 : params.path) || [],
|
|
23593
23601
|
schemaErrorMap: this._def.errorMap,
|
|
23594
23602
|
parent: null,
|
|
23595
23603
|
data,
|
|
23596
23604
|
parsedType: getParsedType(data),
|
|
23597
23605
|
};
|
|
23598
23606
|
const maybeAsyncResult = this._parse({ data, path: ctx.path, parent: ctx });
|
|
23599
|
-
const result = await (isAsync(maybeAsyncResult)
|
|
23607
|
+
const result = await (isAsync(maybeAsyncResult)
|
|
23608
|
+
? maybeAsyncResult
|
|
23609
|
+
: Promise.resolve(maybeAsyncResult));
|
|
23600
23610
|
return handleResult(ctx, result);
|
|
23601
23611
|
}
|
|
23602
23612
|
refine(check, message) {
|
|
@@ -23640,7 +23650,9 @@ class ZodType {
|
|
|
23640
23650
|
refinement(check, refinementData) {
|
|
23641
23651
|
return this._refinement((val, ctx) => {
|
|
23642
23652
|
if (!check(val)) {
|
|
23643
|
-
ctx.addIssue(typeof refinementData === "function"
|
|
23653
|
+
ctx.addIssue(typeof refinementData === "function"
|
|
23654
|
+
? refinementData(val, ctx)
|
|
23655
|
+
: refinementData);
|
|
23644
23656
|
return false;
|
|
23645
23657
|
}
|
|
23646
23658
|
else {
|
|
@@ -23812,15 +23824,15 @@ const base64urlRegex = /^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z
|
|
|
23812
23824
|
const dateRegexSource = `((\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-((0[13578]|1[02])-(0[1-9]|[12]\\d|3[01])|(0[469]|11)-(0[1-9]|[12]\\d|30)|(02)-(0[1-9]|1\\d|2[0-8])))`;
|
|
23813
23825
|
const dateRegex = new RegExp(`^${dateRegexSource}$`);
|
|
23814
23826
|
function timeRegexSource(args) {
|
|
23815
|
-
let
|
|
23827
|
+
// let regex = `\\d{2}:\\d{2}:\\d{2}`;
|
|
23828
|
+
let regex = `([01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d`;
|
|
23816
23829
|
if (args.precision) {
|
|
23817
|
-
|
|
23830
|
+
regex = `${regex}\\.\\d{${args.precision}}`;
|
|
23818
23831
|
}
|
|
23819
23832
|
else if (args.precision == null) {
|
|
23820
|
-
|
|
23833
|
+
regex = `${regex}(\\.\\d+)?`;
|
|
23821
23834
|
}
|
|
23822
|
-
|
|
23823
|
-
return `([01]\\d|2[0-3]):[0-5]\\d(:${secondsRegexSource})${secondsQuantifier}`;
|
|
23835
|
+
return regex;
|
|
23824
23836
|
}
|
|
23825
23837
|
function timeRegex(args) {
|
|
23826
23838
|
return new RegExp(`^${timeRegexSource(args)}$`);
|
|
@@ -23849,8 +23861,6 @@ function isValidJWT(jwt, alg) {
|
|
|
23849
23861
|
return false;
|
|
23850
23862
|
try {
|
|
23851
23863
|
const [header] = jwt.split(".");
|
|
23852
|
-
if (!header)
|
|
23853
|
-
return false;
|
|
23854
23864
|
// Convert base64url to base64
|
|
23855
23865
|
const base64 = header
|
|
23856
23866
|
.replace(/-/g, "+")
|
|
@@ -23859,15 +23869,13 @@ function isValidJWT(jwt, alg) {
|
|
|
23859
23869
|
const decoded = JSON.parse(atob(base64));
|
|
23860
23870
|
if (typeof decoded !== "object" || decoded === null)
|
|
23861
23871
|
return false;
|
|
23862
|
-
if (
|
|
23863
|
-
return false;
|
|
23864
|
-
if (!decoded.alg)
|
|
23872
|
+
if (!decoded.typ || !decoded.alg)
|
|
23865
23873
|
return false;
|
|
23866
23874
|
if (alg && decoded.alg !== alg)
|
|
23867
23875
|
return false;
|
|
23868
23876
|
return true;
|
|
23869
23877
|
}
|
|
23870
|
-
catch {
|
|
23878
|
+
catch (_a) {
|
|
23871
23879
|
return false;
|
|
23872
23880
|
}
|
|
23873
23881
|
}
|
|
@@ -24038,7 +24046,7 @@ class ZodString extends ZodType {
|
|
|
24038
24046
|
try {
|
|
24039
24047
|
new URL(input.data);
|
|
24040
24048
|
}
|
|
24041
|
-
catch {
|
|
24049
|
+
catch (_a) {
|
|
24042
24050
|
ctx = this._getOrReturnCtx(input, ctx);
|
|
24043
24051
|
addIssueToContext(ctx, {
|
|
24044
24052
|
validation: "url",
|
|
@@ -24268,6 +24276,7 @@ class ZodString extends ZodType {
|
|
|
24268
24276
|
return this._addCheck({ kind: "cidr", ...errorUtil.errToObj(options) });
|
|
24269
24277
|
}
|
|
24270
24278
|
datetime(options) {
|
|
24279
|
+
var _a, _b;
|
|
24271
24280
|
if (typeof options === "string") {
|
|
24272
24281
|
return this._addCheck({
|
|
24273
24282
|
kind: "datetime",
|
|
@@ -24279,10 +24288,10 @@ class ZodString extends ZodType {
|
|
|
24279
24288
|
}
|
|
24280
24289
|
return this._addCheck({
|
|
24281
24290
|
kind: "datetime",
|
|
24282
|
-
precision: typeof options
|
|
24283
|
-
offset: options
|
|
24284
|
-
local: options
|
|
24285
|
-
...errorUtil.errToObj(options
|
|
24291
|
+
precision: typeof (options === null || options === void 0 ? void 0 : options.precision) === "undefined" ? null : options === null || options === void 0 ? void 0 : options.precision,
|
|
24292
|
+
offset: (_a = options === null || options === void 0 ? void 0 : options.offset) !== null && _a !== void 0 ? _a : false,
|
|
24293
|
+
local: (_b = options === null || options === void 0 ? void 0 : options.local) !== null && _b !== void 0 ? _b : false,
|
|
24294
|
+
...errorUtil.errToObj(options === null || options === void 0 ? void 0 : options.message),
|
|
24286
24295
|
});
|
|
24287
24296
|
}
|
|
24288
24297
|
date(message) {
|
|
@@ -24298,8 +24307,8 @@ class ZodString extends ZodType {
|
|
|
24298
24307
|
}
|
|
24299
24308
|
return this._addCheck({
|
|
24300
24309
|
kind: "time",
|
|
24301
|
-
precision: typeof options
|
|
24302
|
-
...errorUtil.errToObj(options
|
|
24310
|
+
precision: typeof (options === null || options === void 0 ? void 0 : options.precision) === "undefined" ? null : options === null || options === void 0 ? void 0 : options.precision,
|
|
24311
|
+
...errorUtil.errToObj(options === null || options === void 0 ? void 0 : options.message),
|
|
24303
24312
|
});
|
|
24304
24313
|
}
|
|
24305
24314
|
duration(message) {
|
|
@@ -24316,8 +24325,8 @@ class ZodString extends ZodType {
|
|
|
24316
24325
|
return this._addCheck({
|
|
24317
24326
|
kind: "includes",
|
|
24318
24327
|
value: value,
|
|
24319
|
-
position: options
|
|
24320
|
-
...errorUtil.errToObj(options
|
|
24328
|
+
position: options === null || options === void 0 ? void 0 : options.position,
|
|
24329
|
+
...errorUtil.errToObj(options === null || options === void 0 ? void 0 : options.message),
|
|
24321
24330
|
});
|
|
24322
24331
|
}
|
|
24323
24332
|
startsWith(value, message) {
|
|
@@ -24450,10 +24459,11 @@ class ZodString extends ZodType {
|
|
|
24450
24459
|
}
|
|
24451
24460
|
}
|
|
24452
24461
|
ZodString.create = (params) => {
|
|
24462
|
+
var _a;
|
|
24453
24463
|
return new ZodString({
|
|
24454
24464
|
checks: [],
|
|
24455
24465
|
typeName: ZodFirstPartyTypeKind.ZodString,
|
|
24456
|
-
coerce: params
|
|
24466
|
+
coerce: (_a = params === null || params === void 0 ? void 0 : params.coerce) !== null && _a !== void 0 ? _a : false,
|
|
24457
24467
|
...processCreateParams(params),
|
|
24458
24468
|
});
|
|
24459
24469
|
};
|
|
@@ -24462,9 +24472,9 @@ function floatSafeRemainder(val, step) {
|
|
|
24462
24472
|
const valDecCount = (val.toString().split(".")[1] || "").length;
|
|
24463
24473
|
const stepDecCount = (step.toString().split(".")[1] || "").length;
|
|
24464
24474
|
const decCount = valDecCount > stepDecCount ? valDecCount : stepDecCount;
|
|
24465
|
-
const valInt =
|
|
24466
|
-
const stepInt =
|
|
24467
|
-
return (valInt % stepInt) / 10
|
|
24475
|
+
const valInt = parseInt(val.toFixed(decCount).replace(".", ""));
|
|
24476
|
+
const stepInt = parseInt(step.toFixed(decCount).replace(".", ""));
|
|
24477
|
+
return (valInt % stepInt) / Math.pow(10, decCount);
|
|
24468
24478
|
}
|
|
24469
24479
|
class ZodNumber extends ZodType {
|
|
24470
24480
|
constructor() {
|
|
@@ -24503,7 +24513,9 @@ class ZodNumber extends ZodType {
|
|
|
24503
24513
|
}
|
|
24504
24514
|
}
|
|
24505
24515
|
else if (check.kind === "min") {
|
|
24506
|
-
const tooSmall = check.inclusive
|
|
24516
|
+
const tooSmall = check.inclusive
|
|
24517
|
+
? input.data < check.value
|
|
24518
|
+
: input.data <= check.value;
|
|
24507
24519
|
if (tooSmall) {
|
|
24508
24520
|
ctx = this._getOrReturnCtx(input, ctx);
|
|
24509
24521
|
addIssueToContext(ctx, {
|
|
@@ -24518,7 +24530,9 @@ class ZodNumber extends ZodType {
|
|
|
24518
24530
|
}
|
|
24519
24531
|
}
|
|
24520
24532
|
else if (check.kind === "max") {
|
|
24521
|
-
const tooBig = check.inclusive
|
|
24533
|
+
const tooBig = check.inclusive
|
|
24534
|
+
? input.data > check.value
|
|
24535
|
+
: input.data >= check.value;
|
|
24522
24536
|
if (tooBig) {
|
|
24523
24537
|
ctx = this._getOrReturnCtx(input, ctx);
|
|
24524
24538
|
addIssueToContext(ctx, {
|
|
@@ -24676,13 +24690,15 @@ class ZodNumber extends ZodType {
|
|
|
24676
24690
|
return max;
|
|
24677
24691
|
}
|
|
24678
24692
|
get isInt() {
|
|
24679
|
-
return !!this._def.checks.find((ch) => ch.kind === "int" ||
|
|
24693
|
+
return !!this._def.checks.find((ch) => ch.kind === "int" ||
|
|
24694
|
+
(ch.kind === "multipleOf" && util.isInteger(ch.value)));
|
|
24680
24695
|
}
|
|
24681
24696
|
get isFinite() {
|
|
24682
|
-
let max = null;
|
|
24683
|
-
let min = null;
|
|
24697
|
+
let max = null, min = null;
|
|
24684
24698
|
for (const ch of this._def.checks) {
|
|
24685
|
-
if (ch.kind === "finite" ||
|
|
24699
|
+
if (ch.kind === "finite" ||
|
|
24700
|
+
ch.kind === "int" ||
|
|
24701
|
+
ch.kind === "multipleOf") {
|
|
24686
24702
|
return true;
|
|
24687
24703
|
}
|
|
24688
24704
|
else if (ch.kind === "min") {
|
|
@@ -24701,7 +24717,7 @@ ZodNumber.create = (params) => {
|
|
|
24701
24717
|
return new ZodNumber({
|
|
24702
24718
|
checks: [],
|
|
24703
24719
|
typeName: ZodFirstPartyTypeKind.ZodNumber,
|
|
24704
|
-
coerce: params
|
|
24720
|
+
coerce: (params === null || params === void 0 ? void 0 : params.coerce) || false,
|
|
24705
24721
|
...processCreateParams(params),
|
|
24706
24722
|
});
|
|
24707
24723
|
};
|
|
@@ -24716,7 +24732,7 @@ class ZodBigInt extends ZodType {
|
|
|
24716
24732
|
try {
|
|
24717
24733
|
input.data = BigInt(input.data);
|
|
24718
24734
|
}
|
|
24719
|
-
catch {
|
|
24735
|
+
catch (_a) {
|
|
24720
24736
|
return this._getInvalidInput(input);
|
|
24721
24737
|
}
|
|
24722
24738
|
}
|
|
@@ -24728,7 +24744,9 @@ class ZodBigInt extends ZodType {
|
|
|
24728
24744
|
const status = new ParseStatus();
|
|
24729
24745
|
for (const check of this._def.checks) {
|
|
24730
24746
|
if (check.kind === "min") {
|
|
24731
|
-
const tooSmall = check.inclusive
|
|
24747
|
+
const tooSmall = check.inclusive
|
|
24748
|
+
? input.data < check.value
|
|
24749
|
+
: input.data <= check.value;
|
|
24732
24750
|
if (tooSmall) {
|
|
24733
24751
|
ctx = this._getOrReturnCtx(input, ctx);
|
|
24734
24752
|
addIssueToContext(ctx, {
|
|
@@ -24742,7 +24760,9 @@ class ZodBigInt extends ZodType {
|
|
|
24742
24760
|
}
|
|
24743
24761
|
}
|
|
24744
24762
|
else if (check.kind === "max") {
|
|
24745
|
-
const tooBig = check.inclusive
|
|
24763
|
+
const tooBig = check.inclusive
|
|
24764
|
+
? input.data > check.value
|
|
24765
|
+
: input.data >= check.value;
|
|
24746
24766
|
if (tooBig) {
|
|
24747
24767
|
ctx = this._getOrReturnCtx(input, ctx);
|
|
24748
24768
|
addIssueToContext(ctx, {
|
|
@@ -24874,10 +24894,11 @@ class ZodBigInt extends ZodType {
|
|
|
24874
24894
|
}
|
|
24875
24895
|
}
|
|
24876
24896
|
ZodBigInt.create = (params) => {
|
|
24897
|
+
var _a;
|
|
24877
24898
|
return new ZodBigInt({
|
|
24878
24899
|
checks: [],
|
|
24879
24900
|
typeName: ZodFirstPartyTypeKind.ZodBigInt,
|
|
24880
|
-
coerce: params
|
|
24901
|
+
coerce: (_a = params === null || params === void 0 ? void 0 : params.coerce) !== null && _a !== void 0 ? _a : false,
|
|
24881
24902
|
...processCreateParams(params),
|
|
24882
24903
|
});
|
|
24883
24904
|
};
|
|
@@ -24902,7 +24923,7 @@ class ZodBoolean extends ZodType {
|
|
|
24902
24923
|
ZodBoolean.create = (params) => {
|
|
24903
24924
|
return new ZodBoolean({
|
|
24904
24925
|
typeName: ZodFirstPartyTypeKind.ZodBoolean,
|
|
24905
|
-
coerce: params
|
|
24926
|
+
coerce: (params === null || params === void 0 ? void 0 : params.coerce) || false,
|
|
24906
24927
|
...processCreateParams(params),
|
|
24907
24928
|
});
|
|
24908
24929
|
};
|
|
@@ -24921,7 +24942,7 @@ class ZodDate extends ZodType {
|
|
|
24921
24942
|
});
|
|
24922
24943
|
return INVALID;
|
|
24923
24944
|
}
|
|
24924
|
-
if (
|
|
24945
|
+
if (isNaN(input.data.getTime())) {
|
|
24925
24946
|
const ctx = this._getOrReturnCtx(input);
|
|
24926
24947
|
addIssueToContext(ctx, {
|
|
24927
24948
|
code: ZodIssueCode.invalid_date,
|
|
@@ -25012,7 +25033,7 @@ class ZodDate extends ZodType {
|
|
|
25012
25033
|
ZodDate.create = (params) => {
|
|
25013
25034
|
return new ZodDate({
|
|
25014
25035
|
checks: [],
|
|
25015
|
-
coerce: params
|
|
25036
|
+
coerce: (params === null || params === void 0 ? void 0 : params.coerce) || false,
|
|
25016
25037
|
typeName: ZodFirstPartyTypeKind.ZodDate,
|
|
25017
25038
|
...processCreateParams(params),
|
|
25018
25039
|
});
|
|
@@ -25334,8 +25355,7 @@ class ZodObject extends ZodType {
|
|
|
25334
25355
|
return this._cached;
|
|
25335
25356
|
const shape = this._def.shape();
|
|
25336
25357
|
const keys = util.objectKeys(shape);
|
|
25337
|
-
this._cached = { shape, keys };
|
|
25338
|
-
return this._cached;
|
|
25358
|
+
return (this._cached = { shape, keys });
|
|
25339
25359
|
}
|
|
25340
25360
|
_parse(input) {
|
|
25341
25361
|
const parsedType = this._getType(input);
|
|
@@ -25351,7 +25371,8 @@ class ZodObject extends ZodType {
|
|
|
25351
25371
|
const { status, ctx } = this._processInputParams(input);
|
|
25352
25372
|
const { shape, keys: shapeKeys } = this._getCached();
|
|
25353
25373
|
const extraKeys = [];
|
|
25354
|
-
if (!(this._def.catchall instanceof ZodNever &&
|
|
25374
|
+
if (!(this._def.catchall instanceof ZodNever &&
|
|
25375
|
+
this._def.unknownKeys === "strip")) {
|
|
25355
25376
|
for (const key in ctx.data) {
|
|
25356
25377
|
if (!shapeKeys.includes(key)) {
|
|
25357
25378
|
extraKeys.push(key);
|
|
@@ -25439,10 +25460,11 @@ class ZodObject extends ZodType {
|
|
|
25439
25460
|
...(message !== undefined
|
|
25440
25461
|
? {
|
|
25441
25462
|
errorMap: (issue, ctx) => {
|
|
25442
|
-
|
|
25463
|
+
var _a, _b, _c, _d;
|
|
25464
|
+
const defaultError = (_c = (_b = (_a = this._def).errorMap) === null || _b === void 0 ? void 0 : _b.call(_a, issue, ctx).message) !== null && _c !== void 0 ? _c : ctx.defaultError;
|
|
25443
25465
|
if (issue.code === "unrecognized_keys")
|
|
25444
25466
|
return {
|
|
25445
|
-
message: errorUtil.errToObj(message).message
|
|
25467
|
+
message: (_d = errorUtil.errToObj(message).message) !== null && _d !== void 0 ? _d : defaultError,
|
|
25446
25468
|
};
|
|
25447
25469
|
return {
|
|
25448
25470
|
message: defaultError,
|
|
@@ -25574,11 +25596,11 @@ class ZodObject extends ZodType {
|
|
|
25574
25596
|
}
|
|
25575
25597
|
pick(mask) {
|
|
25576
25598
|
const shape = {};
|
|
25577
|
-
|
|
25599
|
+
util.objectKeys(mask).forEach((key) => {
|
|
25578
25600
|
if (mask[key] && this.shape[key]) {
|
|
25579
25601
|
shape[key] = this.shape[key];
|
|
25580
25602
|
}
|
|
25581
|
-
}
|
|
25603
|
+
});
|
|
25582
25604
|
return new ZodObject({
|
|
25583
25605
|
...this._def,
|
|
25584
25606
|
shape: () => shape,
|
|
@@ -25586,11 +25608,11 @@ class ZodObject extends ZodType {
|
|
|
25586
25608
|
}
|
|
25587
25609
|
omit(mask) {
|
|
25588
25610
|
const shape = {};
|
|
25589
|
-
|
|
25611
|
+
util.objectKeys(this.shape).forEach((key) => {
|
|
25590
25612
|
if (!mask[key]) {
|
|
25591
25613
|
shape[key] = this.shape[key];
|
|
25592
25614
|
}
|
|
25593
|
-
}
|
|
25615
|
+
});
|
|
25594
25616
|
return new ZodObject({
|
|
25595
25617
|
...this._def,
|
|
25596
25618
|
shape: () => shape,
|
|
@@ -25604,7 +25626,7 @@ class ZodObject extends ZodType {
|
|
|
25604
25626
|
}
|
|
25605
25627
|
partial(mask) {
|
|
25606
25628
|
const newShape = {};
|
|
25607
|
-
|
|
25629
|
+
util.objectKeys(this.shape).forEach((key) => {
|
|
25608
25630
|
const fieldSchema = this.shape[key];
|
|
25609
25631
|
if (mask && !mask[key]) {
|
|
25610
25632
|
newShape[key] = fieldSchema;
|
|
@@ -25612,7 +25634,7 @@ class ZodObject extends ZodType {
|
|
|
25612
25634
|
else {
|
|
25613
25635
|
newShape[key] = fieldSchema.optional();
|
|
25614
25636
|
}
|
|
25615
|
-
}
|
|
25637
|
+
});
|
|
25616
25638
|
return new ZodObject({
|
|
25617
25639
|
...this._def,
|
|
25618
25640
|
shape: () => newShape,
|
|
@@ -25620,7 +25642,7 @@ class ZodObject extends ZodType {
|
|
|
25620
25642
|
}
|
|
25621
25643
|
required(mask) {
|
|
25622
25644
|
const newShape = {};
|
|
25623
|
-
|
|
25645
|
+
util.objectKeys(this.shape).forEach((key) => {
|
|
25624
25646
|
if (mask && !mask[key]) {
|
|
25625
25647
|
newShape[key] = this.shape[key];
|
|
25626
25648
|
}
|
|
@@ -25632,7 +25654,7 @@ class ZodObject extends ZodType {
|
|
|
25632
25654
|
}
|
|
25633
25655
|
newShape[key] = newField;
|
|
25634
25656
|
}
|
|
25635
|
-
}
|
|
25657
|
+
});
|
|
25636
25658
|
return new ZodObject({
|
|
25637
25659
|
...this._def,
|
|
25638
25660
|
shape: () => newShape,
|
|
@@ -25904,7 +25926,9 @@ function mergeValues(a, b) {
|
|
|
25904
25926
|
}
|
|
25905
25927
|
else if (aType === ZodParsedType.object && bType === ZodParsedType.object) {
|
|
25906
25928
|
const bKeys = util.objectKeys(b);
|
|
25907
|
-
const sharedKeys = util
|
|
25929
|
+
const sharedKeys = util
|
|
25930
|
+
.objectKeys(a)
|
|
25931
|
+
.filter((key) => bKeys.indexOf(key) !== -1);
|
|
25908
25932
|
const newObj = { ...a, ...b };
|
|
25909
25933
|
for (const key of sharedKeys) {
|
|
25910
25934
|
const sharedValue = mergeValues(a[key], b[key]);
|
|
@@ -25931,7 +25955,9 @@ function mergeValues(a, b) {
|
|
|
25931
25955
|
}
|
|
25932
25956
|
return { valid: true, data: newArray };
|
|
25933
25957
|
}
|
|
25934
|
-
else if (aType === ZodParsedType.date &&
|
|
25958
|
+
else if (aType === ZodParsedType.date &&
|
|
25959
|
+
bType === ZodParsedType.date &&
|
|
25960
|
+
+a === +b) {
|
|
25935
25961
|
return { valid: true, data: a };
|
|
25936
25962
|
}
|
|
25937
25963
|
else {
|
|
@@ -25992,7 +26018,6 @@ ZodIntersection.create = (left, right, params) => {
|
|
|
25992
26018
|
...processCreateParams(params),
|
|
25993
26019
|
});
|
|
25994
26020
|
};
|
|
25995
|
-
// type ZodTupleItems = [ZodTypeAny, ...ZodTypeAny[]];
|
|
25996
26021
|
class ZodTuple extends ZodType {
|
|
25997
26022
|
_parse(input) {
|
|
25998
26023
|
const { status, ctx } = this._processInputParams(input);
|
|
@@ -26289,7 +26314,12 @@ class ZodFunction extends ZodType {
|
|
|
26289
26314
|
return makeIssue({
|
|
26290
26315
|
data: args,
|
|
26291
26316
|
path: ctx.path,
|
|
26292
|
-
errorMaps: [
|
|
26317
|
+
errorMaps: [
|
|
26318
|
+
ctx.common.contextualErrorMap,
|
|
26319
|
+
ctx.schemaErrorMap,
|
|
26320
|
+
getErrorMap(),
|
|
26321
|
+
errorMap,
|
|
26322
|
+
].filter((x) => !!x),
|
|
26293
26323
|
issueData: {
|
|
26294
26324
|
code: ZodIssueCode.invalid_arguments,
|
|
26295
26325
|
argumentsError: error,
|
|
@@ -26300,7 +26330,12 @@ class ZodFunction extends ZodType {
|
|
|
26300
26330
|
return makeIssue({
|
|
26301
26331
|
data: returns,
|
|
26302
26332
|
path: ctx.path,
|
|
26303
|
-
errorMaps: [
|
|
26333
|
+
errorMaps: [
|
|
26334
|
+
ctx.common.contextualErrorMap,
|
|
26335
|
+
ctx.schemaErrorMap,
|
|
26336
|
+
getErrorMap(),
|
|
26337
|
+
errorMap,
|
|
26338
|
+
].filter((x) => !!x),
|
|
26304
26339
|
issueData: {
|
|
26305
26340
|
code: ZodIssueCode.invalid_return_type,
|
|
26306
26341
|
returnTypeError: error,
|
|
@@ -26316,7 +26351,9 @@ class ZodFunction extends ZodType {
|
|
|
26316
26351
|
const me = this;
|
|
26317
26352
|
return OK(async function (...args) {
|
|
26318
26353
|
const error = new ZodError([]);
|
|
26319
|
-
const parsedArgs = await me._def.args
|
|
26354
|
+
const parsedArgs = await me._def.args
|
|
26355
|
+
.parseAsync(args, params)
|
|
26356
|
+
.catch((e) => {
|
|
26320
26357
|
error.addIssue(makeArgsIssue(args, e));
|
|
26321
26358
|
throw error;
|
|
26322
26359
|
});
|
|
@@ -26377,7 +26414,9 @@ class ZodFunction extends ZodType {
|
|
|
26377
26414
|
}
|
|
26378
26415
|
static create(args, returns, params) {
|
|
26379
26416
|
return new ZodFunction({
|
|
26380
|
-
args: (args
|
|
26417
|
+
args: (args
|
|
26418
|
+
? args
|
|
26419
|
+
: ZodTuple.create([]).rest(ZodUnknown.create())),
|
|
26381
26420
|
returns: returns || ZodUnknown.create(),
|
|
26382
26421
|
typeName: ZodFirstPartyTypeKind.ZodFunction,
|
|
26383
26422
|
...processCreateParams(params),
|
|
@@ -26433,6 +26472,10 @@ function createZodEnum(values, params) {
|
|
|
26433
26472
|
});
|
|
26434
26473
|
}
|
|
26435
26474
|
class ZodEnum extends ZodType {
|
|
26475
|
+
constructor() {
|
|
26476
|
+
super(...arguments);
|
|
26477
|
+
_ZodEnum_cache.set(this, void 0);
|
|
26478
|
+
}
|
|
26436
26479
|
_parse(input) {
|
|
26437
26480
|
if (typeof input.data !== "string") {
|
|
26438
26481
|
const ctx = this._getOrReturnCtx(input);
|
|
@@ -26444,10 +26487,10 @@ class ZodEnum extends ZodType {
|
|
|
26444
26487
|
});
|
|
26445
26488
|
return INVALID;
|
|
26446
26489
|
}
|
|
26447
|
-
if (!this
|
|
26448
|
-
this
|
|
26490
|
+
if (!__classPrivateFieldGet(this, _ZodEnum_cache)) {
|
|
26491
|
+
__classPrivateFieldSet(this, _ZodEnum_cache, new Set(this._def.values));
|
|
26449
26492
|
}
|
|
26450
|
-
if (!this.
|
|
26493
|
+
if (!__classPrivateFieldGet(this, _ZodEnum_cache).has(input.data)) {
|
|
26451
26494
|
const ctx = this._getOrReturnCtx(input);
|
|
26452
26495
|
const expectedValues = this._def.values;
|
|
26453
26496
|
addIssueToContext(ctx, {
|
|
@@ -26496,12 +26539,18 @@ class ZodEnum extends ZodType {
|
|
|
26496
26539
|
});
|
|
26497
26540
|
}
|
|
26498
26541
|
}
|
|
26542
|
+
_ZodEnum_cache = new WeakMap();
|
|
26499
26543
|
ZodEnum.create = createZodEnum;
|
|
26500
26544
|
class ZodNativeEnum extends ZodType {
|
|
26545
|
+
constructor() {
|
|
26546
|
+
super(...arguments);
|
|
26547
|
+
_ZodNativeEnum_cache.set(this, void 0);
|
|
26548
|
+
}
|
|
26501
26549
|
_parse(input) {
|
|
26502
26550
|
const nativeEnumValues = util.getValidEnumValues(this._def.values);
|
|
26503
26551
|
const ctx = this._getOrReturnCtx(input);
|
|
26504
|
-
if (ctx.parsedType !== ZodParsedType.string &&
|
|
26552
|
+
if (ctx.parsedType !== ZodParsedType.string &&
|
|
26553
|
+
ctx.parsedType !== ZodParsedType.number) {
|
|
26505
26554
|
const expectedValues = util.objectValues(nativeEnumValues);
|
|
26506
26555
|
addIssueToContext(ctx, {
|
|
26507
26556
|
expected: util.joinValues(expectedValues),
|
|
@@ -26510,10 +26559,10 @@ class ZodNativeEnum extends ZodType {
|
|
|
26510
26559
|
});
|
|
26511
26560
|
return INVALID;
|
|
26512
26561
|
}
|
|
26513
|
-
if (!this
|
|
26514
|
-
this
|
|
26562
|
+
if (!__classPrivateFieldGet(this, _ZodNativeEnum_cache)) {
|
|
26563
|
+
__classPrivateFieldSet(this, _ZodNativeEnum_cache, new Set(util.getValidEnumValues(this._def.values)));
|
|
26515
26564
|
}
|
|
26516
|
-
if (!this.
|
|
26565
|
+
if (!__classPrivateFieldGet(this, _ZodNativeEnum_cache).has(input.data)) {
|
|
26517
26566
|
const expectedValues = util.objectValues(nativeEnumValues);
|
|
26518
26567
|
addIssueToContext(ctx, {
|
|
26519
26568
|
received: ctx.data,
|
|
@@ -26528,6 +26577,7 @@ class ZodNativeEnum extends ZodType {
|
|
|
26528
26577
|
return this._def.values;
|
|
26529
26578
|
}
|
|
26530
26579
|
}
|
|
26580
|
+
_ZodNativeEnum_cache = new WeakMap();
|
|
26531
26581
|
ZodNativeEnum.create = (values, params) => {
|
|
26532
26582
|
return new ZodNativeEnum({
|
|
26533
26583
|
values: values,
|
|
@@ -26541,7 +26591,8 @@ class ZodPromise extends ZodType {
|
|
|
26541
26591
|
}
|
|
26542
26592
|
_parse(input) {
|
|
26543
26593
|
const { ctx } = this._processInputParams(input);
|
|
26544
|
-
if (ctx.parsedType !== ZodParsedType.promise &&
|
|
26594
|
+
if (ctx.parsedType !== ZodParsedType.promise &&
|
|
26595
|
+
ctx.common.async === false) {
|
|
26545
26596
|
addIssueToContext(ctx, {
|
|
26546
26597
|
code: ZodIssueCode.invalid_type,
|
|
26547
26598
|
expected: ZodParsedType.promise,
|
|
@@ -26549,7 +26600,9 @@ class ZodPromise extends ZodType {
|
|
|
26549
26600
|
});
|
|
26550
26601
|
return INVALID;
|
|
26551
26602
|
}
|
|
26552
|
-
const promisified = ctx.parsedType === ZodParsedType.promise
|
|
26603
|
+
const promisified = ctx.parsedType === ZodParsedType.promise
|
|
26604
|
+
? ctx.data
|
|
26605
|
+
: Promise.resolve(ctx.data);
|
|
26553
26606
|
return OK(promisified.then((data) => {
|
|
26554
26607
|
return this._def.type.parseAsync(data, {
|
|
26555
26608
|
path: ctx.path,
|
|
@@ -26655,7 +26708,9 @@ class ZodEffects extends ZodType {
|
|
|
26655
26708
|
return { status: status.value, value: inner.value };
|
|
26656
26709
|
}
|
|
26657
26710
|
else {
|
|
26658
|
-
return this._def.schema
|
|
26711
|
+
return this._def.schema
|
|
26712
|
+
._parseAsync({ data: ctx.data, path: ctx.path, parent: ctx })
|
|
26713
|
+
.then((inner) => {
|
|
26659
26714
|
if (inner.status === "aborted")
|
|
26660
26715
|
return INVALID;
|
|
26661
26716
|
if (inner.status === "dirty")
|
|
@@ -26674,7 +26729,7 @@ class ZodEffects extends ZodType {
|
|
|
26674
26729
|
parent: ctx,
|
|
26675
26730
|
});
|
|
26676
26731
|
if (!isValid$2(base))
|
|
26677
|
-
return
|
|
26732
|
+
return base;
|
|
26678
26733
|
const result = effect.transform(base.value, checkCtx);
|
|
26679
26734
|
if (result instanceof Promise) {
|
|
26680
26735
|
throw new Error(`Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.`);
|
|
@@ -26682,13 +26737,12 @@ class ZodEffects extends ZodType {
|
|
|
26682
26737
|
return { status: status.value, value: result };
|
|
26683
26738
|
}
|
|
26684
26739
|
else {
|
|
26685
|
-
return this._def.schema
|
|
26740
|
+
return this._def.schema
|
|
26741
|
+
._parseAsync({ data: ctx.data, path: ctx.path, parent: ctx })
|
|
26742
|
+
.then((base) => {
|
|
26686
26743
|
if (!isValid$2(base))
|
|
26687
|
-
return
|
|
26688
|
-
return Promise.resolve(effect.transform(base.value, checkCtx)).then((result) => ({
|
|
26689
|
-
status: status.value,
|
|
26690
|
-
value: result,
|
|
26691
|
-
}));
|
|
26744
|
+
return base;
|
|
26745
|
+
return Promise.resolve(effect.transform(base.value, checkCtx)).then((result) => ({ status: status.value, value: result }));
|
|
26692
26746
|
});
|
|
26693
26747
|
}
|
|
26694
26748
|
}
|
|
@@ -26770,7 +26824,9 @@ ZodDefault.create = (type, params) => {
|
|
|
26770
26824
|
return new ZodDefault({
|
|
26771
26825
|
innerType: type,
|
|
26772
26826
|
typeName: ZodFirstPartyTypeKind.ZodDefault,
|
|
26773
|
-
defaultValue: typeof params.default === "function"
|
|
26827
|
+
defaultValue: typeof params.default === "function"
|
|
26828
|
+
? params.default
|
|
26829
|
+
: () => params.default,
|
|
26774
26830
|
...processCreateParams(params),
|
|
26775
26831
|
});
|
|
26776
26832
|
};
|
|
@@ -26936,7 +26992,9 @@ class ZodReadonly extends ZodType {
|
|
|
26936
26992
|
}
|
|
26937
26993
|
return data;
|
|
26938
26994
|
};
|
|
26939
|
-
return isAsync(result)
|
|
26995
|
+
return isAsync(result)
|
|
26996
|
+
? result.then((data) => freeze(data))
|
|
26997
|
+
: freeze(result);
|
|
26940
26998
|
}
|
|
26941
26999
|
unwrap() {
|
|
26942
27000
|
return this._def.innerType;
|
|
@@ -26957,7 +27015,11 @@ ZodReadonly.create = (type, params) => {
|
|
|
26957
27015
|
////////////////////////////////////////
|
|
26958
27016
|
////////////////////////////////////////
|
|
26959
27017
|
function cleanParams(params, data) {
|
|
26960
|
-
const p = typeof params === "function"
|
|
27018
|
+
const p = typeof params === "function"
|
|
27019
|
+
? params(data)
|
|
27020
|
+
: typeof params === "string"
|
|
27021
|
+
? { message: params }
|
|
27022
|
+
: params;
|
|
26961
27023
|
const p2 = typeof p === "string" ? { message: p } : p;
|
|
26962
27024
|
return p2;
|
|
26963
27025
|
}
|
|
@@ -26975,19 +27037,21 @@ function custom(check, _params = {},
|
|
|
26975
27037
|
fatal) {
|
|
26976
27038
|
if (check)
|
|
26977
27039
|
return ZodAny.create().superRefine((data, ctx) => {
|
|
27040
|
+
var _a, _b;
|
|
26978
27041
|
const r = check(data);
|
|
26979
27042
|
if (r instanceof Promise) {
|
|
26980
27043
|
return r.then((r) => {
|
|
27044
|
+
var _a, _b;
|
|
26981
27045
|
if (!r) {
|
|
26982
27046
|
const params = cleanParams(_params, data);
|
|
26983
|
-
const _fatal = params.fatal
|
|
27047
|
+
const _fatal = (_b = (_a = params.fatal) !== null && _a !== void 0 ? _a : fatal) !== null && _b !== void 0 ? _b : true;
|
|
26984
27048
|
ctx.addIssue({ code: "custom", ...params, fatal: _fatal });
|
|
26985
27049
|
}
|
|
26986
27050
|
});
|
|
26987
27051
|
}
|
|
26988
27052
|
if (!r) {
|
|
26989
27053
|
const params = cleanParams(_params, data);
|
|
26990
|
-
const _fatal = params.fatal
|
|
27054
|
+
const _fatal = (_b = (_a = params.fatal) !== null && _a !== void 0 ? _a : fatal) !== null && _b !== void 0 ? _b : true;
|
|
26991
27055
|
ctx.addIssue({ code: "custom", ...params, fatal: _fatal });
|
|
26992
27056
|
}
|
|
26993
27057
|
return;
|
|
@@ -27091,114 +27155,114 @@ const coerce = {
|
|
|
27091
27155
|
const NEVER = INVALID;
|
|
27092
27156
|
|
|
27093
27157
|
var z = /*#__PURE__*/Object.freeze({
|
|
27094
|
-
|
|
27095
|
-
|
|
27096
|
-
|
|
27097
|
-
|
|
27098
|
-
|
|
27099
|
-
|
|
27100
|
-
|
|
27101
|
-
|
|
27102
|
-
|
|
27103
|
-
|
|
27104
|
-
|
|
27105
|
-
|
|
27106
|
-
|
|
27107
|
-
|
|
27108
|
-
|
|
27109
|
-
|
|
27110
|
-
|
|
27111
|
-
|
|
27112
|
-
|
|
27113
|
-
|
|
27114
|
-
|
|
27115
|
-
|
|
27116
|
-
|
|
27117
|
-
|
|
27118
|
-
|
|
27119
|
-
|
|
27120
|
-
|
|
27121
|
-
|
|
27122
|
-
|
|
27123
|
-
|
|
27124
|
-
|
|
27125
|
-
|
|
27126
|
-
|
|
27127
|
-
|
|
27128
|
-
|
|
27129
|
-
|
|
27130
|
-
|
|
27131
|
-
|
|
27132
|
-
|
|
27133
|
-
|
|
27134
|
-
|
|
27135
|
-
|
|
27136
|
-
|
|
27137
|
-
|
|
27138
|
-
|
|
27139
|
-
|
|
27140
|
-
|
|
27141
|
-
|
|
27142
|
-
|
|
27143
|
-
|
|
27144
|
-
|
|
27145
|
-
|
|
27146
|
-
|
|
27147
|
-
|
|
27148
|
-
|
|
27149
|
-
|
|
27150
|
-
|
|
27151
|
-
|
|
27152
|
-
|
|
27153
|
-
|
|
27154
|
-
|
|
27155
|
-
|
|
27156
|
-
|
|
27157
|
-
|
|
27158
|
-
|
|
27159
|
-
|
|
27160
|
-
|
|
27161
|
-
|
|
27162
|
-
|
|
27163
|
-
|
|
27164
|
-
|
|
27165
|
-
|
|
27166
|
-
|
|
27167
|
-
|
|
27168
|
-
|
|
27169
|
-
|
|
27170
|
-
|
|
27171
|
-
|
|
27172
|
-
|
|
27173
|
-
|
|
27174
|
-
|
|
27175
|
-
|
|
27176
|
-
|
|
27177
|
-
|
|
27178
|
-
|
|
27179
|
-
|
|
27180
|
-
|
|
27181
|
-
|
|
27182
|
-
|
|
27183
|
-
|
|
27184
|
-
|
|
27185
|
-
|
|
27186
|
-
|
|
27187
|
-
|
|
27188
|
-
|
|
27189
|
-
|
|
27190
|
-
|
|
27191
|
-
|
|
27192
|
-
|
|
27193
|
-
|
|
27194
|
-
|
|
27195
|
-
|
|
27196
|
-
|
|
27197
|
-
|
|
27198
|
-
|
|
27199
|
-
|
|
27200
|
-
|
|
27201
|
-
|
|
27158
|
+
__proto__: null,
|
|
27159
|
+
defaultErrorMap: errorMap,
|
|
27160
|
+
setErrorMap: setErrorMap,
|
|
27161
|
+
getErrorMap: getErrorMap,
|
|
27162
|
+
makeIssue: makeIssue,
|
|
27163
|
+
EMPTY_PATH: EMPTY_PATH,
|
|
27164
|
+
addIssueToContext: addIssueToContext,
|
|
27165
|
+
ParseStatus: ParseStatus,
|
|
27166
|
+
INVALID: INVALID,
|
|
27167
|
+
DIRTY: DIRTY,
|
|
27168
|
+
OK: OK,
|
|
27169
|
+
isAborted: isAborted,
|
|
27170
|
+
isDirty: isDirty,
|
|
27171
|
+
isValid: isValid$2,
|
|
27172
|
+
isAsync: isAsync,
|
|
27173
|
+
get util () { return util; },
|
|
27174
|
+
get objectUtil () { return objectUtil; },
|
|
27175
|
+
ZodParsedType: ZodParsedType,
|
|
27176
|
+
getParsedType: getParsedType,
|
|
27177
|
+
ZodType: ZodType,
|
|
27178
|
+
datetimeRegex: datetimeRegex,
|
|
27179
|
+
ZodString: ZodString,
|
|
27180
|
+
ZodNumber: ZodNumber,
|
|
27181
|
+
ZodBigInt: ZodBigInt,
|
|
27182
|
+
ZodBoolean: ZodBoolean,
|
|
27183
|
+
ZodDate: ZodDate,
|
|
27184
|
+
ZodSymbol: ZodSymbol,
|
|
27185
|
+
ZodUndefined: ZodUndefined,
|
|
27186
|
+
ZodNull: ZodNull,
|
|
27187
|
+
ZodAny: ZodAny,
|
|
27188
|
+
ZodUnknown: ZodUnknown,
|
|
27189
|
+
ZodNever: ZodNever,
|
|
27190
|
+
ZodVoid: ZodVoid,
|
|
27191
|
+
ZodArray: ZodArray,
|
|
27192
|
+
ZodObject: ZodObject,
|
|
27193
|
+
ZodUnion: ZodUnion,
|
|
27194
|
+
ZodDiscriminatedUnion: ZodDiscriminatedUnion,
|
|
27195
|
+
ZodIntersection: ZodIntersection,
|
|
27196
|
+
ZodTuple: ZodTuple,
|
|
27197
|
+
ZodRecord: ZodRecord,
|
|
27198
|
+
ZodMap: ZodMap,
|
|
27199
|
+
ZodSet: ZodSet,
|
|
27200
|
+
ZodFunction: ZodFunction,
|
|
27201
|
+
ZodLazy: ZodLazy,
|
|
27202
|
+
ZodLiteral: ZodLiteral,
|
|
27203
|
+
ZodEnum: ZodEnum,
|
|
27204
|
+
ZodNativeEnum: ZodNativeEnum,
|
|
27205
|
+
ZodPromise: ZodPromise,
|
|
27206
|
+
ZodEffects: ZodEffects,
|
|
27207
|
+
ZodTransformer: ZodEffects,
|
|
27208
|
+
ZodOptional: ZodOptional,
|
|
27209
|
+
ZodNullable: ZodNullable,
|
|
27210
|
+
ZodDefault: ZodDefault,
|
|
27211
|
+
ZodCatch: ZodCatch,
|
|
27212
|
+
ZodNaN: ZodNaN,
|
|
27213
|
+
BRAND: BRAND,
|
|
27214
|
+
ZodBranded: ZodBranded,
|
|
27215
|
+
ZodPipeline: ZodPipeline,
|
|
27216
|
+
ZodReadonly: ZodReadonly,
|
|
27217
|
+
custom: custom,
|
|
27218
|
+
Schema: ZodType,
|
|
27219
|
+
ZodSchema: ZodType,
|
|
27220
|
+
late: late,
|
|
27221
|
+
get ZodFirstPartyTypeKind () { return ZodFirstPartyTypeKind; },
|
|
27222
|
+
coerce: coerce,
|
|
27223
|
+
any: anyType,
|
|
27224
|
+
array: arrayType,
|
|
27225
|
+
bigint: bigIntType,
|
|
27226
|
+
boolean: booleanType,
|
|
27227
|
+
date: dateType,
|
|
27228
|
+
discriminatedUnion: discriminatedUnionType,
|
|
27229
|
+
effect: effectsType,
|
|
27230
|
+
'enum': enumType,
|
|
27231
|
+
'function': functionType,
|
|
27232
|
+
'instanceof': instanceOfType,
|
|
27233
|
+
intersection: intersectionType,
|
|
27234
|
+
lazy: lazyType,
|
|
27235
|
+
literal: literalType,
|
|
27236
|
+
map: mapType,
|
|
27237
|
+
nan: nanType,
|
|
27238
|
+
nativeEnum: nativeEnumType,
|
|
27239
|
+
never: neverType,
|
|
27240
|
+
'null': nullType,
|
|
27241
|
+
nullable: nullableType,
|
|
27242
|
+
number: numberType,
|
|
27243
|
+
object: objectType,
|
|
27244
|
+
oboolean: oboolean,
|
|
27245
|
+
onumber: onumber,
|
|
27246
|
+
optional: optionalType,
|
|
27247
|
+
ostring: ostring,
|
|
27248
|
+
pipeline: pipelineType,
|
|
27249
|
+
preprocess: preprocessType,
|
|
27250
|
+
promise: promiseType,
|
|
27251
|
+
record: recordType,
|
|
27252
|
+
set: setType,
|
|
27253
|
+
strictObject: strictObjectType,
|
|
27254
|
+
string: stringType,
|
|
27255
|
+
symbol: symbolType,
|
|
27256
|
+
transformer: effectsType,
|
|
27257
|
+
tuple: tupleType,
|
|
27258
|
+
'undefined': undefinedType,
|
|
27259
|
+
union: unionType,
|
|
27260
|
+
unknown: unknownType,
|
|
27261
|
+
'void': voidType,
|
|
27262
|
+
NEVER: NEVER,
|
|
27263
|
+
ZodIssueCode: ZodIssueCode,
|
|
27264
|
+
quotelessJson: quotelessJson,
|
|
27265
|
+
ZodError: ZodError
|
|
27202
27266
|
});
|
|
27203
27267
|
|
|
27204
27268
|
/*
|
|
@@ -28311,11 +28375,12 @@ const convertToZod = (schema) => {
|
|
|
28311
28375
|
}
|
|
28312
28376
|
}
|
|
28313
28377
|
if (Array.isArray(schema.required)) {
|
|
28314
|
-
return
|
|
28378
|
+
return z
|
|
28379
|
+
.object(obj)
|
|
28315
28380
|
.partial()
|
|
28316
28381
|
.required(schema.required.reduce((acc, v) => (Object.assign(Object.assign({}, acc), { [v]: true })), {}));
|
|
28317
28382
|
}
|
|
28318
|
-
return
|
|
28383
|
+
return z.object(obj).partial();
|
|
28319
28384
|
}
|
|
28320
28385
|
if ((schema === null || schema === void 0 ? void 0 : schema.type) === 'array' && (schema === null || schema === void 0 ? void 0 : schema.items)) {
|
|
28321
28386
|
if (Array.isArray(schema.items) && schema.items.length > 1
|
|
@@ -28328,22 +28393,22 @@ const convertToZod = (schema) => {
|
|
|
28328
28393
|
arr.push(zItem);
|
|
28329
28394
|
}
|
|
28330
28395
|
}
|
|
28331
|
-
return
|
|
28396
|
+
return z.tuple(arr);
|
|
28332
28397
|
}
|
|
28333
28398
|
const nextSchema = Array.isArray(schema.items) ? schema.items[0] : schema.items;
|
|
28334
|
-
let zodArraySchema =
|
|
28399
|
+
let zodArraySchema = z.array(convertToZod(nextSchema));
|
|
28335
28400
|
zodArraySchema = schema.minItems !== undefined ? zodArraySchema.min(schema.minItems) : zodArraySchema;
|
|
28336
28401
|
zodArraySchema = schema.maxItems !== undefined ? zodArraySchema.max(schema.maxItems) : zodArraySchema;
|
|
28337
28402
|
return zodArraySchema;
|
|
28338
28403
|
}
|
|
28339
28404
|
if (schema.oneOf && Array.isArray(schema.oneOf)) {
|
|
28340
|
-
return
|
|
28405
|
+
return z.union(schema.oneOf.map(oneOfSchema => convertToZod(oneOfSchema)));
|
|
28341
28406
|
}
|
|
28342
28407
|
if (schema === null || schema === void 0 ? void 0 : schema.format) {
|
|
28343
28408
|
if (!formats[schema.format]) {
|
|
28344
28409
|
throw new SchemaFormatError(schema.format);
|
|
28345
28410
|
}
|
|
28346
|
-
return
|
|
28411
|
+
return z.any().refine(formats[schema.format], (value) => ({
|
|
28347
28412
|
params: { value, format: schema.format },
|
|
28348
28413
|
}));
|
|
28349
28414
|
}
|
|
@@ -28352,7 +28417,7 @@ const convertToZod = (schema) => {
|
|
|
28352
28417
|
typeof z[String(schema.type)] === 'function') {
|
|
28353
28418
|
return z[String(schema.type)]();
|
|
28354
28419
|
}
|
|
28355
|
-
return
|
|
28420
|
+
return z.object({ data: z.any() }).partial();
|
|
28356
28421
|
};
|
|
28357
28422
|
class Validator {
|
|
28358
28423
|
// eslint-disable-next-line no-useless-constructor, @typescript-eslint/no-empty-function
|
|
@@ -114498,14 +114563,6 @@ function requirePermessageDeflate () {
|
|
|
114498
114563
|
this[kError].code = 'WS_ERR_UNSUPPORTED_MESSAGE_LENGTH';
|
|
114499
114564
|
this[kError][kStatusCode] = 1009;
|
|
114500
114565
|
this.removeListener('data', inflateOnData);
|
|
114501
|
-
|
|
114502
|
-
//
|
|
114503
|
-
// The choice to employ `zlib.reset()` over `zlib.close()` is dictated by the
|
|
114504
|
-
// fact that in Node.js versions prior to 13.10.0, the callback for
|
|
114505
|
-
// `zlib.flush()` is not called if `zlib.close()` is used. Utilizing
|
|
114506
|
-
// `zlib.reset()` ensures that either the callback is invoked or an error is
|
|
114507
|
-
// emitted.
|
|
114508
|
-
//
|
|
114509
114566
|
this.reset();
|
|
114510
114567
|
}
|
|
114511
114568
|
|
|
@@ -114521,12 +114578,6 @@ function requirePermessageDeflate () {
|
|
|
114521
114578
|
// closed when an error is emitted.
|
|
114522
114579
|
//
|
|
114523
114580
|
this[kPerMessageDeflate]._inflate = null;
|
|
114524
|
-
|
|
114525
|
-
if (this[kError]) {
|
|
114526
|
-
this[kCallback](this[kError]);
|
|
114527
|
-
return;
|
|
114528
|
-
}
|
|
114529
|
-
|
|
114530
114581
|
err[kStatusCode] = 1007;
|
|
114531
114582
|
this[kCallback](err);
|
|
114532
114583
|
}
|
|
@@ -115418,7 +115469,7 @@ function requireSender () {
|
|
|
115418
115469
|
hasRequiredSender = 1;
|
|
115419
115470
|
|
|
115420
115471
|
const { Duplex } = Stream;
|
|
115421
|
-
const { randomFillSync } =
|
|
115472
|
+
const { randomFillSync } = crypto$2;
|
|
115422
115473
|
|
|
115423
115474
|
const PerMessageDeflate = requirePermessageDeflate();
|
|
115424
115475
|
const { EMPTY_BUFFER, kWebSocket, NOOP } = requireConstants();
|
|
@@ -116543,7 +116594,7 @@ function requireWebsocket () {
|
|
|
116543
116594
|
const http$1 = http;
|
|
116544
116595
|
const net = require$$3;
|
|
116545
116596
|
const tls = require$$4$1;
|
|
116546
|
-
const { randomBytes, createHash } =
|
|
116597
|
+
const { randomBytes, createHash } = crypto$2;
|
|
116547
116598
|
const { Duplex, Readable } = Stream;
|
|
116548
116599
|
const { URL } = Url;
|
|
116549
116600
|
|
|
@@ -117244,7 +117295,7 @@ function requireWebsocket () {
|
|
|
117244
117295
|
if (parsedUrl.protocol !== 'ws:' && !isSecure && !isIpcUrl) {
|
|
117245
117296
|
invalidUrlMessage =
|
|
117246
117297
|
'The URL\'s protocol must be one of "ws:", "wss:", ' +
|
|
117247
|
-
'"http:", "https
|
|
117298
|
+
'"http:", "https", or "ws+unix:"';
|
|
117248
117299
|
} else if (isIpcUrl && !parsedUrl.pathname) {
|
|
117249
117300
|
invalidUrlMessage = "The URL's pathname is empty";
|
|
117250
117301
|
} else if (parsedUrl.hash) {
|
|
@@ -118177,7 +118228,7 @@ function requireWebsocketServer () {
|
|
|
118177
118228
|
const EventEmitter = require$$0$5;
|
|
118178
118229
|
const http$1 = http;
|
|
118179
118230
|
const { Duplex } = Stream;
|
|
118180
|
-
const { createHash } =
|
|
118231
|
+
const { createHash } = crypto$2;
|
|
118181
118232
|
|
|
118182
118233
|
const extension = requireExtension();
|
|
118183
118234
|
const PerMessageDeflate = requirePermessageDeflate();
|
|
@@ -118428,11 +118479,9 @@ function requireWebsocketServer () {
|
|
|
118428
118479
|
return;
|
|
118429
118480
|
}
|
|
118430
118481
|
|
|
118431
|
-
if (version !==
|
|
118482
|
+
if (version !== 8 && version !== 13) {
|
|
118432
118483
|
const message = 'Missing or invalid Sec-WebSocket-Version header';
|
|
118433
|
-
abortHandshakeOrEmitwsClientError(this, req, socket, 400, message
|
|
118434
|
-
'Sec-WebSocket-Version': '13, 8'
|
|
118435
|
-
});
|
|
118484
|
+
abortHandshakeOrEmitwsClientError(this, req, socket, 400, message);
|
|
118436
118485
|
return;
|
|
118437
118486
|
}
|
|
118438
118487
|
|
|
@@ -118700,24 +118749,16 @@ function requireWebsocketServer () {
|
|
|
118700
118749
|
* @param {Duplex} socket The socket of the upgrade request
|
|
118701
118750
|
* @param {Number} code The HTTP response status code
|
|
118702
118751
|
* @param {String} message The HTTP response body
|
|
118703
|
-
* @param {Object} [headers] The HTTP response headers
|
|
118704
118752
|
* @private
|
|
118705
118753
|
*/
|
|
118706
|
-
function abortHandshakeOrEmitwsClientError(
|
|
118707
|
-
server,
|
|
118708
|
-
req,
|
|
118709
|
-
socket,
|
|
118710
|
-
code,
|
|
118711
|
-
message,
|
|
118712
|
-
headers
|
|
118713
|
-
) {
|
|
118754
|
+
function abortHandshakeOrEmitwsClientError(server, req, socket, code, message) {
|
|
118714
118755
|
if (server.listenerCount('wsClientError')) {
|
|
118715
118756
|
const err = new Error(message);
|
|
118716
118757
|
Error.captureStackTrace(err, abortHandshakeOrEmitwsClientError);
|
|
118717
118758
|
|
|
118718
118759
|
server.emit('wsClientError', err, socket, req);
|
|
118719
118760
|
} else {
|
|
118720
|
-
abortHandshake(socket, code, message
|
|
118761
|
+
abortHandshake(socket, code, message);
|
|
118721
118762
|
}
|
|
118722
118763
|
}
|
|
118723
118764
|
return websocketServer;
|
|
@@ -142383,14 +142424,19 @@ const Method = async (resource, baseUrl, params = {}, env) => {
|
|
|
142383
142424
|
let body = {};
|
|
142384
142425
|
if (resource.body) {
|
|
142385
142426
|
for (const key in resource.body) {
|
|
142386
|
-
if (
|
|
142427
|
+
if (resource.body[key] === true) {
|
|
142428
|
+
// Required field
|
|
142387
142429
|
if (!params[key]) {
|
|
142388
142430
|
console.error(`Missing required body parameter: ${key}`);
|
|
142389
142431
|
throw new DimoError({
|
|
142390
142432
|
message: `Missing required body parameter: ${key}`
|
|
142391
142433
|
});
|
|
142392
142434
|
}
|
|
142393
|
-
|
|
142435
|
+
body[key] = params[key];
|
|
142436
|
+
}
|
|
142437
|
+
else if (resource.body[key] === false) {
|
|
142438
|
+
// Optional field - include only if provided
|
|
142439
|
+
if (params[key] !== undefined) {
|
|
142394
142440
|
body[key] = params[key];
|
|
142395
142441
|
}
|
|
142396
142442
|
}
|
|
@@ -142448,6 +142494,69 @@ class Resource {
|
|
|
142448
142494
|
}
|
|
142449
142495
|
}
|
|
142450
142496
|
|
|
142497
|
+
class Agents extends Resource {
|
|
142498
|
+
constructor(api, env) {
|
|
142499
|
+
super(api, 'Agents', env);
|
|
142500
|
+
this.setResource({
|
|
142501
|
+
healthCheck: {
|
|
142502
|
+
method: 'GET',
|
|
142503
|
+
path: '/'
|
|
142504
|
+
},
|
|
142505
|
+
createAgent: {
|
|
142506
|
+
method: 'POST',
|
|
142507
|
+
path: '/agents',
|
|
142508
|
+
body: {
|
|
142509
|
+
'type': false,
|
|
142510
|
+
'personality': false,
|
|
142511
|
+
'secrets': true,
|
|
142512
|
+
'variables': true,
|
|
142513
|
+
},
|
|
142514
|
+
auth: 'developer_jwt'
|
|
142515
|
+
},
|
|
142516
|
+
deleteAgent: {
|
|
142517
|
+
method: 'DELETE',
|
|
142518
|
+
path: '/agents/:agentId',
|
|
142519
|
+
auth: 'developer_jwt'
|
|
142520
|
+
},
|
|
142521
|
+
sendMessage: {
|
|
142522
|
+
method: 'POST',
|
|
142523
|
+
path: '/agents/:agentId/message',
|
|
142524
|
+
body: {
|
|
142525
|
+
'message': true,
|
|
142526
|
+
'vehicleIds': false,
|
|
142527
|
+
'user': false
|
|
142528
|
+
},
|
|
142529
|
+
auth: 'developer_jwt'
|
|
142530
|
+
},
|
|
142531
|
+
streamMessage: {
|
|
142532
|
+
method: 'POST',
|
|
142533
|
+
path: '/agents/:agentId/stream',
|
|
142534
|
+
body: {
|
|
142535
|
+
'message': true,
|
|
142536
|
+
'vehicleIds': false,
|
|
142537
|
+
'user': false
|
|
142538
|
+
},
|
|
142539
|
+
auth: 'developer_jwt'
|
|
142540
|
+
},
|
|
142541
|
+
getHistory: {
|
|
142542
|
+
method: 'GET',
|
|
142543
|
+
path: '/agents/:agentId/history',
|
|
142544
|
+
queryParams: {
|
|
142545
|
+
'limit': false
|
|
142546
|
+
},
|
|
142547
|
+
auth: 'developer_jwt'
|
|
142548
|
+
}
|
|
142549
|
+
});
|
|
142550
|
+
const originalCreateAgent = this.createAgent;
|
|
142551
|
+
this.createAgent = (params = {}) => {
|
|
142552
|
+
return originalCreateAgent({
|
|
142553
|
+
type: 'driver_agent_v1',
|
|
142554
|
+
...params
|
|
142555
|
+
});
|
|
142556
|
+
};
|
|
142557
|
+
}
|
|
142558
|
+
}
|
|
142559
|
+
|
|
142451
142560
|
class Attestation extends Resource {
|
|
142452
142561
|
constructor(api, env) {
|
|
142453
142562
|
super(api, 'Attestation', env);
|
|
@@ -142627,9 +142736,9 @@ class Valuations extends Resource {
|
|
|
142627
142736
|
}
|
|
142628
142737
|
|
|
142629
142738
|
/** @format */
|
|
142630
|
-
class
|
|
142739
|
+
class VehicleTriggers extends Resource {
|
|
142631
142740
|
constructor(api, env) {
|
|
142632
|
-
super(api, '
|
|
142741
|
+
super(api, 'VehicleTriggers', env);
|
|
142633
142742
|
this.setResource({
|
|
142634
142743
|
listWebhooks: {
|
|
142635
142744
|
method: 'GET',
|
|
@@ -142641,13 +142750,14 @@ class VehicleEvents extends Resource {
|
|
|
142641
142750
|
path: '/v1/webhooks',
|
|
142642
142751
|
body: {
|
|
142643
142752
|
service: true,
|
|
142644
|
-
|
|
142645
|
-
|
|
142646
|
-
|
|
142753
|
+
metricName: true,
|
|
142754
|
+
condition: true,
|
|
142755
|
+
coolDownPeriod: true,
|
|
142647
142756
|
description: false,
|
|
142648
|
-
|
|
142757
|
+
targetURL: true,
|
|
142649
142758
|
status: true,
|
|
142650
|
-
|
|
142759
|
+
verificationToken: true,
|
|
142760
|
+
displayName: false
|
|
142651
142761
|
},
|
|
142652
142762
|
auth: 'developer_jwt',
|
|
142653
142763
|
},
|
|
@@ -142655,14 +142765,7 @@ class VehicleEvents extends Resource {
|
|
|
142655
142765
|
method: 'PUT',
|
|
142656
142766
|
path: '/v1/webhooks/:webhookId',
|
|
142657
142767
|
body: {
|
|
142658
|
-
|
|
142659
|
-
data: true,
|
|
142660
|
-
trigger: true,
|
|
142661
|
-
setup: true,
|
|
142662
|
-
description: false,
|
|
142663
|
-
target_uri: true,
|
|
142664
|
-
status: true,
|
|
142665
|
-
verification_token: true,
|
|
142768
|
+
request: true
|
|
142666
142769
|
},
|
|
142667
142770
|
auth: 'developer_jwt',
|
|
142668
142771
|
},
|
|
@@ -142683,12 +142786,12 @@ class VehicleEvents extends Resource {
|
|
|
142683
142786
|
},
|
|
142684
142787
|
listVehicleSubscriptions: {
|
|
142685
142788
|
method: 'GET',
|
|
142686
|
-
path: '/v1/webhooks/vehicles/:
|
|
142789
|
+
path: '/v1/webhooks/vehicles/:tokenDID',
|
|
142687
142790
|
auth: 'developer_jwt',
|
|
142688
142791
|
},
|
|
142689
142792
|
subscribeVehicle: {
|
|
142690
142793
|
method: 'POST',
|
|
142691
|
-
path: '/v1/webhooks/:webhookId/subscribe/:
|
|
142794
|
+
path: '/v1/webhooks/:webhookId/subscribe/:tokenDID',
|
|
142692
142795
|
auth: 'developer_jwt',
|
|
142693
142796
|
},
|
|
142694
142797
|
subscribeAllVehicles: {
|
|
@@ -142698,7 +142801,7 @@ class VehicleEvents extends Resource {
|
|
|
142698
142801
|
},
|
|
142699
142802
|
unsubscribeVehicle: {
|
|
142700
142803
|
method: 'DELETE',
|
|
142701
|
-
path: '/v1/webhooks/:webhookId/unsubscribe/:
|
|
142804
|
+
path: '/v1/webhooks/:webhookId/unsubscribe/:tokenDID',
|
|
142702
142805
|
auth: 'developer_jwt',
|
|
142703
142806
|
},
|
|
142704
142807
|
unsubscribeAllVehicles: {
|
|
@@ -142710,5 +142813,5 @@ class VehicleEvents extends Resource {
|
|
|
142710
142813
|
}
|
|
142711
142814
|
}
|
|
142712
142815
|
|
|
142713
|
-
export { Attestation, Auth, DIMO, DeviceDefinitions, Devices, DimoConstants, DimoEnvironment, DimoError, Identity, Telemetry, TokenExchange, Trips, Valuations,
|
|
142816
|
+
export { Agents, Attestation, Auth, DIMO, DeviceDefinitions, Devices, DimoConstants, DimoEnvironment, DimoError, Identity, Telemetry, TokenExchange, Trips, Valuations, VehicleTriggers };
|
|
142714
142817
|
//# sourceMappingURL=index.js.map
|