@warp-drive/legacy 5.8.0-alpha.4 → 5.8.0-alpha.40
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 +5 -5
- package/declarations/adapter/json-api.d.ts +6 -8
- package/declarations/adapter/rest.d.ts +5 -8
- package/declarations/adapter.d.ts +4 -6
- 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 +8 -8
- package/declarations/model/-private/record-state.d.ts +1 -1
- package/declarations/model/-private/references/belongs-to.d.ts +5 -5
- package/declarations/model/-private/references/has-many.d.ts +3 -3
- 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 +7 -9
- package/declarations/serializer/json.d.ts +7 -9
- package/declarations/serializer/rest.d.ts +4 -6
- package/declarations/serializer.d.ts +9 -12
- package/dist/{-private-8UmnAf9J.js → -private-B1pSSN52.js} +1 -1
- package/dist/adapter/-private.js +1 -1
- package/dist/adapter/error.js +12 -13
- package/dist/adapter/json-api.js +4 -1
- package/dist/adapter/rest.js +6 -9
- package/dist/adapter.js +4 -6
- 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 +58 -41
- package/dist/{errors-8kD2mSe_.js → errors-CIGPcDvd.js} +87 -65
- package/dist/hooks-QqRnX108.js +74 -0
- package/dist/index.js +195 -0
- package/dist/{json-DziiodPf.js → json-BNrV8EYG.js} +12 -16
- package/dist/model/-private.js +1 -1
- package/dist/model/migration-support.js +54 -24
- 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-g5MfTj8n.js} +18 -20
- package/dist/{serialize-into-hash-CS0MIv4F.js → serialize-into-hash-BnYvPex3.js} +1 -1
- package/dist/serializer/json-api.js +17 -44
- 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 +3 -0
- package/dist/unpkg/dev/-private-DbaSCSym.js +1205 -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 +1255 -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 +1146 -0
- package/dist/unpkg/dev/errors-DD96TBEs.js +2591 -0
- package/dist/unpkg/dev/hooks-CqWjNWeL.js +73 -0
- package/dist/unpkg/dev/index.js +197 -0
- package/dist/unpkg/dev/json-CCU-ZQ4b.js +1269 -0
- package/dist/unpkg/dev/model/-private.js +1 -0
- package/dist/unpkg/dev/model/migration-support.js +551 -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-B8jiJOYC.js +2229 -0
- package/dist/unpkg/dev/serialize-into-hash-CPAZXrQU.js +259 -0
- package/dist/unpkg/dev/serializer/json-api.js +648 -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 +636 -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-DbaSCSym.js +1205 -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 +1255 -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 +1146 -0
- package/dist/unpkg/dev-deprecated/errors-DEnabIZj.js +2594 -0
- package/dist/unpkg/dev-deprecated/hooks-CAll-Ets.js +73 -0
- package/dist/unpkg/dev-deprecated/index.js +196 -0
- package/dist/unpkg/dev-deprecated/json-CCU-ZQ4b.js +1269 -0
- package/dist/unpkg/dev-deprecated/model/-private.js +1 -0
- package/dist/unpkg/dev-deprecated/model/migration-support.js +568 -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-k2qXQTBg.js +2254 -0
- package/dist/unpkg/dev-deprecated/serialize-into-hash-CPAZXrQU.js +259 -0
- package/dist/unpkg/dev-deprecated/serializer/json-api.js +648 -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 +636 -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-Cvf_97EG.js +970 -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 +1218 -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 +726 -0
- package/dist/unpkg/prod/errors-CXnfnBfQ.js +2343 -0
- package/dist/unpkg/prod/hooks-DvyWhLNg.js +41 -0
- package/dist/unpkg/prod/index.js +151 -0
- package/dist/unpkg/prod/json-BYrUP8ao.js +1256 -0
- package/dist/unpkg/prod/model/-private.js +1 -0
- package/dist/unpkg/prod/model/migration-support.js +544 -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-CHujJvA9.js +1904 -0
- package/dist/unpkg/prod/serialize-into-hash-DYU2egXl.js +215 -0
- package/dist/unpkg/prod/serializer/json-api.js +591 -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 +504 -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-Cvf_97EG.js +970 -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 +1218 -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 +726 -0
- package/dist/unpkg/prod-deprecated/errors-CG1SPYVg.js +2346 -0
- package/dist/unpkg/prod-deprecated/hooks-BIUBiNGR.js +41 -0
- package/dist/unpkg/prod-deprecated/index.js +150 -0
- package/dist/unpkg/prod-deprecated/json-BYrUP8ao.js +1256 -0
- package/dist/unpkg/prod-deprecated/model/-private.js +1 -0
- package/dist/unpkg/prod-deprecated/model/migration-support.js +561 -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-BJ4TWnZf.js +1947 -0
- package/dist/unpkg/prod-deprecated/serialize-into-hash-DYU2egXl.js +215 -0
- package/dist/unpkg/prod-deprecated/serializer/json-api.js +591 -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 +504 -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
package/declarations/compat.d.ts
CHANGED
|
@@ -6,7 +6,18 @@ import type { AdapterPayload, MinimumAdapterInterface } from "./compat/legacy-ne
|
|
|
6
6
|
import type { MinimumSerializerInterface, SerializerOptions } from "./compat/legacy-network-handler/minimum-serializer-interface.js";
|
|
7
7
|
export { LegacyNetworkHandler } from "./compat/legacy-network-handler/legacy-network-handler.js";
|
|
8
8
|
export type { MinimumAdapterInterface, MinimumSerializerInterface, SerializerOptions, AdapterPayload };
|
|
9
|
+
/**
|
|
10
|
+
* Extends the signature of {@link Store} with additional
|
|
11
|
+
* methods available when using the legacy network layer.
|
|
12
|
+
*
|
|
13
|
+
* @public
|
|
14
|
+
* @noInheritDoc
|
|
15
|
+
* @legacy
|
|
16
|
+
*/
|
|
9
17
|
export interface LegacyStoreCompat extends Store {
|
|
18
|
+
/**
|
|
19
|
+
* @private
|
|
20
|
+
*/
|
|
10
21
|
_fetchManager: FetchManager;
|
|
11
22
|
adapterFor(this: Store, modelName: string): MinimumAdapterInterface;
|
|
12
23
|
adapterFor(this: Store, modelName: string, _allowMissing: true): MinimumAdapterInterface | undefined;
|
|
@@ -14,13 +25,22 @@ export interface LegacyStoreCompat extends Store {
|
|
|
14
25
|
normalize(modelName: string, payload: ObjectValue): ObjectValue;
|
|
15
26
|
pushPayload(modelName: string, payload: ObjectValue): void;
|
|
16
27
|
serializeRecord(record: unknown, options?: SerializerOptions): unknown;
|
|
28
|
+
/**
|
|
29
|
+
* @private
|
|
30
|
+
*/
|
|
17
31
|
_adapterCache: Record<string, MinimumAdapterInterface & {
|
|
18
32
|
store: Store;
|
|
19
33
|
}>;
|
|
34
|
+
/**
|
|
35
|
+
* @private
|
|
36
|
+
*/
|
|
20
37
|
_serializerCache: Record<string, MinimumSerializerInterface & {
|
|
21
38
|
store: Store;
|
|
22
39
|
}>;
|
|
23
40
|
}
|
|
41
|
+
/**
|
|
42
|
+
* @deprecated - use {@link LegacyStoreCompat} instead
|
|
43
|
+
*/
|
|
24
44
|
export type CompatStore = LegacyStoreCompat;
|
|
25
45
|
/**
|
|
26
46
|
Returns an instance of the adapter for a given type. For
|
|
@@ -32,8 +52,7 @@ for an `application` adapter (the default adapter for
|
|
|
32
52
|
your entire application).
|
|
33
53
|
|
|
34
54
|
@public
|
|
35
|
-
@param
|
|
36
|
-
@return {Adapter}
|
|
55
|
+
@param modelName
|
|
37
56
|
*/
|
|
38
57
|
export declare function adapterFor(this: Store, modelName: string): MinimumAdapterInterface;
|
|
39
58
|
export declare function adapterFor(this: Store, modelName: string, _allowMissing: true): MinimumAdapterInterface | undefined;
|
|
@@ -50,13 +69,17 @@ If a serializer cannot be found on the adapter, it will fall back
|
|
|
50
69
|
to an instance of `JSONSerializer`.
|
|
51
70
|
|
|
52
71
|
@public
|
|
53
|
-
@param
|
|
54
|
-
@return {Serializer}
|
|
72
|
+
@param modelName the record to serialize
|
|
55
73
|
*/
|
|
56
74
|
export declare function serializerFor(this: Store, modelName: string): MinimumSerializerInterface | null;
|
|
57
75
|
/**
|
|
58
|
-
`normalize` converts a json payload into the normalized form
|
|
59
|
-
|
|
76
|
+
`normalize` converts a json payload into the normalized form expected by
|
|
77
|
+
{@link Store.push | push} using the serializer specified by `modelName`
|
|
78
|
+
|
|
79
|
+
:::warning
|
|
80
|
+
Generally it would be better to invoke the serializer yourself directly,
|
|
81
|
+
or write a more specialized normalization utility.
|
|
82
|
+
:::
|
|
60
83
|
|
|
61
84
|
Example
|
|
62
85
|
|
|
@@ -68,6 +91,7 @@ store.push(store.normalize(modelName, data));
|
|
|
68
91
|
});
|
|
69
92
|
```
|
|
70
93
|
|
|
94
|
+
@legacy
|
|
71
95
|
@public
|
|
72
96
|
@param modelName The name of the model type for this payload
|
|
73
97
|
@return The normalized payload
|
|
@@ -83,7 +107,7 @@ All objects should be in the format expected by the
|
|
|
83
107
|
serializer.
|
|
84
108
|
|
|
85
109
|
```js [app/serializers/application.js]
|
|
86
|
-
import RESTSerializer from '@
|
|
110
|
+
import RESTSerializer from '@warp-drive/legacy/serializer/rest';
|
|
87
111
|
|
|
88
112
|
export default class ApplicationSerializer extends RESTSerializer;
|
|
89
113
|
```
|
|
@@ -108,13 +132,13 @@ Alternatively, `pushPayload` will accept a model type which
|
|
|
108
132
|
will determine which serializer will process the payload.
|
|
109
133
|
|
|
110
134
|
```js [app/serializers/application.js]
|
|
111
|
-
import RESTSerializer from '@
|
|
135
|
+
import RESTSerializer from '@warp-drive/legacy/serializer/rest';
|
|
112
136
|
|
|
113
137
|
export default class ApplicationSerializer extends RESTSerializer;
|
|
114
138
|
```
|
|
115
139
|
|
|
116
140
|
```js [app/serializers/post.js]
|
|
117
|
-
import JSONSerializer from '@
|
|
141
|
+
import JSONSerializer from '@warp-drive/legacy/serializer/json';
|
|
118
142
|
|
|
119
143
|
export default JSONSerializer;
|
|
120
144
|
```
|
|
@@ -125,8 +149,8 @@ store.pushPayload('post', pushData); // Will use the post serializer
|
|
|
125
149
|
```
|
|
126
150
|
|
|
127
151
|
@public
|
|
128
|
-
@param
|
|
129
|
-
@param
|
|
152
|
+
@param modelName Optionally, a model type used to determine which serializer will be used
|
|
153
|
+
@param inputPayload
|
|
130
154
|
*/
|
|
131
155
|
export declare function pushPayload(this: Store, modelName: string, inputPayload: ObjectValue): void;
|
|
132
156
|
export declare function serializeRecord(this: Store, record: unknown, options?: SerializerOptions): unknown;
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module
|
|
3
|
+
* @mergeModuleWith <project>
|
|
4
|
+
*/
|
|
5
|
+
import { Store, type StoreSetupOptions } from "@warp-drive/core";
|
|
6
|
+
import type { CacheCapabilitiesManager } from "@warp-drive/core/types";
|
|
7
|
+
import type { Cache } from "@warp-drive/core/types/cache";
|
|
8
|
+
import type { ObjectSchema, ResourceSchema } from "@warp-drive/core/types/schema/fields";
|
|
9
|
+
interface _LegacyStoreSetupOptions<T extends Cache> extends Omit<StoreSetupOptions<T>, "schemas"> {
|
|
10
|
+
schemas?: Array<ResourceSchema | ObjectSchema>;
|
|
11
|
+
/**
|
|
12
|
+
* Whether to include support for ModelFragments migrations.
|
|
13
|
+
*/
|
|
14
|
+
modelFragments?: boolean;
|
|
15
|
+
}
|
|
16
|
+
export interface LegacyModelStoreSetupOptions<T extends Cache> extends _LegacyStoreSetupOptions<T> {
|
|
17
|
+
/**
|
|
18
|
+
* If true, it is presumed that no requests require use of the LegacyNetworkHandler
|
|
19
|
+
* and associated adapters/serializer methods.
|
|
20
|
+
*/
|
|
21
|
+
linksMode: true;
|
|
22
|
+
/**
|
|
23
|
+
* if true, all legacy request methods and supporting infrastructure will
|
|
24
|
+
* be available on the store.
|
|
25
|
+
*/
|
|
26
|
+
legacyRequests?: false;
|
|
27
|
+
}
|
|
28
|
+
export interface LegacyModelAndNetworkStoreSetupOptions<T extends Cache> extends _LegacyStoreSetupOptions<T> {
|
|
29
|
+
/**
|
|
30
|
+
* If true, it is presumed that no requests require use of the LegacyNetworkHandler
|
|
31
|
+
* and associated adapters/serializer methods.
|
|
32
|
+
*/
|
|
33
|
+
linksMode: false;
|
|
34
|
+
/**
|
|
35
|
+
* if true, all legacy request methods and supporting infrastructure will
|
|
36
|
+
* be available on the store.
|
|
37
|
+
*/
|
|
38
|
+
legacyRequests?: false;
|
|
39
|
+
}
|
|
40
|
+
export interface LegacyModelAndNetworkAndRequestStoreSetupOptions<T extends Cache> extends _LegacyStoreSetupOptions<T> {
|
|
41
|
+
/**
|
|
42
|
+
* If true, it is presumed that no requests require use of the LegacyNetworkHandler
|
|
43
|
+
* and associated adapters/serializer methods.
|
|
44
|
+
*/
|
|
45
|
+
linksMode: false;
|
|
46
|
+
/**
|
|
47
|
+
* if true, all legacy request methods and supporting infrastructure will
|
|
48
|
+
* be available on the store.
|
|
49
|
+
*/
|
|
50
|
+
legacyRequests: true;
|
|
51
|
+
}
|
|
52
|
+
export type LegacyStoreSetupOptions<T extends Cache = Cache> = LegacyModelStoreSetupOptions<T> | LegacyModelAndNetworkStoreSetupOptions<T> | LegacyModelAndNetworkAndRequestStoreSetupOptions<T>;
|
|
53
|
+
export declare class ConfiguredStore<T extends {
|
|
54
|
+
cache: Cache;
|
|
55
|
+
}> extends Store {
|
|
56
|
+
createCache(capabilities: CacheCapabilitiesManager): T["cache"];
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* Use the legacy store with the given options.
|
|
60
|
+
*/
|
|
61
|
+
export declare function useLegacyStore<T extends Cache>(options: LegacyModelStoreSetupOptions<T>, StoreKlass?: typeof Store): typeof ConfiguredStore<{
|
|
62
|
+
cache: T;
|
|
63
|
+
}>;
|
|
64
|
+
export declare function useLegacyStore<T extends Cache>(options: LegacyModelAndNetworkStoreSetupOptions<T>, StoreKlass?: typeof Store): typeof ConfiguredStore<{
|
|
65
|
+
cache: T;
|
|
66
|
+
}>;
|
|
67
|
+
export declare function useLegacyStore<T extends Cache>(options: LegacyModelAndNetworkAndRequestStoreSetupOptions<T>, StoreKlass?: typeof Store): typeof ConfiguredStore<{
|
|
68
|
+
cache: T;
|
|
69
|
+
}>;
|
|
70
|
+
export {};
|
|
@@ -75,12 +75,12 @@ export type OptionsFromInstance<T> = TypeFromInstance<T> extends never ? never :
|
|
|
75
75
|
*/
|
|
76
76
|
export type DataDecorator = (target: object, key: string, desc?: DecoratorPropertyDescriptor) => void;
|
|
77
77
|
/**
|
|
78
|
-
`attr` defines an attribute on a
|
|
78
|
+
`attr` defines an attribute on a {@link Model}.
|
|
79
79
|
By default, attributes are passed through as-is, however you can specify an
|
|
80
80
|
optional type to have the value automatically transformed.
|
|
81
|
-
|
|
81
|
+
WarpDrive ships with four basic transform types: `string`, `number`,
|
|
82
82
|
`boolean` and `date`. You can define your own transforms by subclassing
|
|
83
|
-
|
|
83
|
+
{@link Transform}.
|
|
84
84
|
|
|
85
85
|
Note that you cannot use `attr` to define an attribute of `id`.
|
|
86
86
|
|
|
@@ -157,9 +157,8 @@ return new this();
|
|
|
157
157
|
```
|
|
158
158
|
|
|
159
159
|
@public
|
|
160
|
-
@param
|
|
161
|
-
@param
|
|
162
|
-
@return {Attribute}
|
|
160
|
+
@param type the attribute type
|
|
161
|
+
@param options a hash of options
|
|
163
162
|
*/
|
|
164
163
|
export declare function attr(): DataDecorator;
|
|
165
164
|
export declare function attr<T>(type: TypeFromInstance<T>): DataDecorator;
|
|
@@ -15,7 +15,7 @@ export type NoNull<T> = Exclude<T, null>;
|
|
|
15
15
|
export type RelationshipDecorator<T> = <This>(target: This, key: string, desc?: PropertyDescriptor) => void;
|
|
16
16
|
/**
|
|
17
17
|
`belongsTo` is used to define One-To-One and One-To-Many, and One-To-None
|
|
18
|
-
relationships on a
|
|
18
|
+
relationships on a {@link Model}.
|
|
19
19
|
|
|
20
20
|
`belongsTo` takes a configuration hash as a second parameter, currently
|
|
21
21
|
supported options are:
|
|
@@ -97,7 +97,7 @@ export default class Person extends Model {
|
|
|
97
97
|
|
|
98
98
|
#### Sync vs Async Relationships
|
|
99
99
|
|
|
100
|
-
|
|
100
|
+
WarpDrive fulfills relationships using resource data available in
|
|
101
101
|
the cache.
|
|
102
102
|
|
|
103
103
|
Sync relationships point directly to the known related resources.
|
|
@@ -165,9 +165,8 @@ must be declared as polymorphic, and the `as` option must be used to declare the
|
|
|
165
165
|
type each record satisfies on both sides.
|
|
166
166
|
|
|
167
167
|
@public
|
|
168
|
-
@param
|
|
169
|
-
@param
|
|
170
|
-
@return {PropertyDescriptor} relationship
|
|
168
|
+
@param type the name of the related resource
|
|
169
|
+
@param options a hash of options
|
|
171
170
|
*/
|
|
172
171
|
export declare function belongsTo(): never;
|
|
173
172
|
export declare function belongsTo(type: string): never;
|
|
@@ -2,7 +2,7 @@ import type { TypeFromInstance } from "@warp-drive/core/types/record";
|
|
|
2
2
|
import type { NoNull, RelationshipDecorator, RelationshipOptions } from "./belongs-to.js";
|
|
3
3
|
/**
|
|
4
4
|
`hasMany` is used to define Many-To-One and Many-To-Many, and Many-To-None
|
|
5
|
-
relationships on a
|
|
5
|
+
relationships on a {@link Model}.
|
|
6
6
|
|
|
7
7
|
`hasMany` takes a configuration hash as a second parameter, currently
|
|
8
8
|
supported options are:
|
|
@@ -85,7 +85,7 @@ export default class Post extends Model {
|
|
|
85
85
|
|
|
86
86
|
#### Sync vs Async Relationships
|
|
87
87
|
|
|
88
|
-
|
|
88
|
+
WarpDrive fulfills relationships using resource data available in
|
|
89
89
|
the cache.
|
|
90
90
|
|
|
91
91
|
Sync relationships point directly to the known related resources.
|
|
@@ -153,9 +153,8 @@ must be declared as polymorphic, and the `as` option must be used to declare the
|
|
|
153
153
|
type each record satisfies on both sides.
|
|
154
154
|
|
|
155
155
|
@public
|
|
156
|
-
@param
|
|
157
|
-
@param
|
|
158
|
-
@return {PropertyDescriptor} relationship
|
|
156
|
+
@param type the name of the related resource
|
|
157
|
+
@param options a hash of options
|
|
159
158
|
*/
|
|
160
159
|
export declare function hasMany(): never;
|
|
161
160
|
export declare function hasMany(type: string): never;
|
|
@@ -2,7 +2,7 @@ import { type Store } from "@warp-drive/core/store/-private";
|
|
|
2
2
|
import type { ResourceKey } from "@warp-drive/core/types/identifier";
|
|
3
3
|
import type { TypeFromInstance } from "@warp-drive/core/types/record";
|
|
4
4
|
import type { Model } from "./model.js";
|
|
5
|
-
export declare function instantiateRecord(this: Store, identifier: ResourceKey, createRecordArgs
|
|
5
|
+
export declare function instantiateRecord(this: Store, identifier: ResourceKey, createRecordArgs?: {
|
|
6
6
|
[key: string]: unknown;
|
|
7
7
|
}): Model;
|
|
8
8
|
export declare function teardownRecord(record: Model): void;
|
|
@@ -38,8 +38,8 @@ export declare class LegacySupport {
|
|
|
38
38
|
_updatePromiseProxyFor(kind: "belongsTo", key: string, args: {
|
|
39
39
|
promise: Promise<OpaqueRecordInstance | null>;
|
|
40
40
|
}): PromiseBelongsTo;
|
|
41
|
-
referenceFor(kind: "belongsTo",
|
|
42
|
-
referenceFor(kind: "hasMany",
|
|
41
|
+
referenceFor(kind: "belongsTo", key: string): BelongsToReference;
|
|
42
|
+
referenceFor(kind: "hasMany", key: string): HasManyReference;
|
|
43
43
|
_findHasManyByJsonApiResource(resource: CollectionResourceRelationship, parentIdentifier: ResourceKey, relationship: CollectionEdge, options?: BaseFinderOptions): Promise<void | unknown[]> | void;
|
|
44
44
|
_findBelongsToByJsonApiResource(resource: SingleResourceRelationship, parentIdentifier: ResourceKey, relationship: ResourceEdge, options?: BaseFinderOptions): Promise<ResourceKey | null>;
|
|
45
45
|
destroy(): void;
|
|
@@ -28,9 +28,6 @@ export type FactoryCache = Record<string, ModelFactory>;
|
|
|
28
28
|
export type ModelStore = Store & {
|
|
29
29
|
_modelFactoryCache: FactoryCache;
|
|
30
30
|
};
|
|
31
|
-
/**
|
|
32
|
-
* @noInheritDoc
|
|
33
|
-
*/
|
|
34
31
|
interface Model {
|
|
35
32
|
/**
|
|
36
33
|
* The store service instance which created this record instance
|
|
@@ -89,8 +86,8 @@ interface Model {
|
|
|
89
86
|
```
|
|
90
87
|
|
|
91
88
|
@public
|
|
92
|
-
@param
|
|
93
|
-
@return
|
|
89
|
+
@param options
|
|
90
|
+
@return a promise that will be resolved when the adapter returns
|
|
94
91
|
successfully or rejected if the adapter returns with an error.
|
|
95
92
|
*/
|
|
96
93
|
destroyRecord<T extends MinimalLegacyRecord>(this: T, options?: Record<string, unknown>): Promise<this>;
|
|
@@ -204,9 +201,9 @@ interface Model {
|
|
|
204
201
|
}
|
|
205
202
|
```
|
|
206
203
|
|
|
204
|
+
@deprecated use {@link Store.request} instead
|
|
207
205
|
@public
|
|
208
|
-
@
|
|
209
|
-
@return {Promise} a promise that will be resolved when the adapter returns
|
|
206
|
+
@return a promise that will be resolved when the adapter returns
|
|
210
207
|
successfully or rejected if the adapter returns with an error.
|
|
211
208
|
*/
|
|
212
209
|
save<T extends MinimalLegacyRecord>(this: T, options?: Record<string, unknown>): Promise<this>;
|
|
@@ -414,7 +411,10 @@ interface Model {
|
|
|
414
411
|
* the class to use as the reactive object for data of resource
|
|
415
412
|
* of that type.
|
|
416
413
|
*
|
|
414
|
+
* @public
|
|
417
415
|
* @noInheritDoc
|
|
416
|
+
* @hideconstructor
|
|
417
|
+
* @legacy
|
|
418
418
|
*/
|
|
419
419
|
declare class Model extends EmberObject implements MinimalLegacyRecord {
|
|
420
420
|
/** @private */
|
|
@@ -797,7 +797,7 @@ declare class Model extends EmberObject implements MinimalLegacyRecord {
|
|
|
797
797
|
Represents the model's class name as a string. This can be used to look up the model's class name through
|
|
798
798
|
`Store`'s modelFor method.
|
|
799
799
|
|
|
800
|
-
`modelName` is generated for you by
|
|
800
|
+
`modelName` is generated for you by WarpDrive. It will be a lowercased, dasherized string.
|
|
801
801
|
For example:
|
|
802
802
|
|
|
803
803
|
```javascript
|
|
@@ -10,11 +10,11 @@ A `BelongsToReference` is a low-level API that allows access
|
|
|
10
10
|
and manipulation of a belongsTo relationship.
|
|
11
11
|
|
|
12
12
|
It is especially useful when you're dealing with `async` relationships
|
|
13
|
-
from `@
|
|
13
|
+
from `@warp-drive/legacy/model` as it allows synchronous access to
|
|
14
14
|
the relationship data if loaded, as well as APIs for loading, reloading
|
|
15
15
|
the data or accessing available information without triggering a load.
|
|
16
16
|
|
|
17
|
-
It may also be useful when using `sync` relationships with `@
|
|
17
|
+
It may also be useful when using `sync` relationships with `@warp-drive/legacy/model`
|
|
18
18
|
that need to be loaded/reloaded with more precise timing than marking the
|
|
19
19
|
relationship as `async` and relying on autofetch would have allowed.
|
|
20
20
|
|
|
@@ -206,7 +206,7 @@ export default class BelongsToReference<
|
|
|
206
206
|
Example
|
|
207
207
|
|
|
208
208
|
```js [app/models/post.js]
|
|
209
|
-
import Model, { hasMany } from '@
|
|
209
|
+
import Model, { hasMany } from '@warp-drive/legacy/model';
|
|
210
210
|
|
|
211
211
|
export default class PostModel extends Model {
|
|
212
212
|
@hasMany('comment', { async: true, inverse: null }) comments;
|
|
@@ -241,7 +241,7 @@ export default class BelongsToReference<
|
|
|
241
241
|
*/
|
|
242
242
|
remoteType(): "link" | "id";
|
|
243
243
|
/**
|
|
244
|
-
`push` can be used to update the data in the relationship and
|
|
244
|
+
`push` can be used to update the data in the relationship and WarpDrive
|
|
245
245
|
will treat the new data as the canonical value of this relationship on
|
|
246
246
|
the backend. A value of `null` (e.g. `{ data: null }`) can be passed to
|
|
247
247
|
clear the relationship.
|
|
@@ -430,7 +430,7 @@ export default class BelongsToReference<
|
|
|
430
430
|
});
|
|
431
431
|
```
|
|
432
432
|
```js [app/adapters/user.js]
|
|
433
|
-
import Adapter from '@
|
|
433
|
+
import Adapter from '@warp-drive/legacy/adapter';
|
|
434
434
|
|
|
435
435
|
export default class UserAdapter extends Adapter {
|
|
436
436
|
findRecord(store, type, id, snapshot) {
|
|
@@ -19,11 +19,11 @@ A `HasManyReference` is a low-level API that allows access
|
|
|
19
19
|
and manipulation of a hasMany relationship.
|
|
20
20
|
|
|
21
21
|
It is especially useful when you're dealing with `async` relationships
|
|
22
|
-
from `@
|
|
22
|
+
from `@warp-drive/legacy/model` as it allows synchronous access to
|
|
23
23
|
the relationship data if loaded, as well as APIs for loading, reloading
|
|
24
24
|
the data or accessing available information without triggering a load.
|
|
25
25
|
|
|
26
|
-
It may also be useful when using `sync` relationships with `@
|
|
26
|
+
It may also be useful when using `sync` relationships with `@warp-drive/legacy/model`
|
|
27
27
|
that need to be loaded/reloaded with more precise timing than marking the
|
|
28
28
|
relationship as `async` and relying on autofetch would have allowed.
|
|
29
29
|
|
|
@@ -243,7 +243,7 @@ export default class HasManyReference<
|
|
|
243
243
|
*/
|
|
244
244
|
meta(): Meta | null;
|
|
245
245
|
/**
|
|
246
|
-
`push` can be used to update the data in the relationship and
|
|
246
|
+
`push` can be used to update the data in the relationship and WarpDrive
|
|
247
247
|
will treat the new data as the canonical value of this relationship on
|
|
248
248
|
the backend. An empty array will signify the canonical value should be
|
|
249
249
|
empty.
|
|
@@ -7,7 +7,7 @@ import type { ResourceKey } from "@warp-drive/core/types/identifier";
|
|
|
7
7
|
import type { ObjectValue } from "@warp-drive/core/types/json/raw";
|
|
8
8
|
import type { TypedRecordInstance, TypeFromInstance } from "@warp-drive/core/types/record";
|
|
9
9
|
import type { Derivation, HashFn, Transformation } from "@warp-drive/core/types/schema/concepts";
|
|
10
|
-
import type { ArrayField, DerivedField, FieldSchema, GenericField, HashField, LegacyResourceSchema, ObjectField, ObjectSchema, ResourceSchema } from "@warp-drive/core/types/schema/fields";
|
|
10
|
+
import type { ArrayField, CacheableFieldSchema, DerivedField, FieldSchema, GenericField, HashField, IdentityField, LegacyResourceSchema, ObjectField, ObjectSchema, ResourceSchema } from "@warp-drive/core/types/schema/fields";
|
|
11
11
|
import type { WithPartial } from "@warp-drive/core/types/utils";
|
|
12
12
|
import type { Snapshot } from "../compat/-private.js";
|
|
13
13
|
import type { MinimalLegacyRecord } from "./-private/model-methods.js";
|
|
@@ -56,14 +56,14 @@ interface LegacyModeRecord<T extends TypedRecordInstance> {
|
|
|
56
56
|
}
|
|
57
57
|
/**
|
|
58
58
|
* A Type utility that enables quickly adding type information for the fields
|
|
59
|
-
* defined by `import { withDefaults } from '@
|
|
59
|
+
* defined by `import { withDefaults } from '@warp-drive/legacy/model/migration-support'`.
|
|
60
60
|
*
|
|
61
61
|
* Example:
|
|
62
62
|
*
|
|
63
63
|
* ```ts
|
|
64
|
-
* import { withDefaults, WithLegacy } from '@
|
|
65
|
-
* import { Type } from '@warp-drive/core
|
|
66
|
-
* import type { HasMany } from '
|
|
64
|
+
* import { withDefaults, WithLegacy } from '@warp-drive/legacy/model/migration-support';
|
|
65
|
+
* import { Type } from '@warp-drive/core/types/symbols';
|
|
66
|
+
* import type { HasMany } from '@@warp-drive/legacy/model';
|
|
67
67
|
*
|
|
68
68
|
* export const UserSchema = withDefaults({
|
|
69
69
|
* type: 'user',
|
|
@@ -99,14 +99,14 @@ export type WithLegacy<T extends TypedRecordInstance> = T & LegacyModeRecord<T>;
|
|
|
99
99
|
/**
|
|
100
100
|
* A function which adds the necessary fields to a schema and marks it as
|
|
101
101
|
* being in LegacyMode. This is used to support the legacy features of
|
|
102
|
-
* @
|
|
102
|
+
* @warp-drive/legacy/model while migrating to WarpDrive.
|
|
103
103
|
*
|
|
104
104
|
* Example:
|
|
105
105
|
*
|
|
106
106
|
* ```ts
|
|
107
|
-
* import { withDefaults, WithLegacy } from '@
|
|
108
|
-
* import { Type } from '@warp-drive/core
|
|
109
|
-
* import type { HasMany } from '@
|
|
107
|
+
* import { withDefaults, WithLegacy } from '@warp-drive/legacy/model/migration-support';
|
|
108
|
+
* import { Type } from '@warp-drive/core/types/symbols';
|
|
109
|
+
* import type { HasMany } from '@warp-drive/legacy/model';
|
|
110
110
|
*
|
|
111
111
|
* export const UserSchema = withDefaults({
|
|
112
112
|
* type: 'user',
|
|
@@ -141,26 +141,42 @@ export type WithLegacy<T extends TypedRecordInstance> = T & LegacyModeRecord<T>;
|
|
|
141
141
|
* it requires with the schema service.
|
|
142
142
|
*
|
|
143
143
|
* ```ts
|
|
144
|
-
* import { registerDerivations } from '@
|
|
144
|
+
* import { registerDerivations } from '@warp-drive/legacy/model/migration-support';
|
|
145
145
|
*
|
|
146
146
|
* registerDerivations(schema);
|
|
147
147
|
* ```
|
|
148
148
|
*
|
|
149
|
-
* @param
|
|
150
|
-
* @return
|
|
149
|
+
* @param schema The schema to add legacy support to.
|
|
150
|
+
* @return The schema with legacy support added.
|
|
151
151
|
* @public
|
|
152
152
|
*/
|
|
153
153
|
export declare function withDefaults(schema: WithPartial<LegacyResourceSchema, "legacy" | "identity">): LegacyResourceSchema;
|
|
154
|
-
export declare function withRestoredDeprecatedModelRequestBehaviors(schema: WithPartial<LegacyResourceSchema, "legacy" | "identity">): LegacyResourceSchema;
|
|
155
154
|
/**
|
|
156
|
-
*
|
|
157
|
-
* the
|
|
155
|
+
* Adds the necessasary fields to the schema for supporting
|
|
156
|
+
* the deprecated request methods on LegacyMode schemas.
|
|
158
157
|
*
|
|
159
|
-
*
|
|
158
|
+
* Use this instead of `withDefaults` to add the fields
|
|
159
|
+
* and behaviors necessary to support Model-Like capabilities.
|
|
160
160
|
*
|
|
161
161
|
* ```ts
|
|
162
|
-
* import {
|
|
162
|
+
* import { withRestoredDeprecatedModelRequestBehaviors } from '@warp-drive/legacy/model/migration-support';
|
|
163
|
+
*
|
|
164
|
+
* export const UserSchema = withRestoredDeprecatedModelRequestBehaviors({
|
|
165
|
+
* type: 'user',
|
|
166
|
+
* fields: [
|
|
167
|
+
* { name: 'firstName', kind: 'attribute' },
|
|
168
|
+
* { name: 'lastName', kind: 'attribute' },
|
|
169
|
+
* ]
|
|
170
|
+
* });
|
|
163
171
|
* ```
|
|
172
|
+
*/
|
|
173
|
+
export declare function withRestoredDeprecatedModelRequestBehaviors(schema: WithPartial<LegacyResourceSchema, "legacy" | "identity">): LegacyResourceSchema;
|
|
174
|
+
/**
|
|
175
|
+
* A function which registers the necessary derivations to support
|
|
176
|
+
* the LegacyMode features of @warp-drive/legacy/model while migrating to WarpDrive.
|
|
177
|
+
*
|
|
178
|
+
* This must be called in order to use the fields added by {@link withDefaults} or
|
|
179
|
+
* {@link withRestoredDeprecatedModelRequestBehaviors}.
|
|
164
180
|
*
|
|
165
181
|
* @param schema The schema service to register the derivations with.
|
|
166
182
|
* @public
|
|
@@ -180,8 +196,8 @@ export declare function registerDerivations(schema: SchemaService): void;
|
|
|
180
196
|
* provide their own schema information to the application.
|
|
181
197
|
*
|
|
182
198
|
* ```ts
|
|
183
|
-
* import { DelegatingSchemaService } from '@
|
|
184
|
-
* import { SchemaService } from '@warp-drive/
|
|
199
|
+
* import { DelegatingSchemaService } from '@warp-drive/legacy/model/migration-support';
|
|
200
|
+
* import { SchemaService } from '@warp-drive/core/reactive';
|
|
185
201
|
*
|
|
186
202
|
* class AppStore extends Store {
|
|
187
203
|
* createSchemaService() {
|
|
@@ -207,8 +223,6 @@ export interface DelegatingSchemaService {
|
|
|
207
223
|
doesTypeExist?(type: string): boolean;
|
|
208
224
|
}
|
|
209
225
|
export declare class DelegatingSchemaService implements SchemaService {
|
|
210
|
-
_preferred: SchemaService;
|
|
211
|
-
_secondary: SchemaService;
|
|
212
226
|
constructor(store: Store, schema: SchemaService);
|
|
213
227
|
isDelegated(resource: ResourceKey | {
|
|
214
228
|
type: string;
|
|
@@ -224,6 +238,9 @@ export declare class DelegatingSchemaService implements SchemaService {
|
|
|
224
238
|
fields(resource: ResourceKey | {
|
|
225
239
|
type: string;
|
|
226
240
|
}): Map<string, FieldSchema>;
|
|
241
|
+
cacheFields?(resource: {
|
|
242
|
+
type: string;
|
|
243
|
+
}): Map<string, Exclude<CacheableFieldSchema, IdentityField>>;
|
|
227
244
|
transformation(field: GenericField | ObjectField | ArrayField | {
|
|
228
245
|
type: string;
|
|
229
246
|
}): Transformation;
|
|
@@ -245,6 +262,10 @@ export declare class DelegatingSchemaService implements SchemaService {
|
|
|
245
262
|
FM extends ObjectValue | null
|
|
246
263
|
>(derivation: Derivation<R, T, FM>): void;
|
|
247
264
|
registerHashFn(hashFn: HashFn): void;
|
|
265
|
+
CAUTION_MEGA_DANGER_ZONE_hasExtension(ext: {
|
|
266
|
+
kind: "object" | "array";
|
|
267
|
+
name: string;
|
|
268
|
+
}): boolean;
|
|
248
269
|
CAUTION_MEGA_DANGER_ZONE_registerExtension(extension: CAUTION_MEGA_DANGER_ZONE_Extension): void;
|
|
249
270
|
CAUTION_MEGA_DANGER_ZONE_resourceExtensions(resource: ResourceKey | {
|
|
250
271
|
type: string;
|
|
@@ -252,4 +273,8 @@ export declare class DelegatingSchemaService implements SchemaService {
|
|
|
252
273
|
CAUTION_MEGA_DANGER_ZONE_objectExtensions(field: ExtensibleField, resolvedType: string | null): null | ProcessedExtension["features"];
|
|
253
274
|
CAUTION_MEGA_DANGER_ZONE_arrayExtensions(field: ExtensibleField): null | ProcessedExtension["features"];
|
|
254
275
|
}
|
|
276
|
+
export interface PrivateDelegatingSchemaService extends DelegatingSchemaService {
|
|
277
|
+
_preferred: SchemaService;
|
|
278
|
+
_secondary: SchemaService;
|
|
279
|
+
}
|
|
255
280
|
export {};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { Fragment } from "./fragment.js";
|
|
2
|
+
export declare class FragmentArray<T extends Fragment> {
|
|
3
|
+
isDestroying: boolean;
|
|
4
|
+
isDestroyed: boolean;
|
|
5
|
+
get hasDirtyAttributes(): boolean;
|
|
6
|
+
addFragment(fragment?: T): Fragment[] | undefined;
|
|
7
|
+
createFragment(fragment?: T): Fragment | undefined;
|
|
8
|
+
removeFragment(fragment?: T): void;
|
|
9
|
+
rollbackAttributes(): void;
|
|
10
|
+
}
|
|
11
|
+
export declare const FragmentArrayExtension: {
|
|
12
|
+
kind: "array";
|
|
13
|
+
name: "fragment-array";
|
|
14
|
+
features: typeof FragmentArray;
|
|
15
|
+
};
|
|
16
|
+
export default FragmentArrayExtension;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { PrivateReactiveResource } from "@warp-drive/core/reactive/-private";
|
|
2
|
+
export declare class Fragment {
|
|
3
|
+
isDestroying: boolean;
|
|
4
|
+
isDestroyed: boolean;
|
|
5
|
+
get hasDirtyAttributes(): boolean;
|
|
6
|
+
get isFragment(): boolean;
|
|
7
|
+
get $type(): string | null | undefined;
|
|
8
|
+
rollbackAttributes(this: PrivateReactiveResource): void;
|
|
9
|
+
}
|
|
10
|
+
export declare const FragmentExtension: {
|
|
11
|
+
kind: "object";
|
|
12
|
+
name: "fragment";
|
|
13
|
+
features: typeof Fragment;
|
|
14
|
+
};
|
|
15
|
+
export default FragmentExtension;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { Store } from "@warp-drive/core";
|
|
2
|
+
import type { ModelSchema } from "@warp-drive/core/types";
|
|
3
|
+
import type { TypedRecordInstance, TypeFromInstance } from "@warp-drive/core/types/record";
|
|
4
|
+
import type { LegacyAttributeField, LegacyRelationshipField } from "@warp-drive/core/types/schema/fields";
|
|
5
|
+
type KeyOrString<T> = keyof T & string extends never ? string : keyof T & string;
|
|
6
|
+
export declare function getShimClass<T>(store: Store, modelName: T extends TypedRecordInstance ? TypeFromInstance<T> : string): ShimModelClass<T>;
|
|
7
|
+
export declare class ShimModelClass<T = unknown> implements ModelSchema<T> {
|
|
8
|
+
__store: Store;
|
|
9
|
+
modelName: T extends TypedRecordInstance ? TypeFromInstance<T> : string;
|
|
10
|
+
constructor(store: Store, modelName: T extends TypedRecordInstance ? TypeFromInstance<T> : string);
|
|
11
|
+
get fields(): Map<KeyOrString<T>, "attribute" | "belongsTo" | "hasMany">;
|
|
12
|
+
get attributes(): Map<KeyOrString<T>, LegacyAttributeField>;
|
|
13
|
+
get relationshipsByName(): Map<KeyOrString<T>, LegacyRelationshipField>;
|
|
14
|
+
eachAttribute<K extends KeyOrString<T>>(callback: (key: K, attribute: LegacyAttributeField) => void, binding?: T): void;
|
|
15
|
+
eachRelationship<K extends KeyOrString<T>>(callback: (key: K, relationship: LegacyRelationshipField) => void, binding?: T): void;
|
|
16
|
+
eachTransformedAttribute<K extends KeyOrString<T>>(callback: (key: K, type: string | null) => void, binding?: T): void;
|
|
17
|
+
}
|
|
18
|
+
export declare function fragmentsModelFor<T extends TypedRecordInstance>(this: Store, modelName: T extends TypedRecordInstance ? TypeFromInstance<T> : string): ShimModelClass<T>;
|
|
19
|
+
export declare const modelFor: typeof fragmentsModelFor;
|
|
20
|
+
export {};
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { WithArrayLike, WithEmberObject } from "../compat/extensions.js";
|
|
2
|
+
import type { Fragment } from "./extensions/fragment.js";
|
|
3
|
+
import type { FragmentArray } from "./extensions/fragment-array.js";
|
|
4
|
+
export type WithFragment<T> = T & WithEmberObject<T> & Fragment;
|
|
5
|
+
export type WithFragmentArray<T extends Fragment> = T & WithArrayLike<T> & FragmentArray<T>;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type ApplicationInstance from "@ember/application/instance";
|
|
2
|
+
import type { SchemaService } from "@warp-drive/core/types";
|
|
3
|
+
export declare function registerFragmentExtensions(schema: SchemaService): void;
|
|
4
|
+
export declare function initialize(application: ApplicationInstance): void;
|
|
5
|
+
declare const _default: {
|
|
6
|
+
name: string;
|
|
7
|
+
initialize: (application: ApplicationInstance) => void;
|
|
8
|
+
};
|
|
9
|
+
export default _default;
|