@ember-data/model 5.6.0-beta.0 → 5.6.0-beta.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/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
package/addon-main.cjs
CHANGED
package/dist/-private.js
CHANGED
|
@@ -1,3 +1 @@
|
|
|
1
|
-
export
|
|
2
|
-
export { E as Errors, L as LEGACY_SUPPORT, M as Model, P as PromiseBelongsTo, a as PromiseManyArray, l as lookupLegacySupport } from "./model-Dkk-TZlL.js";
|
|
3
|
-
export { RelatedCollection as ManyArray } from '@ember-data/store/-private';
|
|
1
|
+
export * from '@warp-drive/legacy/model/-private';
|
package/dist/hooks.js
CHANGED
|
@@ -1,2 +1 @@
|
|
|
1
|
-
export {
|
|
2
|
-
export { b as buildSchema } from "./schema-provider-DyG6fJXt.js";
|
|
1
|
+
export { buildSchema, instantiateRecord, modelFor, teardownRecord } from '@warp-drive/legacy/model';
|
package/dist/index.js
CHANGED
|
@@ -1,5 +1 @@
|
|
|
1
|
-
export {
|
|
2
|
-
export { M as default } from "./model-Dkk-TZlL.js";
|
|
3
|
-
import '@ember-data/store/-private';
|
|
4
|
-
export { i as instantiateRecord, m as modelFor, t as teardownRecord } from "./hooks-o1U_cEA3.js";
|
|
5
|
-
export { M as ModelSchemaProvider } from "./schema-provider-DyG6fJXt.js";
|
|
1
|
+
export { attr, belongsTo, buildSchema, default, hasMany, instantiateRecord, modelFor, teardownRecord } from '@warp-drive/legacy/model';
|
|
@@ -1,388 +1 @@
|
|
|
1
|
-
|
|
2
|
-
import { getOrSetGlobal } from '@warp-drive/core-types/-private';
|
|
3
|
-
import { Type } from '@warp-drive/core-types/symbols';
|
|
4
|
-
import '@ember/object';
|
|
5
|
-
import '@ember-data/store/-private';
|
|
6
|
-
import '@ember/debug';
|
|
7
|
-
import '@ember-data/request-utils/string';
|
|
8
|
-
import { macroCondition, getGlobalConfig } from '@embroider/macros';
|
|
9
|
-
import { u as unloadRecord, s as serialize, b as save, r as rollbackAttributes, c as reload, h as hasMany, E as Errors, d as destroyRecord, e as deleteRecord, R as RecordState, f as changedAttributes, g as belongsTo, i as createSnapshot } from "./model-Dkk-TZlL.js";
|
|
10
|
-
import '@ember/application';
|
|
11
|
-
import { b as buildSchema } from "./schema-provider-DyG6fJXt.js";
|
|
12
|
-
|
|
13
|
-
/**
|
|
14
|
-
* This module provides support for migrating away from @ember-data/model
|
|
15
|
-
* to @warp-drive/schema-record.
|
|
16
|
-
*
|
|
17
|
-
* It includes:
|
|
18
|
-
*
|
|
19
|
-
* - A `withDefaults` function to assist in creating a schema in LegacyMode
|
|
20
|
-
* - A `registerDerivations` function to register the derivations necessary to support LegacyMode
|
|
21
|
-
* - A `DelegatingSchemaService` that can be used to provide a schema service that works with both
|
|
22
|
-
* @ember-data/model and @warp-drive/schema-record simultaneously for migration purposes.
|
|
23
|
-
* - A `WithLegacy` type util that can be used to create a type that includes the legacy
|
|
24
|
-
* properties and methods of a record.
|
|
25
|
-
*
|
|
26
|
-
* Using LegacyMode features on a SchemaRecord *requires* the use of these derivations and schema
|
|
27
|
-
* additions. LegacyMode is not intended to be a long-term solution, but rather a stepping stone
|
|
28
|
-
* to assist in more rapidly adopting modern WarpDrive features.
|
|
29
|
-
*
|
|
30
|
-
* @module @ember-data/model/migration-support
|
|
31
|
-
* @main @ember-data/model/migration-support
|
|
32
|
-
*/
|
|
33
|
-
|
|
34
|
-
// 'isDestroying', 'isDestroyed'
|
|
35
|
-
const LegacyFields = ['_createSnapshot', 'adapterError', 'belongsTo', 'changedAttributes', 'constructor', 'currentState', 'deleteRecord', 'destroyRecord', 'dirtyType', 'errors', 'hasDirtyAttributes', 'hasMany', 'isDeleted', 'isEmpty', 'isError', 'isLoaded', 'isLoading', 'isNew', 'isSaving', 'isValid', 'reload', 'rollbackAttributes', 'save', 'serialize', 'unloadRecord'];
|
|
36
|
-
|
|
37
|
-
/**
|
|
38
|
-
* A Type utility that enables quickly adding type information for the fields
|
|
39
|
-
* defined by `import { withDefaults } from '@ember-data/model/migration-support'`.
|
|
40
|
-
*
|
|
41
|
-
* Example:
|
|
42
|
-
*
|
|
43
|
-
* ```ts
|
|
44
|
-
* import { withDefaults, WithLegacy } from '@ember-data/model/migration-support';
|
|
45
|
-
* import { Type } from '@warp-drive/core-types/symbols';
|
|
46
|
-
* import type { HasMany } from '@ember-data/model';
|
|
47
|
-
*
|
|
48
|
-
* export const UserSchema = withDefaults({
|
|
49
|
-
* type: 'user',
|
|
50
|
-
* fields: [
|
|
51
|
-
* { name: 'firstName', kind: 'attribute' },
|
|
52
|
-
* { name: 'lastName', kind: 'attribute' },
|
|
53
|
-
* { name: 'age', kind: 'attribute' },
|
|
54
|
-
* { name: 'friends',
|
|
55
|
-
* kind: 'hasMany',
|
|
56
|
-
* type: 'user',
|
|
57
|
-
* options: { inverse: 'friends', async: false }
|
|
58
|
-
* },
|
|
59
|
-
* { name: 'bestFriend',
|
|
60
|
-
* kind: 'belongsTo',
|
|
61
|
-
* type: 'user',
|
|
62
|
-
* options: { inverse: null, async: false }
|
|
63
|
-
* },
|
|
64
|
-
* ],
|
|
65
|
-
* });
|
|
66
|
-
*
|
|
67
|
-
* export type User = WithLegacy<{
|
|
68
|
-
* firstName: string;
|
|
69
|
-
* lastName: string;
|
|
70
|
-
* age: number;
|
|
71
|
-
* friends: HasMany<User>;
|
|
72
|
-
* bestFriend: User | null;
|
|
73
|
-
* [Type]: 'user';
|
|
74
|
-
* }>
|
|
75
|
-
* ```
|
|
76
|
-
*
|
|
77
|
-
* @typedoc
|
|
78
|
-
*/
|
|
79
|
-
|
|
80
|
-
const LegacySupport = getOrSetGlobal('LegacySupport', new WeakMap());
|
|
81
|
-
function legacySupport(record, options, prop) {
|
|
82
|
-
let state = LegacySupport.get(record);
|
|
83
|
-
if (!state) {
|
|
84
|
-
state = {};
|
|
85
|
-
LegacySupport.set(record, state);
|
|
86
|
-
}
|
|
87
|
-
switch (prop) {
|
|
88
|
-
case '_createSnapshot':
|
|
89
|
-
return createSnapshot;
|
|
90
|
-
case 'adapterError':
|
|
91
|
-
return record.currentState.adapterError;
|
|
92
|
-
case 'belongsTo':
|
|
93
|
-
return belongsTo;
|
|
94
|
-
case 'changedAttributes':
|
|
95
|
-
return changedAttributes;
|
|
96
|
-
case 'constructor':
|
|
97
|
-
return state._constructor = state._constructor || {
|
|
98
|
-
isModel: true,
|
|
99
|
-
name: `Record<${recordIdentifierFor(record).type}>`,
|
|
100
|
-
modelName: recordIdentifierFor(record).type
|
|
101
|
-
};
|
|
102
|
-
case 'currentState':
|
|
103
|
-
return state.recordState = state.recordState || new RecordState(record);
|
|
104
|
-
case 'deleteRecord':
|
|
105
|
-
return deleteRecord;
|
|
106
|
-
case 'destroyRecord':
|
|
107
|
-
return destroyRecord;
|
|
108
|
-
case 'dirtyType':
|
|
109
|
-
return record.currentState.dirtyType;
|
|
110
|
-
case 'errors':
|
|
111
|
-
// @ts-expect-error
|
|
112
|
-
// eslint-disable-next-line @typescript-eslint/no-unsafe-call
|
|
113
|
-
return state.errors = state.errors || Errors.create({
|
|
114
|
-
__record: record
|
|
115
|
-
});
|
|
116
|
-
case 'hasDirtyAttributes':
|
|
117
|
-
return record.currentState.isDirty;
|
|
118
|
-
case 'hasMany':
|
|
119
|
-
return hasMany;
|
|
120
|
-
case 'isDeleted':
|
|
121
|
-
return record.currentState.isDeleted;
|
|
122
|
-
case 'isEmpty':
|
|
123
|
-
return record.currentState.isEmpty;
|
|
124
|
-
case 'isError':
|
|
125
|
-
return record.currentState.isError;
|
|
126
|
-
case 'isLoaded':
|
|
127
|
-
return record.currentState.isLoaded;
|
|
128
|
-
case 'isLoading':
|
|
129
|
-
return record.currentState.isLoading;
|
|
130
|
-
case 'isNew':
|
|
131
|
-
return record.currentState.isNew;
|
|
132
|
-
case 'isSaving':
|
|
133
|
-
return record.currentState.isSaving;
|
|
134
|
-
case 'isValid':
|
|
135
|
-
return record.currentState.isValid;
|
|
136
|
-
case 'reload':
|
|
137
|
-
return reload;
|
|
138
|
-
case 'rollbackAttributes':
|
|
139
|
-
return rollbackAttributes;
|
|
140
|
-
case 'save':
|
|
141
|
-
return save;
|
|
142
|
-
case 'serialize':
|
|
143
|
-
return serialize;
|
|
144
|
-
case 'unloadRecord':
|
|
145
|
-
return unloadRecord;
|
|
146
|
-
default:
|
|
147
|
-
macroCondition(getGlobalConfig().WarpDrive.env.DEBUG) ? (test => {
|
|
148
|
-
{
|
|
149
|
-
throw new Error(`${prop} is not a supported legacy field`);
|
|
150
|
-
}
|
|
151
|
-
})() : {};
|
|
152
|
-
}
|
|
153
|
-
}
|
|
154
|
-
legacySupport[Type] = '@legacy';
|
|
155
|
-
|
|
156
|
-
/**
|
|
157
|
-
* A function which adds the necessary fields to a schema and marks it as
|
|
158
|
-
* being in LegacyMode. This is used to support the legacy features of
|
|
159
|
-
* @ember-data/model while migrating to WarpDrive.
|
|
160
|
-
*
|
|
161
|
-
* Example:
|
|
162
|
-
*
|
|
163
|
-
* ```ts
|
|
164
|
-
* import { withDefaults, WithLegacy } from '@ember-data/model/migration-support';
|
|
165
|
-
* import { Type } from '@warp-drive/core-types/symbols';
|
|
166
|
-
* import type { HasMany } from '@ember-data/model';
|
|
167
|
-
*
|
|
168
|
-
* export const UserSchema = withDefaults({
|
|
169
|
-
* type: 'user',
|
|
170
|
-
* fields: [
|
|
171
|
-
* { name: 'firstName', kind: 'attribute' },
|
|
172
|
-
* { name: 'lastName', kind: 'attribute' },
|
|
173
|
-
* { name: 'age', kind: 'attribute' },
|
|
174
|
-
* { name: 'friends',
|
|
175
|
-
* kind: 'hasMany',
|
|
176
|
-
* type: 'user',
|
|
177
|
-
* options: { inverse: 'friends', async: false }
|
|
178
|
-
* },
|
|
179
|
-
* { name: 'bestFriend',
|
|
180
|
-
* kind: 'belongsTo',
|
|
181
|
-
* type: 'user',
|
|
182
|
-
* options: { inverse: null, async: false }
|
|
183
|
-
* },
|
|
184
|
-
* ],
|
|
185
|
-
* });
|
|
186
|
-
*
|
|
187
|
-
* export type User = WithLegacy<{
|
|
188
|
-
* firstName: string;
|
|
189
|
-
* lastName: string;
|
|
190
|
-
* age: number;
|
|
191
|
-
* friends: HasMany<User>;
|
|
192
|
-
* bestFriend: User | null;
|
|
193
|
-
* [Type]: 'user';
|
|
194
|
-
* }>
|
|
195
|
-
* ```
|
|
196
|
-
*
|
|
197
|
-
* Using this function require registering the derivations
|
|
198
|
-
* it requires with the schema service.
|
|
199
|
-
*
|
|
200
|
-
* ```ts
|
|
201
|
-
* import { registerDerivations } from '@ember-data/model/migration-support';
|
|
202
|
-
*
|
|
203
|
-
* registerDerivations(schema);
|
|
204
|
-
* ```
|
|
205
|
-
*
|
|
206
|
-
* @method withDefaults
|
|
207
|
-
* @for @ember-data/model/migration-support
|
|
208
|
-
* @static
|
|
209
|
-
* @param {LegacyResourceSchema} schema The schema to add legacy support to.
|
|
210
|
-
* @return {LegacyResourceSchema} The schema with legacy support added.
|
|
211
|
-
* @public
|
|
212
|
-
*/
|
|
213
|
-
function withDefaults(schema) {
|
|
214
|
-
schema.legacy = true;
|
|
215
|
-
schema.identity = {
|
|
216
|
-
kind: '@id',
|
|
217
|
-
name: 'id'
|
|
218
|
-
};
|
|
219
|
-
LegacyFields.forEach(field => {
|
|
220
|
-
schema.fields.push({
|
|
221
|
-
type: '@legacy',
|
|
222
|
-
name: field,
|
|
223
|
-
kind: 'derived'
|
|
224
|
-
});
|
|
225
|
-
});
|
|
226
|
-
schema.fields.push({
|
|
227
|
-
name: 'isReloading',
|
|
228
|
-
kind: '@local',
|
|
229
|
-
type: 'boolean',
|
|
230
|
-
options: {
|
|
231
|
-
defaultValue: false
|
|
232
|
-
}
|
|
233
|
-
});
|
|
234
|
-
schema.fields.push({
|
|
235
|
-
name: 'isDestroying',
|
|
236
|
-
kind: '@local',
|
|
237
|
-
type: 'boolean',
|
|
238
|
-
options: {
|
|
239
|
-
defaultValue: false
|
|
240
|
-
}
|
|
241
|
-
});
|
|
242
|
-
schema.fields.push({
|
|
243
|
-
name: 'isDestroyed',
|
|
244
|
-
kind: '@local',
|
|
245
|
-
type: 'boolean',
|
|
246
|
-
options: {
|
|
247
|
-
defaultValue: false
|
|
248
|
-
}
|
|
249
|
-
});
|
|
250
|
-
return schema;
|
|
251
|
-
}
|
|
252
|
-
|
|
253
|
-
/**
|
|
254
|
-
* A function which registers the necessary derivations to support
|
|
255
|
-
* the LegacyMode features of @ember-data/model while migrating to WarpDrive.
|
|
256
|
-
*
|
|
257
|
-
* This must be called in order to use the fields added by:
|
|
258
|
-
*
|
|
259
|
-
* ```ts
|
|
260
|
-
* import { withDefaults } from '@ember-data/model/migration-support';
|
|
261
|
-
* ```
|
|
262
|
-
*
|
|
263
|
-
* @method registerDerivations
|
|
264
|
-
* @for @ember-data/model/migration-support
|
|
265
|
-
* @static
|
|
266
|
-
* @param {SchemaService} schema The schema service to register the derivations with.
|
|
267
|
-
* @return {void}
|
|
268
|
-
* @public
|
|
269
|
-
*/
|
|
270
|
-
function registerDerivations(schema) {
|
|
271
|
-
schema.registerDerivation(legacySupport);
|
|
272
|
-
}
|
|
273
|
-
|
|
274
|
-
/**
|
|
275
|
-
* A class which provides a schema service that delegates between
|
|
276
|
-
* a primary schema service and one that supports legacy model
|
|
277
|
-
* classes as its schema source.
|
|
278
|
-
*
|
|
279
|
-
* When the primary schema service has a schema for the given
|
|
280
|
-
* resource, it will be used. Otherwise, the fallback schema
|
|
281
|
-
* service will be used.
|
|
282
|
-
*
|
|
283
|
-
* This can be used when incrementally migrating from Models to
|
|
284
|
-
* SchemaRecords by enabling unmigrated Models to continue to
|
|
285
|
-
* provide their own schema information to the application.
|
|
286
|
-
*
|
|
287
|
-
* ```ts
|
|
288
|
-
* import { DelegatingSchemaService } from '@ember-data/model/migration-support';
|
|
289
|
-
* import { SchemaService } from '@warp-drive/schema-record';
|
|
290
|
-
*
|
|
291
|
-
* class AppStore extends Store {
|
|
292
|
-
* createSchemaService() {
|
|
293
|
-
* const schema = new SchemaService();
|
|
294
|
-
* return new DelegatingSchemaService(this, schema);
|
|
295
|
-
* }
|
|
296
|
-
* }
|
|
297
|
-
* ```
|
|
298
|
-
*
|
|
299
|
-
* All calls to register resources, derivations, transformations, hash functions
|
|
300
|
-
* etc. will be delegated to the primary schema service.
|
|
301
|
-
*
|
|
302
|
-
* @class DelegatingSchemaService
|
|
303
|
-
* @extends SchemaService
|
|
304
|
-
* @public
|
|
305
|
-
*/
|
|
306
|
-
|
|
307
|
-
class DelegatingSchemaService {
|
|
308
|
-
_preferred;
|
|
309
|
-
_secondary;
|
|
310
|
-
constructor(store, schema) {
|
|
311
|
-
this._preferred = schema;
|
|
312
|
-
this._secondary = buildSchema(store);
|
|
313
|
-
}
|
|
314
|
-
resourceTypes() {
|
|
315
|
-
return Array.from(new Set(this._preferred.resourceTypes().concat(this._secondary.resourceTypes())));
|
|
316
|
-
}
|
|
317
|
-
hasResource(resource) {
|
|
318
|
-
return this._preferred.hasResource(resource) || this._secondary.hasResource(resource);
|
|
319
|
-
}
|
|
320
|
-
hasTrait(type) {
|
|
321
|
-
if (this._preferred.hasResource({
|
|
322
|
-
type
|
|
323
|
-
})) {
|
|
324
|
-
return this._preferred.hasTrait(type);
|
|
325
|
-
}
|
|
326
|
-
return this._secondary.hasTrait(type);
|
|
327
|
-
}
|
|
328
|
-
resourceHasTrait(resource, trait) {
|
|
329
|
-
if (this._preferred.hasResource(resource)) {
|
|
330
|
-
return this._preferred.resourceHasTrait(resource, trait);
|
|
331
|
-
}
|
|
332
|
-
return this._secondary.resourceHasTrait(resource, trait);
|
|
333
|
-
}
|
|
334
|
-
fields(resource) {
|
|
335
|
-
if (this._preferred.hasResource(resource)) {
|
|
336
|
-
return this._preferred.fields(resource);
|
|
337
|
-
}
|
|
338
|
-
return this._secondary.fields(resource);
|
|
339
|
-
}
|
|
340
|
-
transformation(field) {
|
|
341
|
-
return this._preferred.transformation(field);
|
|
342
|
-
}
|
|
343
|
-
hashFn(field) {
|
|
344
|
-
return this._preferred.hashFn(field);
|
|
345
|
-
}
|
|
346
|
-
derivation(field) {
|
|
347
|
-
return this._preferred.derivation(field);
|
|
348
|
-
}
|
|
349
|
-
resource(resource) {
|
|
350
|
-
if (this._preferred.hasResource(resource)) {
|
|
351
|
-
return this._preferred.resource(resource);
|
|
352
|
-
}
|
|
353
|
-
return this._secondary.resource(resource);
|
|
354
|
-
}
|
|
355
|
-
registerResources(schemas) {
|
|
356
|
-
this._preferred.registerResources(schemas);
|
|
357
|
-
}
|
|
358
|
-
registerResource(schema) {
|
|
359
|
-
this._preferred.registerResource(schema);
|
|
360
|
-
}
|
|
361
|
-
registerTransformation(transform) {
|
|
362
|
-
this._preferred.registerTransformation(transform);
|
|
363
|
-
}
|
|
364
|
-
registerDerivation(derivation) {
|
|
365
|
-
this._preferred.registerDerivation(derivation);
|
|
366
|
-
}
|
|
367
|
-
registerHashFn(hashFn) {
|
|
368
|
-
this._preferred.registerHashFn(hashFn);
|
|
369
|
-
}
|
|
370
|
-
}
|
|
371
|
-
if (macroCondition(getGlobalConfig().WarpDrive.deprecations.ENABLE_LEGACY_SCHEMA_SERVICE)) {
|
|
372
|
-
DelegatingSchemaService.prototype.attributesDefinitionFor = function (resource) {
|
|
373
|
-
if (this._preferred.hasResource(resource)) {
|
|
374
|
-
return this._preferred.attributesDefinitionFor(resource);
|
|
375
|
-
}
|
|
376
|
-
return this._secondary.attributesDefinitionFor(resource);
|
|
377
|
-
};
|
|
378
|
-
DelegatingSchemaService.prototype.relationshipsDefinitionFor = function (resource) {
|
|
379
|
-
if (this._preferred.hasResource(resource)) {
|
|
380
|
-
return this._preferred.relationshipsDefinitionFor(resource);
|
|
381
|
-
}
|
|
382
|
-
return this._secondary.relationshipsDefinitionFor(resource);
|
|
383
|
-
};
|
|
384
|
-
DelegatingSchemaService.prototype.doesTypeExist = function (type) {
|
|
385
|
-
return this._preferred.doesTypeExist?.(type) || this._secondary.doesTypeExist?.(type) || false;
|
|
386
|
-
};
|
|
387
|
-
}
|
|
388
|
-
export { DelegatingSchemaService, registerDerivations, withDefaults };
|
|
1
|
+
export * from '@warp-drive/legacy/model/migration-support';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ember-data/model",
|
|
3
|
-
"version": "5.6.0-beta.
|
|
3
|
+
"version": "5.6.0-beta.1",
|
|
4
4
|
"description": "A basic Ember implementation of a resource presentation layer for use with @ember-data/store",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"ember-addon"
|
|
@@ -41,54 +41,26 @@
|
|
|
41
41
|
"types": "./unstable-preview-types/index.d.ts"
|
|
42
42
|
}
|
|
43
43
|
},
|
|
44
|
-
"peerDependencies": {
|
|
45
|
-
"ember-source": "3.28.12 || ^4.0.4 || ^5.0.0 || ^6.0.0",
|
|
46
|
-
"@ember-data/graph": "5.6.0-beta.0",
|
|
47
|
-
"@ember-data/json-api": "5.6.0-beta.0",
|
|
48
|
-
"@ember-data/legacy-compat": "5.6.0-beta.0",
|
|
49
|
-
"@ember-data/store": "5.6.0-beta.0",
|
|
50
|
-
"@ember-data/request-utils": "5.6.0-beta.0",
|
|
51
|
-
"@warp-drive/core-types": "5.6.0-beta.0"
|
|
52
|
-
},
|
|
53
|
-
"peerDependenciesMeta": {
|
|
54
|
-
"@ember-data/json-api": {
|
|
55
|
-
"optional": true
|
|
56
|
-
},
|
|
57
|
-
"@ember-data/graph": {
|
|
58
|
-
"optional": true
|
|
59
|
-
}
|
|
60
|
-
},
|
|
44
|
+
"peerDependencies": {},
|
|
61
45
|
"dependencies": {
|
|
62
46
|
"@ember/edition-utils": "^1.2.0",
|
|
63
47
|
"@embroider/macros": "^1.16.12",
|
|
64
48
|
"ember-cli-string-utils": "^1.1.0",
|
|
65
49
|
"ember-cli-test-info": "^1.0.0",
|
|
66
50
|
"inflection": "~3.0.2",
|
|
67
|
-
"@warp-drive/
|
|
51
|
+
"@warp-drive/core": "5.6.0-beta.0",
|
|
52
|
+
"@warp-drive/legacy": "5.6.0-beta.0",
|
|
53
|
+
"@warp-drive/utilities": "5.6.0-beta.0"
|
|
68
54
|
},
|
|
69
55
|
"devDependencies": {
|
|
70
56
|
"@babel/core": "^7.26.10",
|
|
71
57
|
"@babel/plugin-transform-typescript": "^7.27.0",
|
|
72
58
|
"@babel/preset-env": "^7.26.9",
|
|
73
59
|
"@babel/preset-typescript": "^7.27.0",
|
|
74
|
-
"@
|
|
75
|
-
"@ember-data/json-api": "5.6.0-beta.0",
|
|
76
|
-
"@ember-data/legacy-compat": "5.6.0-beta.0",
|
|
77
|
-
"@ember-data/request": "5.6.0-beta.0",
|
|
78
|
-
"@ember-data/request-utils": "5.6.0-beta.0",
|
|
79
|
-
"@ember-data/store": "5.6.0-beta.0",
|
|
80
|
-
"@ember/test-waiters": "^4.1.0",
|
|
81
|
-
"@glimmer/component": "^2.0.0",
|
|
82
|
-
"@warp-drive/core-types": "5.6.0-beta.0",
|
|
83
|
-
"@warp-drive/internal-config": "5.6.0-beta.0",
|
|
84
|
-
"decorator-transforms": "^2.3.0",
|
|
85
|
-
"ember-source": "~6.3.0",
|
|
60
|
+
"@warp-drive/internal-config": "5.6.0-beta.1",
|
|
86
61
|
"expect-type": "^1.2.1",
|
|
87
62
|
"typescript": "^5.8.3",
|
|
88
|
-
"vite": "^
|
|
89
|
-
},
|
|
90
|
-
"engines": {
|
|
91
|
-
"node": ">= 18.20.8"
|
|
63
|
+
"vite": "^7.0.0"
|
|
92
64
|
},
|
|
93
65
|
"volta": {
|
|
94
66
|
"extends": "../../package.json"
|
|
@@ -1,13 +1,4 @@
|
|
|
1
1
|
declare module '@ember-data/model/-private' {
|
|
2
|
-
export
|
|
3
|
-
|
|
4
|
-
|
|
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
|
|
2
|
+
export * from "@warp-drive/legacy/model/-private";
|
|
3
|
+
|
|
4
|
+
}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
declare module '@ember-data/model/hooks' {
|
|
2
|
-
export { instantiateRecord, teardownRecord, modelFor } from
|
|
3
|
-
|
|
4
|
-
}
|
|
5
|
-
//# sourceMappingURL=hooks.d.ts.map
|
|
2
|
+
export { instantiateRecord, teardownRecord, modelFor, buildSchema } from "@warp-drive/legacy/model";
|
|
3
|
+
|
|
4
|
+
}
|
|
@@ -1,77 +1,45 @@
|
|
|
1
|
-
/// <reference path="./hooks.d.ts" />
|
|
2
|
-
/// <reference path="./migration-support.d.ts" />
|
|
3
1
|
/// <reference path="./-private.d.ts" />
|
|
4
|
-
/// <reference path="./migration-support.
|
|
5
|
-
/// <reference path="
|
|
6
|
-
/// <reference path="./-private/legacy-relationships-support.d.ts" />
|
|
7
|
-
/// <reference path="./-private/hooks.d.ts" />
|
|
8
|
-
/// <reference path="./-private/model.type-test.d.ts" />
|
|
9
|
-
/// <reference path="./-private/record-state.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/has-many.d.ts" />
|
|
13
|
-
/// <reference path="./-private/belongs-to.type-test.d.ts" />
|
|
14
|
-
/// <reference path="./-private/attr.d.ts" />
|
|
15
|
-
/// <reference path="./-private/attr.type-test.d.ts" />
|
|
16
|
-
/// <reference path="./-private/promise-belongs-to.d.ts" />
|
|
17
|
-
/// <reference path="./-private/model.d.ts" />
|
|
18
|
-
/// <reference path="./-private/model-methods.d.ts" />
|
|
19
|
-
/// <reference path="./-private/belongs-to.d.ts" />
|
|
20
|
-
/// <reference path="./-private/type-utils.d.ts" />
|
|
21
|
-
/// <reference path="./-private/errors.d.ts" />
|
|
22
|
-
/// <reference path="./-private/model-for-mixin.d.ts" />
|
|
23
|
-
/// <reference path="./-private/notify-changes.d.ts" />
|
|
24
|
-
/// <reference path="./-private/promise-proxy-base.d.ts" />
|
|
25
|
-
/// <reference path="./-private/schema-provider.d.ts" />
|
|
26
|
-
/// <reference path="./-private/references/has-many.d.ts" />
|
|
27
|
-
/// <reference path="./-private/references/belongs-to.d.ts" />
|
|
28
|
-
/// <reference path="./-private/debug/assert-polymorphic-type.d.ts" />
|
|
2
|
+
/// <reference path="./migration-support.d.ts" />
|
|
3
|
+
/// <reference path="./hooks.d.ts" />
|
|
29
4
|
declare module '@ember-data/model' {
|
|
30
5
|
/**
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
6
|
+
* This package provides a Presentation Model for resource data in an EmberData Cache.
|
|
7
|
+
*
|
|
8
|
+
* Models are defined as classes extending from `import Model from '@ember-data/model';` and the
|
|
9
|
+
* attributes and relationships on these classes are parsed at runtime to supply static "schema"
|
|
10
|
+
* to EmberData's SchemaService.
|
|
11
|
+
*
|
|
12
|
+
* Resource data for individual resources fetched from your API is presented to the UI via instances
|
|
13
|
+
* of the `Model`s you define. An instantiated `Model` is referred to as a `record`.
|
|
14
|
+
|
|
15
|
+
When we refer to the `ModelClass` as opposed to a `Model` or `Record` we are referring
|
|
16
|
+
specifically to the class definition and the static schema methods present on it.
|
|
39
17
|
|
|
40
|
-
|
|
41
|
-
|
|
18
|
+
When we refer to a `record` we refer to a specific class instance presenting
|
|
19
|
+
the resource data for a given `type` and `id`.
|
|
42
20
|
|
|
43
|
-
|
|
44
|
-
the resource data for a given `type` and `id`.
|
|
21
|
+
### Defining a Model
|
|
45
22
|
|
|
46
|
-
|
|
23
|
+
```js [app/models/person.js]
|
|
24
|
+
import Model, { attr, belongsTo, hasMany } from '@ember-data/model';
|
|
47
25
|
|
|
48
|
-
|
|
49
|
-
|
|
26
|
+
export default class PersonModel extends Model {
|
|
27
|
+
@attr name;
|
|
50
28
|
|
|
51
|
-
|
|
52
|
-
@attr name;
|
|
29
|
+
@belongsTo('pet', { inverse: 'owners', async: false }) dog;
|
|
53
30
|
|
|
54
|
-
|
|
31
|
+
@hasMany('person', { inverse: 'friends', async: true }) friends;
|
|
32
|
+
}
|
|
33
|
+
```
|
|
55
34
|
|
|
56
|
-
|
|
57
|
-
}
|
|
58
|
-
```
|
|
35
|
+
### modelName convention
|
|
59
36
|
|
|
60
|
-
|
|
37
|
+
By convention, the name of a given model (its `type`) matches the name
|
|
38
|
+
of the file in the `app/models` folder and should be lowercase, singular
|
|
39
|
+
and dasherized.
|
|
61
40
|
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
41
|
+
@module
|
|
42
|
+
*/
|
|
43
|
+
export { default, attr, belongsTo, hasMany, instantiateRecord, teardownRecord, modelFor, buildSchema, type ManyArray, type HasMany, type AsyncHasMany, type AsyncBelongsTo } from "@warp-drive/legacy/model";
|
|
65
44
|
|
|
66
|
-
|
|
67
|
-
@main @ember-data/model
|
|
68
|
-
*/
|
|
69
|
-
export { Model as default, attr, belongsTo, hasMany } from '@ember-data/model/-private';
|
|
70
|
-
export type { PromiseBelongsTo as AsyncBelongsTo } from '@ember-data/model/-private/promise-belongs-to';
|
|
71
|
-
export type { PromiseManyArray as AsyncHasMany } from '@ember-data/model/-private/promise-many-array';
|
|
72
|
-
export type { RelatedCollection as ManyArray } from '@ember-data/store/-private';
|
|
73
|
-
export type { RelatedCollection as HasMany } from '@ember-data/store/-private';
|
|
74
|
-
export { instantiateRecord, teardownRecord, modelFor } from '@ember-data/model/-private/hooks';
|
|
75
|
-
export { ModelSchemaProvider } from '@ember-data/model/-private/schema-provider';
|
|
76
|
-
}
|
|
77
|
-
//# sourceMappingURL=index.d.ts.map
|
|
45
|
+
}
|