@warp-drive/core 5.7.0-alpha.9 → 5.7.0-beta.0

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.
Files changed (103) hide show
  1. package/declarations/graph/-private/-diff.d.ts +7 -20
  2. package/declarations/graph/-private/-edge-definition.d.ts +3 -12
  3. package/declarations/graph/-private/-state.d.ts +0 -87
  4. package/declarations/graph/-private/-utils.d.ts +5 -11
  5. package/declarations/graph/-private/coerce-id.d.ts +0 -6
  6. package/declarations/graph/-private/debug/assert-polymorphic-type.d.ts +2 -14
  7. package/declarations/graph/-private/edges/collection.d.ts +10 -10
  8. package/declarations/graph/-private/edges/implicit.d.ts +5 -5
  9. package/declarations/graph/-private/edges/resource.d.ts +6 -7
  10. package/declarations/graph/-private/graph.d.ts +17 -51
  11. package/declarations/graph/-private/normalize-link.d.ts +0 -6
  12. package/declarations/graph/-private/operations/replace-related-records.d.ts +4 -59
  13. package/declarations/graph/-private/operations/update-relationship.d.ts +3 -7
  14. package/declarations/index.d.ts +1 -1
  15. package/declarations/reactive/-private/default-mode.d.ts +2 -2
  16. package/declarations/reactive/-private/document.d.ts +11 -27
  17. package/declarations/reactive/-private/fields/managed-array.d.ts +4 -6
  18. package/declarations/reactive/-private/fields/managed-object.d.ts +2 -8
  19. package/declarations/reactive/-private/fields/many-array-manager.d.ts +2 -2
  20. package/declarations/reactive/-private/hooks.d.ts +2 -2
  21. package/declarations/reactive/-private/record.d.ts +42 -30
  22. package/declarations/reactive/-private/schema.d.ts +11 -73
  23. package/declarations/reactive/-private/symbols.d.ts +2 -33
  24. package/declarations/reactive/-private.d.ts +1 -1
  25. package/declarations/reactive.d.ts +277 -1
  26. package/declarations/request/-private/context.d.ts +3 -5
  27. package/declarations/request/-private/fetch.d.ts +2 -2
  28. package/declarations/request/-private/manager.d.ts +24 -28
  29. package/declarations/request/-private/types.d.ts +22 -24
  30. package/declarations/request/-private/utils.d.ts +44 -2
  31. package/declarations/store/-private/cache-handler/handler.d.ts +2 -8
  32. package/declarations/store/-private/cache-handler/types.d.ts +10 -10
  33. package/declarations/store/-private/cache-handler/utils.d.ts +4 -5
  34. package/declarations/store/-private/caches/instance-cache.d.ts +21 -20
  35. package/declarations/store/-private/debug/utils.d.ts +1 -0
  36. package/declarations/store/-private/default-cache-policy.d.ts +25 -40
  37. package/declarations/store/-private/managers/cache-capabilities-manager.d.ts +24 -15
  38. package/declarations/store/-private/{caches/identifier-cache.d.ts → managers/cache-key-manager.d.ts} +35 -53
  39. package/declarations/store/-private/managers/cache-manager.d.ts +46 -111
  40. package/declarations/store/-private/managers/notification-manager.d.ts +30 -45
  41. package/declarations/store/-private/managers/record-array-manager.d.ts +44 -41
  42. package/declarations/store/-private/network/request-cache.d.ts +21 -25
  43. package/declarations/store/-private/new-core-tmp/expensive-subscription.d.ts +24 -0
  44. package/declarations/store/-private/new-core-tmp/reactivity/configure.d.ts +3 -41
  45. package/declarations/store/-private/new-core-tmp/reactivity/internal.d.ts +14 -29
  46. package/declarations/store/-private/new-core-tmp/reactivity/signal.d.ts +24 -3
  47. package/declarations/store/-private/new-core-tmp/request-state.d.ts +132 -37
  48. package/declarations/store/-private/new-core-tmp/request-subscription.d.ts +51 -135
  49. package/declarations/store/-private/record-arrays/-utils.d.ts +80 -0
  50. package/declarations/store/-private/record-arrays/legacy-live-array.d.ts +81 -0
  51. package/declarations/store/-private/record-arrays/legacy-many-array.d.ts +133 -0
  52. package/declarations/store/-private/record-arrays/legacy-query.d.ts +81 -0
  53. package/declarations/store/-private/record-arrays/native-proxy-type-fix.d.ts +1 -124
  54. package/declarations/store/-private/record-arrays/resource-array.d.ts +67 -0
  55. package/declarations/store/-private/store-service.d.ts +156 -106
  56. package/declarations/store/-private/utils/coerce-id.d.ts +0 -6
  57. package/declarations/store/-private.d.ts +11 -13
  58. package/declarations/store/-types/q/cache-capabilities-manager.d.ts +15 -24
  59. package/declarations/store/-types/q/identifier.d.ts +9 -6
  60. package/declarations/store/-types/q/record-instance.d.ts +0 -1
  61. package/declarations/store/-types/q/schema-service.d.ts +9 -9
  62. package/declarations/store/-types/q/store.d.ts +6 -7
  63. package/declarations/store/deprecated/-private.d.ts +12 -24
  64. package/declarations/store/deprecated/store.d.ts +11 -16
  65. package/declarations/types/-private.d.ts +1 -1
  66. package/declarations/types/cache/aliases.d.ts +0 -11
  67. package/declarations/types/cache/change.d.ts +2 -2
  68. package/declarations/types/cache/mutations.d.ts +13 -37
  69. package/declarations/types/cache/operations.d.ts +115 -32
  70. package/declarations/types/cache/relationship.d.ts +4 -7
  71. package/declarations/types/cache.d.ts +51 -125
  72. package/declarations/types/graph.d.ts +12 -12
  73. package/declarations/types/identifier.d.ts +52 -78
  74. package/declarations/types/params.d.ts +2 -3
  75. package/declarations/types/request.d.ts +66 -42
  76. package/declarations/types/schema/concepts.d.ts +2 -2
  77. package/declarations/types/schema/fields.d.ts +30 -3
  78. package/declarations/types/spec/document.d.ts +6 -10
  79. package/declarations/types/spec/json-api-raw.d.ts +6 -9
  80. package/declarations/types.d.ts +0 -1
  81. package/declarations/utils/string.d.ts +2 -3
  82. package/dist/{configure-B48bFHOl.js → configure-C3x8YXzL.js} +5 -5
  83. package/dist/configure.js +1 -1
  84. package/dist/{context-COmAnXUQ.js → context-C_7OLieY.js} +48 -6
  85. package/dist/graph/-private.js +137 -144
  86. package/dist/index.js +25 -14
  87. package/dist/reactive/-private.js +1 -1
  88. package/dist/reactive.js +144 -1926
  89. package/dist/{request-state-CeN66aML.js → request-state-C955e0AL.js} +5968 -3033
  90. package/dist/request.js +1 -1
  91. package/dist/store/-private.js +2 -3
  92. package/dist/store.js +32 -44
  93. package/dist/{symbols-SIstXMLI.js → symbols-sql1_mdx.js} +3 -8
  94. package/dist/types/-private.js +1 -1
  95. package/dist/types/identifier.js +19 -45
  96. package/dist/types/request.js +45 -3
  97. package/dist/types/schema/fields.js +6 -0
  98. package/dist/utils/string.js +2 -2
  99. package/package.json +11 -11
  100. package/declarations/store/-private/caches/cache-utils.d.ts +0 -12
  101. package/declarations/store/-private/record-arrays/identifier-array.d.ts +0 -147
  102. package/declarations/store/-private/record-arrays/many-array.d.ts +0 -197
  103. package/dist/handler-SdXlte1w.js +0 -339
