@ember-data/store 5.6.0-alpha.3 → 5.6.0-alpha.5
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/dist/-private.js +2 -2
- package/dist/{configure-BfLLW6GY.js → configure-BCr2QDik.js} +0 -1
- package/dist/configure-BCr2QDik.js.map +1 -0
- package/dist/configure.js +1 -1
- package/dist/index.js +2 -2
- package/dist/{request-state-DCuV984f.js → request-state-BEsHKec0.js} +101 -243
- package/dist/request-state-BEsHKec0.js.map +1 -0
- package/package.json +11 -14
- package/unstable-preview-types/-private/cache-handler/handler.d.ts +0 -4
- package/unstable-preview-types/-private/cache-handler/handler.d.ts.map +1 -1
- package/unstable-preview-types/-private/cache-handler/types.d.ts +1 -5
- package/unstable-preview-types/-private/cache-handler/types.d.ts.map +1 -1
- package/unstable-preview-types/-private/caches/identifier-cache.d.ts +0 -9
- package/unstable-preview-types/-private/caches/identifier-cache.d.ts.map +1 -1
- package/unstable-preview-types/-private/caches/instance-cache.d.ts +2 -3
- package/unstable-preview-types/-private/caches/instance-cache.d.ts.map +1 -1
- package/unstable-preview-types/-private/document.d.ts +0 -6
- package/unstable-preview-types/-private/document.d.ts.map +1 -1
- package/unstable-preview-types/-private/legacy-model-support/record-reference.d.ts +0 -13
- package/unstable-preview-types/-private/legacy-model-support/record-reference.d.ts.map +1 -1
- package/unstable-preview-types/-private/managers/cache-capabilities-manager.d.ts +0 -3
- package/unstable-preview-types/-private/managers/cache-capabilities-manager.d.ts.map +1 -1
- package/unstable-preview-types/-private/managers/cache-manager.d.ts +2 -35
- package/unstable-preview-types/-private/managers/cache-manager.d.ts.map +1 -1
- package/unstable-preview-types/-private/managers/notification-manager.d.ts +0 -6
- package/unstable-preview-types/-private/managers/notification-manager.d.ts.map +1 -1
- package/unstable-preview-types/-private/managers/record-array-manager.d.ts +0 -1
- package/unstable-preview-types/-private/managers/record-array-manager.d.ts.map +1 -1
- package/unstable-preview-types/-private/network/request-cache.d.ts +0 -3
- package/unstable-preview-types/-private/network/request-cache.d.ts.map +1 -1
- package/unstable-preview-types/-private/new-core-tmp/promise-state.d.ts +0 -32
- package/unstable-preview-types/-private/new-core-tmp/promise-state.d.ts.map +1 -1
- package/unstable-preview-types/-private/new-core-tmp/reactivity/configure.d.ts +0 -1
- package/unstable-preview-types/-private/new-core-tmp/reactivity/configure.d.ts.map +1 -1
- package/unstable-preview-types/-private/new-core-tmp/request-state.d.ts +0 -20
- package/unstable-preview-types/-private/new-core-tmp/request-state.d.ts.map +1 -1
- package/unstable-preview-types/-private/record-arrays/identifier-array.d.ts +0 -2
- package/unstable-preview-types/-private/record-arrays/identifier-array.d.ts.map +1 -1
- package/unstable-preview-types/-private/record-arrays/many-array.d.ts +12 -13
- package/unstable-preview-types/-private/record-arrays/many-array.d.ts.map +1 -1
- package/unstable-preview-types/-private/store-service.d.ts +47 -51
- package/unstable-preview-types/-private/store-service.d.ts.map +1 -1
- package/unstable-preview-types/-private/utils/coerce-id.d.ts +0 -3
- package/unstable-preview-types/-private/utils/coerce-id.d.ts.map +1 -1
- package/unstable-preview-types/-private/utils/uuid-polyfill.d.ts.map +1 -1
- package/unstable-preview-types/-private.d.ts +0 -3
- package/unstable-preview-types/-private.d.ts.map +1 -1
- package/unstable-preview-types/-types/q/cache-capabilities-manager.d.ts +0 -8
- package/unstable-preview-types/-types/q/cache-capabilities-manager.d.ts.map +1 -1
- package/unstable-preview-types/-types/q/ds-model.d.ts +0 -1
- package/unstable-preview-types/-types/q/ds-model.d.ts.map +1 -1
- package/unstable-preview-types/-types/q/identifier.d.ts +0 -18
- package/unstable-preview-types/-types/q/identifier.d.ts.map +1 -1
- package/unstable-preview-types/-types/q/record-data-json-api.d.ts +0 -3
- package/unstable-preview-types/-types/q/record-data-json-api.d.ts.map +1 -1
- package/unstable-preview-types/-types/q/record-instance.d.ts +0 -5
- package/unstable-preview-types/-types/q/record-instance.d.ts.map +1 -1
- package/unstable-preview-types/-types/q/schema-service.d.ts +1 -21
- package/unstable-preview-types/-types/q/schema-service.d.ts.map +1 -1
- package/unstable-preview-types/-types/q/store.d.ts +0 -1
- package/unstable-preview-types/-types/q/store.d.ts.map +1 -1
- package/unstable-preview-types/configure.d.ts +1 -5
- package/unstable-preview-types/configure.d.ts.map +1 -1
- package/unstable-preview-types/index.d.ts +29 -31
- package/unstable-preview-types/index.d.ts.map +1 -1
- package/dist/configure-BfLLW6GY.js.map +0 -1
- package/dist/request-state-DCuV984f.js.map +0 -1
- package/unstable-preview-types/-types/overview.d.ts +0 -21
- package/unstable-preview-types/-types/overview.d.ts.map +0 -1
|
@@ -3,15 +3,10 @@ import { macroCondition, getGlobalConfig, dependencySatisfies, importSync } from
|
|
|
3
3
|
import { withBrand, EnableHydration, SkipCache } from '@warp-drive/core-types/request';
|
|
4
4
|
import { setLogging, getRuntimeConfig } from '@warp-drive/core-types/runtime';
|
|
5
5
|
import { getOrSetGlobal, peekTransient, setTransient } from '@warp-drive/core-types/-private';
|
|
6
|
-
import { a as createSignal, b as consumeSignal, n as notifySignal, c as createMemo, w as willSyncFlushWatchers, A as ARRAY_SIGNAL } from "./configure-
|
|
6
|
+
import { a as createSignal, b as consumeSignal, n as notifySignal, c as createMemo, w as willSyncFlushWatchers, A as ARRAY_SIGNAL } from "./configure-BCr2QDik.js";
|
|
7
7
|
import { CACHE_OWNER, DEBUG_STALE_CACHE_OWNER, DEBUG_IDENTIFIER_BUCKET, DEBUG_CLIENT_ORIGINATED } from '@warp-drive/core-types/identifier';
|
|
8
8
|
import { dasherize } from '@ember-data/request-utils/string';
|
|
9
9
|
import { getPromiseResult, setPromiseResult } from '@ember-data/request';
|
|
10
|
-
|
|
11
|
-
/**
|
|
12
|
-
@module @ember-data/store
|
|
13
|
-
*/
|
|
14
|
-
|
|
15
10
|
function coerceId(id) {
|
|
16
11
|
if (macroCondition(getGlobalConfig().WarpDrive.deprecations.DEPRECATE_NON_STRICT_ID)) {
|
|
17
12
|
let normalized;
|
|
@@ -68,11 +63,6 @@ function normalizeModelName(type) {
|
|
|
68
63
|
}
|
|
69
64
|
return type;
|
|
70
65
|
}
|
|
71
|
-
|
|
72
|
-
/**
|
|
73
|
-
@module @ember-data/store
|
|
74
|
-
*/
|
|
75
|
-
|
|
76
66
|
function installPolyfill() {
|
|
77
67
|
const isFastBoot = typeof FastBoot !== 'undefined';
|
|
78
68
|
const CRYPTO = isFastBoot ? FastBoot.require('crypto') : globalThis.crypto;
|
|
@@ -125,10 +115,6 @@ function hasId(resource) {
|
|
|
125
115
|
function hasType(resource) {
|
|
126
116
|
return hasProp(resource, 'type');
|
|
127
117
|
}
|
|
128
|
-
|
|
129
|
-
/**
|
|
130
|
-
@module @ember-data/store
|
|
131
|
-
*/
|
|
132
118
|
const DOCUMENTS = getOrSetGlobal('DOCUMENTS', new Set());
|
|
133
119
|
function isStableIdentifier(identifier) {
|
|
134
120
|
return identifier[CACHE_OWNER] !== undefined;
|
|
@@ -293,7 +279,6 @@ class IdentifierCache {
|
|
|
293
279
|
* we allow late binding of this private internal merge so that
|
|
294
280
|
* the cache can insert itself here to handle elimination of duplicates
|
|
295
281
|
*
|
|
296
|
-
* @method __configureMerge
|
|
297
282
|
* @private
|
|
298
283
|
*/
|
|
299
284
|
__configureMerge(method) {
|
|
@@ -304,7 +289,6 @@ class IdentifierCache {
|
|
|
304
289
|
}
|
|
305
290
|
|
|
306
291
|
/**
|
|
307
|
-
* @method _getRecordIdentifier
|
|
308
292
|
* @private
|
|
309
293
|
*/
|
|
310
294
|
|
|
@@ -389,7 +373,6 @@ class IdentifierCache {
|
|
|
389
373
|
* useful for the "create" case when we need to see if
|
|
390
374
|
* we are accidentally overwritting something
|
|
391
375
|
*
|
|
392
|
-
* @method peekRecordIdentifier
|
|
393
376
|
* @param resource
|
|
394
377
|
* @return {StableRecordIdentifier | undefined}
|
|
395
378
|
* @private
|
|
@@ -401,8 +384,7 @@ class IdentifierCache {
|
|
|
401
384
|
/**
|
|
402
385
|
Returns the DocumentIdentifier for the given Request, creates one if it does not yet exist.
|
|
403
386
|
Returns `null` if the request does not have a `cacheKey` or `url`.
|
|
404
|
-
@
|
|
405
|
-
@param request
|
|
387
|
+
@param request
|
|
406
388
|
@return {StableDocumentIdentifier | null}
|
|
407
389
|
@public
|
|
408
390
|
*/
|
|
@@ -435,8 +417,7 @@ class IdentifierCache {
|
|
|
435
417
|
- return an object with an `lid` that is stable (repeated calls with the same
|
|
436
418
|
`id` + `type` or `lid` will return the same `lid` value)
|
|
437
419
|
- this referential stability of the object itself is guaranteed
|
|
438
|
-
@
|
|
439
|
-
@param resource
|
|
420
|
+
@param resource
|
|
440
421
|
@return {StableRecordIdentifier}
|
|
441
422
|
@public
|
|
442
423
|
*/
|
|
@@ -450,8 +431,7 @@ class IdentifierCache {
|
|
|
450
431
|
potentially does not have an `id`.
|
|
451
432
|
Delegates generation to the user supplied `GenerateMethod` if one has been provided
|
|
452
433
|
with the signature `generateMethod({ type }, 'record')`.
|
|
453
|
-
@
|
|
454
|
-
@param data
|
|
434
|
+
@param data
|
|
455
435
|
@return {StableRecordIdentifier}
|
|
456
436
|
@public
|
|
457
437
|
*/
|
|
@@ -494,8 +474,7 @@ class IdentifierCache {
|
|
|
494
474
|
If a merge occurs, it is possible the returned identifier does not match the originally
|
|
495
475
|
provided identifier. In this case the abandoned identifier will go through the usual
|
|
496
476
|
`forgetRecordIdentifier` codepaths.
|
|
497
|
-
@
|
|
498
|
-
@param identifierObject
|
|
477
|
+
@param identifierObject
|
|
499
478
|
@param data
|
|
500
479
|
@return {StableRecordIdentifier}
|
|
501
480
|
@public
|
|
@@ -564,7 +543,6 @@ class IdentifierCache {
|
|
|
564
543
|
}
|
|
565
544
|
|
|
566
545
|
/**
|
|
567
|
-
* @method _mergeRecordIdentifiers
|
|
568
546
|
* @private
|
|
569
547
|
*/
|
|
570
548
|
_mergeRecordIdentifiers(keyInfo, identifier, existingIdentifier, data) {
|
|
@@ -612,8 +590,7 @@ class IdentifierCache {
|
|
|
612
590
|
Useful when a record has been deleted and the deletion has been persisted and
|
|
613
591
|
we do not care about the record anymore. Especially useful when an `id` of a
|
|
614
592
|
deleted record might be reused later for a new record.
|
|
615
|
-
@
|
|
616
|
-
@param identifierObject
|
|
593
|
+
@param identifierObject
|
|
617
594
|
@public
|
|
618
595
|
*/
|
|
619
596
|
forgetRecordIdentifier(identifierObject) {
|
|
@@ -1135,11 +1112,6 @@ function defineGate(obj, key, desc) {
|
|
|
1135
1112
|
}, gate(obj, key, desc));
|
|
1136
1113
|
Object.defineProperty(obj, key, options);
|
|
1137
1114
|
}
|
|
1138
|
-
|
|
1139
|
-
/**
|
|
1140
|
-
* @module @ember-data/store
|
|
1141
|
-
*/
|
|
1142
|
-
|
|
1143
1115
|
function urlFromLink(link) {
|
|
1144
1116
|
if (typeof link === 'string') return link;
|
|
1145
1117
|
return link.href;
|
|
@@ -1256,7 +1228,6 @@ class ReactiveDocument {
|
|
|
1256
1228
|
* with the document when the request completes. If no related link is present,
|
|
1257
1229
|
* will fallback to the self link if present
|
|
1258
1230
|
*
|
|
1259
|
-
* @method fetch
|
|
1260
1231
|
* @public
|
|
1261
1232
|
* @param {Object} options
|
|
1262
1233
|
* @return {Promise<Document>}
|
|
@@ -1280,7 +1251,6 @@ class ReactiveDocument {
|
|
|
1280
1251
|
* with the new document when the request completes, or null if there is no
|
|
1281
1252
|
* next link.
|
|
1282
1253
|
*
|
|
1283
|
-
* @method next
|
|
1284
1254
|
* @public
|
|
1285
1255
|
* @param {Object} options
|
|
1286
1256
|
* @return {Promise<Document | null>}
|
|
@@ -1294,7 +1264,6 @@ class ReactiveDocument {
|
|
|
1294
1264
|
* with the new document when the request completes, or null if there is no
|
|
1295
1265
|
* prev link.
|
|
1296
1266
|
*
|
|
1297
|
-
* @method prev
|
|
1298
1267
|
* @public
|
|
1299
1268
|
* @param {Object} options
|
|
1300
1269
|
* @return {Promise<Document | null>}
|
|
@@ -1308,7 +1277,6 @@ class ReactiveDocument {
|
|
|
1308
1277
|
* with the new document when the request completes, or null if there is no
|
|
1309
1278
|
* first link.
|
|
1310
1279
|
*
|
|
1311
|
-
* @method first
|
|
1312
1280
|
* @public
|
|
1313
1281
|
* @param {Object} options
|
|
1314
1282
|
* @return {Promise<Document | null>}
|
|
@@ -1322,7 +1290,6 @@ class ReactiveDocument {
|
|
|
1322
1290
|
* with the new document when the request completes, or null if there is no
|
|
1323
1291
|
* last link.
|
|
1324
1292
|
*
|
|
1325
|
-
* @method last
|
|
1326
1293
|
* @public
|
|
1327
1294
|
* @param {Object} options
|
|
1328
1295
|
* @return {Promise<Document | null>}
|
|
@@ -1340,7 +1307,6 @@ class ReactiveDocument {
|
|
|
1340
1307
|
* the document's contents, leaving that to the individual record
|
|
1341
1308
|
* instances to determine how to do, if at all.
|
|
1342
1309
|
*
|
|
1343
|
-
* @method toJSON
|
|
1344
1310
|
* @public
|
|
1345
1311
|
* @return
|
|
1346
1312
|
*/
|
|
@@ -1447,14 +1413,6 @@ defineGate(ReactiveDocument.prototype, 'meta', {
|
|
|
1447
1413
|
}
|
|
1448
1414
|
});
|
|
1449
1415
|
|
|
1450
|
-
/**
|
|
1451
|
-
@module @ember-data/store
|
|
1452
|
-
*/
|
|
1453
|
-
|
|
1454
|
-
/**
|
|
1455
|
-
@module @ember-data/store
|
|
1456
|
-
*/
|
|
1457
|
-
|
|
1458
1416
|
/**
|
|
1459
1417
|
A `RecordReference` is a low-level API that allows users and
|
|
1460
1418
|
addon authors to perform meta-operations on a record.
|
|
@@ -1491,8 +1449,7 @@ class RecordReference {
|
|
|
1491
1449
|
let userRef = store.getReference('user', 1);
|
|
1492
1450
|
userRef.id(); // '1'
|
|
1493
1451
|
```
|
|
1494
|
-
|
|
1495
|
-
@public
|
|
1452
|
+
@public
|
|
1496
1453
|
@return {String} The id of the record.
|
|
1497
1454
|
*/
|
|
1498
1455
|
id() {
|
|
@@ -1510,8 +1467,7 @@ class RecordReference {
|
|
|
1510
1467
|
let userRef = store.getReference('user', 1);
|
|
1511
1468
|
userRef.identifier(); // '1'
|
|
1512
1469
|
```
|
|
1513
|
-
|
|
1514
|
-
@public
|
|
1470
|
+
@public
|
|
1515
1471
|
@return {String} The identifier of the record.
|
|
1516
1472
|
*/
|
|
1517
1473
|
identifier() {
|
|
@@ -1527,8 +1483,7 @@ class RecordReference {
|
|
|
1527
1483
|
const userRef = store.getReference('user', 1);
|
|
1528
1484
|
userRef.remoteType(); // 'identity'
|
|
1529
1485
|
```
|
|
1530
|
-
@
|
|
1531
|
-
@public
|
|
1486
|
+
@public
|
|
1532
1487
|
@return {String} 'identity'
|
|
1533
1488
|
*/
|
|
1534
1489
|
remoteType() {
|
|
@@ -1563,8 +1518,7 @@ class RecordReference {
|
|
|
1563
1518
|
userRef.value() === user;
|
|
1564
1519
|
});
|
|
1565
1520
|
```
|
|
1566
|
-
@
|
|
1567
|
-
@public
|
|
1521
|
+
@public
|
|
1568
1522
|
@param objectOrPromise a JSON:API ResourceDocument or a promise resolving to one
|
|
1569
1523
|
@return a promise for the value (record or relationship)
|
|
1570
1524
|
*/
|
|
@@ -1584,8 +1538,7 @@ class RecordReference {
|
|
|
1584
1538
|
let userRef = store.getReference('user', 1);
|
|
1585
1539
|
userRef.value(); // user
|
|
1586
1540
|
```
|
|
1587
|
-
|
|
1588
|
-
@public
|
|
1541
|
+
@public
|
|
1589
1542
|
@return {Model} the record for this RecordReference
|
|
1590
1543
|
*/
|
|
1591
1544
|
value() {
|
|
@@ -1601,8 +1554,7 @@ class RecordReference {
|
|
|
1601
1554
|
// load user (via store.find)
|
|
1602
1555
|
userRef.load().then(...)
|
|
1603
1556
|
```
|
|
1604
|
-
|
|
1605
|
-
@public
|
|
1557
|
+
@public
|
|
1606
1558
|
@return {Promise<record>} the record for this RecordReference
|
|
1607
1559
|
*/
|
|
1608
1560
|
load() {
|
|
@@ -1626,8 +1578,7 @@ class RecordReference {
|
|
|
1626
1578
|
// or trigger a reload
|
|
1627
1579
|
userRef.reload().then(...)
|
|
1628
1580
|
```
|
|
1629
|
-
|
|
1630
|
-
@public
|
|
1581
|
+
@public
|
|
1631
1582
|
@return {Promise<record>} the record for this RecordReference
|
|
1632
1583
|
*/
|
|
1633
1584
|
reload() {
|
|
@@ -1645,10 +1596,6 @@ class RecordReference {
|
|
|
1645
1596
|
}
|
|
1646
1597
|
}
|
|
1647
1598
|
defineSignal(RecordReference.prototype, '_ref');
|
|
1648
|
-
|
|
1649
|
-
/**
|
|
1650
|
-
@module @ember-data/store
|
|
1651
|
-
*/
|
|
1652
1599
|
class CacheCapabilitiesManager {
|
|
1653
1600
|
constructor(_store) {
|
|
1654
1601
|
this._store = _store;
|
|
@@ -1765,11 +1712,6 @@ function peekCache(instance) {
|
|
|
1765
1712
|
function isDestroyable(record) {
|
|
1766
1713
|
return Boolean(record && typeof record === 'object' && typeof record.destroy === 'function');
|
|
1767
1714
|
}
|
|
1768
|
-
|
|
1769
|
-
/**
|
|
1770
|
-
@module @ember-data/store
|
|
1771
|
-
*/
|
|
1772
|
-
|
|
1773
1715
|
const RecordCache = getOrSetGlobal('RecordCache', new Map());
|
|
1774
1716
|
function peekRecordIdentifier(record) {
|
|
1775
1717
|
return RecordCache.get(record);
|
|
@@ -1778,6 +1720,7 @@ function peekRecordIdentifier(record) {
|
|
|
1778
1720
|
/**
|
|
1779
1721
|
Retrieves the unique referentially-stable [RecordIdentifier](/ember-data/release/classes/StableRecordIdentifier)
|
|
1780
1722
|
assigned to the given record instance.
|
|
1723
|
+
|
|
1781
1724
|
```js
|
|
1782
1725
|
import { recordIdentifierFor } from "@ember-data/store";
|
|
1783
1726
|
// ... gain access to a record, for instance with peekRecord or findRecord
|
|
@@ -1787,10 +1730,8 @@ function peekRecordIdentifier(record) {
|
|
|
1787
1730
|
// access the identifier's properties.
|
|
1788
1731
|
const { id, type, lid } = identifier;
|
|
1789
1732
|
```
|
|
1790
|
-
|
|
1733
|
+
|
|
1791
1734
|
@public
|
|
1792
|
-
@static
|
|
1793
|
-
@for @ember-data/store
|
|
1794
1735
|
@param {Object} record a record instance previously obstained from the store.
|
|
1795
1736
|
@return {StableRecordIdentifier}
|
|
1796
1737
|
*/
|
|
@@ -2336,7 +2277,6 @@ class CacheManager {
|
|
|
2336
2277
|
* a `content` member and therefor must not assume the existence
|
|
2337
2278
|
* of `request` and `response` on the document.
|
|
2338
2279
|
*
|
|
2339
|
-
* @method put
|
|
2340
2280
|
* @param {StructuredDocument} doc
|
|
2341
2281
|
* @return {ResourceDocument}
|
|
2342
2282
|
* @public
|
|
@@ -2351,7 +2291,6 @@ class CacheManager {
|
|
|
2351
2291
|
* Note: currently the only valid operation is a MergeOperation
|
|
2352
2292
|
* which occurs when a collision of identifiers is detected.
|
|
2353
2293
|
*
|
|
2354
|
-
* @method patch
|
|
2355
2294
|
* @public
|
|
2356
2295
|
* @param op the operation to perform
|
|
2357
2296
|
* @return {void}
|
|
@@ -2364,7 +2303,6 @@ class CacheManager {
|
|
|
2364
2303
|
* Update resource data with a local mutation. Currently supports operations
|
|
2365
2304
|
* on relationships only.
|
|
2366
2305
|
*
|
|
2367
|
-
* @method mutate
|
|
2368
2306
|
* @public
|
|
2369
2307
|
* @param mutation
|
|
2370
2308
|
*/
|
|
@@ -2399,7 +2337,6 @@ class CacheManager {
|
|
|
2399
2337
|
* of the Graph handling necessary entanglements and
|
|
2400
2338
|
* notifications for relational data.
|
|
2401
2339
|
*
|
|
2402
|
-
* @method peek
|
|
2403
2340
|
* @public
|
|
2404
2341
|
* @param {StableRecordIdentifier | StableDocumentIdentifier} identifier
|
|
2405
2342
|
* @return {ResourceDocument | ResourceBlob | null} the known resource data
|
|
@@ -2415,7 +2352,6 @@ class CacheManager {
|
|
|
2415
2352
|
* Peek the Cache for the existing request data associated with
|
|
2416
2353
|
* a cacheable request
|
|
2417
2354
|
*
|
|
2418
|
-
* @method peekRequest
|
|
2419
2355
|
* @param {StableDocumentIdentifier}
|
|
2420
2356
|
* @return {StableDocumentIdentifier | null}
|
|
2421
2357
|
* @public
|
|
@@ -2427,7 +2363,6 @@ class CacheManager {
|
|
|
2427
2363
|
/**
|
|
2428
2364
|
* Push resource data from a remote source into the cache for this identifier
|
|
2429
2365
|
*
|
|
2430
|
-
* @method upsert
|
|
2431
2366
|
* @public
|
|
2432
2367
|
* @param identifier
|
|
2433
2368
|
* @param data
|
|
@@ -2448,9 +2383,8 @@ class CacheManager {
|
|
|
2448
2383
|
* preferring instead to fork at the Store level, which will
|
|
2449
2384
|
* utilize this method to fork the cache.
|
|
2450
2385
|
*
|
|
2451
|
-
* @method fork
|
|
2452
2386
|
* @public
|
|
2453
|
-
* @return Promise<Cache>
|
|
2387
|
+
* @return {Promise<Cache>}
|
|
2454
2388
|
*/
|
|
2455
2389
|
fork() {
|
|
2456
2390
|
return this.#cache.fork();
|
|
@@ -2463,10 +2397,9 @@ class CacheManager {
|
|
|
2463
2397
|
* preferring instead to merge at the Store level, which will
|
|
2464
2398
|
* utilize this method to merge the caches.
|
|
2465
2399
|
*
|
|
2466
|
-
* @method merge
|
|
2467
2400
|
* @param {Cache} cache
|
|
2468
2401
|
* @public
|
|
2469
|
-
* @return Promise<void>
|
|
2402
|
+
* @return {Promise<void>}
|
|
2470
2403
|
*/
|
|
2471
2404
|
merge(cache) {
|
|
2472
2405
|
return this.#cache.merge(cache);
|
|
@@ -2502,7 +2435,6 @@ class CacheManager {
|
|
|
2502
2435
|
* }
|
|
2503
2436
|
* ```
|
|
2504
2437
|
*
|
|
2505
|
-
* @method diff
|
|
2506
2438
|
* @public
|
|
2507
2439
|
*/
|
|
2508
2440
|
diff() {
|
|
@@ -2517,7 +2449,6 @@ class CacheManager {
|
|
|
2517
2449
|
* which may be fed back into a new instance of the same Cache
|
|
2518
2450
|
* via `cache.hydrate`.
|
|
2519
2451
|
*
|
|
2520
|
-
* @method dump
|
|
2521
2452
|
* @return {Promise<ReadableStream>}
|
|
2522
2453
|
* @public
|
|
2523
2454
|
*/
|
|
@@ -2537,7 +2468,6 @@ class CacheManager {
|
|
|
2537
2468
|
* behavior supports optimizing pre/fetching of data for route transitions
|
|
2538
2469
|
* via data-only SSR modes.
|
|
2539
2470
|
*
|
|
2540
|
-
* @method hydrate
|
|
2541
2471
|
* @param {ReadableStream} stream
|
|
2542
2472
|
* @return {Promise<void>}
|
|
2543
2473
|
* @public
|
|
@@ -2558,7 +2488,6 @@ class CacheManager {
|
|
|
2558
2488
|
* It returns properties from options that should be set on the record during the create
|
|
2559
2489
|
* process. This return value behavior is deprecated.
|
|
2560
2490
|
*
|
|
2561
|
-
* @method clientDidCreate
|
|
2562
2491
|
* @public
|
|
2563
2492
|
* @param identifier
|
|
2564
2493
|
* @param options
|
|
@@ -2571,7 +2500,6 @@ class CacheManager {
|
|
|
2571
2500
|
* [LIFECYCLE] Signals to the cache that a resource
|
|
2572
2501
|
* will be part of a save transaction.
|
|
2573
2502
|
*
|
|
2574
|
-
* @method willCommit
|
|
2575
2503
|
* @public
|
|
2576
2504
|
* @param identifier
|
|
2577
2505
|
*/
|
|
@@ -2583,7 +2511,6 @@ class CacheManager {
|
|
|
2583
2511
|
* [LIFECYCLE] Signals to the cache that a resource
|
|
2584
2512
|
* was successfully updated as part of a save transaction.
|
|
2585
2513
|
*
|
|
2586
|
-
* @method didCommit
|
|
2587
2514
|
* @public
|
|
2588
2515
|
* @param identifier
|
|
2589
2516
|
* @param data
|
|
@@ -2596,7 +2523,6 @@ class CacheManager {
|
|
|
2596
2523
|
* [LIFECYCLE] Signals to the cache that a resource
|
|
2597
2524
|
* was update via a save transaction failed.
|
|
2598
2525
|
*
|
|
2599
|
-
* @method commitWasRejected
|
|
2600
2526
|
* @public
|
|
2601
2527
|
* @param identifier
|
|
2602
2528
|
* @param errors
|
|
@@ -2609,7 +2535,6 @@ class CacheManager {
|
|
|
2609
2535
|
* [LIFECYCLE] Signals to the cache that all data for a resource
|
|
2610
2536
|
* should be cleared.
|
|
2611
2537
|
*
|
|
2612
|
-
* @method unloadRecord
|
|
2613
2538
|
* @public
|
|
2614
2539
|
* @param identifier
|
|
2615
2540
|
*/
|
|
@@ -2623,7 +2548,6 @@ class CacheManager {
|
|
|
2623
2548
|
/**
|
|
2624
2549
|
* Retrieve the data for an attribute from the cache
|
|
2625
2550
|
*
|
|
2626
|
-
* @method getAttr
|
|
2627
2551
|
* @public
|
|
2628
2552
|
* @param identifier
|
|
2629
2553
|
* @param propertyName
|
|
@@ -2636,7 +2560,6 @@ class CacheManager {
|
|
|
2636
2560
|
/**
|
|
2637
2561
|
* Retrieve the remote state for an attribute from the cache
|
|
2638
2562
|
*
|
|
2639
|
-
* @method getRemoteAttr
|
|
2640
2563
|
* @public
|
|
2641
2564
|
* @param identifier
|
|
2642
2565
|
* @param propertyName
|
|
@@ -2649,7 +2572,6 @@ class CacheManager {
|
|
|
2649
2572
|
/**
|
|
2650
2573
|
* Mutate the data for an attribute in the cache
|
|
2651
2574
|
*
|
|
2652
|
-
* @method setAttr
|
|
2653
2575
|
* @public
|
|
2654
2576
|
* @param identifier
|
|
2655
2577
|
* @param propertyName
|
|
@@ -2662,7 +2584,6 @@ class CacheManager {
|
|
|
2662
2584
|
/**
|
|
2663
2585
|
* Query the cache for the changed attributes of a resource.
|
|
2664
2586
|
*
|
|
2665
|
-
* @method changedAttrs
|
|
2666
2587
|
* @public
|
|
2667
2588
|
* @param identifier
|
|
2668
2589
|
* @return
|
|
@@ -2674,7 +2595,6 @@ class CacheManager {
|
|
|
2674
2595
|
/**
|
|
2675
2596
|
* Query the cache for whether any mutated attributes exist
|
|
2676
2597
|
*
|
|
2677
|
-
* @method hasChangedAttrs
|
|
2678
2598
|
* @public
|
|
2679
2599
|
* @param identifier
|
|
2680
2600
|
* @return {Boolean}
|
|
@@ -2686,7 +2606,6 @@ class CacheManager {
|
|
|
2686
2606
|
/**
|
|
2687
2607
|
* Tell the cache to discard any uncommitted mutations to attributes
|
|
2688
2608
|
*
|
|
2689
|
-
* @method rollbackAttrs
|
|
2690
2609
|
* @public
|
|
2691
2610
|
* @param identifier
|
|
2692
2611
|
* @return the names of attributes that were restored
|
|
@@ -2720,7 +2639,6 @@ class CacheManager {
|
|
|
2720
2639
|
};
|
|
2721
2640
|
```
|
|
2722
2641
|
*
|
|
2723
|
-
* @method changedRelationships
|
|
2724
2642
|
* @public
|
|
2725
2643
|
* @param {StableRecordIdentifier} identifier
|
|
2726
2644
|
* @return {Map<string, RelationshipDiff>}
|
|
@@ -2732,7 +2650,6 @@ class CacheManager {
|
|
|
2732
2650
|
/**
|
|
2733
2651
|
* Query the cache for whether any mutated attributes exist
|
|
2734
2652
|
*
|
|
2735
|
-
* @method hasChangedRelationships
|
|
2736
2653
|
* @public
|
|
2737
2654
|
* @param {StableRecordIdentifier} identifier
|
|
2738
2655
|
* @return {Boolean}
|
|
@@ -2748,7 +2665,6 @@ class CacheManager {
|
|
|
2748
2665
|
*
|
|
2749
2666
|
* This method is a candidate to become a mutation
|
|
2750
2667
|
*
|
|
2751
|
-
* @method rollbackRelationships
|
|
2752
2668
|
* @public
|
|
2753
2669
|
* @param {StableRecordIdentifier} identifier
|
|
2754
2670
|
* @return {String[]} the names of relationships that were restored
|
|
@@ -2760,7 +2676,6 @@ class CacheManager {
|
|
|
2760
2676
|
/**
|
|
2761
2677
|
* Query the cache for the current state of a relationship property
|
|
2762
2678
|
*
|
|
2763
|
-
* @method getRelationship
|
|
2764
2679
|
* @public
|
|
2765
2680
|
* @param identifier
|
|
2766
2681
|
* @param propertyName
|
|
@@ -2773,7 +2688,6 @@ class CacheManager {
|
|
|
2773
2688
|
/**
|
|
2774
2689
|
* Query the cache for the remote state of a relationship property
|
|
2775
2690
|
*
|
|
2776
|
-
* @method getRelationship
|
|
2777
2691
|
* @public
|
|
2778
2692
|
* @param identifier
|
|
2779
2693
|
* @param propertyName
|
|
@@ -2790,7 +2704,6 @@ class CacheManager {
|
|
|
2790
2704
|
* Update the cache state for the given resource to be marked as locally deleted,
|
|
2791
2705
|
* or remove such a mark.
|
|
2792
2706
|
*
|
|
2793
|
-
* @method setIsDeleted
|
|
2794
2707
|
* @public
|
|
2795
2708
|
* @param identifier
|
|
2796
2709
|
* @param isDeleted
|
|
@@ -2802,7 +2715,6 @@ class CacheManager {
|
|
|
2802
2715
|
/**
|
|
2803
2716
|
* Query the cache for any validation errors applicable to the given resource.
|
|
2804
2717
|
*
|
|
2805
|
-
* @method getErrors
|
|
2806
2718
|
* @public
|
|
2807
2719
|
* @param identifier
|
|
2808
2720
|
* @return
|
|
@@ -2814,7 +2726,6 @@ class CacheManager {
|
|
|
2814
2726
|
/**
|
|
2815
2727
|
* Query the cache for whether a given resource has any available data
|
|
2816
2728
|
*
|
|
2817
|
-
* @method isEmpty
|
|
2818
2729
|
* @public
|
|
2819
2730
|
* @param identifier
|
|
2820
2731
|
* @return {Boolean}
|
|
@@ -2827,7 +2738,6 @@ class CacheManager {
|
|
|
2827
2738
|
* Query the cache for whether a given resource was created locally and not
|
|
2828
2739
|
* yet persisted.
|
|
2829
2740
|
*
|
|
2830
|
-
* @method isNew
|
|
2831
2741
|
* @public
|
|
2832
2742
|
* @param identifier
|
|
2833
2743
|
* @return {Boolean}
|
|
@@ -2840,7 +2750,6 @@ class CacheManager {
|
|
|
2840
2750
|
* Query the cache for whether a given resource is marked as deleted (but not
|
|
2841
2751
|
* necessarily persisted yet).
|
|
2842
2752
|
*
|
|
2843
|
-
* @method isDeleted
|
|
2844
2753
|
* @public
|
|
2845
2754
|
* @param identifier
|
|
2846
2755
|
* @return {Boolean}
|
|
@@ -2853,7 +2762,6 @@ class CacheManager {
|
|
|
2853
2762
|
* Query the cache for whether a given resource has been deleted and that deletion
|
|
2854
2763
|
* has also been persisted.
|
|
2855
2764
|
*
|
|
2856
|
-
* @method isDeletionCommitted
|
|
2857
2765
|
* @public
|
|
2858
2766
|
* @param identifier
|
|
2859
2767
|
* @return {Boolean}
|
|
@@ -2862,11 +2770,6 @@ class CacheManager {
|
|
|
2862
2770
|
return this.#cache.isDeletionCommitted(identifier);
|
|
2863
2771
|
}
|
|
2864
2772
|
}
|
|
2865
|
-
|
|
2866
|
-
/**
|
|
2867
|
-
* @module @ember-data/store
|
|
2868
|
-
*/
|
|
2869
|
-
|
|
2870
2773
|
function isCacheOperationValue(value) {
|
|
2871
2774
|
return value === 'added' || value === 'state' || value === 'updated' || value === 'removed' || value === 'invalidated';
|
|
2872
2775
|
}
|
|
@@ -2951,7 +2854,6 @@ class NotificationManager {
|
|
|
2951
2854
|
* }
|
|
2952
2855
|
* ```
|
|
2953
2856
|
*
|
|
2954
|
-
* @method subscribe
|
|
2955
2857
|
* @public
|
|
2956
2858
|
* @param {StableDocumentIdentifier | StableRecordIdentifier | 'resource' | 'document'} identifier
|
|
2957
2859
|
* @param {NotificationCallback | ResourceOperationCallback | DocumentOperationCallback} callback
|
|
@@ -2989,7 +2891,6 @@ class NotificationManager {
|
|
|
2989
2891
|
/**
|
|
2990
2892
|
* remove a previous subscription
|
|
2991
2893
|
*
|
|
2992
|
-
* @method unsubscribe
|
|
2993
2894
|
* @public
|
|
2994
2895
|
* @param {UnsubscribeToken} token
|
|
2995
2896
|
*/
|
|
@@ -3002,7 +2903,6 @@ class NotificationManager {
|
|
|
3002
2903
|
/**
|
|
3003
2904
|
* Custom Caches and Application Code should not call this method directly.
|
|
3004
2905
|
*
|
|
3005
|
-
* @method notify
|
|
3006
2906
|
* @param identifier
|
|
3007
2907
|
* @param value
|
|
3008
2908
|
* @param key
|
|
@@ -3132,11 +3032,6 @@ class NotificationManager {
|
|
|
3132
3032
|
*/
|
|
3133
3033
|
|
|
3134
3034
|
const NativeProxy = Proxy;
|
|
3135
|
-
|
|
3136
|
-
/**
|
|
3137
|
-
@module @ember-data/store
|
|
3138
|
-
*/
|
|
3139
|
-
|
|
3140
3035
|
const ARRAY_GETTER_METHODS = new Set([Symbol.iterator, 'concat', 'entries', 'every', 'fill', 'filter', 'find', 'findIndex', 'flat', 'flatMap', 'forEach', 'includes', 'indexOf', 'join', 'keys', 'lastIndexOf', 'map', 'reduce', 'reduceRight', 'slice', 'some', 'values']);
|
|
3141
3036
|
const ARRAY_SETTER_METHODS = new Set(['push', 'pop', 'unshift', 'shift', 'splice', 'sort']);
|
|
3142
3037
|
const SYNC_PROPS = new Set(['[]', 'length', 'links', 'meta']);
|
|
@@ -3488,8 +3383,7 @@ class IdentifierArray {
|
|
|
3488
3383
|
});
|
|
3489
3384
|
people.isUpdating; // true
|
|
3490
3385
|
```
|
|
3491
|
-
@
|
|
3492
|
-
@public
|
|
3386
|
+
@public
|
|
3493
3387
|
*/
|
|
3494
3388
|
update() {
|
|
3495
3389
|
if (this.isUpdating) {
|
|
@@ -3538,8 +3432,7 @@ class IdentifierArray {
|
|
|
3538
3432
|
});
|
|
3539
3433
|
messages.save();
|
|
3540
3434
|
```
|
|
3541
|
-
@
|
|
3542
|
-
@public
|
|
3435
|
+
@public
|
|
3543
3436
|
@return {Promise<IdentifierArray>} promise
|
|
3544
3437
|
*/
|
|
3545
3438
|
save() {
|
|
@@ -3632,11 +3525,6 @@ function extractIdentifierFromRecord$2(record) {
|
|
|
3632
3525
|
assertRecordPassedToHasMany$1(record);
|
|
3633
3526
|
return recordIdentifierFor(record);
|
|
3634
3527
|
}
|
|
3635
|
-
|
|
3636
|
-
/**
|
|
3637
|
-
@module @ember-data/store
|
|
3638
|
-
*/
|
|
3639
|
-
|
|
3640
3528
|
const FAKE_ARR = getOrSetGlobal('FAKE_ARR', {});
|
|
3641
3529
|
const SLICE_BATCH_SIZE = 1200;
|
|
3642
3530
|
/**
|
|
@@ -3764,8 +3652,7 @@ class RecordArrayManager {
|
|
|
3764
3652
|
/**
|
|
3765
3653
|
Get the `RecordArray` for a modelName, which contains all loaded records of
|
|
3766
3654
|
given modelName.
|
|
3767
|
-
@
|
|
3768
|
-
@internal
|
|
3655
|
+
@internal
|
|
3769
3656
|
@param {String} modelName
|
|
3770
3657
|
@return {RecordArray}
|
|
3771
3658
|
*/
|
|
@@ -4034,11 +3921,6 @@ function sync(array, changes, arraySet) {
|
|
|
4034
3921
|
function isCollection(array) {
|
|
4035
3922
|
return array.identifier !== null;
|
|
4036
3923
|
}
|
|
4037
|
-
|
|
4038
|
-
/**
|
|
4039
|
-
* @module @ember-data/store
|
|
4040
|
-
*/
|
|
4041
|
-
|
|
4042
3924
|
const Touching = getOrSetGlobal('Touching', Symbol('touching'));
|
|
4043
3925
|
const RequestPromise = getOrSetGlobal('RequestPromise', Symbol('promise'));
|
|
4044
3926
|
const EMPTY_ARR = macroCondition(getGlobalConfig().WarpDrive.env.DEBUG) ? Object.freeze([]) : [];
|
|
@@ -4195,7 +4077,6 @@ class RequestStateService {
|
|
|
4195
4077
|
* with the RequestManager for these purposes is likely to be a better long-term
|
|
4196
4078
|
* design.
|
|
4197
4079
|
*
|
|
4198
|
-
* @method subscribeForRecord
|
|
4199
4080
|
* @public
|
|
4200
4081
|
* @param {StableRecordIdentifier} identifier
|
|
4201
4082
|
* @param {(state: RequestCacheRequestState) => void} callback
|
|
@@ -4212,7 +4093,6 @@ class RequestStateService {
|
|
|
4212
4093
|
/**
|
|
4213
4094
|
* Retrieve all active requests for a given resource identity.
|
|
4214
4095
|
*
|
|
4215
|
-
* @method getPendingRequestsForRecord
|
|
4216
4096
|
* @public
|
|
4217
4097
|
* @param {StableRecordIdentifier} identifier
|
|
4218
4098
|
* @return {RequestCacheRequestState[]} an array of request states for any pending requests for the given identifier
|
|
@@ -4224,7 +4104,6 @@ class RequestStateService {
|
|
|
4224
4104
|
/**
|
|
4225
4105
|
* Retrieve the last completed request for a given resource identity.
|
|
4226
4106
|
*
|
|
4227
|
-
* @method getLastRequestForRecord
|
|
4228
4107
|
* @public
|
|
4229
4108
|
* @param {StableRecordIdentifier} identifier
|
|
4230
4109
|
* @return {RequestCacheRequestState | null} the state of the most recent request for the given identifier
|
|
@@ -4289,9 +4168,6 @@ function constructResource(type, id, lid) {
|
|
|
4289
4168
|
}
|
|
4290
4169
|
}
|
|
4291
4170
|
|
|
4292
|
-
/**
|
|
4293
|
-
@module @ember-data/store
|
|
4294
|
-
*/
|
|
4295
4171
|
// this import location is deprecated but breaks in 4.8 and older
|
|
4296
4172
|
|
|
4297
4173
|
// @ts-expect-error adding to globalThis
|
|
@@ -4423,7 +4299,6 @@ if (macroCondition(getGlobalConfig().WarpDrive.activeLogging.LOG_METRIC_COUNTS))
|
|
|
4423
4299
|
* TODO: These are limitations we want to (and can) address. If you
|
|
4424
4300
|
* have need of lifting these limitations, please open an issue.
|
|
4425
4301
|
*
|
|
4426
|
-
* @typedoc
|
|
4427
4302
|
*/
|
|
4428
4303
|
|
|
4429
4304
|
/**
|
|
@@ -4431,7 +4306,7 @@ if (macroCondition(getGlobalConfig().WarpDrive.activeLogging.LOG_METRIC_COUNTS))
|
|
|
4431
4306
|
* and sources of data (such as your API or a local persistence layer)
|
|
4432
4307
|
* accessed via a [RequestManager](https://github.com/emberjs/data/tree/main/packages/request).
|
|
4433
4308
|
*
|
|
4434
|
-
* ```app/services/store.js
|
|
4309
|
+
* ```js [app/services/store.js]
|
|
4435
4310
|
* import Store from '@ember-data/store';
|
|
4436
4311
|
*
|
|
4437
4312
|
* export default class extends Store {}
|
|
@@ -4480,6 +4355,8 @@ const app = new EmberApp(defaults, {
|
|
|
4480
4355
|
});
|
|
4481
4356
|
}
|
|
4482
4357
|
class Store extends BaseClass {
|
|
4358
|
+
/** @internal */
|
|
4359
|
+
|
|
4483
4360
|
/**
|
|
4484
4361
|
* Provides access to the NotificationManager associated
|
|
4485
4362
|
* with this Store instance.
|
|
@@ -4509,6 +4386,7 @@ class Store extends BaseClass {
|
|
|
4509
4386
|
}
|
|
4510
4387
|
return this._schema;
|
|
4511
4388
|
}
|
|
4389
|
+
/** @internal */
|
|
4512
4390
|
|
|
4513
4391
|
/**
|
|
4514
4392
|
* Provides access to the IdentifierCache instance
|
|
@@ -4580,6 +4458,15 @@ class Store extends BaseClass {
|
|
|
4580
4458
|
*/
|
|
4581
4459
|
|
|
4582
4460
|
// Private
|
|
4461
|
+
/** @internal */
|
|
4462
|
+
|
|
4463
|
+
/** @internal */
|
|
4464
|
+
|
|
4465
|
+
/** @internal */
|
|
4466
|
+
|
|
4467
|
+
/** @internal */
|
|
4468
|
+
|
|
4469
|
+
/** @internal */
|
|
4583
4470
|
|
|
4584
4471
|
/**
|
|
4585
4472
|
* Async flush buffers notifications until flushed
|
|
@@ -4593,13 +4480,20 @@ class Store extends BaseClass {
|
|
|
4593
4480
|
*/
|
|
4594
4481
|
|
|
4595
4482
|
// DEBUG-only properties
|
|
4483
|
+
/** @internal */
|
|
4484
|
+
|
|
4485
|
+
/** @internal */
|
|
4596
4486
|
|
|
4487
|
+
/** @internal */
|
|
4488
|
+
|
|
4489
|
+
/** @internal */
|
|
4597
4490
|
get isDestroying() {
|
|
4598
4491
|
return this._isDestroying;
|
|
4599
4492
|
}
|
|
4600
4493
|
set isDestroying(value) {
|
|
4601
4494
|
this._isDestroying = value;
|
|
4602
4495
|
}
|
|
4496
|
+
/** @internal */
|
|
4603
4497
|
get isDestroyed() {
|
|
4604
4498
|
return this._isDestroyed;
|
|
4605
4499
|
}
|
|
@@ -4608,7 +4502,6 @@ class Store extends BaseClass {
|
|
|
4608
4502
|
}
|
|
4609
4503
|
|
|
4610
4504
|
/**
|
|
4611
|
-
@method init
|
|
4612
4505
|
@private
|
|
4613
4506
|
*/
|
|
4614
4507
|
constructor(createArgs) {
|
|
@@ -4628,6 +4521,8 @@ class Store extends BaseClass {
|
|
|
4628
4521
|
this.isDestroying = false;
|
|
4629
4522
|
this.isDestroyed = false;
|
|
4630
4523
|
}
|
|
4524
|
+
|
|
4525
|
+
/** @internal */
|
|
4631
4526
|
_run(cb) {
|
|
4632
4527
|
macroCondition(getGlobalConfig().WarpDrive.env.DEBUG) ? (test => {
|
|
4633
4528
|
if (!test) {
|
|
@@ -4681,6 +4576,8 @@ class Store extends BaseClass {
|
|
|
4681
4576
|
this._run(cb);
|
|
4682
4577
|
}
|
|
4683
4578
|
}
|
|
4579
|
+
|
|
4580
|
+
/** @internal */
|
|
4684
4581
|
_schedule(name, cb) {
|
|
4685
4582
|
macroCondition(getGlobalConfig().WarpDrive.env.DEBUG) ? (test => {
|
|
4686
4583
|
if (!test) {
|
|
@@ -4702,13 +4599,14 @@ class Store extends BaseClass {
|
|
|
4702
4599
|
* This can be used to query the status of requests
|
|
4703
4600
|
* that have been initiated for a given identifier.
|
|
4704
4601
|
*
|
|
4705
|
-
* @method getRequestStateService
|
|
4706
4602
|
* @return {RequestStateService}
|
|
4707
4603
|
* @public
|
|
4708
4604
|
*/
|
|
4709
4605
|
getRequestStateService() {
|
|
4710
4606
|
return this._requestCache;
|
|
4711
4607
|
}
|
|
4608
|
+
|
|
4609
|
+
/** @internal */
|
|
4712
4610
|
_getAllPending() {
|
|
4713
4611
|
if (macroCondition(getGlobalConfig().WarpDrive.env.TESTING)) {
|
|
4714
4612
|
const all = [];
|
|
@@ -4771,7 +4669,6 @@ class Store extends BaseClass {
|
|
|
4771
4669
|
* is that `store.request` will attempt to hydrate the response content into
|
|
4772
4670
|
* a response Document containing RecordInstances.
|
|
4773
4671
|
*
|
|
4774
|
-
* @method request
|
|
4775
4672
|
* @param {StoreRequestInput} requestConfig
|
|
4776
4673
|
* @return {Future}
|
|
4777
4674
|
* @public
|
|
@@ -4832,7 +4729,6 @@ class Store extends BaseClass {
|
|
|
4832
4729
|
* mechanism of presenting cache data to the ui for access
|
|
4833
4730
|
* mutation, and interaction.
|
|
4834
4731
|
*
|
|
4835
|
-
* @method instantiateRecord (hook)
|
|
4836
4732
|
* @param identifier
|
|
4837
4733
|
* @param createRecordArgs
|
|
4838
4734
|
* @param recordDataFor deprecated use this.cache
|
|
@@ -4847,7 +4743,6 @@ class Store extends BaseClass {
|
|
|
4847
4743
|
* be used to teardown any custom record instances instantiated
|
|
4848
4744
|
* with `instantiateRecord`.
|
|
4849
4745
|
*
|
|
4850
|
-
* @method teardownRecord (hook)
|
|
4851
4746
|
* @public
|
|
4852
4747
|
* @param record
|
|
4853
4748
|
*/
|
|
@@ -4865,8 +4760,7 @@ class Store extends BaseClass {
|
|
|
4865
4760
|
relationship names of the model, see
|
|
4866
4761
|
[`relationshipNames`](/ember-data/release/classes/Model?anchor=relationshipNames)
|
|
4867
4762
|
for example.
|
|
4868
|
-
@
|
|
4869
|
-
@public
|
|
4763
|
+
@public
|
|
4870
4764
|
@deprecated
|
|
4871
4765
|
@param {String} type
|
|
4872
4766
|
@return {ModelSchema}
|
|
@@ -4910,8 +4804,7 @@ class Store extends BaseClass {
|
|
|
4910
4804
|
user: user
|
|
4911
4805
|
});
|
|
4912
4806
|
```
|
|
4913
|
-
@
|
|
4914
|
-
@public
|
|
4807
|
+
@public
|
|
4915
4808
|
@param {String} type the name of the resource
|
|
4916
4809
|
@param {Object} inputProperties a hash of properties to set on the
|
|
4917
4810
|
newly created record.
|
|
@@ -4990,8 +4883,7 @@ class Store extends BaseClass {
|
|
|
4990
4883
|
});
|
|
4991
4884
|
store.deleteRecord(post);
|
|
4992
4885
|
```
|
|
4993
|
-
@
|
|
4994
|
-
@public
|
|
4886
|
+
@public
|
|
4995
4887
|
@param {unknown} record
|
|
4996
4888
|
*/
|
|
4997
4889
|
deleteRecord(record) {
|
|
@@ -5021,8 +4913,7 @@ class Store extends BaseClass {
|
|
|
5021
4913
|
const { content: { data: post } } = await store.request(findRecord({ type: 'post', id: '1' }));
|
|
5022
4914
|
store.unloadRecord(post);
|
|
5023
4915
|
```
|
|
5024
|
-
@
|
|
5025
|
-
@public
|
|
4916
|
+
@public
|
|
5026
4917
|
@param {Model} record
|
|
5027
4918
|
*/
|
|
5028
4919
|
unloadRecord(record) {
|
|
@@ -5042,7 +4933,7 @@ class Store extends BaseClass {
|
|
|
5042
4933
|
The `findRecord` method will always return a **promise** that will be
|
|
5043
4934
|
resolved with the record.
|
|
5044
4935
|
**Example 1**
|
|
5045
|
-
```app/routes/post.js
|
|
4936
|
+
```js [app/routes/post.js]
|
|
5046
4937
|
export default class PostRoute extends Route {
|
|
5047
4938
|
model({ post_id }) {
|
|
5048
4939
|
return this.store.findRecord('post', post_id);
|
|
@@ -5053,7 +4944,7 @@ class Store extends BaseClass {
|
|
|
5053
4944
|
`findRecord` can be called with a single identifier argument instead of the combination
|
|
5054
4945
|
of `type` (modelName) and `id` as separate arguments. You may recognize this combo as
|
|
5055
4946
|
the typical pairing from [JSON:API](https://jsonapi.org/format/#document-resource-object-identification)
|
|
5056
|
-
```app/routes/post.js
|
|
4947
|
+
```js [app/routes/post.js]
|
|
5057
4948
|
export default class PostRoute extends Route {
|
|
5058
4949
|
model({ post_id: id }) {
|
|
5059
4950
|
return this.store.findRecord({ type: 'post', id });
|
|
@@ -5063,7 +4954,7 @@ class Store extends BaseClass {
|
|
|
5063
4954
|
**Example 3**
|
|
5064
4955
|
If you have previously received an lid via an Identifier for this record, and the record
|
|
5065
4956
|
has already been assigned an id, you can find the record again using just the lid.
|
|
5066
|
-
```app/routes/post.js
|
|
4957
|
+
```js [app/routes/post.js]
|
|
5067
4958
|
store.findRecord({ lid });
|
|
5068
4959
|
```
|
|
5069
4960
|
If the record is not yet available, the store will ask the adapter's `findRecord`
|
|
@@ -5076,7 +4967,7 @@ class Store extends BaseClass {
|
|
|
5076
4967
|
For example, if your Ember route looks like `/posts/1/comments/2` and your API route
|
|
5077
4968
|
for the comment also looks like `/posts/1/comments/2` if you want to fetch the comment
|
|
5078
4969
|
without also fetching the post you can pass in the post to the `findRecord` call:
|
|
5079
|
-
```app/routes/post-comments.js
|
|
4970
|
+
```js [app/routes/post-comments.js]
|
|
5080
4971
|
export default class PostRoute extends Route {
|
|
5081
4972
|
model({ post_id, comment_id: id }) {
|
|
5082
4973
|
return this.store.findRecord({ type: 'comment', id, { preload: { post: post_id }} });
|
|
@@ -5085,7 +4976,7 @@ class Store extends BaseClass {
|
|
|
5085
4976
|
```
|
|
5086
4977
|
In your adapter you can then access this id without triggering a network request via the
|
|
5087
4978
|
snapshot:
|
|
5088
|
-
```app/adapters/application.js
|
|
4979
|
+
```js [app/adapters/application.js]
|
|
5089
4980
|
export default class Adapter {
|
|
5090
4981
|
findRecord(store, schema, id, snapshot) {
|
|
5091
4982
|
let type = schema.modelName;
|
|
@@ -5102,14 +4993,14 @@ class Store extends BaseClass {
|
|
|
5102
4993
|
```
|
|
5103
4994
|
This could also be achieved by supplying the post id to the adapter via the adapterOptions
|
|
5104
4995
|
property on the options hash.
|
|
5105
|
-
```app/routes/post-comments.js
|
|
4996
|
+
```js [app/routes/post-comments.js]
|
|
5106
4997
|
export default class PostRoute extends Route {
|
|
5107
4998
|
model({ post_id, comment_id: id }) {
|
|
5108
4999
|
return this.store.findRecord({ type: 'comment', id, { adapterOptions: { post: post_id }} });
|
|
5109
5000
|
}
|
|
5110
5001
|
}
|
|
5111
5002
|
```
|
|
5112
|
-
```app/adapters/application.js
|
|
5003
|
+
```js [app/adapters/application.js]
|
|
5113
5004
|
export default class Adapter {
|
|
5114
5005
|
findRecord(store, schema, id, snapshot) {
|
|
5115
5006
|
let type = schema.modelName;
|
|
@@ -5196,7 +5087,7 @@ class Store extends BaseClass {
|
|
|
5196
5087
|
If you would like to force or prevent background reloading, you can set a
|
|
5197
5088
|
boolean value for `backgroundReload` in the options object for
|
|
5198
5089
|
`findRecord`.
|
|
5199
|
-
```app/routes/post/edit.js
|
|
5090
|
+
```js [app/routes/post/edit.js]
|
|
5200
5091
|
export default class PostEditRoute extends Route {
|
|
5201
5092
|
model(params) {
|
|
5202
5093
|
return this.store.findRecord('post', params.post_id, { backgroundReload: false });
|
|
@@ -5205,7 +5096,7 @@ class Store extends BaseClass {
|
|
|
5205
5096
|
```
|
|
5206
5097
|
If you pass an object on the `adapterOptions` property of the options
|
|
5207
5098
|
argument it will be passed to your adapter via the snapshot
|
|
5208
|
-
```app/routes/post/edit.js
|
|
5099
|
+
```js [app/routes/post/edit.js]
|
|
5209
5100
|
export default class PostEditRoute extends Route {
|
|
5210
5101
|
model(params) {
|
|
5211
5102
|
return this.store.findRecord('post', params.post_id, {
|
|
@@ -5214,7 +5105,7 @@ class Store extends BaseClass {
|
|
|
5214
5105
|
}
|
|
5215
5106
|
}
|
|
5216
5107
|
```
|
|
5217
|
-
```app/adapters/post.js
|
|
5108
|
+
```js [app/adapters/post.js]
|
|
5218
5109
|
import MyCustomAdapter from './custom-adapter';
|
|
5219
5110
|
export default class PostAdapter extends MyCustomAdapter {
|
|
5220
5111
|
findRecord(store, type, id, snapshot) {
|
|
@@ -5237,14 +5128,14 @@ class Store extends BaseClass {
|
|
|
5237
5128
|
For example, given a `post` model that has a `hasMany` relationship with a `comment`
|
|
5238
5129
|
model, when we retrieve a specific post we can have the server also return that post's
|
|
5239
5130
|
comments in the same request:
|
|
5240
|
-
```app/routes/post.js
|
|
5131
|
+
```js [app/routes/post.js]
|
|
5241
5132
|
export default class PostRoute extends Route {
|
|
5242
5133
|
model(params) {
|
|
5243
5134
|
return this.store.findRecord('post', params.post_id, { include: ['comments'] });
|
|
5244
5135
|
}
|
|
5245
5136
|
}
|
|
5246
5137
|
```
|
|
5247
|
-
```app/adapters/application.js
|
|
5138
|
+
```js [app/adapters/application.js]
|
|
5248
5139
|
export default class Adapter {
|
|
5249
5140
|
findRecord(store, schema, id, snapshot) {
|
|
5250
5141
|
let type = schema.modelName;
|
|
@@ -5265,7 +5156,7 @@ class Store extends BaseClass {
|
|
|
5265
5156
|
list of relationship names, while nested relationships can be specified
|
|
5266
5157
|
using a dot-separated sequence of relationship names. So to request both the post's
|
|
5267
5158
|
comments and the authors of those comments the request would look like this:
|
|
5268
|
-
```app/routes/post.js
|
|
5159
|
+
```js [app/routes/post.js]
|
|
5269
5160
|
export default class PostRoute extends Route {
|
|
5270
5161
|
model(params) {
|
|
5271
5162
|
return this.store.findRecord('post', params.post_id, { include: ['comments','comments.author'] });
|
|
@@ -5276,7 +5167,7 @@ class Store extends BaseClass {
|
|
|
5276
5167
|
If your server endpoint supports the use of a ['fields' query parameter](https://jsonapi.org/format/#fetching-sparse-fieldsets),
|
|
5277
5168
|
you can use pass those fields through to your server. At this point in time, this requires a few manual steps on your part.
|
|
5278
5169
|
1. Implement `buildQuery` in your adapter.
|
|
5279
|
-
```app/adapters/application.js
|
|
5170
|
+
```js [app/adapters/application.js]
|
|
5280
5171
|
buildQuery(snapshot) {
|
|
5281
5172
|
let query = super.buildQuery(...arguments);
|
|
5282
5173
|
let { fields } = snapshot.adapterOptions;
|
|
@@ -5288,7 +5179,7 @@ class Store extends BaseClass {
|
|
|
5288
5179
|
```
|
|
5289
5180
|
2. Then pass through the applicable fields to your `findRecord` request.
|
|
5290
5181
|
Given a `post` model with attributes body, title, publishDate and meta, you can retrieve a filtered list of attributes.
|
|
5291
|
-
```app/routes/post.js
|
|
5182
|
+
```js [app/routes/post.js]
|
|
5292
5183
|
export default class extends Route {
|
|
5293
5184
|
model(params) {
|
|
5294
5185
|
return this.store.findRecord('post', params.post_id, { adapterOptions: { fields: { post: 'body,title' } });
|
|
@@ -5297,7 +5188,7 @@ class Store extends BaseClass {
|
|
|
5297
5188
|
```
|
|
5298
5189
|
Moreover, you can filter attributes on related models as well. If a `post` has a `belongsTo` relationship to a user,
|
|
5299
5190
|
just include the relationship key and attributes.
|
|
5300
|
-
```app/routes/post.js
|
|
5191
|
+
```js [app/routes/post.js]
|
|
5301
5192
|
export default class extends Route {
|
|
5302
5193
|
model(params) {
|
|
5303
5194
|
return this.store.findRecord('post', params.post_id, { adapterOptions: { fields: { post: 'body,title', user: 'name,email' } });
|
|
@@ -5305,7 +5196,6 @@ class Store extends BaseClass {
|
|
|
5305
5196
|
}
|
|
5306
5197
|
```
|
|
5307
5198
|
@since 1.13.0
|
|
5308
|
-
@method findRecord
|
|
5309
5199
|
@public
|
|
5310
5200
|
@param {String|object} type - either a string representing the name of the resource or a ResourceIdentifier object containing both the type (a string) and the id (a string) for the record or an lid (a string) of an existing record
|
|
5311
5201
|
@param {(String|Integer|Object)} id - optional object with options for the request only if the first param is a ResourceIdentifier, else the string id of the record to be retrieved
|
|
@@ -5384,8 +5274,7 @@ class Store extends BaseClass {
|
|
|
5384
5274
|
userRef.value() === user;
|
|
5385
5275
|
});
|
|
5386
5276
|
```
|
|
5387
|
-
@
|
|
5388
|
-
@public
|
|
5277
|
+
@public
|
|
5389
5278
|
@param {String|object} resource - modelName (string) or Identifier (object)
|
|
5390
5279
|
@param {String|Integer} id
|
|
5391
5280
|
@since 2.5.0
|
|
@@ -5441,7 +5330,6 @@ class Store extends BaseClass {
|
|
|
5441
5330
|
post.id; // '1'
|
|
5442
5331
|
```
|
|
5443
5332
|
@since 1.13.0
|
|
5444
|
-
@method peekRecord
|
|
5445
5333
|
@public
|
|
5446
5334
|
@param {String|object} modelName - either a string representing the modelName or a ResourceIdentifier object containing both the type (a string) and the id (a string) for the record or an lid (a string) of an existing record
|
|
5447
5335
|
@param {String|Integer} id - optional only if the first param is a ResourceIdentifier, else the string id of the record to be retrieved.
|
|
@@ -5510,7 +5398,6 @@ class Store extends BaseClass {
|
|
|
5510
5398
|
[`Collection`](/ember-data/release/classes/Collection)
|
|
5511
5399
|
once the server returns.
|
|
5512
5400
|
@since 1.13.0
|
|
5513
|
-
@method query
|
|
5514
5401
|
@public
|
|
5515
5402
|
@param {String} type the name of the resource
|
|
5516
5403
|
@param {Object} query a query to be used by the adapter
|
|
@@ -5578,7 +5465,7 @@ class Store extends BaseClass {
|
|
|
5578
5465
|
});
|
|
5579
5466
|
```
|
|
5580
5467
|
The request is made through the adapters' `queryRecord`:
|
|
5581
|
-
```app/adapters/user.js
|
|
5468
|
+
```js [app/adapters/user.js]
|
|
5582
5469
|
import Adapter from '@ember-data/adapter';
|
|
5583
5470
|
import $ from 'jquery';
|
|
5584
5471
|
export default class UserAdapter extends Adapter {
|
|
@@ -5625,7 +5512,6 @@ class Store extends BaseClass {
|
|
|
5625
5512
|
});
|
|
5626
5513
|
```
|
|
5627
5514
|
@since 1.13.0
|
|
5628
|
-
@method queryRecord
|
|
5629
5515
|
@public
|
|
5630
5516
|
@param {String} type
|
|
5631
5517
|
@param {Object} query an opaque query to be used by the adapter
|
|
@@ -5671,7 +5557,7 @@ class Store extends BaseClass {
|
|
|
5671
5557
|
given type, and returns a promise which will resolve with all records of
|
|
5672
5558
|
this type present in the store, even if the adapter only returns a subset
|
|
5673
5559
|
of them.
|
|
5674
|
-
```app/routes/authors.js
|
|
5560
|
+
```js [app/routes/authors.js]
|
|
5675
5561
|
export default class AuthorsRoute extends Route {
|
|
5676
5562
|
model(params) {
|
|
5677
5563
|
return this.store.findAll('author');
|
|
@@ -5710,7 +5596,7 @@ class Store extends BaseClass {
|
|
|
5710
5596
|
then a background reload is started. Once this resolves, the array with
|
|
5711
5597
|
which the promise resolves, is updated automatically so it contains all the
|
|
5712
5598
|
records in the store:
|
|
5713
|
-
```app/adapters/application.js
|
|
5599
|
+
```js [app/adapters/application.js]
|
|
5714
5600
|
import Adapter from '@ember-data/adapter';
|
|
5715
5601
|
export default class ApplicationAdapter extends Adapter {
|
|
5716
5602
|
shouldReloadAll(store, snapshotsArray) {
|
|
@@ -5744,7 +5630,7 @@ class Store extends BaseClass {
|
|
|
5744
5630
|
If you would like to force or prevent background reloading, you can set a
|
|
5745
5631
|
boolean value for `backgroundReload` in the options object for
|
|
5746
5632
|
`findAll`.
|
|
5747
|
-
```app/routes/post/edit.js
|
|
5633
|
+
```js [app/routes/post/edit.js]
|
|
5748
5634
|
export default class PostEditRoute extends Route {
|
|
5749
5635
|
model() {
|
|
5750
5636
|
return this.store.findAll('post', { backgroundReload: false });
|
|
@@ -5753,7 +5639,7 @@ class Store extends BaseClass {
|
|
|
5753
5639
|
```
|
|
5754
5640
|
If you pass an object on the `adapterOptions` property of the options
|
|
5755
5641
|
argument it will be passed to you adapter via the `snapshotRecordArray`
|
|
5756
|
-
```app/routes/posts.js
|
|
5642
|
+
```js [app/routes/posts.js]
|
|
5757
5643
|
export default class PostsRoute extends Route {
|
|
5758
5644
|
model(params) {
|
|
5759
5645
|
return this.store.findAll('post', {
|
|
@@ -5762,7 +5648,7 @@ class Store extends BaseClass {
|
|
|
5762
5648
|
}
|
|
5763
5649
|
}
|
|
5764
5650
|
```
|
|
5765
|
-
```app/adapters/post.js
|
|
5651
|
+
```js [app/adapters/post.js]
|
|
5766
5652
|
import MyCustomAdapter from './custom-adapter';
|
|
5767
5653
|
export default class UserAdapter extends MyCustomAdapter {
|
|
5768
5654
|
findAll(store, type, sinceToken, snapshotRecordArray) {
|
|
@@ -5786,7 +5672,7 @@ class Store extends BaseClass {
|
|
|
5786
5672
|
For example, given a `post` model that has a `hasMany` relationship with a `comment`
|
|
5787
5673
|
model, when we retrieve all of the post records we can have the server also return
|
|
5788
5674
|
all of the posts' comments in the same request:
|
|
5789
|
-
```app/routes/posts.js
|
|
5675
|
+
```js [app/routes/posts.js]
|
|
5790
5676
|
export default class PostsRoute extends Route {
|
|
5791
5677
|
model() {
|
|
5792
5678
|
return this.store.findAll('post', { include: ['comments'] });
|
|
@@ -5797,7 +5683,7 @@ class Store extends BaseClass {
|
|
|
5797
5683
|
list or relationship names, while nested relationships can be specified
|
|
5798
5684
|
using a dot-separated sequence of relationship names. So to request both the posts'
|
|
5799
5685
|
comments and the authors of those comments the request would look like this:
|
|
5800
|
-
```app/routes/posts.js
|
|
5686
|
+
```js [app/routes/posts.js]
|
|
5801
5687
|
export default class PostsRoute extends Route {
|
|
5802
5688
|
model() {
|
|
5803
5689
|
return this.store.findAll('post', { include: ['comments','comments.author'] });
|
|
@@ -5806,7 +5692,6 @@ class Store extends BaseClass {
|
|
|
5806
5692
|
```
|
|
5807
5693
|
See [query](../methods/query?anchor=query) to only get a subset of records from the server.
|
|
5808
5694
|
@since 1.13.0
|
|
5809
|
-
@method findAll
|
|
5810
5695
|
@public
|
|
5811
5696
|
@param {String} type the name of the resource
|
|
5812
5697
|
@param {Object} options
|
|
@@ -5855,7 +5740,6 @@ class Store extends BaseClass {
|
|
|
5855
5740
|
let localPosts = store.peekAll('post');
|
|
5856
5741
|
```
|
|
5857
5742
|
@since 1.13.0
|
|
5858
|
-
@method peekAll
|
|
5859
5743
|
@public
|
|
5860
5744
|
@param {String} type the name of the resource
|
|
5861
5745
|
@return {RecordArray}
|
|
@@ -5886,8 +5770,7 @@ class Store extends BaseClass {
|
|
|
5886
5770
|
store.unloadAll();
|
|
5887
5771
|
store.unloadAll('post');
|
|
5888
5772
|
```
|
|
5889
|
-
@
|
|
5890
|
-
@param {String} type the name of the resource
|
|
5773
|
+
@param {String} type the name of the resource
|
|
5891
5774
|
@public
|
|
5892
5775
|
*/
|
|
5893
5776
|
|
|
@@ -5968,7 +5851,7 @@ class Store extends BaseClass {
|
|
|
5968
5851
|
- [`data`](http://jsonapi.org/format/#document-resource-object-linkage) - place for primary data
|
|
5969
5852
|
- [`meta`](http://jsonapi.org/format/#document-meta) - object which contains meta-information about relationship
|
|
5970
5853
|
For this model:
|
|
5971
|
-
```app/models/person.js
|
|
5854
|
+
```js [app/models/person.js]
|
|
5972
5855
|
import Model, { attr, hasMany } from '@ember-data/model';
|
|
5973
5856
|
export default class PersonRoute extends Route {
|
|
5974
5857
|
@attr('string') firstName;
|
|
@@ -6038,8 +5921,7 @@ class Store extends BaseClass {
|
|
|
6038
5921
|
```
|
|
6039
5922
|
This method can be used both to push in brand new
|
|
6040
5923
|
records, as well as to update existing records.
|
|
6041
|
-
@
|
|
6042
|
-
@public
|
|
5924
|
+
@public
|
|
6043
5925
|
@param {Object} data
|
|
6044
5926
|
@return the record(s) that was created or
|
|
6045
5927
|
updated.
|
|
@@ -6062,8 +5944,7 @@ class Store extends BaseClass {
|
|
|
6062
5944
|
/**
|
|
6063
5945
|
Push some data in the form of a json-api document into the store,
|
|
6064
5946
|
without creating materialized records.
|
|
6065
|
-
@
|
|
6066
|
-
@private
|
|
5947
|
+
@private
|
|
6067
5948
|
@param {Object} jsonApiDoc
|
|
6068
5949
|
@return {StableRecordIdentifier|Array<StableRecordIdentifier>|null} identifiers for the primary records that had data loaded
|
|
6069
5950
|
*/
|
|
@@ -6089,7 +5970,6 @@ class Store extends BaseClass {
|
|
|
6089
5970
|
*
|
|
6090
5971
|
* Returns a promise resolving with the same record when the save is complete.
|
|
6091
5972
|
*
|
|
6092
|
-
* @method saveRecord
|
|
6093
5973
|
* @public
|
|
6094
5974
|
* @param {unknown} record
|
|
6095
5975
|
* @param options
|
|
@@ -6149,7 +6029,6 @@ class Store extends BaseClass {
|
|
|
6149
6029
|
* This hook should not be called directly by consuming applications or libraries.
|
|
6150
6030
|
* Use `Store.cache` to access the Cache instance.
|
|
6151
6031
|
*
|
|
6152
|
-
* @method createCache (hook)
|
|
6153
6032
|
* @public
|
|
6154
6033
|
* @param storeWrapper
|
|
6155
6034
|
* @return {Cache}
|
|
@@ -6385,10 +6264,6 @@ function getPriority(identifier, deduped, priority) {
|
|
|
6385
6264
|
return priority;
|
|
6386
6265
|
}
|
|
6387
6266
|
|
|
6388
|
-
/**
|
|
6389
|
-
* @module @ember-data/store
|
|
6390
|
-
*/
|
|
6391
|
-
|
|
6392
6267
|
/**
|
|
6393
6268
|
* A CacheHandler that adds support for using an EmberData Cache with a RequestManager.
|
|
6394
6269
|
*
|
|
@@ -6428,7 +6303,6 @@ function getPriority(identifier, deduped, priority) {
|
|
|
6428
6303
|
* [EnableHydration]: true
|
|
6429
6304
|
* });
|
|
6430
6305
|
*
|
|
6431
|
-
* @typedoc
|
|
6432
6306
|
*/
|
|
6433
6307
|
const CacheHandler = {
|
|
6434
6308
|
request(context, next) {
|
|
@@ -6673,9 +6547,6 @@ function fetchContentAndHydrate(next, context, identifier, priority) {
|
|
|
6673
6547
|
});
|
|
6674
6548
|
}
|
|
6675
6549
|
|
|
6676
|
-
/**
|
|
6677
|
-
@module @ember-data/store
|
|
6678
|
-
*/
|
|
6679
6550
|
/**
|
|
6680
6551
|
A `ManyArray` is a `MutableArray` that represents the contents of a has-many
|
|
6681
6552
|
relationship.
|
|
@@ -6691,7 +6562,7 @@ function fetchContentAndHydrate(next, context, identifier, priority) {
|
|
|
6691
6562
|
an inverse. For example, imagine the following models are
|
|
6692
6563
|
defined:
|
|
6693
6564
|
|
|
6694
|
-
```app/models/post.js
|
|
6565
|
+
```js [app/models/post.js]
|
|
6695
6566
|
import Model, { hasMany } from '@ember-data/model';
|
|
6696
6567
|
|
|
6697
6568
|
export default class PostModel extends Model {
|
|
@@ -6699,7 +6570,7 @@ function fetchContentAndHydrate(next, context, identifier, priority) {
|
|
|
6699
6570
|
}
|
|
6700
6571
|
```
|
|
6701
6572
|
|
|
6702
|
-
```app/models/comment.js
|
|
6573
|
+
```js [app/models/comment.js]
|
|
6703
6574
|
import Model, { belongsTo } from '@ember-data/model';
|
|
6704
6575
|
|
|
6705
6576
|
export default class CommentModel extends Model {
|
|
@@ -6994,8 +6865,7 @@ class RelatedCollection extends IdentifierArray {
|
|
|
6994
6865
|
let permissions = await user.permissions;
|
|
6995
6866
|
await permissions.reload();
|
|
6996
6867
|
```
|
|
6997
|
-
@
|
|
6998
|
-
@public
|
|
6868
|
+
@public
|
|
6999
6869
|
*/
|
|
7000
6870
|
reload(options) {
|
|
7001
6871
|
macroCondition(getGlobalConfig().WarpDrive.env.DEBUG) ? (test => {
|
|
@@ -7007,27 +6877,9 @@ class RelatedCollection extends IdentifierArray {
|
|
|
7007
6877
|
return this._manager.reloadHasMany(this.key, options);
|
|
7008
6878
|
}
|
|
7009
6879
|
|
|
7010
|
-
/**
|
|
7011
|
-
Saves all of the records in the `ManyArray`.
|
|
7012
|
-
Note: this API can only be used in legacy mode with a configured Adapter.
|
|
7013
|
-
Example
|
|
7014
|
-
```javascript
|
|
7015
|
-
const { content: { data: inbox } } = await store.request(findRecord({ type: 'inbox', id: '1' }));
|
|
7016
|
-
let messages = await inbox.messages;
|
|
7017
|
-
messages.forEach((message) => {
|
|
7018
|
-
message.isRead = true;
|
|
7019
|
-
});
|
|
7020
|
-
messages.save();
|
|
7021
|
-
```
|
|
7022
|
-
@method save
|
|
7023
|
-
@public
|
|
7024
|
-
@return {PromiseArray} promise
|
|
7025
|
-
*/
|
|
7026
|
-
|
|
7027
6880
|
/**
|
|
7028
6881
|
Create a child record within the owner
|
|
7029
|
-
@
|
|
7030
|
-
@public
|
|
6882
|
+
@public
|
|
7031
6883
|
@param {Object} hash
|
|
7032
6884
|
@return {Model} record
|
|
7033
6885
|
*/
|
|
@@ -7044,6 +6896,24 @@ class RelatedCollection extends IdentifierArray {
|
|
|
7044
6896
|
this.push(record);
|
|
7045
6897
|
return record;
|
|
7046
6898
|
}
|
|
6899
|
+
|
|
6900
|
+
/**
|
|
6901
|
+
Saves all of the records in the `ManyArray`.
|
|
6902
|
+
Note: this API can only be used in legacy mode with a configured Adapter.
|
|
6903
|
+
Example
|
|
6904
|
+
```javascript
|
|
6905
|
+
const { content: { data: inbox } } = await store.request(findRecord({ type: 'inbox', id: '1' }));
|
|
6906
|
+
let messages = await inbox.messages;
|
|
6907
|
+
messages.forEach((message) => {
|
|
6908
|
+
message.isRead = true;
|
|
6909
|
+
});
|
|
6910
|
+
messages.save();
|
|
6911
|
+
```
|
|
6912
|
+
@public
|
|
6913
|
+
@return {PromiseArray} promise
|
|
6914
|
+
*/
|
|
6915
|
+
|
|
6916
|
+
/** @internal */
|
|
7047
6917
|
destroy() {
|
|
7048
6918
|
super.destroy(false);
|
|
7049
6919
|
}
|
|
@@ -7151,7 +7021,6 @@ const PromiseCache = new WeakMap();
|
|
|
7151
7021
|
* The state of a promise in the "pending"
|
|
7152
7022
|
* state. This is the default initial state.
|
|
7153
7023
|
*
|
|
7154
|
-
* @typedoc
|
|
7155
7024
|
*/
|
|
7156
7025
|
|
|
7157
7026
|
/**
|
|
@@ -7159,7 +7028,6 @@ const PromiseCache = new WeakMap();
|
|
|
7159
7028
|
* This is the state of a promise that has resolved
|
|
7160
7029
|
* successfully.
|
|
7161
7030
|
*
|
|
7162
|
-
* @typedoc
|
|
7163
7031
|
*/
|
|
7164
7032
|
|
|
7165
7033
|
/**
|
|
@@ -7167,7 +7035,6 @@ const PromiseCache = new WeakMap();
|
|
|
7167
7035
|
* This is the state of a promise that has rejected
|
|
7168
7036
|
* with an error.
|
|
7169
7037
|
*
|
|
7170
|
-
* @typedoc
|
|
7171
7038
|
*/
|
|
7172
7039
|
|
|
7173
7040
|
/**
|
|
@@ -7179,7 +7046,6 @@ const PromiseCache = new WeakMap();
|
|
|
7179
7046
|
* - {@link ResolvedPromise}
|
|
7180
7047
|
* - {@link RejectedPromise}
|
|
7181
7048
|
*
|
|
7182
|
-
* @typedoc
|
|
7183
7049
|
*/
|
|
7184
7050
|
|
|
7185
7051
|
const PromiseStateProto = {};
|
|
@@ -7300,7 +7166,6 @@ function getPromise(promise) {
|
|
|
7300
7166
|
*
|
|
7301
7167
|
* If looking to use in a template, consider also the `<Await />` component.
|
|
7302
7168
|
*
|
|
7303
|
-
* @typedoc
|
|
7304
7169
|
*/
|
|
7305
7170
|
function getPromiseState(promise) {
|
|
7306
7171
|
const _promise = getPromise(promise);
|
|
@@ -7374,7 +7239,6 @@ async function watchStream(stream, state) {
|
|
|
7374
7239
|
* reactive properties that can be used to build UIs that respond
|
|
7375
7240
|
* to the progress of a request.
|
|
7376
7241
|
*
|
|
7377
|
-
* @typedoc
|
|
7378
7242
|
*/
|
|
7379
7243
|
class RequestLoadingState {
|
|
7380
7244
|
_stream = null;
|
|
@@ -7504,7 +7368,6 @@ defineNonEnumerableSignal(RequestLoadingState.prototype, '_lastPacketTime', 0);
|
|
|
7504
7368
|
*
|
|
7505
7369
|
* Extends the {@link PendingPromise} interface.
|
|
7506
7370
|
*
|
|
7507
|
-
* @typedoc
|
|
7508
7371
|
*/
|
|
7509
7372
|
|
|
7510
7373
|
/**
|
|
@@ -7514,7 +7377,6 @@ defineNonEnumerableSignal(RequestLoadingState.prototype, '_lastPacketTime', 0);
|
|
|
7514
7377
|
*
|
|
7515
7378
|
* Extends the {@link ResolvedPromise} interface.
|
|
7516
7379
|
*
|
|
7517
|
-
* @typedoc
|
|
7518
7380
|
*/
|
|
7519
7381
|
|
|
7520
7382
|
/**
|
|
@@ -7524,7 +7386,6 @@ defineNonEnumerableSignal(RequestLoadingState.prototype, '_lastPacketTime', 0);
|
|
|
7524
7386
|
*
|
|
7525
7387
|
* Extends the {@link RejectedPromise} interface.
|
|
7526
7388
|
*
|
|
7527
|
-
* @typedoc
|
|
7528
7389
|
*/
|
|
7529
7390
|
|
|
7530
7391
|
/**
|
|
@@ -7532,7 +7393,6 @@ defineNonEnumerableSignal(RequestLoadingState.prototype, '_lastPacketTime', 0);
|
|
|
7532
7393
|
* This is the state of a promise that has been
|
|
7533
7394
|
* cancelled.
|
|
7534
7395
|
*
|
|
7535
|
-
* @typedoc
|
|
7536
7396
|
*/
|
|
7537
7397
|
|
|
7538
7398
|
/**
|
|
@@ -7566,7 +7426,6 @@ defineNonEnumerableSignal(RequestLoadingState.prototype, '_lastPacketTime', 0);
|
|
|
7566
7426
|
* - {@link RejectedRequest}
|
|
7567
7427
|
* - {@link CancelledRequest}
|
|
7568
7428
|
*
|
|
7569
|
-
* @typedoc
|
|
7570
7429
|
*/
|
|
7571
7430
|
|
|
7572
7431
|
const RequestStateProto = {};
|
|
@@ -7702,7 +7561,6 @@ function createRequestState(future) {
|
|
|
7702
7561
|
* which offers a numbe of additional capabilities for requests *beyond* what
|
|
7703
7562
|
* `RequestState` provides.
|
|
7704
7563
|
*
|
|
7705
|
-
* @typedoc
|
|
7706
7564
|
*/
|
|
7707
7565
|
function getRequestState(future) {
|
|
7708
7566
|
let state = RequestCache.get(future);
|