@warp-drive/core 5.7.0-alpha.23 → 5.7.0-alpha.24
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/declarations/reactive/-private/schema.d.ts +6 -0
- package/declarations/request/-private/manager.d.ts +2 -6
- package/declarations/request/-private/types.d.ts +19 -18
- package/declarations/store/-private/new-core-tmp/request-state.d.ts +114 -0
- package/declarations/store/-private/new-core-tmp/request-subscription.d.ts +6 -2
- package/declarations/types/request.d.ts +1 -1
- package/dist/{context-kQXhkeBj.js → context-BNZebmoO.js} +2 -0
- package/dist/index.js +6 -7
- package/dist/reactive.js +9 -2
- package/dist/{request-state-55umD7hP.js → request-state-CcOnn4ej.js} +69 -26
- package/dist/request.js +1 -1
- package/dist/store/-private.js +1 -1
- package/dist/types/-private.js +1 -1
- package/package.json +3 -3
|
@@ -301,6 +301,12 @@ export declare class SchemaService implements SchemaServiceInterface {
|
|
|
301
301
|
* @internal
|
|
302
302
|
*/
|
|
303
303
|
_kind<T extends keyof KindFns>(mode: string, kind: T): KindFns[T];
|
|
304
|
+
/**
|
|
305
|
+
* Registers a {@link HashFn} for use with a {@link HashField} for
|
|
306
|
+
* either {@link ObjectSchema} identity or polymorphic type calculation.
|
|
307
|
+
*
|
|
308
|
+
* @public
|
|
309
|
+
*/
|
|
304
310
|
registerHashFn<T extends object>(hashFn: HashFn<T>): void;
|
|
305
311
|
fields({ type }: {
|
|
306
312
|
type: string;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { RequestKey } from "../../types/identifier.js";
|
|
2
|
-
import type
|
|
2
|
+
import { type RequestInfo } from "../../types/request.js";
|
|
3
3
|
import type { CacheHandler, Future, GenericCreateArgs, Handler, ManagedRequestPriority } from "./types.js";
|
|
4
4
|
import { IS_CACHE_HANDLER } from "./utils.js";
|
|
5
5
|
/**
|
|
@@ -90,7 +90,7 @@ import { IS_CACHE_HANDLER } from "./utils.js";
|
|
|
90
90
|
* type StructuredDocument<T> = StructuredDataDocument<T> | StructuredErrorDocument;
|
|
91
91
|
* ```
|
|
92
92
|
*
|
|
93
|
-
* @
|
|
93
|
+
* @hideconstructor
|
|
94
94
|
* @public
|
|
95
95
|
*/
|
|
96
96
|
export declare class RequestManager {
|
|
@@ -132,8 +132,6 @@ export declare class RequestManager {
|
|
|
132
132
|
* curry the request, or pass along a modified request.
|
|
133
133
|
*
|
|
134
134
|
* @public
|
|
135
|
-
* @param {Handler[]} newHandlers
|
|
136
|
-
* @return {ThisType}
|
|
137
135
|
*/
|
|
138
136
|
use(newHandlers: Handler[]): this;
|
|
139
137
|
/**
|
|
@@ -142,8 +140,6 @@ export declare class RequestManager {
|
|
|
142
140
|
* Returns a Future that fulfills with a StructuredDocument
|
|
143
141
|
*
|
|
144
142
|
* @public
|
|
145
|
-
* @param {RequestInfo} request
|
|
146
|
-
* @return {Future}
|
|
147
143
|
*/
|
|
148
144
|
request<RT>(request: RequestInfo<RT>): Future<RT>;
|
|
149
145
|
/**
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
/* eslint-disable no-irregular-whitespace */
|
|
2
|
+
import type { Store } from "../../store/-private.js";
|
|
2
3
|
import type { RequestKey } from "../../types/identifier.js";
|
|
3
4
|
import type { IS_FUTURE, RequestContext, RequestInfo, ResponseInfo, StructuredDataDocument } from "../../types/request.js";
|
|
5
|
+
import type { RequestManager } from "./manager.js";
|
|
4
6
|
export interface GodContext {
|
|
5
7
|
controller: AbortController;
|
|
6
8
|
response: ResponseInfo | null;
|
|
@@ -8,6 +10,7 @@ export interface GodContext {
|
|
|
8
10
|
hasRequestedStream: boolean;
|
|
9
11
|
id: number;
|
|
10
12
|
identifier: RequestKey | null;
|
|
13
|
+
requester: RequestManager | Store;
|
|
11
14
|
}
|
|
12
15
|
export type Deferred<T> = {
|
|
13
16
|
resolve(v: T): void;
|
|
@@ -32,10 +35,14 @@ export type DeferredStream = {
|
|
|
32
35
|
* @public
|
|
33
36
|
*/
|
|
34
37
|
export interface Future<T> extends Promise<StructuredDataDocument<T>> {
|
|
38
|
+
/** @internal */
|
|
35
39
|
[IS_FUTURE]: true;
|
|
36
40
|
/**
|
|
37
41
|
* Cancel this request by firing the {@link AbortController}'s signal.
|
|
38
42
|
*
|
|
43
|
+
* This method can be used as an action or event handler as its
|
|
44
|
+
* context is bound to the Future instance.
|
|
45
|
+
*
|
|
39
46
|
* @privateRemarks
|
|
40
47
|
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/AbortController/abort)
|
|
41
48
|
*
|
|
@@ -46,8 +53,10 @@ export interface Future<T> extends Promise<StructuredDataDocument<T>> {
|
|
|
46
53
|
/**
|
|
47
54
|
* Get the response stream, if any, once made available.
|
|
48
55
|
*
|
|
56
|
+
* This method can be used as an action or event handler as its
|
|
57
|
+
* context is bound to the Future instance.
|
|
58
|
+
*
|
|
49
59
|
* @public
|
|
50
|
-
* @return {Promise<ReadableStream | null>}
|
|
51
60
|
*/
|
|
52
61
|
getStream(): Promise<ReadableStream | null>;
|
|
53
62
|
/**
|
|
@@ -55,28 +64,27 @@ export interface Future<T> extends Promise<StructuredDataDocument<T>> {
|
|
|
55
64
|
* mostly useful for instrumentation and infrastructure.
|
|
56
65
|
*
|
|
57
66
|
* @param cb the callback to run
|
|
58
|
-
* @public
|
|
59
|
-
* @return {void}
|
|
60
67
|
*/
|
|
61
68
|
onFinalize(cb: () => void): void;
|
|
62
69
|
/**
|
|
63
70
|
* The identifier of the associated request, if any, as
|
|
64
71
|
* assigned by the CacheHandler.
|
|
65
|
-
*
|
|
66
|
-
* @property lid
|
|
67
|
-
* @type {RequestKey | null}
|
|
68
|
-
* @public
|
|
69
72
|
*/
|
|
70
73
|
lid: RequestKey | null;
|
|
71
74
|
/**
|
|
72
75
|
* The id of the associated request, if any, as assigned
|
|
73
76
|
* by the RequestManager
|
|
74
77
|
*
|
|
75
|
-
*
|
|
76
|
-
*
|
|
77
|
-
* @public
|
|
78
|
+
* This is not unique across Manager instances and cannot
|
|
79
|
+
* be used to identify or dedupe requests.
|
|
78
80
|
*/
|
|
79
81
|
id: number;
|
|
82
|
+
/**
|
|
83
|
+
* The RequestManager or Store that initiated this request.
|
|
84
|
+
*
|
|
85
|
+
* @private
|
|
86
|
+
*/
|
|
87
|
+
requester: RequestManager | Store;
|
|
80
88
|
}
|
|
81
89
|
export type DeferredFuture<T> = {
|
|
82
90
|
resolve(v: StructuredDataDocument<T>): void;
|
|
@@ -191,8 +199,6 @@ const manager = new RequestManager()
|
|
|
191
199
|
|
|
192
200
|
Handlers will be invoked in the order they are registered ("fifo", first-in first-out), and may only be registered up until the first request is made. It is recommended but not required to register all handlers at one time in order to ensure explicitly visible handler ordering.
|
|
193
201
|
|
|
194
|
-
|
|
195
|
-
@class (Interface) Handler
|
|
196
202
|
@public
|
|
197
203
|
*/
|
|
198
204
|
export interface Handler {
|
|
@@ -202,20 +208,17 @@ export interface Handler {
|
|
|
202
208
|
* other handlers.
|
|
203
209
|
*
|
|
204
210
|
* @public
|
|
205
|
-
* @param context
|
|
206
|
-
* @param next
|
|
207
211
|
*/
|
|
208
212
|
request<T = unknown>(context: RequestContext, next: NextFn<T>): Promise<T | StructuredDataDocument<T>> | Future<T>;
|
|
209
213
|
}
|
|
210
214
|
/**
|
|
211
|
-
* The CacheHandler is identical to other handlers
|
|
215
|
+
* The CacheHandler is identical to other handlers except that it
|
|
212
216
|
* is allowed to return a value synchronously. This is useful for
|
|
213
217
|
* features like reducing microtask queueing when de-duping.
|
|
214
218
|
*
|
|
215
219
|
* A RequestManager may only have one CacheHandler, registered via
|
|
216
220
|
* `manager.useCache(CacheHandler)`.
|
|
217
221
|
*
|
|
218
|
-
* @class (Interface) CacheHandler
|
|
219
222
|
* @public
|
|
220
223
|
*/
|
|
221
224
|
export interface CacheHandler {
|
|
@@ -225,8 +228,6 @@ export interface CacheHandler {
|
|
|
225
228
|
* other handlers.
|
|
226
229
|
*
|
|
227
230
|
* @public
|
|
228
|
-
* @param context
|
|
229
|
-
* @param next
|
|
230
231
|
*/
|
|
231
232
|
request<T = unknown>(context: RequestContext, next: NextFn<T>): Promise<T | StructuredDataDocument<T>> | Future<T> | T;
|
|
232
233
|
}
|
|
@@ -7,6 +7,7 @@ import type { PendingPromise, RejectedPromise, ResolvedPromise } from "./promise
|
|
|
7
7
|
* reactive properties that can be used to build UIs that respond
|
|
8
8
|
* to the progress of a request.
|
|
9
9
|
*
|
|
10
|
+
* @hideconstructor
|
|
10
11
|
*/
|
|
11
12
|
export declare class RequestLoadingState {
|
|
12
13
|
private _sizeHint;
|
|
@@ -71,11 +72,52 @@ export interface PendingRequest extends PendingPromise {
|
|
|
71
72
|
*
|
|
72
73
|
*/
|
|
73
74
|
export interface ResolvedRequest<RT> extends ResolvedPromise<RT> {
|
|
75
|
+
/**
|
|
76
|
+
* Retries the request with high (blocking) priority. This is the
|
|
77
|
+
* same as having passed `cacheOptions.reload = true` on the original
|
|
78
|
+
* request.
|
|
79
|
+
*
|
|
80
|
+
* This will not change the existing request's state. To subscribe
|
|
81
|
+
* to the new request's state, use `getRequestState` on the returned
|
|
82
|
+
* {@link Future}.
|
|
83
|
+
*
|
|
84
|
+
* ```ts
|
|
85
|
+
* const future = state.reload();
|
|
86
|
+
* const state = getRequestState(future);
|
|
87
|
+
* ```
|
|
88
|
+
*
|
|
89
|
+
* It is safe to pass this around as an "action" or "event" handler
|
|
90
|
+
* as its context is bound.
|
|
91
|
+
*/
|
|
92
|
+
reload(): Future<RT>;
|
|
93
|
+
/**
|
|
94
|
+
* Retries the request with low (non-blocking) priority. This is the
|
|
95
|
+
* same as having passed `cacheOptions.backgroundReload = true` on the original
|
|
96
|
+
* request.
|
|
97
|
+
*
|
|
98
|
+
* This will not change the existing request's state. To subscribe
|
|
99
|
+
* to the new request's state, use `getRequestState` on the returned
|
|
100
|
+
* {@link Future}.
|
|
101
|
+
*
|
|
102
|
+
* ```ts
|
|
103
|
+
* const future = state.reload();
|
|
104
|
+
* const state = getRequestState(future);
|
|
105
|
+
* ```
|
|
106
|
+
*
|
|
107
|
+
* It is safe to pass this around as an "action" or "event" handler
|
|
108
|
+
* as its context is bound.
|
|
109
|
+
*/
|
|
110
|
+
refresh(usePolicy?: boolean): Future<RT>;
|
|
74
111
|
/**
|
|
75
112
|
* Whether the request is cancelled.
|
|
76
113
|
*
|
|
77
114
|
*/
|
|
78
115
|
isCancelled: false;
|
|
116
|
+
/**
|
|
117
|
+
* A lazily created {@link RequestLoadingState} instance
|
|
118
|
+
* which provides a number of reactive properties that can be used
|
|
119
|
+
* to build UIs that respond to the progress of a request.
|
|
120
|
+
*/
|
|
79
121
|
loadingState: RequestLoadingState;
|
|
80
122
|
request: ImmutableRequestInfo<RT> | null;
|
|
81
123
|
response: Response | ResponseInfo | null;
|
|
@@ -92,6 +134,42 @@ export interface RejectedRequest<
|
|
|
92
134
|
RT,
|
|
93
135
|
E extends StructuredErrorDocument = StructuredErrorDocument
|
|
94
136
|
> extends RejectedPromise<E> {
|
|
137
|
+
/**
|
|
138
|
+
* Retries the request with high (blocking) priority. This is the
|
|
139
|
+
* same as having passed `cacheOptions.reload = true` on the original
|
|
140
|
+
* request.
|
|
141
|
+
*
|
|
142
|
+
* This will not change the existing request's state. To subscribe
|
|
143
|
+
* to the new request's state, use `getRequestState` on the returned
|
|
144
|
+
* {@link Future}.
|
|
145
|
+
*
|
|
146
|
+
* ```ts
|
|
147
|
+
* const future = state.reload();
|
|
148
|
+
* const state = getRequestState(future);
|
|
149
|
+
* ```
|
|
150
|
+
*
|
|
151
|
+
* It is safe to pass this around as an "action" or "event" handler
|
|
152
|
+
* as its context is bound.
|
|
153
|
+
*/
|
|
154
|
+
reload(): Future<RT>;
|
|
155
|
+
/**
|
|
156
|
+
* Retries the request with low (non-blocking) priority. This is the
|
|
157
|
+
* same as having passed `cacheOptions.backgroundReload = true` on the original
|
|
158
|
+
* request.
|
|
159
|
+
*
|
|
160
|
+
* This will not change the existing request's state. To subscribe
|
|
161
|
+
* to the new request's state, use `getRequestState` on the returned
|
|
162
|
+
* {@link Future}.
|
|
163
|
+
*
|
|
164
|
+
* ```ts
|
|
165
|
+
* const future = state.reload();
|
|
166
|
+
* const state = getRequestState(future);
|
|
167
|
+
* ```
|
|
168
|
+
*
|
|
169
|
+
* It is safe to pass this around as an "action" or "event" handler
|
|
170
|
+
* as its context is bound.
|
|
171
|
+
*/
|
|
172
|
+
refresh(usePolicy?: boolean): Future<RT>;
|
|
95
173
|
/**
|
|
96
174
|
* Whether the request is cancelled.
|
|
97
175
|
*
|
|
@@ -111,6 +189,42 @@ export interface CancelledRequest<
|
|
|
111
189
|
RT,
|
|
112
190
|
E extends StructuredErrorDocument = StructuredErrorDocument
|
|
113
191
|
> {
|
|
192
|
+
/**
|
|
193
|
+
* Retries the request with high (blocking) priority. This is the
|
|
194
|
+
* same as having passed `cacheOptions.reload = true` on the original
|
|
195
|
+
* request.
|
|
196
|
+
*
|
|
197
|
+
* This will not change the existing request's state. To subscribe
|
|
198
|
+
* to the new request's state, use `getRequestState` on the returned
|
|
199
|
+
* {@link Future}.
|
|
200
|
+
*
|
|
201
|
+
* ```ts
|
|
202
|
+
* const future = state.reload();
|
|
203
|
+
* const state = getRequestState(future);
|
|
204
|
+
* ```
|
|
205
|
+
*
|
|
206
|
+
* It is safe to pass this around as an "action" or "event" handler
|
|
207
|
+
* as its context is bound.
|
|
208
|
+
*/
|
|
209
|
+
reload(): Future<RT>;
|
|
210
|
+
/**
|
|
211
|
+
* Retries the request with low (non-blocking) priority. This is the
|
|
212
|
+
* same as having passed `cacheOptions.backgroundReload = true` on the original
|
|
213
|
+
* request.
|
|
214
|
+
*
|
|
215
|
+
* This will not change the existing request's state. To subscribe
|
|
216
|
+
* to the new request's state, use `getRequestState` on the returned
|
|
217
|
+
* {@link Future}.
|
|
218
|
+
*
|
|
219
|
+
* ```ts
|
|
220
|
+
* const future = state.reload();
|
|
221
|
+
* const state = getRequestState(future);
|
|
222
|
+
* ```
|
|
223
|
+
*
|
|
224
|
+
* It is safe to pass this around as an "action" or "event" handler
|
|
225
|
+
* as its context is bound.
|
|
226
|
+
*/
|
|
227
|
+
refresh(usePolicy?: boolean): Future<RT>;
|
|
114
228
|
/**
|
|
115
229
|
* The status of the request.
|
|
116
230
|
*
|
|
@@ -29,14 +29,14 @@ export interface SubscriptionArgs<
|
|
|
29
29
|
* by either the `store.request` or `store.requestManager.request` methods.
|
|
30
30
|
*
|
|
31
31
|
*/
|
|
32
|
-
request?: Future<RT
|
|
32
|
+
request?: Future<RT> | undefined | null;
|
|
33
33
|
/**
|
|
34
34
|
* A query to use for the request. This should be an object that can be
|
|
35
35
|
* passed to `store.request`. Use this in place of `@request` if you would
|
|
36
36
|
* like the component to also initiate the request.
|
|
37
37
|
*
|
|
38
38
|
*/
|
|
39
|
-
query?: StoreRequestInput<RT
|
|
39
|
+
query?: StoreRequestInput<RT> | undefined | null;
|
|
40
40
|
/**
|
|
41
41
|
* The autorefresh behavior for the request. This can be a boolean, or any
|
|
42
42
|
* combination of the following values: `'online'`, `'interval'`, `'invalid'`.
|
|
@@ -227,6 +227,10 @@ export declare class RequestSubscription<
|
|
|
227
227
|
*/
|
|
228
228
|
private _maybeUpdate;
|
|
229
229
|
/**
|
|
230
|
+
* @internal
|
|
231
|
+
*/
|
|
232
|
+
private _getRequester;
|
|
233
|
+
/**
|
|
230
234
|
* Retry the request, reloading it from the server.
|
|
231
235
|
*/
|
|
232
236
|
retry: () => Promise<void>;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
+
import type { Store } from "../store/-private.js";
|
|
1
2
|
import type { ResourceKey } from "./identifier.js";
|
|
2
3
|
import type { QueryParamsSerializationOptions } from "./params.js";
|
|
3
4
|
import type { TypeFromInstanceOrString } from "./record.js";
|
|
4
5
|
import type { ResourceIdentifierObject } from "./spec/json-api-raw.js";
|
|
5
6
|
import type { RequestSignature } from "./symbols.js";
|
|
6
|
-
type Store = unknown;
|
|
7
7
|
export declare const SkipCache: "___(unique) Symbol(SkipCache)";
|
|
8
8
|
export declare const EnableHydration: "___(unique) Symbol(EnableHydration)";
|
|
9
9
|
export declare const IS_FUTURE: "___(unique) Symbol(IS_FUTURE)";
|
|
@@ -450,6 +450,7 @@ function upgradePromise(promise, future) {
|
|
|
450
450
|
promise.onFinalize = future.onFinalize;
|
|
451
451
|
promise.id = future.id;
|
|
452
452
|
promise.lid = future.lid;
|
|
453
|
+
promise.requester = future.requester;
|
|
453
454
|
return promise;
|
|
454
455
|
}
|
|
455
456
|
function createFuture(owner) {
|
|
@@ -477,6 +478,7 @@ function createFuture(owner) {
|
|
|
477
478
|
};
|
|
478
479
|
promise.id = owner.requestId;
|
|
479
480
|
promise.lid = owner.god.identifier;
|
|
481
|
+
promise.requester = owner.god.requester;
|
|
480
482
|
deferred.promise = promise;
|
|
481
483
|
return deferred;
|
|
482
484
|
}
|
package/dist/index.js
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import { setLogging, getRuntimeConfig } from './types/runtime.js';
|
|
2
|
-
import { a as cloneResponseProperties, I as IS_CACHE_HANDLER, b as assertValidRequest, e as executeNextHandler, d as getRequestResult, u as upgradePromise, s as setPromiseResult, f as clearRequestResult } from "./context-
|
|
2
|
+
import { a as cloneResponseProperties, I as IS_CACHE_HANDLER, b as assertValidRequest, e as executeNextHandler, d as getRequestResult, u as upgradePromise, s as setPromiseResult, f as clearRequestResult } from "./context-BNZebmoO.js";
|
|
3
3
|
import { macroCondition, getGlobalConfig } from '@embroider/macros';
|
|
4
4
|
import { w as waitFor } from "./configure-B48bFHOl.js";
|
|
5
5
|
import { peekUniversalTransient, setUniversalTransient } from './types/-private.js';
|
|
6
|
-
|
|
6
|
+
import { EnableHydration } from './types/request.js';
|
|
7
|
+
export { C as CacheHandler, S as Store, r as recordIdentifierFor, M as setIdentifierForgetMethod, K as setIdentifierGenerationMethod, N as setIdentifierResetMethod, L as setIdentifierUpdateMethod, O as setKeyInfoForResource, s as storeFor } from "./request-state-CcOnn4ej.js";
|
|
7
8
|
import '@ember/debug';
|
|
8
9
|
import './utils/string.js';
|
|
9
10
|
import "./symbols-sql1_mdx.js";
|
|
@@ -187,6 +188,7 @@ function isDict(v) {
|
|
|
187
188
|
return v !== null && typeof v === 'object';
|
|
188
189
|
}
|
|
189
190
|
class RequestManager {
|
|
191
|
+
/** @internal */
|
|
190
192
|
#handlers = [];
|
|
191
193
|
/** @internal */
|
|
192
194
|
|
|
@@ -239,8 +241,6 @@ class RequestManager {
|
|
|
239
241
|
* curry the request, or pass along a modified request.
|
|
240
242
|
*
|
|
241
243
|
* @public
|
|
242
|
-
* @param {Handler[]} newHandlers
|
|
243
|
-
* @return {ThisType}
|
|
244
244
|
*/
|
|
245
245
|
use(newHandlers) {
|
|
246
246
|
const handlers = this.#handlers;
|
|
@@ -267,8 +267,6 @@ class RequestManager {
|
|
|
267
267
|
* Returns a Future that fulfills with a StructuredDocument
|
|
268
268
|
*
|
|
269
269
|
* @public
|
|
270
|
-
* @param {RequestInfo} request
|
|
271
|
-
* @return {Future}
|
|
272
270
|
*/
|
|
273
271
|
request(request) {
|
|
274
272
|
const handlers = this.#handlers;
|
|
@@ -290,7 +288,8 @@ class RequestManager {
|
|
|
290
288
|
stream: null,
|
|
291
289
|
hasRequestedStream: false,
|
|
292
290
|
id: requestId,
|
|
293
|
-
identifier: null
|
|
291
|
+
identifier: null,
|
|
292
|
+
requester: request[EnableHydration] && request.store ? request.store : this
|
|
294
293
|
};
|
|
295
294
|
const promise = executeNextHandler(handlers, request, 0, context);
|
|
296
295
|
|
package/dist/reactive.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { F as ReactiveResource, G as isNonIdentityCacheableField, H as getFieldCacheKeyStrict, r as recordIdentifierFor, z as withSignalStore } from "./request-state-
|
|
2
|
-
export { I as checkout, J as commit } from "./request-state-
|
|
1
|
+
import { F as ReactiveResource, G as isNonIdentityCacheableField, H as getFieldCacheKeyStrict, r as recordIdentifierFor, z as withSignalStore } from "./request-state-CcOnn4ej.js";
|
|
2
|
+
export { I as checkout, J as commit } from "./request-state-CcOnn4ej.js";
|
|
3
3
|
import { isResourceSchema } from './types/schema/fields.js';
|
|
4
4
|
import { D as Destroy, C as Context } from "./symbols-sql1_mdx.js";
|
|
5
5
|
export { a as Checkout } from "./symbols-sql1_mdx.js";
|
|
@@ -589,6 +589,13 @@ class SchemaService {
|
|
|
589
589
|
})(kinds[kind]) : {};
|
|
590
590
|
return kinds[kind];
|
|
591
591
|
}
|
|
592
|
+
|
|
593
|
+
/**
|
|
594
|
+
* Registers a {@link HashFn} for use with a {@link HashField} for
|
|
595
|
+
* either {@link ObjectSchema} identity or polymorphic type calculation.
|
|
596
|
+
*
|
|
597
|
+
* @public
|
|
598
|
+
*/
|
|
592
599
|
registerHashFn(hashFn) {
|
|
593
600
|
this._hashFns.set(hashFn[Type], hashFn);
|
|
594
601
|
}
|
|
@@ -7,7 +7,7 @@ import { CACHE_OWNER, DEBUG_STALE_CACHE_OWNER, DEBUG_KEY_TYPE, DEBUG_CLIENT_ORIG
|
|
|
7
7
|
import { dasherize } from './utils/string.js';
|
|
8
8
|
import { S as SOURCE, C as Context, D as Destroy, a as Checkout, b as Commit } from "./symbols-sql1_mdx.js";
|
|
9
9
|
import { a as createSignal, b as consumeSignal, n as notifySignal, c as createMemo, A as ARRAY_SIGNAL, O as OBJECT_SIGNAL, d as willSyncFlushWatchers } from "./configure-B48bFHOl.js";
|
|
10
|
-
import { g as getPromiseResult, s as setPromiseResult } from "./context-
|
|
10
|
+
import { g as getPromiseResult, s as setPromiseResult } from "./context-BNZebmoO.js";
|
|
11
11
|
import { RecordStore } from './types/symbols.js';
|
|
12
12
|
|
|
13
13
|
/**
|
|
@@ -9269,14 +9269,12 @@ class RequestSubscription {
|
|
|
9269
9269
|
this._removeSubscriptions();
|
|
9270
9270
|
|
|
9271
9271
|
// if we have a request, we need to subscribe to it
|
|
9272
|
-
const
|
|
9273
|
-
store
|
|
9274
|
-
} = this;
|
|
9272
|
+
const store = this._getRequester();
|
|
9275
9273
|
if (requestId && isStore(store)) {
|
|
9276
9274
|
this._subscribedTo = requestId;
|
|
9277
9275
|
this._subscription = store.notifications.subscribe(requestId, (_id, op) => {
|
|
9278
9276
|
// ignore subscription events that occur while our own component's request
|
|
9279
|
-
// is
|
|
9277
|
+
// is occurring
|
|
9280
9278
|
if (this._isUpdating) {
|
|
9281
9279
|
return;
|
|
9282
9280
|
}
|
|
@@ -9345,8 +9343,9 @@ class RequestSubscription {
|
|
|
9345
9343
|
* @internal
|
|
9346
9344
|
*/
|
|
9347
9345
|
_removeSubscriptions() {
|
|
9348
|
-
|
|
9349
|
-
|
|
9346
|
+
const store = this._getRequester();
|
|
9347
|
+
if (this._subscription && isStore(store)) {
|
|
9348
|
+
store.notifications.unsubscribe(this._subscription);
|
|
9350
9349
|
this._subscribedTo = null;
|
|
9351
9350
|
this._subscription = null;
|
|
9352
9351
|
}
|
|
@@ -9411,6 +9410,12 @@ class RequestSubscription {
|
|
|
9411
9410
|
if (this.isIdle) {
|
|
9412
9411
|
return;
|
|
9413
9412
|
}
|
|
9413
|
+
const {
|
|
9414
|
+
reqState
|
|
9415
|
+
} = this;
|
|
9416
|
+
if (reqState.isPending) {
|
|
9417
|
+
return;
|
|
9418
|
+
}
|
|
9414
9419
|
const canAttempt = Boolean(this.isOnline && !this.isHidden && (mode || this.autorefreshTypes.size));
|
|
9415
9420
|
if (!canAttempt) {
|
|
9416
9421
|
if (!silent && mode && mode !== '_invalidated') {
|
|
@@ -9447,35 +9452,26 @@ class RequestSubscription {
|
|
|
9447
9452
|
this._invalidated = false;
|
|
9448
9453
|
if (shouldAttempt) {
|
|
9449
9454
|
this._clearInterval();
|
|
9450
|
-
|
|
9455
|
+
this._isUpdating = true;
|
|
9451
9456
|
const realMode = mode === '_invalidated' ? null : mode;
|
|
9452
9457
|
const val = realMode ?? this._args.autorefreshBehavior ?? 'policy';
|
|
9453
9458
|
switch (val) {
|
|
9454
9459
|
case 'reload':
|
|
9455
|
-
|
|
9456
|
-
reload: true
|
|
9457
|
-
});
|
|
9460
|
+
this._latestRequest = reqState.reload();
|
|
9458
9461
|
break;
|
|
9459
9462
|
case 'refresh':
|
|
9460
|
-
|
|
9461
|
-
backgroundReload: true
|
|
9462
|
-
});
|
|
9463
|
+
this._latestRequest = reqState.refresh();
|
|
9463
9464
|
break;
|
|
9464
9465
|
case 'policy':
|
|
9466
|
+
this._latestRequest = reqState.refresh(true);
|
|
9465
9467
|
break;
|
|
9466
9468
|
default:
|
|
9467
|
-
|
|
9469
|
+
macroCondition(getGlobalConfig().WarpDrive.env.DEBUG) ? (test => {
|
|
9470
|
+
{
|
|
9471
|
+
throw new Error(`Invalid ${mode ? 'update mode' : '@autorefreshBehavior'} for <Request />: ${isNeverString(val)}`);
|
|
9472
|
+
}
|
|
9473
|
+
})() : {};
|
|
9468
9474
|
}
|
|
9469
|
-
const wasStoreRequest = request[EnableHydration] === true;
|
|
9470
|
-
macroCondition(getGlobalConfig().WarpDrive.env.DEBUG) ? (test => {
|
|
9471
|
-
if (!test) {
|
|
9472
|
-
throw new Error(`Cannot supply a different store than was used to create the request`);
|
|
9473
|
-
}
|
|
9474
|
-
})(!request.store || request.store === this.store) : {};
|
|
9475
|
-
const store = request.store || this.store;
|
|
9476
|
-
const requester = !wasStoreRequest && 'requestManager' in store ? store.requestManager : store;
|
|
9477
|
-
this._isUpdating = true;
|
|
9478
|
-
this._latestRequest = requester.request(request);
|
|
9479
9475
|
if (val !== 'refresh') {
|
|
9480
9476
|
this._localRequest = this._latestRequest;
|
|
9481
9477
|
}
|
|
@@ -9486,6 +9482,16 @@ class RequestSubscription {
|
|
|
9486
9482
|
}
|
|
9487
9483
|
}
|
|
9488
9484
|
|
|
9485
|
+
/**
|
|
9486
|
+
* @internal
|
|
9487
|
+
*/
|
|
9488
|
+
_getRequester() {
|
|
9489
|
+
if (this._args.request) {
|
|
9490
|
+
return this._args.request.requester;
|
|
9491
|
+
}
|
|
9492
|
+
return this.store;
|
|
9493
|
+
}
|
|
9494
|
+
|
|
9489
9495
|
/**
|
|
9490
9496
|
* Retry the request, reloading it from the server.
|
|
9491
9497
|
*/
|
|
@@ -9573,7 +9579,6 @@ class RequestSubscription {
|
|
|
9573
9579
|
throw new Error(`You must provide either @request or an @query arg with the <Request> component`);
|
|
9574
9580
|
}
|
|
9575
9581
|
})(query) : {};
|
|
9576
|
-
// @ts-expect-error TODO investigate this
|
|
9577
9582
|
return this.store.request(query);
|
|
9578
9583
|
}
|
|
9579
9584
|
static {
|
|
@@ -9710,6 +9715,7 @@ async function watchStream(stream, loadingState) {
|
|
|
9710
9715
|
* reactive properties that can be used to build UIs that respond
|
|
9711
9716
|
* to the progress of a request.
|
|
9712
9717
|
*
|
|
9718
|
+
* @hideconstructor
|
|
9713
9719
|
*/
|
|
9714
9720
|
class RequestLoadingState {
|
|
9715
9721
|
_stream = null;
|
|
@@ -9900,6 +9906,24 @@ defineNonEnumerableSignal(RequestLoadingState.prototype, '_lastPacketTime', 0);
|
|
|
9900
9906
|
*/
|
|
9901
9907
|
|
|
9902
9908
|
const RequestStateProto = {};
|
|
9909
|
+
function performRefresh(requester, request, isReload) {
|
|
9910
|
+
const req = Object.assign({}, request);
|
|
9911
|
+
const cacheOptions = Object.assign({}, req.cacheOptions);
|
|
9912
|
+
if (isReload) {
|
|
9913
|
+
// force direct to network
|
|
9914
|
+
cacheOptions.reload = true;
|
|
9915
|
+
} else if (isReload === false) {
|
|
9916
|
+
// delete reload to ensure we use backgroundReload / policy
|
|
9917
|
+
delete cacheOptions.reload;
|
|
9918
|
+
cacheOptions.backgroundReload = true;
|
|
9919
|
+
} else {
|
|
9920
|
+
// delete props to ensure we use the policy
|
|
9921
|
+
delete cacheOptions.backgroundReload;
|
|
9922
|
+
delete cacheOptions.reload;
|
|
9923
|
+
}
|
|
9924
|
+
req.cacheOptions = cacheOptions;
|
|
9925
|
+
return requester.request(req);
|
|
9926
|
+
}
|
|
9903
9927
|
|
|
9904
9928
|
// TODO introduce a new mechanism for defining multiple properties
|
|
9905
9929
|
// that share a common signal
|
|
@@ -9931,6 +9955,25 @@ function createRequestState(future) {
|
|
|
9931
9955
|
const state = getPromiseResult(future);
|
|
9932
9956
|
const promiseState = Object.create(RequestStateProto);
|
|
9933
9957
|
promiseState._request = future;
|
|
9958
|
+
// @ts-expect-error - we still attach it for PendingState
|
|
9959
|
+
promiseState.reload = () => {
|
|
9960
|
+
macroCondition(getGlobalConfig().WarpDrive.env.DEBUG) ? (test => {
|
|
9961
|
+
if (!test) {
|
|
9962
|
+
throw new Error(`Cannot reload a request that is still pending. Await or abort the original request first.`);
|
|
9963
|
+
}
|
|
9964
|
+
})(!promiseState.isPending) : {};
|
|
9965
|
+
return performRefresh(future.requester, promiseState.request, true);
|
|
9966
|
+
};
|
|
9967
|
+
|
|
9968
|
+
// @ts-expect-error - we still attach it for PendingState
|
|
9969
|
+
promiseState.refresh = (usePolicy = false) => {
|
|
9970
|
+
macroCondition(getGlobalConfig().WarpDrive.env.DEBUG) ? (test => {
|
|
9971
|
+
if (!test) {
|
|
9972
|
+
throw new Error(`Cannot refresh a request that is still pending. Await or abort the original request first.`);
|
|
9973
|
+
}
|
|
9974
|
+
})(!promiseState.isPending) : {};
|
|
9975
|
+
return performRefresh(future.requester, promiseState.request, usePolicy === true ? null : false);
|
|
9976
|
+
};
|
|
9934
9977
|
if (state) {
|
|
9935
9978
|
if (state.isError) {
|
|
9936
9979
|
promiseState.error = state.result;
|
package/dist/request.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export { c as createDeferred, g as getPromiseResult, s as setPromiseResult } from "./context-
|
|
1
|
+
export { c as createDeferred, g as getPromiseResult, s as setPromiseResult } from "./context-BNZebmoO.js";
|
package/dist/store/-private.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export { C as CacheHandler, D as DISPOSE, R as RecordArrayManager, x as Signals, S as Store, g as StoreMap, _ as _clearCaches, n as _deprecatingNormalize, b as coerceId, c as constructResource, B as consumeInternalSignal, h as createLegacyManyArray, m as createRequestSubscription, v as defineGate, w as defineNonEnumerableSignal, u as defineSignal, e as ensureStringId, t as entangleSignal, f as fastPush, q as gate, E as getOrCreateInternalSignal, k as getPromiseState, o as getRequestState, a as isRequestKey, i as isResourceKey, l as log, j as logGroup, p as memoized, A as notifyInternalSignal, y as peekInternalSignal, r as recordIdentifierFor, d as setRecordIdentifier, s as storeFor, z as withSignalStore } from "../request-state-
|
|
1
|
+
export { C as CacheHandler, D as DISPOSE, R as RecordArrayManager, x as Signals, S as Store, g as StoreMap, _ as _clearCaches, n as _deprecatingNormalize, b as coerceId, c as constructResource, B as consumeInternalSignal, h as createLegacyManyArray, m as createRequestSubscription, v as defineGate, w as defineNonEnumerableSignal, u as defineSignal, e as ensureStringId, t as entangleSignal, f as fastPush, q as gate, E as getOrCreateInternalSignal, k as getPromiseState, o as getRequestState, a as isRequestKey, i as isResourceKey, l as log, j as logGroup, p as memoized, A as notifyInternalSignal, y as peekInternalSignal, r as recordIdentifierFor, d as setRecordIdentifier, s as storeFor, z as withSignalStore } from "../request-state-CcOnn4ej.js";
|
|
2
2
|
export { A as ARRAY_SIGNAL, O as OBJECT_SIGNAL, c as createMemo, w as waitFor } from "../configure-B48bFHOl.js";
|
package/dist/types/-private.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { macroCondition, getGlobalConfig } from '@embroider/macros';
|
|
2
2
|
const name = "@warp-drive/core";
|
|
3
|
-
const version = "5.7.0-alpha.
|
|
3
|
+
const version = "5.7.0-alpha.24";
|
|
4
4
|
|
|
5
5
|
// in testing mode, we utilize globals to ensure only one copy exists of
|
|
6
6
|
// these maps, due to bugs in ember-auto-import
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@warp-drive/core",
|
|
3
|
-
"version": "5.7.0-alpha.
|
|
3
|
+
"version": "5.7.0-alpha.24",
|
|
4
4
|
"description": "Core package for WarpDrive | All the Universal Basics",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"ember-addon"
|
|
@@ -37,13 +37,13 @@
|
|
|
37
37
|
},
|
|
38
38
|
"dependencies": {
|
|
39
39
|
"@embroider/macros": "^1.16.12",
|
|
40
|
-
"@warp-drive/build-config": "5.7.0-alpha.
|
|
40
|
+
"@warp-drive/build-config": "5.7.0-alpha.24"
|
|
41
41
|
},
|
|
42
42
|
"devDependencies": {
|
|
43
43
|
"@babel/core": "^7.26.10",
|
|
44
44
|
"@babel/plugin-transform-typescript": "^7.27.0",
|
|
45
45
|
"@babel/preset-typescript": "^7.27.0",
|
|
46
|
-
"@warp-drive/internal-config": "5.7.0-alpha.
|
|
46
|
+
"@warp-drive/internal-config": "5.7.0-alpha.24",
|
|
47
47
|
"decorator-transforms": "^2.3.0",
|
|
48
48
|
"ember-source": "~6.3.0",
|
|
49
49
|
"expect-type": "^1.2.1",
|