orange-orm 4.5.0-beta.0 → 4.5.0-beta.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.
Files changed (261) hide show
  1. package/README.md +6 -1
  2. package/docs/changelog.md +4 -0
  3. package/package.json +8 -5
  4. package/src/client/index.js +3 -2
  5. package/src/client/index.mjs +253 -137
  6. package/src/createDomain.js +11 -16
  7. package/src/d1/newDatabase.js +23 -37
  8. package/src/d1/newPool.js +6 -6
  9. package/src/d1/pool/newGenericPool.js +2 -1
  10. package/src/emitEvent.js +6 -4
  11. package/src/emptyFilter.js +12 -12
  12. package/src/getManyDto/newQuery.js +5 -5
  13. package/src/getManyDto/query/newSingleQuery.js +5 -5
  14. package/src/getManyDto.js +25 -24
  15. package/src/hostExpress/cycle.ts +211 -0
  16. package/src/hostExpress/executePath.js +360 -357
  17. package/src/hostLocal.js +8 -8
  18. package/src/index.js +11 -16
  19. package/src/mssql/newDatabase.js +19 -31
  20. package/src/mssql/newPool.js +2 -2
  21. package/src/mssql/newTransaction.js +4 -3
  22. package/src/mssql/pool/newGenericPool.js +1 -1
  23. package/src/mySql/deleteFromSql.js +1 -1
  24. package/src/mySql/insert.js +5 -5
  25. package/src/mySql/insertSql.js +2 -3
  26. package/src/mySql/lastInsertedSql.js +3 -4
  27. package/src/mySql/newDatabase.js +20 -34
  28. package/src/mySql/newPool.js +10 -10
  29. package/src/mySql/newTransaction.js +2 -2
  30. package/src/mySql/pool/newGenericPool.js +2 -3
  31. package/src/mySql/quote.js +1 -0
  32. package/src/newImmutable.js +1 -2
  33. package/src/oracle/deleteFromSql.js +1 -1
  34. package/src/oracle/formatDateOut.js +1 -1
  35. package/src/oracle/insert.js +6 -6
  36. package/src/oracle/insertSql.js +6 -14
  37. package/src/oracle/lastInsertedSql.js +3 -3
  38. package/src/oracle/mergeSql.js +3 -6
  39. package/src/oracle/newDatabase.js +18 -33
  40. package/src/oracle/newInsertCommandCore.js +3 -3
  41. package/src/oracle/newPool.js +10 -10
  42. package/src/oracle/newTransaction.js +2 -1
  43. package/src/oracle/pool/newGenericPool.js +2 -2
  44. package/src/oracle/quote.js +1 -0
  45. package/src/oracle/wrapQuery.js +0 -3
  46. package/src/patchRow.js +2 -2
  47. package/src/patchTable.js +6 -5
  48. package/src/pg/deleteFromSql.js +1 -1
  49. package/src/pg/formatDateOut.js +1 -2
  50. package/src/pg/insert.js +3 -3
  51. package/src/pg/insertSql.js +2 -7
  52. package/src/pg/lastInsertedSql.js +1 -2
  53. package/src/pg/newDatabase.js +20 -37
  54. package/src/pg/newPool.js +10 -10
  55. package/src/pg/newTransaction.js +2 -1
  56. package/src/pg/pool/newPgPool.js +23 -4
  57. package/src/pg/pool/parseSearchPathParam.js +10 -0
  58. package/src/pg/quote.js +2 -0
  59. package/src/pg/schema.js +2 -2
  60. package/src/{mySql/pool/defaults.js → poolDefaults.js} +0 -2
  61. package/src/query.js +2 -2
  62. package/src/sap/deleteFromSql.js +1 -1
  63. package/src/sap/formatDateOut.js +1 -1
  64. package/src/sap/insert.js +5 -5
  65. package/src/sap/insertSql.js +4 -5
  66. package/src/sap/lastInsertedSql.js +3 -3
  67. package/src/sap/mergeSql.js +1 -2
  68. package/src/sap/newDatabase.js +23 -34
  69. package/src/sap/newPool.js +2 -2
  70. package/src/sap/newTransaction.js +2 -1
  71. package/src/sap/quote.js +1 -0
  72. package/src/sqlite/deleteFromSql.js +1 -1
  73. package/src/sqlite/insert.js +5 -5
  74. package/src/sqlite/insertSql.js +2 -2
  75. package/src/sqlite/lastInsertedSql.js +2 -2
  76. package/src/sqlite/newDatabase.js +16 -32
  77. package/src/sqlite/newPool.js +10 -10
  78. package/src/sqlite/newTransaction.js +2 -1
  79. package/src/sqlite/pool/newGenericPool.js +2 -1
  80. package/src/sqlite/quote.js +1 -0
  81. package/src/table/aggregate.js +1 -1
  82. package/src/table/begin.js +5 -5
  83. package/src/table/cascadeDelete.js +2 -2
  84. package/src/table/column/binary/newDecode.js +2 -2
  85. package/src/table/column/binary/newEncode.js +3 -4
  86. package/src/table/column/boolean/newDecode.js +1 -1
  87. package/src/table/column/boolean/newEncode.js +6 -6
  88. package/src/table/column/date/formatOut.js +3 -5
  89. package/src/table/column/date/newDecode.js +2 -2
  90. package/src/table/column/date/newEncode.js +8 -8
  91. package/src/table/column/date/tryParseISO.js +6 -8
  92. package/src/table/column/date.js +1 -1
  93. package/src/table/column/dateWithTimeZone/newEncode.js +3 -4
  94. package/src/table/column/dateWithTimeZone.js +1 -1
  95. package/src/table/column/encodeFilterArg.js +3 -3
  96. package/src/table/column/equal.js +3 -3
  97. package/src/table/column/extractAlias.js +0 -2
  98. package/src/table/column/greaterThan.js +3 -3
  99. package/src/table/column/greaterThanOrEqual.js +3 -3
  100. package/src/table/column/guid/newDecode.js +1 -1
  101. package/src/table/column/guid/newEncode.js +3 -3
  102. package/src/table/column/in.js +3 -3
  103. package/src/table/column/json/formatOut.js +3 -3
  104. package/src/table/column/json/newDecode.js +3 -3
  105. package/src/table/column/json/newEncode.js +6 -6
  106. package/src/table/column/json.js +2 -1
  107. package/src/table/column/lessThan.js +3 -3
  108. package/src/table/column/lessThanOrEqual.js +4 -4
  109. package/src/table/column/negotiateRawSqlFilter.js +9 -9
  110. package/src/table/column/newBoolean.js +9 -9
  111. package/src/table/column/newColumn.js +21 -21
  112. package/src/table/column/newDecodeCore.js +1 -1
  113. package/src/table/column/notEqual.js +3 -3
  114. package/src/table/column/numeric/newDecode.js +2 -2
  115. package/src/table/column/numeric/newEncode.js +3 -3
  116. package/src/table/column/string/contains.js +2 -1
  117. package/src/table/column/string/containsCore.js +5 -5
  118. package/src/table/column/string/endsWith.js +1 -1
  119. package/src/table/column/string/endsWithCore.js +4 -4
  120. package/src/table/column/string/iContains.js +2 -1
  121. package/src/table/column/string/iEndsWith.js +1 -1
  122. package/src/table/column/string/iEqual.js +3 -3
  123. package/src/table/column/string/iStartsWith.js +1 -1
  124. package/src/table/column/string/newEncode.js +3 -3
  125. package/src/table/column/string/startsWith.js +1 -1
  126. package/src/table/column/string/startsWithCore.js +4 -4
  127. package/src/table/column/string.js +14 -14
  128. package/src/table/commands/beginCommand.js +2 -2
  129. package/src/table/commands/compressChanges.js +2 -2
  130. package/src/table/commands/delete/newSingleCommand.js +5 -5
  131. package/src/table/commands/delete/singleCommand/joinSql.js +12 -12
  132. package/src/table/commands/delete/singleCommand/newSingleCommandCore.js +2 -2
  133. package/src/table/commands/delete/singleCommand/selectSql.js +6 -6
  134. package/src/table/commands/delete/singleCommand/subFilter.js +11 -11
  135. package/src/table/commands/delete/singleCommand/whereSql.js +2 -2
  136. package/src/table/commands/getChangeSet.js +2 -2
  137. package/src/table/commands/insert/getSqlTemplate.js +16 -16
  138. package/src/table/commands/lastCommandMatches.js +2 -2
  139. package/src/table/commands/newDeleteCommand.js +5 -5
  140. package/src/table/commands/newGetLastInsertedCommand.js +4 -4
  141. package/src/table/commands/newGetLastInsertedCommandCore.js +5 -5
  142. package/src/table/commands/newInsertCommand.js +0 -1
  143. package/src/table/commands/newInsertCommandCore.js +3 -3
  144. package/src/table/commands/newRow.js +4 -4
  145. package/src/table/commands/newUpdateCommand.js +4 -4
  146. package/src/table/commands/newUpdateCommandCore.js +4 -4
  147. package/src/table/commands/pushCommand.js +2 -2
  148. package/src/table/commit.js +13 -11
  149. package/src/table/count.js +8 -8
  150. package/src/table/delete.js +4 -4
  151. package/src/table/deleteSessionContext.js +4 -13
  152. package/src/table/executeQueries/executeChanges.js +3 -3
  153. package/src/table/executeQueries/executeQueriesCore.js +2 -2
  154. package/src/table/executeQueries/executeQuery.js +2 -2
  155. package/src/table/executeQueries/resolveExecuteQuery.js +4 -4
  156. package/src/table/executeQueries.js +4 -4
  157. package/src/table/getFromDbById.js +1 -1
  158. package/src/table/getMany.js +7 -7
  159. package/src/table/getManyDto.js +3 -4
  160. package/src/table/getSessionContext.js +4 -4
  161. package/src/table/getSessionSingleton.js +3 -2
  162. package/src/table/groupBy/newQuery.js +4 -4
  163. package/src/table/groupBy.js +9 -9
  164. package/src/table/insert.js +10 -13
  165. package/src/table/joinRelation/getRelatives.js +6 -6
  166. package/src/table/newGetRelated.js +3 -3
  167. package/src/table/newManyRelation.js +9 -9
  168. package/src/table/newOneRelation.js +9 -9
  169. package/src/table/newPrimaryKeyFilter.js +6 -6
  170. package/src/table/newQuery.js +5 -5
  171. package/src/table/newRelatedTable.js +2 -2
  172. package/src/table/newRowCache.js +17 -17
  173. package/src/table/newThrow.js +2 -2
  174. package/src/table/oneRelation/getRelatives.js +5 -5
  175. package/src/table/popChanges.js +3 -3
  176. package/src/table/promise.js +2 -8
  177. package/src/table/query/extractLimit.js +2 -2
  178. package/src/table/query/extractOffset.js +2 -2
  179. package/src/table/query/extractOrderBy.js +2 -2
  180. package/src/table/query/newSingleQuery.js +7 -7
  181. package/src/table/query/singleQuery/columnSql/joinLegToColumnSql.js +5 -5
  182. package/src/table/query/singleQuery/columnSql/newJoinedColumnSql.js +2 -2
  183. package/src/table/query/singleQuery/columnSql/newShallowColumnSql.js +4 -4
  184. package/src/table/query/singleQuery/joinSql/joinLegToJoinSql.js +2 -2
  185. package/src/table/query/singleQuery/joinSql/joinLegToShallowJoinSql.js +2 -2
  186. package/src/table/query/singleQuery/joinSql/newDiscriminatorSql.js +2 -2
  187. package/src/table/query/singleQuery/joinSql/newShallowJoinSql.js +5 -5
  188. package/src/table/query/singleQuery/joinSql/newShallowJoinSqlCore.js +6 -5
  189. package/src/table/query/singleQuery/joinSql/oneLegToJoinSql.js +2 -2
  190. package/src/table/query/singleQuery/joinSql/oneLegToShallowJoinSql.js +2 -2
  191. package/src/table/query/singleQuery/negotiateExclusive.js +2 -2
  192. package/src/table/query/singleQuery/newColumnSql.js +3 -3
  193. package/src/table/query/singleQuery/newDiscriminatorSql.js +2 -2
  194. package/src/table/query/singleQuery/newJoinSql.js +6 -6
  195. package/src/table/query/singleQuery/newWhereSql.js +3 -3
  196. package/src/table/quote.js +4 -4
  197. package/src/table/relatedTable/aggregate.js +2 -2
  198. package/src/table/relatedTable/all.js +5 -5
  199. package/src/table/relatedTable/any.js +3 -3
  200. package/src/table/relatedTable/childColumn.js +12 -12
  201. package/src/table/relatedTable/columnAggregate.js +3 -3
  202. package/src/table/relatedTable/columnAggregateGroup.js +11 -11
  203. package/src/table/relatedTable/joinSql.js +5 -5
  204. package/src/table/relatedTable/joinSqlArray.js +3 -3
  205. package/src/table/relatedTable/none.js +3 -3
  206. package/src/table/relatedTable/relatedColumn.js +13 -13
  207. package/src/table/relatedTable/selectSql.js +2 -2
  208. package/src/table/relatedTable/subFilter.js +4 -4
  209. package/src/table/relatedTable/where.js +3 -3
  210. package/src/table/relatedTable/whereSql.js +2 -2
  211. package/src/table/relation/manyCache/synchronizeAdded.js +2 -2
  212. package/src/table/relation/manyCache/synchronizeChanged.js +3 -3
  213. package/src/table/relation/manyCache/synchronizeRemoved.js +2 -2
  214. package/src/table/relation/newForeignKeyFilter.js +2 -2
  215. package/src/table/relation/newManyCache.js +16 -16
  216. package/src/table/relation/newOneCache.js +6 -6
  217. package/src/table/releaseDbClient.js +4 -4
  218. package/src/table/resultToPromise.js +1 -3
  219. package/src/table/resultToRows/dbRowToRow.js +8 -8
  220. package/src/table/resultToRows/dbRowsToRows.js +2 -2
  221. package/src/table/resultToRows/decodeDbRow.js +2 -2
  222. package/src/table/resultToRows/delete/removeFromCache.js +6 -6
  223. package/src/table/resultToRows/delete.js +6 -6
  224. package/src/table/resultToRows/newDecodeDbRow.js +19 -18
  225. package/src/table/resultToRows/toDto.js +3 -3
  226. package/src/table/resultToRows.js +3 -3
  227. package/src/table/rollback.js +21 -11
  228. package/src/table/rowArray/negotiateNextTick.js +1 -2
  229. package/src/table/setSessionSingleton.js +6 -3
  230. package/src/table/tryGetFirstFromDb.js +4 -4
  231. package/src/table/tryGetFromCacheById.js +3 -3
  232. package/src/table/tryGetFromDbById/extractStrategy.js +2 -2
  233. package/src/table/tryGetFromDbById.js +8 -6
  234. package/src/table/tryGetSessionContext.js +5 -10
  235. package/src/table/tryReleaseDbClient.js +2 -2
  236. package/src/table/updateField.js +4 -4
  237. package/src/table/where.js +2 -2
  238. package/src/table.js +58 -51
  239. package/src/tedious/deleteFromSql.js +1 -1
  240. package/src/tedious/formatDateOut.js +1 -1
  241. package/src/tedious/getManyDto/newQueryCore.js +5 -5
  242. package/src/tedious/getManyDto/query/newSingleQuery.js +5 -5
  243. package/src/tedious/getManyDto/query/newSubQueries/joinLegToQuery.js +3 -3
  244. package/src/tedious/getManyDto/query/newSubQueries/manyLegToQuery.js +3 -3
  245. package/src/tedious/getManyDto/query/newSubQueries/oneLegToQuery.js +4 -4
  246. package/src/tedious/getManyDto/query/newSubQueries.js +8 -8
  247. package/src/tedious/getManyDto/query/singleQuery/newShallowColumnSql.js +5 -6
  248. package/src/tedious/getManyDto.js +6 -6
  249. package/src/tedious/insert.js +3 -3
  250. package/src/tedious/insertSql.js +3 -3
  251. package/src/tedious/newDatabase.js +17 -30
  252. package/src/tedious/newPool.js +10 -10
  253. package/src/tedious/newTransaction.js +3 -4
  254. package/src/tedious/pool/newGenericPool.js +1 -1
  255. package/src/tedious/quote.js +1 -0
  256. package/src/d1/pool/defaults.js +0 -45
  257. package/src/mssql/pool/defaults.js +0 -45
  258. package/src/oracle/pool/defaults.js +0 -45
  259. package/src/pg/pool/defaults.js +0 -45
  260. package/src/sqlite/pool/defaults.js +0 -45
  261. package/src/tedious/pool/defaults.js +0 -45
