orange-orm 4.2.0-beta.1 → 4.2.0-beta.3

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "orange-orm",
3
- "version": "4.2.0-beta.1",
3
+ "version": "4.2.0-beta.3",
4
4
  "main": "./src/index.js",
5
5
  "browser": "./src/client/index.mjs",
6
6
  "bin": {
@@ -229,7 +229,7 @@ function rdbClient(options = {}) {
229
229
  let args = [_, strategy].concat(Array.prototype.slice.call(arguments).slice(2));
230
230
  let rows = await getManyCore.apply(null, args);
231
231
  await metaPromise;
232
- return proxify(rows, strategy);
232
+ return proxify(rows, strategy, {fast: true});
233
233
  }
234
234
 
235
235
  async function groupBy(strategy) {
@@ -261,7 +261,7 @@ function rdbClient(options = {}) {
261
261
  await metaPromise;
262
262
  if (rows.length === 0)
263
263
  return;
264
- return proxify(rows[0], strategy);
264
+ return proxify(rows[0], strategy, {fast: true});
265
265
  }
266
266
 
267
267
  async function getById() {
@@ -449,14 +449,14 @@ function rdbClient(options = {}) {
449
449
  }
450
450
 
451
451
 
452
- function proxify(itemOrArray, strategy) {
452
+ function proxify(itemOrArray, strategy, options) {
453
453
  if (Array.isArray(itemOrArray))
454
- return proxifyArray(itemOrArray, strategy);
454
+ return proxifyArray(itemOrArray, strategy, options);
455
455
  else
456
- return proxifyRow(itemOrArray, strategy);
456
+ return proxifyRow(itemOrArray, strategy, options);
457
457
  }
458
458
 
459
- function proxifyArray(array, strategy) {
459
+ function proxifyArray(array, strategy, { fast } = { }) {
460
460
  let _array = array;
461
461
  if (_reactive)
462
462
  array = _reactive(array);
@@ -485,7 +485,7 @@ function rdbClient(options = {}) {
485
485
  };
486
486
  let innerProxy = new Proxy(array, handler);
487
487
  //todo
488
- rootMap.set(array, { json: cloneFromDb(array), strategy, originalArray: [...array] });
488
+ rootMap.set(array, { json: fast ? structuredClone(array) : cloneFromDb(array), strategy, originalArray: [...array] });
489
489
  if (strategy !== undefined) {
490
490
  const { limit, ...cleanStrategy } = { ...strategy };
491
491
  fetchingStrategyMap.set(array, cleanStrategy);
@@ -493,7 +493,7 @@ function rdbClient(options = {}) {
493
493
  return innerProxy;
494
494
  }
495
495
 
496
- function proxifyRow(row, strategy) {
496
+ function proxifyRow(row, strategy, { fast } = {}) {
497
497
  let handler = {
498
498
  get(_target, property,) {
499
499
  if (property === 'save' || property === 'saveChanges') //call server then acceptChanges
@@ -518,7 +518,7 @@ function rdbClient(options = {}) {
518
518
 
519
519
  };
520
520
  let innerProxy = new Proxy(row, handler);
521
- rootMap.set(row, { json: cloneFromDb(row), strategy });
521
+ rootMap.set(row, { json: fast ? structuredClone(row) : cloneFromDb(row), strategy });
522
522
  fetchingStrategyMap.set(row, strategy);
523
523
  return innerProxy;
524
524
  }
@@ -3607,7 +3607,7 @@ function isAbsoluteURL(url) {
3607
3607
  */
3608
3608
  function combineURLs(baseURL, relativeURL) {
3609
3609
  return relativeURL
3610
- ? baseURL.replace(/\/+$/, '') + '/' + relativeURL.replace(/^\/+/, '')
3610
+ ? baseURL.replace(/\/?\/$/, '') + '/' + relativeURL.replace(/^\/+/, '')
3611
3611
  : baseURL;
3612
3612
  }
3613
3613
 
@@ -4241,7 +4241,7 @@ function mergeConfig(config1, config2) {
4241
4241
  return config;
4242
4242
  }
4243
4243
 
4244
- const VERSION = "1.6.2";
4244
+ const VERSION = "1.6.3";
4245
4245
 
4246
4246
  const validators$1 = {};
4247
4247
 
@@ -4857,7 +4857,7 @@ function httpAdapter(baseURL, path, axiosInterceptor) {
4857
4857
  const res = await axios.request(path, { headers, method: 'patch', data: body });
4858
4858
  return res.data;
4859
4859
  }
4860
- catch (e) {
4860
+ catch (e) {
4861
4861
  if (typeof e.response?.data === 'string')
4862
4862
  throw new Error(e.response.data.replace(/^Error: /, ''));
4863
4863
  else
@@ -5524,7 +5524,7 @@ function rdbClient(options = {}) {
5524
5524
  let args = [_, strategy].concat(Array.prototype.slice.call(arguments).slice(2));
5525
5525
  let rows = await getManyCore.apply(null, args);
5526
5526
  await metaPromise;
5527
- return proxify(rows, strategy);
5527
+ return proxify(rows, strategy, {fastStringify : true});
5528
5528
  }
5529
5529
 
5530
5530
  async function groupBy(strategy) {
@@ -5556,7 +5556,7 @@ function rdbClient(options = {}) {
5556
5556
  await metaPromise;
5557
5557
  if (rows.length === 0)
5558
5558
  return;
5559
- return proxify(rows[0], strategy);
5559
+ return proxify(rows[0], strategy, {fastStringify : true});
5560
5560
  }
5561
5561
 
5562
5562
  async function getById() {
@@ -5744,14 +5744,14 @@ function rdbClient(options = {}) {
5744
5744
  }
5745
5745
 
5746
5746
 
5747
- function proxify(itemOrArray, strategy) {
5747
+ function proxify(itemOrArray, strategy, options) {
5748
5748
  if (Array.isArray(itemOrArray))
5749
- return proxifyArray(itemOrArray, strategy);
5749
+ return proxifyArray(itemOrArray, strategy, options);
5750
5750
  else
5751
- return proxifyRow(itemOrArray, strategy);
5751
+ return proxifyRow(itemOrArray, strategy, options);
5752
5752
  }
5753
5753
 
5754
- function proxifyArray(array, strategy) {
5754
+ function proxifyArray(array, strategy, { fastStringify } = {}) {
5755
5755
  let _array = array;
5756
5756
  if (_reactive)
5757
5757
  array = _reactive(array);
@@ -5779,7 +5779,7 @@ function rdbClient(options = {}) {
5779
5779
 
5780
5780
  };
5781
5781
  let innerProxy = new Proxy(array, handler);
5782
- rootMap.set(array, { json: stringify(array), strategy, originalArray: [...array] });
5782
+ rootMap.set(array, { json: fastStringify ? JSON.stringify(array) : stringify(array), strategy, originalArray: [...array] });
5783
5783
  if (strategy !== undefined) {
5784
5784
  const { limit, ...cleanStrategy } = { ...strategy };
5785
5785
  fetchingStrategyMap.set(array, cleanStrategy);
@@ -5787,7 +5787,7 @@ function rdbClient(options = {}) {
5787
5787
  return innerProxy;
5788
5788
  }
5789
5789
 
5790
- function proxifyRow(row, strategy) {
5790
+ function proxifyRow(row, strategy, { fastStringify } = {}) {
5791
5791
  let handler = {
5792
5792
  get(_target, property,) {
5793
5793
  if (property === 'save' || property === 'saveChanges') //call server then acceptChanges
@@ -5812,7 +5812,7 @@ function rdbClient(options = {}) {
5812
5812
 
5813
5813
  };
5814
5814
  let innerProxy = new Proxy(row, handler);
5815
- rootMap.set(row, { json: stringify(row), strategy });
5815
+ rootMap.set(row, { json: fastStringify ? JSON.stringify(row) : stringify(row), strategy });
5816
5816
  fetchingStrategyMap.set(row, strategy);
5817
5817
  return innerProxy;
5818
5818
  }
package/src/getManyDto.js CHANGED
@@ -140,9 +140,8 @@ async function decode(strategy, span, rows, keys = rows.length > 0 ? Object.keys
140
140
  span._rowsMap = rowsMap;
141
141
  span._ids = fkIds;
142
142
 
143
- for (let i = 0; i < columnsLength + aggregateKeys.length; i++) {
144
- keys.shift();
145
- }
143
+ keys.splice(0, columnsLength + aggregateKeys.length);
144
+
146
145
  await decodeRelations(strategy, span, rows, outRows, keys);
147
146
  return outRows;
148
147