@ember-data/model 5.4.0-alpha.64 → 5.4.0-alpha.70

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 (71) hide show
  1. package/addon-main.cjs +5 -0
  2. package/blueprints/model/index.js +18 -5
  3. package/blueprints/model-test/index.js +16 -10
  4. package/blueprints/model-test/qunit-files/__root__/__path__/__test__.js +4 -5
  5. package/{addon → dist}/-private.js +2 -2
  6. package/{addon/has-many-BuTJfT5a.js → dist/has-many-CR10J-rp.js} +49 -26
  7. package/dist/has-many-CR10J-rp.js.map +1 -0
  8. package/dist/hooks-BNw6VdLr.js +75 -0
  9. package/dist/hooks-BNw6VdLr.js.map +1 -0
  10. package/dist/hooks.js +2 -0
  11. package/{addon → dist}/hooks.js.map +1 -1
  12. package/dist/index.js +4 -0
  13. package/{addon → dist}/index.js.map +1 -1
  14. package/dist/migration-support.js +211 -0
  15. package/dist/migration-support.js.map +1 -0
  16. package/{addon/model-DJ9C4aZ-.js → dist/model-CsbDNxap.js} +821 -250
  17. package/dist/model-CsbDNxap.js.map +1 -0
  18. package/dist/schema-provider-C5vR7TBr.js +256 -0
  19. package/dist/schema-provider-C5vR7TBr.js.map +1 -0
  20. package/package.json +39 -59
  21. package/unstable-preview-types/-private/attr.d.ts.map +1 -1
  22. package/unstable-preview-types/-private/belongs-to.d.ts.map +1 -1
  23. package/unstable-preview-types/-private/debug/assert-polymorphic-type.d.ts +2 -2
  24. package/unstable-preview-types/-private/debug/assert-polymorphic-type.d.ts.map +1 -1
  25. package/unstable-preview-types/-private/errors.d.ts +2 -5
  26. package/unstable-preview-types/-private/errors.d.ts.map +1 -1
  27. package/unstable-preview-types/-private/has-many.d.ts.map +1 -1
  28. package/unstable-preview-types/-private/hooks.d.ts.map +1 -1
  29. package/unstable-preview-types/-private/legacy-relationships-support.d.ts +16 -20
  30. package/unstable-preview-types/-private/legacy-relationships-support.d.ts.map +1 -1
  31. package/unstable-preview-types/-private/many-array.d.ts +11 -13
  32. package/unstable-preview-types/-private/many-array.d.ts.map +1 -1
  33. package/unstable-preview-types/-private/model-methods.d.ts +6 -5
  34. package/unstable-preview-types/-private/model-methods.d.ts.map +1 -1
  35. package/unstable-preview-types/-private/model.d.ts +38 -35
  36. package/unstable-preview-types/-private/model.d.ts.map +1 -1
  37. package/unstable-preview-types/-private/notify-changes.d.ts +1 -1
  38. package/unstable-preview-types/-private/notify-changes.d.ts.map +1 -1
  39. package/unstable-preview-types/-private/promise-belongs-to.d.ts +1 -2
  40. package/unstable-preview-types/-private/promise-belongs-to.d.ts.map +1 -1
  41. package/unstable-preview-types/-private/promise-many-array.d.ts +4 -4
  42. package/unstable-preview-types/-private/promise-many-array.d.ts.map +1 -1
  43. package/unstable-preview-types/-private/record-state.d.ts +3 -4
  44. package/unstable-preview-types/-private/record-state.d.ts.map +1 -1
  45. package/unstable-preview-types/-private/references/belongs-to.d.ts +4 -4
  46. package/unstable-preview-types/-private/references/belongs-to.d.ts.map +1 -1
  47. package/unstable-preview-types/-private/references/has-many.d.ts +7 -7
  48. package/unstable-preview-types/-private/references/has-many.d.ts.map +1 -1
  49. package/unstable-preview-types/-private/schema-provider.d.ts +46 -15
  50. package/unstable-preview-types/-private/schema-provider.d.ts.map +1 -1
  51. package/unstable-preview-types/-private/type-utils.d.ts +64 -0
  52. package/unstable-preview-types/-private/type-utils.d.ts.map +1 -0
  53. package/unstable-preview-types/-private.d.ts +4 -3
  54. package/unstable-preview-types/-private.d.ts.map +1 -1
  55. package/unstable-preview-types/index.d.ts +20 -20
  56. package/unstable-preview-types/index.d.ts.map +1 -1
  57. package/unstable-preview-types/migration-support.d.ts +45 -6
  58. package/unstable-preview-types/migration-support.d.ts.map +1 -1
  59. package/addon/has-many-BuTJfT5a.js.map +0 -1
  60. package/addon/hooks-BMoEt0SI.js +0 -176
  61. package/addon/hooks-BMoEt0SI.js.map +0 -1
  62. package/addon/hooks.js +0 -1
  63. package/addon/index.js +0 -3
  64. package/addon/migration-support.js +0 -118
  65. package/addon/migration-support.js.map +0 -1
  66. package/addon/model-DJ9C4aZ-.js.map +0 -1
  67. package/addon/util-CSYkrwfb.js +0 -35
  68. package/addon/util-CSYkrwfb.js.map +0 -1
  69. package/addon-main.js +0 -94
  70. package/unstable-preview-types/-private/promise-proxy-base.d.ts +0 -35
  71. /package/{addon → dist}/-private.js.map +0 -0