@@ -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
- response && (this.response = response);
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.response && this.response.status ? this.response.status : null
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
- const threshold = 1000 / freq;
3681
- let timer = null;
3682
- return function throttled() {
3683
- const force = this === true;
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
- if (force || now - timestamp > threshold) {
3687
- if (timer) {
3688
- clearTimeout(timer);
3689
- timer = null;
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
- var progressEventReducer = (listener, isDownloadStream, freq = 3) => {
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
- if (_config.cancelToken) {
4042
- _config.cancelToken.unsubscribe(onCanceled);
4043
- }
4102
+ flushUpload && flushUpload(); // flush events
4103
+ flushDownload && flushDownload(); // flush events
4044
4104
 
4045
- if (_config.signal) {
4046
- _config.signal.removeEventListener('abort', onCanceled);
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, _config, request));
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, _config, request));
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
- _config,
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 (typeof _config.onDownloadProgress === 'function') {
4172
- request.addEventListener('progress', progressEventReducer(_config.onDownloadProgress, true));
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 (typeof _config.onUploadProgress === 'function' && request.upload) {
4177
- request.upload.addEventListener('progress', progressEventReducer(_config.onUploadProgress));
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
- let controller = new AbortController();
4277
+ const {length} = (signals = signals ? signals.filter(Boolean) : []);
4213
4278
 
4214
- let aborted;
4279
+ if (timeout || length) {
4280
+ let controller = new AbortController();
4215
4281
 
4216
- const onabort = function (cancel) {
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
- let timer = timeout && setTimeout(() => {
4226
- onabort(new AxiosError(`timeout ${timeout} of ms exceeded`, AxiosError.ETIMEDOUT));
4227
- }, timeout);
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
- const unsubscribe = () => {
4230
- if (signals) {
4231
- timer && clearTimeout(timer);
4293
+ let timer = timeout && setTimeout(() => {
4232
4294
  timer = null;
4233
- signals.forEach(signal => {
4234
- signal &&
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
- signals.forEach((signal) => signal && signal.addEventListener && signal.addEventListener('abort', onabort));
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
- const {signal} = controller;
4311
+ const {signal} = controller;
4244
4312
 
4245
- signal.unsubscribe = unsubscribe;
4313
+ signal.unsubscribe = () => utils$1.asap(unsubscribe);
4246
4314
 
4247
- return [signal, () => {
4248
- timer && clearTimeout(timer);
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, encode) {
4274
- for await (const chunk of iterable) {
4275
- yield* streamChunk(ArrayBuffer.isView(chunk) ? chunk : (await encode(String(chunk))), chunkSize);
4339
+ const readBytes = async function* (iterable, chunkSize) {
4340
+ for await (const chunk of readStream(iterable)) {
4341
+ yield* streamChunk(chunk, chunkSize);
4342
+ }
4343
+ };
4344
+
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();
4276
4362
  }
4277
4363
  };
4278
4364
 
4279
- const trackStream = (stream, chunkSize, onProgress, onFinish, encode) => {
4280
- const iterator = readBytes(stream, chunkSize, encode);
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
- const {done, value} = await iterator.next();
4379
+ try {
4380
+ const {done, value} = await iterator.next();
4289
4381
 
4290
- if (done) {
4291
- controller.close();
4292
- onFinish();
4293
- return;
4294
- }
4382
+ if (done) {
4383
+ _onFinish();
4384
+ controller.close();
4385
+ return;
4386
+ }
4295
4387
 
4296
- let len = value.byteLength;
4297
- onProgress && onProgress(bytes += len);
4298
- controller.enqueue(new Uint8Array(value));
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
- onFinish(reason);
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 supportsRequestStream = isReadableStreamSupported && (() => {
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
- try {
4346
- return utils$1.isReadableStream(new Response('').body);
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
- return (await new Request(body).arrayBuffer()).byteLength;
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 [composedSignal, stopTimeout] = (signal || cancelToken || timeout) ?
4416
- composeSignals$1([signal, cancelToken], timeout) : [];
4513
+ let composedSignal = composeSignals$1([signal, cancelToken && cancelToken.toAbortSignal()], timeout);
4417
4514
 
4418
- let finished, request;
4515
+ let request;
4419
4516
 
4420
- const onFinish = () => {
4421
- !finished && setTimeout(() => {
4422
- composedSignal && composedSignal.unsubscribe();
4423
- });
4424
-
4425
- finished = true;
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
- data = trackStream(_request.body, DEFAULT_CHUNK_SIZE, fetchProgressDecorator(
4541
+ const [onProgress, flush] = progressEventDecorator(
4449
4542
  requestContentLength,
4450
- progressEventReducer(onUploadProgress)
4451
- ), null, encodeText);
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 ? 'cors' : 'omit';
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, onDownloadProgress && fetchProgressDecorator(
4484
- responseContentLength,
4485
- progressEventReducer(onDownloadProgress, true)
4486
- ), isStreamResponse && onFinish, encodeText),
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 && onFinish();
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
- onFinish();
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.2";
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`.
@@ -5930,13 +6045,14 @@ function rdbClient(options = {}) {
5930
6045
  if (!db.createTransaction)
5931
6046
  throw new Error('Transaction not supported through http');
5932
6047
  const transaction = db.createTransaction(_options);
6048
+
5933
6049
  try {
5934
6050
  const nextClient = client({ transaction });
5935
6051
  await fn(nextClient);
5936
- await transaction(db.commit);
6052
+ await transaction(transaction.commit);
5937
6053
  }
5938
6054
  catch (e) {
5939
- await transaction(db.rollback.bind(null, e));
6055
+ await transaction(transaction.rollback.bind(null, e));
5940
6056
  }
5941
6057
  }
5942
6058
 
@@ -1,9 +1,7 @@
1
- let useHook = require('./useHook');
2
- let cls;
3
- var Domain = require('domain');
1
+ var Domain = require('node:domain');
4
2
  var negotiateForwardProperty = require('./createDomain/negotiateForwardProperty');
5
3
 
6
- function createDomain() {
4
+ function createNodeDomain() {
7
5
  var oldDomain = Domain.active || {};
8
6
  var domain = Domain.create();
9
7
  var ownProperties = Object.getOwnPropertyNames(oldDomain);
@@ -13,19 +11,16 @@ function createDomain() {
13
11
  return domain;
14
12
  }
15
13
 
16
- function createOnContext() {
17
- if (!cls)
18
- cls = require('node-cls');
19
- return cls.create('rdb');
20
- }
21
-
22
-
23
- function _createDomain() {
24
- if (useHook())
25
- return createOnContext();
26
- else
27
- return createDomain();
28
14
 
15
+ function _createDomain(useNodeDomain) {
16
+ if (useNodeDomain)
17
+ return createNodeDomain();
18
+ let c = {};
19
+ function run(fn) {
20
+ return fn(c);
21
+ }
22
+ c.run = run;
23
+ return c;
29
24
  }
30
25
 
31
26
  module.exports = _createDomain;