@warp-drive/core 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 +22 -38
- package/declarations/build-config.d.ts +18 -1
- package/declarations/configure.d.ts +1 -1
- package/declarations/graph/-private/-edge-definition.d.ts +12 -2
- package/declarations/index.d.ts +90 -8
- package/declarations/reactive/-private/default-mode.d.ts +1 -1
- package/declarations/reactive/-private/document.d.ts +58 -46
- package/declarations/reactive/-private/fields/extension.d.ts +1 -1
- package/declarations/reactive/-private/fields/managed-array.d.ts +2 -2
- package/declarations/reactive/-private/fields/managed-object.d.ts +1 -1
- package/declarations/reactive/-private/record.d.ts +10 -1
- package/declarations/reactive/-private/schema.d.ts +77 -4
- package/declarations/reactive/-private.d.ts +1 -0
- package/declarations/reactive.d.ts +13 -8
- package/declarations/request/-private/types.d.ts +1 -1
- package/declarations/request.d.ts +47 -0
- package/declarations/signals/-leaked.d.ts +2 -0
- package/declarations/signals/-private.d.ts +6 -0
- package/declarations/{store/-private/new-core-tmp → signals}/promise-state.d.ts +2 -1
- package/declarations/{store/-private/new-core-tmp → signals}/request-state.d.ts +6 -6
- package/declarations/{store/-private/new-core-tmp → signals}/request-subscription.d.ts +4 -4
- package/declarations/store/-private/cache-handler/types.d.ts +2 -16
- package/declarations/store/-private/caches/instance-cache.d.ts +5 -6
- package/declarations/store/-private/default-cache-policy.d.ts +147 -129
- package/declarations/store/-private/managers/cache-capabilities-manager.d.ts +1 -1
- package/declarations/store/-private/managers/cache-key-manager.d.ts +26 -8
- package/declarations/store/-private/managers/cache-manager.d.ts +7 -18
- package/declarations/store/-private/managers/notification-manager.d.ts +1 -1
- package/declarations/store/-private/record-arrays/legacy-many-array.d.ts +1 -1
- package/declarations/store/-private/record-arrays/resource-array.d.ts +1 -1
- package/declarations/store/-private/store-service.d.ts +43 -64
- package/declarations/store/-private.d.ts +0 -6
- package/declarations/store/-types/q/cache-capabilities-manager.d.ts +1 -1
- package/declarations/store/deprecated/-private.d.ts +2 -2
- package/declarations/store/deprecated/store.d.ts +33 -32
- package/declarations/store.d.ts +1 -0
- package/declarations/types/cache.d.ts +8 -6
- package/declarations/types/record.d.ts +132 -0
- package/declarations/types/request.d.ts +26 -14
- package/declarations/types/schema/fields.d.ts +37 -13
- package/declarations/{store/-types/q → types/schema}/schema-service.d.ts +15 -13
- package/declarations/types/spec/document.d.ts +34 -0
- package/declarations/types/symbols.d.ts +2 -2
- package/declarations/types.d.ts +1 -1
- package/dist/build-config.js +1 -1
- package/dist/configure-DPUFCemT.js +1940 -0
- package/dist/configure.js +2 -1
- package/dist/default-cache-policy-D7_u4YRH.js +572 -0
- package/dist/{context-C_7OLieY.js → future-BKkJJkj7.js} +174 -174
- package/dist/graph/-private.js +16 -6
- package/dist/{request-state-CUuZzgvE.js → index-CQP2NSqg.js} +8835 -9432
- package/dist/index.js +6 -382
- package/dist/reactive/-private.js +1 -1
- package/dist/reactive.js +4 -903
- package/dist/request.js +49 -1
- package/dist/signals/-leaked.js +1 -0
- package/dist/store/-private.js +1 -2
- package/dist/store.js +1 -533
- package/dist/symbols-3C1OkYtZ.js +39 -0
- package/dist/types/-private.js +1 -1
- package/dist/types/record.js +127 -0
- package/dist/types/request.js +14 -12
- package/dist/types/schema/fields.js +14 -0
- package/dist/types/schema/schema-service.js +0 -0
- package/dist/types/symbols.js +2 -2
- package/dist/unpkg/dev/-leaked-Co0EI6Go.js +1939 -0
- package/dist/unpkg/dev/build-config/babel-macros.js +1 -0
- package/dist/unpkg/dev/build-config/canary-features.js +1 -0
- package/dist/unpkg/dev/build-config/debugging.js +1 -0
- package/dist/unpkg/dev/build-config/deprecations.js +1 -0
- package/dist/unpkg/dev/build-config/env.js +1 -0
- package/dist/unpkg/dev/build-config/macros.js +1 -0
- package/dist/unpkg/dev/build-config.js +1 -0
- package/dist/unpkg/dev/configure.js +1 -0
- package/dist/unpkg/dev/future-DFfOzSoe.js +672 -0
- package/dist/unpkg/dev/graph/-private.js +3132 -0
- package/dist/unpkg/dev/index-CepUPZlc.js +9392 -0
- package/dist/unpkg/dev/index.js +6 -0
- package/dist/unpkg/dev/reactive/-private.js +1 -0
- package/dist/unpkg/dev/reactive.js +3 -0
- package/dist/unpkg/dev/request.js +49 -0
- package/dist/unpkg/dev/runtime-DGG4CvlW.js +135 -0
- package/dist/unpkg/dev/signals/-leaked.js +1 -0
- package/dist/unpkg/dev/store/-private.js +55 -0
- package/dist/unpkg/dev/store.js +558 -0
- package/dist/unpkg/dev/types/-private.js +69 -0
- package/dist/unpkg/dev/types/cache/aliases.js +0 -0
- package/dist/unpkg/dev/types/cache/change.js +0 -0
- package/dist/unpkg/dev/types/cache/mutations.js +0 -0
- package/dist/unpkg/dev/types/cache/operations.js +0 -0
- package/dist/unpkg/dev/types/cache/relationship.js +0 -0
- package/dist/unpkg/dev/types/cache.js +0 -0
- package/dist/unpkg/dev/types/graph.js +0 -0
- package/dist/unpkg/dev/types/identifier.js +61 -0
- package/dist/unpkg/dev/types/json/raw.js +0 -0
- package/dist/unpkg/dev/types/params.js +0 -0
- package/dist/unpkg/dev/types/record.js +191 -0
- package/dist/unpkg/dev/types/request.js +77 -0
- package/dist/unpkg/dev/types/runtime.js +34 -0
- package/dist/unpkg/dev/types/schema/concepts.js +0 -0
- package/dist/unpkg/dev/types/schema/fields.js +505 -0
- package/dist/unpkg/dev/types/schema/fields.type-test.js +0 -0
- package/dist/unpkg/dev/types/schema/schema-service.js +0 -0
- package/dist/unpkg/dev/types/spec/document.js +0 -0
- package/dist/unpkg/dev/types/spec/error.js +0 -0
- package/dist/unpkg/dev/types/spec/json-api-raw.js +0 -0
- package/dist/unpkg/dev/types/symbols.js +84 -0
- package/dist/unpkg/dev/types/utils.js +0 -0
- package/dist/unpkg/dev/types.js +0 -0
- package/dist/unpkg/dev/utils/string.js +91 -0
- package/dist/unpkg/dev-deprecated/-leaked-DjMeRqdU.js +1939 -0
- package/dist/unpkg/dev-deprecated/-private-3C1OkYtZ.js +39 -0
- package/dist/unpkg/dev-deprecated/build-config/babel-macros.js +1 -0
- package/dist/unpkg/dev-deprecated/build-config/canary-features.js +1 -0
- package/dist/unpkg/dev-deprecated/build-config/debugging.js +1 -0
- package/dist/unpkg/dev-deprecated/build-config/deprecations.js +1 -0
- package/dist/unpkg/dev-deprecated/build-config/env.js +1 -0
- package/dist/unpkg/dev-deprecated/build-config/macros.js +1 -0
- package/dist/unpkg/dev-deprecated/build-config.js +1 -0
- package/dist/unpkg/dev-deprecated/configure.js +1 -0
- package/dist/unpkg/dev-deprecated/future-DFfOzSoe.js +672 -0
- package/dist/unpkg/dev-deprecated/graph/-private.js +3327 -0
- package/dist/unpkg/dev-deprecated/index-C_EEmn_3.js +10007 -0
- package/dist/unpkg/dev-deprecated/index.js +5 -0
- package/dist/unpkg/dev-deprecated/reactive/-private.js +1 -0
- package/dist/unpkg/dev-deprecated/reactive.js +3 -0
- package/dist/unpkg/dev-deprecated/request.js +49 -0
- package/dist/unpkg/dev-deprecated/runtime-DfhJzpZH.js +135 -0
- package/dist/unpkg/dev-deprecated/signals/-leaked.js +1 -0
- package/dist/unpkg/dev-deprecated/store/-private.js +1 -0
- package/dist/unpkg/dev-deprecated/store.js +558 -0
- package/dist/unpkg/dev-deprecated/types/-private.js +69 -0
- package/dist/unpkg/dev-deprecated/types/cache/aliases.js +0 -0
- package/dist/unpkg/dev-deprecated/types/cache/change.js +0 -0
- package/dist/unpkg/dev-deprecated/types/cache/mutations.js +0 -0
- package/dist/unpkg/dev-deprecated/types/cache/operations.js +0 -0
- package/dist/unpkg/dev-deprecated/types/cache/relationship.js +0 -0
- package/dist/unpkg/dev-deprecated/types/cache.js +0 -0
- package/dist/unpkg/dev-deprecated/types/graph.js +0 -0
- package/dist/unpkg/dev-deprecated/types/identifier.js +61 -0
- package/dist/unpkg/dev-deprecated/types/json/raw.js +0 -0
- package/dist/unpkg/dev-deprecated/types/params.js +0 -0
- package/dist/unpkg/dev-deprecated/types/record.js +191 -0
- package/dist/unpkg/dev-deprecated/types/request.js +77 -0
- package/dist/unpkg/dev-deprecated/types/runtime.js +34 -0
- package/dist/unpkg/dev-deprecated/types/schema/concepts.js +0 -0
- package/dist/unpkg/dev-deprecated/types/schema/fields.js +505 -0
- package/dist/unpkg/dev-deprecated/types/schema/fields.type-test.js +0 -0
- package/dist/unpkg/dev-deprecated/types/schema/schema-service.js +0 -0
- package/dist/unpkg/dev-deprecated/types/spec/document.js +0 -0
- package/dist/unpkg/dev-deprecated/types/spec/error.js +0 -0
- package/dist/unpkg/dev-deprecated/types/spec/json-api-raw.js +0 -0
- package/dist/unpkg/dev-deprecated/types/symbols.js +84 -0
- package/dist/unpkg/dev-deprecated/types/utils.js +0 -0
- package/dist/unpkg/dev-deprecated/types.js +0 -0
- package/dist/unpkg/dev-deprecated/utils/string.js +91 -0
- package/dist/unpkg/prod/-leaked-DUONXQDB.js +1676 -0
- package/dist/unpkg/prod/-private-sql1_mdx.js +39 -0
- package/dist/unpkg/prod/build-config/babel-macros.js +1 -0
- package/dist/unpkg/prod/build-config/canary-features.js +1 -0
- package/dist/unpkg/prod/build-config/debugging.js +1 -0
- package/dist/unpkg/prod/build-config/deprecations.js +1 -0
- package/dist/unpkg/prod/build-config/env.js +1 -0
- package/dist/unpkg/prod/build-config/macros.js +1 -0
- package/dist/unpkg/prod/build-config.js +1 -0
- package/dist/unpkg/prod/configure.js +2 -0
- package/dist/unpkg/prod/graph/-private.js +2235 -0
- package/dist/unpkg/prod/handler-EU_8ncB2.js +1619 -0
- package/dist/unpkg/prod/index.js +483 -0
- package/dist/unpkg/prod/promise-cache-DIT8Ypjq.js +19 -0
- package/dist/unpkg/prod/reactive/-private.js +1 -0
- package/dist/unpkg/prod/reactive.js +30 -0
- package/dist/unpkg/prod/request-BrJSCG6r.js +421 -0
- package/dist/unpkg/prod/request.js +2 -0
- package/dist/unpkg/prod/schema-BSkHyoWz.js +5219 -0
- package/dist/unpkg/prod/signals/-leaked.js +1 -0
- package/dist/unpkg/prod/store/-private.js +126 -0
- package/dist/unpkg/prod/store.js +437 -0
- package/dist/unpkg/prod/types/-private.js +49 -0
- package/dist/unpkg/prod/types/cache/aliases.js +0 -0
- package/dist/unpkg/prod/types/cache/change.js +0 -0
- package/dist/unpkg/prod/types/cache/mutations.js +0 -0
- package/dist/unpkg/prod/types/cache/operations.js +0 -0
- package/dist/unpkg/prod/types/cache/relationship.js +0 -0
- package/dist/unpkg/prod/types/cache.js +0 -0
- package/dist/unpkg/prod/types/graph.js +0 -0
- package/dist/unpkg/prod/types/identifier.js +61 -0
- package/dist/unpkg/prod/types/json/raw.js +0 -0
- package/dist/unpkg/prod/types/params.js +0 -0
- package/dist/unpkg/prod/types/record.js +191 -0
- package/dist/unpkg/prod/types/request.js +77 -0
- package/dist/unpkg/prod/types/runtime.js +34 -0
- package/dist/unpkg/prod/types/schema/concepts.js +0 -0
- package/dist/unpkg/prod/types/schema/fields.js +505 -0
- package/dist/unpkg/prod/types/schema/fields.type-test.js +0 -0
- package/dist/unpkg/prod/types/schema/schema-service.js +0 -0
- package/dist/unpkg/prod/types/spec/document.js +0 -0
- package/dist/unpkg/prod/types/spec/error.js +0 -0
- package/dist/unpkg/prod/types/spec/json-api-raw.js +0 -0
- package/dist/unpkg/prod/types/symbols.js +84 -0
- package/dist/unpkg/prod/types/utils.js +0 -0
- package/dist/unpkg/prod/types.js +0 -0
- package/dist/unpkg/prod/utils/string.js +72 -0
- package/dist/unpkg/prod-deprecated/-leaked-DRNv9VIX.js +1676 -0
- package/dist/unpkg/prod-deprecated/-private-3C1OkYtZ.js +39 -0
- package/dist/unpkg/prod-deprecated/build-config/babel-macros.js +1 -0
- package/dist/unpkg/prod-deprecated/build-config/canary-features.js +1 -0
- package/dist/unpkg/prod-deprecated/build-config/debugging.js +1 -0
- package/dist/unpkg/prod-deprecated/build-config/deprecations.js +1 -0
- package/dist/unpkg/prod-deprecated/build-config/env.js +1 -0
- package/dist/unpkg/prod-deprecated/build-config/macros.js +1 -0
- package/dist/unpkg/prod-deprecated/build-config.js +1 -0
- package/dist/unpkg/prod-deprecated/configure.js +2 -0
- package/dist/unpkg/prod-deprecated/graph/-private.js +2408 -0
- package/dist/unpkg/prod-deprecated/handler-CCIu4sQ3.js +334 -0
- package/dist/unpkg/prod-deprecated/hooks-Dv4Np0MY.js +26 -0
- package/dist/unpkg/prod-deprecated/index.js +483 -0
- package/dist/unpkg/prod-deprecated/promise-cache-DIT8Ypjq.js +19 -0
- package/dist/unpkg/prod-deprecated/reactive/-private.js +1 -0
- package/dist/unpkg/prod-deprecated/reactive.js +5 -0
- package/dist/unpkg/prod-deprecated/request-BrJSCG6r.js +421 -0
- package/dist/unpkg/prod-deprecated/request.js +2 -0
- package/dist/unpkg/prod-deprecated/schema-CJcjHv0E.js +6939 -0
- package/dist/unpkg/prod-deprecated/signals/-leaked.js +1 -0
- package/dist/unpkg/prod-deprecated/store/-private.js +88 -0
- package/dist/unpkg/prod-deprecated/store.js +437 -0
- package/dist/unpkg/prod-deprecated/types/-private.js +49 -0
- package/dist/unpkg/prod-deprecated/types/cache/aliases.js +0 -0
- package/dist/unpkg/prod-deprecated/types/cache/change.js +0 -0
- package/dist/unpkg/prod-deprecated/types/cache/mutations.js +0 -0
- package/dist/unpkg/prod-deprecated/types/cache/operations.js +0 -0
- package/dist/unpkg/prod-deprecated/types/cache/relationship.js +0 -0
- package/dist/unpkg/prod-deprecated/types/cache.js +0 -0
- package/dist/unpkg/prod-deprecated/types/graph.js +0 -0
- package/dist/unpkg/prod-deprecated/types/identifier.js +61 -0
- package/dist/unpkg/prod-deprecated/types/json/raw.js +0 -0
- package/dist/unpkg/prod-deprecated/types/params.js +0 -0
- package/dist/unpkg/prod-deprecated/types/record.js +191 -0
- package/dist/unpkg/prod-deprecated/types/request.js +77 -0
- package/dist/unpkg/prod-deprecated/types/runtime.js +34 -0
- package/dist/unpkg/prod-deprecated/types/schema/concepts.js +0 -0
- package/dist/unpkg/prod-deprecated/types/schema/fields.js +505 -0
- package/dist/unpkg/prod-deprecated/types/schema/fields.type-test.js +0 -0
- package/dist/unpkg/prod-deprecated/types/schema/schema-service.js +0 -0
- package/dist/unpkg/prod-deprecated/types/spec/document.js +0 -0
- package/dist/unpkg/prod-deprecated/types/spec/error.js +0 -0
- package/dist/unpkg/prod-deprecated/types/spec/json-api-raw.js +0 -0
- package/dist/unpkg/prod-deprecated/types/symbols.js +84 -0
- package/dist/unpkg/prod-deprecated/types/utils.js +0 -0
- package/dist/unpkg/prod-deprecated/types.js +0 -0
- package/dist/unpkg/prod-deprecated/utils/string.js +72 -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 +11 -3
- package/declarations/store/-private/new-core-tmp/expensive-subscription.d.ts +0 -24
- package/dist/configure-C3x8YXzL.js +0 -181
- 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/{store/-private/new-core-tmp → signals}/reactivity/configure.d.ts +0 -0
- /package/declarations/{store/-private/new-core-tmp → signals}/reactivity/internal.d.ts +0 -0
- /package/declarations/{store/-private/new-core-tmp → signals}/reactivity/signal.d.ts +0 -0
- /package/dist/{symbols-sql1_mdx.js → unpkg/dev/-private-sql1_mdx.js} +0 -0
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { type PersistedResourceKey, type RequestKey, type ResourceKey } from "../../../types/identifier.js";
|
|
2
|
-
import type {
|
|
2
|
+
import type { RequestInfo } from "../../../types/request.js";
|
|
3
3
|
import type { ExistingResourceIdentifierObject, ResourceIdentifierObject } from "../../../types/spec/json-api-raw.js";
|
|
4
4
|
import type { ForgetMethod, GenerationMethod, KeyInfo, KeyInfoMethod, ResetMethod, UpdateMethod } from "../../-types/q/identifier.js";
|
|
5
5
|
type TypeFromIdentifier<T> = T extends {
|
|
@@ -197,16 +197,34 @@ export declare class CacheKeyManager {
|
|
|
197
197
|
*
|
|
198
198
|
* @private
|
|
199
199
|
*/
|
|
200
|
-
|
|
200
|
+
peekResourceKey(resource: ResourceIdentifierObject): ResourceKey | undefined;
|
|
201
201
|
/**
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
@public
|
|
202
|
+
* Peeks the {@link RequestKey} for the given {@link RequestInfo}, but will not
|
|
203
|
+
* create one if none has been previously generated.
|
|
204
|
+
*
|
|
205
|
+
* @public
|
|
206
|
+
*/
|
|
207
|
+
peekRequestKey(request: RequestInfo): RequestKey | null;
|
|
208
|
+
/**
|
|
209
|
+
* Returns the {@link RequestKey} for the given {@link RequestInfo} if the request is
|
|
210
|
+
* considered cacheable. For cacheable requests, this method will create
|
|
211
|
+
* a RequestKey if none is found.
|
|
212
|
+
*
|
|
213
|
+
* A `null` response indicates the request cannot/will not be cached,
|
|
214
|
+
* generally this means either
|
|
215
|
+
*
|
|
216
|
+
* - {@link RequestInfo.cacheOptions.key} is not present on the `RequestInfo`
|
|
217
|
+
* - the request's method is `GET` but it has no `url`
|
|
218
|
+
*
|
|
219
|
+
* Generally you should not seek to cache requests that are not idempotent
|
|
220
|
+
* or have side effects, such as mutations that create, update or delete
|
|
221
|
+
* a resource.
|
|
222
|
+
*
|
|
223
|
+
* @public
|
|
206
224
|
*/
|
|
207
|
-
getOrCreateDocumentIdentifier(request:
|
|
225
|
+
getOrCreateDocumentIdentifier(request: RequestInfo): RequestKey | null;
|
|
208
226
|
/**
|
|
209
|
-
Returns the
|
|
227
|
+
Returns the {@link ResourceKey} for the given Resource, creates one if it does not yet exist.
|
|
210
228
|
|
|
211
229
|
Specifically this means that we:
|
|
212
230
|
|
|
@@ -6,7 +6,7 @@ import type { LocalRelationshipOperation } from "../../../types/graph.js";
|
|
|
6
6
|
import type { RequestKey, ResourceKey } from "../../../types/identifier.js";
|
|
7
7
|
import type { Value } from "../../../types/json/raw.js";
|
|
8
8
|
import type { StructuredDataDocument, StructuredDocument } from "../../../types/request.js";
|
|
9
|
-
import type { ResourceDocument, SingleResourceDataDocument } from "../../../types/spec/document.js";
|
|
9
|
+
import type { CollectionResourceDataDocument, ResourceDocument, SingleResourceDataDocument } from "../../../types/spec/document.js";
|
|
10
10
|
import type { ApiError } from "../../../types/spec/error.js";
|
|
11
11
|
import type { StoreRequestContext } from "../cache-handler/handler.js";
|
|
12
12
|
/**
|
|
@@ -48,8 +48,6 @@ export declare class CacheManager implements Cache {
|
|
|
48
48
|
* a `content` member and therefor must not assume the existence
|
|
49
49
|
* of `request` and `response` on the document.
|
|
50
50
|
*
|
|
51
|
-
* @param {StructuredDocument} doc
|
|
52
|
-
* @return {ResourceDocument}
|
|
53
51
|
* @public
|
|
54
52
|
*/
|
|
55
53
|
put<T>(doc: StructuredDocument<T> | {
|
|
@@ -60,7 +58,6 @@ export declare class CacheManager implements Cache {
|
|
|
60
58
|
*
|
|
61
59
|
* @public
|
|
62
60
|
* @param op the operation to perform
|
|
63
|
-
* @return {void}
|
|
64
61
|
*/
|
|
65
62
|
patch(op: Operation | Operation[]): void;
|
|
66
63
|
/**
|
|
@@ -68,7 +65,6 @@ export declare class CacheManager implements Cache {
|
|
|
68
65
|
* on relationships only.
|
|
69
66
|
*
|
|
70
67
|
* @public
|
|
71
|
-
* @param mutation
|
|
72
68
|
*/
|
|
73
69
|
mutate(mutation: LocalRelationshipOperation): void;
|
|
74
70
|
/**
|
|
@@ -99,8 +95,7 @@ export declare class CacheManager implements Cache {
|
|
|
99
95
|
* notifications for relational data.
|
|
100
96
|
*
|
|
101
97
|
* @public
|
|
102
|
-
* @
|
|
103
|
-
* @return {ResourceDocument | ResourceBlob | null} the known resource data
|
|
98
|
+
* @return the known resource data
|
|
104
99
|
*/
|
|
105
100
|
peek(cacheKey: ResourceKey): unknown;
|
|
106
101
|
peek(cacheKey: RequestKey): ResourceDocument | null;
|
|
@@ -110,8 +105,6 @@ export declare class CacheManager implements Cache {
|
|
|
110
105
|
* Peek the Cache for the existing request data associated with
|
|
111
106
|
* a cacheable request
|
|
112
107
|
*
|
|
113
|
-
* @param {RequestKey}
|
|
114
|
-
* @return {RequestKey | null}
|
|
115
108
|
* @public
|
|
116
109
|
*/
|
|
117
110
|
peekRequest(key: RequestKey): StructuredDocument<ResourceDocument> | null;
|
|
@@ -130,7 +123,6 @@ export declare class CacheManager implements Cache {
|
|
|
130
123
|
* utilize this method to fork the cache.
|
|
131
124
|
*
|
|
132
125
|
* @public
|
|
133
|
-
* @return {Promise<Cache>}
|
|
134
126
|
*/
|
|
135
127
|
fork(): Promise<Cache>;
|
|
136
128
|
/**
|
|
@@ -140,9 +132,7 @@ export declare class CacheManager implements Cache {
|
|
|
140
132
|
* preferring instead to merge at the Store level, which will
|
|
141
133
|
* utilize this method to merge the caches.
|
|
142
134
|
*
|
|
143
|
-
* @param {Cache} cache
|
|
144
135
|
* @public
|
|
145
|
-
* @return {Promise<void>}
|
|
146
136
|
*/
|
|
147
137
|
merge(cache: Cache): Promise<void>;
|
|
148
138
|
/**
|
|
@@ -183,7 +173,6 @@ export declare class CacheManager implements Cache {
|
|
|
183
173
|
* which may be fed back into a new instance of the same Cache
|
|
184
174
|
* via `cache.hydrate`.
|
|
185
175
|
*
|
|
186
|
-
* @return {Promise<ReadableStream>}
|
|
187
176
|
* @public
|
|
188
177
|
*/
|
|
189
178
|
dump(): Promise<ReadableStream<unknown>>;
|
|
@@ -199,8 +188,6 @@ export declare class CacheManager implements Cache {
|
|
|
199
188
|
* behavior supports optimizing pre/fetching of data for route transitions
|
|
200
189
|
* via data-only SSR modes.
|
|
201
190
|
*
|
|
202
|
-
* @param {ReadableStream} stream
|
|
203
|
-
* @return {Promise<void>}
|
|
204
191
|
* @public
|
|
205
192
|
*/
|
|
206
193
|
hydrate(stream: ReadableStream<unknown>): Promise<void>;
|
|
@@ -220,21 +207,23 @@ export declare class CacheManager implements Cache {
|
|
|
220
207
|
* @public
|
|
221
208
|
* @param key
|
|
222
209
|
*/
|
|
223
|
-
willCommit(key: ResourceKey, context: StoreRequestContext): void;
|
|
210
|
+
willCommit(key: ResourceKey | ResourceKey[], context: StoreRequestContext): void;
|
|
224
211
|
/**
|
|
225
212
|
* [LIFECYCLE] Signals to the cache that a resource
|
|
226
213
|
* was successfully updated as part of a save transaction.
|
|
227
214
|
*
|
|
228
215
|
* @public
|
|
229
216
|
*/
|
|
230
|
-
didCommit(key: ResourceKey, result: StructuredDataDocument<
|
|
217
|
+
didCommit(key: ResourceKey, result: StructuredDataDocument<SingleResourceDataDocument> | null): SingleResourceDataDocument;
|
|
218
|
+
didCommit(key: ResourceKey[], result: StructuredDataDocument<SingleResourceDataDocument> | null): SingleResourceDataDocument;
|
|
219
|
+
didCommit(key: ResourceKey[], result: StructuredDataDocument<CollectionResourceDataDocument> | null): CollectionResourceDataDocument;
|
|
231
220
|
/**
|
|
232
221
|
* [LIFECYCLE] Signals to the cache that a resource
|
|
233
222
|
* was update via a save transaction failed.
|
|
234
223
|
*
|
|
235
224
|
* @public
|
|
236
225
|
*/
|
|
237
|
-
commitWasRejected(key: ResourceKey, errors?: ApiError[]): void;
|
|
226
|
+
commitWasRejected(key: ResourceKey | ResourceKey[], errors?: ApiError[]): void;
|
|
238
227
|
/**
|
|
239
228
|
* [LIFECYCLE] Signals to the cache that all data for a resource
|
|
240
229
|
* should be cleared.
|
|
@@ -25,7 +25,7 @@ export interface DocumentOperationCallback {
|
|
|
25
25
|
* @hideconstructor
|
|
26
26
|
* @public
|
|
27
27
|
*/
|
|
28
|
-
export
|
|
28
|
+
export declare class NotificationManager {
|
|
29
29
|
constructor(store: Store);
|
|
30
30
|
/**
|
|
31
31
|
* Subscribe to changes for a given ResourceKey, RequestKey, or addition/removal of any resource
|
|
@@ -16,7 +16,7 @@ This class is not intended to be directly instantiated by consuming applications
|
|
|
16
16
|
|
|
17
17
|
### Inverses
|
|
18
18
|
|
|
19
|
-
Often, the relationships in
|
|
19
|
+
Often, the relationships in WarpDrive applications will have
|
|
20
20
|
an inverse. For example, imagine the following models are
|
|
21
21
|
defined:
|
|
22
22
|
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import type { ExtensionDef } from "../../../reactive.js";
|
|
2
2
|
import { Context } from "../../../reactive/-private.js";
|
|
3
|
+
import type { SignalStore, WarpDriveSignal } from "../../../signals/-private.js";
|
|
3
4
|
import type { RequestKey, ResourceKey } from "../../../types/identifier.js";
|
|
4
5
|
import type { ObjectValue } from "../../../types/json/raw.js";
|
|
5
6
|
import type { CollectionField } from "../../../types/schema/fields.js";
|
|
6
|
-
import type { SignalStore, WarpDriveSignal } from "../new-core-tmp/reactivity/internal.js";
|
|
7
7
|
import type { Store } from "../store-service.js";
|
|
8
8
|
import type { KeyType, MinimumManager } from "./-utils.js";
|
|
9
9
|
import { NativeProxy } from "./native-proxy-type-fix.js";
|
|
@@ -4,18 +4,18 @@ import type { PrivateRequestManager, RequestManager } from "../../request/-priva
|
|
|
4
4
|
import type { Cache } from "../../types/cache.js";
|
|
5
5
|
import type { PersistedResourceKey, ResourceKey } from "../../types/identifier.js";
|
|
6
6
|
import type { TypedRecordInstance, TypeFromInstance } from "../../types/record.js";
|
|
7
|
+
import type { SchemaService } from "../../types/schema/schema-service.js";
|
|
7
8
|
import type { CollectionResourceDocument, EmptyResourceDocument, JsonApiDocument, ResourceIdentifierObject, SingleResourceDocument } from "../../types/spec/json-api-raw.js";
|
|
8
9
|
import type { Type } from "../../types/symbols.js";
|
|
9
10
|
import type { CacheCapabilitiesManager } from "../-types/q/cache-capabilities-manager.js";
|
|
10
11
|
import type { OpaqueRecordInstance } from "../-types/q/record-instance.js";
|
|
11
|
-
import type { SchemaService } from "../-types/q/schema-service.js";
|
|
12
12
|
import type { StoreRequestInput } from "./cache-handler/handler.js";
|
|
13
13
|
import type { CachePolicy } from "./cache-handler/types.js";
|
|
14
14
|
import { InstanceCache, storeFor } from "./caches/instance-cache.js";
|
|
15
15
|
import type { PrivateCacheKeyManager } from "./managers/cache-key-manager.js";
|
|
16
16
|
import { CacheKeyManager } from "./managers/cache-key-manager.js";
|
|
17
17
|
import type { PrivateNotificationManager } from "./managers/notification-manager.js";
|
|
18
|
-
import NotificationManager from "./managers/notification-manager.js";
|
|
18
|
+
import { NotificationManager } from "./managers/notification-manager.js";
|
|
19
19
|
import type { PrivateRecordArrayManager } from "./managers/record-array-manager.js";
|
|
20
20
|
import type { PrivateRequestStateService } from "./network/request-cache.js";
|
|
21
21
|
import { RequestStateService } from "./network/request-cache.js";
|
|
@@ -101,7 +101,7 @@ export interface Store {
|
|
|
101
101
|
* For Example, to use the default SchemaService for ReactiveResource
|
|
102
102
|
*
|
|
103
103
|
* ```ts
|
|
104
|
-
* import { SchemaService } from '@warp-drive/
|
|
104
|
+
* import { SchemaService } from '@warp-drive/core/reactive';
|
|
105
105
|
*
|
|
106
106
|
* class extends Store {
|
|
107
107
|
* createSchemaService() {
|
|
@@ -110,10 +110,10 @@ export interface Store {
|
|
|
110
110
|
* }
|
|
111
111
|
* ```
|
|
112
112
|
*
|
|
113
|
-
* Or to use the SchemaService for @
|
|
113
|
+
* Or to use the SchemaService for @warp-drive/legacy/model
|
|
114
114
|
*
|
|
115
115
|
* ```ts
|
|
116
|
-
* import { buildSchema } from '@
|
|
116
|
+
* import { buildSchema } from '@warp-drive/legacy/model';
|
|
117
117
|
*
|
|
118
118
|
* class extends Store {
|
|
119
119
|
* createSchemaService() {
|
|
@@ -125,13 +125,13 @@ export interface Store {
|
|
|
125
125
|
* If you wish to chain services, you must either
|
|
126
126
|
* instantiate each schema source directly or super to retrieve
|
|
127
127
|
* an existing service. For convenience, when migrating from
|
|
128
|
-
* `@
|
|
128
|
+
* `@warp-drive/legacy/model` to {@link ReactiveResource} a
|
|
129
129
|
* SchemaService is provided that handles this transition
|
|
130
130
|
* for you:
|
|
131
131
|
*
|
|
132
132
|
* ```ts
|
|
133
|
-
* import { DelegatingSchemaService } from '@
|
|
134
|
-
* import { SchemaService } from '@warp-drive/
|
|
133
|
+
* import { DelegatingSchemaService } from '@warp-drive/legacy/model/migration-support';
|
|
134
|
+
* import { SchemaService } from '@warp-drive/core/reactive';
|
|
135
135
|
*
|
|
136
136
|
* class extends Store {
|
|
137
137
|
* createSchemaService() {
|
|
@@ -176,7 +176,7 @@ export interface Store {
|
|
|
176
176
|
* For Example:
|
|
177
177
|
*
|
|
178
178
|
* ```ts
|
|
179
|
-
* import Store from '@
|
|
179
|
+
* import { Store } from '@warp-drive/core';
|
|
180
180
|
*
|
|
181
181
|
* class SchemaDelegator {
|
|
182
182
|
* constructor(schema) {
|
|
@@ -210,7 +210,6 @@ export interface Store {
|
|
|
210
210
|
* }
|
|
211
211
|
* ```
|
|
212
212
|
*
|
|
213
|
-
* @param {SchemaService} schema
|
|
214
213
|
* @deprecated
|
|
215
214
|
* @public
|
|
216
215
|
*/
|
|
@@ -230,7 +229,7 @@ export interface Store {
|
|
|
230
229
|
* For Example:
|
|
231
230
|
*
|
|
232
231
|
* ```ts
|
|
233
|
-
* import Store from '@
|
|
232
|
+
* import { Store } from '@warp-drive/core';
|
|
234
233
|
*
|
|
235
234
|
* class SchemaDelegator {
|
|
236
235
|
* constructor(schema) {
|
|
@@ -264,7 +263,6 @@ export interface Store {
|
|
|
264
263
|
* }
|
|
265
264
|
* ```
|
|
266
265
|
*
|
|
267
|
-
* @param {SchemaService} schema
|
|
268
266
|
* @deprecated
|
|
269
267
|
* @public
|
|
270
268
|
*/
|
|
@@ -290,7 +288,7 @@ export interface Store {
|
|
|
290
288
|
*/
|
|
291
289
|
export declare class Store extends BaseClass {
|
|
292
290
|
/**
|
|
293
|
-
* Provides access to the NotificationManager associated
|
|
291
|
+
* Provides access to the {@link NotificationManager} associated
|
|
294
292
|
* with this Store instance.
|
|
295
293
|
*
|
|
296
294
|
* The NotificationManager can be used to subscribe to
|
|
@@ -321,20 +319,18 @@ export declare class Store extends BaseClass {
|
|
|
321
319
|
*/
|
|
322
320
|
readonly cacheKeyManager: CacheKeyManager;
|
|
323
321
|
/**
|
|
324
|
-
* Provides access to the
|
|
322
|
+
* Provides access to the {@link RequestManager} instance associated
|
|
325
323
|
* with this Store instance.
|
|
326
324
|
*
|
|
327
|
-
*
|
|
328
|
-
*
|
|
329
|
-
*
|
|
330
|
-
*
|
|
325
|
+
* See also:
|
|
326
|
+
* - {@link Fetch}
|
|
327
|
+
* - {@link CacheHandlerInterface | CacheHandler (Interface)}
|
|
328
|
+
* - {@link CacheHandler | CacheHandler (Class)}
|
|
331
329
|
*
|
|
332
330
|
* ```ts
|
|
333
|
-
* import
|
|
334
|
-
* import RequestManager from '@ember-data/request';
|
|
335
|
-
* import Fetch from '@ember-data/request/fetch';
|
|
331
|
+
* import { CacheHandler, Fetch, RequestManager, Store } from '@warp-drive/core';
|
|
336
332
|
*
|
|
337
|
-
* class extends Store {
|
|
333
|
+
* class AppStore extends Store {
|
|
338
334
|
* requestManager = new RequestManager()
|
|
339
335
|
* .use([Fetch])
|
|
340
336
|
* .useCache(CacheHandler);
|
|
@@ -350,9 +346,9 @@ export declare class Store extends BaseClass {
|
|
|
350
346
|
*
|
|
351
347
|
* Note, when defined, these methods will only be invoked if a
|
|
352
348
|
* cache key exists for the request, either because the request
|
|
353
|
-
* contains `cacheOptions.key` or because the
|
|
349
|
+
* contains `cacheOptions.key` or because the {@link CacheKeyManager}
|
|
354
350
|
* was able to generate a key for the request using the configured
|
|
355
|
-
*
|
|
351
|
+
* {@link setIdentifierGenerationMethod | generation method}.
|
|
356
352
|
*
|
|
357
353
|
* `isSoftExpired` will only be invoked if `isHardExpired` returns `false`.
|
|
358
354
|
*
|
|
@@ -557,14 +553,10 @@ export declare class Store extends BaseClass {
|
|
|
557
553
|
otherwise it will return `null`. A record is available if it has been fetched earlier, or
|
|
558
554
|
pushed manually into the store.
|
|
559
555
|
|
|
560
|
-
See [findRecord](../methods/findRecord?anchor=findRecord) if you would like to request this record from the backend.
|
|
561
|
-
|
|
562
|
-
_Note: This is a synchronous method and does not return a promise._
|
|
563
|
-
|
|
564
556
|
**Example 1**
|
|
565
557
|
|
|
566
|
-
```
|
|
567
|
-
|
|
558
|
+
```ts
|
|
559
|
+
const post = store.peekRecord('post', '1');
|
|
568
560
|
|
|
569
561
|
post.id; // '1'
|
|
570
562
|
```
|
|
@@ -575,8 +567,8 @@ export declare class Store extends BaseClass {
|
|
|
575
567
|
|
|
576
568
|
**Example 2**
|
|
577
569
|
|
|
578
|
-
```
|
|
579
|
-
|
|
570
|
+
```ts
|
|
571
|
+
const post = store.peekRecord({ type: 'post', id: '1' });
|
|
580
572
|
post.id; // '1'
|
|
581
573
|
```
|
|
582
574
|
|
|
@@ -590,40 +582,34 @@ export declare class Store extends BaseClass {
|
|
|
590
582
|
post.id; // '1'
|
|
591
583
|
```
|
|
592
584
|
|
|
593
|
-
|
|
594
585
|
@since 1.13.0
|
|
595
586
|
@public
|
|
596
|
-
@param
|
|
597
|
-
@param
|
|
598
|
-
@return {Model|null} record
|
|
587
|
+
@param type - either a string representing the modelName or a ResourceIdentifier object containing both the type (a string) and the id (a string) for the record or an lid (a string) of an existing record
|
|
588
|
+
@param id - optional only if the first param is a ResourceIdentifier, else the string id of the record to be retrieved.
|
|
599
589
|
*/
|
|
600
590
|
peekRecord<T>(type: TypeFromInstance<T>, id: string | number): T | null;
|
|
601
591
|
peekRecord(type: string, id: string | number): unknown | null;
|
|
602
592
|
peekRecord<T>(identifier: ResourceIdentifierObject<TypeFromInstance<T>>): T | null;
|
|
603
593
|
peekRecord(identifier: ResourceIdentifierObject): unknown | null;
|
|
604
594
|
/**
|
|
605
|
-
This method returns
|
|
606
|
-
known records for a given type in the store.
|
|
595
|
+
This method returns the {@link LegacyLiveArray} that contains all of the
|
|
596
|
+
known records for a given type in the store. Each ResourceType has only
|
|
597
|
+
one LiveArray instance, so multiple calls to `peekAll` with the same type
|
|
598
|
+
will always return the same instance.
|
|
607
599
|
|
|
608
|
-
Note that because it's
|
|
600
|
+
Note that because it's a LiveArray, the result will contain any
|
|
609
601
|
locally created records of the type, however, it will not make a
|
|
610
|
-
request to the backend to retrieve additional records.
|
|
611
|
-
would like to request all the records from the backend please use
|
|
612
|
-
[store.findAll](../methods/findAll?anchor=findAll).
|
|
613
|
-
|
|
614
|
-
Also note that multiple calls to `peekAll` for a given type will always
|
|
615
|
-
return the same `RecordArray`.
|
|
602
|
+
request to the backend to retrieve additional records.
|
|
616
603
|
|
|
617
604
|
Example
|
|
618
605
|
|
|
619
|
-
```
|
|
620
|
-
|
|
606
|
+
```ts
|
|
607
|
+
const allPosts = store.peekAll('post');
|
|
621
608
|
```
|
|
622
609
|
|
|
623
610
|
@since 1.13.0
|
|
624
611
|
@public
|
|
625
|
-
@param
|
|
626
|
-
@return {RecordArray}
|
|
612
|
+
@param type the name of the resource
|
|
627
613
|
*/
|
|
628
614
|
peekAll<T>(type: TypeFromInstance<T>): LegacyLiveArray<T>;
|
|
629
615
|
peekAll(type: string): LegacyLiveArray;
|
|
@@ -708,7 +694,7 @@ export declare class Store extends BaseClass {
|
|
|
708
694
|
For this model:
|
|
709
695
|
|
|
710
696
|
```js [app/models/person.js]
|
|
711
|
-
import Model, { attr, hasMany } from '@
|
|
697
|
+
import Model, { attr, hasMany } from '@warp-drive/legacy/model';
|
|
712
698
|
|
|
713
699
|
export default class PersonRoute extends Route {
|
|
714
700
|
@attr('string') firstName;
|
|
@@ -775,23 +761,17 @@ export declare class Store extends BaseClass {
|
|
|
775
761
|
}
|
|
776
762
|
```
|
|
777
763
|
|
|
778
|
-
If you're streaming data or implementing
|
|
779
|
-
that you have converted the incoming data into this form.
|
|
780
|
-
store's [normalize](../methods/normalize?anchor=normalize) method is a convenience
|
|
781
|
-
helper for converting a json payload into the form Ember Data
|
|
782
|
-
expects.
|
|
783
|
-
|
|
784
|
-
```js
|
|
785
|
-
store.push(store.normalize('person', data));
|
|
786
|
-
```
|
|
764
|
+
If you're streaming data, or implementing response handling, make sure
|
|
765
|
+
that you have converted the incoming data into this form.
|
|
787
766
|
|
|
788
767
|
This method can be used both to push in brand new
|
|
789
768
|
records, as well as to update existing records.
|
|
790
769
|
|
|
770
|
+
See also {@link Cache.patch}
|
|
771
|
+
|
|
791
772
|
@public
|
|
792
|
-
@param
|
|
793
|
-
@return the record(s) that
|
|
794
|
-
updated.
|
|
773
|
+
@param data
|
|
774
|
+
@return the primary record(s) that created or updated.
|
|
795
775
|
*/
|
|
796
776
|
push(data: EmptyResourceDocument): null;
|
|
797
777
|
push<T>(data: SingleResourceDocument<TypeFromInstance<T>>): T;
|
|
@@ -803,8 +783,7 @@ export declare class Store extends BaseClass {
|
|
|
803
783
|
without creating materialized records.
|
|
804
784
|
|
|
805
785
|
@private
|
|
806
|
-
@
|
|
807
|
-
@return {ResourceKey|Array<ResourceKey>|null} identifiers for the primary records that had data loaded
|
|
786
|
+
@return identifiers for the primary records that had data loaded
|
|
808
787
|
*/
|
|
809
788
|
_push(jsonApiDoc: JsonApiDocument, asyncFlush?: boolean): PersistedResourceKey | PersistedResourceKey[] | null;
|
|
810
789
|
/**
|
|
@@ -22,9 +22,3 @@ export { normalizeModelName as _deprecatingNormalize } from "./-private/utils/no
|
|
|
22
22
|
export type { StoreRequestInput } from "./-private/cache-handler/handler.js";
|
|
23
23
|
export { type LegacyManyArray, type LegacyManyArray as RelatedCollection, createLegacyManyArray } from "./-private/record-arrays/legacy-many-array.js";
|
|
24
24
|
export { log, logGroup } from "./-private/debug/utils.js";
|
|
25
|
-
export { getPromiseState, type PromiseState } from "./-private/new-core-tmp/promise-state.js";
|
|
26
|
-
export { DISPOSE, createRequestSubscription, type RequestArgs, type SubscriptionArgs, type RequestComponentArgs, type RequestSubscription, type ContentFeatures, type RecoveryFeatures, type AutorefreshBehaviorCombos, type AutorefreshBehaviorType } from "./-private/new-core-tmp/request-subscription.js";
|
|
27
|
-
export { getRequestState, type RequestLoadingState, type RequestCacheRequestState as RequestState } from "./-private/new-core-tmp/request-state.js";
|
|
28
|
-
export { type SignalHooks, waitFor } from "./-private/new-core-tmp/reactivity/configure.js";
|
|
29
|
-
export { signal, memoized, gate, entangleSignal, entangleInitiallyStaleSignal, defineSignal, defineGate, defineNonEnumerableSignal } from "./-private/new-core-tmp/reactivity/signal.js";
|
|
30
|
-
export { ARRAY_SIGNAL, OBJECT_SIGNAL, Signals, type WarpDriveSignal, peekInternalSignal, createInternalMemo, withSignalStore, notifyInternalSignal, consumeInternalSignal, getOrCreateInternalSignal } from "./-private/new-core-tmp/reactivity/internal.js";
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { RequestKey, ResourceKey } from "../../../types/identifier.js";
|
|
2
|
+
import type { SchemaService } from "../../../types/schema/schema-service.js";
|
|
2
3
|
import type { CacheKeyManager } from "../../-private/managers/cache-key-manager.js";
|
|
3
4
|
import type { NotificationType } from "../../-private/managers/notification-manager.js";
|
|
4
|
-
import type { SchemaService } from "./schema-service.js";
|
|
5
5
|
/**
|
|
6
6
|
* CacheCapabilitiesManager provides encapsulated API access to the minimal
|
|
7
7
|
* subset of the Store's functionality that Cache implementations
|
|
@@ -42,7 +42,7 @@ export type KeyOrString<T> = keyof T & string extends never ? string : keyof T &
|
|
|
42
42
|
* "model" class.
|
|
43
43
|
*
|
|
44
44
|
* Only used when using the legacy schema-service implementation
|
|
45
|
-
* for @
|
|
45
|
+
* for @warp-drive/legacy/model or when wrapping schema for legacy
|
|
46
46
|
* Adapters/Serializers.
|
|
47
47
|
*
|
|
48
48
|
*/
|
|
@@ -124,7 +124,7 @@ export declare class RecordReference {
|
|
|
124
124
|
normalized hash of data and the object represented by the reference
|
|
125
125
|
will update.
|
|
126
126
|
|
|
127
|
-
If you pass a promise to `push`,
|
|
127
|
+
If you pass a promise to `push`, WarpDrive will not ask the adapter
|
|
128
128
|
for the data if another attempt to fetch it is made in the
|
|
129
129
|
interim. When the promise resolves, the underlying object is updated
|
|
130
130
|
with the new data, and the promise returned by *this function* is resolved
|
|
@@ -248,13 +248,13 @@ declare module "../-private/store-service" {
|
|
|
248
248
|
}
|
|
249
249
|
```
|
|
250
250
|
|
|
251
|
-
See
|
|
251
|
+
See {@link Store.peekRecord | peekRecord} to get the cached version of a record.
|
|
252
252
|
|
|
253
253
|
### Retrieving Related Model Records
|
|
254
254
|
|
|
255
|
-
If you use an adapter such as
|
|
256
|
-
[
|
|
257
|
-
|
|
255
|
+
If you use an adapter such as the
|
|
256
|
+
[JSONAPIAdapter](/api/@warp-drive/legacy/adapter/json-api/classes/JSONAPIAdapter)
|
|
257
|
+
which supports the [{json:api} specification](http://jsonapi.org/) and if your server
|
|
258
258
|
endpoint supports the use of an
|
|
259
259
|
['include' query parameter](http://jsonapi.org/format/#fetching-includes),
|
|
260
260
|
you can use `findRecord()` or `findAll()` to automatically retrieve additional records related to
|
|
@@ -421,7 +421,7 @@ declare module "../-private/store-service" {
|
|
|
421
421
|
records in the store:
|
|
422
422
|
|
|
423
423
|
```js [app/adapters/application.js]
|
|
424
|
-
import Adapter from '@
|
|
424
|
+
import { Adapter } from '@warp-drive/legacy/adapter';
|
|
425
425
|
|
|
426
426
|
export default class ApplicationAdapter extends Adapter {
|
|
427
427
|
shouldReloadAll(store, snapshotsArray) {
|
|
@@ -498,13 +498,13 @@ declare module "../-private/store-service" {
|
|
|
498
498
|
}
|
|
499
499
|
```
|
|
500
500
|
|
|
501
|
-
See
|
|
501
|
+
See {@link Store.peekAll | peekAll} to get an array of current records in the
|
|
502
502
|
store, without waiting until a reload is finished.
|
|
503
503
|
|
|
504
504
|
### Retrieving Related Model Records
|
|
505
505
|
|
|
506
|
-
If you use an adapter such as
|
|
507
|
-
[
|
|
506
|
+
If you use an adapter such as the default
|
|
507
|
+
[JSONAPIAdapter](/api/@warp-drive/legacy/adapter/json-api/classes/JSONAPIAdapter)
|
|
508
508
|
that supports the [JSON API specification](http://jsonapi.org/) and if your server
|
|
509
509
|
endpoint supports the use of an
|
|
510
510
|
['include' query parameter](http://jsonapi.org/format/#fetching-includes),
|
|
@@ -535,7 +535,7 @@ declare module "../-private/store-service" {
|
|
|
535
535
|
}
|
|
536
536
|
```
|
|
537
537
|
|
|
538
|
-
See
|
|
538
|
+
See {@link Store.query | query} to only get a subset of records from the server.
|
|
539
539
|
|
|
540
540
|
@public
|
|
541
541
|
@deprecated use {@link Store.request} instead
|
|
@@ -575,7 +575,7 @@ declare module "../-private/store-service" {
|
|
|
575
575
|
|
|
576
576
|
If you do something like this:
|
|
577
577
|
|
|
578
|
-
```
|
|
578
|
+
```js
|
|
579
579
|
store.query('person', { ids: ['1', '2', '3'] });
|
|
580
580
|
```
|
|
581
581
|
|
|
@@ -602,7 +602,7 @@ declare module "../-private/store-service" {
|
|
|
602
602
|
query(type: string, query: LegacyResourceQuery, options?: QueryOptions): Promise<LegacyQueryArray>;
|
|
603
603
|
/**
|
|
604
604
|
This method makes a request for one record, where the `id` is not known
|
|
605
|
-
beforehand (if the `id` is known, use
|
|
605
|
+
beforehand (if the `id` is known, use {@link Store.findRecord | findRecord}
|
|
606
606
|
instead).
|
|
607
607
|
|
|
608
608
|
This method can be used when it is certain that the server will return a
|
|
@@ -611,37 +611,40 @@ declare module "../-private/store-service" {
|
|
|
611
611
|
Each time this method is called a new request is made through the adapter.
|
|
612
612
|
|
|
613
613
|
Let's assume our API provides an endpoint for the currently logged in user
|
|
614
|
-
via:
|
|
615
614
|
|
|
616
|
-
```
|
|
617
|
-
// GET /api/
|
|
615
|
+
```ts
|
|
616
|
+
// GET /api/user/me
|
|
618
617
|
{
|
|
619
|
-
|
|
620
|
-
|
|
618
|
+
data: {
|
|
619
|
+
type: 'user',
|
|
620
|
+
id: '1234',
|
|
621
|
+
attributes: {
|
|
621
622
|
username: 'admin'
|
|
622
623
|
}
|
|
623
624
|
}
|
|
625
|
+
}
|
|
624
626
|
```
|
|
625
627
|
|
|
626
628
|
Since the specific `id` of the `user` is not known beforehand, we can use
|
|
627
629
|
`queryRecord` to get the user:
|
|
628
630
|
|
|
629
|
-
```
|
|
630
|
-
store.queryRecord('user', {})
|
|
631
|
-
|
|
632
|
-
// do thing
|
|
633
|
-
});
|
|
631
|
+
```ts
|
|
632
|
+
const user = await store.queryRecord('user', { me: true });
|
|
633
|
+
user.username; // admin
|
|
634
634
|
```
|
|
635
635
|
|
|
636
636
|
The request is made through the adapters' `queryRecord`:
|
|
637
637
|
|
|
638
|
-
```
|
|
639
|
-
import Adapter from '@
|
|
640
|
-
import $ from 'jquery';
|
|
638
|
+
```ts [app/adapters/user.ts]
|
|
639
|
+
import Adapter from '@warp-drive/legacy/adapter';
|
|
641
640
|
|
|
642
641
|
export default class UserAdapter extends Adapter {
|
|
643
|
-
queryRecord(modelName, query) {
|
|
644
|
-
|
|
642
|
+
async queryRecord(modelName, query) {
|
|
643
|
+
if (query.me) {
|
|
644
|
+
const response = await fetch('/api/me');
|
|
645
|
+
return await response.json();
|
|
646
|
+
}
|
|
647
|
+
throw new Error('Unsupported query');
|
|
645
648
|
}
|
|
646
649
|
}
|
|
647
650
|
```
|
|
@@ -664,7 +667,7 @@ declare module "../-private/store-service" {
|
|
|
664
667
|
}
|
|
665
668
|
```
|
|
666
669
|
|
|
667
|
-
```
|
|
670
|
+
```js
|
|
668
671
|
store.query('user', { username: 'unique' }).then(function(users) {
|
|
669
672
|
return users.firstObject;
|
|
670
673
|
}).then(function(user) {
|
|
@@ -684,7 +687,7 @@ declare module "../-private/store-service" {
|
|
|
684
687
|
}
|
|
685
688
|
```
|
|
686
689
|
|
|
687
|
-
```
|
|
690
|
+
```js
|
|
688
691
|
store.queryRecord('user', { username: 'unique' }).then(function(user) {
|
|
689
692
|
// user is null
|
|
690
693
|
});
|
|
@@ -744,7 +747,7 @@ declare module "../-private/store-service" {
|
|
|
744
747
|
/**
|
|
745
748
|
Returns the schema for a particular resource type (modelName).
|
|
746
749
|
|
|
747
|
-
When used with Model
|
|
750
|
+
When used with [Model](/api/@warp-drive/legacy/model/classes/Model) the return is the model class,
|
|
748
751
|
but this is not guaranteed.
|
|
749
752
|
|
|
750
753
|
If looking to query attribute or relationship information it is
|
|
@@ -754,9 +757,7 @@ declare module "../-private/store-service" {
|
|
|
754
757
|
signatures.
|
|
755
758
|
|
|
756
759
|
The class of a model might be useful if you want to get a list of all the
|
|
757
|
-
relationship names of the model
|
|
758
|
-
[`relationshipNames`](/ember-data/release/classes/Model?anchor=relationshipNames)
|
|
759
|
-
for example.
|
|
760
|
+
relationship names of the model.
|
|
760
761
|
|
|
761
762
|
@public
|
|
762
763
|
@deprecated use {@link Store.schema} instead
|