@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.
- package/declarations/graph/-private/-diff.d.ts +7 -20
- package/declarations/graph/-private/-edge-definition.d.ts +3 -12
- package/declarations/graph/-private/-state.d.ts +2 -2
- package/declarations/graph/-private/-utils.d.ts +5 -5
- package/declarations/graph/-private/debug/assert-polymorphic-type.d.ts +3 -3
- package/declarations/graph/-private/edges/collection.d.ts +10 -10
- package/declarations/graph/-private/edges/implicit.d.ts +5 -5
- package/declarations/graph/-private/edges/resource.d.ts +6 -7
- package/declarations/graph/-private/graph.d.ts +17 -15
- package/declarations/graph/-private/operations/replace-related-records.d.ts +4 -4
- package/declarations/graph/-private/operations/update-relationship.d.ts +3 -3
- package/declarations/index.d.ts +1 -1
- package/declarations/reactive/-private/default-mode.d.ts +73 -0
- package/declarations/reactive/-private/document.d.ts +11 -27
- package/declarations/reactive/-private/fields/get-field-key.d.ts +8 -0
- package/declarations/reactive/-private/fields/managed-array.d.ts +7 -10
- package/declarations/reactive/-private/fields/managed-object.d.ts +7 -9
- package/declarations/reactive/-private/fields/many-array-manager.d.ts +2 -2
- package/declarations/reactive/-private/hooks.d.ts +2 -2
- package/declarations/reactive/-private/kind/alias-field.d.ts +4 -0
- package/declarations/reactive/-private/kind/array-field.d.ts +4 -0
- package/declarations/reactive/-private/kind/attribute-field.d.ts +4 -0
- package/declarations/reactive/-private/kind/belongs-to-field.d.ts +4 -0
- package/declarations/reactive/-private/kind/collection-field.d.ts +4 -0
- package/declarations/reactive/-private/kind/derived-field.d.ts +4 -0
- package/declarations/reactive/-private/kind/generic-field.d.ts +4 -0
- package/declarations/reactive/-private/kind/has-many-field.d.ts +4 -0
- package/declarations/reactive/-private/kind/hash-field.d.ts +4 -0
- package/declarations/reactive/-private/kind/identity-field.d.ts +4 -0
- package/declarations/reactive/-private/kind/local-field.d.ts +4 -0
- package/declarations/reactive/-private/kind/object-field.d.ts +4 -0
- package/declarations/reactive/-private/kind/resource-field.d.ts +4 -0
- package/declarations/reactive/-private/kind/schema-array-field.d.ts +4 -0
- package/declarations/reactive/-private/kind/schema-object-field.d.ts +4 -0
- package/declarations/reactive/-private/record.d.ts +44 -33
- package/declarations/reactive/-private/schema.d.ts +50 -66
- package/declarations/reactive/-private/symbols.d.ts +2 -7
- package/declarations/reactive/-private.d.ts +1 -1
- package/declarations/reactive.d.ts +278 -1
- package/declarations/request/-private/context.d.ts +3 -5
- package/declarations/request/-private/fetch.d.ts +2 -0
- package/declarations/request/-private/manager.d.ts +24 -28
- package/declarations/request/-private/types.d.ts +22 -23
- package/declarations/request/-private/utils.d.ts +44 -2
- package/declarations/store/-private/cache-handler/handler.d.ts +2 -8
- package/declarations/store/-private/cache-handler/types.d.ts +10 -10
- package/declarations/store/-private/cache-handler/utils.d.ts +4 -4
- package/declarations/store/-private/caches/instance-cache.d.ts +22 -27
- package/declarations/store/-private/debug/utils.d.ts +1 -0
- package/declarations/store/-private/default-cache-policy.d.ts +25 -38
- package/declarations/store/-private/managers/cache-capabilities-manager.d.ts +24 -15
- package/declarations/store/-private/{caches/identifier-cache.d.ts → managers/cache-key-manager.d.ts} +38 -52
- package/declarations/store/-private/managers/cache-manager.d.ts +46 -95
- package/declarations/store/-private/managers/notification-manager.d.ts +30 -43
- package/declarations/store/-private/managers/record-array-manager.d.ts +44 -41
- package/declarations/store/-private/network/request-cache.d.ts +21 -24
- package/declarations/store/-private/new-core-tmp/expensive-subscription.d.ts +24 -0
- package/declarations/store/-private/new-core-tmp/reactivity/configure.d.ts +3 -41
- package/declarations/store/-private/new-core-tmp/reactivity/internal.d.ts +14 -29
- package/declarations/store/-private/new-core-tmp/reactivity/signal.d.ts +24 -3
- package/declarations/store/-private/new-core-tmp/request-state.d.ts +133 -37
- package/declarations/store/-private/new-core-tmp/request-subscription.d.ts +51 -133
- package/declarations/store/-private/record-arrays/-utils.d.ts +80 -0
- package/declarations/store/-private/record-arrays/legacy-live-array.d.ts +81 -0
- package/declarations/store/-private/record-arrays/legacy-many-array.d.ts +133 -0
- package/declarations/store/-private/record-arrays/legacy-query.d.ts +81 -0
- package/declarations/store/-private/record-arrays/native-proxy-type-fix.d.ts +1 -124
- package/declarations/store/-private/record-arrays/resource-array.d.ts +75 -0
- package/declarations/store/-private/store-service.d.ts +167 -872
- package/declarations/store/-private.d.ts +14 -10
- package/declarations/store/-types/q/cache-capabilities-manager.d.ts +15 -24
- package/declarations/store/-types/q/identifier.d.ts +9 -6
- package/declarations/store/-types/q/record-instance.d.ts +0 -1
- package/declarations/store/-types/q/schema-service.d.ts +64 -40
- package/declarations/store/-types/q/store.d.ts +6 -7
- package/declarations/store/deprecated/-private.d.ts +224 -0
- package/declarations/store/deprecated/store.d.ts +787 -0
- package/declarations/types/-private.d.ts +1 -1
- package/declarations/types/cache/aliases.d.ts +2 -2
- package/declarations/types/cache/change.d.ts +2 -2
- package/declarations/types/cache/mutations.d.ts +13 -13
- package/declarations/types/cache/operations.d.ts +115 -32
- package/declarations/types/cache/relationship.d.ts +4 -4
- package/declarations/types/cache.d.ts +51 -115
- package/declarations/types/graph.d.ts +12 -12
- package/declarations/types/identifier.d.ts +52 -76
- package/declarations/types/params.d.ts +2 -3
- package/declarations/types/request.d.ts +69 -42
- package/declarations/types/schema/concepts.d.ts +2 -2
- package/declarations/types/schema/fields.d.ts +391 -14
- package/declarations/types/spec/document.d.ts +6 -6
- package/declarations/types/spec/json-api-raw.d.ts +6 -8
- package/declarations/types.d.ts +2 -1
- package/declarations/utils/string.d.ts +2 -2
- package/dist/{configure-B48bFHOl.js → configure-C3x8YXzL.js} +5 -5
- package/dist/configure.js +1 -1
- package/dist/{context-COmAnXUQ.js → context-C_7OLieY.js} +48 -6
- package/dist/graph/-private.js +137 -144
- package/dist/index.js +25 -14
- package/dist/reactive/-private.js +1 -1
- package/dist/reactive.js +337 -1422
- package/dist/{request-state-CjLph1LP.js → request-state-C955e0AL.js} +8352 -5912
- package/dist/request.js +1 -1
- package/dist/store/-private.js +2 -3
- package/dist/store.js +32 -44
- package/dist/{symbols-SIstXMLI.js → symbols-sql1_mdx.js} +3 -8
- package/dist/types/-private.js +1 -1
- package/dist/types/identifier.js +19 -45
- package/dist/types/request.js +45 -3
- package/dist/types/schema/fields.js +23 -2
- package/dist/utils/string.js +2 -2
- package/package.json +10 -10
- package/declarations/reactive/-private/fields/compute.d.ts +0 -43
- package/declarations/store/-private/caches/cache-utils.d.ts +0 -12
- package/declarations/store/-private/legacy-model-support/record-reference.d.ts +0 -159
- package/declarations/store/-private/legacy-model-support/shim-model-class.d.ts +0 -17
- package/declarations/store/-private/record-arrays/identifier-array.d.ts +0 -147
- package/declarations/store/-private/record-arrays/many-array.d.ts +0 -197
- package/declarations/store/-types/q/ds-model.d.ts +0 -21
- package/dist/handler-C2T-IyJK.js +0 -339
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { Store } from "../store/-private.js";
|
|
2
|
+
import type { ResourceKey } from "./identifier.js";
|
|
2
3
|
import type { QueryParamsSerializationOptions } from "./params.js";
|
|
3
|
-
import type {
|
|
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)";
|
|
@@ -13,7 +13,7 @@ export type HTTPMethod = "QUERY" | "GET" | "OPTIONS" | "POST" | "PUT" | "PATCH"
|
|
|
13
13
|
* Use these options to adjust CacheHandler behavior for a request.
|
|
14
14
|
*
|
|
15
15
|
*/
|
|
16
|
-
export type CacheOptions
|
|
16
|
+
export type CacheOptions = {
|
|
17
17
|
/**
|
|
18
18
|
* A key that uniquely identifies this request. If not present, the url wil be used
|
|
19
19
|
* as the key for any GET request, while all other requests will not be cached.
|
|
@@ -47,7 +47,10 @@ export type CacheOptions<T = unknown> = {
|
|
|
47
47
|
* than to invalidate findRecord requests for one.
|
|
48
48
|
*
|
|
49
49
|
*/
|
|
50
|
-
|
|
50
|
+
// TODO: Ideally this would be T extends TypedRecordInstance ? ExtractSuggestedCacheTypes<T>[] : string[];
|
|
51
|
+
// but that leads to `Type instantiation is excessively deep and possibly infinite.`
|
|
52
|
+
// issues when `T` has many properties.
|
|
53
|
+
types?: string[];
|
|
51
54
|
/**
|
|
52
55
|
* If true, the request will never be handled by the cache-manager and thus
|
|
53
56
|
* will never resolve from cache nor update the cache.
|
|
@@ -65,31 +68,25 @@ export type FindRecordRequestOptions<
|
|
|
65
68
|
url: string;
|
|
66
69
|
method: "GET";
|
|
67
70
|
headers: Headers;
|
|
68
|
-
cacheOptions?: CacheOptions
|
|
71
|
+
cacheOptions?: CacheOptions;
|
|
69
72
|
op: "findRecord";
|
|
70
73
|
records: [ResourceIdentifierObject<TypeFromInstanceOrString<T>>];
|
|
71
74
|
[RequestSignature]?: RT;
|
|
72
75
|
};
|
|
73
|
-
export type QueryRequestOptions<
|
|
74
|
-
RT = unknown,
|
|
75
|
-
T = unknown
|
|
76
|
-
> = {
|
|
76
|
+
export type QueryRequestOptions<RT = unknown> = {
|
|
77
77
|
url: string;
|
|
78
78
|
method: "GET";
|
|
79
79
|
headers: Headers;
|
|
80
|
-
cacheOptions?: CacheOptions
|
|
80
|
+
cacheOptions?: CacheOptions;
|
|
81
81
|
op: "query";
|
|
82
82
|
[RequestSignature]?: RT;
|
|
83
83
|
};
|
|
84
|
-
export type PostQueryRequestOptions<
|
|
85
|
-
RT = unknown,
|
|
86
|
-
T = unknown
|
|
87
|
-
> = {
|
|
84
|
+
export type PostQueryRequestOptions<RT = unknown> = {
|
|
88
85
|
url: string;
|
|
89
86
|
method: "POST" | "QUERY";
|
|
90
87
|
headers: Headers;
|
|
91
88
|
body?: string | BodyInit | FormData;
|
|
92
|
-
cacheOptions: CacheOptions
|
|
89
|
+
cacheOptions: CacheOptions & {
|
|
93
90
|
key: string;
|
|
94
91
|
};
|
|
95
92
|
op: "query";
|
|
@@ -105,14 +102,14 @@ export type DeleteRequestOptions<
|
|
|
105
102
|
op: "deleteRecord";
|
|
106
103
|
body?: string | BodyInit | FormData;
|
|
107
104
|
data: {
|
|
108
|
-
record:
|
|
105
|
+
record: ResourceKey<TypeFromInstanceOrString<T>>;
|
|
109
106
|
};
|
|
110
107
|
records: [ResourceIdentifierObject<TypeFromInstanceOrString<T>>];
|
|
111
108
|
[RequestSignature]?: RT;
|
|
112
109
|
};
|
|
113
110
|
type ImmutableRequest<T> = Readonly<T> & {
|
|
114
111
|
readonly headers: ImmutableHeaders;
|
|
115
|
-
readonly records: [
|
|
112
|
+
readonly records: [ResourceKey];
|
|
116
113
|
};
|
|
117
114
|
export type UpdateRequestOptions<
|
|
118
115
|
RT = unknown,
|
|
@@ -124,7 +121,7 @@ export type UpdateRequestOptions<
|
|
|
124
121
|
op: "updateRecord";
|
|
125
122
|
body?: string | BodyInit | FormData;
|
|
126
123
|
data: {
|
|
127
|
-
record:
|
|
124
|
+
record: ResourceKey<TypeFromInstanceOrString<T>>;
|
|
128
125
|
};
|
|
129
126
|
records: [ResourceIdentifierObject<TypeFromInstanceOrString<T>>];
|
|
130
127
|
[RequestSignature]?: RT;
|
|
@@ -139,7 +136,7 @@ export type CreateRequestOptions<
|
|
|
139
136
|
op: "createRecord";
|
|
140
137
|
body?: string | BodyInit | FormData;
|
|
141
138
|
data: {
|
|
142
|
-
record:
|
|
139
|
+
record: ResourceKey<TypeFromInstanceOrString<T>>;
|
|
143
140
|
};
|
|
144
141
|
records: [ResourceIdentifierObject<TypeFromInstanceOrString<T>>];
|
|
145
142
|
[RequestSignature]?: RT;
|
|
@@ -152,17 +149,22 @@ export type RemotelyAccessibleIdentifier<T extends string = string> = {
|
|
|
152
149
|
type: T;
|
|
153
150
|
lid?: string;
|
|
154
151
|
};
|
|
155
|
-
export
|
|
152
|
+
export interface ConstrainedRequestOptions {
|
|
156
153
|
reload?: boolean;
|
|
157
154
|
backgroundReload?: boolean;
|
|
158
155
|
host?: string;
|
|
159
156
|
namespace?: string;
|
|
160
157
|
resourcePath?: string;
|
|
161
158
|
urlParamsSettings?: QueryParamsSerializationOptions;
|
|
162
|
-
}
|
|
163
|
-
export
|
|
164
|
-
include?:
|
|
165
|
-
}
|
|
159
|
+
}
|
|
160
|
+
export interface FindRecordOptions extends ConstrainedRequestOptions {
|
|
161
|
+
include?: string | string[];
|
|
162
|
+
}
|
|
163
|
+
/**
|
|
164
|
+
* When a handler chain resolves, it returns an object
|
|
165
|
+
* containing the original request, the response set by the handler
|
|
166
|
+
* chain (if any), and the processed content.
|
|
167
|
+
*/
|
|
166
168
|
export interface StructuredDataDocument<T> {
|
|
167
169
|
[STRUCTURED]?: true;
|
|
168
170
|
/**
|
|
@@ -172,6 +174,14 @@ export interface StructuredDataDocument<T> {
|
|
|
172
174
|
response: Response | ResponseInfo | null;
|
|
173
175
|
content: T;
|
|
174
176
|
}
|
|
177
|
+
/**
|
|
178
|
+
* When a handler chain rejects, it throws an Error that maintains the
|
|
179
|
+
* `{ request, response, content }` shape but is also an Error instance
|
|
180
|
+
* itself.
|
|
181
|
+
*
|
|
182
|
+
* If using the error originates from the {@link Fetch | Fetch Handler}
|
|
183
|
+
* the error will be a {@link FetchError}
|
|
184
|
+
*/
|
|
175
185
|
export interface StructuredErrorDocument<T = unknown> extends Error {
|
|
176
186
|
[STRUCTURED]?: true;
|
|
177
187
|
request: ImmutableRequestInfo;
|
|
@@ -179,14 +189,27 @@ export interface StructuredErrorDocument<T = unknown> extends Error {
|
|
|
179
189
|
error: string | object;
|
|
180
190
|
content?: T;
|
|
181
191
|
}
|
|
192
|
+
/**
|
|
193
|
+
* A union of the resolve/reject data types for a request.
|
|
194
|
+
*
|
|
195
|
+
* See the docs for:
|
|
196
|
+
*
|
|
197
|
+
* - {@link StructuredDataDocument} (resolved/successful requests)
|
|
198
|
+
* - {@link StructuredErrorDocument} (rejected/failed requests)
|
|
199
|
+
*/
|
|
182
200
|
export type StructuredDocument<T> = StructuredDataDocument<T> | StructuredErrorDocument<T>;
|
|
183
201
|
/**
|
|
184
|
-
*
|
|
202
|
+
* The {@link RequestInit} interface accepted by the native {@link fetch} API.
|
|
185
203
|
*
|
|
186
204
|
* WarpDrive provides our own typings due to incompleteness in the native typings.
|
|
187
205
|
*
|
|
206
|
+
* @privateRemarks
|
|
207
|
+
* - [MDN Reference (fetch)](https://developer.mozilla.org/docs/Web/API/Window/fetch)
|
|
208
|
+
* - [MDN Reference (RequestInit)](https://developer.mozilla.org/en-US/docs/Web/API/RequestInit)
|
|
209
|
+
* - [MDN Reference (Request)](https://developer.mozilla.org/docs/Web/API/Request)
|
|
210
|
+
*
|
|
188
211
|
*/
|
|
189
|
-
interface
|
|
212
|
+
interface NativeRequestInit {
|
|
190
213
|
/** Returns the cache mode associated with request, which is a string indicating how the request will interact with the browser's cache when fetching.
|
|
191
214
|
*/
|
|
192
215
|
cache?: RequestCache;
|
|
@@ -246,14 +269,21 @@ export interface ImmutableHeaders extends Headers {
|
|
|
246
269
|
toJSON(): [string, string][];
|
|
247
270
|
}
|
|
248
271
|
/**
|
|
249
|
-
* Extends JavaScript's native {@link
|
|
250
|
-
* properties specific to the RequestManager's capabilities.
|
|
272
|
+
* Extends JavaScript's native {@link fetch} {@link NativeRequestInit | RequestInit} with additional
|
|
273
|
+
* properties specific to the {@link RequestManager | RequestManager's} capabilities.
|
|
251
274
|
*
|
|
275
|
+
* This interface is used to define the shape of a request that can be made via
|
|
276
|
+
* either the {@link RequestManager.request} or {@link Store.request} methods.
|
|
277
|
+
*
|
|
278
|
+
* @privateRemarks
|
|
279
|
+
* - [MDN Reference (fetch)](https://developer.mozilla.org/docs/Web/API/Window/fetch)
|
|
280
|
+
* - [MDN Reference (RequestInit)](https://developer.mozilla.org/en-US/docs/Web/API/RequestInit)
|
|
281
|
+
* - [MDN Reference (Request)](https://developer.mozilla.org/docs/Web/API/Request)
|
|
282
|
+
*
|
|
283
|
+
* @public
|
|
284
|
+
* @since 4.12
|
|
252
285
|
*/
|
|
253
|
-
export interface RequestInfo<
|
|
254
|
-
RT = unknown,
|
|
255
|
-
T = unknown
|
|
256
|
-
> extends Request {
|
|
286
|
+
export interface RequestInfo<RT = unknown> extends NativeRequestInit {
|
|
257
287
|
/**
|
|
258
288
|
* If provided, used instead of the AbortController auto-configured for each request by the RequestManager
|
|
259
289
|
*
|
|
@@ -262,16 +292,16 @@ export interface RequestInfo<
|
|
|
262
292
|
/**
|
|
263
293
|
* @see {@link CacheOptions}
|
|
264
294
|
*/
|
|
265
|
-
cacheOptions?: CacheOptions
|
|
295
|
+
cacheOptions?: CacheOptions;
|
|
266
296
|
store?: Store;
|
|
267
297
|
op?: string;
|
|
268
298
|
/**
|
|
269
|
-
* The
|
|
299
|
+
* The {@link ResourceKey | ResourceKeys} of the primary resources involved in the request
|
|
270
300
|
* (if any). This may be used by handlers to perform transactional
|
|
271
301
|
* operations on the store.
|
|
272
302
|
*
|
|
273
303
|
*/
|
|
274
|
-
records?:
|
|
304
|
+
records?: ResourceKey[];
|
|
275
305
|
disableTestWaiter?: boolean;
|
|
276
306
|
/**
|
|
277
307
|
* data that a handler should convert into
|
|
@@ -283,7 +313,7 @@ export interface RequestInfo<
|
|
|
283
313
|
*/
|
|
284
314
|
data?: Record<string, unknown>;
|
|
285
315
|
/**
|
|
286
|
-
* options specifically intended for
|
|
316
|
+
* options specifically intended for {@link Handler | Handlers}
|
|
287
317
|
* to utilize to process the request
|
|
288
318
|
*
|
|
289
319
|
*/
|
|
@@ -295,11 +325,8 @@ export interface RequestInfo<
|
|
|
295
325
|
* Immutable version of {@link RequestInfo}. This is what is passed to handlers.
|
|
296
326
|
*
|
|
297
327
|
*/
|
|
298
|
-
export type ImmutableRequestInfo<
|
|
299
|
-
|
|
300
|
-
T = unknown
|
|
301
|
-
> = Readonly<Omit<RequestInfo<RT, T>, "controller">> & {
|
|
302
|
-
readonly cacheOptions?: Readonly<CacheOptions<T>>;
|
|
328
|
+
export type ImmutableRequestInfo<RT = unknown> = Readonly<Omit<RequestInfo<RT>, "controller">> & {
|
|
329
|
+
readonly cacheOptions?: Readonly<CacheOptions>;
|
|
303
330
|
readonly headers?: ImmutableHeaders;
|
|
304
331
|
readonly data?: Readonly<Record<string, unknown>>;
|
|
305
332
|
readonly options?: Readonly<Record<string, unknown>>;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { ResourceKey } from "../identifier.js";
|
|
2
2
|
import type { ObjectValue, Value } from "../json/raw.js";
|
|
3
3
|
import type { OpaqueRecordInstance } from "../record.js";
|
|
4
4
|
import type { Type } from "../symbols.js";
|
|
@@ -8,7 +8,7 @@ export type Transformation<
|
|
|
8
8
|
> = {
|
|
9
9
|
serialize(value: PT, options: ObjectValue | null, record: OpaqueRecordInstance): T;
|
|
10
10
|
hydrate(value: T | undefined, options: ObjectValue | null, record: OpaqueRecordInstance): PT;
|
|
11
|
-
defaultValue?(options: ObjectValue | null, identifier:
|
|
11
|
+
defaultValue?(options: ObjectValue | null, identifier: ResourceKey): T;
|
|
12
12
|
[Type]: string;
|
|
13
13
|
};
|
|
14
14
|
export type Derivation<
|