@warp-drive-mirror/core 5.10.0-alpha.12 → 5.10.0-alpha.13
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +32 -0
- package/dist/{-private-CjK1Dmuh.js → -private-BpyvBYFj.js} +508 -144
- package/dist/-private-BpyvBYFj.js.map +1 -0
- package/dist/{unpkg/dev/-private-Dtj8O5W7.js → -private-CmNOwhK0.js} +3 -1
- package/dist/{-private-Dtj8O5W7.js.map → -private-CmNOwhK0.js.map} +1 -1
- package/dist/{aliases-BWYW5EhX.d.ts → aliases-BQmAxXmb.d.ts} +4 -1
- package/dist/aliases-BQmAxXmb.d.ts.map +1 -0
- package/dist/{change-C7kqv2kW.d.ts → change-DClXcHvr.d.ts} +4 -2
- package/dist/change-DClXcHvr.d.ts.map +1 -0
- package/dist/{concepts-DFldVwEM.d.ts → concepts-DzuY5M1K.d.ts} +14 -5
- package/dist/concepts-DzuY5M1K.d.ts.map +1 -0
- package/dist/{configure-B_F639tN.d.ts → configure-CjsojjiI.d.ts} +7 -1
- package/dist/configure-CjsojjiI.d.ts.map +1 -0
- package/dist/configure.d.ts +1 -1
- package/dist/configure.js +1 -1
- package/dist/{document-Ca4ZZBd9.d.ts → document-Ni8Ns26t.d.ts} +22 -4
- package/dist/document-Ni8Ns26t.d.ts.map +1 -0
- package/dist/{error-0uD6GkNX.d.ts → error-APuUdUGk.d.ts} +4 -2
- package/dist/error-APuUdUGk.d.ts.map +1 -0
- package/dist/{fields-CnlWuUd5.d.ts → fields-D6173Q_a.d.ts} +126 -5
- package/dist/fields-D6173Q_a.d.ts.map +1 -0
- package/dist/graph/-private.d.ts +1 -1
- package/dist/graph/-private.js +2 -0
- package/dist/graph/-private.js.map +1 -1
- package/dist/{graph-DLqYXP2z.d.ts → graph-rjTyJ-gd.d.ts} +25 -5
- package/dist/graph-rjTyJ-gd.d.ts.map +1 -0
- package/dist/{identifier-DQnqOSJK.d.ts → identifier-B_tK3FUw.d.ts} +29 -4
- package/dist/identifier-B_tK3FUw.d.ts.map +1 -0
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/{internal-DBnp5uP6.d.ts → internal-CgOlgOt3.d.ts} +496 -31
- package/dist/internal-CgOlgOt3.d.ts.map +1 -0
- package/dist/{json-api-raw-C5APJHHB.d.ts → json-api-raw-BxzNsCg0.d.ts} +44 -2
- package/dist/json-api-raw-BxzNsCg0.d.ts.map +1 -0
- package/dist/{mutations-CqtoGB4t.d.ts → mutations-C81gbYjB.d.ts} +18 -2
- package/dist/mutations-C81gbYjB.d.ts.map +1 -0
- package/dist/{operations-D1qA6r0_.d.ts → operations-B4pQM7D6.d.ts} +39 -5
- package/dist/operations-B4pQM7D6.d.ts.map +1 -0
- package/dist/{params-DrEx3bf8.d.ts → params-dbHiSOMF.d.ts} +11 -1
- package/dist/params-dbHiSOMF.d.ts.map +1 -0
- package/dist/{raw-D5hnjiq7.d.ts → raw-CiC64nCY.d.ts} +10 -1
- package/dist/raw-CiC64nCY.d.ts.map +1 -0
- package/dist/reactive/-private.d.ts +1 -1
- package/dist/reactive/-private.js +1 -1
- package/dist/reactive.d.ts +2 -2
- package/dist/reactive.js +3 -3
- package/dist/{record-D3QQcaIR.d.ts → record-DDxPtzcY.d.ts} +22 -2
- package/dist/record-DDxPtzcY.d.ts.map +1 -0
- package/dist/{relationship-CmHzMPKf.d.ts → relationship-BlGIXgj4.d.ts} +10 -3
- package/dist/relationship-BlGIXgj4.d.ts.map +1 -0
- package/dist/{request-Di274pQz.js → request-MiwUbGdT.js} +26 -1
- package/dist/request-MiwUbGdT.js.map +1 -0
- package/dist/request.d.ts +1 -1
- package/dist/request.js +1 -1
- package/dist/signals/-leaked.d.ts +86 -4
- package/dist/signals/-leaked.d.ts.map +1 -1
- package/dist/signals/-leaked.js +1 -1
- package/dist/{src-B9WcEdYg.js → src-DlNeupkA.js} +221 -20
- package/dist/src-DlNeupkA.js.map +1 -0
- package/dist/store/-private.d.ts +1 -1
- package/dist/store/-private.js +1 -1
- package/dist/{store-DNF9Rgoh.js → store-lcyaxrpj.js} +16 -1
- package/dist/store-lcyaxrpj.js.map +1 -0
- package/dist/store.d.ts +1 -1
- package/dist/store.js +1 -1
- package/dist/{symbols-DjRDCeX0.d.ts → symbols-Cu9un1NR.d.ts} +10 -1
- package/dist/symbols-Cu9un1NR.d.ts.map +1 -0
- package/dist/types/-private.js +1 -1
- package/dist/types/cache/aliases.d.ts +1 -1
- package/dist/types/cache/change.d.ts +1 -1
- package/dist/types/cache/mutations.d.ts +1 -1
- package/dist/types/cache/operations.d.ts +1 -1
- package/dist/types/cache/relationship.d.ts +1 -1
- package/dist/types/cache.d.ts +1 -1
- package/dist/types/graph.d.ts +1 -1
- package/dist/types/identifier.d.ts +1 -1
- package/dist/types/identifier.js +33 -3
- package/dist/types/identifier.js.map +1 -1
- package/dist/types/json/raw.d.ts +1 -1
- package/dist/types/params.d.ts +1 -1
- package/dist/types/record.d.ts +1 -1
- package/dist/types/record.js +25 -0
- package/dist/types/record.js.map +1 -1
- package/dist/types/request.d.ts +1 -1
- package/dist/types/request.js +80 -0
- package/dist/types/request.js.map +1 -1
- package/dist/types/runtime.d.ts.map +1 -1
- package/dist/types/schema/concepts.d.ts +1 -1
- package/dist/types/schema/fields.d.ts +1 -1
- package/dist/types/schema/fields.js +132 -3
- package/dist/types/schema/fields.js.map +1 -1
- package/dist/types/schema/schema-service.d.ts +1 -1
- package/dist/types/spec/document.d.ts +1 -1
- package/dist/types/spec/error.d.ts +1 -1
- package/dist/types/spec/json-api-raw.d.ts +1 -1
- package/dist/types/symbols.d.ts +1 -1
- package/dist/types/symbols.js +14 -0
- package/dist/types/symbols.js.map +1 -1
- package/dist/types/utils.d.ts +1 -1
- package/dist/types.d.ts +2 -2
- package/dist/unpkg/{dev-deprecated/-private-DrQgwtNS.js → dev/-private-BH4O810v.js} +508 -144
- package/dist/unpkg/dev/-private-BH4O810v.js.map +1 -0
- package/dist/{-private-Dtj8O5W7.js → unpkg/dev/-private-CmNOwhK0.js} +3 -1
- package/dist/unpkg/dev/{-private-Dtj8O5W7.js.map → -private-CmNOwhK0.js.map} +1 -1
- package/dist/unpkg/dev/configure.js +1 -1
- package/dist/unpkg/dev/graph/-private.js +2 -0
- package/dist/unpkg/dev/graph/-private.js.map +1 -1
- package/dist/unpkg/dev/index.js +1 -1
- package/dist/unpkg/dev/reactive/-private.js +1 -1
- package/dist/unpkg/dev/reactive.js +3 -3
- package/dist/unpkg/{dev-deprecated/request-nAaeDlS9.js → dev/request-Fe-vpe-u.js} +26 -1
- package/dist/unpkg/dev/request-Fe-vpe-u.js.map +1 -0
- package/dist/unpkg/dev/request.js +1 -1
- package/dist/unpkg/dev/signals/-leaked.js +1 -1
- package/dist/unpkg/dev/{src-CkkrRFE1.js → src-FSk0Z_Lp.js} +212 -13
- package/dist/unpkg/dev/src-FSk0Z_Lp.js.map +1 -0
- package/dist/unpkg/dev/store/-private.js +1 -1
- package/dist/unpkg/dev/{store-BIFNM_fB.js → store-BUV8Pfi7.js} +16 -1
- package/dist/unpkg/dev/store-BUV8Pfi7.js.map +1 -0
- package/dist/unpkg/dev/store.js +1 -1
- package/dist/unpkg/dev/types/-private.js +1 -1
- package/dist/unpkg/dev/types/identifier.js +33 -3
- package/dist/unpkg/dev/types/identifier.js.map +1 -1
- package/dist/unpkg/dev/types/record.js +25 -0
- package/dist/unpkg/dev/types/record.js.map +1 -1
- package/dist/unpkg/dev/types/request.js +80 -0
- package/dist/unpkg/dev/types/request.js.map +1 -1
- package/dist/unpkg/dev/types/schema/fields.js +132 -3
- package/dist/unpkg/dev/types/schema/fields.js.map +1 -1
- package/dist/unpkg/dev/types/symbols.js +14 -0
- package/dist/unpkg/dev/types/symbols.js.map +1 -1
- package/dist/unpkg/{dev/-private-DrQgwtNS.js → dev-deprecated/-private-BH4O810v.js} +508 -144
- package/dist/unpkg/dev-deprecated/-private-BH4O810v.js.map +1 -0
- package/dist/unpkg/{prod-deprecated/-private-Dtj8O5W7.js → dev-deprecated/-private-CmNOwhK0.js} +3 -1
- package/dist/unpkg/dev-deprecated/{-private-Dtj8O5W7.js.map → -private-CmNOwhK0.js.map} +1 -1
- package/dist/unpkg/dev-deprecated/configure.js +1 -1
- package/dist/unpkg/dev-deprecated/graph/-private.js +2 -0
- package/dist/unpkg/dev-deprecated/graph/-private.js.map +1 -1
- package/dist/unpkg/dev-deprecated/index.js +1 -1
- package/dist/unpkg/dev-deprecated/reactive/-private.js +1 -1
- package/dist/unpkg/dev-deprecated/reactive.js +3 -3
- package/dist/unpkg/{dev/request-nAaeDlS9.js → dev-deprecated/request-Fe-vpe-u.js} +26 -1
- package/dist/unpkg/dev-deprecated/request-Fe-vpe-u.js.map +1 -0
- package/dist/unpkg/dev-deprecated/request.js +1 -1
- package/dist/unpkg/dev-deprecated/signals/-leaked.js +1 -1
- package/dist/unpkg/dev-deprecated/{src-oz6OaQXu.js → src-Isk_Je7q.js} +214 -13
- package/dist/unpkg/dev-deprecated/src-Isk_Je7q.js.map +1 -0
- package/dist/unpkg/dev-deprecated/store/-private.js +1 -1
- package/dist/unpkg/dev-deprecated/{store-X1WN7P_O.js → store-CCZBSe0p.js} +16 -1
- package/dist/unpkg/dev-deprecated/store-CCZBSe0p.js.map +1 -0
- package/dist/unpkg/dev-deprecated/store.js +1 -1
- package/dist/unpkg/dev-deprecated/types/-private.js +1 -1
- package/dist/unpkg/dev-deprecated/types/identifier.js +33 -3
- package/dist/unpkg/dev-deprecated/types/identifier.js.map +1 -1
- package/dist/unpkg/dev-deprecated/types/record.js +25 -0
- package/dist/unpkg/dev-deprecated/types/record.js.map +1 -1
- package/dist/unpkg/dev-deprecated/types/request.js +80 -0
- package/dist/unpkg/dev-deprecated/types/request.js.map +1 -1
- package/dist/unpkg/dev-deprecated/types/schema/fields.js +132 -3
- package/dist/unpkg/dev-deprecated/types/schema/fields.js.map +1 -1
- package/dist/unpkg/dev-deprecated/types/symbols.js +14 -0
- package/dist/unpkg/dev-deprecated/types/symbols.js.map +1 -1
- package/dist/unpkg/prod/-private-CmNOwhK0.js +24 -0
- package/dist/unpkg/prod/{-private-Dtj8O5W7.js.map → -private-CmNOwhK0.js.map} +1 -1
- package/dist/unpkg/prod/{-private-Dg1vsF-H.js → -private-DKVDMUfT.js} +481 -138
- package/dist/unpkg/prod/-private-DKVDMUfT.js.map +1 -0
- package/dist/unpkg/prod/configure.js +1 -1
- package/dist/unpkg/prod/graph/-private.js +2 -0
- package/dist/unpkg/prod/graph/-private.js.map +1 -1
- package/dist/unpkg/prod/index.js +1 -1
- package/dist/unpkg/prod/reactive/-private.js +1 -1
- package/dist/unpkg/prod/reactive.js +3 -3
- package/dist/unpkg/prod/{request-DK7nNaAf.js → request-ndw2Fy91.js} +26 -1
- package/dist/unpkg/prod/request-ndw2Fy91.js.map +1 -0
- package/dist/unpkg/prod/request.js +1 -1
- package/dist/unpkg/prod/signals/-leaked.js +1 -1
- package/dist/unpkg/prod/{src-BGKCOL5L.js → src-CoSpuocQ.js} +212 -13
- package/dist/unpkg/prod/src-CoSpuocQ.js.map +1 -0
- package/dist/unpkg/prod/store/-private.js +1 -1
- package/dist/unpkg/{prod-deprecated/store-BWhmb7Ob.js → prod/store-CQOsqdST.js} +16 -1
- package/dist/unpkg/prod/store-CQOsqdST.js.map +1 -0
- package/dist/unpkg/prod/store.js +1 -1
- package/dist/unpkg/prod/types/-private.js +1 -1
- package/dist/unpkg/prod/types/identifier.js +33 -3
- package/dist/unpkg/prod/types/identifier.js.map +1 -1
- package/dist/unpkg/prod/types/record.js +25 -0
- package/dist/unpkg/prod/types/record.js.map +1 -1
- package/dist/unpkg/prod/types/request.js +80 -0
- package/dist/unpkg/prod/types/request.js.map +1 -1
- package/dist/unpkg/prod/types/schema/fields.js +132 -3
- package/dist/unpkg/prod/types/schema/fields.js.map +1 -1
- package/dist/unpkg/prod/types/symbols.js +14 -0
- package/dist/unpkg/prod/types/symbols.js.map +1 -1
- package/dist/unpkg/{dev-deprecated/-private-Dtj8O5W7.js → prod-deprecated/-private-CmNOwhK0.js} +3 -1
- package/dist/unpkg/prod-deprecated/{-private-Dtj8O5W7.js.map → -private-CmNOwhK0.js.map} +1 -1
- package/dist/unpkg/prod-deprecated/{-private-Dg1vsF-H.js → -private-DKVDMUfT.js} +481 -138
- package/dist/unpkg/prod-deprecated/-private-DKVDMUfT.js.map +1 -0
- package/dist/unpkg/prod-deprecated/configure.js +1 -1
- package/dist/unpkg/prod-deprecated/graph/-private.js +2 -0
- package/dist/unpkg/prod-deprecated/graph/-private.js.map +1 -1
- package/dist/unpkg/prod-deprecated/index.js +1 -1
- package/dist/unpkg/prod-deprecated/reactive/-private.js +1 -1
- package/dist/unpkg/prod-deprecated/reactive.js +3 -3
- package/dist/unpkg/prod-deprecated/{request-DK7nNaAf.js → request-ndw2Fy91.js} +26 -1
- package/dist/unpkg/prod-deprecated/request-ndw2Fy91.js.map +1 -0
- package/dist/unpkg/prod-deprecated/request.js +1 -1
- package/dist/unpkg/prod-deprecated/signals/-leaked.js +1 -1
- package/dist/unpkg/prod-deprecated/{src-CGypdIsf.js → src-FK_rMde5.js} +214 -13
- package/dist/unpkg/prod-deprecated/src-FK_rMde5.js.map +1 -0
- package/dist/unpkg/prod-deprecated/store/-private.js +1 -1
- package/dist/unpkg/{prod/store-BWhmb7Ob.js → prod-deprecated/store-CQOsqdST.js} +16 -1
- package/dist/unpkg/prod-deprecated/store-CQOsqdST.js.map +1 -0
- package/dist/unpkg/prod-deprecated/store.js +1 -1
- package/dist/unpkg/prod-deprecated/types/-private.js +1 -1
- package/dist/unpkg/prod-deprecated/types/identifier.js +33 -3
- package/dist/unpkg/prod-deprecated/types/identifier.js.map +1 -1
- package/dist/unpkg/prod-deprecated/types/record.js +25 -0
- package/dist/unpkg/prod-deprecated/types/record.js.map +1 -1
- package/dist/unpkg/prod-deprecated/types/request.js +80 -0
- package/dist/unpkg/prod-deprecated/types/request.js.map +1 -1
- package/dist/unpkg/prod-deprecated/types/schema/fields.js +132 -3
- package/dist/unpkg/prod-deprecated/types/schema/fields.js.map +1 -1
- package/dist/unpkg/prod-deprecated/types/symbols.js +14 -0
- package/dist/unpkg/prod-deprecated/types/symbols.js.map +1 -1
- package/dist/{utils-BtURiy8l.d.ts → utils-CNmQoKm8.d.ts} +8 -1
- package/dist/utils-CNmQoKm8.d.ts.map +1 -0
- package/package.json +5 -5
- package/dist/-private-CjK1Dmuh.js.map +0 -1
- package/dist/aliases-BWYW5EhX.d.ts.map +0 -1
- package/dist/change-C7kqv2kW.d.ts.map +0 -1
- package/dist/concepts-DFldVwEM.d.ts.map +0 -1
- package/dist/configure-B_F639tN.d.ts.map +0 -1
- package/dist/document-Ca4ZZBd9.d.ts.map +0 -1
- package/dist/error-0uD6GkNX.d.ts.map +0 -1
- package/dist/fields-CnlWuUd5.d.ts.map +0 -1
- package/dist/graph-DLqYXP2z.d.ts.map +0 -1
- package/dist/identifier-DQnqOSJK.d.ts.map +0 -1
- package/dist/internal-DBnp5uP6.d.ts.map +0 -1
- package/dist/json-api-raw-C5APJHHB.d.ts.map +0 -1
- package/dist/mutations-CqtoGB4t.d.ts.map +0 -1
- package/dist/operations-D1qA6r0_.d.ts.map +0 -1
- package/dist/params-DrEx3bf8.d.ts.map +0 -1
- package/dist/raw-D5hnjiq7.d.ts.map +0 -1
- package/dist/record-D3QQcaIR.d.ts.map +0 -1
- package/dist/relationship-CmHzMPKf.d.ts.map +0 -1
- package/dist/request-Di274pQz.js.map +0 -1
- package/dist/src-B9WcEdYg.js.map +0 -1
- package/dist/store-DNF9Rgoh.js.map +0 -1
- package/dist/symbols-DjRDCeX0.d.ts.map +0 -1
- package/dist/unpkg/dev/-private-DrQgwtNS.js.map +0 -1
- package/dist/unpkg/dev/request-nAaeDlS9.js.map +0 -1
- package/dist/unpkg/dev/src-CkkrRFE1.js.map +0 -1
- package/dist/unpkg/dev/store-BIFNM_fB.js.map +0 -1
- package/dist/unpkg/dev-deprecated/-private-DrQgwtNS.js.map +0 -1
- package/dist/unpkg/dev-deprecated/request-nAaeDlS9.js.map +0 -1
- package/dist/unpkg/dev-deprecated/src-oz6OaQXu.js.map +0 -1
- package/dist/unpkg/dev-deprecated/store-X1WN7P_O.js.map +0 -1
- package/dist/unpkg/prod/-private-Dg1vsF-H.js.map +0 -1
- package/dist/unpkg/prod/-private-Dtj8O5W7.js +0 -22
- package/dist/unpkg/prod/request-DK7nNaAf.js.map +0 -1
- package/dist/unpkg/prod/src-BGKCOL5L.js.map +0 -1
- package/dist/unpkg/prod/store-BWhmb7Ob.js.map +0 -1
- package/dist/unpkg/prod-deprecated/-private-Dg1vsF-H.js.map +0 -1
- package/dist/unpkg/prod-deprecated/request-DK7nNaAf.js.map +0 -1
- package/dist/unpkg/prod-deprecated/src-CGypdIsf.js.map +0 -1
- package/dist/unpkg/prod-deprecated/store-BWhmb7Ob.js.map +0 -1
- package/dist/utils-BtURiy8l.d.ts.map +0 -1
|
@@ -2,15 +2,26 @@ import { getOrSetGlobal, getOrSetUniversal } from "./-private.js";
|
|
|
2
2
|
|
|
3
3
|
//#region src/types/request.ts
|
|
4
4
|
/**
|
|
5
|
+
* @module
|
|
6
|
+
* @summary Types for requests and responses: `RequestInfo`, the request shapes builders return, cache options, the
|
|
7
|
+
* handler context and the documents a request's `Future` settles with.
|
|
8
|
+
*/
|
|
9
|
+
/**
|
|
5
10
|
* A {@link RequestInfo.cacheOptions | cacheOptions} flag which, when set,
|
|
6
11
|
* signals that a request should never be handled by the cache-manager and
|
|
7
12
|
* thus will never resolve from cache nor update the cache.
|
|
13
|
+
*
|
|
14
|
+
* @summary Symbol key for a request's `cacheOptions` that, when true, makes the request bypass the CacheHandler so it
|
|
15
|
+
* neither resolves from nor updates the cache.
|
|
8
16
|
*/
|
|
9
17
|
const SkipCache = getOrSetUniversal("SkipCache", Symbol.for("wd:skip-cache"));
|
|
10
18
|
/**
|
|
11
19
|
* A {@link RequestInfo} flag which, when set, signals to the store's
|
|
12
20
|
* `instantiateRecord` hook that the resolved content should be hydrated
|
|
13
21
|
* into reactive records rather than returned as raw data.
|
|
22
|
+
*
|
|
23
|
+
* @summary Symbol flag on a request that makes the CacheHandler return reactive records instead of raw cache
|
|
24
|
+
* documents; `store.request` sets it automatically.
|
|
14
25
|
*/
|
|
15
26
|
const EnableHydration = getOrSetUniversal("EnableHydration", Symbol.for("wd:enable-hydration"));
|
|
16
27
|
/**
|
|
@@ -23,61 +34,104 @@ const IS_FUTURE = getOrSetGlobal("IS_FUTURE", Symbol("IS_FUTURE"));
|
|
|
23
34
|
const STRUCTURED = getOrSetGlobal("DOC", Symbol("DOC"));
|
|
24
35
|
/**
|
|
25
36
|
* The HTTP methods WarpDrive's request layer supports.
|
|
37
|
+
*
|
|
38
|
+
* @summary Union of the HTTP method strings, including `QUERY`, that a WarpDrive request's `method` may be set to.
|
|
26
39
|
*/
|
|
27
40
|
/**
|
|
28
41
|
* Use these options to adjust {@link CacheHandler} behavior for a request
|
|
29
42
|
* via {@link RequestInfo.cacheOptions}.
|
|
30
43
|
*
|
|
44
|
+
* @summary Per-request settings on `cacheOptions` that control the cache key, forced or background reloads,
|
|
45
|
+
* invalidation by resource type, and cache bypass.
|
|
31
46
|
*/
|
|
32
47
|
/**
|
|
33
48
|
* The request shape produced by the `findRecord` request builders, for
|
|
34
49
|
* use with {@link Store.request}.
|
|
50
|
+
*
|
|
51
|
+
* @summary Shape of the `GET` request object that `findRecord` builders return for `store.request`, carrying the url,
|
|
52
|
+
* headers, and requested resource identifier.
|
|
35
53
|
*/
|
|
36
54
|
/**
|
|
37
55
|
* The request shape produced by the `query` request builders, for
|
|
38
56
|
* use with {@link Store.request}.
|
|
57
|
+
*
|
|
58
|
+
* @summary Shape of the `GET` request object that `query` builders return for `store.request`, carrying the url,
|
|
59
|
+
* headers, and cache options.
|
|
39
60
|
*/
|
|
40
61
|
/**
|
|
41
62
|
* The request shape produced by the `postQuery` request builders, for
|
|
42
63
|
* use with {@link Store.request}.
|
|
64
|
+
*
|
|
65
|
+
* @summary Shape of the `POST` or `QUERY` request object that `postQuery` builders return, with a body and a required
|
|
66
|
+
* cache key since the url cannot serve as one.
|
|
43
67
|
*/
|
|
44
68
|
/**
|
|
45
69
|
* The request shape produced by the `deleteRecord` request builders, for
|
|
46
70
|
* use with {@link Store.request}.
|
|
71
|
+
*
|
|
72
|
+
* @summary Shape of the `DELETE` request object that `deleteRecord` builders return for `store.request`, identifying
|
|
73
|
+
* the resource being deleted.
|
|
47
74
|
*/
|
|
48
75
|
/**
|
|
49
76
|
* The request shape produced by the `updateRecord` request builders, for
|
|
50
77
|
* use with {@link Store.request}.
|
|
78
|
+
*
|
|
79
|
+
* @summary Shape of the `PATCH` or `PUT` request object that `updateRecord` builders return for `store.request`,
|
|
80
|
+
* identifying the resource being saved.
|
|
51
81
|
*/
|
|
52
82
|
/**
|
|
53
83
|
* The request shape produced by the `createRecord` request builders, for
|
|
54
84
|
* use with {@link Store.request}.
|
|
85
|
+
*
|
|
86
|
+
* @summary Shape of the `POST` request object that `createRecord` builders return for `store.request`, identifying the
|
|
87
|
+
* new resource being saved.
|
|
55
88
|
*/
|
|
56
89
|
/**
|
|
57
90
|
* The immutable, handler-facing form of {@link DeleteRequestOptions}.
|
|
91
|
+
*
|
|
92
|
+
* @summary Read-only view of a `deleteRecord` request as a handler receives it, with immutable headers and `records`
|
|
93
|
+
* as resource keys.
|
|
58
94
|
*/
|
|
59
95
|
/**
|
|
60
96
|
* The immutable, handler-facing form of {@link UpdateRequestOptions}.
|
|
97
|
+
*
|
|
98
|
+
* @summary Read-only view of an `updateRecord` request as a handler receives it, with immutable headers and `records`
|
|
99
|
+
* as resource keys.
|
|
61
100
|
*/
|
|
62
101
|
/**
|
|
63
102
|
* The immutable, handler-facing form of {@link CreateRequestOptions}.
|
|
103
|
+
*
|
|
104
|
+
* @summary Read-only view of a `createRecord` request as a handler receives it, with immutable headers and `records`
|
|
105
|
+
* as resource keys.
|
|
64
106
|
*/
|
|
65
107
|
/**
|
|
66
108
|
* A minimal reference to a resource sufficient to build a URL for it,
|
|
67
109
|
* as accepted by the request builders.
|
|
110
|
+
*
|
|
111
|
+
* @summary A resource reference with a persisted `id` and `type` and an optional `lid`, which is enough for request
|
|
112
|
+
* builders to construct its url.
|
|
68
113
|
*/
|
|
69
114
|
/**
|
|
70
115
|
* Options accepted by the request builders for constraining how a
|
|
71
116
|
* request's url is constructed and how the request interacts with the cache.
|
|
117
|
+
*
|
|
118
|
+
* @summary Options the request builders accept to set reload behavior and override the url's host, namespace, resource
|
|
119
|
+
* path, and query param serialization.
|
|
72
120
|
*/
|
|
73
121
|
/**
|
|
74
122
|
* Options accepted by the `findRecord` request builders.
|
|
123
|
+
*
|
|
124
|
+
* @summary Options the `findRecord` request builders accept: the shared url and reload options plus the relationship
|
|
125
|
+
* paths to `include`.
|
|
75
126
|
*/
|
|
76
127
|
/**
|
|
77
128
|
* When a {@link Future} resolves, it returns an object
|
|
78
129
|
* containing the original {@link RequestInfo | request},
|
|
79
130
|
* the {@link Response | response} set by the handler chain (if any), and
|
|
80
131
|
* the processed content.
|
|
132
|
+
*
|
|
133
|
+
* @summary The `{ request, response, content }` object that a request's `Future` resolves with when the request
|
|
134
|
+
* succeeds.
|
|
81
135
|
*/
|
|
82
136
|
/**
|
|
83
137
|
* When a {@link Future} rejects, it throws either an {@link Error}
|
|
@@ -87,16 +141,24 @@ const STRUCTURED = getOrSetGlobal("DOC", Symbol("DOC"));
|
|
|
87
141
|
*
|
|
88
142
|
* If using the error originates from the {@link Fetch | Fetch Handler}
|
|
89
143
|
* the error will be a {@link FetchError}
|
|
144
|
+
*
|
|
145
|
+
* @summary The Error a request's `Future` rejects with when the request fails, carrying the `request`, `response`,
|
|
146
|
+
* `error`, and any `content` received.
|
|
90
147
|
*/
|
|
91
148
|
/**
|
|
92
149
|
* A union of the resolve/reject data types for the {@link Future}
|
|
93
150
|
* returned by {@link Store.request | request}
|
|
94
151
|
*
|
|
152
|
+
* The [Using The Response](/guides/the-manual/requests/using-the-response) guide shows
|
|
153
|
+
* how to read one.
|
|
154
|
+
*
|
|
95
155
|
* See also the docs for:
|
|
96
156
|
*
|
|
97
157
|
* - {@link Future}
|
|
98
158
|
* - {@link StructuredDataDocument} (resolved/successful requests)
|
|
99
159
|
* - {@link StructuredErrorDocument} (rejected/failed requests)
|
|
160
|
+
*
|
|
161
|
+
* @summary Union of the success and error documents that a request's `Future` resolves or rejects with.
|
|
100
162
|
*/
|
|
101
163
|
/**
|
|
102
164
|
* The {@link RequestInit} interface accepted by the native {@link fetch} API.
|
|
@@ -112,6 +174,9 @@ const STRUCTURED = getOrSetGlobal("DOC", Symbol("DOC"));
|
|
|
112
174
|
/**
|
|
113
175
|
* A read-only {@link Headers} instance, as passed to {@link Handler | Handlers}
|
|
114
176
|
* via {@link ImmutableRequestInfo.headers}.
|
|
177
|
+
*
|
|
178
|
+
* @summary Read-only `Headers` that handlers see on a request, adding `toJSON` to serialize them as `[key, value]`
|
|
179
|
+
* pairs and an optional mutable `clone`.
|
|
115
180
|
*/
|
|
116
181
|
/**
|
|
117
182
|
* Extends JavaScript's native {@link fetch} {@link NativeRequestInit | RequestInit} with additional
|
|
@@ -120,6 +185,11 @@ const STRUCTURED = getOrSetGlobal("DOC", Symbol("DOC"));
|
|
|
120
185
|
* This interface is used to define the shape of a request that can be made via
|
|
121
186
|
* either the {@link RequestManager.request} or {@link Store.request} methods.
|
|
122
187
|
*
|
|
188
|
+
* The [Making Requests](/guides/the-manual/requests/#request-options) guide explains
|
|
189
|
+
* its options.
|
|
190
|
+
*
|
|
191
|
+
* @summary Describes a request for `store.request` or `RequestManager.request`: native fetch options plus cache
|
|
192
|
+
* options, operation name, records, data, and the store.
|
|
123
193
|
* @privateRemarks
|
|
124
194
|
* - [MDN Reference (fetch)](https://developer.mozilla.org/docs/Web/API/Window/fetch)
|
|
125
195
|
* - [MDN Reference (RequestInit)](https://developer.mozilla.org/en-US/docs/Web/API/RequestInit)
|
|
@@ -131,15 +201,25 @@ const STRUCTURED = getOrSetGlobal("DOC", Symbol("DOC"));
|
|
|
131
201
|
/**
|
|
132
202
|
* Immutable version of {@link RequestInfo}. This is what is passed to handlers.
|
|
133
203
|
*
|
|
204
|
+
* @summary Read-only form of a request as handlers receive it, with frozen headers, data, options, and cache options
|
|
205
|
+
* and no `controller`.
|
|
134
206
|
*/
|
|
135
207
|
/**
|
|
136
208
|
* An immutable, JSON-serializable subset of the native {@link Response}
|
|
137
209
|
* interface.
|
|
210
|
+
*
|
|
211
|
+
* @summary Immutable, JSON-serializable snapshot of a fetch `Response`'s headers, status, url, and type, usable in
|
|
212
|
+
* place of a `Response` in request results.
|
|
138
213
|
*/
|
|
139
214
|
/**
|
|
140
215
|
* The object a {@link Handler} uses to fulfill a request: it provides a
|
|
141
216
|
* readonly view of the {@link RequestContext.request | request} and methods
|
|
142
217
|
* for supplying the {@link Future}'s stream and final response.
|
|
218
|
+
*
|
|
219
|
+
* The [Handlers](/guides/the-manual/requests/handlers) guide shows a handler using it.
|
|
220
|
+
*
|
|
221
|
+
* @summary Object passed to each request handler with the immutable request, a request id, and methods for setting the
|
|
222
|
+
* response stream and the response.
|
|
143
223
|
*/
|
|
144
224
|
//#endregion
|
|
145
225
|
export { EnableHydration, IS_FUTURE, STRUCTURED, SkipCache };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"request.js","names":["getOrSetGlobal","getOrSetUniversal","SkipCache","Symbol","for","EnableHydration","IS_FUTURE","STRUCTURED"],"sources":["../../../../src/types/request.ts"],"sourcesContent":["// oxlint-disable-next-line no-unused-vars\nimport type { Future, Handler } from '../request.ts';\n// oxlint-disable-next-line no-unused-vars\nimport type { Fetch } from '../request/-private/fetch.ts';\n// oxlint-disable-next-line no-unused-vars\nimport type { RequestManager } from '../request/-private/manager.ts';\nimport type { FetchError } from '../request/-private/utils.ts';\n// oxlint-disable-next-line no-unused-vars\nimport type { RequestLoadingState } from '../signals/request-state.ts';\nimport type { Store } from '../store/-private.ts';\nimport { getOrSetGlobal, getOrSetUniversal } from './-private.ts';\nimport type { ResourceKey } from './identifier.ts';\nimport type { QueryParamsSerializationOptions } from './params.ts';\nimport type {\n // oxlint-disable-next-line no-unused-vars\n Includes,\n TypeFromInstanceOrString,\n} from './record.ts';\nimport type { ResourceIdentifierObject } from './spec/json-api-raw.ts';\nimport type { RequestSignature } from './symbols.ts';\n\n/**\n * A {@link RequestInfo.cacheOptions | cacheOptions} flag which, when set,\n * signals that a request should never be handled by the cache-manager and\n * thus will never resolve from cache nor update the cache.\n */\nexport const SkipCache: '___(unique) Symbol(SkipCache)' = getOrSetUniversal('SkipCache', Symbol.for('wd:skip-cache'));\n/**\n * A {@link RequestInfo} flag which, when set, signals to the store's\n * `instantiateRecord` hook that the resolved content should be hydrated\n * into reactive records rather than returned as raw data.\n */\nexport const EnableHydration: '___(unique) Symbol(EnableHydration)' = getOrSetUniversal(\n 'EnableHydration',\n Symbol.for('wd:enable-hydration')\n);\n/**\n * @private\n */\nexport const IS_FUTURE: '___(unique) Symbol(IS_FUTURE)' = getOrSetGlobal('IS_FUTURE', Symbol('IS_FUTURE'));\n/**\n * @private\n */\nexport const STRUCTURED: '___(unique) Symbol(DOC)' = getOrSetGlobal('DOC', Symbol('DOC'));\n\nexport type { FetchError };\n\n/**\n * The HTTP methods WarpDrive's request layer supports.\n */\nexport type HTTPMethod =\n | 'QUERY'\n | 'GET'\n | 'OPTIONS'\n | 'POST'\n | 'PUT'\n | 'PATCH'\n | 'DELETE'\n | 'HEAD'\n | 'CONNECT'\n | 'TRACE';\n\n/**\n * Use these options to adjust {@link CacheHandler} behavior for a request\n * via {@link RequestInfo.cacheOptions}.\n *\n */\nexport interface CacheOptions {\n /**\n * A key that uniquely identifies this request. If not present, the url wil be used\n * as the key for any GET request, while all other requests will not be cached.\n *\n */\n key?: string;\n /**\n * If true, the request will be made even if a cached response is present\n * and not expired.\n *\n */\n reload?: boolean;\n /**\n * If true, and a cached response is present and not expired, the request\n * will be made in the background and the cached response will be returned.\n *\n */\n backgroundReload?: boolean;\n /**\n * Useful for metadata around when to invalidate the cache. Typically used\n * by strategies that invalidate requests by resource type when a new resource\n * of that type has been created. See the CachePolicy implementation\n * provided by `@ember-data-mirror/request-utils` for an example.\n *\n * It is recommended to only use this for query/queryRecord requests where\n * new records created later would affect the results, though using it for\n * findRecord requests is also supported if desired where it may be useful\n * when a create may affect the result of a sideloaded relationship.\n *\n * Generally it is better to patch the cache directly for relationship updates\n * than to invalidate findRecord requests for one.\n *\n */\n // TODO: Ideally this would be T extends TypedRecordInstance ? ExtractSuggestedCacheTypes<T>[] : string[];\n // but that leads to `Type instantiation is excessively deep and possibly infinite.`\n // issues when `T` has many properties.\n types?: string[];\n\n /**\n * If true, the request will never be handled by the cache-manager and thus\n * will never resolve from cache nor update the cache.\n *\n * Generally this is only used for legacy request that manage resource cache\n * updates in a non-standard way via the LegacyNetworkHandler.\n *\n */\n [SkipCache]?: boolean;\n}\n/**\n * The request shape produced by the `findRecord` request builders, for\n * use with {@link Store.request}.\n */\nexport type FindRecordRequestOptions<RT = unknown, T = unknown> = {\n /**\n * the url to request\n */\n url: string;\n /**\n * the HTTP method to use\n */\n method: 'GET';\n /**\n * the headers to send with the request\n */\n headers: Headers;\n /**\n * see {@link CacheOptions}\n */\n cacheOptions?: CacheOptions;\n /**\n * the name of the request operation\n */\n op: 'findRecord';\n /**\n * the resource being requested\n */\n records: [ResourceIdentifierObject<TypeFromInstanceOrString<T>>];\n /**\n * @private used only to carry the response type for type inference purposes\n */\n [RequestSignature]?: RT;\n};\n\n/**\n * The request shape produced by the `query` request builders, for\n * use with {@link Store.request}.\n */\nexport type QueryRequestOptions<RT = unknown> = {\n /**\n * the url to request\n */\n url: string;\n /**\n * the HTTP method to use\n */\n method: 'GET';\n /**\n * the headers to send with the request\n */\n headers: Headers;\n /**\n * see {@link CacheOptions}\n */\n cacheOptions?: CacheOptions;\n /**\n * the name of the request operation\n */\n op: 'query';\n /**\n * @private used only to carry the response type for type inference purposes\n */\n [RequestSignature]?: RT;\n};\n\n/**\n * The request shape produced by the `postQuery` request builders, for\n * use with {@link Store.request}.\n */\nexport type PostQueryRequestOptions<RT = unknown> = {\n /**\n * the url to request\n */\n url: string;\n /**\n * the HTTP method to use\n */\n method: 'POST' | 'QUERY';\n /**\n * the headers to send with the request\n */\n headers: Headers;\n /**\n * the body to send with the request\n */\n body?: string | BodyInit | FormData;\n /**\n * see {@link CacheOptions}. A `key` is required since `POST`/`QUERY`\n * requests otherwise have no cache-safe way to derive one from the url.\n */\n cacheOptions: CacheOptions & {\n /**\n * a key that uniquely identifies this request\n */\n key: string;\n };\n /**\n * the name of the request operation\n */\n op: 'query';\n /**\n * @private used only to carry the response type for type inference purposes\n */\n [RequestSignature]?: RT;\n};\n\n/**\n * The request shape produced by the `deleteRecord` request builders, for\n * use with {@link Store.request}.\n */\nexport type DeleteRequestOptions<RT = unknown, T = unknown> = {\n /**\n * the url to request\n */\n url: string;\n /**\n * the HTTP method to use\n */\n method: 'DELETE';\n /**\n * the headers to send with the request\n */\n headers: Headers;\n /**\n * the name of the request operation\n */\n op: 'deleteRecord';\n /**\n * the body to send with the request\n */\n body?: string | BodyInit | FormData;\n /**\n * data for handlers to convert into the request body\n */\n data: {\n /**\n * the resource being deleted\n */\n record: ResourceKey<TypeFromInstanceOrString<T>>;\n };\n /**\n * the resource being deleted\n */\n records: [ResourceIdentifierObject<TypeFromInstanceOrString<T>>];\n /**\n * @private used only to carry the response type for type inference purposes\n */\n [RequestSignature]?: RT;\n};\n\ntype ImmutableRequest<T> = Readonly<T> & {\n readonly headers: ImmutableHeaders;\n readonly records: [ResourceKey];\n};\n\n/**\n * The request shape produced by the `updateRecord` request builders, for\n * use with {@link Store.request}.\n */\nexport type UpdateRequestOptions<RT = unknown, T = unknown> = {\n /**\n * the url to request\n */\n url: string;\n /**\n * the HTTP method to use\n */\n method: 'PATCH' | 'PUT';\n /**\n * the headers to send with the request\n */\n headers: Headers;\n /**\n * the name of the request operation\n */\n op: 'updateRecord';\n /**\n * the body to send with the request\n */\n body?: string | BodyInit | FormData;\n /**\n * data for handlers to convert into the request body\n */\n data: {\n /**\n * the resource being updated\n */\n record: ResourceKey<TypeFromInstanceOrString<T>>;\n };\n /**\n * the resource being updated\n */\n records: [ResourceIdentifierObject<TypeFromInstanceOrString<T>>];\n /**\n * @private used only to carry the response type for type inference purposes\n */\n [RequestSignature]?: RT;\n};\n\n/**\n * The request shape produced by the `createRecord` request builders, for\n * use with {@link Store.request}.\n */\nexport type CreateRequestOptions<RT = unknown, T = unknown> = {\n /**\n * the url to request\n */\n url: string;\n /**\n * the HTTP method to use\n */\n method: 'POST';\n /**\n * the headers to send with the request\n */\n headers: Headers;\n /**\n * the name of the request operation\n */\n op: 'createRecord';\n /**\n * the body to send with the request\n */\n body?: string | BodyInit | FormData;\n /**\n * data for handlers to convert into the request body\n */\n data: {\n /**\n * the resource being created\n */\n record: ResourceKey<TypeFromInstanceOrString<T>>;\n };\n /**\n * the resource being created\n */\n records: [ResourceIdentifierObject<TypeFromInstanceOrString<T>>];\n /**\n * @private used only to carry the response type for type inference purposes\n */\n [RequestSignature]?: RT;\n};\n\n/**\n * The immutable, handler-facing form of {@link DeleteRequestOptions}.\n */\nexport type ImmutableDeleteRequestOptions = ImmutableRequest<DeleteRequestOptions>;\n/**\n * The immutable, handler-facing form of {@link UpdateRequestOptions}.\n */\nexport type ImmutableUpdateRequestOptions = ImmutableRequest<UpdateRequestOptions>;\n/**\n * The immutable, handler-facing form of {@link CreateRequestOptions}.\n */\nexport type ImmutableCreateRequestOptions = ImmutableRequest<CreateRequestOptions>;\n\n/**\n * A minimal reference to a resource sufficient to build a URL for it,\n * as accepted by the request builders.\n */\nexport type RemotelyAccessibleIdentifier<T extends string = string> = {\n /**\n * the resource's persisted id\n */\n id: string;\n /**\n * the resource's type\n */\n type: T;\n /**\n * the local identifier WarpDrive has assigned to the resource, if known\n */\n lid?: string;\n};\n\n/**\n * Options accepted by the request builders for constraining how a\n * request's url is constructed and how the request interacts with the cache.\n */\nexport interface ConstrainedRequestOptions {\n /**\n * If true, the request will be made even if a cached response is present\n * and not expired.\n */\n reload?: boolean;\n /**\n * If true, and a cached response is present and not expired, the request\n * will be made in the background and the cached response will be returned.\n */\n backgroundReload?: boolean;\n /**\n * The host to use when constructing the request's url, overriding any\n * host configured via `setBuildURLConfig`.\n */\n host?: string;\n /**\n * The namespace to use when constructing the request's url, overriding\n * any namespace configured via `setBuildURLConfig`.\n */\n namespace?: string;\n /**\n * The resource path to use when constructing the request's url,\n * overriding the default of pluralizing the resource's type.\n */\n resourcePath?: string;\n /**\n * Options for how to serialize the request's query params, see {@link QueryParamsSerializationOptions}.\n */\n urlParamsSettings?: QueryParamsSerializationOptions;\n}\n\n/**\n * Options accepted by the `findRecord` request builders.\n */\nexport interface FindRecordOptions extends ConstrainedRequestOptions {\n /**\n * the relationship paths to sideload, see {@link Includes}\n */\n include?: string | string[];\n}\n\n/**\n * When a {@link Future} resolves, it returns an object\n * containing the original {@link RequestInfo | request},\n * the {@link Response | response} set by the handler chain (if any), and\n * the processed content.\n */\nexport interface StructuredDataDocument<T> {\n /**\n * @private\n */\n [STRUCTURED]?: true;\n /**\n * @see {@link ImmutableRequestInfo}\n */\n request: ImmutableRequestInfo;\n /**\n * the response set by the handler chain, if any\n */\n response: Response | ResponseInfo | null;\n /**\n * the processed content of the response\n */\n content: T;\n}\n\n/**\n * When a {@link Future} rejects, it throws either an {@link Error}\n * an {@link AggregateError} or a {@link DOMException} that maintains\n * the `{ request, response, content }` shape but is also an Error instance\n * itself.\n *\n * If using the error originates from the {@link Fetch | Fetch Handler}\n * the error will be a {@link FetchError}\n */\nexport interface StructuredErrorDocument<T = unknown> extends Error {\n /**\n * @private\n */\n [STRUCTURED]?: true;\n /**\n * @see {@link ImmutableRequestInfo}\n */\n request: ImmutableRequestInfo;\n /**\n * the response set by the handler chain, if any\n */\n response: Response | ResponseInfo | null;\n /**\n * the error that caused the request to fail\n */\n error: string | object;\n /**\n * the processed content of the response, if any was received before the failure\n */\n content?: T;\n}\n\n/**\n * A union of the resolve/reject data types for the {@link Future}\n * returned by {@link Store.request | request}\n *\n * See also the docs for:\n *\n * - {@link Future}\n * - {@link StructuredDataDocument} (resolved/successful requests)\n * - {@link StructuredErrorDocument} (rejected/failed requests)\n */\nexport type StructuredDocument<T> = StructuredDataDocument<T> | StructuredErrorDocument<T>;\n\n/**\n * The {@link RequestInit} interface accepted by the native {@link fetch} API.\n *\n * WarpDrive provides our own typings due to incompleteness in the native typings.\n *\n * @privateRemarks\n * - [MDN Reference (fetch)](https://developer.mozilla.org/docs/Web/API/Window/fetch)\n * - [MDN Reference (RequestInit)](https://developer.mozilla.org/en-US/docs/Web/API/RequestInit)\n * - [MDN Reference (Request)](https://developer.mozilla.org/docs/Web/API/Request)\n *\n */\ninterface NativeRequestInit {\n /** Returns the cache mode associated with request, which is a string indicating how the request will interact with the browser's cache when fetching.\n */\n cache?: RequestCache;\n /** Returns the credentials mode associated with request, which is a string indicating whether credentials will be sent with the request always, never, or only when sent to a same-origin URL.\n */\n credentials?: RequestCredentials;\n /** Returns the kind of resource requested by request, e.g., \"document\" or \"script\".\n */\n destination?: RequestDestination;\n /** Returns a Headers object consisting of the headers associated with request. Note that headers added in the network layer by the user agent will not be accounted for in this object, e.g., the \"Host\" header.\n */\n headers?: Headers;\n /** Returns request's subresource integrity metadata, which is a cryptographic hash of the resource being fetched. Its value consists of multiple hashes separated by whitespace. [SRI]\n */\n integrity?: string;\n /** Returns a boolean indicating whether or not request can outlive the global in which it was created.\n */\n keepalive?: boolean;\n /** Returns request's HTTP method, which is \"GET\" by default.\n */\n method?: HTTPMethod;\n /** Returns the mode associated with request, which is a string indicating whether the request will use CORS, or will be restricted to same-origin URLs.\n *\n * `no-cors` is not allowed for streaming request bodies.\n *\n */\n mode?: RequestMode;\n /**\n * provides an explicit priority hint for the request.\n */\n priority?: RequestPriority;\n /** Returns the redirect mode associated with request, which is a string indicating how redirects for the request will be handled during fetching. A request will follow redirects by default.\n */\n redirect?: RequestRedirect;\n /** Returns the referrer of request. Its value can be a same-origin URL if explicitly set in init, the empty string to indicate no referrer, and \"about:client\" when defaulting to the global's default. This is used during fetching to determine the value of the `Referer` header of the request being made.\n */\n referrer?: string;\n /** Returns the referrer policy associated with request. This is used during fetching to compute the value of the request's referrer.\n */\n referrerPolicy?: ReferrerPolicy;\n /** Returns the signal associated with request, which is an AbortSignal object indicating whether or not request has been aborted, and its abort event handler.\n */\n signal?: AbortSignal;\n /** Returns the URL of request as a string.\n */\n url?: string;\n /** Any body that you want to add to your request. Note that a GET or HEAD request may not have a body.\n */\n body?: BodyInit | null;\n\n /**\n * When sending a ReadableStream as the body of a request, 'half' must be\n * specified.\n *\n * [Half Duplex Further Reading](https://developer.chrome.com/docs/capabilities/web-apis/fetch-streaming-requests#half_duplex)\n *\n */\n duplex?: 'half';\n}\n\n/**\n * A read-only {@link Headers} instance, as passed to {@link Handler | Handlers}\n * via {@link ImmutableRequestInfo.headers}.\n */\nexport interface ImmutableHeaders extends Headers {\n /**\n * Returns a mutable clone of these headers, if supported by the implementation.\n */\n clone?(): Headers;\n /**\n * Returns the headers as an array of `[key, value]` pairs.\n */\n toJSON(): [string, string][];\n}\n\n/**\n * Extends JavaScript's native {@link fetch} {@link NativeRequestInit | RequestInit} with additional\n * properties specific to the {@link RequestManager | RequestManager's} capabilities.\n *\n * This interface is used to define the shape of a request that can be made via\n * either the {@link RequestManager.request} or {@link Store.request} methods.\n *\n * @privateRemarks\n * - [MDN Reference (fetch)](https://developer.mozilla.org/docs/Web/API/Window/fetch)\n * - [MDN Reference (RequestInit)](https://developer.mozilla.org/en-US/docs/Web/API/RequestInit)\n * - [MDN Reference (Request)](https://developer.mozilla.org/docs/Web/API/Request)\n *\n * @public\n * @since 4.12\n */\nexport interface RequestInfo<RT = unknown> extends NativeRequestInit {\n /**\n * If provided, used instead of the AbortController auto-configured for each request by the RequestManager\n *\n */\n controller?: AbortController;\n\n /**\n * @see {@link CacheOptions}\n */\n cacheOptions?: CacheOptions;\n /**\n * The {@link Store} the request was made against, if made via\n * {@link Store.request} rather than directly against a {@link RequestManager}.\n *\n * A {@link Handler} can read this off of {@link RequestContext.request | context.request}\n * to reach store state (the cache, other services attached to a custom\n * store subclass, etc.) without needing any Ember DI/`setOwner` wiring at\n * handler-construction time. This works for a handler of any shape (a\n * function, plain object, or class) because the store is attached to each\n * request individually rather than to the handler itself.\n *\n * The trade-off is that this is only populated for requests issued via\n * {@link Store.request | store.request(...)}; a request issued directly\n * against a {@link RequestManager} will not have it set unless the caller\n * supplies it explicitly. Handlers that rely on it should treat it as\n * optional.\n *\n * @example\n * ```ts\n * const LoggingHandler = {\n * request<T>(context: RequestContext, next: NextFn<T>) {\n * const store = context.request.store;\n * if (store) {\n * console.log(`[${store.constructor.name}] ${context.request.url ?? ''}`);\n * }\n * return next(context.request);\n * },\n * };\n * ```\n */\n store?: Store;\n\n /**\n * The name of the request operation, if any (e.g. `'findRecord'`, `'query'`).\n */\n op?: string;\n\n /**\n * The {@link ResourceKey | ResourceKeys} of the primary resources involved in the request\n * (if any). This may be used by handlers to perform transactional\n * operations on the store.\n *\n */\n records?: ResourceKey[];\n\n /**\n * If true, this request will not be tracked by test waiters.\n */\n disableTestWaiter?: boolean;\n /**\n * data that a handler should convert into\n * the query (GET) or body (POST).\n *\n * Note: It is recommended that builders set query params\n * and body directly in most scenarios.\n *\n */\n data?: Record<string, unknown>;\n /**\n * options specifically intended for {@link Handler | Handlers}\n * to utilize to process the request\n *\n */\n options?: Record<string, unknown>;\n\n /**\n * @private used only to carry the response type for type inference purposes\n */\n [RequestSignature]?: RT;\n\n /**\n * see {@link EnableHydration}\n */\n [EnableHydration]?: boolean;\n}\n\n/**\n * Immutable version of {@link RequestInfo}. This is what is passed to handlers.\n *\n */\nexport type ImmutableRequestInfo<RT = unknown> = Readonly<Omit<RequestInfo<RT>, 'controller'>> & {\n /**\n * see {@link CacheOptions}\n */\n readonly cacheOptions?: Readonly<CacheOptions>;\n /**\n * see {@link ImmutableHeaders}\n */\n readonly headers?: ImmutableHeaders;\n /**\n * see {@link RequestInfo.data}\n */\n readonly data?: Readonly<Record<string, unknown>>;\n /**\n * see {@link RequestInfo.options}\n */\n readonly options?: Readonly<Record<string, unknown>>;\n\n /** Whether the request body has been read.\n */\n readonly bodyUsed?: boolean;\n};\n\n/**\n * An immutable, JSON-serializable subset of the native {@link Response}\n * interface.\n */\nexport interface ResponseInfo {\n /**\n * see {@link ImmutableHeaders}\n */\n readonly headers: ImmutableHeaders; // to do, maybe not this?\n /**\n * whether the response's status code was in the 200-299 range\n */\n readonly ok: boolean;\n /**\n * whether the response is the result of a redirect\n */\n readonly redirected: boolean;\n /**\n * the response's HTTP status code\n */\n readonly status: number;\n /**\n * the status message associated with the response's status code\n */\n readonly statusText: string;\n /**\n * the type of the response, see [MDN Reference](https://developer.mozilla.org/docs/Web/API/Response/type)\n */\n readonly type: ResponseType;\n /**\n * the url of the response\n */\n readonly url: string;\n}\n\n/**\n * The object a {@link Handler} uses to fulfill a request: it provides a\n * readonly view of the {@link RequestContext.request | request} and methods\n * for supplying the {@link Future}'s stream and final response.\n */\nexport interface RequestContext {\n /**\n * @see {@link ImmutableRequestInfo}\n */\n request: ImmutableRequestInfo;\n /**\n * a unique id for this request\n */\n id: number;\n\n /**\n * Supplies the stream of the response's content, if available, enabling\n * consumers to monitor download progress via {@link RequestLoadingState}.\n */\n setStream(stream: ReadableStream | Promise<ReadableStream | null>): void;\n /**\n * Supplies the response for the request.\n */\n setResponse(response: Response | ResponseInfo | null): void;\n}\n"],"mappings":";;;;;;;;AA0BA,MAAaE,YAA6CD,kBAAkB,aAAaE,OAAOC,IAAI,eAAe,CAAC;;;;;;AAMpH,MAAaC,kBAAyDJ,kBACpE,mBACAE,OAAOC,IAAI,qBAAqB,CAClC;;;;AAIA,MAAaE,YAA6CN,eAAe,aAAaG,OAAO,WAAW,CAAC;;;;AAIzG,MAAaI,aAAwCP,eAAe,OAAOG,OAAO,KAAK,CAAC"}
|
|
1
|
+
{"version":3,"file":"request.js","names":["getOrSetGlobal","getOrSetUniversal","SkipCache","Symbol","for","EnableHydration","IS_FUTURE","STRUCTURED"],"sources":["../../../../src/types/request.ts"],"sourcesContent":["/**\n * @module\n * @summary Types for requests and responses: `RequestInfo`, the request shapes builders return, cache options, the\n * handler context and the documents a request's `Future` settles with.\n */\n\n// oxlint-disable-next-line no-unused-vars\nimport type { Future, Handler } from '../request.ts';\n// oxlint-disable-next-line no-unused-vars\nimport type { Fetch } from '../request/-private/fetch.ts';\n// oxlint-disable-next-line no-unused-vars\nimport type { RequestManager } from '../request/-private/manager.ts';\nimport type { FetchError } from '../request/-private/utils.ts';\n// oxlint-disable-next-line no-unused-vars\nimport type { RequestLoadingState } from '../signals/request-state.ts';\nimport type { Store } from '../store/-private.ts';\nimport { getOrSetGlobal, getOrSetUniversal } from './-private.ts';\nimport type { ResourceKey } from './identifier.ts';\nimport type { QueryParamsSerializationOptions } from './params.ts';\nimport type {\n // oxlint-disable-next-line no-unused-vars\n Includes,\n TypeFromInstanceOrString,\n} from './record.ts';\nimport type { ResourceIdentifierObject } from './spec/json-api-raw.ts';\nimport type { RequestSignature } from './symbols.ts';\n\n/**\n * A {@link RequestInfo.cacheOptions | cacheOptions} flag which, when set,\n * signals that a request should never be handled by the cache-manager and\n * thus will never resolve from cache nor update the cache.\n *\n * @summary Symbol key for a request's `cacheOptions` that, when true, makes the request bypass the CacheHandler so it\n * neither resolves from nor updates the cache.\n */\nexport const SkipCache: '___(unique) Symbol(SkipCache)' = getOrSetUniversal('SkipCache', Symbol.for('wd:skip-cache'));\n/**\n * A {@link RequestInfo} flag which, when set, signals to the store's\n * `instantiateRecord` hook that the resolved content should be hydrated\n * into reactive records rather than returned as raw data.\n *\n * @summary Symbol flag on a request that makes the CacheHandler return reactive records instead of raw cache\n * documents; `store.request` sets it automatically.\n */\nexport const EnableHydration: '___(unique) Symbol(EnableHydration)' = getOrSetUniversal(\n 'EnableHydration',\n Symbol.for('wd:enable-hydration')\n);\n/**\n * @private\n */\nexport const IS_FUTURE: '___(unique) Symbol(IS_FUTURE)' = getOrSetGlobal('IS_FUTURE', Symbol('IS_FUTURE'));\n/**\n * @private\n */\nexport const STRUCTURED: '___(unique) Symbol(DOC)' = getOrSetGlobal('DOC', Symbol('DOC'));\n\nexport type { FetchError };\n\n/**\n * The HTTP methods WarpDrive's request layer supports.\n *\n * @summary Union of the HTTP method strings, including `QUERY`, that a WarpDrive request's `method` may be set to.\n */\nexport type HTTPMethod =\n | 'QUERY'\n | 'GET'\n | 'OPTIONS'\n | 'POST'\n | 'PUT'\n | 'PATCH'\n | 'DELETE'\n | 'HEAD'\n | 'CONNECT'\n | 'TRACE';\n\n/**\n * Use these options to adjust {@link CacheHandler} behavior for a request\n * via {@link RequestInfo.cacheOptions}.\n *\n * @summary Per-request settings on `cacheOptions` that control the cache key, forced or background reloads,\n * invalidation by resource type, and cache bypass.\n */\nexport interface CacheOptions {\n /**\n * A key that uniquely identifies this request. If not present, the url wil be used\n * as the key for any GET request, while all other requests will not be cached.\n *\n */\n key?: string;\n /**\n * If true, the request will be made even if a cached response is present\n * and not expired.\n *\n */\n reload?: boolean;\n /**\n * If true, and a cached response is present and not expired, the request\n * will be made in the background and the cached response will be returned.\n *\n */\n backgroundReload?: boolean;\n /**\n * Useful for metadata around when to invalidate the cache. Typically used\n * by strategies that invalidate requests by resource type when a new resource\n * of that type has been created. See the CachePolicy implementation\n * provided by `@ember-data-mirror/request-utils` for an example.\n *\n * It is recommended to only use this for query/queryRecord requests where\n * new records created later would affect the results, though using it for\n * findRecord requests is also supported if desired where it may be useful\n * when a create may affect the result of a sideloaded relationship.\n *\n * Generally it is better to patch the cache directly for relationship updates\n * than to invalidate findRecord requests for one.\n *\n */\n // TODO: Ideally this would be T extends TypedRecordInstance ? ExtractSuggestedCacheTypes<T>[] : string[];\n // but that leads to `Type instantiation is excessively deep and possibly infinite.`\n // issues when `T` has many properties.\n types?: string[];\n\n /**\n * If true, the request will never be handled by the cache-manager and thus\n * will never resolve from cache nor update the cache.\n *\n * Generally this is only used for legacy request that manage resource cache\n * updates in a non-standard way via the LegacyNetworkHandler.\n *\n */\n [SkipCache]?: boolean;\n}\n/**\n * The request shape produced by the `findRecord` request builders, for\n * use with {@link Store.request}.\n *\n * @summary Shape of the `GET` request object that `findRecord` builders return for `store.request`, carrying the url,\n * headers, and requested resource identifier.\n */\nexport type FindRecordRequestOptions<RT = unknown, T = unknown> = {\n /**\n * the url to request\n */\n url: string;\n /**\n * the HTTP method to use\n */\n method: 'GET';\n /**\n * the headers to send with the request\n */\n headers: Headers;\n /**\n * see {@link CacheOptions}\n */\n cacheOptions?: CacheOptions;\n /**\n * the name of the request operation\n */\n op: 'findRecord';\n /**\n * the resource being requested\n */\n records: [ResourceIdentifierObject<TypeFromInstanceOrString<T>>];\n /**\n * @private used only to carry the response type for type inference purposes\n */\n [RequestSignature]?: RT;\n};\n\n/**\n * The request shape produced by the `query` request builders, for\n * use with {@link Store.request}.\n *\n * @summary Shape of the `GET` request object that `query` builders return for `store.request`, carrying the url,\n * headers, and cache options.\n */\nexport type QueryRequestOptions<RT = unknown> = {\n /**\n * the url to request\n */\n url: string;\n /**\n * the HTTP method to use\n */\n method: 'GET';\n /**\n * the headers to send with the request\n */\n headers: Headers;\n /**\n * see {@link CacheOptions}\n */\n cacheOptions?: CacheOptions;\n /**\n * the name of the request operation\n */\n op: 'query';\n /**\n * @private used only to carry the response type for type inference purposes\n */\n [RequestSignature]?: RT;\n};\n\n/**\n * The request shape produced by the `postQuery` request builders, for\n * use with {@link Store.request}.\n *\n * @summary Shape of the `POST` or `QUERY` request object that `postQuery` builders return, with a body and a required\n * cache key since the url cannot serve as one.\n */\nexport type PostQueryRequestOptions<RT = unknown> = {\n /**\n * the url to request\n */\n url: string;\n /**\n * the HTTP method to use\n */\n method: 'POST' | 'QUERY';\n /**\n * the headers to send with the request\n */\n headers: Headers;\n /**\n * the body to send with the request\n */\n body?: string | BodyInit | FormData;\n /**\n * see {@link CacheOptions}. A `key` is required since `POST`/`QUERY`\n * requests otherwise have no cache-safe way to derive one from the url.\n */\n cacheOptions: CacheOptions & {\n /**\n * a key that uniquely identifies this request\n */\n key: string;\n };\n /**\n * the name of the request operation\n */\n op: 'query';\n /**\n * @private used only to carry the response type for type inference purposes\n */\n [RequestSignature]?: RT;\n};\n\n/**\n * The request shape produced by the `deleteRecord` request builders, for\n * use with {@link Store.request}.\n *\n * @summary Shape of the `DELETE` request object that `deleteRecord` builders return for `store.request`, identifying\n * the resource being deleted.\n */\nexport type DeleteRequestOptions<RT = unknown, T = unknown> = {\n /**\n * the url to request\n */\n url: string;\n /**\n * the HTTP method to use\n */\n method: 'DELETE';\n /**\n * the headers to send with the request\n */\n headers: Headers;\n /**\n * the name of the request operation\n */\n op: 'deleteRecord';\n /**\n * the body to send with the request\n */\n body?: string | BodyInit | FormData;\n /**\n * data for handlers to convert into the request body\n */\n data: {\n /**\n * the resource being deleted\n */\n record: ResourceKey<TypeFromInstanceOrString<T>>;\n };\n /**\n * the resource being deleted\n */\n records: [ResourceIdentifierObject<TypeFromInstanceOrString<T>>];\n /**\n * @private used only to carry the response type for type inference purposes\n */\n [RequestSignature]?: RT;\n};\n\ntype ImmutableRequest<T> = Readonly<T> & {\n readonly headers: ImmutableHeaders;\n readonly records: [ResourceKey];\n};\n\n/**\n * The request shape produced by the `updateRecord` request builders, for\n * use with {@link Store.request}.\n *\n * @summary Shape of the `PATCH` or `PUT` request object that `updateRecord` builders return for `store.request`,\n * identifying the resource being saved.\n */\nexport type UpdateRequestOptions<RT = unknown, T = unknown> = {\n /**\n * the url to request\n */\n url: string;\n /**\n * the HTTP method to use\n */\n method: 'PATCH' | 'PUT';\n /**\n * the headers to send with the request\n */\n headers: Headers;\n /**\n * the name of the request operation\n */\n op: 'updateRecord';\n /**\n * the body to send with the request\n */\n body?: string | BodyInit | FormData;\n /**\n * data for handlers to convert into the request body\n */\n data: {\n /**\n * the resource being updated\n */\n record: ResourceKey<TypeFromInstanceOrString<T>>;\n };\n /**\n * the resource being updated\n */\n records: [ResourceIdentifierObject<TypeFromInstanceOrString<T>>];\n /**\n * @private used only to carry the response type for type inference purposes\n */\n [RequestSignature]?: RT;\n};\n\n/**\n * The request shape produced by the `createRecord` request builders, for\n * use with {@link Store.request}.\n *\n * @summary Shape of the `POST` request object that `createRecord` builders return for `store.request`, identifying the\n * new resource being saved.\n */\nexport type CreateRequestOptions<RT = unknown, T = unknown> = {\n /**\n * the url to request\n */\n url: string;\n /**\n * the HTTP method to use\n */\n method: 'POST';\n /**\n * the headers to send with the request\n */\n headers: Headers;\n /**\n * the name of the request operation\n */\n op: 'createRecord';\n /**\n * the body to send with the request\n */\n body?: string | BodyInit | FormData;\n /**\n * data for handlers to convert into the request body\n */\n data: {\n /**\n * the resource being created\n */\n record: ResourceKey<TypeFromInstanceOrString<T>>;\n };\n /**\n * the resource being created\n */\n records: [ResourceIdentifierObject<TypeFromInstanceOrString<T>>];\n /**\n * @private used only to carry the response type for type inference purposes\n */\n [RequestSignature]?: RT;\n};\n\n/**\n * The immutable, handler-facing form of {@link DeleteRequestOptions}.\n *\n * @summary Read-only view of a `deleteRecord` request as a handler receives it, with immutable headers and `records`\n * as resource keys.\n */\nexport type ImmutableDeleteRequestOptions = ImmutableRequest<DeleteRequestOptions>;\n/**\n * The immutable, handler-facing form of {@link UpdateRequestOptions}.\n *\n * @summary Read-only view of an `updateRecord` request as a handler receives it, with immutable headers and `records`\n * as resource keys.\n */\nexport type ImmutableUpdateRequestOptions = ImmutableRequest<UpdateRequestOptions>;\n/**\n * The immutable, handler-facing form of {@link CreateRequestOptions}.\n *\n * @summary Read-only view of a `createRecord` request as a handler receives it, with immutable headers and `records`\n * as resource keys.\n */\nexport type ImmutableCreateRequestOptions = ImmutableRequest<CreateRequestOptions>;\n\n/**\n * A minimal reference to a resource sufficient to build a URL for it,\n * as accepted by the request builders.\n *\n * @summary A resource reference with a persisted `id` and `type` and an optional `lid`, which is enough for request\n * builders to construct its url.\n */\nexport type RemotelyAccessibleIdentifier<T extends string = string> = {\n /**\n * the resource's persisted id\n */\n id: string;\n /**\n * the resource's type\n */\n type: T;\n /**\n * the local identifier WarpDrive has assigned to the resource, if known\n */\n lid?: string;\n};\n\n/**\n * Options accepted by the request builders for constraining how a\n * request's url is constructed and how the request interacts with the cache.\n *\n * @summary Options the request builders accept to set reload behavior and override the url's host, namespace, resource\n * path, and query param serialization.\n */\nexport interface ConstrainedRequestOptions {\n /**\n * If true, the request will be made even if a cached response is present\n * and not expired.\n */\n reload?: boolean;\n /**\n * If true, and a cached response is present and not expired, the request\n * will be made in the background and the cached response will be returned.\n */\n backgroundReload?: boolean;\n /**\n * The host to use when constructing the request's url, overriding any\n * host configured via `setBuildURLConfig`.\n */\n host?: string;\n /**\n * The namespace to use when constructing the request's url, overriding\n * any namespace configured via `setBuildURLConfig`.\n */\n namespace?: string;\n /**\n * The resource path to use when constructing the request's url,\n * overriding the default of pluralizing the resource's type.\n */\n resourcePath?: string;\n /**\n * Options for how to serialize the request's query params, see {@link QueryParamsSerializationOptions}.\n */\n urlParamsSettings?: QueryParamsSerializationOptions;\n}\n\n/**\n * Options accepted by the `findRecord` request builders.\n *\n * @summary Options the `findRecord` request builders accept: the shared url and reload options plus the relationship\n * paths to `include`.\n */\nexport interface FindRecordOptions extends ConstrainedRequestOptions {\n /**\n * the relationship paths to sideload, see {@link Includes}\n */\n include?: string | string[];\n}\n\n/**\n * When a {@link Future} resolves, it returns an object\n * containing the original {@link RequestInfo | request},\n * the {@link Response | response} set by the handler chain (if any), and\n * the processed content.\n *\n * @summary The `{ request, response, content }` object that a request's `Future` resolves with when the request\n * succeeds.\n */\nexport interface StructuredDataDocument<T> {\n /**\n * @private\n */\n [STRUCTURED]?: true;\n /**\n * @see {@link ImmutableRequestInfo}\n */\n request: ImmutableRequestInfo;\n /**\n * the response set by the handler chain, if any\n */\n response: Response | ResponseInfo | null;\n /**\n * the processed content of the response\n */\n content: T;\n}\n\n/**\n * When a {@link Future} rejects, it throws either an {@link Error}\n * an {@link AggregateError} or a {@link DOMException} that maintains\n * the `{ request, response, content }` shape but is also an Error instance\n * itself.\n *\n * If using the error originates from the {@link Fetch | Fetch Handler}\n * the error will be a {@link FetchError}\n *\n * @summary The Error a request's `Future` rejects with when the request fails, carrying the `request`, `response`,\n * `error`, and any `content` received.\n */\nexport interface StructuredErrorDocument<T = unknown> extends Error {\n /**\n * @private\n */\n [STRUCTURED]?: true;\n /**\n * @see {@link ImmutableRequestInfo}\n */\n request: ImmutableRequestInfo;\n /**\n * the response set by the handler chain, if any\n */\n response: Response | ResponseInfo | null;\n /**\n * the error that caused the request to fail\n */\n error: string | object;\n /**\n * the processed content of the response, if any was received before the failure\n */\n content?: T;\n}\n\n/**\n * A union of the resolve/reject data types for the {@link Future}\n * returned by {@link Store.request | request}\n *\n * The [Using The Response](/guides/the-manual/requests/using-the-response) guide shows\n * how to read one.\n *\n * See also the docs for:\n *\n * - {@link Future}\n * - {@link StructuredDataDocument} (resolved/successful requests)\n * - {@link StructuredErrorDocument} (rejected/failed requests)\n *\n * @summary Union of the success and error documents that a request's `Future` resolves or rejects with.\n */\nexport type StructuredDocument<T> = StructuredDataDocument<T> | StructuredErrorDocument<T>;\n\n/**\n * The {@link RequestInit} interface accepted by the native {@link fetch} API.\n *\n * WarpDrive provides our own typings due to incompleteness in the native typings.\n *\n * @privateRemarks\n * - [MDN Reference (fetch)](https://developer.mozilla.org/docs/Web/API/Window/fetch)\n * - [MDN Reference (RequestInit)](https://developer.mozilla.org/en-US/docs/Web/API/RequestInit)\n * - [MDN Reference (Request)](https://developer.mozilla.org/docs/Web/API/Request)\n *\n */\ninterface NativeRequestInit {\n /** Returns the cache mode associated with request, which is a string indicating how the request will interact with the browser's cache when fetching.\n */\n cache?: RequestCache;\n /** Returns the credentials mode associated with request, which is a string indicating whether credentials will be sent with the request always, never, or only when sent to a same-origin URL.\n */\n credentials?: RequestCredentials;\n /** Returns the kind of resource requested by request, e.g., \"document\" or \"script\".\n */\n destination?: RequestDestination;\n /** Returns a Headers object consisting of the headers associated with request. Note that headers added in the network layer by the user agent will not be accounted for in this object, e.g., the \"Host\" header.\n */\n headers?: Headers;\n /** Returns request's subresource integrity metadata, which is a cryptographic hash of the resource being fetched. Its value consists of multiple hashes separated by whitespace. [SRI]\n */\n integrity?: string;\n /** Returns a boolean indicating whether or not request can outlive the global in which it was created.\n */\n keepalive?: boolean;\n /** Returns request's HTTP method, which is \"GET\" by default.\n */\n method?: HTTPMethod;\n /** Returns the mode associated with request, which is a string indicating whether the request will use CORS, or will be restricted to same-origin URLs.\n *\n * `no-cors` is not allowed for streaming request bodies.\n *\n */\n mode?: RequestMode;\n /**\n * provides an explicit priority hint for the request.\n */\n priority?: RequestPriority;\n /** Returns the redirect mode associated with request, which is a string indicating how redirects for the request will be handled during fetching. A request will follow redirects by default.\n */\n redirect?: RequestRedirect;\n /** Returns the referrer of request. Its value can be a same-origin URL if explicitly set in init, the empty string to indicate no referrer, and \"about:client\" when defaulting to the global's default. This is used during fetching to determine the value of the `Referer` header of the request being made.\n */\n referrer?: string;\n /** Returns the referrer policy associated with request. This is used during fetching to compute the value of the request's referrer.\n */\n referrerPolicy?: ReferrerPolicy;\n /** Returns the signal associated with request, which is an AbortSignal object indicating whether or not request has been aborted, and its abort event handler.\n */\n signal?: AbortSignal;\n /** Returns the URL of request as a string.\n */\n url?: string;\n /** Any body that you want to add to your request. Note that a GET or HEAD request may not have a body.\n */\n body?: BodyInit | null;\n\n /**\n * When sending a ReadableStream as the body of a request, 'half' must be\n * specified.\n *\n * [Half Duplex Further Reading](https://developer.chrome.com/docs/capabilities/web-apis/fetch-streaming-requests#half_duplex)\n *\n */\n duplex?: 'half';\n}\n\n/**\n * A read-only {@link Headers} instance, as passed to {@link Handler | Handlers}\n * via {@link ImmutableRequestInfo.headers}.\n *\n * @summary Read-only `Headers` that handlers see on a request, adding `toJSON` to serialize them as `[key, value]`\n * pairs and an optional mutable `clone`.\n */\nexport interface ImmutableHeaders extends Headers {\n /**\n * Returns a mutable clone of these headers, if supported by the implementation.\n */\n clone?(): Headers;\n /**\n * Returns the headers as an array of `[key, value]` pairs.\n */\n toJSON(): [string, string][];\n}\n\n/**\n * Extends JavaScript's native {@link fetch} {@link NativeRequestInit | RequestInit} with additional\n * properties specific to the {@link RequestManager | RequestManager's} capabilities.\n *\n * This interface is used to define the shape of a request that can be made via\n * either the {@link RequestManager.request} or {@link Store.request} methods.\n *\n * The [Making Requests](/guides/the-manual/requests/#request-options) guide explains\n * its options.\n *\n * @summary Describes a request for `store.request` or `RequestManager.request`: native fetch options plus cache\n * options, operation name, records, data, and the store.\n * @privateRemarks\n * - [MDN Reference (fetch)](https://developer.mozilla.org/docs/Web/API/Window/fetch)\n * - [MDN Reference (RequestInit)](https://developer.mozilla.org/en-US/docs/Web/API/RequestInit)\n * - [MDN Reference (Request)](https://developer.mozilla.org/docs/Web/API/Request)\n *\n * @public\n * @since 4.12\n */\nexport interface RequestInfo<RT = unknown> extends NativeRequestInit {\n /**\n * If provided, used instead of the AbortController auto-configured for each request by the RequestManager\n *\n */\n controller?: AbortController;\n\n /**\n * @see {@link CacheOptions}\n */\n cacheOptions?: CacheOptions;\n /**\n * The {@link Store} the request was made against, if made via\n * {@link Store.request} rather than directly against a {@link RequestManager}.\n *\n * A {@link Handler} can read this off of {@link RequestContext.request | context.request}\n * to reach store state (the cache, other services attached to a custom\n * store subclass, etc.) without needing any Ember DI/`setOwner` wiring at\n * handler-construction time. This works for a handler of any shape (a\n * function, plain object, or class) because the store is attached to each\n * request individually rather than to the handler itself.\n *\n * The trade-off is that this is only populated for requests issued via\n * {@link Store.request | store.request(...)}; a request issued directly\n * against a {@link RequestManager} will not have it set unless the caller\n * supplies it explicitly. Handlers that rely on it should treat it as\n * optional.\n *\n * @example\n * ```ts\n * const LoggingHandler = {\n * request<T>(context: RequestContext, next: NextFn<T>) {\n * const store = context.request.store;\n * if (store) {\n * console.log(`[${store.constructor.name}] ${context.request.url ?? ''}`);\n * }\n * return next(context.request);\n * },\n * };\n * ```\n */\n store?: Store;\n\n /**\n * The name of the request operation, if any (e.g. `'findRecord'`, `'query'`).\n */\n op?: string;\n\n /**\n * The {@link ResourceKey | ResourceKeys} of the primary resources involved in the request\n * (if any). This may be used by handlers to perform transactional\n * operations on the store.\n *\n */\n records?: ResourceKey[];\n\n /**\n * If true, this request will not be tracked by test waiters.\n */\n disableTestWaiter?: boolean;\n /**\n * data that a handler should convert into\n * the query (GET) or body (POST).\n *\n * Note: It is recommended that builders set query params\n * and body directly in most scenarios.\n *\n */\n data?: Record<string, unknown>;\n /**\n * options specifically intended for {@link Handler | Handlers}\n * to utilize to process the request\n *\n */\n options?: Record<string, unknown>;\n\n /**\n * @private used only to carry the response type for type inference purposes\n */\n [RequestSignature]?: RT;\n\n /**\n * see {@link EnableHydration}\n */\n [EnableHydration]?: boolean;\n}\n\n/**\n * Immutable version of {@link RequestInfo}. This is what is passed to handlers.\n *\n * @summary Read-only form of a request as handlers receive it, with frozen headers, data, options, and cache options\n * and no `controller`.\n */\nexport type ImmutableRequestInfo<RT = unknown> = Readonly<Omit<RequestInfo<RT>, 'controller'>> & {\n /**\n * see {@link CacheOptions}\n */\n readonly cacheOptions?: Readonly<CacheOptions>;\n /**\n * see {@link ImmutableHeaders}\n */\n readonly headers?: ImmutableHeaders;\n /**\n * see {@link RequestInfo.data}\n */\n readonly data?: Readonly<Record<string, unknown>>;\n /**\n * see {@link RequestInfo.options}\n */\n readonly options?: Readonly<Record<string, unknown>>;\n\n /** Whether the request body has been read.\n */\n readonly bodyUsed?: boolean;\n};\n\n/**\n * An immutable, JSON-serializable subset of the native {@link Response}\n * interface.\n *\n * @summary Immutable, JSON-serializable snapshot of a fetch `Response`'s headers, status, url, and type, usable in\n * place of a `Response` in request results.\n */\nexport interface ResponseInfo {\n /**\n * see {@link ImmutableHeaders}\n */\n readonly headers: ImmutableHeaders; // to do, maybe not this?\n /**\n * whether the response's status code was in the 200-299 range\n */\n readonly ok: boolean;\n /**\n * whether the response is the result of a redirect\n */\n readonly redirected: boolean;\n /**\n * the response's HTTP status code\n */\n readonly status: number;\n /**\n * the status message associated with the response's status code\n */\n readonly statusText: string;\n /**\n * the type of the response, see [MDN Reference](https://developer.mozilla.org/docs/Web/API/Response/type)\n */\n readonly type: ResponseType;\n /**\n * the url of the response\n */\n readonly url: string;\n}\n\n/**\n * The object a {@link Handler} uses to fulfill a request: it provides a\n * readonly view of the {@link RequestContext.request | request} and methods\n * for supplying the {@link Future}'s stream and final response.\n *\n * The [Handlers](/guides/the-manual/requests/handlers) guide shows a handler using it.\n *\n * @summary Object passed to each request handler with the immutable request, a request id, and methods for setting the\n * response stream and the response.\n */\nexport interface RequestContext {\n /**\n * @see {@link ImmutableRequestInfo}\n */\n request: ImmutableRequestInfo;\n /**\n * a unique id for this request\n */\n id: number;\n\n /**\n * Supplies the stream of the response's content, if available, enabling\n * consumers to monitor download progress via {@link RequestLoadingState}.\n */\n setStream(stream: ReadableStream | Promise<ReadableStream | null>): void;\n /**\n * Supplies the response for the request.\n */\n setResponse(response: Response | ResponseInfo | null): void;\n}\n"],"mappings":";;;;;;;;;;;;;;;;AAmCA,MAAaE,YAA6CD,kBAAkB,aAAaE,OAAOC,IAAI,eAAe,CAAC;;;;;;;;;AASpH,MAAaC,kBAAyDJ,kBACpE,mBACAE,OAAOC,IAAI,qBAAqB,CAClC;;;;AAIA,MAAaE,YAA6CN,eAAe,aAAaG,OAAO,WAAW,CAAC;;;;AAIzG,MAAaI,aAAwCP,eAAe,OAAOG,OAAO,KAAK,CAAC"}
|