@warp-drive/legacy 5.8.0-alpha.4 → 5.8.0-alpha.41
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/README.md +14 -27
- package/declarations/adapter/error.d.ts +7 -7
- package/declarations/adapter/json-api.d.ts +6 -8
- package/declarations/adapter/rest.d.ts +26 -112
- package/declarations/adapter.d.ts +6 -8
- package/declarations/compat/-private.d.ts +1 -1
- package/declarations/compat/builders/find-all.d.ts +6 -6
- package/declarations/compat/builders/find-record.d.ts +8 -8
- package/declarations/compat/builders/query.d.ts +12 -12
- package/declarations/compat/extensions.d.ts +1 -1
- package/declarations/compat/legacy-network-handler/minimum-adapter-interface.d.ts +7 -9
- package/declarations/compat/legacy-network-handler/minimum-serializer-interface.d.ts +20 -30
- package/declarations/compat/utils.d.ts +17 -17
- package/declarations/compat.d.ts +35 -11
- package/declarations/index.d.ts +70 -0
- package/declarations/model/-private/attr.d.ts +5 -6
- package/declarations/model/-private/belongs-to.d.ts +4 -5
- package/declarations/model/-private/has-many.d.ts +4 -5
- package/declarations/model/-private/hooks.d.ts +1 -1
- package/declarations/model/-private/legacy-relationships-support.d.ts +2 -2
- package/declarations/model/-private/model.d.ts +18 -59
- package/declarations/model/-private/promise-many-array.d.ts +0 -18
- package/declarations/model/-private/record-state.d.ts +1 -1
- package/declarations/model/-private/references/belongs-to.d.ts +19 -29
- package/declarations/model/-private/references/has-many.d.ts +14 -16
- package/declarations/model/migration-support.d.ts +46 -21
- package/declarations/model-fragments/extensions/fragment-array.d.ts +16 -0
- package/declarations/model-fragments/extensions/fragment.d.ts +15 -0
- package/declarations/model-fragments/hooks/model-for.d.ts +20 -0
- package/declarations/model-fragments/index.d.ts +5 -0
- package/declarations/model-fragments/instance-initializers/fragment-extensions.d.ts +9 -0
- package/declarations/model-fragments/utilities/with-array-defaults.d.ts +15 -0
- package/declarations/model-fragments/utilities/with-fragment-array-defaults.d.ts +20 -0
- package/declarations/model-fragments/utilities/with-fragment-defaults.d.ts +19 -0
- package/declarations/model-fragments/utilities/with-legacy.d.ts +3 -0
- package/declarations/model-fragments.d.ts +9 -0
- package/declarations/model.d.ts +2 -2
- package/declarations/serializer/-private/embedded-records-mixin.d.ts +1 -6
- package/declarations/serializer/-private/transforms/boolean.d.ts +2 -2
- package/declarations/serializer/-private/transforms/date.d.ts +2 -2
- package/declarations/serializer/-private/transforms/number.d.ts +1 -1
- package/declarations/serializer/-private/transforms/string.d.ts +1 -1
- package/declarations/serializer/json-api.d.ts +11 -12
- package/declarations/serializer/json.d.ts +9 -11
- package/declarations/serializer/rest.d.ts +4 -6
- package/declarations/serializer.d.ts +9 -12
- package/dist/{-private-8UmnAf9J.js → -private-BG3bMiKp.js} +3 -2
- package/dist/adapter/-private.js +1 -1
- package/dist/adapter/error.js +14 -15
- package/dist/adapter/json-api.js +4 -1
- package/dist/adapter/rest.js +38 -125
- package/dist/adapter.js +6 -8
- package/dist/compat/-private.js +1 -1
- package/dist/compat/builders.js +26 -26
- package/dist/compat/utils.js +17 -18
- package/dist/compat.js +61 -43
- package/dist/{errors-8kD2mSe_.js → errors-Cz5KrzBk.js} +115 -122
- package/dist/hooks-D6diaM34.js +74 -0
- package/dist/index.js +195 -0
- package/dist/{json-DziiodPf.js → json-ChdEfB0X.js} +18 -35
- package/dist/model/-private.js +1 -1
- package/dist/model/migration-support.js +57 -25
- package/dist/model-for-CqXsIKws.js +221 -0
- package/dist/model-fragments.js +76 -0
- package/dist/model.js +18 -90
- package/dist/{schema-provider-DQu4Rjco.js → schema-provider-DJCV_6AF.js} +50 -95
- package/dist/{serialize-into-hash-CS0MIv4F.js → serialize-into-hash-DPZYoF-i.js} +1 -1
- package/dist/serializer/json-api.js +18 -45
- package/dist/serializer/json.js +1 -1
- package/dist/serializer/rest.js +14 -21
- package/dist/serializer/transform.js +15 -6
- package/dist/serializer.js +9 -13
- package/dist/store.js +5 -1
- package/dist/unpkg/dev/-private-DtjBbEgy.js +1206 -0
- package/dist/unpkg/dev/adapter/-private.js +1 -0
- package/dist/unpkg/dev/adapter/error.js +335 -0
- package/dist/unpkg/dev/adapter/json-api.js +271 -0
- package/dist/unpkg/dev/adapter/rest.js +1171 -0
- package/dist/unpkg/dev/adapter.js +1252 -0
- package/dist/unpkg/dev/compat/-private.js +1 -0
- package/dist/unpkg/dev/compat/builders.js +275 -0
- package/dist/unpkg/dev/compat/extensions.js +242 -0
- package/dist/unpkg/dev/compat/utils.js +223 -0
- package/dist/unpkg/dev/compat.js +1147 -0
- package/dist/unpkg/dev/errors-DmGGJr3T.js +2562 -0
- package/dist/unpkg/dev/hooks-CkYiE6Ud.js +73 -0
- package/dist/unpkg/dev/index.js +197 -0
- package/dist/unpkg/dev/json-Cu1LNgmQ.js +1256 -0
- package/dist/unpkg/dev/model/-private.js +1 -0
- package/dist/unpkg/dev/model/migration-support.js +553 -0
- package/dist/unpkg/dev/model-for-CqXsIKws.js +221 -0
- package/dist/unpkg/dev/model-fragments.js +76 -0
- package/dist/unpkg/dev/model.js +678 -0
- package/dist/unpkg/dev/runtime-BPCpkOf1-BKOwiRJp.js +65 -0
- package/dist/unpkg/dev/schema-provider-DDVYxmUV.js +2186 -0
- package/dist/unpkg/dev/serialize-into-hash-B2xDbuo5.js +259 -0
- package/dist/unpkg/dev/serializer/json-api.js +649 -0
- package/dist/unpkg/dev/serializer/json.js +4 -0
- package/dist/unpkg/dev/serializer/rest.js +1242 -0
- package/dist/unpkg/dev/serializer/transform.js +278 -0
- package/dist/unpkg/dev/serializer.js +248 -0
- package/dist/unpkg/dev/store.js +637 -0
- package/dist/unpkg/dev/util-DvanW33H.js +20 -0
- package/dist/unpkg/dev/utils-BhvS1iTS.js +8 -0
- package/dist/unpkg/dev-deprecated/-private-DtjBbEgy.js +1206 -0
- package/dist/unpkg/dev-deprecated/adapter/-private.js +1 -0
- package/dist/unpkg/dev-deprecated/adapter/error.js +335 -0
- package/dist/unpkg/dev-deprecated/adapter/json-api.js +271 -0
- package/dist/unpkg/dev-deprecated/adapter/rest.js +1171 -0
- package/dist/unpkg/dev-deprecated/adapter.js +1252 -0
- package/dist/unpkg/dev-deprecated/compat/-private.js +1 -0
- package/dist/unpkg/dev-deprecated/compat/builders.js +275 -0
- package/dist/unpkg/dev-deprecated/compat/extensions.js +242 -0
- package/dist/unpkg/dev-deprecated/compat/utils.js +223 -0
- package/dist/unpkg/dev-deprecated/compat.js +1147 -0
- package/dist/unpkg/dev-deprecated/errors-Spt6ubMd.js +2565 -0
- package/dist/unpkg/dev-deprecated/hooks-DOXegvhL.js +73 -0
- package/dist/unpkg/dev-deprecated/index.js +196 -0
- package/dist/unpkg/dev-deprecated/json-Cu1LNgmQ.js +1256 -0
- package/dist/unpkg/dev-deprecated/model/-private.js +1 -0
- package/dist/unpkg/dev-deprecated/model/migration-support.js +570 -0
- package/dist/unpkg/dev-deprecated/model-for-CqXsIKws.js +221 -0
- package/dist/unpkg/dev-deprecated/model-fragments.js +76 -0
- package/dist/unpkg/dev-deprecated/model.js +682 -0
- package/dist/unpkg/dev-deprecated/runtime-BPCpkOf1-BKOwiRJp.js +65 -0
- package/dist/unpkg/dev-deprecated/schema-provider-BP6_8N-V.js +2211 -0
- package/dist/unpkg/dev-deprecated/serialize-into-hash-B2xDbuo5.js +259 -0
- package/dist/unpkg/dev-deprecated/serializer/json-api.js +649 -0
- package/dist/unpkg/dev-deprecated/serializer/json.js +4 -0
- package/dist/unpkg/dev-deprecated/serializer/rest.js +1242 -0
- package/dist/unpkg/dev-deprecated/serializer/transform.js +278 -0
- package/dist/unpkg/dev-deprecated/serializer.js +248 -0
- package/dist/unpkg/dev-deprecated/store.js +637 -0
- package/dist/unpkg/dev-deprecated/util-CWr5WQOT.js +24 -0
- package/dist/unpkg/dev-deprecated/utils-C9PJehtL.js +12 -0
- package/dist/unpkg/prod/-private-BdyZaGEh.js +971 -0
- package/dist/unpkg/prod/adapter/-private.js +1 -0
- package/dist/unpkg/prod/adapter/error.js +330 -0
- package/dist/unpkg/prod/adapter/json-api.js +266 -0
- package/dist/unpkg/prod/adapter/rest.js +1134 -0
- package/dist/unpkg/prod/adapter.js +1219 -0
- package/dist/unpkg/prod/compat/-private.js +1 -0
- package/dist/unpkg/prod/compat/builders.js +210 -0
- package/dist/unpkg/prod/compat/extensions.js +232 -0
- package/dist/unpkg/prod/compat/utils.js +218 -0
- package/dist/unpkg/prod/compat.js +727 -0
- package/dist/unpkg/prod/errors-BGVFCBmi.js +2314 -0
- package/dist/unpkg/prod/hooks-BztVA_x0.js +41 -0
- package/dist/unpkg/prod/index.js +151 -0
- package/dist/unpkg/prod/json-BWrZ5546.js +1243 -0
- package/dist/unpkg/prod/model/-private.js +1 -0
- package/dist/unpkg/prod/model/migration-support.js +546 -0
- package/dist/unpkg/prod/model-for-CqXsIKws.js +221 -0
- package/dist/unpkg/prod/model-fragments.js +76 -0
- package/dist/unpkg/prod/model.js +593 -0
- package/dist/unpkg/prod/runtime-BPCpkOf1-BKOwiRJp.js +65 -0
- package/dist/unpkg/prod/schema-provider-DJtD_8jZ.js +1861 -0
- package/dist/unpkg/prod/serialize-into-hash-DGlzQteF.js +215 -0
- package/dist/unpkg/prod/serializer/json-api.js +592 -0
- package/dist/unpkg/prod/serializer/json.js +4 -0
- package/dist/unpkg/prod/serializer/rest.js +1210 -0
- package/dist/unpkg/prod/serializer/transform.js +278 -0
- package/dist/unpkg/prod/serializer.js +248 -0
- package/dist/unpkg/prod/store.js +505 -0
- package/dist/unpkg/prod/util-DvanW33H.js +20 -0
- package/dist/unpkg/prod/utils-BhvS1iTS.js +8 -0
- package/dist/unpkg/prod-deprecated/-private-BdyZaGEh.js +971 -0
- package/dist/unpkg/prod-deprecated/adapter/-private.js +1 -0
- package/dist/unpkg/prod-deprecated/adapter/error.js +330 -0
- package/dist/unpkg/prod-deprecated/adapter/json-api.js +266 -0
- package/dist/unpkg/prod-deprecated/adapter/rest.js +1134 -0
- package/dist/unpkg/prod-deprecated/adapter.js +1219 -0
- package/dist/unpkg/prod-deprecated/compat/-private.js +1 -0
- package/dist/unpkg/prod-deprecated/compat/builders.js +210 -0
- package/dist/unpkg/prod-deprecated/compat/extensions.js +232 -0
- package/dist/unpkg/prod-deprecated/compat/utils.js +218 -0
- package/dist/unpkg/prod-deprecated/compat.js +727 -0
- package/dist/unpkg/prod-deprecated/errors-CdDaK81x.js +2317 -0
- package/dist/unpkg/prod-deprecated/hooks-yId87yyG.js +41 -0
- package/dist/unpkg/prod-deprecated/index.js +150 -0
- package/dist/unpkg/prod-deprecated/json-BWrZ5546.js +1243 -0
- package/dist/unpkg/prod-deprecated/model/-private.js +1 -0
- package/dist/unpkg/prod-deprecated/model/migration-support.js +563 -0
- package/dist/unpkg/prod-deprecated/model-for-CqXsIKws.js +221 -0
- package/dist/unpkg/prod-deprecated/model-fragments.js +76 -0
- package/dist/unpkg/prod-deprecated/model.js +596 -0
- package/dist/unpkg/prod-deprecated/runtime-BPCpkOf1-BKOwiRJp.js +65 -0
- package/dist/unpkg/prod-deprecated/schema-provider-CjX55uSY.js +1904 -0
- package/dist/unpkg/prod-deprecated/serialize-into-hash-DGlzQteF.js +215 -0
- package/dist/unpkg/prod-deprecated/serializer/json-api.js +592 -0
- package/dist/unpkg/prod-deprecated/serializer/json.js +4 -0
- package/dist/unpkg/prod-deprecated/serializer/rest.js +1210 -0
- package/dist/unpkg/prod-deprecated/serializer/transform.js +278 -0
- package/dist/unpkg/prod-deprecated/serializer.js +248 -0
- package/dist/unpkg/prod-deprecated/store.js +505 -0
- package/dist/unpkg/prod-deprecated/util-B6cn-i93.js +23 -0
- package/dist/unpkg/prod-deprecated/utils-BUWwQwCh.js +11 -0
- package/logos/README.md +2 -2
- package/logos/logo-yellow-slab.svg +1 -0
- package/logos/word-mark-black.svg +1 -0
- package/logos/word-mark-white.svg +1 -0
- package/package.json +14 -6
- package/logos/NCC-1701-a-blue.svg +0 -4
- package/logos/NCC-1701-a-gold.svg +0 -4
- package/logos/NCC-1701-a-gold_100.svg +0 -1
- package/logos/NCC-1701-a-gold_base-64.txt +0 -1
- package/logos/NCC-1701-a.svg +0 -4
- package/logos/docs-badge.svg +0 -2
- package/logos/ember-data-logo-dark.svg +0 -12
- package/logos/ember-data-logo-light.svg +0 -12
- package/logos/social1.png +0 -0
- package/logos/social2.png +0 -0
- package/logos/warp-drive-logo-dark.svg +0 -4
- package/logos/warp-drive-logo-gold.svg +0 -4
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import { setOwner, getOwner } from '@ember/application';
|
|
2
|
+
import { assertPrivateStore, setRecordIdentifier, StoreMap } from '@warp-drive/core/store/-private';
|
|
3
|
+
import { g as getModelFactory } from "./schema-provider-BP6_8N-V.js";
|
|
4
|
+
import { n as normalizeModelName } from "./util-CWr5WQOT.js";
|
|
5
|
+
function instantiateRecord(identifier, createRecordArgs) {
|
|
6
|
+
const type = identifier.type;
|
|
7
|
+
|
|
8
|
+
// TODO deprecate allowing unknown args setting
|
|
9
|
+
const createOptions = {
|
|
10
|
+
_createProps: createRecordArgs ?? {},
|
|
11
|
+
// TODO @deprecate consider deprecating accessing record properties during init which the below is necessary for
|
|
12
|
+
_secretInit: {
|
|
13
|
+
identifier,
|
|
14
|
+
store: this,
|
|
15
|
+
cb: secretInit
|
|
16
|
+
}
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
// ensure that `getOwner(this)` works inside a model instance
|
|
20
|
+
setOwner(createOptions, getOwner(this));
|
|
21
|
+
const factory = getModelFactory(this, type);
|
|
22
|
+
(test => {
|
|
23
|
+
if (!test) {
|
|
24
|
+
throw new Error(`No model was found for '${type}'`);
|
|
25
|
+
}
|
|
26
|
+
})(factory);
|
|
27
|
+
return factory.class.create(createOptions);
|
|
28
|
+
}
|
|
29
|
+
function teardownRecord(record) {
|
|
30
|
+
(test => {
|
|
31
|
+
if (!test) {
|
|
32
|
+
throw new Error(`expected to receive an instance of Model from @ember-data/model. If using a custom model make sure you implement teardownRecord`);
|
|
33
|
+
}
|
|
34
|
+
})('destroy' in record);
|
|
35
|
+
record.destroy();
|
|
36
|
+
}
|
|
37
|
+
function modelFor(modelName) {
|
|
38
|
+
assertPrivateStore(this);
|
|
39
|
+
(test => {
|
|
40
|
+
if (!test) {
|
|
41
|
+
throw new Error(`Attempted to call store.modelFor(), but the store instance has already been destroyed.`);
|
|
42
|
+
}
|
|
43
|
+
})(!this.isDestroyed && !this.isDestroying);
|
|
44
|
+
(test => {
|
|
45
|
+
if (!test) {
|
|
46
|
+
throw new Error(`You need to pass a model name to the store's modelFor method`);
|
|
47
|
+
}
|
|
48
|
+
})(modelName);
|
|
49
|
+
(test => {
|
|
50
|
+
if (!test) {
|
|
51
|
+
throw new Error(`Please pass a proper model name to the store's modelFor method`);
|
|
52
|
+
}
|
|
53
|
+
})(typeof modelName === 'string' && modelName.length);
|
|
54
|
+
const type = normalizeModelName(modelName);
|
|
55
|
+
const maybeFactory = getModelFactory(this, type);
|
|
56
|
+
const klass = maybeFactory && maybeFactory.class ? maybeFactory.class : null;
|
|
57
|
+
const ignoreType = !klass || !klass.isModel || this._forceShim;
|
|
58
|
+
if (!ignoreType) {
|
|
59
|
+
return klass;
|
|
60
|
+
}
|
|
61
|
+
(test => {
|
|
62
|
+
if (!test) {
|
|
63
|
+
throw new Error(`No model was found for '${type}' and no schema handles the type`);
|
|
64
|
+
}
|
|
65
|
+
})(this.schema.hasResource({
|
|
66
|
+
type
|
|
67
|
+
}));
|
|
68
|
+
}
|
|
69
|
+
function secretInit(record, identifier, store) {
|
|
70
|
+
setRecordIdentifier(record, identifier);
|
|
71
|
+
StoreMap.set(record, store);
|
|
72
|
+
}
|
|
73
|
+
export { instantiateRecord as i, modelFor as m, teardownRecord as t };
|
|
@@ -0,0 +1,196 @@
|
|
|
1
|
+
import { Store, RequestManager, Fetch, CacheHandler, recordIdentifierFor } from '@warp-drive/core';
|
|
2
|
+
import { SchemaService, registerDerivations, instantiateRecord as instantiateRecord$1, teardownRecord as teardownRecord$1 } from '@warp-drive/core/reactive';
|
|
3
|
+
import { DefaultCachePolicy } from '@warp-drive/core/store';
|
|
4
|
+
import { LegacyNetworkHandler, adapterFor, serializerFor, pushPayload, normalize, serializeRecord, cleanup } from './compat.js';
|
|
5
|
+
import { EmberArrayLikeExtension, EmberObjectArrayExtension, EmberObjectExtension } from './compat/extensions.js';
|
|
6
|
+
import '@ember/object';
|
|
7
|
+
import '@warp-drive/core/types/symbols';
|
|
8
|
+
import '@warp-drive/utilities/string';
|
|
9
|
+
import '@warp-drive/core/store/-private';
|
|
10
|
+
import "./errors-Spt6ubMd.js";
|
|
11
|
+
import "./schema-provider-BP6_8N-V.js";
|
|
12
|
+
import { i as instantiateRecord, t as teardownRecord, m as modelFor } from "./hooks-DOXegvhL.js";
|
|
13
|
+
import { registerDerivations as registerDerivations$1, DelegatingSchemaService } from './model/migration-support.js';
|
|
14
|
+
import { F as FragmentExtension, a as FragmentArrayExtension, f as fragmentsModelFor } from "./model-for-CqXsIKws.js";
|
|
15
|
+
import { restoreDeprecatedStoreBehaviors } from './store.js';
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* @module
|
|
19
|
+
* @mergeModuleWith <project>
|
|
20
|
+
*/
|
|
21
|
+
|
|
22
|
+
//export type ConfiguredStore<T = unknown> = typeof Store;
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* Use the legacy store with the given options.
|
|
26
|
+
*/
|
|
27
|
+
|
|
28
|
+
function useLegacyStore(options, StoreKlass = Store) {
|
|
29
|
+
(test => {
|
|
30
|
+
if (!test) {
|
|
31
|
+
throw new Error(`If legacyRequests is true, linksMode must be false`);
|
|
32
|
+
}
|
|
33
|
+
})(!(options.linksMode && options.legacyRequests));
|
|
34
|
+
// we extend the store to ensure we don't leak our prototype overrides to other stores below.
|
|
35
|
+
class BaseKlass extends StoreKlass {}
|
|
36
|
+
class LegacyConfiguredStore extends BaseKlass {
|
|
37
|
+
requestManager = new RequestManager().use([options.linksMode ? null : LegacyNetworkHandler, ...(options.handlers ?? []), Fetch].filter(Boolean)).useCache(CacheHandler);
|
|
38
|
+
lifetimes = options.policy ?? new DefaultCachePolicy({
|
|
39
|
+
apiCacheHardExpires: 15 * 60 * 1000,
|
|
40
|
+
// 15 minutes
|
|
41
|
+
apiCacheSoftExpires: 1 * 30 * 1000,
|
|
42
|
+
// 30 seconds
|
|
43
|
+
constraints: {
|
|
44
|
+
headers: {
|
|
45
|
+
'X-WarpDrive-Expires': true,
|
|
46
|
+
'Cache-Control': true,
|
|
47
|
+
Expires: true
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
});
|
|
51
|
+
createSchemaService() {
|
|
52
|
+
// prepare for PolarisMode
|
|
53
|
+
const schema = new SchemaService();
|
|
54
|
+
registerDerivations(schema);
|
|
55
|
+
if (options.schemas) schema.registerResources(options.schemas);
|
|
56
|
+
if (options.traits) {
|
|
57
|
+
for (const trait of options.traits) {
|
|
58
|
+
schema.registerTrait(trait);
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
if (options.derivations) {
|
|
62
|
+
for (const derivation of options.derivations) {
|
|
63
|
+
schema.registerDerivation(derivation);
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
if (options.transformations) {
|
|
67
|
+
for (const transformation of options.transformations) {
|
|
68
|
+
schema.registerTransformation(transformation);
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
if (options.hashFns) {
|
|
72
|
+
for (const hashFn of options.hashFns) {
|
|
73
|
+
schema.registerHashFn(hashFn);
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
if (options.CAUTION_MEGA_DANGER_ZONE_extensions) {
|
|
77
|
+
for (const extension of options.CAUTION_MEGA_DANGER_ZONE_extensions) {
|
|
78
|
+
schema.CAUTION_MEGA_DANGER_ZONE_registerExtension(extension);
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
// Add support for LegacyMode ReactiveResource with Maximal coverage
|
|
83
|
+
// for upgrading from 4.x
|
|
84
|
+
registerDerivations$1(schema);
|
|
85
|
+
schema.CAUTION_MEGA_DANGER_ZONE_registerExtension(EmberArrayLikeExtension);
|
|
86
|
+
schema.CAUTION_MEGA_DANGER_ZONE_registerExtension(EmberObjectArrayExtension);
|
|
87
|
+
schema.CAUTION_MEGA_DANGER_ZONE_registerExtension(EmberObjectExtension);
|
|
88
|
+
|
|
89
|
+
// add support for fragments
|
|
90
|
+
if (options.modelFragments) {
|
|
91
|
+
schema.CAUTION_MEGA_DANGER_ZONE_registerExtension?.(FragmentExtension);
|
|
92
|
+
schema.CAUTION_MEGA_DANGER_ZONE_registerExtension?.(FragmentArrayExtension);
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
// Add fallback for Models
|
|
96
|
+
return new DelegatingSchemaService(this, schema);
|
|
97
|
+
}
|
|
98
|
+
createCache(capabilities) {
|
|
99
|
+
// eslint-disable-next-line new-cap
|
|
100
|
+
return new options.cache(capabilities);
|
|
101
|
+
}
|
|
102
|
+
instantiateRecord(key, createArgs) {
|
|
103
|
+
if (this.schema.isDelegated(key)) {
|
|
104
|
+
return instantiateRecord.call(this, key, createArgs);
|
|
105
|
+
}
|
|
106
|
+
return instantiateRecord$1(this, key, createArgs);
|
|
107
|
+
}
|
|
108
|
+
teardownRecord(record) {
|
|
109
|
+
const key = recordIdentifierFor(record);
|
|
110
|
+
if (this.schema.isDelegated(key)) {
|
|
111
|
+
return teardownRecord.call(this, record);
|
|
112
|
+
}
|
|
113
|
+
return teardownRecord$1(record);
|
|
114
|
+
}
|
|
115
|
+
modelFor(type) {
|
|
116
|
+
assertType(this.schema, type);
|
|
117
|
+
// TODO I'm not sure this is right
|
|
118
|
+
(test => {
|
|
119
|
+
if (!test) {
|
|
120
|
+
throw new Error(`modelFor should only be used to lookup legacy models when in linksMode: false`);
|
|
121
|
+
}
|
|
122
|
+
})(!options.linksMode || !this.schema.isDelegated({
|
|
123
|
+
type
|
|
124
|
+
}));
|
|
125
|
+
const klass =
|
|
126
|
+
// prefer real models if present
|
|
127
|
+
modelFor.call(this, type) || (
|
|
128
|
+
// fallback to ShimModelClass specific to fragments if fragments support in use
|
|
129
|
+
options.modelFragments ? fragmentsModelFor.call(this, type) : false) ||
|
|
130
|
+
// fallback to ShimModelClass
|
|
131
|
+
super.modelFor(type);
|
|
132
|
+
return klass;
|
|
133
|
+
}
|
|
134
|
+
adapterFor(modelName, _allowMissing) {
|
|
135
|
+
(test => {
|
|
136
|
+
if (!test) {
|
|
137
|
+
throw new Error(`useLegacyStore was setup in linksMode. linksMode assumes that all requests have been migrated away from adapters and serializers.`);
|
|
138
|
+
}
|
|
139
|
+
})(!options.linksMode);
|
|
140
|
+
// @ts-expect-error
|
|
141
|
+
return adapterFor.call(this, modelName, _allowMissing);
|
|
142
|
+
}
|
|
143
|
+
serializerFor(...args) {
|
|
144
|
+
(test => {
|
|
145
|
+
if (!test) {
|
|
146
|
+
throw new Error(`useLegacyStore was setup in linksMode. linksMode assumes that all requests have been migrated away from adapters and serializers.`);
|
|
147
|
+
}
|
|
148
|
+
})(!options.linksMode);
|
|
149
|
+
return serializerFor.call(this, ...args);
|
|
150
|
+
}
|
|
151
|
+
pushPayload(...args) {
|
|
152
|
+
(test => {
|
|
153
|
+
if (!test) {
|
|
154
|
+
throw new Error(`useLegacyStore was setup in linksMode. linksMode assumes that all requests have been migrated away from adapters and serializers.`);
|
|
155
|
+
}
|
|
156
|
+
})(!options.linksMode);
|
|
157
|
+
return pushPayload.call(this, ...args);
|
|
158
|
+
}
|
|
159
|
+
normalize(...args) {
|
|
160
|
+
(test => {
|
|
161
|
+
if (!test) {
|
|
162
|
+
throw new Error(`useLegacyStore was setup in linksMode. linksMode assumes that all requests have been migrated away from adapters and serializers.`);
|
|
163
|
+
}
|
|
164
|
+
})(!options.linksMode);
|
|
165
|
+
return normalize.call(this, ...args);
|
|
166
|
+
}
|
|
167
|
+
serializeRecord(...args) {
|
|
168
|
+
(test => {
|
|
169
|
+
if (!test) {
|
|
170
|
+
throw new Error(`useLegacyStore was setup in linksMode. linksMode assumes that all requests have been migrated away from adapters and serializers.`);
|
|
171
|
+
}
|
|
172
|
+
})(!options.linksMode);
|
|
173
|
+
return serializeRecord.call(this, ...args);
|
|
174
|
+
}
|
|
175
|
+
destroy() {
|
|
176
|
+
if (!options.linksMode) {
|
|
177
|
+
cleanup.call(this);
|
|
178
|
+
}
|
|
179
|
+
super.destroy();
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
if (options.legacyRequests) {
|
|
183
|
+
restoreDeprecatedStoreBehaviors(BaseKlass);
|
|
184
|
+
}
|
|
185
|
+
return LegacyConfiguredStore;
|
|
186
|
+
}
|
|
187
|
+
function assertType(schema, type) {
|
|
188
|
+
(test => {
|
|
189
|
+
if (!test) {
|
|
190
|
+
throw new Error(`Expected type ${type} to be a valid ResourceType`);
|
|
191
|
+
}
|
|
192
|
+
})(schema.hasResource({
|
|
193
|
+
type
|
|
194
|
+
}));
|
|
195
|
+
}
|
|
196
|
+
export { useLegacyStore };
|