@ember-data/model 5.4.0-alpha.32 → 5.4.0-alpha.34
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/addon/-private.js +1 -1
- package/addon/{has-many-Qm5aUQol.js → has-many-Mz5PIxmL.js} +10 -0
- package/addon/{has-many-Qm5aUQol.js.map → has-many-Mz5PIxmL.js.map} +1 -1
- package/addon/index.js +1 -1
- package/addon/model-eXqU5A13.js.map +1 -1
- package/package.json +19 -19
- package/unstable-preview-types/-private/attr.d.ts +170 -168
- package/unstable-preview-types/-private/attr.type-test.d.ts +3 -1
- package/unstable-preview-types/-private/belongs-to.d.ts +179 -178
- package/unstable-preview-types/-private/belongs-to.d.ts.map +1 -1
- package/unstable-preview-types/-private/belongs-to.type-test.d.ts +3 -1
- package/unstable-preview-types/-private/debug/assert-polymorphic-type.d.ts +7 -5
- package/unstable-preview-types/-private/errors.d.ts +288 -286
- package/unstable-preview-types/-private/has-many.d.ts +168 -167
- package/unstable-preview-types/-private/has-many.d.ts.map +1 -1
- package/unstable-preview-types/-private/has-many.type-test.d.ts +3 -1
- package/unstable-preview-types/-private/hooks.d.ts +12 -10
- package/unstable-preview-types/-private/legacy-relationships-support.d.ts +60 -58
- package/unstable-preview-types/-private/many-array.d.ts +192 -189
- package/unstable-preview-types/-private/many-array.d.ts.map +1 -1
- package/unstable-preview-types/-private/model-for-mixin.d.ts +5 -3
- package/unstable-preview-types/-private/model-methods.d.ts +32 -30
- package/unstable-preview-types/-private/model.d.ts +103 -100
- package/unstable-preview-types/-private/model.type-test.d.ts +3 -1
- package/unstable-preview-types/-private/notify-changes.d.ts +7 -5
- package/unstable-preview-types/-private/promise-belongs-to.d.ts +45 -43
- package/unstable-preview-types/-private/promise-many-array.d.ts +127 -125
- package/unstable-preview-types/-private/promise-proxy-base.d.ts +35 -32
- package/unstable-preview-types/-private/record-state.d.ts +86 -84
- package/unstable-preview-types/-private/references/belongs-to.d.ts +471 -469
- package/unstable-preview-types/-private/references/has-many.d.ts +486 -484
- package/unstable-preview-types/-private/schema-provider.d.ts +25 -23
- package/unstable-preview-types/-private/util.d.ts +10 -8
- package/unstable-preview-types/-private.d.ts +11 -9
- package/unstable-preview-types/hooks.d.ts +4 -2
- package/unstable-preview-types/index.d.ts +74 -45
- package/unstable-preview-types/migration-support.d.ts +10 -8
|
@@ -1,25 +1,27 @@
|
|
|
1
|
-
|
|
2
|
-
import type
|
|
3
|
-
import type {
|
|
4
|
-
import type {
|
|
5
|
-
import type {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
1
|
+
declare module '@ember-data/model/-private/schema-provider' {
|
|
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';
|
|
6
|
+
import type { ModelFactory, ModelStore } from '@ember-data/model/-private/model';
|
|
7
|
+
export declare class ModelSchemaProvider {
|
|
8
|
+
store: ModelStore;
|
|
9
|
+
_relationshipsDefCache: Record<string, RelationshipsSchema>;
|
|
10
|
+
_attributesDefCache: Record<string, AttributesSchema>;
|
|
11
|
+
_fieldsDefCache: Record<string, Map<string, FieldSchema>>;
|
|
12
|
+
constructor(store: ModelStore);
|
|
13
|
+
fields(identifier: RecordIdentifier | {
|
|
14
|
+
type: string;
|
|
15
|
+
}): Map<string, FieldSchema>;
|
|
16
|
+
attributesDefinitionFor(identifier: RecordIdentifier | {
|
|
17
|
+
type: string;
|
|
18
|
+
}): AttributesSchema;
|
|
19
|
+
relationshipsDefinitionFor(identifier: RecordIdentifier | {
|
|
20
|
+
type: string;
|
|
21
|
+
}): RelationshipsSchema;
|
|
22
|
+
doesTypeExist(modelName: string): boolean;
|
|
23
|
+
}
|
|
24
|
+
export declare function buildSchema(store: Store): ModelSchemaProvider;
|
|
25
|
+
export declare function getModelFactory(store: ModelStore, type: string): ModelFactory | null;
|
|
22
26
|
}
|
|
23
|
-
export declare function buildSchema(store: Store): ModelSchemaProvider;
|
|
24
|
-
export declare function getModelFactory(store: ModelStore, type: string): ModelFactory | null;
|
|
25
27
|
//# sourceMappingURL=schema-provider.d.ts.map
|
|
@@ -1,9 +1,11 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
export
|
|
6
|
-
export type
|
|
7
|
-
export
|
|
8
|
-
export declare function
|
|
1
|
+
declare module '@ember-data/model/-private/util' {
|
|
2
|
+
export type DecoratorPropertyDescriptor = (PropertyDescriptor & {
|
|
3
|
+
initializer?: () => unknown;
|
|
4
|
+
}) | undefined;
|
|
5
|
+
export declare function isElementDescriptor(args: unknown[]): args is [object, string, DecoratorPropertyDescriptor];
|
|
6
|
+
export type DataDecorator = (target: object, key: string, desc?: DecoratorPropertyDescriptor) => DecoratorPropertyDescriptor;
|
|
7
|
+
export type DataDecoratorFactory = (...args: unknown[]) => DataDecorator;
|
|
8
|
+
export declare function computedMacroWithOptionalParams(fn: DataDecorator | DataDecoratorFactory): (...maybeDesc: unknown[]) => DecoratorPropertyDescriptor | DataDecorator;
|
|
9
|
+
export declare function normalizeModelName(type: string): string;
|
|
10
|
+
}
|
|
9
11
|
//# sourceMappingURL=util.d.ts.map
|
|
@@ -1,10 +1,12 @@
|
|
|
1
|
-
|
|
2
|
-
export {
|
|
3
|
-
export {
|
|
4
|
-
export {
|
|
5
|
-
export {
|
|
6
|
-
export { default as
|
|
7
|
-
export {
|
|
8
|
-
export {
|
|
9
|
-
export {
|
|
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 { default as Errors } from '@ember-data/model/-private/errors';
|
|
7
|
+
export { default as ManyArray } from '@ember-data/model/-private/many-array';
|
|
8
|
+
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 { lookupLegacySupport, LEGACY_SUPPORT } from '@ember-data/model/-private/legacy-relationships-support';
|
|
11
|
+
}
|
|
10
12
|
//# sourceMappingURL=-private.d.ts.map
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
export {
|
|
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
|
+
}
|
|
3
5
|
//# sourceMappingURL=hooks.d.ts.map
|
|
@@ -1,46 +1,75 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
1
|
+
/// <reference path="./hooks.d.ts" />
|
|
2
|
+
/// <reference path="./migration-support.d.ts" />
|
|
3
|
+
/// <reference path="./-private.d.ts" />
|
|
4
|
+
/// <reference path="./-private/model-methods.d.ts" />
|
|
5
|
+
/// <reference path="./-private/has-many.d.ts" />
|
|
6
|
+
/// <reference path="./-private/attr.d.ts" />
|
|
7
|
+
/// <reference path="./-private/model.type-test.d.ts" />
|
|
8
|
+
/// <reference path="./-private/legacy-relationships-support.d.ts" />
|
|
9
|
+
/// <reference path="./-private/util.d.ts" />
|
|
10
|
+
/// <reference path="./-private/attr.type-test.d.ts" />
|
|
11
|
+
/// <reference path="./-private/promise-many-array.d.ts" />
|
|
12
|
+
/// <reference path="./-private/errors.d.ts" />
|
|
13
|
+
/// <reference path="./-private/hooks.d.ts" />
|
|
14
|
+
/// <reference path="./-private/record-state.d.ts" />
|
|
15
|
+
/// <reference path="./-private/model.d.ts" />
|
|
16
|
+
/// <reference path="./-private/schema-provider.d.ts" />
|
|
17
|
+
/// <reference path="./-private/model-for-mixin.d.ts" />
|
|
18
|
+
/// <reference path="./-private/notify-changes.d.ts" />
|
|
19
|
+
/// <reference path="./-private/has-many.type-test.d.ts" />
|
|
20
|
+
/// <reference path="./-private/many-array.d.ts" />
|
|
21
|
+
/// <reference path="./-private/belongs-to.d.ts" />
|
|
22
|
+
/// <reference path="./-private/promise-proxy-base.d.ts" />
|
|
23
|
+
/// <reference path="./-private/promise-belongs-to.d.ts" />
|
|
24
|
+
/// <reference path="./-private/belongs-to.type-test.d.ts" />
|
|
25
|
+
/// <reference path="./-private/debug/assert-polymorphic-type.d.ts" />
|
|
26
|
+
/// <reference path="./-private/references/has-many.d.ts" />
|
|
27
|
+
/// <reference path="./-private/references/belongs-to.d.ts" />
|
|
28
|
+
declare module '@ember-data/model' {
|
|
29
|
+
/**
|
|
30
|
+
* This package provides a Presentation Model for resource data in an EmberData Cache.
|
|
31
|
+
*
|
|
32
|
+
* Models are defined as classes extending from `import Model from '@ember-data/model';` and the
|
|
33
|
+
* attributes and relationships on these classes are parsed at runtime to supply static "schema"
|
|
34
|
+
* to EmberData's SchemaService.
|
|
35
|
+
*
|
|
36
|
+
* Resource data for individual resources fetched from your API is presented to the UI via instances
|
|
37
|
+
* of the `Model`s you define. An instantiated `Model` is referred to as a `record`.
|
|
38
|
+
|
|
39
|
+
When we refer to the `ModelClass` as opposed to a `Model` or `Record` we are referring
|
|
40
|
+
specifically to the class definition and the static schema methods present on it.
|
|
41
|
+
|
|
42
|
+
When we refer to a `record` we refer to a specific class instance presenting
|
|
43
|
+
the resource data for a given `type` and `id`.
|
|
44
|
+
|
|
45
|
+
### Defining a Model
|
|
46
|
+
|
|
47
|
+
```app/models/person.js
|
|
48
|
+
import Model, { attr, belongsTo, hasMany } from '@ember-data/model';
|
|
49
|
+
|
|
50
|
+
export default class PersonModel extends Model {
|
|
51
|
+
@attr name;
|
|
52
|
+
|
|
53
|
+
@belongsTo('pet', { inverse: 'owners', async: false }) dog;
|
|
54
|
+
|
|
55
|
+
@hasMany('person', { inverse: 'friends', async: true }) friends;
|
|
56
|
+
}
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
### modelName convention
|
|
60
|
+
|
|
61
|
+
By convention, the name of a given model (its `type`) matches the name
|
|
62
|
+
of the file in the `app/models` folder and should be lowercase, singular
|
|
63
|
+
and dasherized.
|
|
64
|
+
|
|
65
|
+
@module @ember-data/model
|
|
66
|
+
@main @ember-data/model
|
|
67
|
+
*/
|
|
68
|
+
export { Model as default, attr, belongsTo, hasMany } from '@ember-data/model/-private';
|
|
69
|
+
export type { PromiseBelongsTo as AsyncBelongsTo } from './-private/promise-belongs-to';
|
|
70
|
+
export type { default as AsyncHasMany } from './-private/promise-many-array';
|
|
71
|
+
export type { default as ManyArray } from './-private/many-array';
|
|
72
|
+
export { instantiateRecord, teardownRecord, modelFor } from '@ember-data/model/-private/hooks';
|
|
73
|
+
export { ModelSchemaProvider } from '@ember-data/model/-private/schema-provider';
|
|
74
|
+
}
|
|
46
75
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1,9 +1,11 @@
|
|
|
1
|
-
|
|
2
|
-
type
|
|
3
|
-
type
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
export declare function
|
|
8
|
-
export
|
|
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 declare function withFields(fields: FieldSchema[]): FieldSchema[];
|
|
8
|
+
export declare function registerDerivations(schema: SchemaService): void;
|
|
9
|
+
export {};
|
|
10
|
+
}
|
|
9
11
|
//# sourceMappingURL=migration-support.d.ts.map
|