@ember-data/model 5.4.0-alpha.14 → 5.4.0-alpha.140

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 (87) hide show
  1. package/README.md +19 -0
  2. package/addon-main.cjs +5 -0
  3. package/blueprints/model/index.js +18 -5
  4. package/blueprints/model-test/index.js +16 -10
  5. package/blueprints/model-test/qunit-files/__root__/__path__/__test__.js +4 -5
  6. package/dist/-private.js +3 -0
  7. package/{addon → dist}/-private.js.map +1 -1
  8. package/dist/has-many-CZ2v_WT1.js +674 -0
  9. package/dist/has-many-CZ2v_WT1.js.map +1 -0
  10. package/dist/hooks-BXXZ6FSQ.js +75 -0
  11. package/dist/hooks-BXXZ6FSQ.js.map +1 -0
  12. package/dist/hooks.js +2 -0
  13. package/{addon → dist}/hooks.js.map +1 -1
  14. package/dist/index.js +5 -0
  15. package/{addon → dist}/index.js.map +1 -1
  16. package/dist/migration-support.js +210 -0
  17. package/dist/migration-support.js.map +1 -0
  18. package/{addon/model-498f8197.js → dist/model-CRnavZCc.js} +2800 -2646
  19. package/dist/model-CRnavZCc.js.map +1 -0
  20. package/dist/schema-provider-D_VKN7Wh.js +256 -0
  21. package/dist/schema-provider-D_VKN7Wh.js.map +1 -0
  22. package/ember-data-logo-dark.svg +12 -0
  23. package/ember-data-logo-light.svg +12 -0
  24. package/package.json +84 -47
  25. package/unstable-preview-types/-private/attr.d.ts +175 -0
  26. package/unstable-preview-types/-private/attr.d.ts.map +1 -0
  27. package/unstable-preview-types/-private/attr.type-test.d.ts +4 -0
  28. package/unstable-preview-types/-private/attr.type-test.d.ts.map +1 -0
  29. package/unstable-preview-types/-private/belongs-to.d.ts +181 -0
  30. package/unstable-preview-types/-private/belongs-to.d.ts.map +1 -0
  31. package/unstable-preview-types/-private/belongs-to.type-test.d.ts +4 -0
  32. package/unstable-preview-types/-private/belongs-to.type-test.d.ts.map +1 -0
  33. package/unstable-preview-types/-private/debug/assert-polymorphic-type.d.ts +8 -0
  34. package/unstable-preview-types/-private/debug/assert-polymorphic-type.d.ts.map +1 -0
  35. package/unstable-preview-types/-private/errors.d.ts +303 -0
  36. package/unstable-preview-types/-private/errors.d.ts.map +1 -0
  37. package/unstable-preview-types/-private/has-many.d.ts +169 -0
  38. package/unstable-preview-types/-private/has-many.d.ts.map +1 -0
  39. package/unstable-preview-types/-private/has-many.type-test.d.ts +4 -0
  40. package/unstable-preview-types/-private/has-many.type-test.d.ts.map +1 -0
  41. package/unstable-preview-types/-private/hooks.d.ts +13 -0
  42. package/unstable-preview-types/-private/hooks.d.ts.map +1 -0
  43. package/unstable-preview-types/-private/legacy-relationships-support.d.ts +60 -0
  44. package/unstable-preview-types/-private/legacy-relationships-support.d.ts.map +1 -0
  45. package/unstable-preview-types/-private/model-for-mixin.d.ts +6 -0
  46. package/unstable-preview-types/-private/model-for-mixin.d.ts.map +1 -0
  47. package/unstable-preview-types/-private/model-methods.d.ts +37 -0
  48. package/unstable-preview-types/-private/model-methods.d.ts.map +1 -0
  49. package/unstable-preview-types/-private/model.d.ts +1303 -0
  50. package/unstable-preview-types/-private/model.d.ts.map +1 -0
  51. package/unstable-preview-types/-private/model.type-test.d.ts +4 -0
  52. package/unstable-preview-types/-private/model.type-test.d.ts.map +1 -0
  53. package/unstable-preview-types/-private/notify-changes.d.ts +8 -0
  54. package/unstable-preview-types/-private/notify-changes.d.ts.map +1 -0
  55. package/unstable-preview-types/-private/promise-belongs-to.d.ts +46 -0
  56. package/unstable-preview-types/-private/promise-belongs-to.d.ts.map +1 -0
  57. package/unstable-preview-types/-private/promise-many-array.d.ts +131 -0
  58. package/unstable-preview-types/-private/promise-many-array.d.ts.map +1 -0
  59. package/unstable-preview-types/-private/record-state.d.ts +90 -0
  60. package/unstable-preview-types/-private/record-state.d.ts.map +1 -0
  61. package/unstable-preview-types/-private/references/belongs-to.d.ts +503 -0
  62. package/unstable-preview-types/-private/references/belongs-to.d.ts.map +1 -0
  63. package/unstable-preview-types/-private/references/has-many.d.ts +515 -0
  64. package/unstable-preview-types/-private/references/has-many.d.ts.map +1 -0
  65. package/unstable-preview-types/-private/schema-provider.d.ts +64 -0
  66. package/unstable-preview-types/-private/schema-provider.d.ts.map +1 -0
  67. package/unstable-preview-types/-private/type-utils.d.ts +64 -0
  68. package/unstable-preview-types/-private/type-utils.d.ts.map +1 -0
  69. package/unstable-preview-types/-private/util.d.ts +8 -0
  70. package/unstable-preview-types/-private/util.d.ts.map +1 -0
  71. package/unstable-preview-types/-private.d.ts +13 -0
  72. package/unstable-preview-types/-private.d.ts.map +1 -0
  73. package/unstable-preview-types/hooks.d.ts +5 -0
  74. package/unstable-preview-types/hooks.d.ts.map +1 -0
  75. package/unstable-preview-types/index.d.ts +75 -0
  76. package/unstable-preview-types/index.d.ts.map +1 -0
  77. package/unstable-preview-types/migration-support.d.ts +63 -0
  78. package/unstable-preview-types/migration-support.d.ts.map +1 -0
  79. package/addon/-private.js +0 -2
  80. package/addon/has-many-660c2e2c.js +0 -507
  81. package/addon/has-many-660c2e2c.js.map +0 -1
  82. package/addon/hooks-c8f587af.js +0 -157
  83. package/addon/hooks-c8f587af.js.map +0 -1
  84. package/addon/hooks.js +0 -1
  85. package/addon/index.js +0 -3
  86. package/addon/model-498f8197.js.map +0 -1
  87. package/addon-main.js +0 -93
