@ember-data/store 4.10.0-beta.2 → 4.10.0-beta.3
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.
|
@@ -476,12 +476,6 @@ export class InstanceCache {
|
|
|
476
476
|
const isEmpty = _isEmpty(this, identifier);
|
|
477
477
|
const isLoading = _isLoading(this, identifier);
|
|
478
478
|
|
|
479
|
-
if (options.preload) {
|
|
480
|
-
this.store._join(() => {
|
|
481
|
-
preloadData(this.store, identifier, options.preload!);
|
|
482
|
-
});
|
|
483
|
-
}
|
|
484
|
-
|
|
485
479
|
let promise: Promise<StableRecordIdentifier>;
|
|
486
480
|
if (isEmpty) {
|
|
487
481
|
assertIdentifierHasId(identifier);
|
|
@@ -617,7 +611,7 @@ export function recordDataIsFullyDeleted(cache: InstanceCache, identifier: Stabl
|
|
|
617
611
|
models.
|
|
618
612
|
*/
|
|
619
613
|
type PreloadRelationshipValue = RecordInstance | string;
|
|
620
|
-
function preloadData(store: Store, identifier: StableRecordIdentifier, preload: Dict<unknown>) {
|
|
614
|
+
export function preloadData(store: Store, identifier: StableRecordIdentifier, preload: Dict<unknown>) {
|
|
621
615
|
let jsonPayload: JsonApiResource = {};
|
|
622
616
|
//TODO(Igor) consider the polymorphic case
|
|
623
617
|
const schemas = store.getSchemaDefinitionService();
|
|
@@ -81,16 +81,11 @@ export default class ShimModelClass implements ModelSchema {
|
|
|
81
81
|
});
|
|
82
82
|
}
|
|
83
83
|
|
|
84
|
-
eachTransformedAttribute<T>(
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
.getSchemaDefinitionService()
|
|
90
|
-
.relationshipsDefinitionFor({ type: this.modelName });
|
|
91
|
-
Object.keys(relationshipDefs).forEach((key) => {
|
|
92
|
-
if (relationshipDefs[key]!.type) {
|
|
93
|
-
callback.call(binding, key, relationshipDefs[key] as RelationshipSchema);
|
|
84
|
+
eachTransformedAttribute<T>(callback: (this: T | undefined, key: string, type: string) => void, binding?: T) {
|
|
85
|
+
const attrDefs = this.__store.getSchemaDefinitionService().attributesDefinitionFor({ type: this.modelName });
|
|
86
|
+
Object.keys(attrDefs).forEach((key) => {
|
|
87
|
+
if (attrDefs[key]!.type) {
|
|
88
|
+
callback.call(binding, key, attrDefs[key]!.type);
|
|
94
89
|
}
|
|
95
90
|
});
|
|
96
91
|
}
|
|
@@ -45,6 +45,7 @@ import { IdentifierCache } from './caches/identifier-cache';
|
|
|
45
45
|
import {
|
|
46
46
|
InstanceCache,
|
|
47
47
|
peekRecordIdentifier,
|
|
48
|
+
preloadData,
|
|
48
49
|
recordDataIsFullyDeleted,
|
|
49
50
|
recordIdentifierFor,
|
|
50
51
|
setRecordIdentifier,
|
|
@@ -482,6 +483,7 @@ class Store extends Service {
|
|
|
482
483
|
@return {subclass of Model | ShimModelClass}
|
|
483
484
|
*/
|
|
484
485
|
// TODO @deprecate in favor of schema APIs, requires adapter/serializer overhaul or replacement
|
|
486
|
+
declare _forceShim: boolean;
|
|
485
487
|
modelFor(modelName: string): ShimModelClass | DSModelClass {
|
|
486
488
|
if (DEBUG) {
|
|
487
489
|
assertDestroyedStoreOnly(this, 'modelFor');
|
|
@@ -497,7 +499,7 @@ class Store extends Service {
|
|
|
497
499
|
|
|
498
500
|
// for factorFor factory/class split
|
|
499
501
|
let klass = maybeFactory && maybeFactory.class ? maybeFactory.class : maybeFactory;
|
|
500
|
-
if (!klass || !klass.isModel) {
|
|
502
|
+
if (!klass || !klass.isModel || this._forceShim) {
|
|
501
503
|
assert(
|
|
502
504
|
`No model was found for '${modelName}' and no schema handles the type`,
|
|
503
505
|
this.getSchemaDefinitionService().doesTypeExist(modelName)
|
|
@@ -1127,6 +1129,12 @@ class Store extends Service {
|
|
|
1127
1129
|
let promise;
|
|
1128
1130
|
options = options || {};
|
|
1129
1131
|
|
|
1132
|
+
if (options.preload) {
|
|
1133
|
+
this._join(() => {
|
|
1134
|
+
preloadData(this, identifier, options!.preload!);
|
|
1135
|
+
});
|
|
1136
|
+
}
|
|
1137
|
+
|
|
1130
1138
|
// if not loaded start loading
|
|
1131
1139
|
if (!this._instanceCache.recordIsLoaded(identifier)) {
|
|
1132
1140
|
promise = this._instanceCache._fetchDataIfNeededForIdentifier(identifier, options);
|
|
@@ -1134,6 +1142,7 @@ class Store extends Service {
|
|
|
1134
1142
|
// Refetch if the reload option is passed
|
|
1135
1143
|
} else if (options.reload) {
|
|
1136
1144
|
assertIdentifierHasId(identifier);
|
|
1145
|
+
|
|
1137
1146
|
promise = this._fetchManager.scheduleFetch(identifier, options);
|
|
1138
1147
|
} else {
|
|
1139
1148
|
let snapshot: Snapshot | null = null;
|
|
@@ -2310,8 +2319,8 @@ class Store extends Service {
|
|
|
2310
2319
|
|
|
2311
2320
|
const saveOptions = Object.assign({ [SaveOp]: operation }, options);
|
|
2312
2321
|
let fetchManagerPromise = this._fetchManager.scheduleSave(identifier, saveOptions);
|
|
2313
|
-
return fetchManagerPromise
|
|
2314
|
-
(payload) => {
|
|
2322
|
+
return fetchManagerPromise
|
|
2323
|
+
.then((payload) => {
|
|
2315
2324
|
if (LOG_PAYLOADS) {
|
|
2316
2325
|
try {
|
|
2317
2326
|
let data = payload ? JSON.parse(JSON.stringify(payload)) : payload;
|
|
@@ -2366,8 +2375,8 @@ class Store extends Service {
|
|
|
2366
2375
|
}
|
|
2367
2376
|
});
|
|
2368
2377
|
return record;
|
|
2369
|
-
}
|
|
2370
|
-
(e) => {
|
|
2378
|
+
})
|
|
2379
|
+
.catch((e) => {
|
|
2371
2380
|
let err = e;
|
|
2372
2381
|
if (!e) {
|
|
2373
2382
|
err = new Error(`Unknown Error Occurred During Request`);
|
|
@@ -2376,8 +2385,7 @@ class Store extends Service {
|
|
|
2376
2385
|
}
|
|
2377
2386
|
adapterDidInvalidate(this, identifier, err);
|
|
2378
2387
|
throw err;
|
|
2379
|
-
}
|
|
2380
|
-
);
|
|
2388
|
+
});
|
|
2381
2389
|
}
|
|
2382
2390
|
|
|
2383
2391
|
/**
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ember-data/store",
|
|
3
|
-
"version": "4.10.0-beta.
|
|
3
|
+
"version": "4.10.0-beta.3",
|
|
4
4
|
"description": "The core of EmberData. Provides the Store service which coordinates the cache with the network and presentation layers.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"ember-addon"
|
|
@@ -14,9 +14,9 @@
|
|
|
14
14
|
"author": "",
|
|
15
15
|
"directories": {},
|
|
16
16
|
"peerDependencies": {
|
|
17
|
-
"@ember-data/model": "4.10.0-beta.
|
|
18
|
-
"@ember-data/record-data": "4.10.0-beta.
|
|
19
|
-
"@ember-data/tracking": "4.10.0-beta.
|
|
17
|
+
"@ember-data/model": "4.10.0-beta.3",
|
|
18
|
+
"@ember-data/record-data": "4.10.0-beta.3",
|
|
19
|
+
"@ember-data/tracking": "4.10.0-beta.3",
|
|
20
20
|
"@ember/string": "^3.0.0",
|
|
21
21
|
"@glimmer/tracking": "^1.1.2"
|
|
22
22
|
},
|
|
@@ -37,8 +37,8 @@
|
|
|
37
37
|
}
|
|
38
38
|
},
|
|
39
39
|
"dependencies": {
|
|
40
|
-
"@ember-data/canary-features": "4.10.0-beta.
|
|
41
|
-
"@ember-data/private-build-infra": "4.10.0-beta.
|
|
40
|
+
"@ember-data/canary-features": "4.10.0-beta.3",
|
|
41
|
+
"@ember-data/private-build-infra": "4.10.0-beta.3",
|
|
42
42
|
"@embroider/macros": "^1.10.0",
|
|
43
43
|
"ember-auto-import": "^2.5.0",
|
|
44
44
|
"ember-cached-decorator-polyfill": "^1.0.1",
|