@ember-data/store 5.4.0-alpha.57 → 5.4.0-alpha.59
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/addon/-private.js +1 -1
- package/addon/{cache-handler-TC2-lizB.js → cache-handler-DoL926UP.js} +21 -13
- package/addon/cache-handler-DoL926UP.js.map +1 -0
- package/addon/index.js +1 -1
- package/package.json +9 -9
- package/unstable-preview-types/-private/cache-handler.d.ts.map +1 -1
- package/unstable-preview-types/-private/store-service.d.ts +12 -12
- package/addon/cache-handler-TC2-lizB.js.map +0 -1
package/addon/-private.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export { A as ARRAY_SIGNAL, b as AdapterPopulatedRecordArray, C as CacheHandler, I as IdentifierArray, M as MUTATE, I as RecordArray, R as RecordArrayManager, d as SOURCE, S as Store, j as StoreMap, _ as _clearCaches, l as _deprecatingNormalize, a as coerceId, c as constructResource, e as ensureStringId, f as fastPush, i as isStableIdentifier, n as notifyArray, p as peekCache, r as recordIdentifierFor, g as removeRecordDataFor, k as setCacheFor, h as setRecordIdentifier, s as storeFor } from "./cache-handler-
|
|
1
|
+
export { A as ARRAY_SIGNAL, b as AdapterPopulatedRecordArray, C as CacheHandler, I as IdentifierArray, M as MUTATE, I as RecordArray, R as RecordArrayManager, d as SOURCE, S as Store, j as StoreMap, _ as _clearCaches, l as _deprecatingNormalize, a as coerceId, c as constructResource, e as ensureStringId, f as fastPush, i as isStableIdentifier, n as notifyArray, p as peekCache, r as recordIdentifierFor, g as removeRecordDataFor, k as setCacheFor, h as setRecordIdentifier, s as storeFor } from "./cache-handler-DoL926UP";
|
|
@@ -3860,7 +3860,7 @@ class Store extends EmberObject {
|
|
|
3860
3860
|
```
|
|
3861
3861
|
To create a new instance of a `Post` that has a relationship with a `User` record:
|
|
3862
3862
|
```js
|
|
3863
|
-
let user = this.store.peekRecord('user', 1);
|
|
3863
|
+
let user = this.store.peekRecord('user', '1');
|
|
3864
3864
|
store.createRecord('post', {
|
|
3865
3865
|
title: 'Ember is awesome!',
|
|
3866
3866
|
user: user
|
|
@@ -3958,7 +3958,7 @@ class Store extends EmberObject {
|
|
|
3958
3958
|
This will cause the record to be destroyed and freed up for garbage collection.
|
|
3959
3959
|
Example
|
|
3960
3960
|
```javascript
|
|
3961
|
-
store.findRecord('post', 1).then(function(post) {
|
|
3961
|
+
store.findRecord('post', '1').then(function(post) {
|
|
3962
3962
|
store.unloadRecord(post);
|
|
3963
3963
|
});
|
|
3964
3964
|
```
|
|
@@ -4071,8 +4071,8 @@ class Store extends EmberObject {
|
|
|
4071
4071
|
```
|
|
4072
4072
|
If you have access to the post model you can also pass the model itself to preload:
|
|
4073
4073
|
```javascript
|
|
4074
|
-
let post = await store.findRecord('post', 1);
|
|
4075
|
-
let comment = await store.findRecord('comment', 2, { post: myPostModel });
|
|
4074
|
+
let post = await store.findRecord('post', '1');
|
|
4075
|
+
let comment = await store.findRecord('comment', '2', { post: myPostModel });
|
|
4076
4076
|
```
|
|
4077
4077
|
### Reloading
|
|
4078
4078
|
The reload behavior is configured either via the passed `options` hash or
|
|
@@ -4096,7 +4096,7 @@ class Store extends EmberObject {
|
|
|
4096
4096
|
// revision: 2
|
|
4097
4097
|
// }
|
|
4098
4098
|
// ]
|
|
4099
|
-
store.findRecord('post', 1, { reload: true }).then(function(post) {
|
|
4099
|
+
store.findRecord('post', '1', { reload: true }).then(function(post) {
|
|
4100
4100
|
post.revision; // 2
|
|
4101
4101
|
});
|
|
4102
4102
|
```
|
|
@@ -4125,7 +4125,7 @@ class Store extends EmberObject {
|
|
|
4125
4125
|
revision: 1
|
|
4126
4126
|
}
|
|
4127
4127
|
});
|
|
4128
|
-
let blogPost = store.findRecord('post', 1).then(function(post) {
|
|
4128
|
+
let blogPost = store.findRecord('post', '1').then(function(post) {
|
|
4129
4129
|
post.revision; // 1
|
|
4130
4130
|
});
|
|
4131
4131
|
// later, once adapter#findRecord resolved with
|
|
@@ -4309,7 +4309,7 @@ class Store extends EmberObject {
|
|
|
4309
4309
|
Get the reference for the specified record.
|
|
4310
4310
|
Example
|
|
4311
4311
|
```javascript
|
|
4312
|
-
let userRef = store.getReference('user', 1);
|
|
4312
|
+
let userRef = store.getReference('user', '1');
|
|
4313
4313
|
// check if the user is loaded
|
|
4314
4314
|
let isLoaded = userRef.value() !== null;
|
|
4315
4315
|
// get the record of the reference (null if not yet available)
|
|
@@ -4361,8 +4361,8 @@ class Store extends EmberObject {
|
|
|
4361
4361
|
_Note: This is a synchronous method and does not return a promise._
|
|
4362
4362
|
**Example 1**
|
|
4363
4363
|
```js
|
|
4364
|
-
let post = store.peekRecord('post', 1);
|
|
4365
|
-
post.id; // 1
|
|
4364
|
+
let post = store.peekRecord('post', '1');
|
|
4365
|
+
post.id; // '1'
|
|
4366
4366
|
```
|
|
4367
4367
|
`peekRecord` can be called with a single identifier argument instead of the combination
|
|
4368
4368
|
of `type` (modelName) and `id` as separate arguments. You may recognize this combo as
|
|
@@ -4370,14 +4370,14 @@ class Store extends EmberObject {
|
|
|
4370
4370
|
**Example 2**
|
|
4371
4371
|
```js
|
|
4372
4372
|
let post = store.peekRecord({ type: 'post', id });
|
|
4373
|
-
post.id; // 1
|
|
4373
|
+
post.id; // '1'
|
|
4374
4374
|
```
|
|
4375
4375
|
If you have previously received an lid from an Identifier for this record, you can lookup the record again using
|
|
4376
4376
|
just the lid.
|
|
4377
4377
|
**Example 3**
|
|
4378
4378
|
```js
|
|
4379
4379
|
let post = store.peekRecord({ lid });
|
|
4380
|
-
post.id; // 1
|
|
4380
|
+
post.id; // '1'
|
|
4381
4381
|
```
|
|
4382
4382
|
@since 1.13.0
|
|
4383
4383
|
@method peekRecord
|
|
@@ -4430,7 +4430,7 @@ class Store extends EmberObject {
|
|
|
4430
4430
|
---
|
|
4431
4431
|
If you do something like this:
|
|
4432
4432
|
```javascript
|
|
4433
|
-
store.query('person', { ids: [1, 2, 3] });
|
|
4433
|
+
store.query('person', { ids: ['1', '2', '3'] });
|
|
4434
4434
|
```
|
|
4435
4435
|
The request made to the server will look something like this:
|
|
4436
4436
|
```
|
|
@@ -5603,10 +5603,18 @@ function fetchContentAndHydrate(next, context, identifier, shouldFetch, shouldBa
|
|
|
5603
5603
|
}]
|
|
5604
5604
|
});
|
|
5605
5605
|
}
|
|
5606
|
+
function isAggregateError(error) {
|
|
5607
|
+
return error instanceof AggregateError || error.name === 'AggregateError' && Array.isArray(error.errors);
|
|
5608
|
+
}
|
|
5609
|
+
// TODO @runspired, consider if we should deep freeze errors (potentially only in debug) vs cloning them
|
|
5606
5610
|
function cloneError(error) {
|
|
5607
|
-
const
|
|
5611
|
+
const isAggregate = isAggregateError(error);
|
|
5612
|
+
const cloned = isAggregate ? new AggregateError(structuredClone(error.errors), error.message) : new Error(error.message);
|
|
5608
5613
|
cloned.stack = error.stack;
|
|
5609
5614
|
cloned.error = error.error;
|
|
5615
|
+
|
|
5616
|
+
// copy over enumerable properties
|
|
5617
|
+
Object.assign(cloned, error);
|
|
5610
5618
|
return cloned;
|
|
5611
5619
|
}
|
|
5612
5620
|
|