@ember-data/model 5.6.0-beta.0 → 5.6.0-beta.2
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-main.cjs +1 -1
- package/dist/-private.js +1 -3
- package/dist/hooks.js +1 -2
- package/dist/index.js +1 -5
- package/dist/migration-support.js +1 -388
- package/package.json +7 -35
- package/unstable-preview-types/-private.d.ts +3 -12
- package/unstable-preview-types/hooks.d.ts +3 -4
- package/unstable-preview-types/index.d.ts +32 -64
- package/unstable-preview-types/migration-support.d.ts +21 -269
- package/dist/-private.js.map +0 -1
- package/dist/has-many-BXU96bZ9.js +0 -682
- package/dist/has-many-BXU96bZ9.js.map +0 -1
- package/dist/hooks-o1U_cEA3.js +0 -75
- package/dist/hooks-o1U_cEA3.js.map +0 -1
- package/dist/hooks.js.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/migration-support.js.map +0 -1
- package/dist/model-Dkk-TZlL.js +0 -4899
- package/dist/model-Dkk-TZlL.js.map +0 -1
- package/dist/schema-provider-DyG6fJXt.js +0 -259
- package/dist/schema-provider-DyG6fJXt.js.map +0 -1
- package/unstable-preview-types/-private/attr.d.ts +0 -175
- package/unstable-preview-types/-private/attr.d.ts.map +0 -1
- package/unstable-preview-types/-private/attr.type-test.d.ts +0 -4
- package/unstable-preview-types/-private/attr.type-test.d.ts.map +0 -1
- package/unstable-preview-types/-private/belongs-to.d.ts +0 -181
- package/unstable-preview-types/-private/belongs-to.d.ts.map +0 -1
- package/unstable-preview-types/-private/belongs-to.type-test.d.ts +0 -4
- package/unstable-preview-types/-private/belongs-to.type-test.d.ts.map +0 -1
- package/unstable-preview-types/-private/debug/assert-polymorphic-type.d.ts +0 -8
- package/unstable-preview-types/-private/debug/assert-polymorphic-type.d.ts.map +0 -1
- package/unstable-preview-types/-private/errors.d.ts +0 -303
- package/unstable-preview-types/-private/errors.d.ts.map +0 -1
- package/unstable-preview-types/-private/has-many.d.ts +0 -169
- package/unstable-preview-types/-private/has-many.d.ts.map +0 -1
- package/unstable-preview-types/-private/has-many.type-test.d.ts +0 -4
- package/unstable-preview-types/-private/has-many.type-test.d.ts.map +0 -1
- package/unstable-preview-types/-private/hooks.d.ts +0 -13
- package/unstable-preview-types/-private/hooks.d.ts.map +0 -1
- package/unstable-preview-types/-private/legacy-relationships-support.d.ts +0 -60
- package/unstable-preview-types/-private/legacy-relationships-support.d.ts.map +0 -1
- package/unstable-preview-types/-private/model-for-mixin.d.ts +0 -6
- package/unstable-preview-types/-private/model-for-mixin.d.ts.map +0 -1
- package/unstable-preview-types/-private/model-methods.d.ts +0 -37
- package/unstable-preview-types/-private/model-methods.d.ts.map +0 -1
- package/unstable-preview-types/-private/model.d.ts +0 -1303
- package/unstable-preview-types/-private/model.d.ts.map +0 -1
- package/unstable-preview-types/-private/model.type-test.d.ts +0 -4
- package/unstable-preview-types/-private/model.type-test.d.ts.map +0 -1
- package/unstable-preview-types/-private/notify-changes.d.ts +0 -8
- package/unstable-preview-types/-private/notify-changes.d.ts.map +0 -1
- package/unstable-preview-types/-private/promise-belongs-to.d.ts +0 -46
- package/unstable-preview-types/-private/promise-belongs-to.d.ts.map +0 -1
- package/unstable-preview-types/-private/promise-many-array.d.ts +0 -136
- package/unstable-preview-types/-private/promise-many-array.d.ts.map +0 -1
- package/unstable-preview-types/-private/promise-proxy-base.d.ts +0 -5
- package/unstable-preview-types/-private/promise-proxy-base.d.ts.map +0 -1
- package/unstable-preview-types/-private/record-state.d.ts +0 -80
- package/unstable-preview-types/-private/record-state.d.ts.map +0 -1
- package/unstable-preview-types/-private/references/belongs-to.d.ts +0 -506
- package/unstable-preview-types/-private/references/belongs-to.d.ts.map +0 -1
- package/unstable-preview-types/-private/references/has-many.d.ts +0 -518
- package/unstable-preview-types/-private/references/has-many.d.ts.map +0 -1
- package/unstable-preview-types/-private/schema-provider.d.ts +0 -65
- package/unstable-preview-types/-private/schema-provider.d.ts.map +0 -1
- package/unstable-preview-types/-private/type-utils.d.ts +0 -64
- package/unstable-preview-types/-private/type-utils.d.ts.map +0 -1
- package/unstable-preview-types/-private/util.d.ts +0 -8
- package/unstable-preview-types/-private/util.d.ts.map +0 -1
- package/unstable-preview-types/-private.d.ts.map +0 -1
- package/unstable-preview-types/hooks.d.ts.map +0 -1
- package/unstable-preview-types/index.d.ts.map +0 -1
- package/unstable-preview-types/migration-support.d.ts.map +0 -1
- package/unstable-preview-types/migration-support.type-test.d.ts +0 -4
- package/unstable-preview-types/migration-support.type-test.d.ts.map +0 -1
|
@@ -1,271 +1,23 @@
|
|
|
1
1
|
declare module '@ember-data/model/migration-support' {
|
|
2
2
|
/**
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
import type { SchemaService } from '@ember-data/store/types';
|
|
25
|
-
import type { StableRecordIdentifier } from '@warp-drive/core-types';
|
|
26
|
-
import type { ChangedAttributesHash } from '@warp-drive/core-types/cache';
|
|
27
|
-
import type { ObjectValue } from '@warp-drive/core-types/json/raw';
|
|
28
|
-
import type { TypedRecordInstance, TypeFromInstance } from '@warp-drive/core-types/record';
|
|
29
|
-
import type { Derivation, HashFn, Transformation } from '@warp-drive/core-types/schema/concepts';
|
|
30
|
-
import type { ArrayField, DerivedField, FieldSchema, GenericField, HashField, LegacyResourceSchema, ObjectField, ObjectSchema, ResourceSchema } from '@warp-drive/core-types/schema/fields';
|
|
31
|
-
import type { WithPartial } from '@warp-drive/core-types/utils';
|
|
32
|
-
import type { MinimalLegacyRecord } from '@ember-data/model/-private/model-methods';
|
|
33
|
-
import { belongsTo, hasMany } from '@ember-data/model/-private/model-methods';
|
|
34
|
-
import RecordState from '@ember-data/model/-private/record-state';
|
|
35
|
-
import type BelongsToReference from '@ember-data/model/-private/references/belongs-to';
|
|
36
|
-
import type HasManyReference from '@ember-data/model/-private/references/has-many';
|
|
37
|
-
import type { _MaybeBelongsToFields, MaybeHasManyFields } from '@ember-data/model/-private/type-utils';
|
|
38
|
-
export type WithLegacyDerivations<T extends TypedRecordInstance> = T & MinimalLegacyRecord & {
|
|
39
|
-
belongsTo: typeof belongsTo;
|
|
40
|
-
hasMany: typeof hasMany;
|
|
41
|
-
};
|
|
42
|
-
type AttributesSchema = ReturnType<Exclude<SchemaService['attributesDefinitionFor'], undefined>>;
|
|
43
|
-
type RelationshipsSchema = ReturnType<Exclude<SchemaService['relationshipsDefinitionFor'], undefined>>;
|
|
44
|
-
interface LegacyModeRecord<T extends TypedRecordInstance> {
|
|
45
|
-
id: string | null;
|
|
46
|
-
serialize(options?: Record<string, unknown>): unknown;
|
|
47
|
-
destroyRecord(options?: Record<string, unknown>): Promise<this>;
|
|
48
|
-
unloadRecord(): void;
|
|
49
|
-
changedAttributes(): ChangedAttributesHash;
|
|
50
|
-
rollbackAttributes(): void;
|
|
51
|
-
_createSnapshot(): Snapshot<T>;
|
|
52
|
-
save(options?: Record<string, unknown>): Promise<this>;
|
|
53
|
-
reload(options?: Record<string, unknown>): Promise<T>;
|
|
54
|
-
belongsTo<K extends _MaybeBelongsToFields<T>>(prop: K): BelongsToReference<T, K>;
|
|
55
|
-
hasMany<K extends MaybeHasManyFields<T>>(prop: K): HasManyReference<T, K>;
|
|
56
|
-
deleteRecord(): void;
|
|
57
|
-
adapterError: unknown;
|
|
58
|
-
constructor: {
|
|
59
|
-
modelName: TypeFromInstance<T>;
|
|
60
|
-
};
|
|
61
|
-
currentState: RecordState;
|
|
62
|
-
dirtyType: 'deleted' | 'created' | 'updated' | '';
|
|
63
|
-
errors: unknown;
|
|
64
|
-
hasDirtyAttributes: boolean;
|
|
65
|
-
isDeleted: boolean;
|
|
66
|
-
isEmpty: boolean;
|
|
67
|
-
isError: boolean;
|
|
68
|
-
isLoaded: boolean;
|
|
69
|
-
isLoading: boolean;
|
|
70
|
-
isDestroying: boolean;
|
|
71
|
-
isDestroyed: boolean;
|
|
72
|
-
isNew: boolean;
|
|
73
|
-
isSaving: boolean;
|
|
74
|
-
isValid: boolean;
|
|
75
|
-
}
|
|
76
|
-
/**
|
|
77
|
-
* A Type utility that enables quickly adding type information for the fields
|
|
78
|
-
* defined by `import { withDefaults } from '@ember-data/model/migration-support'`.
|
|
79
|
-
*
|
|
80
|
-
* Example:
|
|
81
|
-
*
|
|
82
|
-
* ```ts
|
|
83
|
-
* import { withDefaults, WithLegacy } from '@ember-data/model/migration-support';
|
|
84
|
-
* import { Type } from '@warp-drive/core-types/symbols';
|
|
85
|
-
* import type { HasMany } from '@ember-data/model';
|
|
86
|
-
*
|
|
87
|
-
* export const UserSchema = withDefaults({
|
|
88
|
-
* type: 'user',
|
|
89
|
-
* fields: [
|
|
90
|
-
* { name: 'firstName', kind: 'attribute' },
|
|
91
|
-
* { name: 'lastName', kind: 'attribute' },
|
|
92
|
-
* { name: 'age', kind: 'attribute' },
|
|
93
|
-
* { name: 'friends',
|
|
94
|
-
* kind: 'hasMany',
|
|
95
|
-
* type: 'user',
|
|
96
|
-
* options: { inverse: 'friends', async: false }
|
|
97
|
-
* },
|
|
98
|
-
* { name: 'bestFriend',
|
|
99
|
-
* kind: 'belongsTo',
|
|
100
|
-
* type: 'user',
|
|
101
|
-
* options: { inverse: null, async: false }
|
|
102
|
-
* },
|
|
103
|
-
* ],
|
|
104
|
-
* });
|
|
105
|
-
*
|
|
106
|
-
* export type User = WithLegacy<{
|
|
107
|
-
* firstName: string;
|
|
108
|
-
* lastName: string;
|
|
109
|
-
* age: number;
|
|
110
|
-
* friends: HasMany<User>;
|
|
111
|
-
* bestFriend: User | null;
|
|
112
|
-
* [Type]: 'user';
|
|
113
|
-
* }>
|
|
114
|
-
* ```
|
|
115
|
-
*
|
|
116
|
-
* @typedoc
|
|
117
|
-
*/
|
|
118
|
-
export type WithLegacy<T extends TypedRecordInstance> = T & LegacyModeRecord<T>;
|
|
119
|
-
/**
|
|
120
|
-
* A function which adds the necessary fields to a schema and marks it as
|
|
121
|
-
* being in LegacyMode. This is used to support the legacy features of
|
|
122
|
-
* @ember-data/model while migrating to WarpDrive.
|
|
123
|
-
*
|
|
124
|
-
* Example:
|
|
125
|
-
*
|
|
126
|
-
* ```ts
|
|
127
|
-
* import { withDefaults, WithLegacy } from '@ember-data/model/migration-support';
|
|
128
|
-
* import { Type } from '@warp-drive/core-types/symbols';
|
|
129
|
-
* import type { HasMany } from '@ember-data/model';
|
|
130
|
-
*
|
|
131
|
-
* export const UserSchema = withDefaults({
|
|
132
|
-
* type: 'user',
|
|
133
|
-
* fields: [
|
|
134
|
-
* { name: 'firstName', kind: 'attribute' },
|
|
135
|
-
* { name: 'lastName', kind: 'attribute' },
|
|
136
|
-
* { name: 'age', kind: 'attribute' },
|
|
137
|
-
* { name: 'friends',
|
|
138
|
-
* kind: 'hasMany',
|
|
139
|
-
* type: 'user',
|
|
140
|
-
* options: { inverse: 'friends', async: false }
|
|
141
|
-
* },
|
|
142
|
-
* { name: 'bestFriend',
|
|
143
|
-
* kind: 'belongsTo',
|
|
144
|
-
* type: 'user',
|
|
145
|
-
* options: { inverse: null, async: false }
|
|
146
|
-
* },
|
|
147
|
-
* ],
|
|
148
|
-
* });
|
|
149
|
-
*
|
|
150
|
-
* export type User = WithLegacy<{
|
|
151
|
-
* firstName: string;
|
|
152
|
-
* lastName: string;
|
|
153
|
-
* age: number;
|
|
154
|
-
* friends: HasMany<User>;
|
|
155
|
-
* bestFriend: User | null;
|
|
156
|
-
* [Type]: 'user';
|
|
157
|
-
* }>
|
|
158
|
-
* ```
|
|
159
|
-
*
|
|
160
|
-
* Using this function require registering the derivations
|
|
161
|
-
* it requires with the schema service.
|
|
162
|
-
*
|
|
163
|
-
* ```ts
|
|
164
|
-
* import { registerDerivations } from '@ember-data/model/migration-support';
|
|
165
|
-
*
|
|
166
|
-
* registerDerivations(schema);
|
|
167
|
-
* ```
|
|
168
|
-
*
|
|
169
|
-
* @method withDefaults
|
|
170
|
-
* @for @ember-data/model/migration-support
|
|
171
|
-
* @static
|
|
172
|
-
* @param {LegacyResourceSchema} schema The schema to add legacy support to.
|
|
173
|
-
* @return {LegacyResourceSchema} The schema with legacy support added.
|
|
174
|
-
* @public
|
|
175
|
-
*/
|
|
176
|
-
export function withDefaults(schema: WithPartial<LegacyResourceSchema, 'legacy' | 'identity'>): LegacyResourceSchema;
|
|
177
|
-
/**
|
|
178
|
-
* A function which registers the necessary derivations to support
|
|
179
|
-
* the LegacyMode features of @ember-data/model while migrating to WarpDrive.
|
|
180
|
-
*
|
|
181
|
-
* This must be called in order to use the fields added by:
|
|
182
|
-
*
|
|
183
|
-
* ```ts
|
|
184
|
-
* import { withDefaults } from '@ember-data/model/migration-support';
|
|
185
|
-
* ```
|
|
186
|
-
*
|
|
187
|
-
* @method registerDerivations
|
|
188
|
-
* @for @ember-data/model/migration-support
|
|
189
|
-
* @static
|
|
190
|
-
* @param {SchemaService} schema The schema service to register the derivations with.
|
|
191
|
-
* @return {void}
|
|
192
|
-
* @public
|
|
193
|
-
*/
|
|
194
|
-
export function registerDerivations(schema: SchemaService): void;
|
|
195
|
-
/**
|
|
196
|
-
* A class which provides a schema service that delegates between
|
|
197
|
-
* a primary schema service and one that supports legacy model
|
|
198
|
-
* classes as its schema source.
|
|
199
|
-
*
|
|
200
|
-
* When the primary schema service has a schema for the given
|
|
201
|
-
* resource, it will be used. Otherwise, the fallback schema
|
|
202
|
-
* service will be used.
|
|
203
|
-
*
|
|
204
|
-
* This can be used when incrementally migrating from Models to
|
|
205
|
-
* SchemaRecords by enabling unmigrated Models to continue to
|
|
206
|
-
* provide their own schema information to the application.
|
|
207
|
-
*
|
|
208
|
-
* ```ts
|
|
209
|
-
* import { DelegatingSchemaService } from '@ember-data/model/migration-support';
|
|
210
|
-
* import { SchemaService } from '@warp-drive/schema-record';
|
|
211
|
-
*
|
|
212
|
-
* class AppStore extends Store {
|
|
213
|
-
* createSchemaService() {
|
|
214
|
-
* const schema = new SchemaService();
|
|
215
|
-
* return new DelegatingSchemaService(this, schema);
|
|
216
|
-
* }
|
|
217
|
-
* }
|
|
218
|
-
* ```
|
|
219
|
-
*
|
|
220
|
-
* All calls to register resources, derivations, transformations, hash functions
|
|
221
|
-
* etc. will be delegated to the primary schema service.
|
|
222
|
-
*
|
|
223
|
-
* @class DelegatingSchemaService
|
|
224
|
-
* @extends SchemaService
|
|
225
|
-
* @public
|
|
226
|
-
*/
|
|
227
|
-
export interface DelegatingSchemaService {
|
|
228
|
-
attributesDefinitionFor?(resource: StableRecordIdentifier | {
|
|
229
|
-
type: string;
|
|
230
|
-
}): AttributesSchema;
|
|
231
|
-
relationshipsDefinitionFor?(resource: StableRecordIdentifier | {
|
|
232
|
-
type: string;
|
|
233
|
-
}): RelationshipsSchema;
|
|
234
|
-
doesTypeExist?(type: string): boolean;
|
|
235
|
-
}
|
|
236
|
-
export class DelegatingSchemaService implements SchemaService {
|
|
237
|
-
_preferred: SchemaService;
|
|
238
|
-
_secondary: SchemaService;
|
|
239
|
-
constructor(store: Store, schema: SchemaService);
|
|
240
|
-
resourceTypes(): Readonly<string[]>;
|
|
241
|
-
hasResource(resource: StableRecordIdentifier | {
|
|
242
|
-
type: string;
|
|
243
|
-
}): boolean;
|
|
244
|
-
hasTrait(type: string): boolean;
|
|
245
|
-
resourceHasTrait(resource: StableRecordIdentifier | {
|
|
246
|
-
type: string;
|
|
247
|
-
}, trait: string): boolean;
|
|
248
|
-
fields(resource: StableRecordIdentifier | {
|
|
249
|
-
type: string;
|
|
250
|
-
}): Map<string, FieldSchema>;
|
|
251
|
-
transformation(field: GenericField | ObjectField | ArrayField | {
|
|
252
|
-
type: string;
|
|
253
|
-
}): Transformation;
|
|
254
|
-
hashFn(field: HashField | {
|
|
255
|
-
type: string;
|
|
256
|
-
}): HashFn;
|
|
257
|
-
derivation(field: DerivedField | {
|
|
258
|
-
type: string;
|
|
259
|
-
}): Derivation;
|
|
260
|
-
resource(resource: StableRecordIdentifier | {
|
|
261
|
-
type: string;
|
|
262
|
-
}): ResourceSchema | ObjectSchema;
|
|
263
|
-
registerResources(schemas: Array<ResourceSchema | ObjectSchema>): void;
|
|
264
|
-
registerResource(schema: ResourceSchema | ObjectSchema): void;
|
|
265
|
-
registerTransformation(transform: Transformation): void;
|
|
266
|
-
registerDerivation<R, T, FM extends ObjectValue | null>(derivation: Derivation<R, T, FM>): void;
|
|
267
|
-
registerHashFn(hashFn: HashFn): void;
|
|
268
|
-
}
|
|
269
|
-
export {};
|
|
270
|
-
}
|
|
271
|
-
//# sourceMappingURL=migration-support.d.ts.map
|
|
3
|
+
* This module provides support for migrating away from @ember-data/model
|
|
4
|
+
* to @warp-drive/schema-record.
|
|
5
|
+
*
|
|
6
|
+
* It includes:
|
|
7
|
+
*
|
|
8
|
+
* - A `withDefaults` function to assist in creating a schema in LegacyMode
|
|
9
|
+
* - A `registerDerivations` function to register the derivations necessary to support LegacyMode
|
|
10
|
+
* - A `DelegatingSchemaService` that can be used to provide a schema service that works with both
|
|
11
|
+
* @ember-data/model and @warp-drive/schema-record simultaneously for migration purposes.
|
|
12
|
+
* - A `WithLegacy` type util that can be used to create a type that includes the legacy
|
|
13
|
+
* properties and methods of a record.
|
|
14
|
+
*
|
|
15
|
+
* Using LegacyMode features on a SchemaRecord *requires* the use of these derivations and schema
|
|
16
|
+
* additions. LegacyMode is not intended to be a long-term solution, but rather a stepping stone
|
|
17
|
+
* to assist in more rapidly adopting modern WarpDrive features.
|
|
18
|
+
*
|
|
19
|
+
* @module
|
|
20
|
+
*/
|
|
21
|
+
export * from "@warp-drive/legacy/model/migration-support";
|
|
22
|
+
|
|
23
|
+
}
|
package/dist/-private.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"-private.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;"}
|