orange-orm 4.4.0 → 4.4.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/README.md +8 -8
- package/docs/changelog.md +2 -0
- package/package.json +1 -1
- package/src/client/index.mjs +250 -135
- package/src/table/column/date/tryParseISO.js +6 -8
package/README.md
CHANGED
|
@@ -40,7 +40,7 @@ If you value the hard work behind Orange and wish to see it evolve further, cons
|
|
|
40
40
|
## Installation
|
|
41
41
|
|
|
42
42
|
```bash
|
|
43
|
-
|
|
43
|
+
npm install orange-orm
|
|
44
44
|
```
|
|
45
45
|
|
|
46
46
|
## Example
|
|
@@ -50,7 +50,7 @@ Watch the [tutorial video on YouTube](https://youtu.be/1IwwjPr2lMs)
|
|
|
50
50
|
|
|
51
51
|
Here we choose SQLite.
|
|
52
52
|
```bash
|
|
53
|
-
|
|
53
|
+
npm install sqlite3
|
|
54
54
|
```
|
|
55
55
|
<sub>📄 map.ts</sub>
|
|
56
56
|
```javascript
|
|
@@ -280,7 +280,7 @@ In SQLite, columns with the INTEGER PRIMARY KEY attribute are designed to autoin
|
|
|
280
280
|
|
|
281
281
|
__SQLite__
|
|
282
282
|
```bash
|
|
283
|
-
|
|
283
|
+
npm install sqlite3
|
|
284
284
|
```
|
|
285
285
|
```javascript
|
|
286
286
|
import map from './map';
|
|
@@ -288,7 +288,7 @@ const db = map.sqlite('demo.db');
|
|
|
288
288
|
```
|
|
289
289
|
__With connection pool__
|
|
290
290
|
```bash
|
|
291
|
-
|
|
291
|
+
npm install sqlite3
|
|
292
292
|
```
|
|
293
293
|
```javascript
|
|
294
294
|
import map from './map';
|
|
@@ -331,7 +331,7 @@ const db = map.mysql('mysql://test:test@mysql/test');
|
|
|
331
331
|
|
|
332
332
|
__MS SQL__
|
|
333
333
|
```bash
|
|
334
|
-
|
|
334
|
+
npm install tedious
|
|
335
335
|
```
|
|
336
336
|
```javascript
|
|
337
337
|
import map from './map';
|
|
@@ -353,7 +353,7 @@ const db = map.mssql({
|
|
|
353
353
|
|
|
354
354
|
__PostgreSQL__
|
|
355
355
|
```bash
|
|
356
|
-
|
|
356
|
+
npm install pg
|
|
357
357
|
```
|
|
358
358
|
```javascript
|
|
359
359
|
import map from './map';
|
|
@@ -361,7 +361,7 @@ const db = map.postgres('postgres://postgres:postgres@postgres/postgres');
|
|
|
361
361
|
```
|
|
362
362
|
__Oracle__
|
|
363
363
|
```bash
|
|
364
|
-
|
|
364
|
+
npm install oracledb
|
|
365
365
|
```
|
|
366
366
|
```javascript
|
|
367
367
|
import map from './map';
|
|
@@ -375,7 +375,7 @@ const db = map.oracle({
|
|
|
375
375
|
__SAP Adaptive Server__
|
|
376
376
|
Even though msnodesqlv8 was developed for MS SQL, it also works for SAP ASE as it is ODBC compliant.
|
|
377
377
|
```bash
|
|
378
|
-
|
|
378
|
+
npm install msnodesqlv8
|
|
379
379
|
```
|
|
380
380
|
```javascript
|
|
381
381
|
import { fileURLToPath } from 'url';
|
package/docs/changelog.md
CHANGED
package/package.json
CHANGED
package/src/client/index.mjs
CHANGED
|
@@ -2311,6 +2311,36 @@ const isAsyncFn = kindOfTest('AsyncFunction');
|
|
|
2311
2311
|
const isThenable = (thing) =>
|
|
2312
2312
|
thing && (isObject(thing) || isFunction(thing)) && isFunction(thing.then) && isFunction(thing.catch);
|
|
2313
2313
|
|
|
2314
|
+
// original code
|
|
2315
|
+
// https://github.com/DigitalBrainJS/AxiosPromise/blob/16deab13710ec09779922131f3fa5954320f83ab/lib/utils.js#L11-L34
|
|
2316
|
+
|
|
2317
|
+
const _setImmediate = ((setImmediateSupported, postMessageSupported) => {
|
|
2318
|
+
if (setImmediateSupported) {
|
|
2319
|
+
return setImmediate;
|
|
2320
|
+
}
|
|
2321
|
+
|
|
2322
|
+
return postMessageSupported ? ((token, callbacks) => {
|
|
2323
|
+
_global.addEventListener("message", ({source, data}) => {
|
|
2324
|
+
if (source === _global && data === token) {
|
|
2325
|
+
callbacks.length && callbacks.shift()();
|
|
2326
|
+
}
|
|
2327
|
+
}, false);
|
|
2328
|
+
|
|
2329
|
+
return (cb) => {
|
|
2330
|
+
callbacks.push(cb);
|
|
2331
|
+
_global.postMessage(token, "*");
|
|
2332
|
+
}
|
|
2333
|
+
})(`axios@${Math.random()}`, []) : (cb) => setTimeout(cb);
|
|
2334
|
+
})(
|
|
2335
|
+
typeof setImmediate === 'function',
|
|
2336
|
+
isFunction(_global.postMessage)
|
|
2337
|
+
);
|
|
2338
|
+
|
|
2339
|
+
const asap = typeof queueMicrotask !== 'undefined' ?
|
|
2340
|
+
queueMicrotask.bind(_global) : ( typeof process !== 'undefined' && process.nextTick || _setImmediate);
|
|
2341
|
+
|
|
2342
|
+
// *********************
|
|
2343
|
+
|
|
2314
2344
|
var utils$1 = {
|
|
2315
2345
|
isArray,
|
|
2316
2346
|
isArrayBuffer,
|
|
@@ -2366,7 +2396,9 @@ var utils$1 = {
|
|
|
2366
2396
|
isSpecCompliantForm,
|
|
2367
2397
|
toJSONObject,
|
|
2368
2398
|
isAsyncFn,
|
|
2369
|
-
isThenable
|
|
2399
|
+
isThenable,
|
|
2400
|
+
setImmediate: _setImmediate,
|
|
2401
|
+
asap
|
|
2370
2402
|
};
|
|
2371
2403
|
|
|
2372
2404
|
/**
|
|
@@ -2394,7 +2426,10 @@ function AxiosError(message, code, config, request, response) {
|
|
|
2394
2426
|
code && (this.code = code);
|
|
2395
2427
|
config && (this.config = config);
|
|
2396
2428
|
request && (this.request = request);
|
|
2397
|
-
|
|
2429
|
+
if (response) {
|
|
2430
|
+
this.response = response;
|
|
2431
|
+
this.status = response.status ? response.status : null;
|
|
2432
|
+
}
|
|
2398
2433
|
}
|
|
2399
2434
|
|
|
2400
2435
|
utils$1.inherits(AxiosError, Error, {
|
|
@@ -2414,7 +2449,7 @@ utils$1.inherits(AxiosError, Error, {
|
|
|
2414
2449
|
// Axios
|
|
2415
2450
|
config: utils$1.toJSONObject(this.config),
|
|
2416
2451
|
code: this.code,
|
|
2417
|
-
status: this.
|
|
2452
|
+
status: this.status
|
|
2418
2453
|
};
|
|
2419
2454
|
}
|
|
2420
2455
|
});
|
|
@@ -2882,6 +2917,8 @@ var platform$1 = {
|
|
|
2882
2917
|
|
|
2883
2918
|
const hasBrowserEnv = typeof window !== 'undefined' && typeof document !== 'undefined';
|
|
2884
2919
|
|
|
2920
|
+
const _navigator = typeof navigator === 'object' && navigator || undefined;
|
|
2921
|
+
|
|
2885
2922
|
/**
|
|
2886
2923
|
* Determine if we're running in a standard browser environment
|
|
2887
2924
|
*
|
|
@@ -2899,10 +2936,8 @@ const hasBrowserEnv = typeof window !== 'undefined' && typeof document !== 'unde
|
|
|
2899
2936
|
*
|
|
2900
2937
|
* @returns {boolean}
|
|
2901
2938
|
*/
|
|
2902
|
-
const hasStandardBrowserEnv =
|
|
2903
|
-
(product)
|
|
2904
|
-
return hasBrowserEnv && ['ReactNative', 'NativeScript', 'NS'].indexOf(product) < 0
|
|
2905
|
-
})(typeof navigator !== 'undefined' && navigator.product);
|
|
2939
|
+
const hasStandardBrowserEnv = hasBrowserEnv &&
|
|
2940
|
+
(!_navigator || ['ReactNative', 'NativeScript', 'NS'].indexOf(_navigator.product) < 0);
|
|
2906
2941
|
|
|
2907
2942
|
/**
|
|
2908
2943
|
* Determine if we're running in a standard browser webWorker environment
|
|
@@ -2929,6 +2964,7 @@ var utils = /*#__PURE__*/Object.freeze({
|
|
|
2929
2964
|
hasBrowserEnv: hasBrowserEnv,
|
|
2930
2965
|
hasStandardBrowserWebWorkerEnv: hasStandardBrowserWebWorkerEnv,
|
|
2931
2966
|
hasStandardBrowserEnv: hasStandardBrowserEnv,
|
|
2967
|
+
navigator: _navigator,
|
|
2932
2968
|
origin: origin
|
|
2933
2969
|
});
|
|
2934
2970
|
|
|
@@ -3677,31 +3713,42 @@ function speedometer(samplesCount, min) {
|
|
|
3677
3713
|
*/
|
|
3678
3714
|
function throttle(fn, freq) {
|
|
3679
3715
|
let timestamp = 0;
|
|
3680
|
-
|
|
3681
|
-
let
|
|
3682
|
-
|
|
3683
|
-
|
|
3716
|
+
let threshold = 1000 / freq;
|
|
3717
|
+
let lastArgs;
|
|
3718
|
+
let timer;
|
|
3719
|
+
|
|
3720
|
+
const invoke = (args, now = Date.now()) => {
|
|
3721
|
+
timestamp = now;
|
|
3722
|
+
lastArgs = null;
|
|
3723
|
+
if (timer) {
|
|
3724
|
+
clearTimeout(timer);
|
|
3725
|
+
timer = null;
|
|
3726
|
+
}
|
|
3727
|
+
fn.apply(null, args);
|
|
3728
|
+
};
|
|
3684
3729
|
|
|
3730
|
+
const throttled = (...args) => {
|
|
3685
3731
|
const now = Date.now();
|
|
3686
|
-
|
|
3687
|
-
|
|
3688
|
-
|
|
3689
|
-
|
|
3732
|
+
const passed = now - timestamp;
|
|
3733
|
+
if ( passed >= threshold) {
|
|
3734
|
+
invoke(args, now);
|
|
3735
|
+
} else {
|
|
3736
|
+
lastArgs = args;
|
|
3737
|
+
if (!timer) {
|
|
3738
|
+
timer = setTimeout(() => {
|
|
3739
|
+
timer = null;
|
|
3740
|
+
invoke(lastArgs);
|
|
3741
|
+
}, threshold - passed);
|
|
3690
3742
|
}
|
|
3691
|
-
timestamp = now;
|
|
3692
|
-
return fn.apply(null, arguments);
|
|
3693
|
-
}
|
|
3694
|
-
if (!timer) {
|
|
3695
|
-
timer = setTimeout(() => {
|
|
3696
|
-
timer = null;
|
|
3697
|
-
timestamp = Date.now();
|
|
3698
|
-
return fn.apply(null, arguments);
|
|
3699
|
-
}, threshold - (now - timestamp));
|
|
3700
3743
|
}
|
|
3701
3744
|
};
|
|
3745
|
+
|
|
3746
|
+
const flush = () => lastArgs && invoke(lastArgs);
|
|
3747
|
+
|
|
3748
|
+
return [throttled, flush];
|
|
3702
3749
|
}
|
|
3703
3750
|
|
|
3704
|
-
|
|
3751
|
+
const progressEventReducer = (listener, isDownloadStream, freq = 3) => {
|
|
3705
3752
|
let bytesNotified = 0;
|
|
3706
3753
|
const _speedometer = speedometer(50, 250);
|
|
3707
3754
|
|
|
@@ -3722,21 +3769,32 @@ var progressEventReducer = (listener, isDownloadStream, freq = 3) => {
|
|
|
3722
3769
|
rate: rate ? rate : undefined,
|
|
3723
3770
|
estimated: rate && total && inRange ? (total - loaded) / rate : undefined,
|
|
3724
3771
|
event: e,
|
|
3725
|
-
lengthComputable: total != null
|
|
3772
|
+
lengthComputable: total != null,
|
|
3773
|
+
[isDownloadStream ? 'download' : 'upload']: true
|
|
3726
3774
|
};
|
|
3727
3775
|
|
|
3728
|
-
data[isDownloadStream ? 'download' : 'upload'] = true;
|
|
3729
|
-
|
|
3730
3776
|
listener(data);
|
|
3731
3777
|
}, freq);
|
|
3732
3778
|
};
|
|
3733
3779
|
|
|
3780
|
+
const progressEventDecorator = (total, throttled) => {
|
|
3781
|
+
const lengthComputable = total != null;
|
|
3782
|
+
|
|
3783
|
+
return [(loaded) => throttled[0]({
|
|
3784
|
+
lengthComputable,
|
|
3785
|
+
total,
|
|
3786
|
+
loaded
|
|
3787
|
+
}), throttled[1]];
|
|
3788
|
+
};
|
|
3789
|
+
|
|
3790
|
+
const asyncDecorator = (fn) => (...args) => utils$1.asap(() => fn(...args));
|
|
3791
|
+
|
|
3734
3792
|
var isURLSameOrigin = platform.hasStandardBrowserEnv ?
|
|
3735
3793
|
|
|
3736
3794
|
// Standard browser envs have full support of the APIs needed to test
|
|
3737
3795
|
// whether the request URL is of the same origin as current location.
|
|
3738
3796
|
(function standardBrowserEnv() {
|
|
3739
|
-
const msie = /(msie|trident)/i.test(navigator.userAgent);
|
|
3797
|
+
const msie = platform.navigator && /(msie|trident)/i.test(platform.navigator.userAgent);
|
|
3740
3798
|
const urlParsingNode = document.createElement('a');
|
|
3741
3799
|
let originURL;
|
|
3742
3800
|
|
|
@@ -4035,16 +4093,18 @@ var xhrAdapter = isXHRAdapterSupported && function (config) {
|
|
|
4035
4093
|
const _config = resolveConfig(config);
|
|
4036
4094
|
let requestData = _config.data;
|
|
4037
4095
|
const requestHeaders = AxiosHeaders$1.from(_config.headers).normalize();
|
|
4038
|
-
let {responseType} = _config;
|
|
4096
|
+
let {responseType, onUploadProgress, onDownloadProgress} = _config;
|
|
4039
4097
|
let onCanceled;
|
|
4098
|
+
let uploadThrottled, downloadThrottled;
|
|
4099
|
+
let flushUpload, flushDownload;
|
|
4100
|
+
|
|
4040
4101
|
function done() {
|
|
4041
|
-
|
|
4042
|
-
|
|
4043
|
-
}
|
|
4102
|
+
flushUpload && flushUpload(); // flush events
|
|
4103
|
+
flushDownload && flushDownload(); // flush events
|
|
4044
4104
|
|
|
4045
|
-
|
|
4046
|
-
|
|
4047
|
-
|
|
4105
|
+
_config.cancelToken && _config.cancelToken.unsubscribe(onCanceled);
|
|
4106
|
+
|
|
4107
|
+
_config.signal && _config.signal.removeEventListener('abort', onCanceled);
|
|
4048
4108
|
}
|
|
4049
4109
|
|
|
4050
4110
|
let request = new XMLHttpRequest();
|
|
@@ -4114,7 +4174,7 @@ var xhrAdapter = isXHRAdapterSupported && function (config) {
|
|
|
4114
4174
|
return;
|
|
4115
4175
|
}
|
|
4116
4176
|
|
|
4117
|
-
reject(new AxiosError('Request aborted', AxiosError.ECONNABORTED,
|
|
4177
|
+
reject(new AxiosError('Request aborted', AxiosError.ECONNABORTED, config, request));
|
|
4118
4178
|
|
|
4119
4179
|
// Clean up request
|
|
4120
4180
|
request = null;
|
|
@@ -4124,7 +4184,7 @@ var xhrAdapter = isXHRAdapterSupported && function (config) {
|
|
|
4124
4184
|
request.onerror = function handleError() {
|
|
4125
4185
|
// Real errors are hidden from us by the browser
|
|
4126
4186
|
// onerror should only fire if it's a network error
|
|
4127
|
-
reject(new AxiosError('Network Error', AxiosError.ERR_NETWORK,
|
|
4187
|
+
reject(new AxiosError('Network Error', AxiosError.ERR_NETWORK, config, request));
|
|
4128
4188
|
|
|
4129
4189
|
// Clean up request
|
|
4130
4190
|
request = null;
|
|
@@ -4140,7 +4200,7 @@ var xhrAdapter = isXHRAdapterSupported && function (config) {
|
|
|
4140
4200
|
reject(new AxiosError(
|
|
4141
4201
|
timeoutErrorMessage,
|
|
4142
4202
|
transitional.clarifyTimeoutError ? AxiosError.ETIMEDOUT : AxiosError.ECONNABORTED,
|
|
4143
|
-
|
|
4203
|
+
config,
|
|
4144
4204
|
request));
|
|
4145
4205
|
|
|
4146
4206
|
// Clean up request
|
|
@@ -4168,13 +4228,18 @@ var xhrAdapter = isXHRAdapterSupported && function (config) {
|
|
|
4168
4228
|
}
|
|
4169
4229
|
|
|
4170
4230
|
// Handle progress if needed
|
|
4171
|
-
if (
|
|
4172
|
-
|
|
4231
|
+
if (onDownloadProgress) {
|
|
4232
|
+
([downloadThrottled, flushDownload] = progressEventReducer(onDownloadProgress, true));
|
|
4233
|
+
request.addEventListener('progress', downloadThrottled);
|
|
4173
4234
|
}
|
|
4174
4235
|
|
|
4175
4236
|
// Not all browsers support upload events
|
|
4176
|
-
if (
|
|
4177
|
-
|
|
4237
|
+
if (onUploadProgress && request.upload) {
|
|
4238
|
+
([uploadThrottled, flushUpload] = progressEventReducer(onUploadProgress));
|
|
4239
|
+
|
|
4240
|
+
request.upload.addEventListener('progress', uploadThrottled);
|
|
4241
|
+
|
|
4242
|
+
request.upload.addEventListener('loadend', flushUpload);
|
|
4178
4243
|
}
|
|
4179
4244
|
|
|
4180
4245
|
if (_config.cancelToken || _config.signal) {
|
|
@@ -4209,45 +4274,46 @@ var xhrAdapter = isXHRAdapterSupported && function (config) {
|
|
|
4209
4274
|
};
|
|
4210
4275
|
|
|
4211
4276
|
const composeSignals = (signals, timeout) => {
|
|
4212
|
-
|
|
4277
|
+
const {length} = (signals = signals ? signals.filter(Boolean) : []);
|
|
4213
4278
|
|
|
4214
|
-
|
|
4279
|
+
if (timeout || length) {
|
|
4280
|
+
let controller = new AbortController();
|
|
4215
4281
|
|
|
4216
|
-
|
|
4217
|
-
if (!aborted) {
|
|
4218
|
-
aborted = true;
|
|
4219
|
-
unsubscribe();
|
|
4220
|
-
const err = cancel instanceof Error ? cancel : this.reason;
|
|
4221
|
-
controller.abort(err instanceof AxiosError ? err : new CanceledError(err instanceof Error ? err.message : err));
|
|
4222
|
-
}
|
|
4223
|
-
};
|
|
4282
|
+
let aborted;
|
|
4224
4283
|
|
|
4225
|
-
|
|
4226
|
-
|
|
4227
|
-
|
|
4284
|
+
const onabort = function (reason) {
|
|
4285
|
+
if (!aborted) {
|
|
4286
|
+
aborted = true;
|
|
4287
|
+
unsubscribe();
|
|
4288
|
+
const err = reason instanceof Error ? reason : this.reason;
|
|
4289
|
+
controller.abort(err instanceof AxiosError ? err : new CanceledError(err instanceof Error ? err.message : err));
|
|
4290
|
+
}
|
|
4291
|
+
};
|
|
4228
4292
|
|
|
4229
|
-
|
|
4230
|
-
if (signals) {
|
|
4231
|
-
timer && clearTimeout(timer);
|
|
4293
|
+
let timer = timeout && setTimeout(() => {
|
|
4232
4294
|
timer = null;
|
|
4233
|
-
|
|
4234
|
-
|
|
4235
|
-
(signal.removeEventListener ? signal.removeEventListener('abort', onabort) : signal.unsubscribe(onabort));
|
|
4236
|
-
});
|
|
4237
|
-
signals = null;
|
|
4238
|
-
}
|
|
4239
|
-
};
|
|
4295
|
+
onabort(new AxiosError(`timeout ${timeout} of ms exceeded`, AxiosError.ETIMEDOUT));
|
|
4296
|
+
}, timeout);
|
|
4240
4297
|
|
|
4241
|
-
|
|
4298
|
+
const unsubscribe = () => {
|
|
4299
|
+
if (signals) {
|
|
4300
|
+
timer && clearTimeout(timer);
|
|
4301
|
+
timer = null;
|
|
4302
|
+
signals.forEach(signal => {
|
|
4303
|
+
signal.unsubscribe ? signal.unsubscribe(onabort) : signal.removeEventListener('abort', onabort);
|
|
4304
|
+
});
|
|
4305
|
+
signals = null;
|
|
4306
|
+
}
|
|
4307
|
+
};
|
|
4308
|
+
|
|
4309
|
+
signals.forEach((signal) => signal.addEventListener('abort', onabort));
|
|
4242
4310
|
|
|
4243
|
-
|
|
4311
|
+
const {signal} = controller;
|
|
4244
4312
|
|
|
4245
|
-
|
|
4313
|
+
signal.unsubscribe = () => utils$1.asap(unsubscribe);
|
|
4246
4314
|
|
|
4247
|
-
|
|
4248
|
-
|
|
4249
|
-
timer = null;
|
|
4250
|
-
}];
|
|
4315
|
+
return signal;
|
|
4316
|
+
}
|
|
4251
4317
|
};
|
|
4252
4318
|
|
|
4253
4319
|
var composeSignals$1 = composeSignals;
|
|
@@ -4270,35 +4336,68 @@ const streamChunk = function* (chunk, chunkSize) {
|
|
|
4270
4336
|
}
|
|
4271
4337
|
};
|
|
4272
4338
|
|
|
4273
|
-
const readBytes = async function* (iterable, chunkSize
|
|
4274
|
-
for await (const chunk of iterable) {
|
|
4275
|
-
yield* streamChunk(
|
|
4339
|
+
const readBytes = async function* (iterable, chunkSize) {
|
|
4340
|
+
for await (const chunk of readStream(iterable)) {
|
|
4341
|
+
yield* streamChunk(chunk, chunkSize);
|
|
4276
4342
|
}
|
|
4277
4343
|
};
|
|
4278
4344
|
|
|
4279
|
-
const
|
|
4280
|
-
|
|
4345
|
+
const readStream = async function* (stream) {
|
|
4346
|
+
if (stream[Symbol.asyncIterator]) {
|
|
4347
|
+
yield* stream;
|
|
4348
|
+
return;
|
|
4349
|
+
}
|
|
4350
|
+
|
|
4351
|
+
const reader = stream.getReader();
|
|
4352
|
+
try {
|
|
4353
|
+
for (;;) {
|
|
4354
|
+
const {done, value} = await reader.read();
|
|
4355
|
+
if (done) {
|
|
4356
|
+
break;
|
|
4357
|
+
}
|
|
4358
|
+
yield value;
|
|
4359
|
+
}
|
|
4360
|
+
} finally {
|
|
4361
|
+
await reader.cancel();
|
|
4362
|
+
}
|
|
4363
|
+
};
|
|
4364
|
+
|
|
4365
|
+
const trackStream = (stream, chunkSize, onProgress, onFinish) => {
|
|
4366
|
+
const iterator = readBytes(stream, chunkSize);
|
|
4281
4367
|
|
|
4282
4368
|
let bytes = 0;
|
|
4369
|
+
let done;
|
|
4370
|
+
let _onFinish = (e) => {
|
|
4371
|
+
if (!done) {
|
|
4372
|
+
done = true;
|
|
4373
|
+
onFinish && onFinish(e);
|
|
4374
|
+
}
|
|
4375
|
+
};
|
|
4283
4376
|
|
|
4284
4377
|
return new ReadableStream({
|
|
4285
|
-
type: 'bytes',
|
|
4286
|
-
|
|
4287
4378
|
async pull(controller) {
|
|
4288
|
-
|
|
4379
|
+
try {
|
|
4380
|
+
const {done, value} = await iterator.next();
|
|
4289
4381
|
|
|
4290
|
-
|
|
4291
|
-
|
|
4292
|
-
|
|
4293
|
-
|
|
4294
|
-
|
|
4382
|
+
if (done) {
|
|
4383
|
+
_onFinish();
|
|
4384
|
+
controller.close();
|
|
4385
|
+
return;
|
|
4386
|
+
}
|
|
4295
4387
|
|
|
4296
|
-
|
|
4297
|
-
|
|
4298
|
-
|
|
4388
|
+
let len = value.byteLength;
|
|
4389
|
+
if (onProgress) {
|
|
4390
|
+
let loadedBytes = bytes += len;
|
|
4391
|
+
onProgress(loadedBytes);
|
|
4392
|
+
}
|
|
4393
|
+
controller.enqueue(new Uint8Array(value));
|
|
4394
|
+
} catch (err) {
|
|
4395
|
+
_onFinish(err);
|
|
4396
|
+
throw err;
|
|
4397
|
+
}
|
|
4299
4398
|
},
|
|
4300
4399
|
cancel(reason) {
|
|
4301
|
-
|
|
4400
|
+
_onFinish(reason);
|
|
4302
4401
|
return iterator.return();
|
|
4303
4402
|
}
|
|
4304
4403
|
}, {
|
|
@@ -4306,15 +4405,6 @@ const trackStream = (stream, chunkSize, onProgress, onFinish, encode) => {
|
|
|
4306
4405
|
})
|
|
4307
4406
|
};
|
|
4308
4407
|
|
|
4309
|
-
const fetchProgressDecorator = (total, fn) => {
|
|
4310
|
-
const lengthComputable = total != null;
|
|
4311
|
-
return (loaded) => setTimeout(() => fn({
|
|
4312
|
-
lengthComputable,
|
|
4313
|
-
total,
|
|
4314
|
-
loaded
|
|
4315
|
-
}));
|
|
4316
|
-
};
|
|
4317
|
-
|
|
4318
4408
|
const isFetchSupported = typeof fetch === 'function' && typeof Request === 'function' && typeof Response === 'function';
|
|
4319
4409
|
const isReadableStreamSupported = isFetchSupported && typeof ReadableStream === 'function';
|
|
4320
4410
|
|
|
@@ -4324,7 +4414,15 @@ const encodeText = isFetchSupported && (typeof TextEncoder === 'function' ?
|
|
|
4324
4414
|
async (str) => new Uint8Array(await new Response(str).arrayBuffer())
|
|
4325
4415
|
);
|
|
4326
4416
|
|
|
4327
|
-
const
|
|
4417
|
+
const test = (fn, ...args) => {
|
|
4418
|
+
try {
|
|
4419
|
+
return !!fn(...args);
|
|
4420
|
+
} catch (e) {
|
|
4421
|
+
return false
|
|
4422
|
+
}
|
|
4423
|
+
};
|
|
4424
|
+
|
|
4425
|
+
const supportsRequestStream = isReadableStreamSupported && test(() => {
|
|
4328
4426
|
let duplexAccessed = false;
|
|
4329
4427
|
|
|
4330
4428
|
const hasContentType = new Request(platform.origin, {
|
|
@@ -4337,17 +4435,13 @@ const supportsRequestStream = isReadableStreamSupported && (() => {
|
|
|
4337
4435
|
}).headers.has('Content-Type');
|
|
4338
4436
|
|
|
4339
4437
|
return duplexAccessed && !hasContentType;
|
|
4340
|
-
})
|
|
4438
|
+
});
|
|
4341
4439
|
|
|
4342
4440
|
const DEFAULT_CHUNK_SIZE = 64 * 1024;
|
|
4343
4441
|
|
|
4344
|
-
const supportsResponseStream = isReadableStreamSupported &&
|
|
4345
|
-
|
|
4346
|
-
|
|
4347
|
-
} catch(err) {
|
|
4348
|
-
// return undefined
|
|
4349
|
-
}
|
|
4350
|
-
})();
|
|
4442
|
+
const supportsResponseStream = isReadableStreamSupported &&
|
|
4443
|
+
test(() => utils$1.isReadableStream(new Response('').body));
|
|
4444
|
+
|
|
4351
4445
|
|
|
4352
4446
|
const resolvers = {
|
|
4353
4447
|
stream: supportsResponseStream && ((res) => res.body)
|
|
@@ -4372,10 +4466,14 @@ const getBodyLength = async (body) => {
|
|
|
4372
4466
|
}
|
|
4373
4467
|
|
|
4374
4468
|
if(utils$1.isSpecCompliantForm(body)) {
|
|
4375
|
-
|
|
4469
|
+
const _request = new Request(platform.origin, {
|
|
4470
|
+
method: 'POST',
|
|
4471
|
+
body,
|
|
4472
|
+
});
|
|
4473
|
+
return (await _request.arrayBuffer()).byteLength;
|
|
4376
4474
|
}
|
|
4377
4475
|
|
|
4378
|
-
if(utils$1.isArrayBufferView(body)) {
|
|
4476
|
+
if(utils$1.isArrayBufferView(body) || utils$1.isArrayBuffer(body)) {
|
|
4379
4477
|
return body.byteLength;
|
|
4380
4478
|
}
|
|
4381
4479
|
|
|
@@ -4412,18 +4510,13 @@ var fetchAdapter = isFetchSupported && (async (config) => {
|
|
|
4412
4510
|
|
|
4413
4511
|
responseType = responseType ? (responseType + '').toLowerCase() : 'text';
|
|
4414
4512
|
|
|
4415
|
-
let
|
|
4416
|
-
composeSignals$1([signal, cancelToken], timeout) : [];
|
|
4417
|
-
|
|
4418
|
-
let finished, request;
|
|
4513
|
+
let composedSignal = composeSignals$1([signal, cancelToken && cancelToken.toAbortSignal()], timeout);
|
|
4419
4514
|
|
|
4420
|
-
|
|
4421
|
-
!finished && setTimeout(() => {
|
|
4422
|
-
composedSignal && composedSignal.unsubscribe();
|
|
4423
|
-
});
|
|
4515
|
+
let request;
|
|
4424
4516
|
|
|
4425
|
-
|
|
4426
|
-
|
|
4517
|
+
const unsubscribe = composedSignal && composedSignal.unsubscribe && (() => {
|
|
4518
|
+
composedSignal.unsubscribe();
|
|
4519
|
+
});
|
|
4427
4520
|
|
|
4428
4521
|
let requestContentLength;
|
|
4429
4522
|
|
|
@@ -4445,17 +4538,22 @@ var fetchAdapter = isFetchSupported && (async (config) => {
|
|
|
4445
4538
|
}
|
|
4446
4539
|
|
|
4447
4540
|
if (_request.body) {
|
|
4448
|
-
|
|
4541
|
+
const [onProgress, flush] = progressEventDecorator(
|
|
4449
4542
|
requestContentLength,
|
|
4450
|
-
progressEventReducer(onUploadProgress)
|
|
4451
|
-
)
|
|
4543
|
+
progressEventReducer(asyncDecorator(onUploadProgress))
|
|
4544
|
+
);
|
|
4545
|
+
|
|
4546
|
+
data = trackStream(_request.body, DEFAULT_CHUNK_SIZE, onProgress, flush);
|
|
4452
4547
|
}
|
|
4453
4548
|
}
|
|
4454
4549
|
|
|
4455
4550
|
if (!utils$1.isString(withCredentials)) {
|
|
4456
|
-
withCredentials = withCredentials ? '
|
|
4551
|
+
withCredentials = withCredentials ? 'include' : 'omit';
|
|
4457
4552
|
}
|
|
4458
4553
|
|
|
4554
|
+
// Cloudflare Workers throws when credentials are defined
|
|
4555
|
+
// see https://github.com/cloudflare/workerd/issues/902
|
|
4556
|
+
const isCredentialsSupported = "credentials" in Request.prototype;
|
|
4459
4557
|
request = new Request(url, {
|
|
4460
4558
|
...fetchOptions,
|
|
4461
4559
|
signal: composedSignal,
|
|
@@ -4463,14 +4561,14 @@ var fetchAdapter = isFetchSupported && (async (config) => {
|
|
|
4463
4561
|
headers: headers.normalize().toJSON(),
|
|
4464
4562
|
body: data,
|
|
4465
4563
|
duplex: "half",
|
|
4466
|
-
withCredentials
|
|
4564
|
+
credentials: isCredentialsSupported ? withCredentials : undefined
|
|
4467
4565
|
});
|
|
4468
4566
|
|
|
4469
4567
|
let response = await fetch(request);
|
|
4470
4568
|
|
|
4471
4569
|
const isStreamResponse = supportsResponseStream && (responseType === 'stream' || responseType === 'response');
|
|
4472
4570
|
|
|
4473
|
-
if (supportsResponseStream && (onDownloadProgress || isStreamResponse)) {
|
|
4571
|
+
if (supportsResponseStream && (onDownloadProgress || (isStreamResponse && unsubscribe))) {
|
|
4474
4572
|
const options = {};
|
|
4475
4573
|
|
|
4476
4574
|
['status', 'statusText', 'headers'].forEach(prop => {
|
|
@@ -4479,11 +4577,16 @@ var fetchAdapter = isFetchSupported && (async (config) => {
|
|
|
4479
4577
|
|
|
4480
4578
|
const responseContentLength = utils$1.toFiniteNumber(response.headers.get('content-length'));
|
|
4481
4579
|
|
|
4580
|
+
const [onProgress, flush] = onDownloadProgress && progressEventDecorator(
|
|
4581
|
+
responseContentLength,
|
|
4582
|
+
progressEventReducer(asyncDecorator(onDownloadProgress), true)
|
|
4583
|
+
) || [];
|
|
4584
|
+
|
|
4482
4585
|
response = new Response(
|
|
4483
|
-
trackStream(response.body, DEFAULT_CHUNK_SIZE,
|
|
4484
|
-
|
|
4485
|
-
|
|
4486
|
-
),
|
|
4586
|
+
trackStream(response.body, DEFAULT_CHUNK_SIZE, onProgress, () => {
|
|
4587
|
+
flush && flush();
|
|
4588
|
+
unsubscribe && unsubscribe();
|
|
4589
|
+
}),
|
|
4487
4590
|
options
|
|
4488
4591
|
);
|
|
4489
4592
|
}
|
|
@@ -4492,9 +4595,7 @@ var fetchAdapter = isFetchSupported && (async (config) => {
|
|
|
4492
4595
|
|
|
4493
4596
|
let responseData = await resolvers[utils$1.findKey(resolvers, responseType) || 'text'](response, config);
|
|
4494
4597
|
|
|
4495
|
-
!isStreamResponse &&
|
|
4496
|
-
|
|
4497
|
-
stopTimeout && stopTimeout();
|
|
4598
|
+
!isStreamResponse && unsubscribe && unsubscribe();
|
|
4498
4599
|
|
|
4499
4600
|
return await new Promise((resolve, reject) => {
|
|
4500
4601
|
settle(resolve, reject, {
|
|
@@ -4507,7 +4608,7 @@ var fetchAdapter = isFetchSupported && (async (config) => {
|
|
|
4507
4608
|
});
|
|
4508
4609
|
})
|
|
4509
4610
|
} catch (err) {
|
|
4510
|
-
|
|
4611
|
+
unsubscribe && unsubscribe();
|
|
4511
4612
|
|
|
4512
4613
|
if (err && err.name === 'TypeError' && /fetch/i.test(err.message)) {
|
|
4513
4614
|
throw Object.assign(
|
|
@@ -4669,7 +4770,7 @@ function dispatchRequest(config) {
|
|
|
4669
4770
|
});
|
|
4670
4771
|
}
|
|
4671
4772
|
|
|
4672
|
-
const VERSION = "1.7.
|
|
4773
|
+
const VERSION = "1.7.7";
|
|
4673
4774
|
|
|
4674
4775
|
const validators$1 = {};
|
|
4675
4776
|
|
|
@@ -5076,6 +5177,20 @@ class CancelToken {
|
|
|
5076
5177
|
}
|
|
5077
5178
|
}
|
|
5078
5179
|
|
|
5180
|
+
toAbortSignal() {
|
|
5181
|
+
const controller = new AbortController();
|
|
5182
|
+
|
|
5183
|
+
const abort = (err) => {
|
|
5184
|
+
controller.abort(err);
|
|
5185
|
+
};
|
|
5186
|
+
|
|
5187
|
+
this.subscribe(abort);
|
|
5188
|
+
|
|
5189
|
+
controller.signal.unsubscribe = () => this.unsubscribe(abort);
|
|
5190
|
+
|
|
5191
|
+
return controller.signal;
|
|
5192
|
+
}
|
|
5193
|
+
|
|
5079
5194
|
/**
|
|
5080
5195
|
* Returns an object that contains a new `CancelToken` and a function that, when called,
|
|
5081
5196
|
* cancels the `CancelToken`.
|
|
@@ -1,14 +1,12 @@
|
|
|
1
|
-
var
|
|
1
|
+
var patternWithTime = /(\d{4}-[01]\d-[0-3]\d(T| )[0-2]\d:[0-5]\d:[0-5]\d\.\d+)|(\d{4}-[01]\d-[0-3]\d(T| )[0-2]\d:[0-5]\d:[0-5]\d)|(\d{4}-[01]\d-[0-3]\d(T| )[0-2]\d:[0-5]\d)/;
|
|
2
|
+
var patternDateOnly = /^\d{4}-[01]\d-[0-3]\d$/;
|
|
2
3
|
|
|
3
4
|
function tryParseISO(iso) {
|
|
4
|
-
if (
|
|
5
|
+
if (patternWithTime.test(iso) || patternDateOnly.test(iso)) {
|
|
5
6
|
return iso;
|
|
6
|
-
else
|
|
7
|
-
throw new TypeError(iso +
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
7
|
+
} else {
|
|
8
|
+
throw new TypeError(iso + ' is not a valid Date');
|
|
9
|
+
}
|
|
12
10
|
}
|
|
13
11
|
|
|
14
12
|
module.exports = tryParseISO;
|