@ember-data/model 5.4.0-alpha.3 → 5.4.0-alpha.31

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (73) hide show
  1. package/addon/-private.js +2 -2
  2. package/addon/has-many-Qm5aUQol.js +645 -0
  3. package/addon/has-many-Qm5aUQol.js.map +1 -0
  4. package/addon/{hooks-0482f3cc.js → hooks-YY4O5eQM.js} +34 -15
  5. package/addon/hooks-YY4O5eQM.js.map +1 -0
  6. package/addon/hooks.js +1 -1
  7. package/addon/index.js +3 -3
  8. package/addon/index.js.map +1 -1
  9. package/addon/migration-support.js +118 -0
  10. package/addon/migration-support.js.map +1 -0
  11. package/addon/{model-48ae96f9.js → model-eXqU5A13.js} +2030 -1876
  12. package/addon/model-eXqU5A13.js.map +1 -0
  13. package/addon/util-Km_Z-hz0.js +35 -0
  14. package/addon/util-Km_Z-hz0.js.map +1 -0
  15. package/package.json +85 -34
  16. package/unstable-preview-types/-private/attr.d.ts +172 -0
  17. package/unstable-preview-types/-private/attr.d.ts.map +1 -0
  18. package/unstable-preview-types/-private/attr.type-test.d.ts +2 -0
  19. package/unstable-preview-types/-private/attr.type-test.d.ts.map +1 -0
  20. package/unstable-preview-types/-private/belongs-to.d.ts +179 -0
  21. package/unstable-preview-types/-private/belongs-to.d.ts.map +1 -0
  22. package/unstable-preview-types/-private/belongs-to.type-test.d.ts +2 -0
  23. package/unstable-preview-types/-private/belongs-to.type-test.d.ts.map +1 -0
  24. package/unstable-preview-types/-private/debug/assert-polymorphic-type.d.ts +6 -0
  25. package/unstable-preview-types/-private/debug/assert-polymorphic-type.d.ts.map +1 -0
  26. package/unstable-preview-types/-private/errors.d.ts +306 -0
  27. package/unstable-preview-types/-private/errors.d.ts.map +1 -0
  28. package/unstable-preview-types/-private/has-many.d.ts +168 -0
  29. package/unstable-preview-types/-private/has-many.d.ts.map +1 -0
  30. package/unstable-preview-types/-private/has-many.type-test.d.ts +2 -0
  31. package/unstable-preview-types/-private/has-many.type-test.d.ts.map +1 -0
  32. package/unstable-preview-types/-private/hooks.d.ts +11 -0
  33. package/unstable-preview-types/-private/hooks.d.ts.map +1 -0
  34. package/unstable-preview-types/-private/legacy-relationships-support.d.ts +60 -0
  35. package/unstable-preview-types/-private/legacy-relationships-support.d.ts.map +1 -0
  36. package/unstable-preview-types/-private/many-array.d.ts +195 -0
  37. package/unstable-preview-types/-private/many-array.d.ts.map +1 -0
  38. package/unstable-preview-types/-private/model-for-mixin.d.ts +4 -0
  39. package/unstable-preview-types/-private/model-for-mixin.d.ts.map +1 -0
  40. package/unstable-preview-types/-private/model-methods.d.ts +32 -0
  41. package/unstable-preview-types/-private/model-methods.d.ts.map +1 -0
  42. package/unstable-preview-types/-private/model.d.ts +101 -0
  43. package/unstable-preview-types/-private/model.type-test.d.ts +2 -0
  44. package/unstable-preview-types/-private/model.type-test.d.ts.map +1 -0
  45. package/unstable-preview-types/-private/notify-changes.d.ts +6 -0
  46. package/unstable-preview-types/-private/notify-changes.d.ts.map +1 -0
  47. package/unstable-preview-types/-private/promise-belongs-to.d.ts +45 -0
  48. package/unstable-preview-types/-private/promise-belongs-to.d.ts.map +1 -0
  49. package/unstable-preview-types/-private/promise-many-array.d.ts +127 -0
  50. package/unstable-preview-types/-private/promise-many-array.d.ts.map +1 -0
  51. package/unstable-preview-types/-private/promise-proxy-base.d.ts +32 -0
  52. package/unstable-preview-types/-private/record-state.d.ts +89 -0
  53. package/unstable-preview-types/-private/record-state.d.ts.map +1 -0
  54. package/unstable-preview-types/-private/references/belongs-to.d.ts +501 -0
  55. package/unstable-preview-types/-private/references/belongs-to.d.ts.map +1 -0
  56. package/unstable-preview-types/-private/references/has-many.d.ts +513 -0
  57. package/unstable-preview-types/-private/references/has-many.d.ts.map +1 -0
  58. package/unstable-preview-types/-private/schema-provider.d.ts +25 -0
  59. package/unstable-preview-types/-private/schema-provider.d.ts.map +1 -0
  60. package/unstable-preview-types/-private/util.d.ts +9 -0
  61. package/unstable-preview-types/-private/util.d.ts.map +1 -0
  62. package/unstable-preview-types/-private.d.ts +10 -0
  63. package/unstable-preview-types/-private.d.ts.map +1 -0
  64. package/unstable-preview-types/hooks.d.ts +3 -0
  65. package/unstable-preview-types/hooks.d.ts.map +1 -0
  66. package/unstable-preview-types/index.d.ts +46 -0
  67. package/unstable-preview-types/index.d.ts.map +1 -0
  68. package/unstable-preview-types/migration-support.d.ts +9 -0
  69. package/unstable-preview-types/migration-support.d.ts.map +1 -0
  70. package/addon/has-many-0759b264.js +0 -507
  71. package/addon/has-many-0759b264.js.map +0 -1
  72. package/addon/hooks-0482f3cc.js.map +0 -1
  73. package/addon/model-48ae96f9.js.map +0 -1
