@warp-drive/core 5.6.0-alpha.14 → 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 +8 -0
- 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 -58
- package/declarations/reactive/-private/schema.d.ts +256 -165
- package/declarations/reactive/-private/symbols.d.ts +27 -2
- 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 +155 -72
- 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 +261 -0
- package/declarations/store/-private/record-arrays/identifier-array.d.ts +125 -119
- package/declarations/store/-private/record-arrays/many-array.d.ts +180 -182
- 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 -27
- 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 -323
- 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 -1587
- 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/{configure-BgaZESRo.js → configure-B48bFHOl.js} +38 -2
- package/dist/configure.js +1 -1
- package/dist/graph/-private.js +2 -2
- package/dist/{handler-cHghx9Y9.js → handler-C2T-IyJK.js} +1 -1
- package/dist/index.js +3 -3
- package/dist/reactive/-private.js +1 -1
- package/dist/reactive.js +287 -101
- package/dist/{request-state-DgwTEXLU.js → request-state-CjLph1LP.js} +1030 -249
- package/dist/store/-private.js +3 -3
- package/dist/{symbols-BmDcn6hS.js → symbols-SIstXMLI.js} +3 -3
- package/dist/types/-private.js +1 -1
- package/dist/types/schema/fields.js +4 -4
- 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/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/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-BgaZESRo.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-cHghx9Y9.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-DgwTEXLU.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-BmDcn6hS.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,255 +1,277 @@
|
|
|
1
|
-
import type { Future } from
|
|
2
|
-
import type { ImmutableRequestInfo, ResponseInfo, StructuredErrorDocument } from
|
|
3
|
-
import type { PendingPromise, RejectedPromise, ResolvedPromise } from
|
|
1
|
+
import type { Future } from "../../../request.js";
|
|
2
|
+
import type { ImmutableRequestInfo, ResponseInfo, StructuredErrorDocument } from "../../../types/request.js";
|
|
3
|
+
import type { PendingPromise, RejectedPromise, ResolvedPromise } from "./promise-state.js";
|
|
4
4
|
/**
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
5
|
+
* Lazily consumes the stream of a request, providing a number of
|
|
6
|
+
* reactive properties that can be used to build UIs that respond
|
|
7
|
+
* to the progress of a request.
|
|
8
|
+
*
|
|
9
|
+
*/
|
|
10
10
|
export declare class RequestLoadingState {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
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
|
-
|
|
11
|
+
private _sizeHint;
|
|
12
|
+
private _bytesLoaded;
|
|
13
|
+
private _startTime;
|
|
14
|
+
private _endTime;
|
|
15
|
+
private _lastPacketTime;
|
|
16
|
+
private _isPending;
|
|
17
|
+
private _isStarted;
|
|
18
|
+
private _isComplete;
|
|
19
|
+
private _isCancelled;
|
|
20
|
+
private _isErrored;
|
|
21
|
+
private _error;
|
|
22
|
+
private _stream;
|
|
23
|
+
private _future;
|
|
24
|
+
private _triggered;
|
|
25
|
+
private _trigger;
|
|
26
|
+
promise: Promise<void> | null;
|
|
27
|
+
get isPending(): boolean;
|
|
28
|
+
get sizeHint(): number;
|
|
29
|
+
get stream(): ReadableStream | null;
|
|
30
|
+
get isStarted(): boolean;
|
|
31
|
+
get bytesLoaded(): number;
|
|
32
|
+
get startTime(): number;
|
|
33
|
+
get endTime(): number;
|
|
34
|
+
get lastPacketTime(): number;
|
|
35
|
+
get isComplete(): boolean;
|
|
36
|
+
get isCancelled(): boolean;
|
|
37
|
+
get isErrored(): boolean;
|
|
38
|
+
get error(): Error | null;
|
|
39
|
+
get elapsedTime(): number;
|
|
40
|
+
get completedRatio(): number;
|
|
41
|
+
get remainingRatio(): number;
|
|
42
|
+
get duration(): number;
|
|
43
|
+
get speed(): number;
|
|
44
|
+
constructor(future: Future<unknown>);
|
|
45
|
+
abort: () => void;
|
|
46
46
|
}
|
|
47
47
|
/**
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
48
|
+
* The state of a request in the "pending"
|
|
49
|
+
* state. This is the default initial state.
|
|
50
|
+
*
|
|
51
|
+
* Extends the {@link PendingPromise} interface.
|
|
52
|
+
*
|
|
53
|
+
*/
|
|
54
54
|
export interface PendingRequest extends PendingPromise {
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
55
|
+
/**
|
|
56
|
+
* Whether the request is cancelled.
|
|
57
|
+
*
|
|
58
|
+
*/
|
|
59
|
+
isCancelled: false;
|
|
60
|
+
loadingState: RequestLoadingState;
|
|
61
|
+
request: null;
|
|
62
|
+
response: null;
|
|
63
63
|
}
|
|
64
64
|
/**
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
export interface ResolvedRequest<
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
65
|
+
* The state of a request in the "fulfilled" state.
|
|
66
|
+
* This is the state of a request that has resolved
|
|
67
|
+
* successfully.
|
|
68
|
+
*
|
|
69
|
+
* Extends the {@link ResolvedPromise} interface.
|
|
70
|
+
*
|
|
71
|
+
*/
|
|
72
|
+
export interface ResolvedRequest<
|
|
73
|
+
RT,
|
|
74
|
+
T
|
|
75
|
+
> extends ResolvedPromise<RT> {
|
|
76
|
+
/**
|
|
77
|
+
* Whether the request is cancelled.
|
|
78
|
+
*
|
|
79
|
+
*/
|
|
80
|
+
isCancelled: false;
|
|
81
|
+
loadingState: RequestLoadingState;
|
|
82
|
+
request: ImmutableRequestInfo<RT, T> | null;
|
|
83
|
+
response: Response | ResponseInfo | null;
|
|
81
84
|
}
|
|
82
85
|
/**
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
export interface RejectedRequest<
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
86
|
+
* The state of a request in the "rejected" state.
|
|
87
|
+
* This is the state of a request that has rejected
|
|
88
|
+
* with an error.
|
|
89
|
+
*
|
|
90
|
+
* Extends the {@link RejectedPromise} interface.
|
|
91
|
+
*
|
|
92
|
+
*/
|
|
93
|
+
export interface RejectedRequest<
|
|
94
|
+
RT,
|
|
95
|
+
T,
|
|
96
|
+
E extends StructuredErrorDocument = StructuredErrorDocument
|
|
97
|
+
> extends RejectedPromise<E> {
|
|
98
|
+
/**
|
|
99
|
+
* Whether the request is cancelled.
|
|
100
|
+
*
|
|
101
|
+
*/
|
|
102
|
+
isCancelled: false;
|
|
103
|
+
loadingState: RequestLoadingState;
|
|
104
|
+
request: ImmutableRequestInfo<RT, T> | null;
|
|
105
|
+
response: Response | ResponseInfo | null;
|
|
99
106
|
}
|
|
100
107
|
/**
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
export interface CancelledRequest<
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
108
|
+
* The state of a request in the "cancelled" state.
|
|
109
|
+
* This is the state of a promise that has been
|
|
110
|
+
* cancelled.
|
|
111
|
+
*
|
|
112
|
+
*/
|
|
113
|
+
export interface CancelledRequest<
|
|
114
|
+
RT,
|
|
115
|
+
T,
|
|
116
|
+
E extends StructuredErrorDocument = StructuredErrorDocument
|
|
117
|
+
> {
|
|
118
|
+
/**
|
|
119
|
+
* The status of the request.
|
|
120
|
+
*
|
|
121
|
+
*/
|
|
122
|
+
status: "cancelled";
|
|
123
|
+
/**
|
|
124
|
+
* Whether the request is pending.
|
|
125
|
+
*
|
|
126
|
+
*/
|
|
127
|
+
isPending: false;
|
|
128
|
+
/**
|
|
129
|
+
* Whether the request is pending.
|
|
130
|
+
*
|
|
131
|
+
*/
|
|
132
|
+
isLoading: false;
|
|
133
|
+
/**
|
|
134
|
+
* Whether the request has resolved
|
|
135
|
+
* successfully.
|
|
136
|
+
*
|
|
137
|
+
*/
|
|
138
|
+
isSuccess: false;
|
|
139
|
+
/**
|
|
140
|
+
* Whether the request has rejected
|
|
141
|
+
* with an error.
|
|
142
|
+
*
|
|
143
|
+
*/
|
|
144
|
+
isError: true;
|
|
145
|
+
/**
|
|
146
|
+
* Once the request has resolved, this will
|
|
147
|
+
* be the value the request resolved to.
|
|
148
|
+
*
|
|
149
|
+
*/
|
|
150
|
+
value: null;
|
|
151
|
+
/**
|
|
152
|
+
* Once the request has resolved, this will
|
|
153
|
+
* be the value the request resolved to.
|
|
154
|
+
*
|
|
155
|
+
* @deprecated use `value` instead
|
|
156
|
+
*/
|
|
157
|
+
result: null;
|
|
158
|
+
/**
|
|
159
|
+
* Once the request has rejected, this will
|
|
160
|
+
* be the error the request rejected with.
|
|
161
|
+
*
|
|
162
|
+
*
|
|
163
|
+
* @deprecated use `reason` instead
|
|
164
|
+
*/
|
|
165
|
+
error: E;
|
|
166
|
+
/**
|
|
167
|
+
* Once the request has rejected, this will
|
|
168
|
+
* be the error the request rejected with.
|
|
169
|
+
*
|
|
170
|
+
*/
|
|
171
|
+
reason: E;
|
|
172
|
+
/**
|
|
173
|
+
* Whether the request is cancelled.
|
|
174
|
+
*
|
|
175
|
+
*/
|
|
176
|
+
isCancelled: true;
|
|
177
|
+
loadingState: RequestLoadingState;
|
|
178
|
+
request: ImmutableRequestInfo<RT, T> | null;
|
|
179
|
+
response: Response | ResponseInfo | null;
|
|
169
180
|
}
|
|
170
181
|
/**
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
export type RequestCacheRequestState<
|
|
203
|
-
|
|
182
|
+
* RequestState extends the concept of PromiseState to provide a reactive
|
|
183
|
+
* wrapper for a request `Future` which allows you write declarative code
|
|
184
|
+
* around a Future's control flow.
|
|
185
|
+
*
|
|
186
|
+
* It is useful in both Template and JavaScript contexts, allowing you
|
|
187
|
+
* to quickly derive behaviors and data from pending, error and success
|
|
188
|
+
* states.
|
|
189
|
+
*
|
|
190
|
+
* The key difference between a Promise and a Future is that Futures provide
|
|
191
|
+
* access to a stream of their content, the identity of the request (if any)
|
|
192
|
+
* as well as the ability to attempt to abort the request.
|
|
193
|
+
*
|
|
194
|
+
* ```ts
|
|
195
|
+
* interface Future<T> extends Promise<T>> {
|
|
196
|
+
* getStream(): Promise<ReadableStream>;
|
|
197
|
+
* abort(): void;
|
|
198
|
+
* lid: StableDocumentIdentifier | null;
|
|
199
|
+
* }
|
|
200
|
+
* ```
|
|
201
|
+
*
|
|
202
|
+
* These additional APIs allow us to craft even richer state experiences.
|
|
203
|
+
*
|
|
204
|
+
* To get the state of a request, use `getRequestState`.
|
|
205
|
+
*
|
|
206
|
+
* See also:
|
|
207
|
+
* - {@link PendingRequest}
|
|
208
|
+
* - {@link ResolvedRequest}
|
|
209
|
+
* - {@link RejectedRequest}
|
|
210
|
+
* - {@link CancelledRequest}
|
|
211
|
+
*
|
|
212
|
+
*/
|
|
213
|
+
export type RequestCacheRequestState<
|
|
214
|
+
RT = unknown,
|
|
215
|
+
T = unknown,
|
|
216
|
+
E extends StructuredErrorDocument = StructuredErrorDocument
|
|
217
|
+
> = PendingRequest | ResolvedRequest<RT, T> | RejectedRequest<RT, T, E> | CancelledRequest<RT, T, E>;
|
|
218
|
+
export declare function createRequestState<
|
|
219
|
+
RT,
|
|
220
|
+
T,
|
|
221
|
+
E
|
|
222
|
+
>(future: Future<RT>): Readonly<RequestCacheRequestState<RT, T, StructuredErrorDocument<E>>>;
|
|
204
223
|
/**
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
export declare function getRequestState<
|
|
255
|
-
|
|
224
|
+
* `getRequestState` can be used in both JavaScript and Template contexts.
|
|
225
|
+
*
|
|
226
|
+
* ```ts
|
|
227
|
+
* import { getRequestState } from '@warp-drive/ember';
|
|
228
|
+
*
|
|
229
|
+
* const state = getRequestState(future);
|
|
230
|
+
* ```
|
|
231
|
+
*
|
|
232
|
+
* For instance, we could write a getter on a component that updates whenever
|
|
233
|
+
* the request state advances or the future changes, by combining the function
|
|
234
|
+
* with the use of `@cached`
|
|
235
|
+
*
|
|
236
|
+
* ```ts
|
|
237
|
+
* class Component {
|
|
238
|
+
* @cached
|
|
239
|
+
* get title() {
|
|
240
|
+
* const state = getRequestState(this.args.request);
|
|
241
|
+
* if (state.isPending) {
|
|
242
|
+
* return 'loading...';
|
|
243
|
+
* }
|
|
244
|
+
* if (state.isError) { return null; }
|
|
245
|
+
* return state.result.title;
|
|
246
|
+
* }
|
|
247
|
+
* }
|
|
248
|
+
* ```
|
|
249
|
+
*
|
|
250
|
+
* Or in a template as a helper:
|
|
251
|
+
*
|
|
252
|
+
* ```gjs
|
|
253
|
+
* import { getRequestState } from '@warp-drive/ember';
|
|
254
|
+
*
|
|
255
|
+
* <template>
|
|
256
|
+
* {{#let (getRequestState @request) as |state|}}
|
|
257
|
+
* {{#if state.isPending}}
|
|
258
|
+
* <Spinner />
|
|
259
|
+
* {{else if state.isError}}
|
|
260
|
+
* <ErrorForm @error={{state.error}} />
|
|
261
|
+
* {{else}}
|
|
262
|
+
* <h1>{{state.result.title}}</h1>
|
|
263
|
+
* {{/if}}
|
|
264
|
+
* {{/let}}
|
|
265
|
+
* </template>
|
|
266
|
+
* ```
|
|
267
|
+
*
|
|
268
|
+
* If looking to use in a template, consider also the `<Request />` component
|
|
269
|
+
* which offers a numbe of additional capabilities for requests *beyond* what
|
|
270
|
+
* `RequestState` provides.
|
|
271
|
+
*
|
|
272
|
+
*/
|
|
273
|
+
export declare function getRequestState<
|
|
274
|
+
RT,
|
|
275
|
+
T,
|
|
276
|
+
E
|
|
277
|
+
>(future: Future<RT>): Readonly<RequestCacheRequestState<RT, T, StructuredErrorDocument<E>>>;
|