@@ -1,4 +1,4 @@
1
- import type { StableRecordIdentifier } from "../../../types/identifier.js";
1
+ import type { ResourceKey } from "../../../types/identifier.js";
2
2
  import type { FindRecordOptions } from "../../-types/q/store.js";
3
3
  import type { Store } from "../store-service.js";
4
4
  declare const Touching: "___(unique) Symbol(Touching)";
@@ -6,7 +6,7 @@ export declare const RequestPromise: "___(unique) Symbol(RequestPromise)";
6
6
  export interface Operation {
7
7
  op: string;
8
8
  options: FindRecordOptions | undefined;
9
- recordIdentifier: StableRecordIdentifier;
9
+ recordIdentifier: ResourceKey;
10
10
  }
11
11
  export interface FindRecordQuery extends Operation {
12
12
  op: "findRecord";
@@ -26,11 +26,10 @@ export interface RequestCacheRequestState {
26
26
  response?: Response;
27
27
  }
28
28
  export interface Response {
29
- // rawData: unknown;
30
29
  data: unknown;
31
30
  }
32
31
  interface InternalRequest extends RequestCacheRequestState {
33
- [Touching]: StableRecordIdentifier[];
32
+ [Touching]: ResourceKey[];
34
33
  [RequestPromise]?: Promise<unknown>;
35
34
  }
36
35
  export type RequestSubscription = (requestState: RequestCacheRequestState) => void;
@@ -42,22 +41,7 @@ export type RequestSubscription = (requestState: RequestCacheRequestState) => vo
42
41
  * @public
43
42
  */
44
43
  export declare class RequestStateService {
45
- /** @internal */
46
- _pending: Map<StableRecordIdentifier, InternalRequest[]>;
47
- private _done;
48
- private _subscriptions;
49
- private _toFlush;
50
- private _store;
51
44
  constructor(store: Store);
52
- /** @internal */
53
- _clearEntries(identifier: StableRecordIdentifier): void;
54
- /** @internal */
55
- _enqueue<T>(promise: Promise<T>, queryRequest: Request): Promise<T>;
56
- private _triggerSubscriptions;
57
- private _flush;
58
- private _flushRequest;
59
- private _dequeue;
60
- private _addDone;
61
45
  /**
62
46
  * Subscribe to requests for a given resource identity.
63
47
  *
@@ -83,25 +67,37 @@ export declare class RequestStateService {
83
67
  * design.
84
68
  *
85
69
  * @public
86
- * @param {StableRecordIdentifier} identifier
70
+ * @param {ResourceKey} identifier
87
71
  * @param {(state: RequestCacheRequestState) => void} callback
88
72
  */
89
- subscribeForRecord(identifier: StableRecordIdentifier, callback: RequestSubscription): void;
73
+ subscribeForRecord(identifier: ResourceKey, callback: RequestSubscription): void;
90
74
  /**
91
75
  * Retrieve all active requests for a given resource identity.
92
76
  *
93
77
  * @public
94
- * @param {StableRecordIdentifier} identifier
78
+ * @param {ResourceKey} identifier
95
79
  * @return {RequestCacheRequestState[]} an array of request states for any pending requests for the given identifier
96
80
  */
97
- getPendingRequestsForRecord(identifier: StableRecordIdentifier): RequestCacheRequestState[];
81
+ getPendingRequestsForRecord(identifier: ResourceKey): RequestCacheRequestState[];
98
82
  /**
99
83
  * Retrieve the last completed request for a given resource identity.
100
84
  *
101
85
  * @public
102
- * @param {StableRecordIdentifier} identifier
86
+ * @param {ResourceKey} identifier
103
87
  * @return {RequestCacheRequestState | null} the state of the most recent request for the given identifier
104
88
  */
105
- getLastRequestForRecord(identifier: StableRecordIdentifier): RequestCacheRequestState | null;
89
+ getLastRequestForRecord(identifier: ResourceKey): RequestCacheRequestState | null;
90
+ }
91
+ /**
92
+ * This type exists for internal use only for
93
+ * where intimate contracts still exist either for
94
+ * the Test Suite or for Legacy code.
95
+ *
96
+ * @private
97
+ */
98
+ export interface PrivateRequestStateService extends RequestStateService {
99
+ _pending: Map<ResourceKey, InternalRequest[]>;
100
+ _clearEntries(identifier: ResourceKey): void;
101
+ _enqueue<T>(promise: Promise<T>, queryRequest: Request): Promise<T>;
106
102
  }
107
103
  export {};
@@ -0,0 +1,24 @@
1
+ import type { RequestKey } from "../../../types/identifier.js";
2
+ import type { Store } from "../store-service.js";
3
+ /**
4
+ * Creates an {@link ExpensiveSubscription} for the {@link RequestKey}
5
+ * if one does not already exist and adds a watcher to it.
6
+ *
7
+ * Returns a cleanup function. This should be called on-mount by a component
8
+ * that wants to subscribe to a request and cleanup should be called on dismount.
9
+ *
10
+ * ::: warning ⚠️ Avoid Using If Your App Supports Fine-grained Reactivity
11
+ * This mechanism should never be used by frameworks or libraries
12
+ * that support fine-grained reactivity.
13
+ * :::
14
+ *
15
+ * `ExpensiveSubscription` is a mechanism for non-reactive
16
+ * frameworks such as `react` to integrate with WarpDrive, for instance
17
+ * by treating a request as an [external store](https://react.dev/reference/react/useSyncExternalStore)
18
+ *
19
+ * `ExpensiveSubscription` is expensive *because* it doubles the number
20
+ * of notification callbacks required for each resource contained in
21
+ * the request being subscribed to. The more requests in-use, the more
22
+ * this cost adds up.
23
+ */
24
+ export declare function getExpensiveRequestSubscription(store: Store, requestKey: RequestKey, callback: () => void): () => void;
@@ -1,44 +1,6 @@
1
1
  export declare const ARRAY_SIGNAL: "___(unique) Symbol(#[])";
2
2
  export declare const OBJECT_SIGNAL: "___(unique) Symbol(#{})";
3
3
  /**
4
- * Requirements:
5
- *
6
- * Signal:
7
- *
8
- * - signal: a way of creating a reference that we can dirty when we desire to notify
9
- * - @signal: a way of creating an accessor on an object that subscribes to a signal on access
10
- * and notifies the signal on set, or of upgrading a descriptor to be such an accessor
11
- * - defineSignal: a way of creating a signal on an object
12
- * - notifySignal: a way of notifying the underlying signal that it has been dirtied
13
- * - peekSignal: a way of inspecting the signal without notifying it
14
- *
15
- * - gate: a memoized getter function that re-runs when on access if its signal is dirty
16
- * conceptually, a gate is a tightly coupled signal and memo
17
- * - @gate: a way of creating a gate on an object or upgrading a descriptor with a getter
18
- * to be a gate
19
- * - defineGate: a way of creating a gate on an object
20
- * - notifySignal: a way of notifying the signal for a gate that it has been dirtied
21
- *
22
- * - memo:
23
- * - @memo: a way of creating a memoized getter on an object or upgrading a descriptor with a getter
24
- * to be a memo
25
- * - defineMemo: a way of creating a memo on an object
26
- *
27
- * - signalStore: storage bucket for signals associated to an object
28
- * - withSignalStore: a way of pre-creating a signal store on an object
29
- *
30
- *
31
- * @internal
32
- */
33
- /**
34
- * An Opaque type that represents a framework specific or TC39 signal.
35
- *
36
- * It may be an array of signals or a single signal.
37
- *
38
- * @internal
39
- */
40
- export type SignalRef = unknown;
41
- /**
42
4
  * The hooks which MUST be configured in order to use reactive arrays,
43
5
  * resources and documents with framework specfic signals or TC39 signals.
44
6
  *
@@ -156,19 +118,19 @@ export declare function setupSignals<T>(buildConfig: (options: HooksOptions) =>
156
118
  /**
157
119
  * Internal method for consuming the configured `createSignal` hook
158
120
  *
159
- * @internal
121
+ * @private
160
122
  */
161
123
  export declare function createSignal(obj: object, key: string | symbol): SignalRef;
162
124
  /**
163
125
  * Internal method for consuming the configured `consumeSignal` hook
164
126
  *
165
- * @internal
127
+ * @private
166
128
  */
167
129
  export declare function consumeSignal(signal: SignalRef): void;
168
130
  /**
169
131
  * Internal method for consuming the configured `notifySignal` hook
170
132
  *
171
- * @internal
133
+ * @private
172
134
  */
173
135
  export declare function notifySignal(signal: SignalRef): void;
174
136
  export declare function createMemo<T>(object: object, key: string | symbol, fn: () => T): () => T;
@@ -1,6 +1,10 @@
1
1
  import { ARRAY_SIGNAL, OBJECT_SIGNAL, type SignalRef } from "./configure.js";
2
2
  export type { SignalRef };
3
3
  export { ARRAY_SIGNAL, OBJECT_SIGNAL };
4
+ interface Initializer {
5
+ value: () => unknown;
6
+ }
7
+ export declare function makeInitializer(fn: () => unknown): Initializer;
4
8
  /**
5
9
  * A WarpDriveSignal is a wrapper around a framework specific or TC39 signal
6
10
  * that enables us to store and manage the signal in a universal way.
@@ -27,30 +31,9 @@ export { ARRAY_SIGNAL, OBJECT_SIGNAL };
27
31
  * - the "key" or "name" of the signal
28
32
  * - the "object identity" or "context" to which the signal is attached
29
33
  *
30
- * @internal
34
+ * @private
31
35
  */
32
36
  export interface WarpDriveSignal {
33
- /**
34
- * The "key" or "name" of the signal.
35
- * This is usually (but not always) the name of a property
36
- * on the object to which the signal is attached.
37
- *
38
- * This is used for debugging purposes.
39
- * It is not used for any other purpose.
40
- *
41
- * @internal
42
- */
43
- key: string | symbol;
44
- /**
45
- * The "object identity" or "context" to which the
46
- * signal is attached.
47
- *
48
- * This is used for debugging purposes.
49
- * It is not used for any other purpose.
50
- *
51
- * @internal
52
- */
53
- context: object;
54
37
  /**
55
38
  * The underlying signal(s) in-use.
56
39
  *
@@ -94,14 +77,14 @@ export interface WarpDriveSignal {
94
77
  * },
95
78
  * });
96
79
  *
97
- * @internal
80
+ * @private
98
81
  */
99
82
  signal: SignalRef;
100
83
  /**
101
84
  * The last "value" computed for this signal when
102
85
  * a signal is also used for storage.
103
86
  *
104
- * @internal
87
+ * @private
105
88
  */
106
89
  value: unknown;
107
90
  /**
@@ -110,7 +93,7 @@ export interface WarpDriveSignal {
110
93
  * `value` cache and when using the signal as a
111
94
  * "gate"
112
95
  *
113
- * @internal
96
+ * @private
114
97
  */
115
98
  isStale: boolean;
116
99
  }
@@ -130,14 +113,14 @@ export interface WarpDriveSignal {
130
113
  * initializeSignalStore(obj);
131
114
  * ```
132
115
  *
133
- * @internal
116
+ * @private
134
117
  */
135
118
  export declare const Signals: "___(unique) Symbol(Signals)";
136
119
  export type SignalStore = Map<string | symbol, WarpDriveSignal>;
137
120
  /**
138
121
  * A type util to recast the object as having a signal store.
139
122
  *
140
- * @internal
123
+ * @private
141
124
  */
142
125
  export declare function upgradeWithSignals<T extends object>(obj: T): asserts obj is T & {
143
126
  [Signals]: SignalStore;
@@ -147,7 +130,7 @@ export declare function upgradeWithSignals<T extends object>(obj: T): asserts ob
147
130
  * if it does not already exist and returns the associated
148
131
  * signal store.
149
132
  *
150
- * @internal
133
+ * @private
151
134
  */
152
135
  export declare function withSignalStore<T extends object>(obj: T): SignalStore;
153
136
  /**
@@ -157,13 +140,15 @@ export declare function withSignalStore<T extends object>(obj: T): SignalStore;
157
140
  * Useful for pre-warming the shape of an object to ensure
158
141
  * a key-transition to add it is not required later.
159
142
  *
160
- * @internal
143
+ * @private
161
144
  */
162
145
  export declare function initializeSignalStore<T extends object>(obj: T): asserts obj is T & {
163
146
  [Signals]: SignalStore;
164
147
  };
165
148
  export declare function createInternalSignal(signals: SignalStore, obj: object, key: string | symbol, initialValue: unknown): WarpDriveSignal;
166
149
  export declare function getOrCreateInternalSignal(signals: SignalStore, obj: object, key: string | symbol, initialValue: unknown): WarpDriveSignal;
150
+ export declare function createInternalMemo<T>(signals: SignalStore, object: object, key: string | symbol, fn: () => T): () => T;
151
+ export declare function consumeInternalMemo<T>(fn: () => T): T;
167
152
  export declare function peekInternalSignal(signals: SignalStore | undefined, key: string | symbol): WarpDriveSignal | undefined;
168
153
  export declare function consumeInternalSignal(signal: WarpDriveSignal): void;
169
154
  export declare function notifyInternalSignal(signal: WarpDriveSignal | undefined): void;
@@ -4,9 +4,11 @@ import type { SignalStore, WarpDriveSignal } from "./internal.js";
4
4
  *
5
5
  * Use when you need to ensure a signal exists and is subscribed to.
6
6
  *
7
- * @internal
7
+ * @private
8
8
  */
9
9
  export declare function entangleSignal<T extends object>(signals: SignalStore, obj: T, key: string | symbol, initialValue: unknown): WarpDriveSignal;
10
+ export declare function entangleInitiallyStaleSignal<T extends object>(signals: SignalStore, obj: T, key: string | symbol, initialValue: unknown): WarpDriveSignal;
11
+ export declare function createSignalDescriptor(key: string | symbol, intialValue: unknown): PropertyDescriptor;
10
12
  /**
11
13
  * define an enumerable signal property.
12
14
  *
@@ -15,21 +17,40 @@ export declare function entangleSignal<T extends object>(signals: SignalStore, o
15
17
  * The signal will be lazily created when accessed and scoped to the
16
18
  * instance of the object.
17
19
  *
18
- * @internal
20
+ * @private
19
21
  */
20
22
  export declare function defineSignal<T extends object>(obj: T, key: string, v?: unknown): void;
21
23
  /**
22
24
  * Define a non-enumerable signal property.
23
25
  *
24
- * @internal
26
+ * @private
25
27
  */
26
28
  export declare function defineNonEnumerableSignal<T extends object>(obj: T, key: string, v?: unknown): void;
29
+ interface DecoratorPropertyDescriptor extends PropertyDescriptor {
30
+ initializer?: () => unknown;
31
+ }
32
+ /**
33
+ * Decorator version of creating a signal.
34
+ */
35
+ export declare function signal<
36
+ T extends object,
37
+ K extends keyof T & string
38
+ >(target: T, key: K, descriptor?: DecoratorPropertyDescriptor): void;
39
+ /**
40
+ * Decorator version of creating a memoized getter
41
+ */
27
42
  export declare function memoized<
28
43
  T extends object,
29
44
  K extends keyof T & string
30
45
  >(target: T, key: K, descriptor: PropertyDescriptor): PropertyDescriptor;
46
+ /**
47
+ * Decorator version of creating a gate.
48
+ *
49
+ * @private
50
+ */
31
51
  export declare function gate<
32
52
  T extends object,
33
53
  K extends keyof T & string
34
54
  >(_target: T, key: K, desc: PropertyDescriptor): PropertyDescriptor;
35
55
  export declare function defineGate<T extends object>(obj: T, key: string, desc: PropertyDescriptor): void;
56
+ export {};
@@ -6,23 +6,9 @@ import type { PendingPromise, RejectedPromise, ResolvedPromise } from "./promise
6
6
  * reactive properties that can be used to build UIs that respond
7
7
  * to the progress of a request.
8
8
  *
9
+ * @hideconstructor
9
10
  */
10
11
  export declare class RequestLoadingState {
11
- private _sizeHint;
12
- private _bytesLoaded;
13
- private _startTime;
14
- private _endTime;
15
- private _lastPacketTime;
16
- private _isPending;
17
- private _isStarted;
18
- private _isComplete;
19
- private _isCancelled;
20
- private _isErrored;
21
- private _error;
22
- private _stream;
23
- private _future;
24
- private _triggered;
25
- private _trigger;
26
12
  promise: Promise<void> | null;
27
13
  get isPending(): boolean;
28
14
  get sizeHint(): number;
@@ -69,17 +55,55 @@ export interface PendingRequest extends PendingPromise {
69
55
  * Extends the {@link ResolvedPromise} interface.
70
56
  *
71
57
  */
72
- export interface ResolvedRequest<
73
- RT,
74
- T
75
- > extends ResolvedPromise<RT> {
58
+ export interface ResolvedRequest<RT> extends ResolvedPromise<RT> {
59
+ /**
60
+ * Retries the request with high (blocking) priority. This is the
61
+ * same as having passed `cacheOptions.reload = true` on the original
62
+ * request.
63
+ *
64
+ * This will not change the existing request's state. To subscribe
65
+ * to the new request's state, use `getRequestState` on the returned
66
+ * {@link Future}.
67
+ *
68
+ * ```ts
69
+ * const future = state.reload();
70
+ * const state = getRequestState(future);
71
+ * ```
72
+ *
73
+ * It is safe to pass this around as an "action" or "event" handler
74
+ * as its context is bound.
75
+ */
76
+ reload(): Future<RT>;
77
+ /**
78
+ * Retries the request with low (non-blocking) priority. This is the
79
+ * same as having passed `cacheOptions.backgroundReload = true` on the original
80
+ * request.
81
+ *
82
+ * This will not change the existing request's state. To subscribe
83
+ * to the new request's state, use `getRequestState` on the returned
84
+ * {@link Future}.
85
+ *
86
+ * ```ts
87
+ * const future = state.reload();
88
+ * const state = getRequestState(future);
89
+ * ```
90
+ *
91
+ * It is safe to pass this around as an "action" or "event" handler
92
+ * as its context is bound.
93
+ */
94
+ refresh(usePolicy?: boolean): Future<RT>;
76
95
  /**
77
96
  * Whether the request is cancelled.
78
97
  *
79
98
  */
80
99
  isCancelled: false;
100
+ /**
101
+ * A lazily created {@link RequestLoadingState} instance
102
+ * which provides a number of reactive properties that can be used
103
+ * to build UIs that respond to the progress of a request.
104
+ */
81
105
  loadingState: RequestLoadingState;
82
- request: ImmutableRequestInfo<RT, T> | null;
106
+ request: ImmutableRequestInfo<RT> | null;
83
107
  response: Response | ResponseInfo | null;
84
108
  }
85
109
  /**
@@ -92,16 +116,51 @@ export interface ResolvedRequest<
92
116
  */
93
117
  export interface RejectedRequest<
94
118
  RT,
95
- T,
96
119
  E extends StructuredErrorDocument = StructuredErrorDocument
97
120
  > extends RejectedPromise<E> {
121
+ /**
122
+ * Retries the request with high (blocking) priority. This is the
123
+ * same as having passed `cacheOptions.reload = true` on the original
124
+ * request.
125
+ *
126
+ * This will not change the existing request's state. To subscribe
127
+ * to the new request's state, use `getRequestState` on the returned
128
+ * {@link Future}.
129
+ *
130
+ * ```ts
131
+ * const future = state.reload();
132
+ * const state = getRequestState(future);
133
+ * ```
134
+ *
135
+ * It is safe to pass this around as an "action" or "event" handler
136
+ * as its context is bound.
137
+ */
138
+ reload(): Future<RT>;
139
+ /**
140
+ * Retries the request with low (non-blocking) priority. This is the
141
+ * same as having passed `cacheOptions.backgroundReload = true` on the original
142
+ * request.
143
+ *
144
+ * This will not change the existing request's state. To subscribe
145
+ * to the new request's state, use `getRequestState` on the returned
146
+ * {@link Future}.
147
+ *
148
+ * ```ts
149
+ * const future = state.reload();
150
+ * const state = getRequestState(future);
151
+ * ```
152
+ *
153
+ * It is safe to pass this around as an "action" or "event" handler
154
+ * as its context is bound.
155
+ */
156
+ refresh(usePolicy?: boolean): Future<RT>;
98
157
  /**
99
158
  * Whether the request is cancelled.
100
159
  *
101
160
  */
102
161
  isCancelled: false;
103
162
  loadingState: RequestLoadingState;
104
- request: ImmutableRequestInfo<RT, T> | null;
163
+ request: ImmutableRequestInfo<RT> | null;
105
164
  response: Response | ResponseInfo | null;
106
165
  }
107
166
  /**
@@ -112,9 +171,44 @@ export interface RejectedRequest<
112
171
  */
113
172
  export interface CancelledRequest<
114
173
  RT,
115
- T,
116
174
  E extends StructuredErrorDocument = StructuredErrorDocument
117
175
  > {
176
+ /**
177
+ * Retries the request with high (blocking) priority. This is the
178
+ * same as having passed `cacheOptions.reload = true` on the original
179
+ * request.
180
+ *
181
+ * This will not change the existing request's state. To subscribe
182
+ * to the new request's state, use `getRequestState` on the returned
183
+ * {@link Future}.
184
+ *
185
+ * ```ts
186
+ * const future = state.reload();
187
+ * const state = getRequestState(future);
188
+ * ```
189
+ *
190
+ * It is safe to pass this around as an "action" or "event" handler
191
+ * as its context is bound.
192
+ */
193
+ reload(): Future<RT>;
194
+ /**
195
+ * Retries the request with low (non-blocking) priority. This is the
196
+ * same as having passed `cacheOptions.backgroundReload = true` on the original
197
+ * request.
198
+ *
199
+ * This will not change the existing request's state. To subscribe
200
+ * to the new request's state, use `getRequestState` on the returned
201
+ * {@link Future}.
202
+ *
203
+ * ```ts
204
+ * const future = state.reload();
205
+ * const state = getRequestState(future);
206
+ * ```
207
+ *
208
+ * It is safe to pass this around as an "action" or "event" handler
209
+ * as its context is bound.
210
+ */
211
+ refresh(usePolicy?: boolean): Future<RT>;
118
212
  /**
119
213
  * The status of the request.
120
214
  *
@@ -175,33 +269,37 @@ export interface CancelledRequest<
175
269
  */
176
270
  isCancelled: true;
177
271
  loadingState: RequestLoadingState;
178
- request: ImmutableRequestInfo<RT, T> | null;
272
+ request: ImmutableRequestInfo<RT> | null;
179
273
  response: Response | ResponseInfo | null;
180
274
  }
275
+ export interface PrivateRequestState {
276
+ _loadingState?: RequestLoadingState;
277
+ _request: Future<unknown>;
278
+ }
181
279
  /**
182
- * RequestState extends the concept of PromiseState to provide a reactive
183
- * wrapper for a request `Future` which allows you write declarative code
280
+ * RequestState extends the concept of {@link PromiseState} to provide a reactive
281
+ * wrapper for a request {@link Future} which allows you write declarative code
184
282
  * around a Future's control flow.
185
283
  *
186
284
  * It is useful in both Template and JavaScript contexts, allowing you
187
285
  * to quickly derive behaviors and data from pending, error and success
188
286
  * states.
189
287
  *
190
- * The key difference between a Promise and a Future is that Futures provide
191
- * access to a stream of their content, the identity of the request (if any)
192
- * as well as the ability to attempt to abort the request.
288
+ * The key difference between a {@link Promise} and a Future is that Futures provide
289
+ * access to a {@link ReadableStream | stream} of their content, the {@link RequestKey} of the request (if any)
290
+ * as well as the ability to attempt to {@link Future.abort | abort} the request.
193
291
  *
194
292
  * ```ts
195
293
  * interface Future<T> extends Promise<T>> {
196
294
  * getStream(): Promise<ReadableStream>;
197
295
  * abort(): void;
198
- * lid: StableDocumentIdentifier | null;
296
+ * lid: RequestKey | null;
199
297
  * }
200
298
  * ```
201
299
  *
202
300
  * These additional APIs allow us to craft even richer state experiences.
203
301
  *
204
- * To get the state of a request, use `getRequestState`.
302
+ * To get the state of a request, use {@link getRequestState}.
205
303
  *
206
304
  * See also:
207
305
  * - {@link PendingRequest}
@@ -212,14 +310,12 @@ export interface CancelledRequest<
212
310
  */
213
311
  export type RequestCacheRequestState<
214
312
  RT = unknown,
215
- T = unknown,
216
313
  E extends StructuredErrorDocument = StructuredErrorDocument
217
- > = PendingRequest | ResolvedRequest<RT, T> | RejectedRequest<RT, T, E> | CancelledRequest<RT, T, E>;
314
+ > = PendingRequest | ResolvedRequest<RT> | RejectedRequest<RT, E> | CancelledRequest<RT, E>;
218
315
  export declare function createRequestState<
219
316
  RT,
220
- T,
221
317
  E
222
- >(future: Future<RT>): Readonly<RequestCacheRequestState<RT, T, StructuredErrorDocument<E>>>;
318
+ >(future: Future<RT>): Readonly<RequestCacheRequestState<RT, StructuredErrorDocument<E>>>;
223
319
  /**
224
320
  * `getRequestState` can be used in both JavaScript and Template contexts.
225
321
  *
@@ -272,6 +368,5 @@ export declare function createRequestState<
272
368
  */
273
369
  export declare function getRequestState<
274
370
  RT,
275
- T,
276
371
  E
277
- >(future: Future<RT>): Readonly<RequestCacheRequestState<RT, T, StructuredErrorDocument<E>>>;
372
+ >(future: Future<RT>): Readonly<RequestCacheRequestState<RT, StructuredErrorDocument<E>>>;