@@ -0,0 +1,513 @@
1
+ import type { CollectionEdge } from '@ember-data/graph/-private/edges/collection';
2
+ import type { Graph } from '@ember-data/graph/-private/graph';
3
+ import type Store from '@ember-data/store';
4
+ import type { BaseFinderOptions } from '@ember-data/store/-types/q/store';
5
+ import type { StableRecordIdentifier } from '@warp-drive/core-types';
6
+ import type { TypeFromInstanceOrString } from '@warp-drive/core-types/record';
7
+ import type { CollectionResourceDocument, CollectionResourceRelationship, ExistingResourceObject, LinkObject, Meta, PaginationLinks } from '@warp-drive/core-types/spec/raw';
8
+ import type { IsUnknown } from '../belongs-to';
9
+ import type ManyArray from '../many-array';
10
+ /**
11
+ @module @ember-data/model
12
+ */
13
+ interface ResourceIdentifier {
14
+ links?: {
15
+ related?: string | LinkObject;
16
+ };
17
+ meta?: Meta;
18
+ }
19
+ type ArrayItemType<T> = T extends (infer U)[] ? U : never;
20
+ /**
21
+ A `HasManyReference` is a low-level API that allows access
22
+ and manipulation of a hasMany relationship.
23
+
24
+ It is especially useful when you're dealing with `async` relationships
25
+ from `@ember-data/model` as it allows synchronous access to
26
+ the relationship data if loaded, as well as APIs for loading, reloading
27
+ the data or accessing available information without triggering a load.
28
+
29
+ It may also be useful when using `sync` relationships with `@ember-data/model`
30
+ that need to be loaded/reloaded with more precise timing than marking the
31
+ relationship as `async` and relying on autofetch would have allowed.
32
+
33
+ However,keep in mind that marking a relationship as `async: false` will introduce
34
+ bugs into your application if the data is not always guaranteed to be available
35
+ by the time the relationship is accessed. Ergo, it is recommended when using this
36
+ approach to utilize `links` for unloaded relationship state instead of identifiers.
37
+
38
+ Reference APIs are entangled with the relationship's underlying state,
39
+ thus any getters or cached properties that utilize these will properly
40
+ invalidate if the relationship state changes.
41
+
42
+ References are "stable", meaning that multiple calls to retrieve the reference
43
+ for a given relationship will always return the same HasManyReference.
44
+
45
+ @class HasManyReference
46
+ @public
47
+ */
48
+ export default class HasManyReference<T = unknown, K extends string = IsUnknown<T> extends true ? string : keyof T & string, Related = K extends keyof T ? ArrayItemType<Awaited<T[K]>> : unknown> {
49
+ graph: Graph;
50
+ store: Store;
51
+ hasManyRelationship: CollectionEdge;
52
+ /**
53
+ * The field name on the parent record for this has-many relationship.
54
+ *
55
+ * @property {String} key
56
+ * @public
57
+ */
58
+ key: K;
59
+ /**
60
+ * The type of resource this relationship will contain.
61
+ *
62
+ * @property {String} type
63
+ * @public
64
+ */
65
+ type: TypeFromInstanceOrString<Related>;
66
+ ___token: object;
67
+ ___identifier: StableRecordIdentifier<TypeFromInstanceOrString<T>>;
68
+ ___relatedTokenMap: Map<StableRecordIdentifier, object>;
69
+ _ref: number;
70
+ constructor(store: Store, graph: Graph, parentIdentifier: StableRecordIdentifier<TypeFromInstanceOrString<T>>, hasManyRelationship: CollectionEdge, key: K);
71
+ /**
72
+ * This method should never be called by user code.
73
+ *
74
+ * @internal
75
+ */
76
+ destroy(): void;
77
+ /**
78
+ * An array of identifiers for the records that this reference refers to.
79
+ *
80
+ * @property {StableRecordIdentifier[]} identifiers
81
+ * @public
82
+ */
83
+ get identifiers(): StableRecordIdentifier<TypeFromInstanceOrString<Related>>[];
84
+ _resource(): CollectionResourceRelationship;
85
+ /**
86
+ This returns a string that represents how the reference will be
87
+ looked up when it is loaded. If the relationship has a link it will
88
+ use the "link" otherwise it defaults to "id".
89
+
90
+ Example
91
+
92
+ ```app/models/post.js
93
+ import Model, { hasMany } from '@ember-data/model';
94
+
95
+ export default class PostModel extends Model {
96
+ @hasMany('comment', { async: true, inverse: null }) comments;
97
+ }
98
+ ```
99
+
100
+ ```javascript
101
+ let post = store.push({
102
+ data: {
103
+ type: 'post',
104
+ id: 1,
105
+ relationships: {
106
+ comments: {
107
+ data: [{ type: 'comment', id: 1 }]
108
+ }
109
+ }
110
+ }
111
+ });
112
+
113
+ let commentsRef = post.hasMany('comments');
114
+
115
+ // get the identifier of the reference
116
+ if (commentsRef.remoteType() === "ids") {
117
+ let ids = commentsRef.ids();
118
+ } else if (commentsRef.remoteType() === "link") {
119
+ let link = commentsRef.link();
120
+ }
121
+ ```
122
+
123
+ @method remoteType
124
+ @public
125
+ @return {String} The name of the remote type. This should either be `link` or `ids`
126
+ */
127
+ remoteType(): 'link' | 'ids';
128
+ /**
129
+ `ids()` returns an array of the record IDs in this relationship.
130
+
131
+ Example
132
+
133
+ ```app/models/post.js
134
+ import Model, { hasMany } from '@ember-data/model';
135
+
136
+ export default class PostModel extends Model {
137
+ @hasMany('comment', { async: true, inverse: null }) comments;
138
+ }
139
+ ```
140
+
141
+ ```javascript
142
+ let post = store.push({
143
+ data: {
144
+ type: 'post',
145
+ id: 1,
146
+ relationships: {
147
+ comments: {
148
+ data: [{ type: 'comment', id: 1 }]
149
+ }
150
+ }
151
+ }
152
+ });
153
+
154
+ let commentsRef = post.hasMany('comments');
155
+
156
+ commentsRef.ids(); // ['1']
157
+ ```
158
+
159
+ @method ids
160
+ @public
161
+ @return {Array} The ids in this has-many relationship
162
+ */
163
+ ids(): Array<string | null>;
164
+ /**
165
+ The link Ember Data will use to fetch or reload this belongs-to
166
+ relationship. By default it uses only the "related" resource linkage.
167
+
168
+ Example
169
+
170
+ ```javascript
171
+ // models/blog.js
172
+ import Model, { belongsTo } from '@ember-data/model';
173
+ export default Model.extend({
174
+ user: belongsTo('user', { async: true, inverse: null })
175
+ });
176
+
177
+ let blog = store.push({
178
+ data: {
179
+ type: 'blog',
180
+ id: 1,
181
+ relationships: {
182
+ user: {
183
+ links: {
184
+ related: '/articles/1/author'
185
+ }
186
+ }
187
+ }
188
+ }
189
+ });
190
+ let userRef = blog.belongsTo('user');
191
+
192
+ // get the identifier of the reference
193
+ if (userRef.remoteType() === "link") {
194
+ let link = userRef.link();
195
+ }
196
+ ```
197
+
198
+ @method link
199
+ @public
200
+ @return {String} The link Ember Data will use to fetch or reload this belongs-to relationship.
201
+ */
202
+ link(): string | null;
203
+ /**
204
+ * any links that have been received for this relationship
205
+ *
206
+ * @method links
207
+ * @public
208
+ * @return
209
+ */
210
+ links(): PaginationLinks | null;
211
+ /**
212
+ The meta data for the has-many relationship.
213
+
214
+ Example
215
+
216
+ ```javascript
217
+ // models/blog.js
218
+ import Model, { hasMany } from '@ember-data/model';
219
+ export default Model.extend({
220
+ users: hasMany('user', { async: true, inverse: null })
221
+ });
222
+
223
+ let blog = store.push({
224
+ data: {
225
+ type: 'blog',
226
+ id: 1,
227
+ relationships: {
228
+ users: {
229
+ links: {
230
+ related: {
231
+ href: '/articles/1/authors'
232
+ },
233
+ },
234
+ meta: {
235
+ lastUpdated: 1458014400000
236
+ }
237
+ }
238
+ }
239
+ }
240
+ });
241
+
242
+ let usersRef = blog.hasMany('user');
243
+
244
+ usersRef.meta() // { lastUpdated: 1458014400000 }
245
+ ```
246
+
247
+ @method meta
248
+ @public
249
+ @return {Object|null} The meta information for the belongs-to relationship.
250
+ */
251
+ meta(): Meta | null;
252
+ /**
253
+ `push` can be used to update the data in the relationship and EmberData
254
+ will treat the new data as the canonical value of this relationship on
255
+ the backend. An empty array will signify the canonical value should be
256
+ empty.
257
+
258
+ Example model
259
+
260
+ ```app/models/post.js
261
+ import Model, { hasMany } from '@ember-data/model';
262
+
263
+ export default class PostModel extends Model {
264
+ @hasMany('comment', { async: true, inverse: null }) comments;
265
+ }
266
+ ```
267
+
268
+ Setup some initial state, note we haven't loaded the comments yet:
269
+
270
+ ```js
271
+ const post = store.push({
272
+ data: {
273
+ type: 'post',
274
+ id: '1',
275
+ relationships: {
276
+ comments: {
277
+ data: [{ type: 'comment', id: '1' }]
278
+ }
279
+ }
280
+ }
281
+ });
282
+
283
+ const commentsRef = post.hasMany('comments');
284
+ commentsRef.ids(); // ['1']
285
+ ```
286
+
287
+ Update the state using `push`, note we can do this even without
288
+ having loaded these comments yet by providing resource identifiers.
289
+
290
+ Both full resources and resource identifiers are supported.
291
+
292
+ ```js
293
+ await commentsRef.push({
294
+ data: [
295
+ { type: 'comment', id: '2' },
296
+ { type: 'comment', id: '3' },
297
+ ]
298
+ });
299
+
300
+ commentsRef.ids(); // ['2', '3']
301
+ ```
302
+
303
+ For convenience, you can also pass in an array of resources or resource identifiers
304
+ without wrapping them in the `data` property:
305
+
306
+ ```js
307
+ await commentsRef.push([
308
+ { type: 'comment', id: '4' },
309
+ { type: 'comment', id: '5' },
310
+ ]);
311
+
312
+ commentsRef.ids(); // ['4', '5']
313
+ ```
314
+
315
+ When using the `data` property, you may also include other resource data via included,
316
+ as well as provide new links and meta to the relationship.
317
+
318
+ ```js
319
+ await commentsRef.push({
320
+ links: {
321
+ related: '/posts/1/comments'
322
+ },
323
+ meta: {
324
+ total: 2
325
+ },
326
+ data: [
327
+ { type: 'comment', id: '4' },
328
+ { type: 'comment', id: '5' },
329
+ ],
330
+ included: [
331
+ { type: 'other-thing', id: '1', attributes: { foo: 'bar' },
332
+ ]
333
+ });
334
+ ```
335
+
336
+ By default, the store will attempt to fetch any unloaded records before resolving
337
+ the returned promise with the ManyArray.
338
+
339
+ Alternatively, pass `true` as the second argument to avoid fetching unloaded records
340
+ and instead the promise will resolve with void without attempting to fetch. This is
341
+ particularly useful if you want to update the state of the relationship without
342
+ forcing the load of all of the associated records.
343
+
344
+ @method push
345
+ @public
346
+ @param {Array|Object} doc a JSONAPI document object describing the new value of this relationship.
347
+ @param {Boolean} [skipFetch] if `true`, do not attempt to fetch unloaded records
348
+ @return {Promise<ManyArray | void>}
349
+ */
350
+ push(doc: ExistingResourceObject[] | CollectionResourceDocument, skipFetch?: boolean): Promise<ManyArray<Related> | void>;
351
+ _isLoaded(): boolean | undefined;
352
+ /**
353
+ `value()` synchronously returns the current value of the has-many
354
+ relationship. Unlike `record.relationshipName`, calling
355
+ `value()` on a reference does not trigger a fetch if the async
356
+ relationship is not yet loaded. If the relationship is not loaded
357
+ it will always return `null`.
358
+
359
+ Example
360
+
361
+ ```app/models/post.js
362
+ import Model, { hasMany } from '@ember-data/model';
363
+
364
+ export default class PostModel extends Model {
365
+ @hasMany('comment', { async: true, inverse: null }) comments;
366
+ }
367
+ ```
368
+
369
+ ```javascript
370
+ let post = store.push({
371
+ data: {
372
+ type: 'post',
373
+ id: 1,
374
+ relationships: {
375
+ comments: {
376
+ data: [{ type: 'comment', id: 1 }]
377
+ }
378
+ }
379
+ }
380
+ });
381
+
382
+ let commentsRef = post.hasMany('comments');
383
+
384
+ post.comments.then(function(comments) {
385
+ commentsRef.value() === comments
386
+ })
387
+ ```
388
+
389
+ @method value
390
+ @public
391
+ @return {ManyArray}
392
+ */
393
+ value(): ManyArray<Related> | null;
394
+ /**
395
+ Loads the relationship if it is not already loaded. If the
396
+ relationship is already loaded this method does not trigger a new
397
+ load. This causes a request to the specified
398
+ relationship link or reloads all items currently in the relationship.
399
+
400
+ Example
401
+
402
+ ```app/models/post.js
403
+ import Model, { hasMany } from '@ember-data/model';
404
+
405
+ export default class PostModel extends Model {
406
+ @hasMany('comment', { async: true, inverse: null }) comments;
407
+ }
408
+ ```
409
+
410
+ ```javascript
411
+ let post = store.push({
412
+ data: {
413
+ type: 'post',
414
+ id: 1,
415
+ relationships: {
416
+ comments: {
417
+ data: [{ type: 'comment', id: 1 }]
418
+ }
419
+ }
420
+ }
421
+ });
422
+
423
+ let commentsRef = post.hasMany('comments');
424
+
425
+ commentsRef.load().then(function(comments) {
426
+ //...
427
+ });
428
+ ```
429
+
430
+ You may also pass in an options object whose properties will be
431
+ fed forward. This enables you to pass `adapterOptions` into the
432
+ request given to the adapter via the reference.
433
+
434
+ Example
435
+
436
+ ```javascript
437
+ commentsRef.load({ adapterOptions: { isPrivate: true } })
438
+ .then(function(comments) {
439
+ //...
440
+ });
441
+ ```
442
+
443
+ ```app/adapters/comment.js
444
+ export default ApplicationAdapter.extend({
445
+ findMany(store, type, id, snapshots) {
446
+ // In the adapter you will have access to adapterOptions.
447
+ let adapterOptions = snapshots[0].adapterOptions;
448
+ }
449
+ });
450
+ ```
451
+
452
+ @method load
453
+ @public
454
+ @param {Object} options the options to pass in.
455
+ @return {Promise} a promise that resolves with the ManyArray in
456
+ this has-many relationship.
457
+ */
458
+ load(options?: BaseFinderOptions): Promise<ManyArray<Related>>;
459
+ /**
460
+ Reloads this has-many relationship. This causes a request to the specified
461
+ relationship link or reloads all items currently in the relationship.
462
+
463
+ Example
464
+
465
+ ```app/models/post.js
466
+ import Model, { hasMany } from '@ember-data/model';
467
+
468
+ export default class PostModel extends Model {
469
+ @hasMany('comment', { async: true, inverse: null }) comments;
470
+ }
471
+ ```
472
+
473
+ ```javascript
474
+ let post = store.push({
475
+ data: {
476
+ type: 'post',
477
+ id: 1,
478
+ relationships: {
479
+ comments: {
480
+ data: [{ type: 'comment', id: 1 }]
481
+ }
482
+ }
483
+ }
484
+ });
485
+
486
+ let commentsRef = post.hasMany('comments');
487
+
488
+ commentsRef.reload().then(function(comments) {
489
+ //...
490
+ });
491
+ ```
492
+
493
+ You may also pass in an options object whose properties will be
494
+ fed forward. This enables you to pass `adapterOptions` into the
495
+ request given to the adapter via the reference. A full example
496
+ can be found in the `load` method.
497
+
498
+ Example
499
+
500
+ ```javascript
501
+ commentsRef.reload({ adapterOptions: { isPrivate: true } })
502
+ ```
503
+
504
+ @method reload
505
+ @public
506
+ @param {Object} options the options to pass in.
507
+ @return {Promise} a promise that resolves with the ManyArray in this has-many relationship.
508
+ */
509
+ reload(options?: BaseFinderOptions): Promise<unknown> | import("../promise-many-array").default<unknown>;
510
+ }
511
+ export declare function isMaybeResource(object: ExistingResourceObject | ResourceIdentifier): object is ExistingResourceObject;
512
+ export {};
513
+ //# sourceMappingURL=has-many.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"has-many.d.ts","sourceRoot":"","sources":["../../../src/-private/references/has-many.ts"],"names":[],"mappings":"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"}
@@ -0,0 +1,25 @@
1
+ import type Store from '@ember-data/store';
2
+ import type { FieldSchema } from '@ember-data/store/-types/q/schema-service';
3
+ import type { RecordIdentifier } from '@warp-drive/core-types/identifier';
4
+ import type { AttributesSchema, RelationshipsSchema } from '@warp-drive/core-types/schema';
5
+ import type { ModelFactory, ModelStore } from './model';
6
+ export declare class ModelSchemaProvider {
7
+ store: ModelStore;
8
+ _relationshipsDefCache: Record<string, RelationshipsSchema>;
9
+ _attributesDefCache: Record<string, AttributesSchema>;
10
+ _fieldsDefCache: Record<string, Map<string, FieldSchema>>;
11
+ constructor(store: ModelStore);
12
+ fields(identifier: RecordIdentifier | {
13
+ type: string;
14
+ }): Map<string, FieldSchema>;
15
+ attributesDefinitionFor(identifier: RecordIdentifier | {
16
+ type: string;
17
+ }): AttributesSchema;
18
+ relationshipsDefinitionFor(identifier: RecordIdentifier | {
19
+ type: string;
20
+ }): RelationshipsSchema;
21
+ doesTypeExist(modelName: string): boolean;
22
+ }
23
+ export declare function buildSchema(store: Store): ModelSchemaProvider;
24
+ export declare function getModelFactory(store: ModelStore, type: string): ModelFactory | null;
25
+ //# sourceMappingURL=schema-provider.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"schema-provider.d.ts","sourceRoot":"","sources":["../../src/-private/schema-provider.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,KAAK,MAAM,mBAAmB,CAAC;AAC3C,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,2CAA2C,CAAC;AAC7E,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,mCAAmC,CAAC;AAC1E,OAAO,KAAK,EAAE,gBAAgB,EAAE,mBAAmB,EAAE,MAAM,+BAA+B,CAAC;AAE3F,OAAO,KAAK,EAAuB,YAAY,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAI7E,qBAAa,mBAAmB;IACtB,KAAK,EAAE,UAAU,CAAC;IAClB,sBAAsB,EAAE,MAAM,CAAC,MAAM,EAAE,mBAAmB,CAAC,CAAC;IAC5D,mBAAmB,EAAE,MAAM,CAAC,MAAM,EAAE,gBAAgB,CAAC,CAAC;IACtD,eAAe,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,MAAM,EAAE,WAAW,CAAC,CAAC,CAAC;gBAEtD,KAAK,EAAE,UAAU;IAO7B,MAAM,CAAC,UAAU,EAAE,gBAAgB,GAAG;QAAE,IAAI,EAAE,MAAM,CAAA;KAAE,GAAG,GAAG,CAAC,MAAM,EAAE,WAAW,CAAC;IAwBjF,uBAAuB,CAAC,UAAU,EAAE,gBAAgB,GAAG;QAAE,IAAI,EAAE,MAAM,CAAA;KAAE,GAAG,gBAAgB;IAmB1F,0BAA0B,CAAC,UAAU,EAAE,gBAAgB,GAAG;QAAE,IAAI,EAAE,MAAM,CAAA;KAAE,GAAG,mBAAmB;IAehG,aAAa,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO;CAM1C;AAED,wBAAgB,WAAW,CAAC,KAAK,EAAE,KAAK,uBAEvC;AAED,wBAAgB,eAAe,CAAC,KAAK,EAAE,UAAU,EAAE,IAAI,EAAE,MAAM,GAAG,YAAY,GAAG,IAAI,CAkCpF"}
@@ -0,0 +1,9 @@
1
+ export type DecoratorPropertyDescriptor = (PropertyDescriptor & {
2
+ initializer?: () => unknown;
3
+ }) | undefined;
4
+ export declare function isElementDescriptor(args: unknown[]): args is [object, string, DecoratorPropertyDescriptor];
5
+ export type DataDecorator = (target: object, key: string, desc?: DecoratorPropertyDescriptor) => DecoratorPropertyDescriptor;
6
+ export type DataDecoratorFactory = (...args: unknown[]) => DataDecorator;
7
+ export declare function computedMacroWithOptionalParams(fn: DataDecorator | DataDecoratorFactory): (...maybeDesc: unknown[]) => DecoratorPropertyDescriptor | DataDecorator;
8
+ export declare function normalizeModelName(type: string): string;
9
+ //# 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,MAAM,MAAM,aAAa,GAAG,CAC1B,MAAM,EAAE,MAAM,EACd,GAAG,EAAE,MAAM,EACX,IAAI,CAAC,EAAE,2BAA2B,KAC/B,2BAA2B,CAAC;AACjC,MAAM,MAAM,oBAAoB,GAAG,CAAC,GAAG,IAAI,EAAE,OAAO,EAAE,KAAK,aAAa,CAAC;AAEzE,wBAAgB,+BAA+B,CAAC,EAAE,EAAE,aAAa,GAAG,oBAAoB,kBAChE,OAAO,EAAE,iDAIhC;AAED,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAsBvD"}
@@ -0,0 +1,10 @@
1
+ export { attr } from './-private/attr';
2
+ export { belongsTo } from './-private/belongs-to';
3
+ export { hasMany } from './-private/has-many';
4
+ export { Model } from './-private/model';
5
+ export { default as Errors } from './-private/errors';
6
+ export { default as ManyArray } from './-private/many-array';
7
+ export { PromiseBelongsTo } from './-private/promise-belongs-to';
8
+ export { default as PromiseManyArray } from './-private/promise-many-array';
9
+ export { lookupLegacySupport, LEGACY_SUPPORT } from './-private/legacy-relationships-support';
10
+ //# 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,OAAO,EAAE,OAAO,IAAI,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAEtD,OAAO,EAAE,OAAO,IAAI,SAAS,EAAE,MAAM,uBAAuB,CAAC;AAC7D,OAAO,EAAE,gBAAgB,EAAE,MAAM,+BAA+B,CAAC;AACjE,OAAO,EAAE,OAAO,IAAI,gBAAgB,EAAE,MAAM,+BAA+B,CAAC;AAG5E,OAAO,EAAE,mBAAmB,EAAE,cAAc,EAAE,MAAM,yCAAyC,CAAC"}
@@ -0,0 +1,3 @@
1
+ export { instantiateRecord, teardownRecord, modelFor } from './-private/hooks';
2
+ export { buildSchema } from './-private/schema-provider';
3
+ //# sourceMappingURL=hooks.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"hooks.d.ts","sourceRoot":"","sources":["../src/hooks.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,cAAc,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAC/E,OAAO,EAAE,WAAW,EAAE,MAAM,4BAA4B,CAAC"}
@@ -0,0 +1,46 @@
1
+ /**
2
+ * This package provides a Presentation Model for resource data in an EmberData Cache.
3
+ *
4
+ * Models are defined as classes extending from `import Model from '@ember-data/model';` and the
5
+ * attributes and relationships on these classes are parsed at runtime to supply static "schema"
6
+ * to EmberData's SchemaService.
7
+ *
8
+ * Resource data for individual resources fetched from your API is presented to the UI via instances
9
+ * of the `Model`s you define. An instantiated `Model` is referred to as a `record`.
10
+
11
+ When we refer to the `ModelClass` as opposed to a `Model` or `Record` we are referring
12
+ specifically to the class definition and the static schema methods present on it.
13
+
14
+ When we refer to a `record` we refer to a specific class instance presenting
15
+ the resource data for a given `type` and `id`.
16
+
17
+ ### Defining a Model
18
+
19
+ ```app/models/person.js
20
+ import Model, { attr, belongsTo, hasMany } from '@ember-data/model';
21
+
22
+ export default class PersonModel extends Model {
23
+ @attr name;
24
+
25
+ @belongsTo('pet', { inverse: 'owners', async: false }) dog;
26
+
27
+ @hasMany('person', { inverse: 'friends', async: true }) friends;
28
+ }
29
+ ```
30
+
31
+ ### modelName convention
32
+
33
+ By convention, the name of a given model (its `type`) matches the name
34
+ of the file in the `app/models` folder and should be lowercase, singular
35
+ and dasherized.
36
+
37
+ @module @ember-data/model
38
+ @main @ember-data/model
39
+ */
40
+ export { Model as default, attr, belongsTo, hasMany } from './-private';
41
+ export type { PromiseBelongsTo as AsyncBelongsTo } from './-private/promise-belongs-to';
42
+ export type { default as AsyncHasMany } from './-private/promise-many-array';
43
+ export type { default as ManyArray } from './-private/many-array';
44
+ export { instantiateRecord, teardownRecord, modelFor } from './-private/hooks';
45
+ export { ModelSchemaProvider } from './-private/schema-provider';
46
+ //# 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,OAAO,IAAI,YAAY,EAAE,MAAM,+BAA+B,CAAC;AAC7E,YAAY,EAAE,OAAO,IAAI,SAAS,EAAE,MAAM,uBAAuB,CAAC;AAClE,OAAO,EAAE,iBAAiB,EAAE,cAAc,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAC/E,OAAO,EAAE,mBAAmB,EAAE,MAAM,4BAA4B,CAAC"}
@@ -0,0 +1,9 @@
1
+ import type { FieldSchema } from '@ember-data/store/-types/q/schema-service';
2
+ type Derivation<R, T> = (record: R, options: Record<string, unknown> | null, prop: string) => T;
3
+ type SchemaService = {
4
+ registerDerivation(name: string, derivation: Derivation<unknown, unknown>): void;
5
+ };
6
+ export declare function withFields(fields: FieldSchema[]): FieldSchema[];
7
+ export declare function registerDerivations(schema: SchemaService): void;
8
+ export {};
9
+ //# 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":"AAGA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,2CAA2C,CAAC;AAmB7E,KAAK,UAAU,CAAC,CAAC,EAAE,CAAC,IAAI,CAAC,MAAM,EAAE,CAAC,EAAE,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI,EAAE,IAAI,EAAE,MAAM,KAAK,CAAC,CAAC;AAChG,KAAK,aAAa,GAAG;IACnB,kBAAkB,CAAC,IAAI,EAAE,MAAM,EAAE,UAAU,EAAE,UAAU,CAAC,OAAO,EAAE,OAAO,CAAC,GAAG,IAAI,CAAC;CAClF,CAAC;AAqGF,wBAAgB,UAAU,CAAC,MAAM,EAAE,WAAW,EAAE,iBAgC/C;AAED,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,aAAa,QAExD"}