@@ -1 +1 @@
1
- {"version":3,"file":"has-many.d.ts","sourceRoot":"","sources":["../../../src/-private/references/has-many.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,6CAA6C,CAAC;AAClF,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,kCAAkC,CAAC;AAC9D,OAAO,KAAK,KAAK,MAAM,mBAAmB,CAAC;AAE3C,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,kCAAkC,CAAC;AAI1E,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,wBAAwB,CAAC;AAErE,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,+BAA+B,CAAC;AAC9E,OAAO,KAAK,EACV,0BAA0B,EAC1B,8BAA8B,EAC9B,sBAAsB,EACtB,UAAU,EACV,IAAI,EACJ,eAAe,EAChB,MAAM,iCAAiC,CAAC;AAEzC,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAI/C,OAAO,KAAK,SAAS,MAAM,eAAe,CAAC;AAE3C;;EAEE;AACF,UAAU,kBAAkB;IAC1B,KAAK,CAAC,EAAE;QACN,OAAO,CAAC,EAAE,MAAM,GAAG,UAAU,CAAC;KAC/B,CAAC;IACF,IAAI,CAAC,EAAE,IAAI,CAAC;CACb;AAED,KAAK,aAAa,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC,EAAE,GAAG,CAAC,GAAG,KAAK,CAAC;AAO1D;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,MAAM,CAAC,OAAO,OAAO,gBA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AO,CAAC,SAAS,CAAC,OAAO,CAAC,GAAG,IAAI,CAAC;IAiDrC,SAAS;IAaT;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OAwCG;IACH,KAAK,IAAI,SAAS,CAAC,OAAO,CAAC,GAAG,IAAI;IAiBlC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OA+DG;IACG,IAAI,CAAC,OAAO,CAAC,EAAE,iBAAiB,GAAG,OAAO,CAAC,SAAS,CAAC,OAAO,CAAC,CAAC;IAapE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OAiDG;IACH,MAAM,CAAC,OAAO,CAAC,EAAE,iBAAiB,GAAG,OAAO,CAAC,SAAS,CAAC,OAAO,CAAC,CAAC;CAMjE;AAGD,wBAAgB,eAAe,CAAC,MAAM,EAAE,sBAAsB,GAAG,kBAAkB,GAAG,MAAM,IAAI,sBAAsB,CAGrH"}
@@ -1,27 +1,58 @@
1
1
  declare module '@ember-data/model/-private/schema-provider' {
2
2
  import type Store from '@ember-data/store';
3
- import type { FieldSchema } from '@ember-data/store/-types/q/schema-service';
4
- import type { RecordIdentifier } from '@warp-drive/core-types/identifier';
5
- import type { AttributesSchema, RelationshipsSchema } from '@warp-drive/core-types/schema';
3
+ import type { SchemaService } from '@ember-data/store/types';
4
+ import type { RecordIdentifier, StableRecordIdentifier } from '@warp-drive/core-types/identifier';
5
+ import type { ObjectValue } from '@warp-drive/core-types/json/raw';
6
+ import type { Derivation, HashFn, Transformation } from '@warp-drive/core-types/schema/concepts';
7
+ import type { LegacyAttributeField, LegacyFieldSchema, LegacyRelationshipSchema, ResourceSchema } from '@warp-drive/core-types/schema/fields';
6
8
  import type { ModelFactory, ModelStore } from '@ember-data/model/-private/model';
7
- export class ModelSchemaProvider {
9
+ type AttributesSchema = ReturnType<Exclude<SchemaService['attributesDefinitionFor'], undefined>>;
10
+ type RelationshipsSchema = ReturnType<Exclude<SchemaService['relationshipsDefinitionFor'], undefined>>;
11
+ type InternalSchema = {
12
+ schema: ResourceSchema;
13
+ fields: Map<string, LegacyAttributeField | LegacyRelationshipSchema>;
14
+ attributes: Record<string, LegacyAttributeField>;
15
+ relationships: Record<string, LegacyRelationshipSchema>;
16
+ };
17
+ export interface ModelSchemaProvider {
18
+ attributesDefinitionFor(resource: RecordIdentifier | {
19
+ type: string;
20
+ }): AttributesSchema;
21
+ relationshipsDefinitionFor(resource: RecordIdentifier | {
22
+ type: string;
23
+ }): RelationshipsSchema;
24
+ doesTypeExist(type: string): boolean;
25
+ }
26
+ export class ModelSchemaProvider implements SchemaService {
8
27
  store: ModelStore;
9
- _relationshipsDefCache: Record<string, RelationshipsSchema>;
10
- _attributesDefCache: Record<string, AttributesSchema>;
11
- _fieldsDefCache: Record<string, Map<string, FieldSchema>>;
28
+ _schemas: Map<string, InternalSchema>;
29
+ _typeMisses: Set<string>;
12
30
  constructor(store: ModelStore);
13
- fields(identifier: RecordIdentifier | {
31
+ hasTrait(type: string): boolean;
32
+ resourceHasTrait(resource: StableRecordIdentifier | {
14
33
  type: string;
15
- }): Map<string, FieldSchema>;
16
- attributesDefinitionFor(identifier: RecordIdentifier | {
34
+ }, trait: string): boolean;
35
+ transformation(name: string): Transformation;
36
+ hashFn(name: string): HashFn;
37
+ derivation(name: string): Derivation;
38
+ resource(resource: StableRecordIdentifier | {
17
39
  type: string;
18
- }): AttributesSchema;
19
- relationshipsDefinitionFor(identifier: RecordIdentifier | {
40
+ }): ResourceSchema;
41
+ registerResources(schemas: ResourceSchema[]): void;
42
+ registerResource(schema: ResourceSchema): void;
43
+ registerTransformation(transform: Transformation): void;
44
+ registerDerivation<R, T, FM extends ObjectValue | null>(derivation: Derivation<R, T, FM>): void;
45
+ registerHashFn(hashFn: HashFn): void;
46
+ _loadModelSchema(type: string): InternalSchema;
47
+ fields(resource: RecordIdentifier | {
20
48
  type: string;
21
- }): RelationshipsSchema;
22
- doesTypeExist(modelName: string): boolean;
49
+ }): Map<string, LegacyFieldSchema>;
50
+ hasResource(resource: {
51
+ type: string;
52
+ }): boolean;
23
53
  }
24
- export function buildSchema(store: Store): ModelSchemaProvider;
54
+ export function buildSchema(store: Store): SchemaService;
25
55
  export function getModelFactory(store: ModelStore, type: string): ModelFactory | null;
56
+ export {};
26
57
  }
27
58
  //# sourceMappingURL=schema-provider.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"schema-provider.d.ts","sourceRoot":"","sources":["../../src/-private/schema-provider.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,KAAK,MAAM,mBAAmB,CAAC;AAC3C,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,2CAA2C,CAAC;AAC7E,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,mCAAmC,CAAC;AAC1E,OAAO,KAAK,EAAE,gBAAgB,EAAE,mBAAmB,EAAE,MAAM,+BAA+B,CAAC;AAE3F,OAAO,KAAK,EAAuB,YAAY,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAI7E,qBAAa,mBAAmB;IACtB,KAAK,EAAE,UAAU,CAAC;IAClB,sBAAsB,EAAE,MAAM,CAAC,MAAM,EAAE,mBAAmB,CAAC,CAAC;IAC5D,mBAAmB,EAAE,MAAM,CAAC,MAAM,EAAE,gBAAgB,CAAC,CAAC;IACtD,eAAe,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,MAAM,EAAE,WAAW,CAAC,CAAC,CAAC;gBAEtD,KAAK,EAAE,UAAU;IAO7B,MAAM,CAAC,UAAU,EAAE,gBAAgB,GAAG;QAAE,IAAI,EAAE,MAAM,CAAA;KAAE,GAAG,GAAG,CAAC,MAAM,EAAE,WAAW,CAAC;IAwBjF,uBAAuB,CAAC,UAAU,EAAE,gBAAgB,GAAG;QAAE,IAAI,EAAE,MAAM,CAAA;KAAE,GAAG,gBAAgB;IAmB1F,0BAA0B,CAAC,UAAU,EAAE,gBAAgB,GAAG;Q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,EAAE,UAAU,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,GAAG,IAAI;IAG/F,cAAc,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI;IAGpC,gBAAgB,CAAC,IAAI,EAAE,MAAM;IAoC7B,MAAM,CAAC,QAAQ,EAAE,gBAAgB,GAAG;QAAE,IAAI,EAAE,MAAM,CAAA;KAAE,GAAG,GAAG,CAAC,MAAM,EAAE,iBAAiB,CAAC;IAUrF,WAAW,CAAC,QAAQ,EAAE;QAAE,IAAI,EAAE,MAAM,CAAA;KAAE,GAAG,OAAO;CAqBjD;AA2DD,wBAAgB,WAAW,CAAC,KAAK,EAAE,KAAK,GAAG,aAAa,CAEvD;AAED,wBAAgB,eAAe,CAAC,KAAK,EAAE,UAAU,EAAE,IAAI,EAAE,MAAM,GAAG,YAAY,GAAG,IAAI,CAkCpF"}
@@ -0,0 +1,64 @@
1
+ declare module '@ember-data/model/-private/type-utils' {
2
+ import type { TypedRecordInstance } from '@warp-drive/core-types/record';
3
+ import type { ResourceType } from '@warp-drive/core-types/symbols';
4
+ import type { RelatedCollection } from '@ember-data/model/-private/many-array';
5
+ import type { Model } from '@ember-data/model/-private/model';
6
+ import type { PromiseBelongsTo } from '@ember-data/model/-private/promise-belongs-to';
7
+ import type { PromiseManyArray } from '@ember-data/model/-private/promise-many-array';
8
+ type ExcludeNull<T> = Exclude<T, null> extends never ? T : Exclude<T, null>;
9
+ type GetMappedKey<M, V> = {
10
+ [K in keyof M]-?: ExcludeNull<M[K]> extends V ? K : never;
11
+ }[keyof M] & string;
12
+ /**
13
+ * Get the keys of fields that are maybe defined as `belongsTo` relationships
14
+ *
15
+ * "Maybe" because getter/computed fields might be returning values that look
16
+ * like relationships, but are not.
17
+ *
18
+ * @typedoc
19
+ */
20
+ export type MaybeBelongsToFields<ThisType> = _TrueKeys<ThisType> extends never ? string : _MaybeBelongsToFields<ThisType>;
21
+ export type _MaybeBelongsToFields<ThisType> = GetMappedKey<ThisType, PromiseBelongsTo | TypedRecordInstance>;
22
+ /**
23
+ * Get the keys of fields that are maybe defined as `hasMany` relationships
24
+ *
25
+ * "Maybe" because getter/computed fields might be returning values that look
26
+ * like relationships, but are not.
27
+ *
28
+ * @typedoc
29
+ */
30
+ export type MaybeHasManyFields<ThisType> = _TrueKeys<ThisType> extends never ? string : _MaybeHasManyFields<ThisType>;
31
+ type _MaybeHasManyFields<ThisType> = GetMappedKey<ThisType, RelatedCollection | PromiseManyArray>;
32
+ /**
33
+ * Get the keys of fields that are maybe defined as `attr` fields
34
+ *
35
+ * "Maybe" because getter/computed fields might be returning values that look
36
+ * like attributes, but are not.
37
+ *
38
+ * This is computed by excluding the keys that are defined as `belongsTo` or `hasMany`
39
+ * as well as the keys on EmberObject and the Model base class
40
+ *
41
+ * @typedoc
42
+ */
43
+ export type MaybeAttrFields<ThisType> = Exclude<_TrueKeys<ThisType>, _MaybeBelongsToFields<ThisType> | _MaybeHasManyFields<ThisType>>;
44
+ /**
45
+ * Get the keys of fields that are maybe defined as relationships
46
+ *
47
+ * "Maybe" because getter/computed fields might be returning values that look
48
+ * like relationships, but are not.
49
+ *
50
+ * @typedoc
51
+ */
52
+ export type MaybeRelationshipFields<ThisType> = _TrueKeys<ThisType> extends never ? string : _MaybeBelongsToFields<ThisType> | _MaybeHasManyFields<ThisType>;
53
+ type _TrueKeys<ThisType> = Exclude<keyof ThisType & string, (keyof Model & string) | typeof ResourceType>;
54
+ export type isSubClass<ThisType> = _TrueKeys<ThisType> extends never ? false : true;
55
+ /**
56
+ * Get the keys of all fields defined on the given subclass of Model
57
+ * that don't exist on EmberObject or Model.
58
+ *
59
+ * @typedoc
60
+ */
61
+ export type SubclassKeys<ThisType> = _TrueKeys<ThisType> extends never ? string : _TrueKeys<ThisType>;
62
+ export {};
63
+ }
64
+ //# sourceMappingURL=type-utils.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"type-utils.d.ts","sourceRoot":"","sources":["../../src/-private/type-utils.ts"],"names":[],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CAAC;AAElG;;;;;;;;;;GAUG;AACH,MAAM,MAAM,eAAe,CAAC,QAAQ,IAAI,OAAO,CAC7C,SAAS,CAAC,QAAQ,CAAC,EACnB,qBAAqB,CAAC,QAAQ,CAAC,GAAG,mBAAmB,CAAC,QAAQ,CAAC,CAChE,CAAC;AAEF;;;;;;;GAOG;AACH,MAAM,MAAM,uBAAuB,CAAC,QAAQ,IAC1C,SAAS,CAAC,QAAQ,CAAC,SAAS,KAAK,GAAG,MAAM,GAAG,qBAAqB,CAAC,QAAQ,CAAC,GAAG,mBAAmB,CAAC,QAAQ,CAAC,CAAC;AAE/G,KAAK,SAAS,CAAC,QAAQ,IAAI,OAAO,CAAC,MAAM,QAAQ,GAAG,MAAM,EAAE,CAAC,MAAM,KAAK,GAAG,MAAM,CAAC,GAAG,OAAO,YAAY,CAAC,CAAC;AAC1G,MAAM,MAAM,UAAU,CAAC,QAAQ,IAAI,SAAS,CAAC,QAAQ,CAAC,SAAS,KAAK,GAAG,KAAK,GAAG,IAAI,CAAC;AACpF;;;;;GAKG;AACH,MAAM,MAAM,YAAY,CAAC,QAAQ,IAAI,SAAS,CAAC,QAAQ,CAAC,SAAS,KAAK,GAAG,MAAM,GAAG,SAAS,CAAC,QAAQ,CAAC,CAAC"}
@@ -3,10 +3,11 @@ declare module '@ember-data/model/-private' {
3
3
  export { belongsTo } from '@ember-data/model/-private/belongs-to';
4
4
  export { hasMany } from '@ember-data/model/-private/has-many';
5
5
  export { Model } from '@ember-data/model/-private/model';
6
- export { default as Errors } from '@ember-data/model/-private/errors';
7
- export { default as ManyArray } from '@ember-data/model/-private/many-array';
6
+ export type { ModelStore } from '@ember-data/model/-private/model';
7
+ export { Errors } from '@ember-data/model/-private/errors';
8
+ export { RelatedCollection as ManyArray } from '@ember-data/model/-private/many-array';
8
9
  export { PromiseBelongsTo } from '@ember-data/model/-private/promise-belongs-to';
9
- export { default as PromiseManyArray } from '@ember-data/model/-private/promise-many-array';
10
+ export { PromiseManyArray } from '@ember-data/model/-private/promise-many-array';
10
11
  export { lookupLegacySupport, LEGACY_SUPPORT } from '@ember-data/model/-private/legacy-relationships-support';
11
12
  }
12
13
  //# sourceMappingURL=-private.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"-private.d.ts","sourceRoot":"","sources":["../src/-private.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,iBAAiB,CAAC;AACvC,OAAO,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAC;AAClD,OAAO,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAC;AAC9C,OAAO,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAC;AACzC,OAAO,EAAE,OAAO,IAAI,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAEtD,OAAO,EAAE,OAAO,IAAI,SAAS,EAAE,MAAM,uBAAuB,CAAC;AAC7D,OAAO,EAAE,gBAAgB,EAAE,MAAM,+BAA+B,CAAC;AACjE,OAAO,EAAE,OAAO,IAAI,gBAAgB,EAAE,MAAM,+BAA+B,CAAC;AAG5E,OAAO,EAAE,mBAAmB,EAAE,cAAc,EAAE,MAAM,yCAAyC,CAAC"}
1
+ {"version":3,"file":"-private.d.ts","sourceRoot":"","sources":["../src/-private.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,iBAAiB,CAAC;AACvC,OAAO,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAC;AAClD,OAAO,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAC;AAC9C,OAAO,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAC;AACzC,YAAY,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AACnD,OAAO,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAE3C,OAAO,EAAE,iBAAiB,IAAI,SAAS,EAAE,MAAM,uBAAuB,CAAC;AACvE,OAAO,EAAE,gBAAgB,EAAE,MAAM,+BAA+B,CAAC;AACjE,OAAO,EAAE,gBAAgB,EAAE,MAAM,+BAA+B,CAAC;AAGjE,OAAO,EAAE,mBAAmB,EAAE,cAAc,EAAE,MAAM,yCAAyC,CAAC"}
@@ -1,30 +1,30 @@
1
- /// <reference path="./migration-support.d.ts" />
2
- /// <reference path="./hooks.d.ts" />
3
1
  /// <reference path="./-private.d.ts" />
4
- /// <reference path="./-private/errors.d.ts" />
2
+ /// <reference path="./hooks.d.ts" />
3
+ /// <reference path="./migration-support.d.ts" />
4
+ /// <reference path="./-private/util.d.ts" />
5
5
  /// <reference path="./-private/model.d.ts" />
6
- /// <reference path="./-private/legacy-relationships-support.d.ts" />
7
- /// <reference path="./-private/schema-provider.d.ts" />
8
- /// <reference path="./-private/has-many.d.ts" />
9
- /// <reference path="./-private/has-many.type-test.d.ts" />
10
- /// <reference path="./-private/many-array.d.ts" />
6
+ /// <reference path="./-private/hooks.d.ts" />
11
7
  /// <reference path="./-private/record-state.d.ts" />
12
- /// <reference path="./-private/promise-proxy-base.d.ts" />
13
- /// <reference path="./-private/model.type-test.d.ts" />
14
- /// <reference path="./-private/belongs-to.type-test.d.ts" />
15
- /// <reference path="./-private/promise-belongs-to.d.ts" />
16
8
  /// <reference path="./-private/attr.type-test.d.ts" />
17
- /// <reference path="./-private/util.d.ts" />
18
- /// <reference path="./-private/hooks.d.ts" />
19
- /// <reference path="./-private/model-methods.d.ts" />
20
- /// <reference path="./-private/belongs-to.d.ts" />
21
- /// <reference path="./-private/model-for-mixin.d.ts" />
9
+ /// <reference path="./-private/legacy-relationships-support.d.ts" />
10
+ /// <reference path="./-private/has-many.d.ts" />
22
11
  /// <reference path="./-private/promise-many-array.d.ts" />
12
+ /// <reference path="./-private/model-for-mixin.d.ts" />
13
+ /// <reference path="./-private/belongs-to.type-test.d.ts" />
23
14
  /// <reference path="./-private/notify-changes.d.ts" />
15
+ /// <reference path="./-private/belongs-to.d.ts" />
16
+ /// <reference path="./-private/many-array.d.ts" />
17
+ /// <reference path="./-private/has-many.type-test.d.ts" />
18
+ /// <reference path="./-private/errors.d.ts" />
19
+ /// <reference path="./-private/type-utils.d.ts" />
20
+ /// <reference path="./-private/schema-provider.d.ts" />
21
+ /// <reference path="./-private/model-methods.d.ts" />
22
+ /// <reference path="./-private/promise-belongs-to.d.ts" />
23
+ /// <reference path="./-private/model.type-test.d.ts" />
24
24
  /// <reference path="./-private/attr.d.ts" />
25
+ /// <reference path="./-private/debug/assert-polymorphic-type.d.ts" />
25
26
  /// <reference path="./-private/references/has-many.d.ts" />
26
27
  /// <reference path="./-private/references/belongs-to.d.ts" />
27
- /// <reference path="./-private/debug/assert-polymorphic-type.d.ts" />
28
28
  declare module '@ember-data/model' {
29
29
  /**
30
30
  * This package provides a Presentation Model for resource data in an EmberData Cache.
@@ -67,8 +67,8 @@ declare module '@ember-data/model' {
67
67
  */
68
68
  export { Model as default, attr, belongsTo, hasMany } from '@ember-data/model/-private';
69
69
  export type { PromiseBelongsTo as AsyncBelongsTo } from '@ember-data/model/-private/promise-belongs-to';
70
- export type { default as AsyncHasMany } from '@ember-data/model/-private/promise-many-array';
71
- export type { default as ManyArray } from '@ember-data/model/-private/many-array';
70
+ export type { PromiseManyArray as AsyncHasMany } from '@ember-data/model/-private/promise-many-array';
71
+ export type { RelatedCollection as ManyArray } from '@ember-data/model/-private/many-array';
72
72
  export { instantiateRecord, teardownRecord, modelFor } from '@ember-data/model/-private/hooks';
73
73
  export { ModelSchemaProvider } from '@ember-data/model/-private/schema-provider';
74
74
  }
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAsCG;AACH,OAAO,EAAE,KAAK,IAAI,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AAExE,YAAY,EAAE,gBAAgB,IAAI,cAAc,EAAE,MAAM,+BAA+B,CAAC;AACxF,YAAY,EAAE,OAAO,IAAI,YAAY,EAAE,MAAM,+BAA+B,CAAC;AAC7E,YAAY,EAAE,OAAO,IAAI,SAAS,EAAE,MAAM,uBAAuB,CAAC;AAClE,OAAO,EAAE,iBAAiB,EAAE,cAAc,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAC/E,OAAO,EAAE,mBAAmB,EAAE,MAAM,4BAA4B,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAsCG;AACH,OAAO,EAAE,KAAK,IAAI,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AAExE,YAAY,EAAE,gBAAgB,IAAI,cAAc,EAAE,MAAM,+BAA+B,CAAC;AACxF,YAAY,EAAE,gBAAgB,IAAI,YAAY,EAAE,MAAM,+BAA+B,CAAC;AACtF,YAAY,EAAE,iBAAiB,IAAI,SAAS,EAAE,MAAM,uBAAuB,CAAC;AAC5E,OAAO,EAAE,iBAAiB,EAAE,cAAc,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAC/E,OAAO,EAAE,mBAAmB,EAAE,MAAM,4BAA4B,CAAC"}
@@ -1,11 +1,50 @@
1
1
  declare module '@ember-data/model/migration-support' {
2
- import type { FieldSchema } from '@ember-data/store/-types/q/schema-service';
3
- type Derivation<R, T> = (record: R, options: Record<string, unknown> | null, prop: string) => T;
4
- type SchemaService = {
5
- registerDerivation(name: string, derivation: Derivation<unknown, unknown>): void;
6
- };
7
- export function withFields(fields: FieldSchema[]): FieldSchema[];
2
+ import type Store from '@ember-data/store';
3
+ import type { SchemaService } from '@ember-data/store/types';
4
+ import type { StableRecordIdentifier } from '@warp-drive/core-types';
5
+ import type { ObjectValue } from '@warp-drive/core-types/json/raw';
6
+ import type { Derivation, HashFn, Transformation } from '@warp-drive/core-types/schema/concepts';
7
+ import type { FieldSchema, ResourceSchema } from '@warp-drive/core-types/schema/fields';
8
+ import type { WithPartial } from '@warp-drive/core-types/utils';
9
+ type AttributesSchema = ReturnType<Exclude<SchemaService['attributesDefinitionFor'], undefined>>;
10
+ type RelationshipsSchema = ReturnType<Exclude<SchemaService['relationshipsDefinitionFor'], undefined>>;
11
+ export function withDefaults(schema: WithPartial<ResourceSchema, 'legacy' | 'identity'>): ResourceSchema;
8
12
  export function registerDerivations(schema: SchemaService): void;
13
+ export interface DelegatingSchemaService {
14
+ attributesDefinitionFor?(resource: StableRecordIdentifier | {
15
+ type: string;
16
+ }): AttributesSchema;
17
+ relationshipsDefinitionFor?(resource: StableRecordIdentifier | {
18
+ type: string;
19
+ }): RelationshipsSchema;
20
+ doesTypeExist?(type: string): boolean;
21
+ }
22
+ export class DelegatingSchemaService implements SchemaService {
23
+ _preferred: SchemaService;
24
+ _secondary: SchemaService;
25
+ constructor(store: Store, schema: SchemaService);
26
+ hasResource(resource: StableRecordIdentifier | {
27
+ type: string;
28
+ }): boolean;
29
+ hasTrait(type: string): boolean;
30
+ resourceHasTrait(resource: StableRecordIdentifier | {
31
+ type: string;
32
+ }, trait: string): boolean;
33
+ fields(resource: StableRecordIdentifier | {
34
+ type: string;
35
+ }): Map<string, FieldSchema>;
36
+ transformation(name: string): Transformation;
37
+ hashFn(name: string): HashFn;
38
+ derivation(name: string): Derivation;
39
+ resource(resource: StableRecordIdentifier | {
40
+ type: string;
41
+ }): ResourceSchema;
42
+ registerResources(schemas: ResourceSchema[]): void;
43
+ registerResource(schema: ResourceSchema): void;
44
+ registerTransformation(transform: Transformation): void;
45
+ registerDerivation<R, T, FM extends ObjectValue | null>(derivation: Derivation<R, T, FM>): void;
46
+ registerHashFn(hashFn: HashFn): void;
47
+ }
9
48
  export {};
10
49
  }
11
50
  //# sourceMappingURL=migration-support.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"migration-support.d.ts","sourceRoot":"","sources":["../src/migration-support.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,E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iB,CAAC,OAAO,EAAE,cAAc,EAAE,GAAG,IAAI;IAGlD,gBAAgB,CAAC,MAAM,EAAE,cAAc,GAAG,IAAI;IAG9C,sBAAsB,CAAC,SAAS,EAAE,cAAc,GAAG,IAAI;IAGvD,kBAAkB,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,SAAS,WAAW,GAAG,IAAI,EAAE,UAAU,EAAE,UAAU,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,GAAG,IAAI;IAG/F,cAAc,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI;CAGrC"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"has-many-BuTJfT5a.js","sources":["../src/-private/attr.ts","../src/-private/belongs-to.ts","../src/-private/has-many.ts"],"sourcesContent":["/**\n @module @ember-data/model\n*/\nimport { assert } from '@ember/debug';\nimport { computed } from '@ember/object';\n\nimport { recordIdentifierFor } from '@ember-data/store';\nimport { peekCache } from '@ember-data/store/-private';\nimport { DEBUG } from '@warp-drive/build-config/env';\nimport type { ArrayValue, ObjectValue, PrimitiveValue, Value } from '@warp-drive/core-types/json/raw';\nimport type { TransformName } from '@warp-drive/core-types/symbols';\n\nimport type { Model } from './model';\nimport type { DecoratorPropertyDescriptor } from './util';\nimport { isElementDescriptor } from './util';\n\n/**\n * Options provided to the attr decorator are\n * supplied to the associated transform. Any\n * key-value pair is valid; however, it is highly\n * recommended to only use statically defined values\n * that could be serialized to JSON.\n *\n * If no transform is provided, the only valid\n * option is `defaultValue`.\n *\n * Examples:\n *\n * ```ts\n * class User extends Model {\n * @attr('string', { defaultValue: 'Anonymous' }) name;\n * @attr('date', { defaultValue: () => new Date() }) createdAt;\n * @attr({ defaultValue: () => ({}) }) preferences;\n * @attr('boolean') hasVerifiedEmail;\n * @attr address;\n * }\n *\n * @class NOTATHING\n * @typedoc\n */\nexport type AttrOptions<DV = PrimitiveValue | object | unknown[]> = {\n /**\n * The default value for this attribute.\n *\n * Default values can be provided as a value or a function that will be\n * executed to generate the default value.\n *\n * Default values *should not* be stateful (object, arrays, etc.) as\n * they will be shared across all instances of the record.\n *\n * @typedoc\n */\n defaultValue?: DV extends PrimitiveValue ? DV : () => DV;\n};\n\nfunction _attr(type?: string | AttrOptions, options?: AttrOptions & object) {\n if (typeof type === 'object') {\n options = type;\n type = undefined;\n } else {\n options = options || {};\n }\n\n const meta = {\n type: type,\n kind: 'attribute',\n isAttribute: true,\n options: options,\n key: null,\n };\n\n return computed({\n get(this: Model, key: string) {\n if (DEBUG) {\n if (['currentState'].includes(key)) {\n throw new Error(\n `'${key}' is a reserved property name on instances of classes extending Model. Please choose a different property name for your attr on ${this.constructor.toString()}`\n );\n }\n }\n if (this.isDestroyed || this.isDestroying) {\n return;\n }\n return peekCache(this).getAttr(recordIdentifierFor(this), key);\n },\n set(this: Model, key: string, value: Value) {\n if (DEBUG) {\n if (['currentState'].includes(key)) {\n throw new Error(\n `'${key}' is a reserved property name on instances of classes extending Model. Please choose a different property name for your attr on ${this.constructor.toString()}`\n );\n }\n }\n const identifier = recordIdentifierFor(this);\n assert(\n `Attempted to set '${key}' on the deleted record ${identifier.type}:${identifier.id} (${identifier.lid})`,\n !this.currentState.isDeleted\n );\n const cache = peekCache(this);\n\n const currentValue = cache.getAttr(identifier, key);\n if (currentValue !== value) {\n cache.setAttr(identifier, key, value);\n\n if (!this.isValid) {\n const { errors } = this;\n if (errors.get(key)) {\n errors.remove(key);\n this.currentState.cleanErrorRequests();\n }\n }\n }\n\n return value;\n },\n }).meta(meta);\n}\n\n// NOTE: Usage of Explicit ANY\n// -------------------------------------------------------------------\n// any is required here because we are the maximal not the minimal\n// subset of options allowed. If we used unknown, object, or\n// Record<string, unknown> we would get type errors when we try to\n// assert against a more specific implementation with precise options.\n// -------------------------------------------------------------------\n\ntype LooseTransformInstance<V, Raw, Name extends string> = {\n /**\n * value type must match the return type of the deserialize method\n *\n * @typedoc\n */\n // see note on Explicit ANY above\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n serialize: (value: V, options: any) => Raw;\n /**\n * defaultValue type must match the return type of the deserialize method\n *\n * @typedoc\n */\n // see note on Explicit ANY above\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n deserialize: (value: Raw, options: any) => V;\n\n [TransformName]: Name;\n};\nexport type TransformHasType = { [TransformName]: string };\n\nexport type TypedTransformInstance<V, T extends string> =\n | LooseTransformInstance<V, string, T>\n | LooseTransformInstance<V, number, T>\n | LooseTransformInstance<V, boolean, T>\n | LooseTransformInstance<V, null, T>\n | LooseTransformInstance<V, ObjectValue, T>\n | LooseTransformInstance<V, ArrayValue, T>;\n\n// see note on Explicit ANY above\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport type GetMaybeDeserializeValue<T> = T extends { deserialize: (...args: any[]) => unknown }\n ? ReturnType<T['deserialize']>\n : never;\n\nexport type TypeFromInstance<T> = T extends TransformHasType ? T[typeof TransformName] : never;\nexport type OptionsFromInstance<T> =\n TypeFromInstance<T> extends never\n ? never\n : GetMaybeDeserializeValue<T> extends never\n ? never\n : T extends TypedTransformInstance<GetMaybeDeserializeValue<T>, TypeFromInstance<T>>\n ? Parameters<T['deserialize']>[1] & Parameters<T['serialize']>[1] & AttrOptions<ReturnType<T['deserialize']>>\n : never;\n\n/**\n * The return type of `void` is a lie to appease TypeScript. The actual return type\n * is a descriptor, but typescript incorrectly insists that decorator functions return\n * `void` or `any`.\n *\n * @typedoc\n */\nexport type DataDecorator = (target: object, key: string, desc?: DecoratorPropertyDescriptor) => void;\n\n/**\n `attr` defines an attribute on a [Model](/ember-data/release/classes/Model).\n By default, attributes are passed through as-is, however you can specify an\n optional type to have the value automatically transformed.\n EmberData ships with four basic transform types: `string`, `number`,\n `boolean` and `date`. You can define your own transforms by subclassing\n [Transform](/ember-data/release/classes/Transform).\n\n Note that you cannot use `attr` to define an attribute of `id`.\n\n `attr` takes an optional hash as a second parameter, currently\n supported options are:\n\n - `defaultValue`: Pass a string or a function to be called to set the attribute\n to a default value if and only if the key is absent from the payload response.\n\n Example\n\n ```app/models/user.js\n import Model, { attr } from '@ember-data/model';\n\n export default class UserModel extends Model {\n @attr('string') username;\n @attr('string') email;\n @attr('boolean', { defaultValue: false }) verified;\n }\n ```\n\n Default value can also be a function. This is useful it you want to return\n a new object for each attribute.\n\n ```app/models/user.js\n import Model, { attr } from '@ember-data/model';\n\n export default class UserModel extends Model {\n @attr('string') username;\n @attr('string') email;\n\n @attr({\n defaultValue() {\n return {};\n }\n })\n settings;\n }\n ```\n\n The `options` hash is passed as second argument to a transforms'\n `serialize` and `deserialize` method. This allows to configure a\n transformation and adapt the corresponding value, based on the config:\n\n ```app/models/post.js\n import Model, { attr } from '@ember-data/model';\n\n export default class PostModel extends Model {\n @attr('text', {\n uppercase: true\n })\n text;\n }\n ```\n\n ```app/transforms/text.js\n export default class TextTransform {\n serialize(value, options) {\n if (options.uppercase) {\n return value.toUpperCase();\n }\n\n return value;\n }\n\n deserialize(value) {\n return value;\n }\n\n static create() {\n return new this();\n }\n }\n ```\n\n @method attr\n @public\n @static\n @for @ember-data/model\n @param {String|Object} type the attribute type\n @param {Object} options a hash of options\n @return {Attribute}\n*/\nexport function attr(): DataDecorator;\nexport function attr<T>(type: TypeFromInstance<T>): DataDecorator;\nexport function attr(type: string): DataDecorator;\nexport function attr(options: AttrOptions): DataDecorator;\nexport function attr<T>(type: TypeFromInstance<T>, options?: OptionsFromInstance<T>): DataDecorator;\nexport function attr(type: string, options?: AttrOptions & object): DataDecorator;\nexport function attr(target: object, key: string | symbol, desc?: PropertyDescriptor): void; // see note on DataDecorator for why void\nexport function attr(\n type?: string | AttrOptions | object,\n options?: (AttrOptions & object) | string | symbol,\n desc?: PropertyDescriptor\n): DataDecorator | void {\n const args = [type, options, desc];\n // see note on DataDecorator for why void\n return isElementDescriptor(args) ? (_attr()(...args) as void) : _attr(type, options as object);\n}\n","import { assert, warn } from '@ember/debug';\nimport { computed } from '@ember/object';\n\nimport { DEBUG } from '@warp-drive/build-config/env';\nimport type { TypeFromInstance } from '@warp-drive/core-types/record';\nimport { RecordStore } from '@warp-drive/core-types/symbols';\n\nimport { lookupLegacySupport } from './legacy-relationships-support';\nimport type { MinimalLegacyRecord } from './model-methods';\nimport { isElementDescriptor, normalizeModelName } from './util';\n/**\n @module @ember-data/model\n*/\n\nexport type IsUnknown<T> = unknown extends T ? true : false;\n\nexport type RelationshipOptions<T, Async extends boolean> = {\n async: Async;\n inverse: null | (IsUnknown<T> extends true ? string : keyof NoNull<T> & string);\n polymorphic?: boolean;\n as?: string;\n resetOnRemoteUpdate?: boolean;\n};\n\nexport type NoNull<T> = Exclude<T, null>;\n// type BelongsToDecoratorObject<getT> = {\n// get: () => getT;\n// // set: (value: Awaited<getT>) => void;\n// set: (value: getT) => void;\n// // init: () => getT;\n// };\n// eslint-disable-next-line @typescript-eslint/no-unused-vars\nexport type RelationshipDecorator<T> = <This>(target: This, key: string, desc?: PropertyDescriptor) => void; // BelongsToDecoratorObject<getT>;\n\nfunction _belongsTo<T, Async extends boolean>(\n type: string,\n options: RelationshipOptions<T, Async>\n): RelationshipDecorator<T> {\n assert(\n `Expected options.async from @belongsTo('${type}', options) to be a boolean`,\n options && typeof options.async === 'boolean'\n );\n assert(\n `Expected options.inverse from @belongsTo('${type}', options) to be either null or the string type of the related resource.`,\n options.inverse === null || (typeof options.inverse === 'string' && options.inverse.length > 0)\n );\n\n const meta = {\n type: normalizeModelName(type),\n isRelationship: true,\n options: options,\n kind: 'belongsTo',\n name: '<Unknown BelongsTo>',\n key: null,\n };\n\n return computed({\n get<R extends MinimalLegacyRecord>(this: R, key: string) {\n // this is a legacy behavior we may not carry into a new model setup\n // it's better to error on disconnected records so users find errors\n // in their logic.\n if (this.isDestroying || this.isDestroyed) {\n return null;\n }\n const support = lookupLegacySupport(this);\n\n if (DEBUG) {\n if (['currentState'].includes(key)) {\n throw new Error(\n `'${key}' is a reserved property name on instances of classes extending Model. Please choose a different property name for your belongsTo on ${this.constructor.toString()}`\n );\n }\n if (Object.prototype.hasOwnProperty.call(options, 'serialize')) {\n warn(\n `You provided a serialize option on the \"${key}\" property in the \"${support.identifier.type}\" class, this belongs in the serializer. See Serializer and it's implementations https://api.emberjs.com/ember-data/release/classes/Serializer`,\n false,\n {\n id: 'ds.model.serialize-option-in-belongs-to',\n }\n );\n }\n\n if (Object.prototype.hasOwnProperty.call(options, 'embedded')) {\n warn(\n `You provided an embedded option on the \"${key}\" property in the \"${support.identifier.type}\" class, this belongs in the serializer. See EmbeddedRecordsMixin https://api.emberjs.com/ember-data/release/classes/EmbeddedRecordsMixin`,\n false,\n {\n id: 'ds.model.embedded-option-in-belongs-to',\n }\n );\n }\n }\n\n return support.getBelongsTo(key);\n },\n set<R extends MinimalLegacyRecord>(this: R, key: string, value: unknown) {\n const support = lookupLegacySupport(this);\n if (DEBUG) {\n if (['currentState'].includes(key)) {\n throw new Error(\n `'${key}' is a reserved property name on instances of classes extending Model. Please choose a different property name for your belongsTo on ${this.constructor.toString()}`\n );\n }\n }\n this[RecordStore]._join(() => {\n support.setDirtyBelongsTo(key, value);\n });\n\n return support.getBelongsTo(key);\n },\n }).meta(meta) as RelationshipDecorator<T>;\n}\n\n/**\n `belongsTo` is used to define One-To-One and One-To-Many, and One-To-None\n relationships on a [Model](/ember-data/release/classes/Model).\n\n `belongsTo` takes a configuration hash as a second parameter, currently\n supported options are:\n\n - `async`: (*required*) A boolean value used to declare whether this is a sync (false) or async (true) relationship.\n - `inverse`: (*required*) A string used to identify the inverse property on a related model, or `null`.\n - `polymorphic`: (*optional*) A boolean value to mark the relationship as polymorphic\n - `as`: (*optional*) A string used to declare the abstract type \"this\" record satisfies for polymorphism.\n\n ### Examples\n\n To declare a **one-to-many** (or many-to-many) relationship, use\n `belongsTo` in combination with `hasMany`:\n\n ```js\n // app/models/comment.js\n import Model, { belongsTo } from '@ember-data/model';\n\n export default class Comment extends Model {\n @belongsTo('post', { async: false, inverse: 'comments' }) post;\n }\n\n // app/models/post.js\n import Model, { hasMany } from '@ember-data/model';\n\n export default class Post extends Model {\n @hasMany('comment', { async: false, inverse: 'post' }) comments;\n }\n ```\n\n To declare a **one-to-one** relationship with managed inverses, use `belongsTo` for both sides:\n\n ```js\n // app/models/author.js\n import Model, { belongsTo } from '@ember-data/model';\n\n export default class Author extends Model {\n @belongsTo('address', { async: true, inverse: 'owner' }) address;\n }\n\n // app/models/address.js\n import Model, { belongsTo } from '@ember-data/model';\n\n export default class Address extends Model {\n @belongsTo('author', { async: true, inverse: 'address' }) owner;\n }\n ```\n\n To declare a **one-to-one** relationship without managed inverses, use `belongsTo` for both sides\n with `null` as the inverse:\n\n ```js\n // app/models/author.js\n import Model, { belongsTo } from '@ember-data/model';\n\n export default class Author extends Model {\n @belongsTo('address', { async: true, inverse: null }) address;\n }\n\n // app/models/address.js\n import Model, { belongsTo } from '@ember-data/model';\n\n export default class Address extends Model {\n @belongsTo('author', { async: true, inverse: null }) owner;\n }\n ```\n\n To declare a one-to-none relationship between two models, use\n `belongsTo` with inverse set to `null` on just one side::\n\n ```js\n // app/models/person.js\n import Model, { belongsTo } from '@ember-data/model';\n\n export default class Person extends Model {\n @belongsTo('person', { async: false, inverse: null }) bestFriend;\n }\n ```\n\n #### Sync vs Async Relationships\n\n EmberData fulfills relationships using resource data available in\n the cache.\n\n Sync relationships point directly to the known related resources.\n\n When a relationship is declared as async, if any of the known related\n resources have not been loaded, they will be fetched. The property\n on the record when accessed provides a promise that resolves once\n all resources are loaded.\n\n Async relationships may take advantage of links. On access, if the related\n link has not been loaded, or if any known resources are not available in\n the cache, the fresh state will be fetched using the link.\n\n In contrast to async relationship, accessing a sync relationship\n will error on access when any of the known related resources have\n not been loaded.\n\n If you are using `links` with sync relationships, you have to use\n the BelongsTo reference API to fetch or refresh related resources\n that aren't loaded. For instance, for a `bestFriend` relationship:\n\n ```js\n person.belongsTo('bestFriend').reload();\n ```\n\n #### Polymorphic Relationships\n\n To declare a polymorphic relationship, use `hasMany` with the `polymorphic`\n option set to `true`:\n\n ```js\n // app/models/comment.js\n import Model, { belongsTo } from '@ember-data/model';\n\n export default class Comment extends Model {\n @belongsTo('commentable', { async: false, inverse: 'comments', polymorphic: true }) parent;\n }\n ```\n\n `'commentable'` here is referred to as the \"abstract type\" for the polymorphic\n relationship.\n\n Polymorphic relationships with `inverse: null` will accept any type of record as their content.\n Polymorphic relationships with `inverse` set to a string will only accept records with a matching\n inverse relationships declaring itself as satisfying the abstract type.\n\n Below, 'as' is used to declare the that 'post' record satisfies the abstract type 'commentable'\n for this relationship.\n\n ```js\n // app/models/post.js\n import Model, { hasMany } from '@ember-data/model';\n\n export default class Post extends Model {\n @hasMany('comment', { async: false, inverse: 'parent', as: 'commentable' }) comments;\n }\n ```\n\n Note: every Model that declares an inverse to a polymorphic relationship must\n declare itself exactly the same. This is because polymorphism is based on structural\n traits.\n\n Polymorphic to polymorphic relationships are supported. Both sides of the relationship\n must be declared as polymorphic, and the `as` option must be used to declare the abstract\n type each record satisfies on both sides.\n\n @method belongsTo\n @public\n @static\n @for @ember-data/model\n @param {string} type (optional) the name of the related resource\n @param {object} options (optional) a hash of options\n @return {PropertyDescriptor} relationship\n*/\n\nexport function belongsTo(): never;\nexport function belongsTo(type: string): never;\nexport function belongsTo<T>(\n type: TypeFromInstance<NoNull<T>>,\n options: RelationshipOptions<T, boolean>\n): RelationshipDecorator<T>;\n// export function belongsTo<K extends Promise<unknown>, T extends Awaited<K> = Awaited<K>>(\n// type: TypeFromInstance<NoNull<T>>,\n// options: RelationshipOptions<T, true>\n// ): RelationshipDecorator<K>;\nexport function belongsTo(type: string, options: RelationshipOptions<unknown, boolean>): RelationshipDecorator<unknown>;\nexport function belongsTo<T>(\n type?: TypeFromInstance<NoNull<T>>,\n options?: RelationshipOptions<T, boolean>\n): RelationshipDecorator<T> {\n if (DEBUG) {\n assert(\n `belongsTo must be invoked with a type and options. Did you mean \\`@belongsTo(${type}, { async: false, inverse: null })\\`?`,\n !isElementDescriptor(arguments as unknown as unknown[])\n );\n }\n return _belongsTo(type!, options!);\n}\n","/**\n @module @ember-data/model\n*/\nimport { assert, deprecate } from '@ember/debug';\nimport { computed } from '@ember/object';\nimport { dasherize } from '@ember/string';\n\nimport { singularize } from 'ember-inflector';\n\nimport { DEPRECATE_NON_STRICT_TYPES } from '@warp-drive/build-config/deprecations';\nimport { DEBUG } from '@warp-drive/build-config/env';\nimport type { TypeFromInstance } from '@warp-drive/core-types/record';\nimport { RecordStore } from '@warp-drive/core-types/symbols';\n\nimport type { NoNull, RelationshipDecorator, RelationshipOptions } from './belongs-to';\nimport { lookupLegacySupport } from './legacy-relationships-support';\nimport type { MinimalLegacyRecord } from './model-methods';\nimport { isElementDescriptor } from './util';\n\nfunction normalizeType(type: string) {\n if (DEPRECATE_NON_STRICT_TYPES) {\n const result = singularize(dasherize(type));\n\n deprecate(\n `The resource type '${type}' is not normalized. Update your application code to use '${result}' instead of '${type}'.`,\n result === type,\n {\n id: 'ember-data:deprecate-non-strict-types',\n until: '6.0',\n for: 'ember-data',\n since: {\n available: '5.3',\n enabled: '5.3',\n },\n }\n );\n\n return result;\n }\n\n return type;\n}\n\nfunction _hasMany<T, Async extends boolean>(\n type: string,\n options: RelationshipOptions<T, Async>\n): RelationshipDecorator<T> {\n assert(`Expected hasMany options.async to be a boolean`, options && typeof options.async === 'boolean');\n\n // Metadata about relationships is stored on the meta of\n // the relationship. This is used for introspection and\n // serialization. Note that `key` is populated lazily\n // the first time the CP is called.\n const meta = {\n type: normalizeType(type),\n options,\n isRelationship: true,\n kind: 'hasMany',\n name: '<Unknown BelongsTo>',\n key: null,\n };\n\n return computed({\n get<R extends MinimalLegacyRecord>(this: R, key: string) {\n if (DEBUG) {\n if (['currentState'].includes(key)) {\n throw new Error(\n `'${key}' is a reserved property name on instances of classes extending Model. Please choose a different property name for your hasMany on ${this.constructor.toString()}`\n );\n }\n }\n if (this.isDestroying || this.isDestroyed) {\n return [];\n }\n return lookupLegacySupport(this).getHasMany(key);\n },\n set<R extends MinimalLegacyRecord>(this: R, key: string, records: T[]) {\n if (DEBUG) {\n if (['currentState'].includes(key)) {\n throw new Error(\n `'${key}' is a reserved property name on instances of classes extending Model. Please choose a different property name for your hasMany on ${this.constructor.toString()}`\n );\n }\n }\n const support = lookupLegacySupport(this);\n const manyArray = support.getManyArray(key);\n assert(`You must pass an array of records to set a hasMany relationship`, Array.isArray(records));\n this[RecordStore]._join(() => {\n manyArray.splice(0, manyArray.length, ...records);\n });\n\n return support.getHasMany(key);\n },\n }).meta(meta);\n}\n\n/**\n `hasMany` is used to define Many-To-One and Many-To-Many, and Many-To-None\n relationships on a [Model](/ember-data/release/classes/Model).\n\n `hasMany` takes a configuration hash as a second parameter, currently\n supported options are:\n\n - `async`: (*required*) A boolean value used to declare whether this is a sync (false) or async (true) relationship.\n - `inverse`: (*required*) A string used to identify the inverse property on a related model, or `null`.\n - `polymorphic`: (*optional*) A boolean value to mark the relationship as polymorphic\n - `as`: (*optional*) A string used to declare the abstract type \"this\" record satisfies for polymorphism.\n\n ### Examples\n\n To declare a **many-to-one** (or one-to-many) relationship, use\n `belongsTo` in combination with `hasMany`:\n\n ```js\n // app/models/post.js\n import Model, { hasMany } from '@ember-data/model';\n\n export default class Post extends Model {\n @hasMany('comment', { async: false, inverse: 'post' }) comments;\n }\n\n\n // app/models/comment.js\n import Model, { belongsTo } from '@ember-data/model';\n\n export default class Comment extends Model {\n @belongsTo('post', { async: false, inverse: 'comments' }) post;\n }\n ```\n\n To declare a **many-to-many** relationship with managed inverses, use `hasMany` for both sides:\n\n ```js\n // app/models/post.js\n import Model, { hasMany } from '@ember-data/model';\n\n export default class Post extends Model {\n @hasMany('tag', { async: true, inverse: 'posts' }) tags;\n }\n\n // app/models/tag.js\n import Model, { hasMany } from '@ember-data/model';\n\n export default class Tag extends Model {\n @hasMany('post', { async: true, inverse: 'tags' }) posts;\n }\n ```\n\n To declare a **many-to-many** relationship without managed inverses, use `hasMany` for both sides\n with `null` as the inverse:\n\n ```js\n // app/models/post.js\n import Model, { hasMany } from '@ember-data/model';\n\n export default class Post extends Model {\n @hasMany('tag', { async: true, inverse: null }) tags;\n }\n\n // app/models/tag.js\n import Model, { hasMany } from '@ember-data/model';\n\n export default class Tag extends Model {\n @hasMany('post', { async: true, inverse: null }) posts;\n }\n ```\n\n To declare a many-to-none relationship between two models, use\n `hasMany` with inverse set to `null` on just one side::\n\n ```js\n // app/models/post.js\n import Model, { hasMany } from '@ember-data/model';\n\n export default class Post extends Model {\n @hasMany('category', { async: true, inverse: null }) categories;\n }\n ```\n\n #### Sync vs Async Relationships\n\n EmberData fulfills relationships using resource data available in\n the cache.\n\n Sync relationships point directly to the known related resources.\n\n When a relationship is declared as async, if any of the known related\n resources have not been loaded, they will be fetched. The property\n on the record when accessed provides a promise that resolves once\n all resources are loaded.\n\n Async relationships may take advantage of links. On access, if the related\n link has not been loaded, or if any known resources are not available in\n the cache, the fresh state will be fetched using the link.\n\n In contrast to async relationship, accessing a sync relationship\n will error on access when any of the known related resources have\n not been loaded.\n\n If you are using `links` with sync relationships, you have to use\n the HasMany reference API to fetch or refresh related resources\n that aren't loaded. For instance, for a `comments` relationship:\n\n ```js\n post.hasMany('comments').reload();\n ```\n\n #### Polymorphic Relationships\n\n To declare a polymorphic relationship, use `hasMany` with the `polymorphic`\n option set to `true`:\n\n ```js\n // app/models/comment.js\n import Model, { belongsTo } from '@ember-data/model';\n\n export default class Comment extends Model {\n @belongsTo('commentable', { async: false, inverse: 'comments', polymorphic: true }) parent;\n }\n ```\n\n `'commentable'` here is referred to as the \"abstract type\" for the polymorphic\n relationship.\n\n Polymorphic relationships with `inverse: null` will accept any type of record as their content.\n Polymorphic relationships with `inverse` set to a string will only accept records with a matching\n inverse relationships declaring itself as satisfying the abstract type.\n\n Below, 'as' is used to declare the that 'post' record satisfies the abstract type 'commentable'\n for this relationship.\n\n ```js\n // app/models/post.js\n import Model, { hasMany } from '@ember-data/model';\n\n export default class Post extends Model {\n @hasMany('comment', { async: false, inverse: 'parent', as: 'commentable' }) comments;\n }\n ```\n\n Note: every Model that declares an inverse to a polymorphic relationship must\n declare itself exactly the same. This is because polymorphism is based on structural\n traits.\n\n Polymorphic to polymorphic relationships are supported. Both sides of the relationship\n must be declared as polymorphic, and the `as` option must be used to declare the abstract\n type each record satisfies on both sides.\n\n @method hasMany\n @public\n @static\n @for @ember-data/model\n @param {string} type (optional) the name of the related resource\n @param {object} options (optional) a hash of options\n @return {PropertyDescriptor} relationship\n*/\nexport function hasMany(): never;\nexport function hasMany(type: string): never;\nexport function hasMany<T>(\n type: TypeFromInstance<NoNull<T>>,\n options: RelationshipOptions<T, boolean>\n): RelationshipDecorator<T>;\n// export function hasMany<K extends Promise<unknown>, T extends Awaited<K> = Awaited<K>>(\n// type: TypeFromInstance<NoNull<T>>,\n// options: RelationshipOptions<T, true>\n// ): RelationshipDecorator<K>;\nexport function hasMany(type: string, options: RelationshipOptions<unknown, boolean>): RelationshipDecorator<unknown>;\nexport function hasMany<T>(\n type?: TypeFromInstance<NoNull<T>>,\n options?: RelationshipOptions<T, boolean>\n): RelationshipDecorator<T> {\n if (DEBUG) {\n assert(\n `hasMany must be invoked with a type and options. Did you mean \\`@hasMany(${type}, { async: false, inverse: null })\\`?`,\n !isElementDescriptor(arguments as unknown as unknown[])\n );\n }\n return _hasMany(type!, options!);\n}\n"],"names":["_attr","type","options","undefined","meta","kind","isAttribute","key","computed","get","macroCondition","getOwnConfig","env","DEBUG","includes","Error","constructor","toString","isDestroyed","isDestroying","peekCache","getAttr","recordIdentifierFor","set","value","identifier","assert","id","lid","currentState","isDeleted","cache","currentValue","setAttr","isValid","errors","remove","cleanErrorRequests","attr","desc","args","isElementDescriptor","_belongsTo","async","inverse","length","normalizeModelName","isRelationship","name","support","lookupLegacySupport","Object","prototype","hasOwnProperty","call","warn","getBelongsTo","RecordStore","_join","setDirtyBelongsTo","belongsTo","arguments","normalizeType","deprecations","DEPRECATE_NON_STRICT_TYPES","result","singularize","dasherize","deprecate","until","for","since","available","enabled","_hasMany","getHasMany","records","manyArray","getManyArray","Array","isArray","splice","has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AACA;;AAgCA;AACA;;AAeA;AACA;AACA;AACA;AACA;AACA;AACA;;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAO6F;AACtF,SAASkC,IAAIA,CAClBrC,IAAoC,EACpCC,OAAkD,EAClDqC,IAAyB,EACH;EACtB,MAAMC,IAAI,GAAG,CAACvC,IAAI,EAAEC,OAAO,EAAEqC,IAAI,CAAC,CAAA;AAClC;AACA,EAAA,OAAOE,mBAAmB,CAACD,IAAI,CAAC,GAAIxC,KAAK,EAAE,CAAC,GAAGwC,IAAI,CAAC,GAAYxC,KAAK,CAACC,IAAI,EAAEC,OAAiB,CAAC,CAAA;AAChG;;ACpQA;AACA;AACA;AACA;AACA;AACA;AAC6G;;AAE7G,SAASwC,UAAUA,CACjBzC,IAAY,EACZC,OAAsC,EACZ;AAC1BwB,EAAAA,MAAM,CACH,CAAA,wCAAA,EAA0CzB,IAAK,CAAA,2BAAA,CAA4B,EAC5EC,OAAO,IAAI,OAAOA,OAAO,CAACyC,KAAK,KAAK,SACtC,CAAC,CAAA;EACDjB,MAAM,CACH,CAA4CzB,0CAAAA,EAAAA,IAAK,CAA0E,yEAAA,CAAA,EAC5HC,OAAO,CAAC0C,OAAO,KAAK,IAAI,IAAK,OAAO1C,OAAO,CAAC0C,OAAO,KAAK,QAAQ,IAAI1C,OAAO,CAAC0C,OA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ACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAQA;AACA;AACA;AACA;;AAEO,SAASwD,SAASA,CACvB3D,IAAkC,EAClCC,OAAyC,EACf;AAC1B,EAAA,IAAAQ,cAAA,CAAAC,YAAA,GAAAC,GAAA,CAAAC,KAAA,CAAW,EAAA;IACTa,MAAM,CACH,CAA+EzB,6EAAAA,EAAAA,IAAK,CAAsC,qCAAA,CAAA,EAC3H,CAACwC,mBAAmB,CAACoB,SAAiC,CACxD,CAAC,CAAA;AACH,GAAA;AACA,EAAA,OAAOnB,UAAU,CAACzC,IAAI,EAAGC,OAAQ,CAAC,CAAA;AACpC;;ACvSA;AACA;AACA;AAiBA,SAAS4D,aAAaA,CAAC7D,IAAY,EAAE;AACnC,EAAA,IAAAS,cAAA,CAAAC,YAAA,GAAAoD,YAAA,CAAAC,0BAAA,CAAgC,EAAA;IAC9B,MAAMC,MAAM,GAAGC,WAAW,CAACC,SAAS,CAAClE,IAAI,CAAC,CAAC,CAAA;AAE3CmE,IAAAA,SAAS,CACN,CAAA,mBAAA,EAAq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ACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAOA;AACA;AACA;AACA;;AAEO,SAAS8E,OAAOA,CACrBjF,IAAkC,EAClCC,OAAyC,EACf;AAC1B,EAAA,IAAAQ,cAAA,CAAAC,YAAA,GAAAC,GAAA,CAAAC,KAAA,CAAW,EAAA;IACTa,MAAM,CACH,CAA2EzB,yEAAAA,EAAAA,IAAK,CAAsC,qCAAA,CAAA,EACvH,CAACwC,mBAAmB,CAACoB,SAAiC,CACxD,CAAC,CAAA;AACH,GAAA;AACA,EAAA,OAAOa,QAAQ,CAACzE,IAAI,EAAGC,OAAQ,CAAC,CAAA;AAClC;;;;"}
@@ -1,176 +0,0 @@
1
- import { getOwner, setOwner } from '@ember/application';
2
- import { assert } from '@ember/debug';
3
- import { setRecordIdentifier, StoreMap, setCacheFor } from '@ember-data/store/-private';
4
- import { M as Model } from "./model-DJ9C4aZ-";
5
- import { n as normalizeModelName } from "./util-CSYkrwfb";
6
-
7
- /*
8
- In case someone defined a relationship to a mixin, for example:
9
- ```ts
10
- class CommentModel extends Model {
11
- @belongsTo('commentable', { polymorphic: true }) owner;
12
- }
13
-
14
- let Commentable = Mixin.create({
15
- @hasMany('comment') comments;
16
- });
17
- ```
18
- we want to look up a Commentable class which has all the necessary
19
- relationship meta data. Thus, we look up the mixin and create a mock
20
- Model, so we can access the relationship CPs of the mixin (`comments`)
21
- in this case
22
- */
23
- function modelForMixin(store, normalizedModelName) {
24
- const owner = getOwner(store);
25
- const MaybeMixin = owner.factoryFor(`mixin:${normalizedModelName}`);
26
- const mixin = MaybeMixin && MaybeMixin.class;
27
- if (mixin) {
28
- const ModelForMixin = Model.extend(mixin);
29
- ModelForMixin.__isMixin = true;
30
- ModelForMixin.__mixin = mixin;
31
- //Cache the class as a model
32
- owner.register(`model:${normalizedModelName}`, ModelForMixin);
33
- }
34
- return owner.factoryFor(`model:${normalizedModelName}`);
35
- }
36
- class ModelSchemaProvider {
37
- constructor(store) {
38
- this.store = store;
39
- this._relationshipsDefCache = Object.create(null);
40
- this._attributesDefCache = Object.create(null);
41
- this._fieldsDefCache = Object.create(null);
42
- }
43
- fields(identifier) {
44
- const {
45
- type
46
- } = identifier;
47
- let fieldDefs = this._fieldsDefCache[type];
48
- if (fieldDefs === undefined) {
49
- fieldDefs = new Map();
50
- this._fieldsDefCache[type] = fieldDefs;
51
- const attributes = this.attributesDefinitionFor(identifier);
52
- const relationships = this.relationshipsDefinitionFor(identifier);
53
- for (const attr of Object.values(attributes)) {
54
- fieldDefs.set(attr.name, attr);
55
- }
56
- for (const rel of Object.values(relationships)) {
57
- fieldDefs.set(rel.name, rel);
58
- }
59
- }
60
- return fieldDefs;
61
- }
62
-
63
- // Following the existing RD implementation
64
- attributesDefinitionFor(identifier) {
65
- const {
66
- type
67
- } = identifier;
68
- let attributes;
69
- attributes = this._attributesDefCache[type];
70
- if (attributes === undefined) {
71
- const modelClass = this.store.modelFor(type);
72
- const attributeMap = modelClass.attributes;
73
- attributes = Object.create(null);
74
- attributeMap.forEach((meta, name) => attributes[name] = meta);
75
- this._attributesDefCache[type] = attributes;
76
- }
77
- return attributes;
78
- }
79
-
80
- // Following the existing RD implementation
81
- relationshipsDefinitionFor(identifier) {
82
- const {
83
- type
84
- } = identifier;
85
- let relationships;
86
- relationships = this._relationshipsDefCache[type];
87
- if (relationships === undefined) {
88
- const modelClass = this.store.modelFor(type);
89
- relationships = modelClass.relationshipsObject || null;
90
- this._relationshipsDefCache[type] = relationships;
91
- }
92
- return relationships;
93
- }
94
- doesTypeExist(modelName) {
95
- const type = normalizeModelName(modelName);
96
- const factory = getModelFactory(this.store, type);
97
- return factory !== null;
98
- }
99
- }
100
- function buildSchema(store) {
101
- return new ModelSchemaProvider(store);
102
- }
103
- function getModelFactory(store, type) {
104
- if (!store._modelFactoryCache) {
105
- store._modelFactoryCache = Object.create(null);
106
- }
107
- const cache = store._modelFactoryCache;
108
- let factory = cache[type];
109
- if (!factory) {
110
- const owner = getOwner(store);
111
- factory = owner.factoryFor(`model:${type}`);
112
- if (!factory) {
113
- //Support looking up mixins as base types for polymorphic relationships
114
- factory = modelForMixin(store, type);
115
- }
116
- if (!factory) {
117
- // we don't cache misses in case someone wants to register a missing model
118
- return null;
119
- }
120
- const klass = factory.class;
121
- if (klass.isModel) {
122
- const hasOwnModelNameSet = klass.modelName && Object.prototype.hasOwnProperty.call(klass, 'modelName');
123
- if (!hasOwnModelNameSet) {
124
- Object.defineProperty(klass, 'modelName', {
125
- value: type
126
- });
127
- }
128
- }
129
- cache[type] = factory;
130
- }
131
- return factory;
132
- }
133
- function instantiateRecord(identifier, createRecordArgs) {
134
- const type = identifier.type;
135
- const cache = this.cache;
136
- // TODO deprecate allowing unknown args setting
137
- const createOptions = {
138
- _createProps: createRecordArgs,
139
- // TODO @deprecate consider deprecating accessing record properties during init which the below is necessary for
140
- _secretInit: {
141
- identifier,
142
- cache,
143
- store: this,
144
- cb: secretInit
145
- }
146
- };
147
-
148
- // ensure that `getOwner(this)` works inside a model instance
149
- setOwner(createOptions, getOwner(this));
150
- const factory = getModelFactory(this, type);
151
- assert(`No model was found for '${type}'`, factory);
152
- return factory.class.create(createOptions);
153
- }
154
- function teardownRecord(record) {
155
- assert(`expected to receive an instance of Model from @ember-data/model. If using a custom model make sure you implement teardownRecord`, 'destroy' in record);
156
- record.destroy();
157
- }
158
- function modelFor(modelName) {
159
- assert(`Attempted to call store.modelFor(), but the store instance has already been destroyed.`, !this.isDestroyed && !this.isDestroying);
160
- assert(`You need to pass a model name to the store's modelFor method`, modelName);
161
- assert(`Please pass a proper model name to the store's modelFor method`, typeof modelName === 'string' && modelName.length);
162
- const type = normalizeModelName(modelName);
163
- const maybeFactory = getModelFactory(this, type);
164
- const klass = maybeFactory && maybeFactory.class ? maybeFactory.class : null;
165
- const ignoreType = !klass || !klass.isModel || this._forceShim;
166
- if (!ignoreType) {
167
- return klass;
168
- }
169
- assert(`No model was found for '${type}' and no schema handles the type`, this.getSchemaDefinitionService().doesTypeExist(type));
170
- }
171
- function secretInit(record, cache, identifier, store) {
172
- setRecordIdentifier(record, identifier);
173
- StoreMap.set(record, store);
174
- setCacheFor(record, cache);
175
- }
176
- export { ModelSchemaProvider as M, buildSchema as b, instantiateRecord as i, modelFor as m, teardownRecord as t };