@warp-drive/core 5.6.0-beta.1 → 5.6.0-beta.2

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 (120) 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 +2 -2
  4. package/declarations/graph/-private/-utils.d.ts +5 -5
  5. package/declarations/graph/-private/debug/assert-polymorphic-type.d.ts +3 -3
  6. package/declarations/graph/-private/edges/collection.d.ts +10 -10
  7. package/declarations/graph/-private/edges/implicit.d.ts +5 -5
  8. package/declarations/graph/-private/edges/resource.d.ts +6 -7
  9. package/declarations/graph/-private/graph.d.ts +17 -15
  10. package/declarations/graph/-private/operations/replace-related-records.d.ts +4 -4
  11. package/declarations/graph/-private/operations/update-relationship.d.ts +3 -3
  12. package/declarations/index.d.ts +1 -1
  13. package/declarations/reactive/-private/default-mode.d.ts +73 -0
  14. package/declarations/reactive/-private/document.d.ts +11 -27
  15. package/declarations/reactive/-private/fields/get-field-key.d.ts +8 -0
  16. package/declarations/reactive/-private/fields/managed-array.d.ts +7 -10
  17. package/declarations/reactive/-private/fields/managed-object.d.ts +7 -9
  18. package/declarations/reactive/-private/fields/many-array-manager.d.ts +2 -2
  19. package/declarations/reactive/-private/hooks.d.ts +2 -2
  20. package/declarations/reactive/-private/kind/alias-field.d.ts +4 -0
  21. package/declarations/reactive/-private/kind/array-field.d.ts +4 -0
  22. package/declarations/reactive/-private/kind/attribute-field.d.ts +4 -0
  23. package/declarations/reactive/-private/kind/belongs-to-field.d.ts +4 -0
  24. package/declarations/reactive/-private/kind/collection-field.d.ts +4 -0
  25. package/declarations/reactive/-private/kind/derived-field.d.ts +4 -0
  26. package/declarations/reactive/-private/kind/generic-field.d.ts +4 -0
  27. package/declarations/reactive/-private/kind/has-many-field.d.ts +4 -0
  28. package/declarations/reactive/-private/kind/hash-field.d.ts +4 -0
  29. package/declarations/reactive/-private/kind/identity-field.d.ts +4 -0
  30. package/declarations/reactive/-private/kind/local-field.d.ts +4 -0
  31. package/declarations/reactive/-private/kind/object-field.d.ts +4 -0
  32. package/declarations/reactive/-private/kind/resource-field.d.ts +4 -0
  33. package/declarations/reactive/-private/kind/schema-array-field.d.ts +4 -0
  34. package/declarations/reactive/-private/kind/schema-object-field.d.ts +4 -0
  35. package/declarations/reactive/-private/record.d.ts +44 -33
  36. package/declarations/reactive/-private/schema.d.ts +50 -66
  37. package/declarations/reactive/-private/symbols.d.ts +2 -7
  38. package/declarations/reactive/-private.d.ts +1 -1
  39. package/declarations/reactive.d.ts +278 -1
  40. package/declarations/request/-private/context.d.ts +3 -5
  41. package/declarations/request/-private/fetch.d.ts +2 -0
  42. package/declarations/request/-private/manager.d.ts +24 -28
  43. package/declarations/request/-private/types.d.ts +22 -23
  44. package/declarations/request/-private/utils.d.ts +44 -2
  45. package/declarations/store/-private/cache-handler/handler.d.ts +2 -8
  46. package/declarations/store/-private/cache-handler/types.d.ts +10 -10
  47. package/declarations/store/-private/cache-handler/utils.d.ts +4 -4
  48. package/declarations/store/-private/caches/instance-cache.d.ts +22 -27
  49. package/declarations/store/-private/debug/utils.d.ts +1 -0
  50. package/declarations/store/-private/default-cache-policy.d.ts +25 -38
  51. package/declarations/store/-private/managers/cache-capabilities-manager.d.ts +24 -15
  52. package/declarations/store/-private/{caches/identifier-cache.d.ts → managers/cache-key-manager.d.ts} +38 -52
  53. package/declarations/store/-private/managers/cache-manager.d.ts +46 -95
  54. package/declarations/store/-private/managers/notification-manager.d.ts +30 -43
  55. package/declarations/store/-private/managers/record-array-manager.d.ts +44 -41
  56. package/declarations/store/-private/network/request-cache.d.ts +21 -24
  57. package/declarations/store/-private/new-core-tmp/expensive-subscription.d.ts +24 -0
  58. package/declarations/store/-private/new-core-tmp/reactivity/configure.d.ts +3 -41
  59. package/declarations/store/-private/new-core-tmp/reactivity/internal.d.ts +14 -29
  60. package/declarations/store/-private/new-core-tmp/reactivity/signal.d.ts +24 -3
  61. package/declarations/store/-private/new-core-tmp/request-state.d.ts +133 -37
  62. package/declarations/store/-private/new-core-tmp/request-subscription.d.ts +51 -133
  63. package/declarations/store/-private/record-arrays/-utils.d.ts +80 -0
  64. package/declarations/store/-private/record-arrays/legacy-live-array.d.ts +81 -0
  65. package/declarations/store/-private/record-arrays/legacy-many-array.d.ts +133 -0
  66. package/declarations/store/-private/record-arrays/legacy-query.d.ts +81 -0
  67. package/declarations/store/-private/record-arrays/native-proxy-type-fix.d.ts +1 -124
  68. package/declarations/store/-private/record-arrays/resource-array.d.ts +75 -0
  69. package/declarations/store/-private/store-service.d.ts +167 -872
  70. package/declarations/store/-private.d.ts +14 -10
  71. package/declarations/store/-types/q/cache-capabilities-manager.d.ts +15 -24
  72. package/declarations/store/-types/q/identifier.d.ts +9 -6
  73. package/declarations/store/-types/q/record-instance.d.ts +0 -1
  74. package/declarations/store/-types/q/schema-service.d.ts +64 -40
  75. package/declarations/store/-types/q/store.d.ts +6 -7
  76. package/declarations/store/deprecated/-private.d.ts +224 -0
  77. package/declarations/store/deprecated/store.d.ts +787 -0
  78. package/declarations/types/-private.d.ts +1 -1
  79. package/declarations/types/cache/aliases.d.ts +2 -2
  80. package/declarations/types/cache/change.d.ts +2 -2
  81. package/declarations/types/cache/mutations.d.ts +13 -13
  82. package/declarations/types/cache/operations.d.ts +115 -32
  83. package/declarations/types/cache/relationship.d.ts +4 -4
  84. package/declarations/types/cache.d.ts +51 -115
  85. package/declarations/types/graph.d.ts +12 -12
  86. package/declarations/types/identifier.d.ts +52 -76
  87. package/declarations/types/params.d.ts +2 -3
  88. package/declarations/types/request.d.ts +69 -42
  89. package/declarations/types/schema/concepts.d.ts +2 -2
  90. package/declarations/types/schema/fields.d.ts +391 -14
  91. package/declarations/types/spec/document.d.ts +6 -6
  92. package/declarations/types/spec/json-api-raw.d.ts +6 -8
  93. package/declarations/types.d.ts +2 -1
  94. package/declarations/utils/string.d.ts +2 -2
  95. package/dist/{configure-B48bFHOl.js → configure-C3x8YXzL.js} +5 -5
  96. package/dist/configure.js +1 -1
  97. package/dist/{context-COmAnXUQ.js → context-C_7OLieY.js} +48 -6
  98. package/dist/graph/-private.js +137 -144
  99. package/dist/index.js +25 -14
  100. package/dist/reactive/-private.js +1 -1
  101. package/dist/reactive.js +337 -1422
  102. package/dist/{request-state-CjLph1LP.js → request-state-C955e0AL.js} +8352 -5912
  103. package/dist/request.js +1 -1
  104. package/dist/store/-private.js +2 -3
  105. package/dist/store.js +32 -44
  106. package/dist/{symbols-SIstXMLI.js → symbols-sql1_mdx.js} +3 -8
  107. package/dist/types/-private.js +1 -1
  108. package/dist/types/identifier.js +19 -45
  109. package/dist/types/request.js +45 -3
  110. package/dist/types/schema/fields.js +23 -2
  111. package/dist/utils/string.js +2 -2
  112. package/package.json +10 -10
  113. package/declarations/reactive/-private/fields/compute.d.ts +0 -43
  114. package/declarations/store/-private/caches/cache-utils.d.ts +0 -12
  115. package/declarations/store/-private/legacy-model-support/record-reference.d.ts +0 -159
  116. package/declarations/store/-private/legacy-model-support/shim-model-class.d.ts +0 -17
  117. package/declarations/store/-private/record-arrays/identifier-array.d.ts +0 -147
  118. package/declarations/store/-private/record-arrays/many-array.d.ts +0 -197
  119. package/declarations/store/-types/q/ds-model.d.ts +0 -21
  120. package/dist/handler-C2T-IyJK.js +0 -339