@@ -0,0 +1,13 @@
1
+ declare module '@ember-data/model/-private' {
2
+ export { attr } from '@ember-data/model/-private/attr';
3
+ export { belongsTo } from '@ember-data/model/-private/belongs-to';
4
+ export { hasMany } from '@ember-data/model/-private/has-many';
5
+ export { Model } from '@ember-data/model/-private/model';
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/store/-private';
9
+ export { PromiseBelongsTo } from '@ember-data/model/-private/promise-belongs-to';
10
+ export { PromiseManyArray } from '@ember-data/model/-private/promise-many-array';
11
+ export { lookupLegacySupport, LEGACY_SUPPORT } from '@ember-data/model/-private/legacy-relationships-support';
12
+ }
13
+ //# sourceMappingURL=-private.d.ts.map
@@ -0,0 +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,YAAY,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AACnD,OAAO,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAE3C,OAAO,EAAE,iBAAiB,IAAI,SAAS,EAAE,MAAM,4BAA4B,CAAC;AAC5E,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"}
@@ -0,0 +1,5 @@
1
+ declare module '@ember-data/model/hooks' {
2
+ export { instantiateRecord, teardownRecord, modelFor } from '@ember-data/model/-private/hooks';
3
+ export { buildSchema } from '@ember-data/model/-private/schema-provider';
4
+ }
5
+ //# sourceMappingURL=hooks.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"hooks.d.ts","sourceRoot":"","sources":["../src/hooks.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,cAAc,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAC/E,OAAO,EAAE,WAAW,EAAE,MAAM,4BAA4B,CAAC"}
@@ -0,0 +1,75 @@
1
+ /// <reference path="./hooks.d.ts" />
2
+ /// <reference path="./-private.d.ts" />
3
+ /// <reference path="./migration-support.d.ts" />
4
+ /// <reference path="./-private/model-for-mixin.d.ts" />
5
+ /// <reference path="./-private/hooks.d.ts" />
6
+ /// <reference path="./-private/has-many.type-test.d.ts" />
7
+ /// <reference path="./-private/model.d.ts" />
8
+ /// <reference path="./-private/notify-changes.d.ts" />
9
+ /// <reference path="./-private/promise-belongs-to.d.ts" />
10
+ /// <reference path="./-private/attr.d.ts" />
11
+ /// <reference path="./-private/belongs-to.d.ts" />
12
+ /// <reference path="./-private/schema-provider.d.ts" />
13
+ /// <reference path="./-private/record-state.d.ts" />
14
+ /// <reference path="./-private/model.type-test.d.ts" />
15
+ /// <reference path="./-private/has-many.d.ts" />
16
+ /// <reference path="./-private/legacy-relationships-support.d.ts" />
17
+ /// <reference path="./-private/type-utils.d.ts" />
18
+ /// <reference path="./-private/util.d.ts" />
19
+ /// <reference path="./-private/belongs-to.type-test.d.ts" />
20
+ /// <reference path="./-private/errors.d.ts" />
21
+ /// <reference path="./-private/model-methods.d.ts" />
22
+ /// <reference path="./-private/promise-many-array.d.ts" />
23
+ /// <reference path="./-private/attr.type-test.d.ts" />
24
+ /// <reference path="./-private/references/belongs-to.d.ts" />
25
+ /// <reference path="./-private/references/has-many.d.ts" />
26
+ /// <reference path="./-private/debug/assert-polymorphic-type.d.ts" />
27
+ declare module '@ember-data/model' {
28
+ /**
29
+ * This package provides a Presentation Model for resource data in an EmberData Cache.
30
+ *
31
+ * Models are defined as classes extending from `import Model from '@ember-data/model';` and the
32
+ * attributes and relationships on these classes are parsed at runtime to supply static "schema"
33
+ * to EmberData's SchemaService.
34
+ *
35
+ * Resource data for individual resources fetched from your API is presented to the UI via instances
36
+ * of the `Model`s you define. An instantiated `Model` is referred to as a `record`.
37
+
38
+ When we refer to the `ModelClass` as opposed to a `Model` or `Record` we are referring
39
+ specifically to the class definition and the static schema methods present on it.
40
+
41
+ When we refer to a `record` we refer to a specific class instance presenting
42
+ the resource data for a given `type` and `id`.
43
+
44
+ ### Defining a Model
45
+
46
+ ```app/models/person.js
47
+ import Model, { attr, belongsTo, hasMany } from '@ember-data/model';
48
+
49
+ export default class PersonModel extends Model {
50
+ @attr name;
51
+
52
+ @belongsTo('pet', { inverse: 'owners', async: false }) dog;
53
+
54
+ @hasMany('person', { inverse: 'friends', async: true }) friends;
55
+ }
56
+ ```
57
+
58
+ ### modelName convention
59
+
60
+ By convention, the name of a given model (its `type`) matches the name
61
+ of the file in the `app/models` folder and should be lowercase, singular
62
+ and dasherized.
63
+
64
+ @module @ember-data/model
65
+ @main @ember-data/model
66
+ */
67
+ export { Model as default, attr, belongsTo, hasMany } from '@ember-data/model/-private';
68
+ export type { PromiseBelongsTo as AsyncBelongsTo } from '@ember-data/model/-private/promise-belongs-to';
69
+ export type { PromiseManyArray as AsyncHasMany } from '@ember-data/model/-private/promise-many-array';
70
+ export type { RelatedCollection as ManyArray } from '@ember-data/store/-private';
71
+ export type { RelatedCollection as HasMany } from '@ember-data/store/-private';
72
+ export { instantiateRecord, teardownRecord, modelFor } from '@ember-data/model/-private/hooks';
73
+ export { ModelSchemaProvider } from '@ember-data/model/-private/schema-provider';
74
+ }
75
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +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,gBAAgB,IAAI,YAAY,EAAE,MAAM,+BAA+B,CAAC;AACtF,YAAY,EAAE,iBAAiB,IAAI,SAAS,EAAE,MAAM,4BAA4B,CAAC;AACjF,YAAY,EAAE,iBAAiB,IAAI,OAAO,EAAE,MAAM,4BAA4B,CAAC;AAC/E,OAAO,EAAE,iBAAiB,EAAE,cAAc,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAC/E,OAAO,EAAE,mBAAmB,EAAE,MAAM,4BAA4B,CAAC"}
@@ -0,0 +1,63 @@
1
+ declare module '@ember-data/model/migration-support' {
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 { TypedRecordInstance } from '@warp-drive/core-types/record';
7
+ import type { Derivation, HashFn, Transformation } from '@warp-drive/core-types/schema/concepts';
8
+ import type { ArrayField, DerivedField, FieldSchema, GenericField, HashField, ObjectField, ResourceSchema } from '@warp-drive/core-types/schema/fields';
9
+ import type { WithPartial } from '@warp-drive/core-types/utils';
10
+ import type { MinimalLegacyRecord } from '@ember-data/model/-private/model-methods';
11
+ import { belongsTo, hasMany } from '@ember-data/model/-private/model-methods';
12
+ export type WithLegacyDerivations<T extends TypedRecordInstance> = T & MinimalLegacyRecord & {
13
+ belongsTo: typeof belongsTo;
14
+ hasMany: typeof hasMany;
15
+ };
16
+ type AttributesSchema = ReturnType<Exclude<SchemaService['attributesDefinitionFor'], undefined>>;
17
+ type RelationshipsSchema = ReturnType<Exclude<SchemaService['relationshipsDefinitionFor'], undefined>>;
18
+ export function withDefaults(schema: WithPartial<ResourceSchema, 'legacy' | 'identity'>): ResourceSchema;
19
+ export function registerDerivations(schema: SchemaService): void;
20
+ export interface DelegatingSchemaService {
21
+ attributesDefinitionFor?(resource: StableRecordIdentifier | {
22
+ type: string;
23
+ }): AttributesSchema;
24
+ relationshipsDefinitionFor?(resource: StableRecordIdentifier | {
25
+ type: string;
26
+ }): RelationshipsSchema;
27
+ doesTypeExist?(type: string): boolean;
28
+ }
29
+ export class DelegatingSchemaService implements SchemaService {
30
+ _preferred: SchemaService;
31
+ _secondary: SchemaService;
32
+ constructor(store: Store, schema: SchemaService);
33
+ hasResource(resource: StableRecordIdentifier | {
34
+ type: string;
35
+ }): boolean;
36
+ hasTrait(type: string): boolean;
37
+ resourceHasTrait(resource: StableRecordIdentifier | {
38
+ type: string;
39
+ }, trait: string): boolean;
40
+ fields(resource: StableRecordIdentifier | {
41
+ type: string;
42
+ }): Map<string, FieldSchema>;
43
+ transformation(field: GenericField | ObjectField | ArrayField | {
44
+ type: string;
45
+ }): Transformation;
46
+ hashFn(field: HashField | {
47
+ type: string;
48
+ }): HashFn;
49
+ derivation(field: DerivedField | {
50
+ type: string;
51
+ }): Derivation;
52
+ resource(resource: StableRecordIdentifier | {
53
+ type: string;
54
+ }): ResourceSchema;
55
+ registerResources(schemas: ResourceSchema[]): void;
56
+ registerResource(schema: ResourceSchema): void;
57
+ registerTransformation(transform: Transformation): void;
58
+ registerDerivation<R, T, FM extends ObjectValue | null>(derivation: Derivation<R, T, FM>): void;
59
+ registerHashFn(hashFn: HashFn): void;
60
+ }
61
+ export {};
62
+ }
63
+ //# sourceMappingURL=migration-support.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"migration-support.d.ts","sourceRoot":"","sources":["../src/migration-support.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,mBAAmB,CAAC;AAE3C,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AAG7D,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,wBAAwB,CAAC;AAErE,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,iCAAiC,CAAC;AACnE,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,+BAA+B,CAAC;AACzE,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,EAAE,cAAc,EAAE,MAAM,wCAAwC,CAAC;AACjG,OAAO,KAAK,EACV,UAAU,EACV,YAAY,EACZ,WAAW,EACX,YAAY,EACZ,SAAS,EACT,WAAW,EACX,cAAc,EACf,MAAM,sCAAsC,CAAC;AAE9C,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,8BAA8B,CAAC;AAGhE,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM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M/B,gBAAgB,CAAC,QAAQ,EAAE,sBAAsB,GAAG;QAAE,IAAI,EAAE,MAAM,CAAA;KAAE,EAAE,KAAK,EAAE,MAAM,GAAG,OAAO;IAM7F,MAAM,CAAC,QAAQ,EAAE,sBAAsB,GAAG;QAAE,IAAI,EAAE,MAAM,CAAA;KAAE,GAAG,GAAG,CAAC,MAAM,EAAE,WAAW,CAAC;IAMrF,cAAc,CAAC,KAAK,EAAE,YAAY,GAAG,WAAW,GAAG,UAAU,GAAG;QAAE,IAAI,EAAE,MAAM,CAAA;KAAE,GAAG,cAAc;IAGjG,MAAM,CAAC,KAAK,EAAE,SAAS,GAAG;QAAE,IAAI,EAAE,MAAM,CAAA;KAAE,GAAG,MAAM;IAGnD,UAAU,CAAC,KAAK,EAAE,YAAY,GAAG;QAAE,IAAI,EAAE,MAAM,CAAA;KAAE,GAAG,UAAU;IAG9D,QAAQ,CAAC,QAAQ,EAAE,sBAAsB,GAAG;QAAE,IAAI,EAAE,MAAM,CAAA;KAAE,GAAG,cAAc;IAM7E,iBAAiB,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"}
package/addon/-private.js DELETED
@@ -1,2 +0,0 @@
1
- export { a as attr, b as belongsTo, h as hasMany } from "./has-many-660c2e2c";
2
- export { E as Errors, L as LEGACY_SUPPORT, R as ManyArray, M as Model, P as PromiseBelongsTo, a as PromiseManyArray } from "./model-498f8197";