metal-orm 1.0.104 → 1.0.105

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs CHANGED
@@ -5261,7 +5261,8 @@ var hideInternal = (obj, keys) => {
5261
5261
  Object.defineProperty(obj, key, {
5262
5262
  value: obj[key],
5263
5263
  writable: false,
5264
- configurable: false,
5264
+ configurable: true,
5265
+ // Must be configurable for Proxy get trap to work properly
5265
5266
  enumerable: false
5266
5267
  });
5267
5268
  }
@@ -5424,7 +5425,8 @@ var hideInternal2 = (obj, keys) => {
5424
5425
  Object.defineProperty(obj, key, {
5425
5426
  value: obj[key],
5426
5427
  writable: false,
5427
- configurable: false,
5428
+ configurable: true,
5429
+ // Must be configurable for Proxy get trap to work properly
5428
5430
  enumerable: false
5429
5431
  });
5430
5432
  }
@@ -5555,7 +5557,8 @@ var hideInternal3 = (obj, keys) => {
5555
5557
  Object.defineProperty(obj, key, {
5556
5558
  value: obj[key],
5557
5559
  writable: false,
5558
- configurable: false,
5560
+ configurable: true,
5561
+ // Must be configurable for Proxy get trap to work properly
5559
5562
  enumerable: false
5560
5563
  });
5561
5564
  }
@@ -5660,7 +5663,8 @@ var hideInternal4 = (obj, keys) => {
5660
5663
  Object.defineProperty(obj, key, {
5661
5664
  value: obj[key],
5662
5665
  writable: false,
5663
- configurable: false,
5666
+ configurable: true,
5667
+ // Must be configurable for Proxy get trap to work properly
5664
5668
  enumerable: false
5665
5669
  });
5666
5670
  }
@@ -6178,6 +6182,23 @@ var relationLoaderCache = (meta, relationName, factory) => {
6178
6182
  var proxifyRelationWrapper = (wrapper) => {
6179
6183
  return new Proxy(wrapper, {
6180
6184
  get(target, prop, _receiver) {
6185
+ if (prop === "toJSON") {
6186
+ return () => {
6187
+ const wrapperToJSON = target.toJSON;
6188
+ if (typeof wrapperToJSON === "function") {
6189
+ return wrapperToJSON.call(target);
6190
+ }
6191
+ const getRef2 = target.get;
6192
+ if (typeof getRef2 === "function") {
6193
+ return getRef2.call(target);
6194
+ }
6195
+ const getItems2 = target.getItems;
6196
+ if (typeof getItems2 === "function") {
6197
+ return getItems2.call(target);
6198
+ }
6199
+ return target;
6200
+ };
6201
+ }
6181
6202
  if (typeof prop === "symbol") {
6182
6203
  const value = Reflect.get(target, prop, target);
6183
6204
  return typeof value === "function" ? value.bind(target) : value;
@@ -6352,7 +6373,8 @@ var createEntityProxy = (ctx, table, row, lazyRelations = [], lazyRelationOption
6352
6373
  const buildJson = (self) => {
6353
6374
  const json = {};
6354
6375
  for (const key of Object.keys(target)) {
6355
- json[key] = self[key];
6376
+ const value = self[key];
6377
+ json[key] = unwrapRelationForJson(value);
6356
6378
  }
6357
6379
  for (const [relationName, wrapper] of meta.relationWrappers) {
6358
6380
  if (Object.prototype.hasOwnProperty.call(json, relationName)) continue;