@warp-drive/legacy 5.7.0-alpha.3 → 5.7.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.
- package/declarations/adapter/-private/utils/continue-on-reject.d.ts +1 -7
- package/declarations/compat/builders/find-all.d.ts +2 -2
- package/declarations/compat/builders/query.d.ts +2 -2
- package/declarations/compat/builders/save-record.d.ts +3 -3
- package/declarations/compat/legacy-network-handler/fetch-manager.d.ts +24 -16
- package/declarations/compat/legacy-network-handler/identifier-has-id.d.ts +2 -2
- package/declarations/compat/legacy-network-handler/legacy-data-fetch.d.ts +5 -5
- package/declarations/compat/legacy-network-handler/minimum-adapter-interface.d.ts +3 -3
- package/declarations/compat/legacy-network-handler/snapshot-record-array.d.ts +40 -18
- package/declarations/compat/legacy-network-handler/snapshot.d.ts +70 -44
- package/declarations/compat.d.ts +3 -3
- package/declarations/model/-private/attr.d.ts +1 -1
- package/declarations/model/-private/debug/assert-polymorphic-type.d.ts +2 -2
- package/declarations/model/-private/hooks.d.ts +2 -2
- package/declarations/model/-private/legacy-relationships-support.d.ts +21 -27
- package/declarations/model/-private/model-methods.d.ts +0 -4
- package/declarations/model/-private/model.d.ts +13 -31
- package/declarations/model/-private/notify-changes.d.ts +2 -2
- package/declarations/model/-private/promise-many-array.d.ts +0 -3
- package/declarations/model/-private/record-state.d.ts +2 -25
- package/declarations/model/-private/references/belongs-to.d.ts +6 -6
- package/declarations/model/-private/references/has-many.d.ts +6 -12
- package/declarations/model/-private/schema-provider.d.ts +6 -6
- package/declarations/model/-private.d.ts +2 -1
- package/declarations/model/migration-support.d.ts +10 -34
- package/declarations/store/-private.d.ts +12 -23
- package/dist/{-private-CKrP0ogQ.js → -private-HaYCdCCm.js} +155 -141
- package/dist/adapter/-private.js +1 -1
- package/dist/adapter/json-api.js +1 -1
- package/dist/adapter/rest.js +1 -1
- package/dist/compat/-private.js +1 -1
- package/dist/compat/builders.js +3 -2
- package/dist/compat.js +7 -2
- package/dist/{errors-BX5wowuz.js → errors-BMZPmFxm.js} +46 -36
- package/dist/model/-private.js +1 -2
- package/dist/model/migration-support.js +14 -6
- package/dist/model.js +13 -11
- package/dist/{schema-provider-Cbnf6sKm.js → schema-provider-Dhk-879f.js} +55 -26
- package/dist/{serialize-into-hash-Bp58npke.js → serialize-into-hash-Ceon-MrI.js} +2 -1
- package/dist/store.js +8 -6
- package/package.json +13 -13
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Context } from '@warp-drive/core/reactive/-private';
|
|
2
2
|
import { warn } from '@ember/debug';
|
|
3
3
|
import { createDeferred } from '@warp-drive/core/request';
|
|
4
|
+
import { assertPrivateStore, waitFor, coerceId } from '@warp-drive/core/store/-private';
|
|
4
5
|
import { getOrSetGlobal } from '@warp-drive/core/types/-private';
|
|
5
6
|
import { macroCondition, getGlobalConfig } from '@embroider/macros';
|
|
6
7
|
|
|
@@ -9,40 +10,26 @@ import { macroCondition, getGlobalConfig } from '@embroider/macros';
|
|
|
9
10
|
Instances are provided to consuming application's
|
|
10
11
|
adapters for certain `findAll` requests.
|
|
11
12
|
|
|
12
|
-
@
|
|
13
|
+
@hideconstructor
|
|
13
14
|
@public
|
|
14
15
|
*/
|
|
15
16
|
class SnapshotRecordArray {
|
|
16
17
|
/**
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
@private
|
|
21
|
-
@constructor
|
|
22
|
-
@param {Store} store
|
|
23
|
-
@param {String} type
|
|
24
|
-
@param options
|
|
18
|
+
* An array of snapshots
|
|
19
|
+
*
|
|
20
|
+
* @internal
|
|
25
21
|
*/
|
|
26
|
-
constructor(store, type, options = {}) {
|
|
27
|
-
this.__store = store;
|
|
28
|
-
/**
|
|
29
|
-
An array of snapshots
|
|
30
|
-
@private
|
|
31
|
-
@property _snapshots
|
|
32
|
-
@type {Array}
|
|
33
|
-
*/
|
|
34
|
-
this._snapshots = null;
|
|
35
22
|
|
|
36
|
-
|
|
37
|
-
The modelName of the underlying records for the snapshots in the array, as a Model
|
|
38
|
-
@property modelName
|
|
39
|
-
@public
|
|
40
|
-
@type {Model}
|
|
41
|
-
*/
|
|
42
|
-
this.modelName = type;
|
|
23
|
+
/** @internal */
|
|
43
24
|
|
|
44
|
-
|
|
45
|
-
|
|
25
|
+
/**
|
|
26
|
+
* The ResourceType of the underlying records for the {@link Snapshot | Snapshots} in the array
|
|
27
|
+
*/
|
|
28
|
+
|
|
29
|
+
/** @internal */
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* A hash of adapter options passed into the store method for this request.
|
|
46
33
|
Example
|
|
47
34
|
```js [app/adapters/post.js]
|
|
48
35
|
import MyCustomAdapter from './custom-adapter';
|
|
@@ -55,14 +42,10 @@ class SnapshotRecordArray {
|
|
|
55
42
|
}
|
|
56
43
|
}
|
|
57
44
|
```
|
|
58
|
-
|
|
59
|
-
@public
|
|
60
|
-
@type {Object}
|
|
61
|
-
*/
|
|
62
|
-
this.adapterOptions = options.adapterOptions;
|
|
45
|
+
*/
|
|
63
46
|
|
|
64
|
-
|
|
65
|
-
|
|
47
|
+
/**
|
|
48
|
+
* The relationships to include for this request.
|
|
66
49
|
Example
|
|
67
50
|
```js [app/adapters/application.js]
|
|
68
51
|
import Adapter from '@ember-data/adapter';
|
|
@@ -73,18 +56,29 @@ class SnapshotRecordArray {
|
|
|
73
56
|
}
|
|
74
57
|
}
|
|
75
58
|
```
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
59
|
+
*/
|
|
60
|
+
|
|
61
|
+
/**
|
|
62
|
+
SnapshotRecordArray is not directly instantiable.
|
|
63
|
+
Instances are provided to consuming application's
|
|
64
|
+
adapters and serializers for certain requests.
|
|
65
|
+
@private
|
|
66
|
+
@constructor
|
|
67
|
+
@param {Store} store
|
|
68
|
+
@param {String} type
|
|
69
|
+
@param options
|
|
70
|
+
*/
|
|
71
|
+
constructor(store, type, options = {}) {
|
|
72
|
+
this.__store = store;
|
|
73
|
+
this._snapshots = null;
|
|
74
|
+
this.modelName = type;
|
|
75
|
+
this.adapterOptions = options.adapterOptions;
|
|
80
76
|
this.include = options.include;
|
|
81
77
|
}
|
|
82
78
|
|
|
83
79
|
/**
|
|
84
80
|
An array of records
|
|
85
|
-
@
|
|
86
|
-
@private
|
|
87
|
-
@type {Array}
|
|
81
|
+
@internal
|
|
88
82
|
*/
|
|
89
83
|
get _recordArray() {
|
|
90
84
|
return this.__store.peekAll(this.modelName);
|
|
@@ -101,9 +95,6 @@ class SnapshotRecordArray {
|
|
|
101
95
|
}
|
|
102
96
|
});
|
|
103
97
|
```
|
|
104
|
-
@property length
|
|
105
|
-
@public
|
|
106
|
-
@type {Number}
|
|
107
98
|
*/
|
|
108
99
|
get length() {
|
|
109
100
|
return this._recordArray.length;
|
|
@@ -139,7 +130,8 @@ class SnapshotRecordArray {
|
|
|
139
130
|
const {
|
|
140
131
|
_fetchManager
|
|
141
132
|
} = this.__store;
|
|
142
|
-
|
|
133
|
+
const LiveArrayContext = this._recordArray[Context];
|
|
134
|
+
this._snapshots = LiveArrayContext.source.map(identifier => _fetchManager.createSnapshot(identifier));
|
|
143
135
|
return this._snapshots;
|
|
144
136
|
}
|
|
145
137
|
}
|
|
@@ -238,17 +230,44 @@ function normalizeResponseHelper(serializer, store, modelClass, payload, id, req
|
|
|
238
230
|
Snapshots are only available when using `@ember-data/legacy-compat`
|
|
239
231
|
for legacy compatibility with adapters and serializers.
|
|
240
232
|
|
|
241
|
-
|
|
233
|
+
For serialization of records in modern paradigms, request data from
|
|
234
|
+
the cache or off the record directly.
|
|
235
|
+
|
|
236
|
+
@hideconstructor
|
|
242
237
|
@public
|
|
243
238
|
*/
|
|
244
239
|
class Snapshot {
|
|
245
240
|
/**
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
241
|
+
The unique ResourceKey associated with this Snapshot.
|
|
242
|
+
@public
|
|
243
|
+
*/
|
|
244
|
+
|
|
245
|
+
/**
|
|
246
|
+
The ResourceType of the underlying record for this Snapshot, as a string.
|
|
247
|
+
@public
|
|
248
|
+
*/
|
|
249
|
+
|
|
250
|
+
/**
|
|
251
|
+
The id of the snapshot's underlying record
|
|
252
|
+
Example
|
|
253
|
+
```js
|
|
254
|
+
// store.push('post', { id: 1, author: 'Tomster', title: 'Ember.js rocks' });
|
|
255
|
+
postSnapshot.id; // => '1'
|
|
256
|
+
```
|
|
257
|
+
@public
|
|
258
|
+
*/
|
|
259
|
+
|
|
260
|
+
/**
|
|
261
|
+
If `include` was passed to the options for the request, the value
|
|
262
|
+
would be available here.
|
|
263
|
+
@public
|
|
264
|
+
*/
|
|
265
|
+
|
|
266
|
+
/**
|
|
267
|
+
The adapterOptions passed to the request which generated this Snapshot, if any
|
|
268
|
+
@public
|
|
269
|
+
*/
|
|
270
|
+
|
|
252
271
|
constructor(options, identifier, store) {
|
|
253
272
|
this._store = store;
|
|
254
273
|
this.__attributes = null;
|
|
@@ -256,15 +275,9 @@ class Snapshot {
|
|
|
256
275
|
this._belongsToIds = Object.create(null);
|
|
257
276
|
this._hasManyRelationships = Object.create(null);
|
|
258
277
|
this._hasManyIds = Object.create(null);
|
|
278
|
+
assertPrivateStore(store);
|
|
259
279
|
const hasRecord = !!store._instanceCache.peek(identifier);
|
|
260
280
|
this.modelName = identifier.type;
|
|
261
|
-
|
|
262
|
-
/**
|
|
263
|
-
The unique RecordIdentifier associated with this Snapshot.
|
|
264
|
-
@property identifier
|
|
265
|
-
@public
|
|
266
|
-
@type {StableRecordIdentifier}
|
|
267
|
-
*/
|
|
268
281
|
this.identifier = identifier;
|
|
269
282
|
|
|
270
283
|
/*
|
|
@@ -278,43 +291,9 @@ class Snapshot {
|
|
|
278
291
|
// eslint-disable-next-line @typescript-eslint/no-unused-expressions
|
|
279
292
|
this._attributes;
|
|
280
293
|
}
|
|
281
|
-
|
|
282
|
-
/**
|
|
283
|
-
The id of the snapshot's underlying record
|
|
284
|
-
Example
|
|
285
|
-
```javascript
|
|
286
|
-
// store.push('post', { id: 1, author: 'Tomster', title: 'Ember.js rocks' });
|
|
287
|
-
postSnapshot.id; // => '1'
|
|
288
|
-
```
|
|
289
|
-
@property id
|
|
290
|
-
@type {String}
|
|
291
|
-
@public
|
|
292
|
-
*/
|
|
293
294
|
this.id = identifier.id;
|
|
294
|
-
|
|
295
|
-
/**
|
|
296
|
-
A hash of adapter options
|
|
297
|
-
@property adapterOptions
|
|
298
|
-
@type {Object}
|
|
299
|
-
@public
|
|
300
|
-
*/
|
|
301
295
|
this.adapterOptions = options.adapterOptions;
|
|
302
|
-
|
|
303
|
-
/**
|
|
304
|
-
If `include` was passed to the options hash for the request, the value
|
|
305
|
-
would be available here.
|
|
306
|
-
@property include
|
|
307
|
-
@type {String|Array}
|
|
308
|
-
@public
|
|
309
|
-
*/
|
|
310
296
|
this.include = options.include;
|
|
311
|
-
|
|
312
|
-
/**
|
|
313
|
-
The name of the type of the underlying record for this snapshot, as a string.
|
|
314
|
-
@property modelName
|
|
315
|
-
@type {String}
|
|
316
|
-
@public
|
|
317
|
-
*/
|
|
318
297
|
this.modelName = identifier.type;
|
|
319
298
|
if (hasRecord) {
|
|
320
299
|
const cache = this._store.cache;
|
|
@@ -325,12 +304,10 @@ class Snapshot {
|
|
|
325
304
|
/**
|
|
326
305
|
The underlying record for this snapshot. Can be used to access methods and
|
|
327
306
|
properties defined on the record.
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
let json = snapshot.record.toJSON();
|
|
307
|
+
```js
|
|
308
|
+
const someValue = snapshot.record.someProp;
|
|
331
309
|
```
|
|
332
310
|
@property record
|
|
333
|
-
@type {Model}
|
|
334
311
|
@public
|
|
335
312
|
*/
|
|
336
313
|
get record() {
|
|
@@ -342,6 +319,8 @@ class Snapshot {
|
|
|
342
319
|
})(record !== null) : {};
|
|
343
320
|
return record;
|
|
344
321
|
}
|
|
322
|
+
|
|
323
|
+
/** @internal */
|
|
345
324
|
get _attributes() {
|
|
346
325
|
if (this.__attributes !== null) {
|
|
347
326
|
return this.__attributes;
|
|
@@ -350,12 +329,9 @@ class Snapshot {
|
|
|
350
329
|
const {
|
|
351
330
|
identifier
|
|
352
331
|
} = this;
|
|
353
|
-
const attrs = this._store.schema.fields(identifier);
|
|
354
332
|
const cache = this._store.cache;
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
attributes[keyName] = cache.getAttr(identifier, keyName);
|
|
358
|
-
}
|
|
333
|
+
this.eachAttribute((key, meta) => {
|
|
334
|
+
attributes[key] = cache.getAttr(identifier, key);
|
|
359
335
|
});
|
|
360
336
|
return attributes;
|
|
361
337
|
}
|
|
@@ -373,8 +349,7 @@ class Snapshot {
|
|
|
373
349
|
postSnapshot.attr('title'); // => 'Ember.js rocks'
|
|
374
350
|
```
|
|
375
351
|
Note: Values are loaded eagerly and cached when the snapshot is created.
|
|
376
|
-
@
|
|
377
|
-
@return {Object} The attribute value or undefined
|
|
352
|
+
@return The attribute value or undefined
|
|
378
353
|
@public
|
|
379
354
|
*/
|
|
380
355
|
attr(keyName) {
|
|
@@ -390,12 +365,18 @@ class Snapshot {
|
|
|
390
365
|
|
|
391
366
|
/**
|
|
392
367
|
Returns all attributes and their corresponding values.
|
|
368
|
+
::: warning ⚠️ WARNING
|
|
369
|
+
Attributes are SHALLOW copied from the cache.
|
|
370
|
+
Because they are NOT deep copied from the cache, mutating
|
|
371
|
+
any object or array fields will cause unintended side-effects
|
|
372
|
+
and bugs.
|
|
373
|
+
:::
|
|
393
374
|
Example
|
|
394
|
-
```
|
|
375
|
+
```js
|
|
395
376
|
// store.push('post', { id: 1, author: 'Tomster', title: 'Ember.js rocks' });
|
|
396
377
|
postSnapshot.attributes(); // => { author: 'Tomster', title: 'Ember.js rocks' }
|
|
397
378
|
```
|
|
398
|
-
@return
|
|
379
|
+
@return All attributes of the current snapshot
|
|
399
380
|
@public
|
|
400
381
|
*/
|
|
401
382
|
attributes() {
|
|
@@ -407,12 +388,12 @@ class Snapshot {
|
|
|
407
388
|
/**
|
|
408
389
|
Returns all changed attributes and their old and new values.
|
|
409
390
|
Example
|
|
410
|
-
```
|
|
391
|
+
```js
|
|
411
392
|
// store.push('post', { id: 1, author: 'Tomster', title: 'Ember.js rocks' });
|
|
412
393
|
postModel.set('title', 'Ember.js rocks!');
|
|
413
394
|
postSnapshot.changedAttributes(); // => { title: ['Ember.js rocks', 'Ember.js rocks!'] }
|
|
414
395
|
```
|
|
415
|
-
@return
|
|
396
|
+
@return All changed attributes of the current snapshot
|
|
416
397
|
@public
|
|
417
398
|
*/
|
|
418
399
|
changedAttributes() {
|
|
@@ -435,7 +416,7 @@ class Snapshot {
|
|
|
435
416
|
- `id`: set to `true` if you only want the ID of the related record to be
|
|
436
417
|
returned.
|
|
437
418
|
Example
|
|
438
|
-
```
|
|
419
|
+
```js
|
|
439
420
|
// store.push('post', { id: 1, title: 'Hello World' });
|
|
440
421
|
// store.createRecord('comment', { body: 'Lorem ipsum', post: post });
|
|
441
422
|
commentSnapshot.belongsTo('post'); // => Snapshot
|
|
@@ -448,12 +429,10 @@ class Snapshot {
|
|
|
448
429
|
known but unset, `belongsTo` will return `null`. If the contents of the
|
|
449
430
|
relationship is unknown `belongsTo` will return `undefined`.
|
|
450
431
|
Note: Relationships are loaded lazily and cached upon first access.
|
|
451
|
-
@
|
|
452
|
-
@
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
relationship or null if the relationship is known but unset. undefined
|
|
456
|
-
will be returned if the contents of the relationship is unknown.
|
|
432
|
+
@public
|
|
433
|
+
@return A snapshot or ID of a known relationship or null if the
|
|
434
|
+
relationship is known but unset. undefined will be returned if the
|
|
435
|
+
contents of the relationship are unknown.
|
|
457
436
|
*/
|
|
458
437
|
belongsTo(keyName, options) {
|
|
459
438
|
const returnModeIsId = !!(options && options.id);
|
|
@@ -496,7 +475,7 @@ class Snapshot {
|
|
|
496
475
|
}
|
|
497
476
|
const value = this._store.cache.getRelationship(identifier, keyName);
|
|
498
477
|
const data = value && value.data;
|
|
499
|
-
const inverseIdentifier = data ? store.
|
|
478
|
+
const inverseIdentifier = data ? store.cacheKeyManager.getOrCreateRecordIdentifier(data) : null;
|
|
500
479
|
if (value && value.data !== undefined) {
|
|
501
480
|
const cache = store.cache;
|
|
502
481
|
if (inverseIdentifier && !cache.isDeleted(inverseIdentifier)) {
|
|
@@ -532,10 +511,8 @@ class Snapshot {
|
|
|
532
511
|
postSnapshot.hasMany('comments'); // => undefined
|
|
533
512
|
```
|
|
534
513
|
Note: Relationships are loaded lazily and cached upon first access.
|
|
535
|
-
@
|
|
536
|
-
@
|
|
537
|
-
@public
|
|
538
|
-
@return {(Array|undefined)} An array of snapshots or IDs of a known
|
|
514
|
+
@public
|
|
515
|
+
@return An array of snapshots or IDs of a known
|
|
539
516
|
relationship or an empty array if the relationship is known but unset.
|
|
540
517
|
undefined will be returned if the contents of the relationship is unknown.
|
|
541
518
|
*/
|
|
@@ -590,7 +567,7 @@ class Snapshot {
|
|
|
590
567
|
if (value.data) {
|
|
591
568
|
results = [];
|
|
592
569
|
value.data.forEach(member => {
|
|
593
|
-
const inverseIdentifier = store.
|
|
570
|
+
const inverseIdentifier = store.cacheKeyManager.getOrCreateRecordIdentifier(member);
|
|
594
571
|
const cache = store.cache;
|
|
595
572
|
if (!cache.isDeleted(inverseIdentifier)) {
|
|
596
573
|
if (returnModeIsIds) {
|
|
@@ -621,17 +598,24 @@ class Snapshot {
|
|
|
621
598
|
// ...
|
|
622
599
|
});
|
|
623
600
|
```
|
|
624
|
-
@param
|
|
625
|
-
@param
|
|
601
|
+
@param callback the callback to execute
|
|
602
|
+
@param binding the optional value to which the callback's `this` should be bound
|
|
626
603
|
@public
|
|
627
604
|
*/
|
|
628
605
|
eachAttribute(callback, binding) {
|
|
629
|
-
|
|
630
|
-
fields
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
}
|
|
606
|
+
// if the store has a modelFor implementation, we use it to iterate attributes. This allows
|
|
607
|
+
// a custom "ModelSchema" class for legacy serializers to adapt to new fields if desired.
|
|
608
|
+
if (typeof this._store.modelFor === 'function') {
|
|
609
|
+
const modelSchema = this._store.modelFor(this.identifier.type);
|
|
610
|
+
modelSchema.eachAttribute(callback, binding);
|
|
611
|
+
} else {
|
|
612
|
+
const fields = this._store.schema.fields(this.identifier);
|
|
613
|
+
fields.forEach((field, key) => {
|
|
614
|
+
if (field.kind === 'attribute') {
|
|
615
|
+
callback.call(binding, key, field);
|
|
616
|
+
}
|
|
617
|
+
});
|
|
618
|
+
}
|
|
635
619
|
}
|
|
636
620
|
|
|
637
621
|
/**
|
|
@@ -643,17 +627,24 @@ class Snapshot {
|
|
|
643
627
|
// ...
|
|
644
628
|
});
|
|
645
629
|
```
|
|
646
|
-
@param
|
|
647
|
-
@param
|
|
630
|
+
@param callback the callback to execute
|
|
631
|
+
@param binding the optional value to which the callback's `this` should be bound
|
|
648
632
|
@public
|
|
649
633
|
*/
|
|
650
634
|
eachRelationship(callback, binding) {
|
|
651
|
-
|
|
652
|
-
fields
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
}
|
|
635
|
+
// if the store has a modelFor implementation, we use it to iterate relationships. This allows
|
|
636
|
+
// a custom "ModelSchema" class for legacy serializers to adapt to new fields if desired.
|
|
637
|
+
if (typeof this._store.modelFor === 'function') {
|
|
638
|
+
const modelSchema = this._store.modelFor(this.identifier.type);
|
|
639
|
+
modelSchema.eachRelationship(callback, binding);
|
|
640
|
+
} else {
|
|
641
|
+
const fields = this._store.schema.fields(this.identifier);
|
|
642
|
+
fields.forEach((field, key) => {
|
|
643
|
+
if (field.kind === 'belongsTo' || field.kind === 'hasMany') {
|
|
644
|
+
callback.call(binding, key, field);
|
|
645
|
+
}
|
|
646
|
+
});
|
|
647
|
+
}
|
|
657
648
|
}
|
|
658
649
|
|
|
659
650
|
/**
|
|
@@ -672,8 +663,7 @@ class Snapshot {
|
|
|
672
663
|
}
|
|
673
664
|
});
|
|
674
665
|
```
|
|
675
|
-
@
|
|
676
|
-
@return {Object} an object whose values are primitive JSON values only
|
|
666
|
+
@return an object whose values are primitive JSON values only
|
|
677
667
|
@public
|
|
678
668
|
*/
|
|
679
669
|
serialize(options) {
|
|
@@ -688,10 +678,25 @@ class Snapshot {
|
|
|
688
678
|
}
|
|
689
679
|
}
|
|
690
680
|
const SaveOp = getOrSetGlobal('SaveOp', Symbol('SaveOp'));
|
|
681
|
+
/**
|
|
682
|
+
* @private
|
|
683
|
+
*/
|
|
691
684
|
class FetchManager {
|
|
685
|
+
/**
|
|
686
|
+
* @internal
|
|
687
|
+
*/
|
|
688
|
+
|
|
689
|
+
/** @internal */
|
|
690
|
+
|
|
692
691
|
// fetches pending in the runloop, waiting to be coalesced
|
|
692
|
+
/**
|
|
693
|
+
* @internal
|
|
694
|
+
*/
|
|
695
|
+
|
|
696
|
+
/** @internal */
|
|
693
697
|
|
|
694
698
|
constructor(store) {
|
|
699
|
+
assertPrivateStore(store);
|
|
695
700
|
this._store = store;
|
|
696
701
|
// used to keep track of all the find requests that need to be coalesced
|
|
697
702
|
this._pendingFetch = new Map();
|
|
@@ -706,7 +711,7 @@ class FetchManager {
|
|
|
706
711
|
This method is called by `record.save`, and gets passed a
|
|
707
712
|
resolver for the promise that `record.save` returns.
|
|
708
713
|
It schedules saving to happen at the end of the run loop.
|
|
709
|
-
@
|
|
714
|
+
@private
|
|
710
715
|
*/
|
|
711
716
|
scheduleSave(identifier, options) {
|
|
712
717
|
const resolver = createDeferred();
|
|
@@ -870,6 +875,15 @@ class FetchManager {
|
|
|
870
875
|
this.isDestroyed = true;
|
|
871
876
|
}
|
|
872
877
|
}
|
|
878
|
+
|
|
879
|
+
/**
|
|
880
|
+
* This type exists for internal use only for
|
|
881
|
+
* where intimate contracts still exist either for
|
|
882
|
+
* the Test Suite or for Legacy code.
|
|
883
|
+
*
|
|
884
|
+
* @private
|
|
885
|
+
*/
|
|
886
|
+
|
|
873
887
|
function _isEmpty(instanceCache, identifier) {
|
|
874
888
|
const cache = instanceCache.cache;
|
|
875
889
|
if (!cache) {
|
package/dist/adapter/-private.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export { d as determineBodyPromise, g as fetch, p as parseResponseHeaders, b as serializeIntoHash, s as serializeQueryParams, a as setupFastboot } from "../serialize-into-hash-
|
|
1
|
+
export { d as determineBodyPromise, g as fetch, p as parseResponseHeaders, b as serializeIntoHash, s as serializeQueryParams, a as setupFastboot } from "../serialize-into-hash-Ceon-MrI.js";
|
package/dist/adapter/json-api.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { dasherize, pluralize } from '@warp-drive/utilities/string';
|
|
2
2
|
import '@ember/debug';
|
|
3
3
|
import { macroCondition, getGlobalConfig } from '@embroider/macros';
|
|
4
|
-
import { b as serializeIntoHash } from "../serialize-into-hash-
|
|
4
|
+
import { b as serializeIntoHash } from "../serialize-into-hash-Ceon-MrI.js";
|
|
5
5
|
import { RESTAdapter } from './rest.js';
|
|
6
6
|
class JSONAPIAdapter extends RESTAdapter {
|
|
7
7
|
_defaultContentType = 'application/vnd.api+json';
|
package/dist/adapter/rest.js
CHANGED
|
@@ -2,7 +2,7 @@ import { getOwner } from '@ember/application';
|
|
|
2
2
|
import { warn } from '@ember/debug';
|
|
3
3
|
import { computed } from '@ember/object';
|
|
4
4
|
import { Adapter, BuildURLMixin } from '../adapter.js';
|
|
5
|
-
import { b as serializeIntoHash, d as determineBodyPromise, g as getFetchFunction, s as serializeQueryParams, p as parseResponseHeaders } from "../serialize-into-hash-
|
|
5
|
+
import { b as serializeIntoHash, d as determineBodyPromise, g as getFetchFunction, s as serializeQueryParams, p as parseResponseHeaders } from "../serialize-into-hash-Ceon-MrI.js";
|
|
6
6
|
import { InvalidError, ServerError, ConflictError, NotFoundError, ForbiddenError, UnauthorizedError, AdapterError, TimeoutError, AbortError } from './error.js';
|
|
7
7
|
import { macroCondition, getGlobalConfig } from '@embroider/macros';
|
|
8
8
|
import { d as decorateMethodV2 } from "../runtime-BPCpkOf1-BKOwiRJp.js";
|
package/dist/compat/-private.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export { F as FetchManager, S as SaveOp, c as Snapshot, b as SnapshotRecordArray, u as upgradeStore } from "../-private-
|
|
1
|
+
export { F as FetchManager, S as SaveOp, c as Snapshot, b as SnapshotRecordArray, u as upgradeStore } from "../-private-HaYCdCCm.js";
|
package/dist/compat/builders.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { SkipCache } from '@warp-drive/core/types/request';
|
|
2
2
|
import { n as normalizeModelName, i as isMaybeIdentifier } from "../utils-Cqw9eRj5.js";
|
|
3
3
|
import { macroCondition, getGlobalConfig } from '@embroider/macros';
|
|
4
|
-
import { ensureStringId, constructResource } from '@warp-drive/core/store/-private';
|
|
4
|
+
import { ensureStringId, constructResource, assertPrivateStore } from '@warp-drive/core/store/-private';
|
|
5
5
|
import { storeFor, recordIdentifierFor } from '@warp-drive/core';
|
|
6
6
|
|
|
7
7
|
/**
|
|
@@ -227,7 +227,8 @@ function resourceIsFullyDeleted(instanceCache, identifier) {
|
|
|
227
227
|
@return {SaveRecordRequestInput} request config
|
|
228
228
|
*/
|
|
229
229
|
function saveRecordBuilder(record, options = {}) {
|
|
230
|
-
const store = storeFor(record);
|
|
230
|
+
const store = storeFor(record, true);
|
|
231
|
+
assertPrivateStore(store);
|
|
231
232
|
macroCondition(getGlobalConfig().WarpDrive.env.DEBUG) ? (test => {
|
|
232
233
|
if (!test) {
|
|
233
234
|
throw new Error(`Unable to initiate save for a record in a disconnected state`);
|
package/dist/compat.js
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { getOwner } from '@ember/application';
|
|
2
2
|
import { recordIdentifierFor } from '@warp-drive/core';
|
|
3
|
-
import { waitFor, _deprecatingNormalize } from '@warp-drive/core/store/-private';
|
|
4
|
-
import
|
|
3
|
+
import { assertPrivateStore, waitFor, _deprecatingNormalize } from '@warp-drive/core/store/-private';
|
|
4
|
+
import '@warp-drive/core/reactive/-private';
|
|
5
|
+
import { p as payloadIsNotBlank, n as normalizeResponseHelper, i as iterateData, F as FetchManager, S as SaveOp, a as assertIdentifierHasId, b as SnapshotRecordArray } from "./-private-HaYCdCCm.js";
|
|
5
6
|
import { macroCondition, getGlobalConfig } from '@embroider/macros';
|
|
6
7
|
function _findHasMany(adapter, store, identifier, link, relationship, options) {
|
|
7
8
|
const promise = Promise.resolve().then(() => {
|
|
@@ -424,6 +425,7 @@ function saveRecord(context) {
|
|
|
424
425
|
options,
|
|
425
426
|
record: identifier
|
|
426
427
|
} = data;
|
|
428
|
+
assertPrivateStore(store);
|
|
427
429
|
store.cache.willCommit(identifier, context);
|
|
428
430
|
const saveOptions = Object.assign({
|
|
429
431
|
[SaveOp]: operation
|
|
@@ -529,6 +531,7 @@ function findRecord(context) {
|
|
|
529
531
|
record: identifier,
|
|
530
532
|
options
|
|
531
533
|
} = data;
|
|
534
|
+
assertPrivateStore(store);
|
|
532
535
|
let promise;
|
|
533
536
|
|
|
534
537
|
// if not loaded start loading
|
|
@@ -583,6 +586,7 @@ function findAll(context) {
|
|
|
583
586
|
type,
|
|
584
587
|
options
|
|
585
588
|
} = data;
|
|
589
|
+
assertPrivateStore(store);
|
|
586
590
|
const adapter = store.adapterFor(type);
|
|
587
591
|
macroCondition(getGlobalConfig().WarpDrive.env.DEBUG) ? (test => {
|
|
588
592
|
if (!test) {
|
|
@@ -647,6 +651,7 @@ function query(context) {
|
|
|
647
651
|
store,
|
|
648
652
|
data
|
|
649
653
|
} = context.request;
|
|
654
|
+
assertPrivateStore(store);
|
|
650
655
|
let {
|
|
651
656
|
options
|
|
652
657
|
} = data;
|