@warp-drive/core 5.6.0-alpha.15 → 5.6.0-alpha.17
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/declarations/build-config/babel-macros.d.ts +1 -2
- package/declarations/build-config/canary-features.d.ts +1 -2
- package/declarations/build-config/debugging.d.ts +1 -2
- package/declarations/build-config/deprecations.d.ts +1 -2
- package/declarations/build-config/env.d.ts +1 -2
- package/declarations/build-config/macros.d.ts +1 -2
- package/declarations/build-config.d.ts +1 -2
- package/declarations/configure.d.ts +6 -7
- package/declarations/graph/-private/-diff.d.ts +21 -22
- package/declarations/graph/-private/-edge-definition.d.ts +134 -135
- package/declarations/graph/-private/-state.d.ts +93 -7
- package/declarations/graph/-private/-utils.d.ts +18 -13
- package/declarations/graph/-private/coerce-id.d.ts +6 -1
- package/declarations/graph/-private/debug/assert-polymorphic-type.d.ts +15 -4
- package/declarations/graph/-private/edges/collection.d.ts +35 -36
- package/declarations/graph/-private/edges/implicit.d.ts +28 -29
- package/declarations/graph/-private/edges/resource.d.ts +19 -20
- package/declarations/graph/-private/graph.d.ts +83 -48
- package/declarations/graph/-private/normalize-link.d.ts +7 -2
- package/declarations/graph/-private/operations/add-to-related-records.d.ts +3 -4
- package/declarations/graph/-private/operations/merge-identifier.d.ts +2 -3
- package/declarations/graph/-private/operations/remove-from-related-records.d.ts +3 -4
- package/declarations/graph/-private/operations/replace-related-record.d.ts +2 -3
- package/declarations/graph/-private/operations/replace-related-records.d.ts +58 -4
- package/declarations/graph/-private/operations/update-relationship.d.ts +11 -9
- package/declarations/graph/-private.d.ts +9 -10
- package/declarations/index.d.ts +11 -12
- package/declarations/reactive/-private/document.d.ts +143 -144
- package/declarations/reactive/-private/fields/compute.d.ts +31 -28
- package/declarations/reactive/-private/fields/extension.d.ts +2 -3
- package/declarations/reactive/-private/fields/managed-array.d.ts +19 -20
- package/declarations/reactive/-private/fields/managed-object.d.ts +16 -16
- package/declarations/reactive/-private/fields/many-array-manager.d.ts +15 -16
- package/declarations/reactive/-private/hooks.d.ts +3 -4
- package/declarations/reactive/-private/record.d.ts +61 -59
- package/declarations/reactive/-private/schema.d.ts +242 -224
- package/declarations/reactive/-private/symbols.d.ts +26 -1
- package/declarations/reactive/-private.d.ts +1 -2
- package/declarations/reactive.d.ts +4 -5
- package/declarations/request/-private/context.d.ts +34 -35
- package/declarations/request/-private/debug.d.ts +2 -3
- package/declarations/request/-private/fetch.d.ts +23 -24
- package/declarations/request/-private/future.d.ts +3 -4
- package/declarations/request/-private/manager.d.ts +159 -157
- package/declarations/request/-private/promise-cache.d.ts +21 -13
- package/declarations/request/-private/types.d.ts +124 -124
- package/declarations/request/-private/utils.d.ts +8 -9
- package/declarations/request.d.ts +5 -6
- package/declarations/store/-private/cache-handler/handler.d.ts +57 -52
- package/declarations/store/-private/cache-handler/types.d.ts +95 -96
- package/declarations/store/-private/cache-handler/utils.d.ts +16 -16
- package/declarations/store/-private/caches/cache-utils.d.ts +7 -4
- package/declarations/store/-private/caches/identifier-cache.d.ts +234 -246
- package/declarations/store/-private/caches/instance-cache.d.ts +47 -47
- package/declarations/store/-private/caches/resource-utils.d.ts +3 -4
- package/declarations/store/-private/debug/utils.d.ts +6 -7
- package/declarations/store/-private/default-cache-policy.d.ts +362 -361
- package/declarations/store/-private/legacy-model-support/record-reference.d.ts +154 -159
- package/declarations/store/-private/legacy-model-support/shim-model-class.d.ts +14 -14
- package/declarations/store/-private/managers/cache-capabilities-manager.d.ts +21 -22
- package/declarations/store/-private/managers/cache-manager.d.ts +440 -425
- package/declarations/store/-private/managers/notification-manager.d.ts +88 -83
- package/declarations/store/-private/managers/record-array-manager.d.ts +89 -90
- package/declarations/store/-private/network/request-cache.d.ts +86 -83
- package/declarations/store/-private/new-core-tmp/promise-state.d.ts +252 -244
- package/declarations/store/-private/new-core-tmp/reactivity/configure.d.ts +154 -155
- package/declarations/store/-private/new-core-tmp/reactivity/internal.d.ts +148 -149
- package/declarations/store/-private/new-core-tmp/reactivity/signal.d.ts +28 -23
- package/declarations/store/-private/new-core-tmp/request-state.d.ts +263 -241
- package/declarations/store/-private/new-core-tmp/request-subscription.d.ts +253 -223
- package/declarations/store/-private/record-arrays/identifier-array.d.ts +125 -121
- package/declarations/store/-private/record-arrays/many-array.d.ts +180 -184
- package/declarations/store/-private/record-arrays/native-proxy-type-fix.d.ts +120 -110
- package/declarations/store/-private/store-service.d.ts +1594 -1586
- package/declarations/store/-private/utils/coerce-id.d.ts +6 -1
- package/declarations/store/-private/utils/construct-resource.d.ts +1 -2
- package/declarations/store/-private/utils/is-non-empty-string.d.ts +0 -1
- package/declarations/store/-private/utils/normalize-model-name.d.ts +0 -1
- package/declarations/store/-private/utils/uuid-polyfill.d.ts +0 -1
- package/declarations/store/-private.d.ts +31 -28
- package/declarations/store/-types/q/cache-capabilities-manager.d.ts +96 -97
- package/declarations/store/-types/q/ds-model.d.ts +17 -18
- package/declarations/store/-types/q/identifier.d.ts +11 -12
- package/declarations/store/-types/q/record-instance.d.ts +16 -17
- package/declarations/store/-types/q/schema-service.d.ts +346 -343
- package/declarations/store/-types/q/store.d.ts +25 -28
- package/declarations/store.d.ts +1 -2
- package/declarations/types/-private.d.ts +16 -8
- package/declarations/types/cache/aliases.d.ts +11 -1
- package/declarations/types/cache/change.d.ts +4 -5
- package/declarations/types/cache/mutations.d.ts +51 -28
- package/declarations/types/cache/operations.d.ts +60 -47
- package/declarations/types/cache/relationship.d.ts +11 -9
- package/declarations/types/cache.d.ts +495 -484
- package/declarations/types/graph.d.ts +31 -32
- package/declarations/types/identifier.d.ts +83 -82
- package/declarations/types/json/raw.d.ts +1 -2
- package/declarations/types/params.d.ts +4 -5
- package/declarations/types/record.d.ts +117 -76
- package/declarations/types/request.d.ts +289 -266
- package/declarations/types/runtime.d.ts +8 -9
- package/declarations/types/schema/concepts.d.ts +19 -13
- package/declarations/types/schema/fields.d.ts +1712 -1713
- package/declarations/types/schema/fields.type-test.d.ts +0 -1
- package/declarations/types/spec/document.d.ts +28 -22
- package/declarations/types/spec/error.d.ts +16 -17
- package/declarations/types/spec/json-api-raw.d.ts +102 -102
- package/declarations/types/symbols.d.ts +74 -75
- package/declarations/types/utils.d.ts +5 -5
- package/declarations/types.d.ts +10 -11
- package/declarations/utils/string.d.ts +43 -40
- package/dist/graph/-private.js +1 -1
- package/dist/{handler-D1C3Innj.js → handler-C2T-IyJK.js} +1 -1
- package/dist/index.js +2 -2
- package/dist/reactive/-private.js +1 -1
- package/dist/reactive.js +42 -73
- package/dist/{request-state-CCOJIj5i.js → request-state-CjLph1LP.js} +275 -261
- package/dist/store/-private.js +2 -2
- package/dist/{symbols-epHW0Vm9.js → symbols-SIstXMLI.js} +1 -1
- package/dist/types/-private.js +1 -1
- package/package.json +4 -4
- package/declarations/build-config/babel-macros.d.ts.map +0 -1
- package/declarations/build-config/canary-features.d.ts.map +0 -1
- package/declarations/build-config/debugging.d.ts.map +0 -1
- package/declarations/build-config/deprecations.d.ts.map +0 -1
- package/declarations/build-config/env.d.ts.map +0 -1
- package/declarations/build-config/macros.d.ts.map +0 -1
- package/declarations/build-config.d.ts.map +0 -1
- package/declarations/configure.d.ts.map +0 -1
- package/declarations/graph/-private/-diff.d.ts.map +0 -1
- package/declarations/graph/-private/-edge-definition.d.ts.map +0 -1
- package/declarations/graph/-private/-state.d.ts.map +0 -1
- package/declarations/graph/-private/-utils.d.ts.map +0 -1
- package/declarations/graph/-private/coerce-id.d.ts.map +0 -1
- package/declarations/graph/-private/debug/assert-polymorphic-type.d.ts.map +0 -1
- package/declarations/graph/-private/edges/collection.d.ts.map +0 -1
- package/declarations/graph/-private/edges/implicit.d.ts.map +0 -1
- package/declarations/graph/-private/edges/resource.d.ts.map +0 -1
- package/declarations/graph/-private/graph.d.ts.map +0 -1
- package/declarations/graph/-private/normalize-link.d.ts.map +0 -1
- package/declarations/graph/-private/operations/add-to-related-records.d.ts.map +0 -1
- package/declarations/graph/-private/operations/merge-identifier.d.ts.map +0 -1
- package/declarations/graph/-private/operations/remove-from-related-records.d.ts.map +0 -1
- package/declarations/graph/-private/operations/replace-related-record.d.ts.map +0 -1
- package/declarations/graph/-private/operations/replace-related-records.d.ts.map +0 -1
- package/declarations/graph/-private/operations/update-relationship.d.ts.map +0 -1
- package/declarations/graph/-private.d.ts.map +0 -1
- package/declarations/index.d.ts.map +0 -1
- package/declarations/reactive/-private/document.d.ts.map +0 -1
- package/declarations/reactive/-private/fields/compute.d.ts.map +0 -1
- package/declarations/reactive/-private/fields/extension.d.ts.map +0 -1
- package/declarations/reactive/-private/fields/managed-array.d.ts.map +0 -1
- package/declarations/reactive/-private/fields/managed-object.d.ts.map +0 -1
- package/declarations/reactive/-private/fields/many-array-manager.d.ts.map +0 -1
- package/declarations/reactive/-private/hooks.d.ts.map +0 -1
- package/declarations/reactive/-private/record.d.ts.map +0 -1
- package/declarations/reactive/-private/schema.d.ts.map +0 -1
- package/declarations/reactive/-private/symbols.d.ts.map +0 -1
- package/declarations/reactive/-private.d.ts.map +0 -1
- package/declarations/reactive.d.ts.map +0 -1
- package/declarations/request/-private/context.d.ts.map +0 -1
- package/declarations/request/-private/debug.d.ts.map +0 -1
- package/declarations/request/-private/fetch.d.ts.map +0 -1
- package/declarations/request/-private/future.d.ts.map +0 -1
- package/declarations/request/-private/manager.d.ts.map +0 -1
- package/declarations/request/-private/promise-cache.d.ts.map +0 -1
- package/declarations/request/-private/types.d.ts.map +0 -1
- package/declarations/request/-private/utils.d.ts.map +0 -1
- package/declarations/request.d.ts.map +0 -1
- package/declarations/store/-private/cache-handler/handler.d.ts.map +0 -1
- package/declarations/store/-private/cache-handler/types.d.ts.map +0 -1
- package/declarations/store/-private/cache-handler/utils.d.ts.map +0 -1
- package/declarations/store/-private/caches/cache-utils.d.ts.map +0 -1
- package/declarations/store/-private/caches/identifier-cache.d.ts.map +0 -1
- package/declarations/store/-private/caches/instance-cache.d.ts.map +0 -1
- package/declarations/store/-private/caches/resource-utils.d.ts.map +0 -1
- package/declarations/store/-private/debug/utils.d.ts.map +0 -1
- package/declarations/store/-private/default-cache-policy.d.ts.map +0 -1
- package/declarations/store/-private/legacy-model-support/record-reference.d.ts.map +0 -1
- package/declarations/store/-private/legacy-model-support/shim-model-class.d.ts.map +0 -1
- package/declarations/store/-private/managers/cache-capabilities-manager.d.ts.map +0 -1
- package/declarations/store/-private/managers/cache-manager.d.ts.map +0 -1
- package/declarations/store/-private/managers/notification-manager.d.ts.map +0 -1
- package/declarations/store/-private/managers/record-array-manager.d.ts.map +0 -1
- package/declarations/store/-private/network/request-cache.d.ts.map +0 -1
- package/declarations/store/-private/new-core-tmp/promise-state.d.ts.map +0 -1
- package/declarations/store/-private/new-core-tmp/reactivity/configure.d.ts.map +0 -1
- package/declarations/store/-private/new-core-tmp/reactivity/internal.d.ts.map +0 -1
- package/declarations/store/-private/new-core-tmp/reactivity/signal.d.ts.map +0 -1
- package/declarations/store/-private/new-core-tmp/request-state.d.ts.map +0 -1
- package/declarations/store/-private/new-core-tmp/request-subscription.d.ts.map +0 -1
- package/declarations/store/-private/record-arrays/identifier-array.d.ts.map +0 -1
- package/declarations/store/-private/record-arrays/many-array.d.ts.map +0 -1
- package/declarations/store/-private/record-arrays/native-proxy-type-fix.d.ts.map +0 -1
- package/declarations/store/-private/store-service.d.ts.map +0 -1
- package/declarations/store/-private/store-service.type-test.d.ts +0 -2
- package/declarations/store/-private/store-service.type-test.d.ts.map +0 -1
- package/declarations/store/-private/utils/coerce-id.d.ts.map +0 -1
- package/declarations/store/-private/utils/construct-resource.d.ts.map +0 -1
- package/declarations/store/-private/utils/is-non-empty-string.d.ts.map +0 -1
- package/declarations/store/-private/utils/normalize-model-name.d.ts.map +0 -1
- package/declarations/store/-private/utils/uuid-polyfill.d.ts.map +0 -1
- package/declarations/store/-private.d.ts.map +0 -1
- package/declarations/store/-types/q/cache-capabilities-manager.d.ts.map +0 -1
- package/declarations/store/-types/q/ds-model.d.ts.map +0 -1
- package/declarations/store/-types/q/identifier.d.ts.map +0 -1
- package/declarations/store/-types/q/promise-proxies.d.ts +0 -2
- package/declarations/store/-types/q/promise-proxies.d.ts.map +0 -1
- package/declarations/store/-types/q/record-data-json-api.d.ts +0 -31
- package/declarations/store/-types/q/record-data-json-api.d.ts.map +0 -1
- package/declarations/store/-types/q/record-instance.d.ts.map +0 -1
- package/declarations/store/-types/q/schema-service.d.ts.map +0 -1
- package/declarations/store/-types/q/store.d.ts.map +0 -1
- package/declarations/store.d.ts.map +0 -1
- package/declarations/types/-private.d.ts.map +0 -1
- package/declarations/types/cache/aliases.d.ts.map +0 -1
- package/declarations/types/cache/change.d.ts.map +0 -1
- package/declarations/types/cache/mutations.d.ts.map +0 -1
- package/declarations/types/cache/operations.d.ts.map +0 -1
- package/declarations/types/cache/relationship.d.ts.map +0 -1
- package/declarations/types/cache.d.ts.map +0 -1
- package/declarations/types/graph.d.ts.map +0 -1
- package/declarations/types/identifier.d.ts.map +0 -1
- package/declarations/types/json/raw.d.ts.map +0 -1
- package/declarations/types/params.d.ts.map +0 -1
- package/declarations/types/record.d.ts.map +0 -1
- package/declarations/types/record.type-test.d.ts +0 -2
- package/declarations/types/record.type-test.d.ts.map +0 -1
- package/declarations/types/request.d.ts.map +0 -1
- package/declarations/types/request.type-test.d.ts +0 -2
- package/declarations/types/request.type-test.d.ts.map +0 -1
- package/declarations/types/runtime.d.ts.map +0 -1
- package/declarations/types/schema/concepts.d.ts.map +0 -1
- package/declarations/types/schema/fields.d.ts.map +0 -1
- package/declarations/types/schema/fields.type-test.d.ts.map +0 -1
- package/declarations/types/spec/document.d.ts.map +0 -1
- package/declarations/types/spec/error.d.ts.map +0 -1
- package/declarations/types/spec/json-api-raw.d.ts.map +0 -1
- package/declarations/types/symbols.d.ts.map +0 -1
- package/declarations/types/utils.d.ts.map +0 -1
- package/declarations/types.d.ts.map +0 -1
- package/declarations/utils/string.d.ts.map +0 -1
- package/dist/build-config/babel-macros.js.map +0 -1
- package/dist/build-config/canary-features.js.map +0 -1
- package/dist/build-config/debugging.js.map +0 -1
- package/dist/build-config/deprecations.js.map +0 -1
- package/dist/build-config/env.js.map +0 -1
- package/dist/build-config/macros.js.map +0 -1
- package/dist/build-config.js.map +0 -1
- package/dist/configure-B48bFHOl.js.map +0 -1
- package/dist/configure.js.map +0 -1
- package/dist/context-COmAnXUQ.js.map +0 -1
- package/dist/graph/-private.js.map +0 -1
- package/dist/handler-D1C3Innj.js.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/reactive/-private.js.map +0 -1
- package/dist/reactive.js.map +0 -1
- package/dist/request-state-CCOJIj5i.js.map +0 -1
- package/dist/request.js.map +0 -1
- package/dist/store/-private.js.map +0 -1
- package/dist/store.js.map +0 -1
- package/dist/symbols-epHW0Vm9.js.map +0 -1
- package/dist/types/-private.js.map +0 -1
- package/dist/types/cache/aliases.js.map +0 -1
- package/dist/types/cache/change.js.map +0 -1
- package/dist/types/cache/mutations.js.map +0 -1
- package/dist/types/cache/operations.js.map +0 -1
- package/dist/types/cache/relationship.js.map +0 -1
- package/dist/types/cache.js.map +0 -1
- package/dist/types/graph.js.map +0 -1
- package/dist/types/identifier.js.map +0 -1
- package/dist/types/json/raw.js.map +0 -1
- package/dist/types/params.js.map +0 -1
- package/dist/types/record.js.map +0 -1
- package/dist/types/request.js.map +0 -1
- package/dist/types/runtime.js.map +0 -1
- package/dist/types/schema/concepts.js.map +0 -1
- package/dist/types/schema/fields.js.map +0 -1
- package/dist/types/schema/fields.type-test.js.map +0 -1
- package/dist/types/spec/document.js.map +0 -1
- package/dist/types/spec/error.js.map +0 -1
- package/dist/types/spec/json-api-raw.js.map +0 -1
- package/dist/types/symbols.js.map +0 -1
- package/dist/types/utils.js.map +0 -1
- package/dist/types.js.map +0 -1
- package/dist/utils/string.js.map +0 -1
|
@@ -1,90 +1,91 @@
|
|
|
1
|
-
|
|
2
|
-
import type {
|
|
1
|
+
/* eslint-disable no-irregular-whitespace */
|
|
2
|
+
import type { StableDocumentIdentifier } from "../../types/identifier.js";
|
|
3
|
+
import type { IS_FUTURE, RequestContext, RequestInfo, ResponseInfo, StructuredDataDocument } from "../../types/request.js";
|
|
3
4
|
export interface GodContext {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
5
|
+
controller: AbortController;
|
|
6
|
+
response: ResponseInfo | null;
|
|
7
|
+
stream: ReadableStream | Promise<ReadableStream | null> | null;
|
|
8
|
+
hasRequestedStream: boolean;
|
|
9
|
+
id: number;
|
|
10
|
+
identifier: StableDocumentIdentifier | null;
|
|
10
11
|
}
|
|
11
12
|
export type Deferred<T> = {
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
13
|
+
resolve(v: T): void;
|
|
14
|
+
reject(v: unknown): void;
|
|
15
|
+
promise: Promise<T>;
|
|
15
16
|
};
|
|
16
17
|
export type ManagedRequestPriority = {
|
|
17
|
-
|
|
18
|
+
blocking: boolean;
|
|
18
19
|
};
|
|
19
20
|
export type DeferredStream = {
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
21
|
+
resolve(v: ReadableStream | null): void;
|
|
22
|
+
reject(v: unknown): void;
|
|
23
|
+
promise: Promise<ReadableStream | null> & {
|
|
24
|
+
sizeHint?: number;
|
|
25
|
+
};
|
|
25
26
|
};
|
|
26
27
|
/**
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
28
|
+
* A Future is a {@link Promise} which resolves to a {@link StructuredDataDocument | StructuredDocument}
|
|
29
|
+
* while providing the ability to {@link Future.abort | abort} the underlying request, and
|
|
30
|
+
* {@link Future.getStream | access the response stream} before the outer promise resolves;
|
|
31
|
+
*
|
|
32
|
+
* @public
|
|
33
|
+
*/
|
|
33
34
|
export interface Future<T> extends Promise<StructuredDataDocument<T>> {
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
35
|
+
[IS_FUTURE]: true;
|
|
36
|
+
/**
|
|
37
|
+
* Cancel this request by firing the {@link AbortController}'s signal.
|
|
38
|
+
*
|
|
39
|
+
* @privateRemarks
|
|
40
|
+
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/AbortController/abort)
|
|
41
|
+
*
|
|
42
|
+
* @param reason optional reason for aborting the request
|
|
43
|
+
* @public
|
|
44
|
+
*/
|
|
45
|
+
abort(reason?: string): void;
|
|
46
|
+
/**
|
|
47
|
+
* Get the response stream, if any, once made available.
|
|
48
|
+
*
|
|
49
|
+
* @public
|
|
50
|
+
* @return {Promise<ReadableStream | null>}
|
|
51
|
+
*/
|
|
52
|
+
getStream(): Promise<ReadableStream | null>;
|
|
53
|
+
/**
|
|
54
|
+
* Run a callback when this request completes. Use sparingly,
|
|
55
|
+
* mostly useful for instrumentation and infrastructure.
|
|
56
|
+
*
|
|
57
|
+
* @param cb the callback to run
|
|
58
|
+
* @public
|
|
59
|
+
* @return {void}
|
|
60
|
+
*/
|
|
61
|
+
onFinalize(cb: () => void): void;
|
|
62
|
+
/**
|
|
63
|
+
* The identifier of the associated request, if any, as
|
|
64
|
+
* assigned by the CacheHandler.
|
|
65
|
+
*
|
|
66
|
+
* @property lid
|
|
67
|
+
* @type {StableDocumentIdentifier | null}
|
|
68
|
+
* @public
|
|
69
|
+
*/
|
|
70
|
+
lid: StableDocumentIdentifier | null;
|
|
71
|
+
/**
|
|
72
|
+
* The id of the associated request, if any, as assigned
|
|
73
|
+
* by the RequestManager
|
|
74
|
+
*
|
|
75
|
+
* @property id
|
|
76
|
+
* @type {Number}
|
|
77
|
+
* @public
|
|
78
|
+
*/
|
|
79
|
+
id: number;
|
|
79
80
|
}
|
|
80
81
|
export type DeferredFuture<T> = {
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
82
|
+
resolve(v: StructuredDataDocument<T>): void;
|
|
83
|
+
reject(v: unknown): void;
|
|
84
|
+
promise: Future<T>;
|
|
84
85
|
};
|
|
85
86
|
export type NextFn<P = unknown> = (req: RequestInfo) => Future<P>;
|
|
86
87
|
/**
|
|
87
|
-
|
|
88
|
+
* Requests are fulfilled by handlers. A handler receives the request context
|
|
88
89
|
as well as a `next` function with which to pass along a request to the next
|
|
89
90
|
handler if it so chooses.
|
|
90
91
|
|
|
@@ -98,7 +99,7 @@ that it can then compose how it sees fit with its own response.
|
|
|
98
99
|
type NextFn<P> = (req: RequestInfo) => Future<P>;
|
|
99
100
|
|
|
100
101
|
interface Handler {
|
|
101
|
-
|
|
102
|
+
async request<T>(context: RequestContext, next: NextFn<P>): T;
|
|
102
103
|
}
|
|
103
104
|
```
|
|
104
105
|
|
|
@@ -106,10 +107,10 @@ interface Handler {
|
|
|
106
107
|
|
|
107
108
|
```ts
|
|
108
109
|
interface RequestContext<T> {
|
|
109
|
-
|
|
110
|
+
readonly request: RequestInfo;
|
|
110
111
|
|
|
111
|
-
|
|
112
|
-
|
|
112
|
+
setStream(stream: ReadableStream | Promise<ReadableStream>): void;
|
|
113
|
+
setResponse(response: Response | ResponseInfo): void;
|
|
113
114
|
}
|
|
114
115
|
```
|
|
115
116
|
|
|
@@ -122,13 +123,13 @@ response content before passing along the chunk downstream.
|
|
|
122
123
|
|
|
123
124
|
```ts
|
|
124
125
|
const FetchHandler = {
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
126
|
+
async request(context) {
|
|
127
|
+
const response = await fetch(context.request);
|
|
128
|
+
context.setResponse(reponse);
|
|
129
|
+
context.setStream(response.clone().body);
|
|
129
130
|
|
|
130
|
-
|
|
131
|
-
|
|
131
|
+
return response.json();
|
|
132
|
+
}
|
|
132
133
|
}
|
|
133
134
|
```
|
|
134
135
|
|
|
@@ -139,13 +140,13 @@ const FetchHandler = {
|
|
|
139
140
|
For context, it helps to understand a few of the use-cases that RequestManager
|
|
140
141
|
is intended to allow.
|
|
141
142
|
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
143
|
+
- to manage and return streaming content (such as video files)
|
|
144
|
+
- to fulfill a request from multiple sources or by splitting one request into multiple requests
|
|
145
|
+
- for instance one API call for a user and another for the user's friends
|
|
146
|
+
- or e.g. fulfilling part of the request from one source (one API, in-memory, localStorage, IndexedDB etc.) and the rest from another source (a different API, a WebWorker, etc.)
|
|
147
|
+
- to coalesce multiple requests
|
|
148
|
+
- to decorate a request with additional info
|
|
149
|
+
- e.g. an Auth handler that ensures the correct tokens or headers or cookies are attached.
|
|
149
150
|
|
|
150
151
|
----
|
|
151
152
|
|
|
@@ -185,52 +186,51 @@ Request handlers are registered by configuring the manager via `use`
|
|
|
185
186
|
|
|
186
187
|
```ts
|
|
187
188
|
const manager = new RequestManager()
|
|
188
|
-
|
|
189
|
+
.use([Handler1, Handler2]);
|
|
189
190
|
```
|
|
190
191
|
|
|
191
192
|
Handlers will be invoked in the order they are registered ("fifo", first-in first-out), and may only be registered up until the first request is made. It is recommended but not required to register all handlers at one time in order to ensure explicitly visible handler ordering.
|
|
192
193
|
|
|
193
194
|
|
|
194
|
-
|
|
195
|
-
|
|
195
|
+
@class (Interface) Handler
|
|
196
|
+
@public
|
|
196
197
|
*/
|
|
197
198
|
export interface Handler {
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
199
|
+
/**
|
|
200
|
+
* Method to implement to handle requests. Receives the request
|
|
201
|
+
* context and a nextFn to call to pass-along the request to
|
|
202
|
+
* other handlers.
|
|
203
|
+
*
|
|
204
|
+
* @public
|
|
205
|
+
* @param context
|
|
206
|
+
* @param next
|
|
207
|
+
*/
|
|
208
|
+
request<T = unknown>(context: RequestContext, next: NextFn<T>): Promise<T | StructuredDataDocument<T>> | Future<T>;
|
|
208
209
|
}
|
|
209
210
|
/**
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
211
|
+
* The CacheHandler is identical to other handlers ecxept that it
|
|
212
|
+
* is allowed to return a value synchronously. This is useful for
|
|
213
|
+
* features like reducing microtask queueing when de-duping.
|
|
214
|
+
*
|
|
215
|
+
* A RequestManager may only have one CacheHandler, registered via
|
|
216
|
+
* `manager.useCache(CacheHandler)`.
|
|
217
|
+
*
|
|
218
|
+
* @class (Interface) CacheHandler
|
|
219
|
+
* @public
|
|
220
|
+
*/
|
|
220
221
|
export interface CacheHandler {
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
222
|
+
/**
|
|
223
|
+
* Method to implement to handle requests. Receives the request
|
|
224
|
+
* context and a nextFn to call to pass-along the request to
|
|
225
|
+
* other handlers.
|
|
226
|
+
*
|
|
227
|
+
* @public
|
|
228
|
+
* @param context
|
|
229
|
+
* @param next
|
|
230
|
+
*/
|
|
231
|
+
request<T = unknown>(context: RequestContext, next: NextFn<T>): Promise<T | StructuredDataDocument<T>> | Future<T> | T;
|
|
231
232
|
}
|
|
232
233
|
export interface RequestResponse<T> {
|
|
233
|
-
|
|
234
|
+
result: T;
|
|
234
235
|
}
|
|
235
236
|
export type GenericCreateArgs = Record<string | symbol, unknown>;
|
|
236
|
-
//# sourceMappingURL=types.d.ts.map
|
|
@@ -1,16 +1,15 @@
|
|
|
1
|
-
import type { RequestInfo, StructuredDataDocument } from
|
|
2
|
-
import { ContextOwner } from
|
|
3
|
-
import type { DeferredFuture, Future, GodContext, Handler } from
|
|
1
|
+
import type { RequestInfo, StructuredDataDocument } from "../../types/request.js";
|
|
2
|
+
import { ContextOwner } from "./context.js";
|
|
3
|
+
import type { DeferredFuture, Future, GodContext, Handler } from "./types.js";
|
|
4
4
|
export declare const IS_CACHE_HANDLER: "___(unique) Symbol(IS_CACHE_HANDLER)";
|
|
5
5
|
export declare function curryFuture<T>(owner: ContextOwner, inbound: Future<T>, outbound: DeferredFuture<T>): Future<T>;
|
|
6
6
|
export interface HttpErrorProps extends DOMException {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
7
|
+
code: number;
|
|
8
|
+
name: string;
|
|
9
|
+
status: number;
|
|
10
|
+
statusText: string;
|
|
11
|
+
isRequestError: boolean;
|
|
12
12
|
}
|
|
13
13
|
export declare function enhanceReason(reason?: string): DOMException;
|
|
14
14
|
export declare function handleOutcome<T>(owner: ContextOwner, inbound: Promise<T | StructuredDataDocument<T>>, outbound: DeferredFuture<T>): Future<T>;
|
|
15
15
|
export declare function executeNextHandler<T>(wares: Readonly<Handler[]>, request: RequestInfo, i: number, god: GodContext): Future<T>;
|
|
16
|
-
//# sourceMappingURL=utils.d.ts.map
|
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
export { createDeferred } from
|
|
2
|
-
export type { Future, Handler, CacheHandler, NextFn, Deferred, ManagedRequestPriority
|
|
3
|
-
export { setPromiseResult, getPromiseResult } from
|
|
4
|
-
export type { Awaitable } from
|
|
5
|
-
export type { Context } from
|
|
6
|
-
//# sourceMappingURL=request.d.ts.map
|
|
1
|
+
export { createDeferred } from "./request/-private/future.js";
|
|
2
|
+
export type { Future, Handler, CacheHandler, NextFn, Deferred, ManagedRequestPriority } from "./request/-private/types.js";
|
|
3
|
+
export { setPromiseResult, getPromiseResult } from "./request/-private/promise-cache.js";
|
|
4
|
+
export type { Awaitable } from "./request/-private/promise-cache.js";
|
|
5
|
+
export type { Context } from "./request/-private/context.js";
|
|
@@ -1,57 +1,62 @@
|
|
|
1
|
-
import type { CacheHandler as CacheHandlerType } from
|
|
2
|
-
import type { ImmutableRequestInfo, RequestContext } from
|
|
3
|
-
import type { ResourceIdentifierObject } from
|
|
4
|
-
import type { RequestSignature } from
|
|
5
|
-
import type { Store } from
|
|
6
|
-
export type LooseStoreRequestInfo<
|
|
7
|
-
|
|
8
|
-
|
|
1
|
+
import type { CacheHandler as CacheHandlerType } from "../../../request.js";
|
|
2
|
+
import type { ImmutableRequestInfo, RequestContext } from "../../../types/request.js";
|
|
3
|
+
import type { ResourceIdentifierObject } from "../../../types/spec/json-api-raw.js";
|
|
4
|
+
import type { RequestSignature } from "../../../types/symbols.js";
|
|
5
|
+
import type { Store } from "../store-service.js";
|
|
6
|
+
export type LooseStoreRequestInfo<
|
|
7
|
+
RT = unknown,
|
|
8
|
+
T = unknown
|
|
9
|
+
> = Omit<ImmutableRequestInfo<RT, T>, "records" | "headers" | typeof RequestSignature> & {
|
|
10
|
+
records?: ResourceIdentifierObject[];
|
|
11
|
+
headers?: Headers;
|
|
9
12
|
};
|
|
10
|
-
export type StoreRequestInput<
|
|
13
|
+
export type StoreRequestInput<
|
|
14
|
+
RT = unknown,
|
|
15
|
+
T = unknown
|
|
16
|
+
> = ImmutableRequestInfo<RT, T> | LooseStoreRequestInfo<RT, T>;
|
|
11
17
|
export interface StoreRequestContext extends RequestContext {
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
18
|
+
request: ImmutableRequestInfo & {
|
|
19
|
+
store: Store;
|
|
20
|
+
};
|
|
15
21
|
}
|
|
16
22
|
/**
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
23
|
+
* A CacheHandler that adds support for using an WarpDrive Cache with a RequestManager.
|
|
24
|
+
*
|
|
25
|
+
* This handler will only run when a request has supplied a `store` instance. Requests
|
|
26
|
+
* issued by the store via `store.request()` will automatically have the `store` instance
|
|
27
|
+
* attached to the request.
|
|
28
|
+
*
|
|
29
|
+
* ```ts
|
|
30
|
+
* requestManager.request({
|
|
31
|
+
* store: store,
|
|
32
|
+
* url: '/api/posts',
|
|
33
|
+
* method: 'GET'
|
|
34
|
+
* });
|
|
35
|
+
* ```
|
|
36
|
+
*
|
|
37
|
+
* When this handler elects to handle a request, it will return the raw `StructuredDocument`
|
|
38
|
+
* unless the request has `[EnableHydration]` set to `true`. In this case, the handler will
|
|
39
|
+
* return a `Document` instance that will automatically update the UI when the cache is updated
|
|
40
|
+
* in the future and will hydrate any identifiers in the StructuredDocument into Record instances.
|
|
41
|
+
*
|
|
42
|
+
* When issuing a request via the store, [EnableHydration] is automatically set to `true`. This
|
|
43
|
+
* means that if desired you can issue requests that utilize the cache without needing to also
|
|
44
|
+
* utilize Record instances if desired.
|
|
45
|
+
*
|
|
46
|
+
* Said differently, you could elect to issue all requests via a RequestManager, without ever using
|
|
47
|
+
* the store directly, by setting [EnableHydration] to `true` and providing a store instance. Not
|
|
48
|
+
* necessarily the most useful thing, but the decoupled nature of the RequestManager and incremental-feature
|
|
49
|
+
* approach of WarpDrive allows for this flexibility.
|
|
50
|
+
*
|
|
51
|
+
* ```ts
|
|
52
|
+
* import { EnableHydration } from '@warp-drive/core/types/request';
|
|
53
|
+
*
|
|
54
|
+
* requestManager.request({
|
|
55
|
+
* store: store,
|
|
56
|
+
* url: '/api/posts',
|
|
57
|
+
* method: 'GET',
|
|
58
|
+
* [EnableHydration]: true
|
|
59
|
+
* });
|
|
60
|
+
*
|
|
61
|
+
*/
|
|
56
62
|
export declare const CacheHandler: CacheHandlerType;
|
|
57
|
-
//# sourceMappingURL=handler.d.ts.map
|