@ember-data/model 4.12.8 → 4.13.0-alpha.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +19 -0
- package/addon-main.cjs +5 -0
- package/blueprints/model/index.js +18 -5
- package/blueprints/model-test/index.js +16 -10
- package/blueprints/model-test/qunit-files/__root__/__path__/__test__.js +4 -5
- package/dist/-private.js +2 -0
- package/dist/-private.js.map +1 -0
- package/dist/has-many-CshPdrqR.js +842 -0
- package/dist/has-many-CshPdrqR.js.map +1 -0
- package/dist/hooks-DCYCaSEL.js +75 -0
- package/dist/hooks-DCYCaSEL.js.map +1 -0
- package/dist/hooks.js +2 -0
- package/dist/hooks.js.map +1 -0
- package/dist/index.js +4 -0
- package/{addon → dist}/index.js.map +1 -1
- package/{addon/has-many-d45aa09e.js → dist/legacy-relationships-support-D5m0xTYg.js} +5532 -5533
- package/dist/legacy-relationships-support-D5m0xTYg.js.map +1 -0
- package/dist/migration-support.js +210 -0
- package/dist/migration-support.js.map +1 -0
- package/dist/schema-provider-m94yB7iS.js +294 -0
- package/dist/schema-provider-m94yB7iS.js.map +1 -0
- package/ember-data-logo-dark.svg +12 -0
- package/ember-data-logo-light.svg +12 -0
- package/package.json +78 -44
- package/unstable-preview-types/-private/attr.d.ts +175 -0
- package/unstable-preview-types/-private/attr.d.ts.map +1 -0
- package/unstable-preview-types/-private/attr.type-test.d.ts +4 -0
- package/unstable-preview-types/-private/attr.type-test.d.ts.map +1 -0
- package/unstable-preview-types/-private/belongs-to.d.ts +180 -0
- package/unstable-preview-types/-private/belongs-to.d.ts.map +1 -0
- package/unstable-preview-types/-private/belongs-to.type-test.d.ts +4 -0
- package/unstable-preview-types/-private/belongs-to.type-test.d.ts.map +1 -0
- package/unstable-preview-types/-private/debug/assert-polymorphic-type.d.ts +8 -0
- package/unstable-preview-types/-private/debug/assert-polymorphic-type.d.ts.map +1 -0
- package/unstable-preview-types/-private/deprecated-promise-proxy.d.ts +5 -0
- package/unstable-preview-types/-private/deprecated-promise-proxy.d.ts.map +1 -0
- package/unstable-preview-types/-private/errors.d.ts +303 -0
- package/unstable-preview-types/-private/errors.d.ts.map +1 -0
- package/unstable-preview-types/-private/has-many.d.ts +169 -0
- package/unstable-preview-types/-private/has-many.d.ts.map +1 -0
- package/unstable-preview-types/-private/has-many.type-test.d.ts +4 -0
- package/unstable-preview-types/-private/has-many.type-test.d.ts.map +1 -0
- package/unstable-preview-types/-private/hooks.d.ts +13 -0
- package/unstable-preview-types/-private/hooks.d.ts.map +1 -0
- package/unstable-preview-types/-private/legacy-relationships-support.d.ts +60 -0
- package/unstable-preview-types/-private/legacy-relationships-support.d.ts.map +1 -0
- package/unstable-preview-types/-private/many-array.d.ts +196 -0
- package/unstable-preview-types/-private/many-array.d.ts.map +1 -0
- package/unstable-preview-types/-private/model-for-mixin.d.ts +6 -0
- package/unstable-preview-types/-private/model-for-mixin.d.ts.map +1 -0
- package/unstable-preview-types/-private/model-methods.d.ts +37 -0
- package/unstable-preview-types/-private/model-methods.d.ts.map +1 -0
- package/unstable-preview-types/-private/model.d.ts +1305 -0
- package/unstable-preview-types/-private/model.d.ts.map +1 -0
- package/unstable-preview-types/-private/model.type-test.d.ts +4 -0
- package/unstable-preview-types/-private/model.type-test.d.ts.map +1 -0
- package/unstable-preview-types/-private/notify-changes.d.ts +8 -0
- package/unstable-preview-types/-private/notify-changes.d.ts.map +1 -0
- package/unstable-preview-types/-private/promise-belongs-to.d.ts +46 -0
- package/unstable-preview-types/-private/promise-belongs-to.d.ts.map +1 -0
- package/unstable-preview-types/-private/promise-many-array.d.ts +130 -0
- package/unstable-preview-types/-private/promise-many-array.d.ts.map +1 -0
- package/unstable-preview-types/-private/record-state.d.ts +90 -0
- package/unstable-preview-types/-private/record-state.d.ts.map +1 -0
- package/unstable-preview-types/-private/references/belongs-to.d.ts +503 -0
- package/unstable-preview-types/-private/references/belongs-to.d.ts.map +1 -0
- package/unstable-preview-types/-private/references/has-many.d.ts +515 -0
- package/unstable-preview-types/-private/references/has-many.d.ts.map +1 -0
- package/unstable-preview-types/-private/relationship-meta.d.ts +35 -0
- package/unstable-preview-types/-private/relationship-meta.d.ts.map +1 -0
- package/unstable-preview-types/-private/schema-provider.d.ts +64 -0
- package/unstable-preview-types/-private/schema-provider.d.ts.map +1 -0
- package/unstable-preview-types/-private/type-utils.d.ts +64 -0
- package/unstable-preview-types/-private/type-utils.d.ts.map +1 -0
- package/unstable-preview-types/-private/util.d.ts +8 -0
- package/unstable-preview-types/-private/util.d.ts.map +1 -0
- package/unstable-preview-types/-private.d.ts +13 -0
- package/unstable-preview-types/-private.d.ts.map +1 -0
- package/unstable-preview-types/hooks.d.ts +5 -0
- package/unstable-preview-types/hooks.d.ts.map +1 -0
- package/unstable-preview-types/index.d.ts +78 -0
- package/unstable-preview-types/index.d.ts.map +1 -0
- package/unstable-preview-types/migration-support.d.ts +56 -0
- package/unstable-preview-types/migration-support.d.ts.map +1 -0
- package/addon/-private.js +0 -95
- package/addon/-private.js.map +0 -1
- package/addon/has-many-d45aa09e.js.map +0 -1
- package/addon/index.js +0 -1
- package/addon-main.js +0 -93
- package/blueprints/model-test/mocha-files/__root__/__path__/__test__.js +0 -18
- package/blueprints/model-test/mocha-rfc-232-files/__root__/__path__/__test__.js +0 -15
|
@@ -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 { Type } 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 Type>;
|
|
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":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,+BAA+B,CAAC;AACzE,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,gCAAgC,CAAC;AAE3D,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAC;AACtD,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AACrC,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AAC7D,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AAE7D,KAAK,WAAW,CAAC,CAAC,IAAI,OAAO,CAAC,CAAC,EAAE,IAAI,CAAC,SAAS,KAAK,GAAG,CAAC,GAAG,OAAO,CAAC,CAAC,EAAE,IAAI,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,CAAC,GAAG,OAAO,IAAI,CAAC,CAAC;AAClG,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"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
declare module '@ember-data/model/-private/util' {
|
|
2
|
+
export type DecoratorPropertyDescriptor = (PropertyDescriptor & {
|
|
3
|
+
initializer?: () => unknown;
|
|
4
|
+
}) | undefined;
|
|
5
|
+
export function isElementDescriptor(args: unknown[]): args is [object, string, DecoratorPropertyDescriptor];
|
|
6
|
+
export function normalizeModelName(type: string): string;
|
|
7
|
+
}
|
|
8
|
+
//# sourceMappingURL=util.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"util.d.ts","sourceRoot":"","sources":["../../src/-private/util.ts"],"names":[],"mappings":"AAKA,MAAM,MAAM,2BAA2B,GAAG,CAAC,kBAAkB,GAAG;IAAE,WAAW,CAAC,EAAE,MAAM,OAAO,CAAA;CAAE,CAAC,GAAG,SAAS,CAAC;AAE7G,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,OAAO,EAAE,GAAG,IAAI,IAAI,CAAC,MAAM,EAAE,MAAM,EAAE,2BAA2B,CAAC,CAkB1G;AAED,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAsBvD"}
|
|
@@ -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/model/-private/many-array';
|
|
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,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"}
|
|
@@ -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,78 @@
|
|
|
1
|
+
/// <reference path="./hooks.d.ts" />
|
|
2
|
+
/// <reference path="./migration-support.d.ts" />
|
|
3
|
+
/// <reference path="./-private.d.ts" />
|
|
4
|
+
/// <reference path="./-private/attr.d.ts" />
|
|
5
|
+
/// <reference path="./-private/errors.d.ts" />
|
|
6
|
+
/// <reference path="./-private/model.type-test.d.ts" />
|
|
7
|
+
/// <reference path="./-private/hooks.d.ts" />
|
|
8
|
+
/// <reference path="./-private/model.d.ts" />
|
|
9
|
+
/// <reference path="./-private/belongs-to.type-test.d.ts" />
|
|
10
|
+
/// <reference path="./-private/has-many.type-test.d.ts" />
|
|
11
|
+
/// <reference path="./-private/promise-many-array.d.ts" />
|
|
12
|
+
/// <reference path="./-private/type-utils.d.ts" />
|
|
13
|
+
/// <reference path="./-private/many-array.d.ts" />
|
|
14
|
+
/// <reference path="./-private/model-for-mixin.d.ts" />
|
|
15
|
+
/// <reference path="./-private/notify-changes.d.ts" />
|
|
16
|
+
/// <reference path="./-private/legacy-relationships-support.d.ts" />
|
|
17
|
+
/// <reference path="./-private/belongs-to.d.ts" />
|
|
18
|
+
/// <reference path="./-private/schema-provider.d.ts" />
|
|
19
|
+
/// <reference path="./-private/promise-belongs-to.d.ts" />
|
|
20
|
+
/// <reference path="./-private/has-many.d.ts" />
|
|
21
|
+
/// <reference path="./-private/util.d.ts" />
|
|
22
|
+
/// <reference path="./-private/attr.type-test.d.ts" />
|
|
23
|
+
/// <reference path="./-private/relationship-meta.d.ts" />
|
|
24
|
+
/// <reference path="./-private/model-methods.d.ts" />
|
|
25
|
+
/// <reference path="./-private/record-state.d.ts" />
|
|
26
|
+
/// <reference path="./-private/deprecated-promise-proxy.d.ts" />
|
|
27
|
+
/// <reference path="./-private/debug/assert-polymorphic-type.d.ts" />
|
|
28
|
+
/// <reference path="./-private/references/belongs-to.d.ts" />
|
|
29
|
+
/// <reference path="./-private/references/has-many.d.ts" />
|
|
30
|
+
declare module '@ember-data/model' {
|
|
31
|
+
/**
|
|
32
|
+
* This package provides a Presentation Model for resource data in an EmberData Cache.
|
|
33
|
+
*
|
|
34
|
+
* Models are defined as classes extending from `import Model from '@ember-data/model';` and the
|
|
35
|
+
* attributes and relationships on these classes are parsed at runtime to supply static "schema"
|
|
36
|
+
* to EmberData's SchemaService.
|
|
37
|
+
*
|
|
38
|
+
* Resource data for individual resources fetched from your API is presented to the UI via instances
|
|
39
|
+
* of the `Model`s you define. An instantiated `Model` is referred to as a `record`.
|
|
40
|
+
|
|
41
|
+
When we refer to the `ModelClass` as opposed to a `Model` or `Record` we are referring
|
|
42
|
+
specifically to the class definition and the static schema methods present on it.
|
|
43
|
+
|
|
44
|
+
When we refer to a `record` we refer to a specific class instance presenting
|
|
45
|
+
the resource data for a given `type` and `id`.
|
|
46
|
+
|
|
47
|
+
### Defining a Model
|
|
48
|
+
|
|
49
|
+
```app/models/person.js
|
|
50
|
+
import Model, { attr, belongsTo, hasMany } from '@ember-data/model';
|
|
51
|
+
|
|
52
|
+
export default class PersonModel extends Model {
|
|
53
|
+
@attr name;
|
|
54
|
+
|
|
55
|
+
@belongsTo('pet', { inverse: 'owners', async: false }) dog;
|
|
56
|
+
|
|
57
|
+
@hasMany('person', { inverse: 'friends', async: true }) friends;
|
|
58
|
+
}
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
### modelName convention
|
|
62
|
+
|
|
63
|
+
By convention, the name of a given model (its `type`) matches the name
|
|
64
|
+
of the file in the `app/models` folder and should be lowercase, singular
|
|
65
|
+
and dasherized.
|
|
66
|
+
|
|
67
|
+
@module @ember-data/model
|
|
68
|
+
@main @ember-data/model
|
|
69
|
+
*/
|
|
70
|
+
export { Model as default, attr, belongsTo, hasMany } from '@ember-data/model/-private';
|
|
71
|
+
export type { PromiseBelongsTo as AsyncBelongsTo } from '@ember-data/model/-private/promise-belongs-to';
|
|
72
|
+
export type { PromiseManyArray as AsyncHasMany } from '@ember-data/model/-private/promise-many-array';
|
|
73
|
+
export type { RelatedCollection as ManyArray } from '@ember-data/model/-private/many-array';
|
|
74
|
+
export type { RelatedCollection as HasMany } from '@ember-data/model/-private/many-array';
|
|
75
|
+
export { instantiateRecord, teardownRecord, modelFor } from '@ember-data/model/-private/hooks';
|
|
76
|
+
export { ModelSchemaProvider } from '@ember-data/model/-private/schema-provider';
|
|
77
|
+
}
|
|
78
|
+
//# 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,uBAAuB,CAAC;AAC5E,YAAY,EAAE,iBAAiB,IAAI,OAAO,EAAE,MAAM,uBAAuB,CAAC;AAC1E,OAAO,EAAE,iBAAiB,EAAE,cAAc,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAC/E,OAAO,EAAE,mBAAmB,EAAE,MAAM,4BAA4B,CAAC"}
|
|
@@ -0,0 +1,56 @@
|
|
|
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 { Derivation, HashFn, Transformation } from '@warp-drive/core-types/schema/concepts';
|
|
7
|
+
import type { ArrayField, DerivedField, FieldSchema, GenericField, HashField, ObjectField, 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;
|
|
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(field: GenericField | ObjectField | ArrayField | {
|
|
37
|
+
type: string;
|
|
38
|
+
}): Transformation;
|
|
39
|
+
hashFn(field: HashField | {
|
|
40
|
+
type: string;
|
|
41
|
+
}): HashFn;
|
|
42
|
+
derivation(field: DerivedField | {
|
|
43
|
+
type: string;
|
|
44
|
+
}): Derivation;
|
|
45
|
+
resource(resource: StableRecordIdentifier | {
|
|
46
|
+
type: string;
|
|
47
|
+
}): ResourceSchema;
|
|
48
|
+
registerResources(schemas: ResourceSchema[]): void;
|
|
49
|
+
registerResource(schema: ResourceSchema): void;
|
|
50
|
+
registerTransformation(transform: Transformation): void;
|
|
51
|
+
registerDerivation<R, T, FM extends ObjectValue | null>(derivation: Derivation<R, T, FM>): void;
|
|
52
|
+
registerHashFn(hashFn: HashFn): void;
|
|
53
|
+
}
|
|
54
|
+
export {};
|
|
55
|
+
}
|
|
56
|
+
//# 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,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;AAoBhE,KAAK,gBAAgB,GAAG,UAAU,CAAC,OAAO,CAAC,aAAa,CAAC,yBAAyB,CAAC,EAAE,SAAS,CAAC,CAAC,CAAC;AACjG,KAAK,mBAAmB,GAAG,UAAU,CAAC,OAAO,CAAC,aAAa,CAAC,4BAA4B,CAAC,EAAE,SAAS,CAAC,CAAC,CAAC;AAuGvG,wBAAgB,YAAY,CAAC,MAAM,EAAE,WAAW,CAAC,cAAc,EAAE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E,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,95 +0,0 @@
|
|
|
1
|
-
import { M as Model } from "./has-many-d45aa09e";
|
|
2
|
-
export { E as Errors, L as LEGACY_SUPPORT, R as ManyArray, P as PromiseBelongsTo, c as PromiseManyArray, a as attr, b as belongsTo, h as hasMany } from "./has-many-d45aa09e";
|
|
3
|
-
import { getOwner } from '@ember/application';
|
|
4
|
-
|
|
5
|
-
/*
|
|
6
|
-
In case someone defined a relationship to a mixin, for example:
|
|
7
|
-
```
|
|
8
|
-
import Model, { belongsTo, hasMany } from '@ember-data/model';
|
|
9
|
-
import Mixin from '@ember/object/mixin';
|
|
10
|
-
|
|
11
|
-
class CommentModel extends Model {
|
|
12
|
-
@belongsTo('commentable', { polymorphic: true }) owner;
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
let Commentable = Mixin.create({
|
|
16
|
-
@hasMany('comment') comments;
|
|
17
|
-
});
|
|
18
|
-
```
|
|
19
|
-
we want to look up a Commentable class which has all the necessary
|
|
20
|
-
relationship meta data. Thus, we look up the mixin and create a mock
|
|
21
|
-
Model, so we can access the relationship CPs of the mixin (`comments`)
|
|
22
|
-
in this case
|
|
23
|
-
*/
|
|
24
|
-
function modelForMixin(store, normalizedModelName) {
|
|
25
|
-
let owner = getOwner(store);
|
|
26
|
-
let MaybeMixin = owner.factoryFor(`mixin:${normalizedModelName}`);
|
|
27
|
-
let mixin = MaybeMixin && MaybeMixin.class;
|
|
28
|
-
if (mixin) {
|
|
29
|
-
let ModelForMixin = Model.extend(mixin);
|
|
30
|
-
ModelForMixin.__isMixin = true;
|
|
31
|
-
ModelForMixin.__mixin = mixin;
|
|
32
|
-
//Cache the class as a model
|
|
33
|
-
owner.register('model:' + normalizedModelName, ModelForMixin);
|
|
34
|
-
}
|
|
35
|
-
return owner.factoryFor(`model:${normalizedModelName}`);
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
/**
|
|
39
|
-
@module @ember-data/model
|
|
40
|
-
*/
|
|
41
|
-
|
|
42
|
-
/**
|
|
43
|
-
@method diffArray
|
|
44
|
-
@internal
|
|
45
|
-
@param {Array} oldArray the old array
|
|
46
|
-
@param {Array} newArray the new array
|
|
47
|
-
@return {hash} {
|
|
48
|
-
firstChangeIndex: <integer>, // null if no change
|
|
49
|
-
addedCount: <integer>, // 0 if no change
|
|
50
|
-
removedCount: <integer> // 0 if no change
|
|
51
|
-
}
|
|
52
|
-
*/
|
|
53
|
-
function diffArray(oldArray, newArray) {
|
|
54
|
-
const oldLength = oldArray.length;
|
|
55
|
-
const newLength = newArray.length;
|
|
56
|
-
const shortestLength = Math.min(oldLength, newLength);
|
|
57
|
-
let firstChangeIndex = null; // null signifies no changes
|
|
58
|
-
|
|
59
|
-
// find the first change
|
|
60
|
-
for (let i = 0; i < shortestLength; i++) {
|
|
61
|
-
// compare each item in the array
|
|
62
|
-
if (oldArray[i] !== newArray[i]) {
|
|
63
|
-
firstChangeIndex = i;
|
|
64
|
-
break;
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
if (firstChangeIndex === null && newLength !== oldLength) {
|
|
68
|
-
// no change found in the overlapping block
|
|
69
|
-
// and array lengths differ,
|
|
70
|
-
// so change starts at end of overlap
|
|
71
|
-
firstChangeIndex = shortestLength;
|
|
72
|
-
}
|
|
73
|
-
let addedCount = 0;
|
|
74
|
-
let removedCount = 0;
|
|
75
|
-
if (firstChangeIndex !== null) {
|
|
76
|
-
// we found a change, find the end of the change
|
|
77
|
-
let unchangedEndBlockLength = shortestLength - firstChangeIndex;
|
|
78
|
-
// walk back from the end of both arrays until we find a change
|
|
79
|
-
for (let i = 1; i <= shortestLength; i++) {
|
|
80
|
-
// compare each item in the array
|
|
81
|
-
if (oldArray[oldLength - i] !== newArray[newLength - i]) {
|
|
82
|
-
unchangedEndBlockLength = i - 1;
|
|
83
|
-
break;
|
|
84
|
-
}
|
|
85
|
-
}
|
|
86
|
-
addedCount = newLength - unchangedEndBlockLength - firstChangeIndex;
|
|
87
|
-
removedCount = oldLength - unchangedEndBlockLength - firstChangeIndex;
|
|
88
|
-
}
|
|
89
|
-
return {
|
|
90
|
-
firstChangeIndex,
|
|
91
|
-
addedCount,
|
|
92
|
-
removedCount
|
|
93
|
-
};
|
|
94
|
-
}
|
|
95
|
-
export { Model, modelForMixin as _modelForMixin, diffArray };
|
package/addon/-private.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"-private.js","sources":["../src/-private/model-for-mixin.ts","../src/-private/diff-array.ts"],"sourcesContent":["import { getOwner } from '@ember/application';\n\nimport type Store from '@ember-data/store';\n\nimport Model from './model';\n\n/*\n In case someone defined a relationship to a mixin, for example:\n ```\n import Model, { belongsTo, hasMany } from '@ember-data/model';\n import Mixin from '@ember/object/mixin';\n\n class CommentModel extends Model {\n @belongsTo('commentable', { polymorphic: true }) owner;\n }\n\n let Commentable = Mixin.create({\n @hasMany('comment') comments;\n });\n ```\n we want to look up a Commentable class which has all the necessary\n relationship meta data. Thus, we look up the mixin and create a mock\n Model, so we can access the relationship CPs of the mixin (`comments`)\n in this case\n */\nexport default function modelForMixin(store: Store, normalizedModelName: string): Model | null {\n let owner: any = getOwner(store);\n let MaybeMixin = owner.factoryFor(`mixin:${normalizedModelName}`);\n let mixin = MaybeMixin && MaybeMixin.class;\n if (mixin) {\n let ModelForMixin = Model.extend(mixin);\n ModelForMixin.__isMixin = true;\n ModelForMixin.__mixin = mixin;\n //Cache the class as a model\n owner.register('model:' + normalizedModelName, ModelForMixin);\n }\n return owner.factoryFor(`model:${normalizedModelName}`);\n}\n","/**\n @module @ember-data/model\n*/\n\nexport interface ArrayDiffResult {\n firstChangeIndex: number | null;\n removedCount: number;\n addedCount: number;\n}\n\n/**\n @method diffArray\n @internal\n @param {Array} oldArray the old array\n @param {Array} newArray the new array\n @return {hash} {\n firstChangeIndex: <integer>, // null if no change\n addedCount: <integer>, // 0 if no change\n removedCount: <integer> // 0 if no change\n }\n*/\nexport default function diffArray(oldArray: unknown[], newArray: unknown[]): ArrayDiffResult {\n const oldLength = oldArray.length;\n const newLength = newArray.length;\n\n const shortestLength = Math.min(oldLength, newLength);\n let firstChangeIndex: number | null = null; // null signifies no changes\n\n // find the first change\n for (let i = 0; i < shortestLength; i++) {\n // compare each item in the array\n if (oldArray[i] !== newArray[i]) {\n firstChangeIndex = i;\n break;\n }\n }\n\n if (firstChangeIndex === null && newLength !== oldLength) {\n // no change found in the overlapping block\n // and array lengths differ,\n // so change starts at end of overlap\n firstChangeIndex = shortestLength;\n }\n\n let addedCount = 0;\n let removedCount = 0;\n if (firstChangeIndex !== null) {\n // we found a change, find the end of the change\n let unchangedEndBlockLength = shortestLength - firstChangeIndex;\n // walk back from the end of both arrays until we find a change\n for (let i = 1; i <= shortestLength; i++) {\n // compare each item in the array\n if (oldArray[oldLength - i] !== newArray[newLength - i]) {\n unchangedEndBlockLength = i - 1;\n break;\n }\n }\n addedCount = newLength - unchangedEndBlockLength - firstChangeIndex;\n removedCount = oldLength - unchangedEndBlockLength - firstChangeIndex;\n }\n\n return {\n firstChangeIndex,\n addedCount,\n removedCount,\n };\n}\n"],"names":["modelForMixin","store","normalizedModelName","owner","getOwner","MaybeMixin","factoryFor","mixin","class","ModelForMixin","Model","extend","__isMixin","__mixin","register","diffArray","oldArray","newArray","oldLength","length","newLength","shortestLength","Math","min","firstChangeIndex","i","addedCount","removedCount","unchangedEndBlockLength"],"mappings":";;;;AAMA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACe,SAASA,aAAaA,CAACC,KAAY,EAAEC,mBAA2B,EAAgB;AAC7F,EAAA,IAAIC,KAAU,GAAGC,QAAQ,CAACH,KAAK,CAAC,CAAA;EAChC,IAAII,UAAU,GAAGF,KAAK,CAACG,UAAU,CAAE,CAAA,MAAA,EAAQJ,mBAAoB,CAAA,CAAC,CAAC,CAAA;AACjE,EAAA,IAAIK,KAAK,GAAGF,UAAU,IAAIA,UAAU,CAACG,KAAK,CAAA;AAC1C,EAAA,IAAID,KAAK,EAAE;AACT,IAAA,IAAIE,aAAa,GAAGC,KAAK,CAACC,MAAM,CAACJ,KAAK,CAAC,CAAA;IACvCE,aAAa,CAACG,SAAS,GAAG,IAAI,CAAA;IAC9BH,aAAa,CAACI,OAAO,GAAGN,KAAK,CAAA;AAC7B;IACAJ,KAAK,CAACW,QAAQ,CAAC,QAAQ,GAAGZ,mBAAmB,EAAEO,aAAa,CAAC,CAAA;AAC/D,GAAA;AACA,EAAA,OAAON,KAAK,CAACG,UAAU,CAAE,CAAQJ,MAAAA,EAAAA,mBAAoB,EAAC,CAAC,CAAA;AACzD;;ACrCA;AACA;AACA;;AAQA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACe,SAASa,SAASA,CAACC,QAAmB,EAAEC,QAAmB,EAAmB;AAC3F,EAAA,MAAMC,SAAS,GAAGF,QAAQ,CAACG,MAAM,CAAA;AACjC,EAAA,MAAMC,SAAS,GAAGH,QAAQ,CAACE,MAAM,CAAA;EAEjC,MAAME,cAAc,GAAGC,IAAI,CAACC,GAAG,CAACL,SAAS,EAAEE,SAAS,CAAC,CAAA;AACrD,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