@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
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { type default as EmberObject } from "@ember/object";
|
|
2
|
-
import type { CAUTION_MEGA_DANGER_ZONE_Extension } from "@warp-drive/core/reactive
|
|
2
|
+
import type { CAUTION_MEGA_DANGER_ZONE_Extension } from "@warp-drive/core/reactive";
|
|
3
3
|
declare const EmberObjectMethods: readonly ["addObserver", "cacheFor", "decrementProperty", "get", "getProperties", "incrementProperty", "notifyPropertyChange", "removeObserver", "set", "setProperties", "toggleProperty"];
|
|
4
4
|
export declare const EmberObjectArrayExtension: CAUTION_MEGA_DANGER_ZONE_Extension;
|
|
5
5
|
export declare const EmberObjectExtension: CAUTION_MEGA_DANGER_ZONE_Extension;
|
|
@@ -7,13 +7,11 @@ import type { SnapshotRecordArray } from "./snapshot-record-array.js";
|
|
|
7
7
|
type Group = Snapshot[];
|
|
8
8
|
export type AdapterPayload = Record<string, unknown> | unknown[];
|
|
9
9
|
/**
|
|
10
|
-
*
|
|
11
|
-
|
|
12
|
-
⚠️ <strong>This is LEGACY documentation</strong> for a feature that is no longer encouraged to be used.
|
|
10
|
+
* :::danger
|
|
11
|
+
⚠️ **This is LEGACY documentation** for a feature that is no longer encouraged to be used.
|
|
13
12
|
If starting a new app or thinking of implementing a new adapter, consider writing a
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
</blockquote>
|
|
13
|
+
{@link Handler} instead to be used with the {@link RequestManager}
|
|
14
|
+
:::
|
|
17
15
|
|
|
18
16
|
The following documentation describes the methods an
|
|
19
17
|
adapter should implement with descriptions around when an
|
|
@@ -170,7 +168,7 @@ export interface MinimumAdapterInterface {
|
|
|
170
168
|
* let error = new Error(errorMessage);
|
|
171
169
|
*
|
|
172
170
|
* // these two properties combined
|
|
173
|
-
* // alert
|
|
171
|
+
* // alert WarpDrive to this error being for
|
|
174
172
|
* // invalid properties on the record during
|
|
175
173
|
* // the request
|
|
176
174
|
* error.isAdapterError = true;
|
|
@@ -221,7 +219,7 @@ export interface MinimumAdapterInterface {
|
|
|
221
219
|
* let error = new Error(errorMessage);
|
|
222
220
|
*
|
|
223
221
|
* // these two properties combined
|
|
224
|
-
* // alert
|
|
222
|
+
* // alert WarpDrive to this error being for
|
|
225
223
|
* // invalid properties on the record during
|
|
226
224
|
* // the request
|
|
227
225
|
* error.isAdapterError = true;
|
|
@@ -404,7 +402,7 @@ export interface MinimumAdapterInterface {
|
|
|
404
402
|
*
|
|
405
403
|
* A group is an array of snapshots meant to be fetched together by a single `findMany` request.
|
|
406
404
|
*
|
|
407
|
-
* By default if this method is not implemented
|
|
405
|
+
* By default if this method is not implemented WarpDrive will call `findMany` once with all
|
|
408
406
|
* requested records as a single group when `coalesceFindRequests` is `true`.
|
|
409
407
|
*
|
|
410
408
|
* See also `findMany` and `coalesceFindRequests`
|
|
@@ -9,13 +9,11 @@ export type SerializerOptions = {
|
|
|
9
9
|
};
|
|
10
10
|
export type RequestType = "findRecord" | "queryRecord" | "findAll" | "findBelongsTo" | "findHasMany" | "findMany" | "query" | "createRecord" | "deleteRecord" | "updateRecord";
|
|
11
11
|
/**
|
|
12
|
-
*
|
|
13
|
-
|
|
14
|
-
⚠️ <strong>This is LEGACY documentation</strong> for a feature that is no longer encouraged to be used.
|
|
12
|
+
* :::danger
|
|
13
|
+
⚠️ **This is LEGACY documentation** for a feature that is no longer encouraged to be used.
|
|
15
14
|
If starting a new app or thinking of implementing a new adapter, consider writing a
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
</blockquote>
|
|
15
|
+
{@link Handler} instead to be used with the {@link RequestManager}
|
|
16
|
+
:::
|
|
19
17
|
|
|
20
18
|
The following documentation describes the methods an application
|
|
21
19
|
serializer should implement with descriptions around when an
|
|
@@ -23,7 +21,6 @@ application might expect these methods to be called.
|
|
|
23
21
|
|
|
24
22
|
Methods that are not required are marked as **optional**.
|
|
25
23
|
|
|
26
|
-
@class (Interface) Serializer
|
|
27
24
|
@public
|
|
28
25
|
*/
|
|
29
26
|
export interface MinimumSerializerInterface {
|
|
@@ -43,23 +40,22 @@ export interface MinimumSerializerInterface {
|
|
|
43
40
|
* and [Resource Identifier Objects](https://jsonapi.org/format/#document-resource-identifier-objects)
|
|
44
41
|
*
|
|
45
42
|
* @public
|
|
46
|
-
* @param
|
|
47
|
-
* @param
|
|
43
|
+
* @param store The store service that initiated the request being normalized
|
|
44
|
+
* @param schema An object with methods for accessing information about
|
|
48
45
|
* the type, attributes and relationships of the primary type associated with the request.
|
|
49
|
-
* @param
|
|
46
|
+
* @param rawPayload The raw JSON response data returned from an API request.
|
|
50
47
|
* This correlates to the value the promise returned by the adapter method that performed
|
|
51
48
|
* the request resolved to.
|
|
52
|
-
* @param
|
|
49
|
+
* @param id For a findRecord request, this is the id initially provided
|
|
53
50
|
* in the call to store.findRecord. Else this value is null.
|
|
54
|
-
* @param
|
|
55
|
-
* type of request the Adapter had been asked to perform.
|
|
51
|
+
* @param requestType The type of request the Adapter had been asked to perform.
|
|
56
52
|
*
|
|
57
|
-
* @return
|
|
53
|
+
* @return a document following the structure of a [{json:api} Document](https://jsonapi.org/format/#document-structure).
|
|
58
54
|
*/
|
|
59
55
|
normalizeResponse(store: Store, schema: ModelSchema, rawPayload: AdapterPayload, id: string | null, requestType: "findRecord" | "queryRecord" | "findAll" | "findBelongsTo" | "findHasMany" | "findMany" | "query" | "createRecord" | "deleteRecord" | "updateRecord"): JsonApiDocument;
|
|
60
56
|
/**
|
|
61
57
|
* This method is responsible for serializing an individual record
|
|
62
|
-
* via a
|
|
58
|
+
* via a {@link Snapshot} into the format expected by the API.
|
|
63
59
|
*
|
|
64
60
|
* This method is called by `snapshot.serialize()`.
|
|
65
61
|
*
|
|
@@ -70,8 +66,7 @@ export interface MinimumSerializerInterface {
|
|
|
70
66
|
* is not implemented.
|
|
71
67
|
*
|
|
72
68
|
* @public
|
|
73
|
-
* @param
|
|
74
|
-
* @param {Object} [options]
|
|
69
|
+
* @param snapshot A Snapshot for the record to serialize
|
|
75
70
|
*/
|
|
76
71
|
serialize(snapshot: Snapshot, options?: SerializerOptions): ObjectValue;
|
|
77
72
|
/**
|
|
@@ -118,14 +113,12 @@ export interface MinimumSerializerInterface {
|
|
|
118
113
|
*
|
|
119
114
|
* @public
|
|
120
115
|
* @optional
|
|
121
|
-
* @param
|
|
116
|
+
* @param schema An object with methods for accessing information about
|
|
122
117
|
* the type, attributes and relationships of the primary type associated with the request.
|
|
123
|
-
* @param
|
|
124
|
-
* @param
|
|
118
|
+
* @param rawPayload Some raw JSON data to be normalized into a JSON:API Resource.
|
|
119
|
+
* @param prop When called by the EmbeddedRecordsMixin this param will be the
|
|
125
120
|
* property at which the object provided as rawPayload was found.
|
|
126
|
-
* @return
|
|
127
|
-
* containing a single JSON:API Resource
|
|
128
|
-
* as its primary data.
|
|
121
|
+
* @return A JSON:API Document containing a single JSON:API Resource as its primary data.
|
|
129
122
|
*/
|
|
130
123
|
normalize?(schema: ModelSchema, rawPayload: ObjectValue, prop?: string): SingleResourceDocument;
|
|
131
124
|
/**
|
|
@@ -161,11 +154,9 @@ export interface MinimumSerializerInterface {
|
|
|
161
154
|
* @optional
|
|
162
155
|
* @param hash A top most object of the request payload onto
|
|
163
156
|
* which to append the serialized record
|
|
164
|
-
* @param
|
|
157
|
+
* @param schema An object with methods for accessing information about
|
|
165
158
|
* the type, attributes and relationships of the primary type associated with the request.
|
|
166
|
-
* @param
|
|
167
|
-
* @param [options]
|
|
168
|
-
* @return {void}
|
|
159
|
+
* @param snapshot A Snapshot for the record to serialize
|
|
169
160
|
*/
|
|
170
161
|
serializeIntoHash?(hash: object, schema: ModelSchema, snapshot: Snapshot, options?: SerializerOptions): void;
|
|
171
162
|
/**
|
|
@@ -204,10 +195,9 @@ export interface MinimumSerializerInterface {
|
|
|
204
195
|
*
|
|
205
196
|
* @public
|
|
206
197
|
* @optional
|
|
207
|
-
* @param
|
|
208
|
-
* @param
|
|
198
|
+
* @param store The store service that initiated the request being normalized
|
|
199
|
+
* @param rawPayload The raw JSON response data returned from an API request.
|
|
209
200
|
* This JSON should be in the API format expected by the serializer.
|
|
210
|
-
* @return {void}
|
|
211
201
|
*/
|
|
212
202
|
pushPayload?(store: Store, rawPayload: ObjectValue): void;
|
|
213
203
|
/**
|
|
@@ -4,7 +4,7 @@ type Reporter = (type: "formatted-id" | "formatted-type", actual: unknown, expec
|
|
|
4
4
|
* changes during normalization. This is useful for instrumenting
|
|
5
5
|
* to discover places where usage in the app is not consistent.
|
|
6
6
|
*
|
|
7
|
-
* @param
|
|
7
|
+
* @param fn - a function which takes a mismatch-type ('formatted-id' | 'formatted-type'), actual, and expected value
|
|
8
8
|
* @public
|
|
9
9
|
*/
|
|
10
10
|
export declare function configureMismatchReporter(fn: Reporter): void;
|
|
@@ -13,7 +13,7 @@ export declare function configureMismatchReporter(fn: Reporter): void;
|
|
|
13
13
|
* fails validation. This is useful for instrumenting
|
|
14
14
|
* to discover places where usage in the app is not consistent.
|
|
15
15
|
*
|
|
16
|
-
* @param
|
|
16
|
+
* @param fn - a function which takes a message and a condition
|
|
17
17
|
* @public
|
|
18
18
|
*/
|
|
19
19
|
export declare function configureAssertFn(fn: (message: string, condition: unknown) => void): void;
|
|
@@ -27,13 +27,13 @@ export declare function configureAssertFn(fn: (message: string, condition: unkno
|
|
|
27
27
|
* the configured mismatch reporter and assert functions will
|
|
28
28
|
* be called.
|
|
29
29
|
*
|
|
30
|
-
* @param
|
|
30
|
+
* @param fn - a function which takes a string and returns a string
|
|
31
31
|
* @public
|
|
32
32
|
*/
|
|
33
33
|
export declare function configureTypeNormalization(fn: (type: string) => string): void;
|
|
34
34
|
/**
|
|
35
35
|
* Converts a potentially unnormalized type into the format expected
|
|
36
|
-
* by our
|
|
36
|
+
* by our WarpDrive Cache. Currently this is singular-dasherized.
|
|
37
37
|
*
|
|
38
38
|
* you should not rely on this function to give you an exact format
|
|
39
39
|
* for display purposes. Formatting for display should be handled
|
|
@@ -56,13 +56,13 @@ export declare function configureTypeNormalization(fn: (type: string) => string)
|
|
|
56
56
|
* formattedType('PostComment'); // => 'post-comment'
|
|
57
57
|
* ```
|
|
58
58
|
*
|
|
59
|
-
* @param
|
|
60
|
-
* @return
|
|
59
|
+
* @param type the potentially un-normalized type
|
|
60
|
+
* @return the normalized type
|
|
61
61
|
* @public
|
|
62
62
|
*/
|
|
63
63
|
export declare function formattedType<T extends string>(type: T | string): T;
|
|
64
64
|
/**
|
|
65
|
-
* Format an id to the format expected by the
|
|
65
|
+
* Format an id to the format expected by the WarpDrive Cache.
|
|
66
66
|
* Currently this means that id should be `string | null`.
|
|
67
67
|
*
|
|
68
68
|
* Asserts invalid IDs (undefined, '', 0, '0') in dev.
|
|
@@ -77,8 +77,8 @@ export declare function formattedType<T extends string>(type: T | string): T;
|
|
|
77
77
|
* formattedId(null); // => null
|
|
78
78
|
* ```
|
|
79
79
|
*
|
|
80
|
-
* @param
|
|
81
|
-
* @return
|
|
80
|
+
* @param id the potentially un-normalized id
|
|
81
|
+
* @return the normalized id
|
|
82
82
|
* @public
|
|
83
83
|
*/
|
|
84
84
|
export declare function formattedId(id: string | number): string;
|
|
@@ -88,7 +88,7 @@ export declare function expectId(id: string | number): string;
|
|
|
88
88
|
export declare function expectId(id: null): never;
|
|
89
89
|
/**
|
|
90
90
|
* Compares two types for strict equality, converting them to
|
|
91
|
-
* the format expected by the
|
|
91
|
+
* the format expected by the WarpDrive Cache to ensure
|
|
92
92
|
* differences in format are accounted for in the comparison.
|
|
93
93
|
*
|
|
94
94
|
* Asserts when expected or actual are invalid types in dev.
|
|
@@ -106,15 +106,15 @@ export declare function expectId(id: null): never;
|
|
|
106
106
|
* isEquivType('posts', null); // false
|
|
107
107
|
* ```
|
|
108
108
|
*
|
|
109
|
-
* @param
|
|
110
|
-
* @param
|
|
111
|
-
* @return
|
|
109
|
+
* @param expected a potentially unnormalized type to match against
|
|
110
|
+
* @param actual a potentially unnormalized type to match against
|
|
111
|
+
* @return true if the types are equivalent
|
|
112
112
|
* @public
|
|
113
113
|
*/
|
|
114
114
|
export declare function isEquivType(expected: string, actual: string): boolean;
|
|
115
115
|
/**
|
|
116
116
|
* Compares two IDs for strict equality, converting them to
|
|
117
|
-
* the format expected by the
|
|
117
|
+
* the format expected by the WarpDrive Cache to ensure
|
|
118
118
|
* differences in format are accounted for in the comparison.
|
|
119
119
|
*
|
|
120
120
|
* Asserts when expected or actual are invalid IDs in dev.
|
|
@@ -128,9 +128,9 @@ export declare function isEquivType(expected: string, actual: string): boolean;
|
|
|
128
128
|
* isEquivId(1, null); // false
|
|
129
129
|
* ```
|
|
130
130
|
*
|
|
131
|
-
* @param
|
|
132
|
-
* @param
|
|
133
|
-
* @return
|
|
131
|
+
* @param expected a potentially un-normalized id to match against
|
|
132
|
+
* @param actual a potentially un-normalized id to match against
|
|
133
|
+
* @return true if the ids are equivalent
|
|
134
134
|
* @public
|
|
135
135
|
*/
|
|
136
136
|
export declare function isEquivId(expected: string | number, actual: string | number | null): boolean;
|
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;
|