@warp-drive/legacy 5.9.0-alpha.16 → 5.9.0-alpha.18

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 (37) hide show
  1. package/dist/{hooks-D6diaM34.js → hooks-CoxuoIfB.js} +1 -1
  2. package/dist/index.js +3 -3
  3. package/dist/model/migration-support.js +1 -1
  4. package/dist/{unpkg/dev-deprecated/model-for-CqXsIKws.js → model-for-DOiIKvY_.js} +7 -1
  5. package/dist/model-fragments.js +2 -2
  6. package/dist/model.js +2 -2
  7. package/dist/{schema-provider-DJCV_6AF.js → schema-provider-qgBVdfoF.js} +5 -1
  8. package/dist/unpkg/dev/{hooks-CkYiE6Ud.js → hooks-BAeKqW7Q.js} +1 -1
  9. package/dist/unpkg/dev/index.js +3 -3
  10. package/dist/unpkg/dev/model/migration-support.js +1 -1
  11. package/dist/unpkg/dev/{model-for-CqXsIKws.js → model-for-DOiIKvY_.js} +7 -1
  12. package/dist/unpkg/dev/model-fragments.js +2 -2
  13. package/dist/unpkg/dev/model.js +2 -2
  14. package/dist/unpkg/dev/{schema-provider-DDVYxmUV.js → schema-provider-CBgMOLPn.js} +5 -1
  15. package/dist/unpkg/dev-deprecated/{hooks-DOXegvhL.js → hooks-CX2QnOWh.js} +1 -1
  16. package/dist/unpkg/dev-deprecated/index.js +3 -3
  17. package/dist/unpkg/dev-deprecated/model/migration-support.js +1 -1
  18. package/dist/{model-for-CqXsIKws.js → unpkg/dev-deprecated/model-for-DOiIKvY_.js} +7 -1
  19. package/dist/unpkg/dev-deprecated/model-fragments.js +2 -2
  20. package/dist/unpkg/dev-deprecated/model.js +2 -2
  21. package/dist/unpkg/dev-deprecated/{schema-provider-BP6_8N-V.js → schema-provider-Cby8K0AB.js} +5 -1
  22. package/dist/unpkg/prod/{hooks-BztVA_x0.js → hooks-BenXLbeb.js} +1 -1
  23. package/dist/unpkg/prod/index.js +3 -3
  24. package/dist/unpkg/prod/model/migration-support.js +1 -1
  25. package/dist/unpkg/prod/model-for-DOiIKvY_.js +227 -0
  26. package/dist/unpkg/prod/model-fragments.js +2 -2
  27. package/dist/unpkg/prod/model.js +2 -2
  28. package/dist/unpkg/prod/{schema-provider-DJtD_8jZ.js → schema-provider-DHGEb_sz.js} +5 -1
  29. package/dist/unpkg/prod-deprecated/{hooks-yId87yyG.js → hooks-Ds1PZsBo.js} +1 -1
  30. package/dist/unpkg/prod-deprecated/index.js +3 -3
  31. package/dist/unpkg/prod-deprecated/model/migration-support.js +1 -1
  32. package/dist/unpkg/prod-deprecated/{model-for-CqXsIKws.js → model-for-DOiIKvY_.js} +7 -1
  33. package/dist/unpkg/prod-deprecated/model-fragments.js +2 -2
  34. package/dist/unpkg/prod-deprecated/model.js +2 -2
  35. package/dist/unpkg/prod-deprecated/{schema-provider-CjX55uSY.js → schema-provider-D6EzGZB-.js} +5 -1
  36. package/package.json +6 -6
  37. package/dist/unpkg/prod/model-for-CqXsIKws.js +0 -221
@@ -1,6 +1,6 @@
1
1
  import { setOwner, getOwner } from '@ember/application';
2
2
  import { assertPrivateStore, setRecordIdentifier, StoreMap } from '@warp-drive/core/store/-private';
3
- import { g as getModelFactory } from "./schema-provider-DJCV_6AF.js";
3
+ import { g as getModelFactory } from "./schema-provider-qgBVdfoF.js";
4
4
  import { n as normalizeModelName } from "./util-Dul6TZts.js";
5
5
  import { macroCondition, getGlobalConfig } from '@embroider/macros';
