@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,32 +1,31 @@
|
|
|
1
|
-
import { type Context } from
|
|
1
|
+
import { type Context } from "./context.js";
|
|
2
2
|
interface FastbootRequest extends Request {
|
|
3
|
-
|
|
4
|
-
|
|
3
|
+
protocol: string;
|
|
4
|
+
host: string;
|
|
5
5
|
}
|
|
6
6
|
export interface FastBoot {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
7
|
+
require(moduleName: string): unknown;
|
|
8
|
+
isFastBoot: boolean;
|
|
9
|
+
request: FastbootRequest;
|
|
10
10
|
}
|
|
11
11
|
/**
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
12
|
+
* ```ts
|
|
13
|
+
* import { Fetch } from '@warp-drive/core';
|
|
14
|
+
* ```
|
|
15
|
+
*
|
|
16
|
+
* A basic Fetch Handler which converts a request into a
|
|
17
|
+
* `fetch` call presuming the response to be `json`.
|
|
18
|
+
*
|
|
19
|
+
* ```ts
|
|
20
|
+
* import { RequestManager, Fetch } from '@warp-drive/core';
|
|
21
|
+
*
|
|
22
|
+
* const manager = new RequestManager()
|
|
23
|
+
* .use([Fetch]);
|
|
24
|
+
* ```
|
|
25
|
+
*
|
|
26
|
+
* @public
|
|
27
|
+
*/
|
|
28
28
|
declare const Fetch: {
|
|
29
|
-
|
|
29
|
+
request<T>(context: Context): Promise<T>;
|
|
30
30
|
};
|
|
31
31
|
export { Fetch };
|
|
32
|
-
//# sourceMappingURL=fetch.d.ts.map
|
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
import { type StructuredDocument } from
|
|
2
|
-
import type { ContextOwner } from
|
|
3
|
-
import type { Deferred, DeferredFuture, Future } from
|
|
1
|
+
import { type StructuredDocument } from "../../types/request.js";
|
|
2
|
+
import type { ContextOwner } from "./context.js";
|
|
3
|
+
import type { Deferred, DeferredFuture, Future } from "./types.js";
|
|
4
4
|
export declare function isFuture<T>(maybe: unknown): maybe is Future<T>;
|
|
5
5
|
export declare function createDeferred<T>(): Deferred<T>;
|
|
6
6
|
export declare function upgradePromise<T>(promise: Promise<StructuredDocument<T>>, future: Future<T>): Future<T>;
|
|
7
7
|
export declare function createFuture<T>(owner: ContextOwner): DeferredFuture<T>;
|
|
8
|
-
//# sourceMappingURL=future.d.ts.map
|
|
@@ -1,160 +1,162 @@
|
|
|
1
|
-
import type { StableDocumentIdentifier } from
|
|
2
|
-
import type { RequestInfo } from
|
|
3
|
-
import type { CacheHandler, Future, GenericCreateArgs, Handler, ManagedRequestPriority } from
|
|
4
|
-
import { IS_CACHE_HANDLER } from
|
|
1
|
+
import type { StableDocumentIdentifier } from "../../types/identifier.js";
|
|
2
|
+
import type { RequestInfo } from "../../types/request.js";
|
|
3
|
+
import type { CacheHandler, Future, GenericCreateArgs, Handler, ManagedRequestPriority } from "./types.js";
|
|
4
|
+
import { IS_CACHE_HANDLER } from "./utils.js";
|
|
5
5
|
/**
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
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
|
-
|
|
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
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
6
|
+
* ## Import
|
|
7
|
+
*
|
|
8
|
+
* ```js
|
|
9
|
+
* import { RequestManager } from '@warp-drive/core';
|
|
10
|
+
* ```
|
|
11
|
+
*
|
|
12
|
+
* For complete usage guide see the [RequestManager Documentation](/guides/).
|
|
13
|
+
*
|
|
14
|
+
* ## How It Works
|
|
15
|
+
*
|
|
16
|
+
* ```ts
|
|
17
|
+
* interface RequestManager {
|
|
18
|
+
* request<T>(req: RequestInfo): Future<T>;
|
|
19
|
+
* }
|
|
20
|
+
* ```
|
|
21
|
+
*
|
|
22
|
+
* A RequestManager provides a request/response flow in which configured
|
|
23
|
+
* handlers are successively given the opportunity to handle, modify, or
|
|
24
|
+
* pass-along a request.
|
|
25
|
+
*
|
|
26
|
+
* <img src="/images/handlers-all-labeled.gif" alt="RequestManager Flow Animation" width="100%" />
|
|
27
|
+
*
|
|
28
|
+
* For example:
|
|
29
|
+
*
|
|
30
|
+
* ::: code-group
|
|
31
|
+
*
|
|
32
|
+
* ```ts [Setup.ts]
|
|
33
|
+
* import { RequestManager, Fetch } from '@warp-drive/core';
|
|
34
|
+
* import { AutoCompress } from '@warp-drive/utilities/handlers';
|
|
35
|
+
* import Auth from 'ember-simple-auth/handler';
|
|
36
|
+
*
|
|
37
|
+
* // ... create manager
|
|
38
|
+
* const manager = new RequestManager()
|
|
39
|
+
* .use([Auth, new AutoCompress(), Fetch]); // [!code focus]
|
|
40
|
+
* ```
|
|
41
|
+
*
|
|
42
|
+
* ```ts [Usage.ts]
|
|
43
|
+
* import Config from './config';
|
|
44
|
+
*
|
|
45
|
+
* const { apiUrl } = Config;
|
|
46
|
+
*
|
|
47
|
+
* // ... execute a request
|
|
48
|
+
* const response = await manager.request({
|
|
49
|
+
* url: `${apiUrl}/users`
|
|
50
|
+
* });
|
|
51
|
+
* ```
|
|
52
|
+
*
|
|
53
|
+
* :::
|
|
54
|
+
*
|
|
55
|
+
* ### Futures
|
|
56
|
+
*
|
|
57
|
+
* The return value of `manager.request` is a `Future`, which allows
|
|
58
|
+
* access to limited information about the request while it is still
|
|
59
|
+
* pending and fulfills with the final state when the request completes.
|
|
60
|
+
*
|
|
61
|
+
* A `Future` is cancellable via `abort`.
|
|
62
|
+
*
|
|
63
|
+
* Handlers may optionally expose a `ReadableStream` to the `Future` for
|
|
64
|
+
* streaming data; however, when doing so the future should not resolve
|
|
65
|
+
* until the response stream is fully read.
|
|
66
|
+
*
|
|
67
|
+
* ```ts
|
|
68
|
+
* interface Future<T> extends Promise<StructuredDocument<T>> {
|
|
69
|
+
* abort(): void;
|
|
70
|
+
*
|
|
71
|
+
* async getStream(): ReadableStream | null;
|
|
72
|
+
* }
|
|
73
|
+
* ```
|
|
74
|
+
*
|
|
75
|
+
* ### StructuredDocuments
|
|
76
|
+
*
|
|
77
|
+
* A Future resolves with a `StructuredDataDocument` or rejects with a `StructuredErrorDocument`.
|
|
78
|
+
*
|
|
79
|
+
* ```ts
|
|
80
|
+
* interface StructuredDataDocument<T> {
|
|
81
|
+
* request: ImmutableRequestInfo;
|
|
82
|
+
* response: ImmutableResponseInfo;
|
|
83
|
+
* content: T;
|
|
84
|
+
* }
|
|
85
|
+
* interface StructuredErrorDocument extends Error {
|
|
86
|
+
* request: ImmutableRequestInfo;
|
|
87
|
+
* response: ImmutableResponseInfo;
|
|
88
|
+
* error: string | object;
|
|
89
|
+
* }
|
|
90
|
+
* type StructuredDocument<T> = StructuredDataDocument<T> | StructuredErrorDocument;
|
|
91
|
+
* ```
|
|
92
|
+
*
|
|
93
|
+
* @class RequestManager
|
|
94
|
+
* @public
|
|
95
|
+
*/
|
|
96
96
|
export declare class RequestManager {
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
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
|
-
|
|
97
|
+
#private;
|
|
98
|
+
/** @internal */
|
|
99
|
+
_hasCacheHandler: boolean;
|
|
100
|
+
/**
|
|
101
|
+
* A map of pending requests from request.id to their
|
|
102
|
+
* associated CacheHandler promise.
|
|
103
|
+
*
|
|
104
|
+
* This queue is managed by the CacheHandler
|
|
105
|
+
*
|
|
106
|
+
* @internal
|
|
107
|
+
*/
|
|
108
|
+
_pending: Map<number, Promise<unknown>>;
|
|
109
|
+
/** @internal */
|
|
110
|
+
_deduped: Map<StableDocumentIdentifier, {
|
|
111
|
+
priority: ManagedRequestPriority;
|
|
112
|
+
promise: Promise<unknown>;
|
|
113
|
+
}>;
|
|
114
|
+
constructor(options?: GenericCreateArgs);
|
|
115
|
+
/**
|
|
116
|
+
* Register a handler to use for primary cache intercept.
|
|
117
|
+
*
|
|
118
|
+
* Only one such handler may exist. If using the same
|
|
119
|
+
* RequestManager as the Store instance the Store
|
|
120
|
+
* registers itself as a Cache handler.
|
|
121
|
+
*
|
|
122
|
+
* @public
|
|
123
|
+
*/
|
|
124
|
+
useCache(cacheHandler: CacheHandler & {
|
|
125
|
+
[IS_CACHE_HANDLER]?: true;
|
|
126
|
+
}): this;
|
|
127
|
+
/**
|
|
128
|
+
* Register handler(s) to use when a request is issued.
|
|
129
|
+
*
|
|
130
|
+
* Handlers will be invoked in the order they are registered.
|
|
131
|
+
* Each Handler is given the opportunity to handle the request,
|
|
132
|
+
* curry the request, or pass along a modified request.
|
|
133
|
+
*
|
|
134
|
+
* @public
|
|
135
|
+
* @param {Handler[]} newHandlers
|
|
136
|
+
* @return {ThisType}
|
|
137
|
+
*/
|
|
138
|
+
use(newHandlers: Handler[]): this;
|
|
139
|
+
/**
|
|
140
|
+
* Issue a Request.
|
|
141
|
+
*
|
|
142
|
+
* Returns a Future that fulfills with a StructuredDocument
|
|
143
|
+
*
|
|
144
|
+
* @public
|
|
145
|
+
* @param {RequestInfo} request
|
|
146
|
+
* @return {Future}
|
|
147
|
+
*/
|
|
148
|
+
request<
|
|
149
|
+
RT,
|
|
150
|
+
T = unknown
|
|
151
|
+
>(request: RequestInfo<RT, T>): Future<RT>;
|
|
152
|
+
/**
|
|
153
|
+
* This method exists so that the RequestManager can be created
|
|
154
|
+
* can be created by container/factory systems that expect to
|
|
155
|
+
* call a static `create` method to instantiate the class.
|
|
156
|
+
*
|
|
157
|
+
* Using `new RequestManager()` directly is preferred.
|
|
158
|
+
*
|
|
159
|
+
* @private
|
|
160
|
+
*/
|
|
161
|
+
static create(options?: GenericCreateArgs): RequestManager;
|
|
159
162
|
}
|
|
160
|
-
//# sourceMappingURL=manager.d.ts.map
|
|
@@ -1,20 +1,28 @@
|
|
|
1
|
-
export type CacheResult<
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
export type CacheResult<
|
|
2
|
+
T = unknown,
|
|
3
|
+
E = unknown
|
|
4
|
+
> = {
|
|
5
|
+
isError: true;
|
|
6
|
+
result: E;
|
|
4
7
|
} | {
|
|
5
|
-
|
|
6
|
-
|
|
8
|
+
isError: false;
|
|
9
|
+
result: T;
|
|
7
10
|
};
|
|
8
|
-
export type Awaitable<
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
11
|
+
export type Awaitable<
|
|
12
|
+
T = unknown,
|
|
13
|
+
E = unknown
|
|
14
|
+
> = {
|
|
15
|
+
then: (onFulfilled: (value: T) => unknown, onRejected: (reason: E) => unknown) => unknown;
|
|
16
|
+
catch: (onRejected: (reason: E) => unknown) => unknown;
|
|
17
|
+
finally: (onFinally: () => unknown) => unknown;
|
|
12
18
|
};
|
|
13
|
-
export declare const PromiseCache: WeakMap<Awaitable
|
|
14
|
-
export declare const RequestMap: Map<number, CacheResult
|
|
19
|
+
export declare const PromiseCache: WeakMap<Awaitable, CacheResult>;
|
|
20
|
+
export declare const RequestMap: Map<number, CacheResult>;
|
|
15
21
|
export declare function setRequestResult(requestId: number, result: CacheResult): void;
|
|
16
22
|
export declare function clearRequestResult(requestId: number): void;
|
|
17
23
|
export declare function getRequestResult(requestId: number): CacheResult | undefined;
|
|
18
24
|
export declare function setPromiseResult(promise: Promise<unknown> | Awaitable, result: CacheResult): void;
|
|
19
|
-
export declare function getPromiseResult<
|
|
20
|
-
|
|
25
|
+
export declare function getPromiseResult<
|
|
26
|
+
T,
|
|
27
|
+
E
|
|
28
|
+
>(promise: Promise<T> | Awaitable<T, E>): CacheResult<T, E> | undefined;
|