@@ -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 {};
@@ -1,28 +1,15 @@
1
1
  import type { Future } from "../../../request.js";
2
2
  import type { ImmutableRequestInfo, ResponseInfo, StructuredErrorDocument } from "../../../types/request.js";
3
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
3
4
  import type { PendingPromise, RejectedPromise, ResolvedPromise } from "./promise-state.js";
4
5
  /**
5
6
  * Lazily consumes the stream of a request, providing a number of
6
7
  * reactive properties that can be used to build UIs that respond
7
8
  * to the progress of a request.
8
9
  *
10
+ * @hideconstructor
9
11
  */
10
12
  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
13
  promise: Promise<void> | null;
27
14
  get isPending(): boolean;
28
15
  get sizeHint(): number;
@@ -69,17 +56,55 @@ export interface PendingRequest extends PendingPromise {
69
56
  * Extends the {@link ResolvedPromise} interface.
70
57
  *
71
58
  */
72
- export interface ResolvedRequest<
73
- RT,
74
- T
75
- > extends ResolvedPromise<RT> {
59
+ export interface ResolvedRequest<RT> extends ResolvedPromise<RT> {
60
+ /**
61
+ * Retries the request with high (blocking) priority. This is the
62
+ * same as having passed `cacheOptions.reload = true` on the original
63
+ * request.
64
+ *
65
+ * This will not change the existing request's state. To subscribe
66
+ * to the new request's state, use `getRequestState` on the returned
67
+ * {@link Future}.
68
+ *
69
+ * ```ts
70
+ * const future = state.reload();
71
+ * const state = getRequestState(future);
72
+ * ```
73
+ *
74
+ * It is safe to pass this around as an "action" or "event" handler
75
+ * as its context is bound.
76
+ */
77
+ reload(): Future<RT>;
78
+ /**
79
+ * Retries the request with low (non-blocking) priority. This is the
80
+ * same as having passed `cacheOptions.backgroundReload = true` on the original
81
+ * request.
82
+ *
83
+ * This will not change the existing request's state. To subscribe
84
+ * to the new request's state, use `getRequestState` on the returned
85
+ * {@link Future}.
86
+ *
87
+ * ```ts
88
+ * const future = state.reload();
89
+ * const state = getRequestState(future);
90
+ * ```
91
+ *
92
+ * It is safe to pass this around as an "action" or "event" handler
93
+ * as its context is bound.
94
+ */
95
+ refresh(usePolicy?: boolean): Future<RT>;
76
96
  /**
77
97
  * Whether the request is cancelled.
78
98
  *
79
99
  */
80
100
  isCancelled: false;
101
+ /**
102
+ * A lazily created {@link RequestLoadingState} instance
103
+ * which provides a number of reactive properties that can be used
104
+ * to build UIs that respond to the progress of a request.
105
+ */
81
106
  loadingState: RequestLoadingState;
82
- request: ImmutableRequestInfo<RT, T> | null;
107
+ request: ImmutableRequestInfo<RT> | null;
83
108
  response: Response | ResponseInfo | null;
84
109
  }
85
110
  /**
@@ -92,16 +117,51 @@ export interface ResolvedRequest<
92
117
  */
93
118
  export interface RejectedRequest<
94
119
  RT,
95
- T,
96
120
  E extends StructuredErrorDocument = StructuredErrorDocument
97
121
  > extends RejectedPromise<E> {
122
+ /**
123
+ * Retries the request with high (blocking) priority. This is the
124
+ * same as having passed `cacheOptions.reload = true` on the original
125
+ * request.
126
+ *
127
+ * This will not change the existing request's state. To subscribe
128
+ * to the new request's state, use `getRequestState` on the returned
129
+ * {@link Future}.
130
+ *
131
+ * ```ts
132
+ * const future = state.reload();
133
+ * const state = getRequestState(future);
134
+ * ```
135
+ *
136
+ * It is safe to pass this around as an "action" or "event" handler
137
+ * as its context is bound.
138
+ */
139
+ reload(): Future<RT>;
140
+ /**
141
+ * Retries the request with low (non-blocking) priority. This is the
142
+ * same as having passed `cacheOptions.backgroundReload = true` on the original
143
+ * request.
144
+ *
145
+ * This will not change the existing request's state. To subscribe
146
+ * to the new request's state, use `getRequestState` on the returned
147
+ * {@link Future}.
148
+ *
149
+ * ```ts
150
+ * const future = state.reload();
151
+ * const state = getRequestState(future);
152
+ * ```
153
+ *
154
+ * It is safe to pass this around as an "action" or "event" handler
155
+ * as its context is bound.
156
+ */
157
+ refresh(usePolicy?: boolean): Future<RT>;
98
158
  /**
99
159
  * Whether the request is cancelled.
100
160
  *
101
161
  */
102
162
  isCancelled: false;
103
163
  loadingState: RequestLoadingState;
104
- request: ImmutableRequestInfo<RT, T> | null;
164
+ request: ImmutableRequestInfo<RT> | null;
105
165
  response: Response | ResponseInfo | null;
106
166
  }
107
167
  /**
@@ -112,9 +172,44 @@ export interface RejectedRequest<
112
172
  */
113
173
  export interface CancelledRequest<
114
174
  RT,
115
- T,
116
175
  E extends StructuredErrorDocument = StructuredErrorDocument
117
176
  > {
177
+ /**
178
+ * Retries the request with high (blocking) priority. This is the
179
+ * same as having passed `cacheOptions.reload = true` on the original
180
+ * request.
181
+ *
182
+ * This will not change the existing request's state. To subscribe
183
+ * to the new request's state, use `getRequestState` on the returned
184
+ * {@link Future}.
185
+ *
186
+ * ```ts
187
+ * const future = state.reload();
188
+ * const state = getRequestState(future);
189
+ * ```
190
+ *
191
+ * It is safe to pass this around as an "action" or "event" handler
192
+ * as its context is bound.
193
+ */
194
+ reload(): Future<RT>;
195
+ /**
196
+ * Retries the request with low (non-blocking) priority. This is the
197
+ * same as having passed `cacheOptions.backgroundReload = true` on the original
198
+ * request.
199
+ *
200
+ * This will not change the existing request's state. To subscribe
201
+ * to the new request's state, use `getRequestState` on the returned
202
+ * {@link Future}.
203
+ *
204
+ * ```ts
205
+ * const future = state.reload();
206
+ * const state = getRequestState(future);
207
+ * ```
208
+ *
209
+ * It is safe to pass this around as an "action" or "event" handler
210
+ * as its context is bound.
211
+ */
212
+ refresh(usePolicy?: boolean): Future<RT>;
118
213
  /**
119
214
  * The status of the request.
120
215
  *
@@ -175,33 +270,37 @@ export interface CancelledRequest<
175
270
  */
176
271
  isCancelled: true;
177
272
  loadingState: RequestLoadingState;
178
- request: ImmutableRequestInfo<RT, T> | null;
273
+ request: ImmutableRequestInfo<RT> | null;
179
274
  response: Response | ResponseInfo | null;
180
275
  }
276
+ export interface PrivateRequestState {
277
+ _loadingState?: RequestLoadingState;
278
+ _request: Future<unknown>;
279
+ }
181
280
  /**
182
- * RequestState extends the concept of PromiseState to provide a reactive
183
- * wrapper for a request `Future` which allows you write declarative code
281
+ * RequestState extends the concept of {@link PromiseState} to provide a reactive
282
+ * wrapper for a request {@link Future} which allows you write declarative code
184
283
  * around a Future's control flow.
185
284
  *
186
285
  * It is useful in both Template and JavaScript contexts, allowing you
187
286
  * to quickly derive behaviors and data from pending, error and success
188
287
  * states.
189
288
  *
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.
289
+ * The key difference between a {@link Promise} and a Future is that Futures provide
290
+ * access to a {@link ReadableStream | stream} of their content, the {@link RequestKey} of the request (if any)
291
+ * as well as the ability to attempt to {@link Future.abort | abort} the request.
193
292
  *
194
293
  * ```ts
195
294
  * interface Future<T> extends Promise<T>> {
196
295
  * getStream(): Promise<ReadableStream>;
197
296
  * abort(): void;
198
- * lid: StableDocumentIdentifier | null;
297
+ * lid: RequestKey | null;
199
298
  * }
200
299
  * ```
201
300
  *
202
301
  * These additional APIs allow us to craft even richer state experiences.
203
302
  *
204
- * To get the state of a request, use `getRequestState`.
303
+ * To get the state of a request, use {@link getRequestState}.
205
304
  *
206
305
  * See also:
207
306
  * - {@link PendingRequest}
@@ -212,14 +311,12 @@ export interface CancelledRequest<
212
311
  */
213
312
  export type RequestCacheRequestState<
214
313
  RT = unknown,
215
- T = unknown,
216
314
  E extends StructuredErrorDocument = StructuredErrorDocument
217
- > = PendingRequest | ResolvedRequest<RT, T> | RejectedRequest<RT, T, E> | CancelledRequest<RT, T, E>;
315
+ > = PendingRequest | ResolvedRequest<RT> | RejectedRequest<RT, E> | CancelledRequest<RT, E>;
218
316
  export declare function createRequestState<
219
317
  RT,
220
- T,
221
318
  E
222
- >(future: Future<RT>): Readonly<RequestCacheRequestState<RT, T, StructuredErrorDocument<E>>>;
319
+ >(future: Future<RT>): Readonly<RequestCacheRequestState<RT, StructuredErrorDocument<E>>>;
223
320
  /**
224
321
  * `getRequestState` can be used in both JavaScript and Template contexts.
225
322
  *
@@ -272,6 +369,5 @@ export declare function createRequestState<
272
369
  */
273
370
  export declare function getRequestState<
274
371
  RT,
275
- T,
276
372
  E
277
- >(future: Future<RT>): Readonly<RequestCacheRequestState<RT, T, StructuredErrorDocument<E>>>;
373
+ >(future: Future<RT>): Readonly<RequestCacheRequestState<RT, StructuredErrorDocument<E>>>;