6
6
  function instantiateRecord(identifier, createRecordArgs) {
package/dist/index.js CHANGED
@@ -10,10 +10,10 @@ import '@warp-drive/utilities/string';
10
10
  import { macroCondition, getGlobalConfig } from '@embroider/macros';
11
11
  import '@warp-drive/core/store/-private';
12
12
  import "./errors-Cz5KrzBk.js";
13
- import "./schema-provider-DJCV_6AF.js";
14
- import { i as instantiateRecord, t as teardownRecord, m as modelFor } from "./hooks-D6diaM34.js";
13
+ import "./schema-provider-qgBVdfoF.js";
14
+ import { i as instantiateRecord, t as teardownRecord, m as modelFor } from "./hooks-CoxuoIfB.js";
15
15
  import { registerDerivations as registerDerivations$1, DelegatingSchemaService } from './model/migration-support.js';
16
- import { F as FragmentExtension, a as FragmentArrayExtension, f as fragmentsModelFor } from "./model-for-CqXsIKws.js";
16
+ import { F as FragmentExtension, a as FragmentArrayExtension, f as fragmentsModelFor } from "./model-for-DOiIKvY_.js";
17
17
  import { restoreDeprecatedStoreBehaviors } from './store.js';
18
18
 
19
19
  /**
@@ -6,7 +6,7 @@ import { assertPrivateStore } from '@warp-drive/core/store/-private';
6
6
  import { getOrSetGlobal } from '@warp-drive/core/types/-private';
7
7
  import { Type } from '@warp-drive/core/types/symbols';
8
8
  import { l as lookupLegacySupport, E as Errors } from "../errors-Cz5KrzBk.js";
9
- import { b as buildSchema, u as unloadRecord, s as serialize, _ as _save, a as save, r as rollbackAttributes, c as _reload, d as reload, h as hasMany, e as _destroyRecord, f as destroyRecord, i as deleteRecord, R as RecordState, j as changedAttributes, k as belongsTo, l as createSnapshot } from "../schema-provider-DJCV_6AF.js";
9
+ import { b as buildSchema, u as unloadRecord, s as serialize, _ as _save, a as save, r as rollbackAttributes, c as _reload, d as reload, h as hasMany, e as _destroyRecord, f as destroyRecord, i as deleteRecord, R as RecordState, j as changedAttributes, k as belongsTo, l as createSnapshot } from "../schema-provider-qgBVdfoF.js";
10
10
  import { macroCondition, getGlobalConfig } from '@embroider/macros';
11
11
 
12
12
  /**
@@ -70,13 +70,19 @@ class FragmentArray {
70
70
  }
71
71
  #isDestroyed = (initializeDeferredDecorator(this, "isDestroyed"), void 0);
72
72
  get hasDirtyAttributes() {
73
+ const array = this;
74
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
75
+ const context = array[Context];
76
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
73
77
  const {
74
78
  path,
75
79
  resourceKey,
76
80
  store
77
- } = this[Context];
81
+ } = context;
82
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-call, @typescript-eslint/no-unsafe-member-access
78
83
  const record = store.peekRecord(resourceKey);
79
84
  if (record.hasDirtyAttributes && path) {
85
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-call, @typescript-eslint/no-unsafe-member-access
80
86
  const root = path.at(0);
81
87
  return root in record.changedAttributes();
82
88
  }
@@ -1,7 +1,7 @@
1
1
  import { pluralize, singularize } from '@warp-drive/utilities/string';
2
2
  import { withDefaults } from './model/migration-support.js';
3
- import { F as FragmentExtension, a as FragmentArrayExtension } from "./model-for-CqXsIKws.js";
4
- export { c as Fragment, b as FragmentArray, m as modelFor } from "./model-for-CqXsIKws.js";
3
+ import { F as FragmentExtension, a as FragmentArrayExtension } from "./model-for-DOiIKvY_.js";
4
+ export { c as Fragment, b as FragmentArray, m as modelFor } from "./model-for-DOiIKvY_.js";
5
5
 
6
6
  /**
7
7
  * Used as a helper to setup the relevant parts of an array
package/dist/model.js CHANGED
@@ -7,8 +7,8 @@ import { warn, deprecate } from '@ember/debug';
7
7
  import { assertPrivateStore } from '@warp-drive/core/store/-private';
8
8
  import { l as lookupLegacySupport } from "./errors-Cz5KrzBk.js";
9
9
  import { singularize, dasherize } from '@warp-drive/utilities/string';
10
- export { M as Model, b as buildSchema, M as default, m as restoreDeprecatedModelRequestBehaviors } from "./schema-provider-DJCV_6AF.js";
11
- export { i as instantiateRecord, m as modelFor, t as teardownRecord } from "./hooks-D6diaM34.js";
10
+ export { M as Model, b as buildSchema, M as default, m as restoreDeprecatedModelRequestBehaviors } from "./schema-provider-qgBVdfoF.js";
11
+ export { i as instantiateRecord, m as modelFor, t as teardownRecord } from "./hooks-CoxuoIfB.js";
12
12
  function _attr(type, options) {
13
13
  if (typeof type === 'object') {
14
14
  options = type;
@@ -2147,7 +2147,11 @@ class ModelSchemaProvider {
2147
2147
  }
2148
2148
  /** @internal */
2149
2149
  _loadModelSchema(type) {
2150
- const modelClass = this.store.modelFor(type);
2150
+ const factory = getModelFactory(this.store, type);
2151
+ if (!factory) {
2152
+ throw new Error(`No model was found for '${type}'`);
2153
+ }
2154
+ const modelClass = factory.class;
2151
2155
  const attributeMap = modelClass.attributes;
2152
2156
  const attributes = Object.create(null);
2153
2157
  attributeMap.forEach((meta, name) => attributes[name] = meta);
@@ -1,6 +1,6 @@
1
1
  import { setOwner, getOwner } from '@ember/application';
2
2
  import { assertPrivateStore, setRecordIdentifier, StoreMap } from '@warp-drive/core/store/-private';
3
- import { g as getModelFactory } from "./schema-provider-DDVYxmUV.js";
3
+ import { g as getModelFactory } from "./schema-provider-CBgMOLPn.js";
4
4
  import { n as normalizeModelName } from "./util-DvanW33H.js";
5
5
  function instantiateRecord(identifier, createRecordArgs) {
6
6
  const type = identifier.type;
@@ -8,11 +8,11 @@ import '@warp-drive/core/types/symbols';
8
8
  import '@warp-drive/utilities/string';
9
9
  import '@warp-drive/core/store/-private';
10
10
  import "./errors-DmGGJr3T.js";
11
- import "./schema-provider-DDVYxmUV.js";
12
- import { i as instantiateRecord, t as teardownRecord, m as modelFor } from "./hooks-CkYiE6Ud.js";
11
+ import "./schema-provider-CBgMOLPn.js";
12
+ import { i as instantiateRecord, t as teardownRecord, m as modelFor } from "./hooks-BAeKqW7Q.js";
13
13
  import '@ember/application';
14
14
  import { registerDerivations as registerDerivations$1, DelegatingSchemaService } from './model/migration-support.js';
15
- import { F as FragmentExtension, a as FragmentArrayExtension, f as fragmentsModelFor } from "./model-for-CqXsIKws.js";
15
+ import { F as FragmentExtension, a as FragmentArrayExtension, f as fragmentsModelFor } from "./model-for-DOiIKvY_.js";
16
16
  import { restoreDeprecatedStoreBehaviors } from './store.js';
17
17
 
18
18
  /**
@@ -5,7 +5,7 @@ import { assertPrivateStore } from '@warp-drive/core/store/-private';
5
5
  import { getOrSetGlobal } from '@warp-drive/core/types/-private';
6
6
  import { Type } from '@warp-drive/core/types/symbols';
7
7
  import { l as lookupLegacySupport, E as Errors } from "../errors-DmGGJr3T.js";
8
- import { b as buildSchema, u as unloadRecord, s as serialize, _ as _save, a as save, r as rollbackAttributes, c as _reload, d as reload, h as hasMany, e as _destroyRecord, f as destroyRecord, i as deleteRecord, R as RecordState, j as changedAttributes, k as belongsTo, l as createSnapshot } from "../schema-provider-DDVYxmUV.js";
8
+ import { b as buildSchema, u as unloadRecord, s as serialize, _ as _save, a as save, r as rollbackAttributes, c as _reload, d as reload, h as hasMany, e as _destroyRecord, f as destroyRecord, i as deleteRecord, R as RecordState, j as changedAttributes, k as belongsTo, l as createSnapshot } from "../schema-provider-CBgMOLPn.js";
9
9
 
10
10
  /**
11
11
  * This module provides support for migrating away from @warp-drive/legacy/model
@@ -70,13 +70,19 @@ class FragmentArray {
70
70
  }
71
71
  #isDestroyed = (initializeDeferredDecorator(this, "isDestroyed"), void 0);
72
72
  get hasDirtyAttributes() {
73
+ const array = this;
74
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
75
+ const context = array[Context];
76
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
73
77
  const {
74
78
  path,
75
79
  resourceKey,
76
80
  store
77
- } = this[Context];
81
+ } = context;
82
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-call, @typescript-eslint/no-unsafe-member-access
78
83
  const record = store.peekRecord(resourceKey);
79
84
  if (record.hasDirtyAttributes && path) {
85
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-call, @typescript-eslint/no-unsafe-member-access
80
86
  const root = path.at(0);
81
87
  return root in record.changedAttributes();
82
88
  }
@@ -1,7 +1,7 @@
1
1
  import { pluralize, singularize } from '@warp-drive/utilities/string';
2
2
  import { withDefaults } from './model/migration-support.js';
3
- import { F as FragmentExtension, a as FragmentArrayExtension } from "./model-for-CqXsIKws.js";
4
- export { c as Fragment, b as FragmentArray, m as modelFor } from "./model-for-CqXsIKws.js";
3
+ import { F as FragmentExtension, a as FragmentArrayExtension } from "./model-for-DOiIKvY_.js";
4
+ export { c as Fragment, b as FragmentArray, m as modelFor } from "./model-for-DOiIKvY_.js";
5
5
 
6
6
  /**
7
7
  * Used as a helper to setup the relevant parts of an array
@@ -5,8 +5,8 @@ import { i as isElementDescriptor, n as normalizeModelName } from "./util-DvanW3
5
5
  import { assertPrivateStore } from '@warp-drive/core/store/-private';
6
6
  import { l as lookupLegacySupport } from "./errors-DmGGJr3T.js";
7
7
  import '@warp-drive/utilities/string';
8
- export { M as Model, b as buildSchema, M as default, m as restoreDeprecatedModelRequestBehaviors } from "./schema-provider-DDVYxmUV.js";
9
- export { i as instantiateRecord, m as modelFor, t as teardownRecord } from "./hooks-CkYiE6Ud.js";
8
+ export { M as Model, b as buildSchema, M as default, m as restoreDeprecatedModelRequestBehaviors } from "./schema-provider-CBgMOLPn.js";
9
+ export { i as instantiateRecord, m as modelFor, t as teardownRecord } from "./hooks-BAeKqW7Q.js";
10
10
 
11
11
  /**
12
12
  * Options provided to the attr decorator are
@@ -2096,7 +2096,11 @@ class ModelSchemaProvider {
2096
2096
  }
2097
2097
  /** @internal */
2098
2098
  _loadModelSchema(type) {
2099
- const modelClass = this.store.modelFor(type);
2099
+ const factory = getModelFactory(this.store, type);
2100
+ if (!factory) {
2101
+ throw new Error(`No model was found for '${type}'`);
2102
+ }
2103
+ const modelClass = factory.class;
2100
2104
  const attributeMap = modelClass.attributes;
2101
2105
  const attributes = Object.create(null);
2102
2106
  attributeMap.forEach((meta, name) => attributes[name] = meta);
@@ -1,6 +1,6 @@
1
1
  import { setOwner, getOwner } from '@ember/application';
2
2
  import { assertPrivateStore, setRecordIdentifier, StoreMap } from '@warp-drive/core/store/-private';
3
- import { g as getModelFactory } from "./schema-provider-BP6_8N-V.js";
3
+ import { g as getModelFactory } from "./schema-provider-Cby8K0AB.js";
4
4
  import { n as normalizeModelName } from "./util-CWr5WQOT.js";
5
5
  function instantiateRecord(identifier, createRecordArgs) {
6
6
  const type = identifier.type;
@@ -8,10 +8,10 @@ import '@warp-drive/core/types/symbols';
8
8
  import '@warp-drive/utilities/string';
9
9
  import '@warp-drive/core/store/-private';
10
10
  import "./errors-Spt6ubMd.js";
11
- import "./schema-provider-BP6_8N-V.js";
12
- import { i as instantiateRecord, t as teardownRecord, m as modelFor } from "./hooks-DOXegvhL.js";
11
+ import "./schema-provider-Cby8K0AB.js";
12
+ import { i as instantiateRecord, t as teardownRecord, m as modelFor } from "./hooks-CX2QnOWh.js";
13
13
  import { registerDerivations as registerDerivations$1, DelegatingSchemaService } from './model/migration-support.js';
14
- import { F as FragmentExtension, a as FragmentArrayExtension, f as fragmentsModelFor } from "./model-for-CqXsIKws.js";
14
+ import { F as FragmentExtension, a as FragmentArrayExtension, f as fragmentsModelFor } from "./model-for-DOiIKvY_.js";
15
15
  import { restoreDeprecatedStoreBehaviors } from './store.js';
16
16
 
17
17
  /**
@@ -5,7 +5,7 @@ import { assertPrivateStore } from '@warp-drive/core/store/-private';
5
5
  import { getOrSetGlobal } from '@warp-drive/core/types/-private';
6
6
  import { Type } from '@warp-drive/core/types/symbols';
7
7
  import { l as lookupLegacySupport, E as Errors } from "../errors-Spt6ubMd.js";
8
- import { b as buildSchema, u as unloadRecord, s as serialize, _ as _save, a as save, r as rollbackAttributes, c as _reload, d as reload, h as hasMany, e as _destroyRecord, f as destroyRecord, i as deleteRecord, R as RecordState, j as changedAttributes, k as belongsTo, l as createSnapshot } from "../schema-provider-BP6_8N-V.js";
8
+ import { b as buildSchema, u as unloadRecord, s as serialize, _ as _save, a as save, r as rollbackAttributes, c as _reload, d as reload, h as hasMany, e as _destroyRecord, f as destroyRecord, i as deleteRecord, R as RecordState, j as changedAttributes, k as belongsTo, l as createSnapshot } from "../schema-provider-Cby8K0AB.js";
9
9
 
10
10
  /**
11
11
  * This module provides support for migrating away from @warp-drive/legacy/model
@@ -70,13 +70,19 @@ class FragmentArray {
70
70
  }
71
71
  #isDestroyed = (initializeDeferredDecorator(this, "isDestroyed"), void 0);
72
72
  get hasDirtyAttributes() {
73
+ const array = this;
74
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
75
+ const context = array[Context];
76
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
73
77
  const {
74
78
  path,
75
79
  resourceKey,
76
80
  store
77
- } = this[Context];
81
+ } = context;
82
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-call, @typescript-eslint/no-unsafe-member-access
78
83
  const record = store.peekRecord(resourceKey);
79
84
  if (record.hasDirtyAttributes && path) {
85
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-call, @typescript-eslint/no-unsafe-member-access
80
86
  const root = path.at(0);
81
87
  return root in record.changedAttributes();
82
88
  }
@@ -1,7 +1,7 @@
1
1
  import { pluralize, singularize } from '@warp-drive/utilities/string';
2
2
  import { withDefaults } from './model/migration-support.js';
3
- import { F as FragmentExtension, a as FragmentArrayExtension } from "./model-for-CqXsIKws.js";
4
- export { c as Fragment, b as FragmentArray, m as modelFor } from "./model-for-CqXsIKws.js";
3
+ import { F as FragmentExtension, a as FragmentArrayExtension } from "./model-for-DOiIKvY_.js";
4
+ export { c as Fragment, b as FragmentArray, m as modelFor } from "./model-for-DOiIKvY_.js";
5
5
 
6
6
  /**
7
7
  * Used as a helper to setup the relevant parts of an array
@@ -5,8 +5,8 @@ import { i as isElementDescriptor, n as normalizeModelName } from "./util-CWr5WQ
5
5
  import { assertPrivateStore } from '@warp-drive/core/store/-private';
6
6
  import { l as lookupLegacySupport } from "./errors-Spt6ubMd.js";
7
7
  import { singularize, dasherize } from '@warp-drive/utilities/string';
8
- export { M as Model, b as buildSchema, M as default, m as restoreDeprecatedModelRequestBehaviors } from "./schema-provider-BP6_8N-V.js";
9
- export { i as instantiateRecord, m as modelFor, t as teardownRecord } from "./hooks-DOXegvhL.js";
8
+ export { M as Model, b as buildSchema, M as default, m as restoreDeprecatedModelRequestBehaviors } from "./schema-provider-Cby8K0AB.js";
9
+ export { i as instantiateRecord, m as modelFor, t as teardownRecord } from "./hooks-CX2QnOWh.js";
10
10
 
11
11
  /**
12
12
  * Options provided to the attr decorator are
@@ -2087,7 +2087,11 @@ class ModelSchemaProvider {
2087
2087
  }
2088
2088
  /** @internal */
2089
2089
  _loadModelSchema(type) {
2090
- const modelClass = this.store.modelFor(type);
2090
+ const factory = getModelFactory(this.store, type);
2091
+ if (!factory) {
2092
+ throw new Error(`No model was found for '${type}'`);
2093
+ }
2094
+ const modelClass = factory.class;
2091
2095
  const attributeMap = modelClass.attributes;
2092
2096
  const attributes = Object.create(null);
2093
2097
  attributeMap.forEach((meta, name) => attributes[name] = meta);
@@ -1,6 +1,6 @@
1
1
  import { setOwner, getOwner } from '@ember/application';
2
2
  import { assertPrivateStore, setRecordIdentifier, StoreMap } from '@warp-drive/core/store/-private';
3
- import { g as getModelFactory } from "./schema-provider-DJtD_8jZ.js";
3
+ import { g as getModelFactory } from "./schema-provider-DHGEb_sz.js";
4
4
  import { n as normalizeModelName } from "./util-DvanW33H.js";
5
5
  function instantiateRecord(identifier, createRecordArgs) {
6
6
  const type = identifier.type;
@@ -8,11 +8,11 @@ import '@warp-drive/core/types/symbols';
8
8
  import '@warp-drive/utilities/string';
9
9
  import '@warp-drive/core/store/-private';
10
10
  import "./errors-BGVFCBmi.js";
11
- import "./schema-provider-DJtD_8jZ.js";
12
- import { i as instantiateRecord, t as teardownRecord, m as modelFor } from "./hooks-BztVA_x0.js";
11
+ import "./schema-provider-DHGEb_sz.js";
12
+ import { i as instantiateRecord, t as teardownRecord, m as modelFor } from "./hooks-BenXLbeb.js";
13
13
  import '@ember/application';
14
14
  import { registerDerivations as registerDerivations$1, DelegatingSchemaService } from './model/migration-support.js';
15
- import { F as FragmentExtension, a as FragmentArrayExtension, f as fragmentsModelFor } from "./model-for-CqXsIKws.js";
15
+ import { F as FragmentExtension, a as FragmentArrayExtension, f as fragmentsModelFor } from "./model-for-DOiIKvY_.js";
16
16
  import { restoreDeprecatedStoreBehaviors } from './store.js';
17
17
 
18
18
  /**
@@ -5,7 +5,7 @@ import { assertPrivateStore } from '@warp-drive/core/store/-private';
5
5
  import { getOrSetGlobal } from '@warp-drive/core/types/-private';
6
6
  import { Type } from '@warp-drive/core/types/symbols';
7
7
  import { l as lookupLegacySupport, E as Errors } from "../errors-BGVFCBmi.js";
8
- import { b as buildSchema, u as unloadRecord, s as serialize, _ as _save, a as save, r as rollbackAttributes, c as _reload, d as reload, h as hasMany, e as _destroyRecord, f as destroyRecord, i as deleteRecord, R as RecordState, j as changedAttributes, k as belongsTo, l as createSnapshot } from "../schema-provider-DJtD_8jZ.js";
8
+ import { b as buildSchema, u as unloadRecord, s as serialize, _ as _save, a as save, r as rollbackAttributes, c as _reload, d as reload, h as hasMany, e as _destroyRecord, f as destroyRecord, i as deleteRecord, R as RecordState, j as changedAttributes, k as belongsTo, l as createSnapshot } from "../schema-provider-DHGEb_sz.js";
9
9
 
10
10
  /**
11
11
  * This module provides support for migrating away from @warp-drive/legacy/model
@@ -0,0 +1,227 @@
1
+ import { tracked, cached } from '@glimmer/tracking';
2
+ import { Context } from '@warp-drive/core/reactive/-private';
3
+ import { a as decorateFieldV2, i as initializeDeferredDecorator, d as decorateMethodV2 } from "./runtime-BPCpkOf1-BKOwiRJp.js";
4
+ class Fragment {
5
+ static {
6
+ decorateFieldV2(this.prototype, "isDestroying", [tracked], function () {
7
+ return false;
8
+ });
9
+ }
10
+ #isDestroying = (initializeDeferredDecorator(this, "isDestroying"), void 0); // We might want to check the parent values once we move this code to warp-drive.
11
+ static {
12
+ decorateFieldV2(this.prototype, "isDestroyed", [tracked], function () {
13
+ return false;
14
+ });
15
+ }
16
+ #isDestroyed = (initializeDeferredDecorator(this, "isDestroyed"), void 0);
17
+ get hasDirtyAttributes() {
18
+ const {
19
+ path,
20
+ resourceKey,
21
+ store
22
+ } = this[Context];
23
+ const record = store.peekRecord(resourceKey);
24
+ if (record.hasDirtyAttributes && path) {
25
+ const root = path.at(0);
26
+ return root in record.changedAttributes();
27
+ }
28
+ return false;
29
+ }
30
+ static {
31
+ decorateMethodV2(this.prototype, "hasDirtyAttributes", [cached]);
32
+ }
33
+ get isFragment() {
34
+ return true;
35
+ }
36
+ get $type() {
37
+ const {
38
+ field
39
+ } = this[Context];
40
+ return field?.type;
41
+ }
42
+ rollbackAttributes() {
43
+ const {
44
+ path,
45
+ resourceKey,
46
+ store
47
+ } = this[Context];
48
+ if (path) {
49
+ const oldValue = store.cache.getRemoteAttr(resourceKey, path);
50
+ store.cache.setAttr(resourceKey, path, oldValue);
51
+ }
52
+ }
53
+ }
54
+ const FragmentExtension = {
55
+ kind: 'object',
56
+ name: 'fragment',
57
+ features: Fragment
58
+ };
59
+ class FragmentArray {
60
+ static {
61
+ decorateFieldV2(this.prototype, "isDestroying", [tracked], function () {
62
+ return false;
63
+ });
64
+ }
65
+ #isDestroying = (initializeDeferredDecorator(this, "isDestroying"), void 0); // We might want to check the parent values once we move this code to warp-drive.
66
+ static {
67
+ decorateFieldV2(this.prototype, "isDestroyed", [tracked], function () {
68
+ return false;
69
+ });
70
+ }
71
+ #isDestroyed = (initializeDeferredDecorator(this, "isDestroyed"), void 0);
72
+ get hasDirtyAttributes() {
73
+ const array = this;
74
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
75
+ const context = array[Context];
76
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
77
+ const {
78
+ path,
79
+ resourceKey,
80
+ store
81
+ } = context;
82
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-call, @typescript-eslint/no-unsafe-member-access
83
+ const record = store.peekRecord(resourceKey);
84
+ if (record.hasDirtyAttributes && path) {
85
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-call, @typescript-eslint/no-unsafe-member-access
86
+ const root = path.at(0);
87
+ return root in record.changedAttributes();
88
+ }
89
+ return false;
90
+ }
91
+ static {
92
+ decorateMethodV2(this.prototype, "hasDirtyAttributes", [cached]);
93
+ }
94
+ addFragment(fragment) {
95
+ if (!fragment) {
96
+ return;
97
+ }
98
+ return this.addObject(fragment);
99
+ }
100
+ createFragment(fragment) {
101
+ if (!fragment) {
102
+ return;
103
+ }
104
+ return this.pushObject(fragment);
105
+ }
106
+ removeFragment(fragment) {
107
+ if (!fragment) {
108
+ return;
109
+ }
110
+ const index = this.indexOf(fragment);
111
+ if (index !== -1) {
112
+ this.splice(index, 1);
113
+ }
114
+ }
115
+ rollbackAttributes() {
116
+ for (const fragment of this) {
117
+ // @ts-expect-error TODO: fix these types
118
+ fragment?.rollbackAttributes?.();
119
+ }
120
+ }
121
+ }
122
+ const FragmentArrayExtension = {
123
+ kind: 'array',
124
+ name: 'fragment-array',
125
+ features: FragmentArray
126
+ };
127
+
128
+ // if modelFor turns out to be a bottleneck we should replace with a Map
129
+ // and clear it during store teardown.
130
+ const AvailableShims = new WeakMap();
131
+ function getShimClass(store, modelName) {
132
+ let shims = AvailableShims.get(store);
133
+ if (!shims) {
134
+ shims = Object.create(null);
135
+ AvailableShims.set(store, shims);
136
+ }
137
+ let shim = shims[modelName];
138
+ if (shim === undefined) {
139
+ shim = shims[modelName] = new ShimModelClass(store, modelName);
140
+ }
141
+ return shim;
142
+ }
143
+ const AttributeKinds = ['field', 'attribute', 'object', 'array', 'schema-object', 'schema-array'];
144
+
145
+ // Mimics the static apis of @warp-drive/legacy/model
146
+ class ShimModelClass {
147
+ constructor(store, modelName) {
148
+ this.__store = store;
149
+ this.modelName = modelName;
150
+ }
151
+ get fields() {
152
+ const fields = new Map();
153
+ const fieldSchemas = this.__store.schema.fields({
154
+ type: this.modelName
155
+ });
156
+ fieldSchemas.forEach((schema, key) => {
157
+ // @ts-expect-error checking if a string is a valid string
158
+ if (AttributeKinds.includes(schema.kind)) {
159
+ fields.set(key, 'attribute');
160
+ } else if (schema.kind === 'belongsTo' || schema.kind === 'hasMany') {
161
+ fields.set(key, schema.kind);
162
+ }
163
+ });
164
+ return fields;
165
+ }
166
+ get attributes() {
167
+ const attrs = new Map();
168
+ const fields = this.__store.schema.fields({
169
+ type: this.modelName
170
+ });
171
+ fields.forEach((schema, key) => {
172
+ if (schema.kind === 'attribute') {
173
+ attrs.set(key, schema);
174
+ // @ts-expect-error checking if a string is a valid string
175
+ } else if (AttributeKinds.includes(schema.kind)) {
176
+ attrs.set(key, {
177
+ kind: 'attribute',
178
+ name: key,
179
+ type: null,
180
+ options: schema.options ?? {}
181
+ });
182
+ }
183
+ });
184
+ return attrs;
185
+ }
186
+ get relationshipsByName() {
187
+ const rels = new Map();
188
+ const fields = this.__store.schema.fields({
189
+ type: this.modelName
190
+ });
191
+ fields.forEach((schema, key) => {
192
+ if (schema.kind === 'belongsTo' || schema.kind === 'hasMany') {
193
+ rels.set(key, schema);
194
+ }
195
+ });
196
+ return rels;
197
+ }
198
+ eachAttribute(callback, binding) {
199
+ this.attributes.forEach((schema, key) => {
200
+ callback.call(binding, key, schema);
201
+ });
202
+ }
203
+ eachRelationship(callback, binding) {
204
+ this.__store.schema.fields({
205
+ type: this.modelName
206
+ }).forEach((schema, key) => {
207
+ if (schema.kind === 'belongsTo' || schema.kind === 'hasMany') {
208
+ callback.call(binding, key, schema);
209
+ }
210
+ });
211
+ }
212
+ eachTransformedAttribute(callback, binding) {
213
+ this.__store.schema.fields({
214
+ type: this.modelName
215
+ }).forEach((schema, key) => {
216
+ if (schema.kind === 'attribute') {
217
+ const type = schema.type;
218
+ if (type) callback.call(binding, key, type);
219
+ }
220
+ });
221
+ }
222
+ }
223
+ function fragmentsModelFor(modelName) {
224
+ return getShimClass(this, modelName);
225
+ }
226
+ const modelFor = fragmentsModelFor;
227
+ export { FragmentExtension as F, FragmentArrayExtension as a, FragmentArray as b, Fragment as c, fragmentsModelFor as f, modelFor as m };
@@ -1,7 +1,7 @@
1
1
  import { pluralize, singularize } from '@warp-drive/utilities/string';
2
2
  import { withDefaults } from './model/migration-support.js';
3
- import { F as FragmentExtension, a as FragmentArrayExtension } from "./model-for-CqXsIKws.js";
4
- export { c as Fragment, b as FragmentArray, m as modelFor } from "./model-for-CqXsIKws.js";
3
+ import { F as FragmentExtension, a as FragmentArrayExtension } from "./model-for-DOiIKvY_.js";
4
+ export { c as Fragment, b as FragmentArray, m as modelFor } from "./model-for-DOiIKvY_.js";
5
5
 
6
6
  /**
7
7
  * Used as a helper to setup the relevant parts of an array
@@ -5,8 +5,8 @@ import { i as isElementDescriptor, n as normalizeModelName } from "./util-DvanW3
5
5
  import { assertPrivateStore } from '@warp-drive/core/store/-private';
6
6
  import { l as lookupLegacySupport } from "./errors-BGVFCBmi.js";
7
7
  import '@warp-drive/utilities/string';
8
- export { M as Model, b as buildSchema, M as default, m as restoreDeprecatedModelRequestBehaviors } from "./schema-provider-DJtD_8jZ.js";
9
- export { i as instantiateRecord, m as modelFor, t as teardownRecord } from "./hooks-BztVA_x0.js";
8
+ export { M as Model, b as buildSchema, M as default, m as restoreDeprecatedModelRequestBehaviors } from "./schema-provider-DHGEb_sz.js";
9
+ export { i as instantiateRecord, m as modelFor, t as teardownRecord } from "./hooks-BenXLbeb.js";
10
10
 
11
11
  /**
12
12
  * Options provided to the attr decorator are
@@ -1771,7 +1771,11 @@ class ModelSchemaProvider {
1771
1771
  registerHashFn(hashFn) {}
1772
1772
  /** @internal */
1773
1773
  _loadModelSchema(type) {
1774
- const modelClass = this.store.modelFor(type);
1774
+ const factory = getModelFactory(this.store, type);
1775
+ if (!factory) {
1776
+ throw new Error(`No model was found for '${type}'`);
1777
+ }
1778
+ const modelClass = factory.class;
1775
1779
  const attributeMap = modelClass.attributes;
1776
1780
  const attributes = Object.create(null);
1777
1781
  attributeMap.forEach((meta, name) => attributes[name] = meta);
@@ -1,6 +1,6 @@
1
1
  import { setOwner, getOwner } from '@ember/application';
2
2
  import { assertPrivateStore, setRecordIdentifier, StoreMap } from '@warp-drive/core/store/-private';
3
- import { g as getModelFactory } from "./schema-provider-CjX55uSY.js";
3
+ import { g as getModelFactory } from "./schema-provider-D6EzGZB-.js";
4
4
  import { n as normalizeModelName } from "./util-B6cn-i93.js";
5
5
  function instantiateRecord(identifier, createRecordArgs) {
6
6
  const type = identifier.type;
@@ -8,10 +8,10 @@ import '@warp-drive/core/types/symbols';
8
8
  import '@warp-drive/utilities/string';
9
9
  import '@warp-drive/core/store/-private';
10
10
  import "./errors-CdDaK81x.js";
11
- import "./schema-provider-CjX55uSY.js";
12
- import { i as instantiateRecord, t as teardownRecord, m as modelFor } from "./hooks-yId87yyG.js";
11
+ import "./schema-provider-D6EzGZB-.js";
12
+ import { i as instantiateRecord, t as teardownRecord, m as modelFor } from "./hooks-Ds1PZsBo.js";
13
13
  import { registerDerivations as registerDerivations$1, DelegatingSchemaService } from './model/migration-support.js';
14
- import { F as FragmentExtension, a as FragmentArrayExtension, f as fragmentsModelFor } from "./model-for-CqXsIKws.js";
14
+ import { F as FragmentExtension, a as FragmentArrayExtension, f as fragmentsModelFor } from "./model-for-DOiIKvY_.js";
15
15
  import { restoreDeprecatedStoreBehaviors } from './store.js';
16
16
 
17
17
  /**
@@ -5,7 +5,7 @@ import { assertPrivateStore } from '@warp-drive/core/store/-private';
5
5
  import { getOrSetGlobal } from '@warp-drive/core/types/-private';
6
6
  import { Type } from '@warp-drive/core/types/symbols';
7
7
  import { l as lookupLegacySupport, E as Errors } from "../errors-CdDaK81x.js";
8
- import { b as buildSchema, u as unloadRecord, s as serialize, _ as _save, a as save, r as rollbackAttributes, c as _reload, d as reload, h as hasMany, e as _destroyRecord, f as destroyRecord, i as deleteRecord, R as RecordState, j as changedAttributes, k as belongsTo, l as createSnapshot } from "../schema-provider-CjX55uSY.js";
8
+ import { b as buildSchema, u as unloadRecord, s as serialize, _ as _save, a as save, r as rollbackAttributes, c as _reload, d as reload, h as hasMany, e as _destroyRecord, f as destroyRecord, i as deleteRecord, R as RecordState, j as changedAttributes, k as belongsTo, l as createSnapshot } from "../schema-provider-D6EzGZB-.js";
9
9
 
10
10
  /**
11
11
  * This module provides support for migrating away from @warp-drive/legacy/model
@@ -70,13 +70,19 @@ class FragmentArray {
70
70
  }
71
71
  #isDestroyed = (initializeDeferredDecorator(this, "isDestroyed"), void 0);
72
72
  get hasDirtyAttributes() {
73
+ const array = this;
74
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
75
+ const context = array[Context];
76
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
73
77
  const {
74
78
  path,
75
79
  resourceKey,
76
80
  store
77
- } = this[Context];
81
+ } = context;
82
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-call, @typescript-eslint/no-unsafe-member-access
78
83
  const record = store.peekRecord(resourceKey);
79
84
  if (record.hasDirtyAttributes && path) {
85
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-call, @typescript-eslint/no-unsafe-member-access
80
86
  const root = path.at(0);
81
87
  return root in record.changedAttributes();
82
88
  }
@@ -1,7 +1,7 @@
1
1
  import { pluralize, singularize } from '@warp-drive/utilities/string';
2
2
  import { withDefaults } from './model/migration-support.js';
3
- import { F as FragmentExtension, a as FragmentArrayExtension } from "./model-for-CqXsIKws.js";
4
- export { c as Fragment, b as FragmentArray, m as modelFor } from "./model-for-CqXsIKws.js";
3
+ import { F as FragmentExtension, a as FragmentArrayExtension } from "./model-for-DOiIKvY_.js";
4
+ export { c as Fragment, b as FragmentArray, m as modelFor } from "./model-for-DOiIKvY_.js";
5
5
 
6
6
  /**
7
7
  * Used as a helper to setup the relevant parts of an array
@@ -5,8 +5,8 @@ import { i as isElementDescriptor, n as normalizeModelName } from "./util-B6cn-i
5
5
  import { assertPrivateStore } from '@warp-drive/core/store/-private';
6
6
  import { l as lookupLegacySupport } from "./errors-CdDaK81x.js";
7
7
  import { singularize, dasherize } from '@warp-drive/utilities/string';
8
- export { M as Model, b as buildSchema, M as default, m as restoreDeprecatedModelRequestBehaviors } from "./schema-provider-CjX55uSY.js";
9
- export { i as instantiateRecord, m as modelFor, t as teardownRecord } from "./hooks-yId87yyG.js";
8
+ export { M as Model, b as buildSchema, M as default, m as restoreDeprecatedModelRequestBehaviors } from "./schema-provider-D6EzGZB-.js";
9
+ export { i as instantiateRecord, m as modelFor, t as teardownRecord } from "./hooks-Ds1PZsBo.js";
10
10
 
11
11
  /**
12
12
  * Options provided to the attr decorator are
@@ -1783,7 +1783,11 @@ class ModelSchemaProvider {
1783
1783
  registerHashFn(hashFn) {}
1784
1784
  /** @internal */
1785
1785
  _loadModelSchema(type) {
1786
- const modelClass = this.store.modelFor(type);
1786
+ const factory = getModelFactory(this.store, type);
1787
+ if (!factory) {
1788
+ throw new Error(`No model was found for '${type}'`);
1789
+ }
1790
+ const modelClass = factory.class;
1787
1791
  const attributeMap = modelClass.attributes;
1788
1792
  const attributes = Object.create(null);
1789
1793
  attributeMap.forEach((meta, name) => attributes[name] = meta);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@warp-drive/legacy",
3
- "version": "5.9.0-alpha.16",
3
+ "version": "5.9.0-alpha.18",
4
4
  "description": "Decommissioned Packages for WarpDrive | Things your app might still want to maintain use of for a little longer.",
5
5
  "keywords": [
6
6
  "ember-addon"
@@ -40,8 +40,8 @@
40
40
  }
41
41
  },
42
42
  "peerDependencies": {
43
- "@warp-drive/core": "5.9.0-alpha.16",
44
- "@warp-drive/utilities": "5.9.0-alpha.16"
43
+ "@warp-drive/core": "5.9.0-alpha.18",
44
+ "@warp-drive/utilities": "5.9.0-alpha.18"
45
45
  },
46
46
  "dependencies": {
47
47
  "@embroider/macros": "^1.19.6"
@@ -51,9 +51,9 @@
51
51
  "@babel/plugin-transform-typescript": "^7.28.0",
52
52
  "@babel/preset-typescript": "^7.27.1",
53
53
  "@types/jquery": "^3.5.33",
54
- "@warp-drive/internal-config": "5.9.0-alpha.16",
55
- "@warp-drive/core": "5.9.0-alpha.16",
56
- "@warp-drive/utilities": "5.9.0-alpha.16",
54
+ "@warp-drive/internal-config": "5.9.0-alpha.18",
55
+ "@warp-drive/core": "5.9.0-alpha.18",
56
+ "@warp-drive/utilities": "5.9.0-alpha.18",
57
57
  "ember-source": "~6.12.0",
58
58
  "decorator-transforms": "^2.3.0",
59
59
  "expect-type": "^1.2.2",
@@ -1,221 +0,0 @@
1
- import { tracked, cached } from '@glimmer/tracking';
2
- import { Context } from '@warp-drive/core/reactive/-private';
3
- import { a as decorateFieldV2, i as initializeDeferredDecorator, d as decorateMethodV2 } from "./runtime-BPCpkOf1-BKOwiRJp.js";
4
- class Fragment {
5
- static {
6
- decorateFieldV2(this.prototype, "isDestroying", [tracked], function () {
7
- return false;
8
- });
9
- }
10
- #isDestroying = (initializeDeferredDecorator(this, "isDestroying"), void 0); // We might want to check the parent values once we move this code to warp-drive.
11
- static {
12
- decorateFieldV2(this.prototype, "isDestroyed", [tracked], function () {
13
- return false;
14
- });
15
- }
16
- #isDestroyed = (initializeDeferredDecorator(this, "isDestroyed"), void 0);
17
- get hasDirtyAttributes() {
18
- const {
19
- path,
20
- resourceKey,
21
- store
22
- } = this[Context];
23
- const record = store.peekRecord(resourceKey);
24
- if (record.hasDirtyAttributes && path) {
25
- const root = path.at(0);
26
- return root in record.changedAttributes();
27
- }
28
- return false;
29
- }
30
- static {
31
- decorateMethodV2(this.prototype, "hasDirtyAttributes", [cached]);
32
- }
33
- get isFragment() {
34
- return true;
35
- }
36
- get $type() {
37
- const {
38
- field
39
- } = this[Context];
40
- return field?.type;
41
- }
42
- rollbackAttributes() {
43
- const {
44
- path,
45
- resourceKey,
46
- store
47
- } = this[Context];
48
- if (path) {
49
- const oldValue = store.cache.getRemoteAttr(resourceKey, path);
50
- store.cache.setAttr(resourceKey, path, oldValue);
51
- }
52
- }
53
- }
54
- const FragmentExtension = {
55
- kind: 'object',
56
- name: 'fragment',
57
- features: Fragment
58
- };
59
- class FragmentArray {
60
- static {
61
- decorateFieldV2(this.prototype, "isDestroying", [tracked], function () {
62
- return false;
63
- });
64
- }
65
- #isDestroying = (initializeDeferredDecorator(this, "isDestroying"), void 0); // We might want to check the parent values once we move this code to warp-drive.
66
- static {
67
- decorateFieldV2(this.prototype, "isDestroyed", [tracked], function () {
68
- return false;
69
- });
70
- }
71
- #isDestroyed = (initializeDeferredDecorator(this, "isDestroyed"), void 0);
72
- get hasDirtyAttributes() {
73
- const {
74
- path,
75
- resourceKey,
76
- store
77
- } = this[Context];
78
- const record = store.peekRecord(resourceKey);
79
- if (record.hasDirtyAttributes && path) {
80
- const root = path.at(0);
81
- return root in record.changedAttributes();
82
- }
83
- return false;
84
- }
85
- static {
86
- decorateMethodV2(this.prototype, "hasDirtyAttributes", [cached]);
87
- }
88
- addFragment(fragment) {
89
- if (!fragment) {
90
- return;
91
- }
92
- return this.addObject(fragment);
93
- }
94
- createFragment(fragment) {
95
- if (!fragment) {
96
- return;
97
- }
98
- return this.pushObject(fragment);
99
- }
100
- removeFragment(fragment) {
101
- if (!fragment) {
102
- return;
103
- }
104
- const index = this.indexOf(fragment);
105
- if (index !== -1) {
106
- this.splice(index, 1);
107
- }
108
- }
109
- rollbackAttributes() {
110
- for (const fragment of this) {
111
- // @ts-expect-error TODO: fix these types
112
- fragment?.rollbackAttributes?.();
113
- }
114
- }
115
- }
116
- const FragmentArrayExtension = {
117
- kind: 'array',
118
- name: 'fragment-array',
119
- features: FragmentArray
120
- };
121
-
122
- // if modelFor turns out to be a bottleneck we should replace with a Map
123
- // and clear it during store teardown.
124
- const AvailableShims = new WeakMap();
125
- function getShimClass(store, modelName) {
126
- let shims = AvailableShims.get(store);
127
- if (!shims) {
128
- shims = Object.create(null);
129
- AvailableShims.set(store, shims);
130
- }
131
- let shim = shims[modelName];
132
- if (shim === undefined) {
133
- shim = shims[modelName] = new ShimModelClass(store, modelName);
134
- }
135
- return shim;
136
- }
137
- const AttributeKinds = ['field', 'attribute', 'object', 'array', 'schema-object', 'schema-array'];
138
-
139
- // Mimics the static apis of @warp-drive/legacy/model
140
- class ShimModelClass {
141
- constructor(store, modelName) {
142
- this.__store = store;
143
- this.modelName = modelName;
144
- }
145
- get fields() {
146
- const fields = new Map();
147
- const fieldSchemas = this.__store.schema.fields({
148
- type: this.modelName
149
- });
150
- fieldSchemas.forEach((schema, key) => {
151
- // @ts-expect-error checking if a string is a valid string
152
- if (AttributeKinds.includes(schema.kind)) {
153
- fields.set(key, 'attribute');
154
- } else if (schema.kind === 'belongsTo' || schema.kind === 'hasMany') {
155
- fields.set(key, schema.kind);
156
- }
157
- });
158
- return fields;
159
- }
160
- get attributes() {
161
- const attrs = new Map();
162
- const fields = this.__store.schema.fields({
163
- type: this.modelName
164
- });
165
- fields.forEach((schema, key) => {
166
- if (schema.kind === 'attribute') {
167
- attrs.set(key, schema);
168
- // @ts-expect-error checking if a string is a valid string
169
- } else if (AttributeKinds.includes(schema.kind)) {
170
- attrs.set(key, {
171
- kind: 'attribute',
172
- name: key,
173
- type: null,
174
- options: schema.options ?? {}
175
- });
176
- }
177
- });
178
- return attrs;
179
- }
180
- get relationshipsByName() {
181
- const rels = new Map();
182
- const fields = this.__store.schema.fields({
183
- type: this.modelName
184
- });
185
- fields.forEach((schema, key) => {
186
- if (schema.kind === 'belongsTo' || schema.kind === 'hasMany') {
187
- rels.set(key, schema);
188
- }
189
- });
190
- return rels;
191
- }
192
- eachAttribute(callback, binding) {
193
- this.attributes.forEach((schema, key) => {
194
- callback.call(binding, key, schema);
195
- });
196
- }
197
- eachRelationship(callback, binding) {
198
- this.__store.schema.fields({
199
- type: this.modelName
200
- }).forEach((schema, key) => {
201
- if (schema.kind === 'belongsTo' || schema.kind === 'hasMany') {
202
- callback.call(binding, key, schema);
203
- }
204
- });
205
- }
206
- eachTransformedAttribute(callback, binding) {
207
- this.__store.schema.fields({
208
- type: this.modelName
209
- }).forEach((schema, key) => {
210
- if (schema.kind === 'attribute') {
211
- const type = schema.type;
212
- if (type) callback.call(binding, key, type);
213
- }
214
- });
215
- }
216
- }
217
- function fragmentsModelFor(modelName) {
218
- return getShimClass(this, modelName);
219
- }
220
- const modelFor = fragmentsModelFor;
221
- export { FragmentExtension as F, FragmentArrayExtension as a, FragmentArray as b, Fragment as c, fragmentsModelFor as f, modelFor as m };