@warp-drive/core 5.6.0-beta.1 → 5.6.0-beta.3
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 +0 -87
- package/declarations/graph/-private/-utils.d.ts +5 -11
- package/declarations/graph/-private/coerce-id.d.ts +0 -6
- package/declarations/graph/-private/debug/assert-polymorphic-type.d.ts +2 -14
- 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 -51
- package/declarations/graph/-private/normalize-link.d.ts +0 -6
- package/declarations/graph/-private/operations/replace-related-records.d.ts +4 -59
- package/declarations/graph/-private/operations/update-relationship.d.ts +3 -7
- 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 -11
- package/declarations/reactive/-private/fields/managed-object.d.ts +7 -11
- 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 -34
- package/declarations/reactive/-private/schema.d.ts +50 -68
- package/declarations/reactive/-private/symbols.d.ts +2 -33
- 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 -24
- 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 -5
- package/declarations/store/-private/caches/instance-cache.d.ts +22 -28
- package/declarations/store/-private/debug/utils.d.ts +1 -0
- package/declarations/store/-private/default-cache-policy.d.ts +25 -40
- 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} +35 -53
- package/declarations/store/-private/managers/cache-manager.d.ts +46 -111
- package/declarations/store/-private/managers/notification-manager.d.ts +30 -45
- package/declarations/store/-private/managers/record-array-manager.d.ts +44 -41
- package/declarations/store/-private/network/request-cache.d.ts +21 -25
- 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 +132 -37
- package/declarations/store/-private/new-core-tmp/request-subscription.d.ts +51 -135
- 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 +67 -0
- package/declarations/store/-private/store-service.d.ts +167 -877
- package/declarations/store/-private/utils/coerce-id.d.ts +0 -6
- package/declarations/store/-private.d.ts +13 -14
- 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 +223 -0
- package/declarations/store/deprecated/store.d.ts +783 -0
- package/declarations/types/-private.d.ts +1 -1
- package/declarations/types/cache/aliases.d.ts +0 -11
- package/declarations/types/cache/change.d.ts +2 -2
- package/declarations/types/cache/mutations.d.ts +13 -37
- package/declarations/types/cache/operations.d.ts +115 -32
- package/declarations/types/cache/relationship.d.ts +4 -7
- package/declarations/types/cache.d.ts +51 -127
- package/declarations/types/graph.d.ts +12 -12
- package/declarations/types/identifier.d.ts +52 -78
- package/declarations/types/params.d.ts +2 -3
- package/declarations/types/request.d.ts +66 -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 -10
- package/declarations/types/spec/json-api-raw.d.ts +6 -9
- package/declarations/types.d.ts +1 -1
- package/declarations/utils/string.d.ts +2 -3
- 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 +11 -11
- 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,7 @@ export type CacheOptions<T = unknown> = {
|
|
|
47
47
|
* than to invalidate findRecord requests for one.
|
|
48
48
|
*
|
|
49
49
|
*/
|
|
50
|
-
types?:
|
|
50
|
+
types?: string[];
|
|
51
51
|
/**
|
|
52
52
|
* If true, the request will never be handled by the cache-manager and thus
|
|
53
53
|
* will never resolve from cache nor update the cache.
|
|
@@ -65,31 +65,25 @@ export type FindRecordRequestOptions<
|
|
|
65
65
|
url: string;
|
|
66
66
|
method: "GET";
|
|
67
67
|
headers: Headers;
|
|
68
|
-
cacheOptions?: CacheOptions
|
|
68
|
+
cacheOptions?: CacheOptions;
|
|
69
69
|
op: "findRecord";
|
|
70
70
|
records: [ResourceIdentifierObject<TypeFromInstanceOrString<T>>];
|
|
71
71
|
[RequestSignature]?: RT;
|
|
72
72
|
};
|
|
73
|
-
export type QueryRequestOptions<
|
|
74
|
-
RT = unknown,
|
|
75
|
-
T = unknown
|
|
76
|
-
> = {
|
|
73
|
+
export type QueryRequestOptions<RT = unknown> = {
|
|
77
74
|
url: string;
|
|
78
75
|
method: "GET";
|
|
79
76
|
headers: Headers;
|
|
80
|
-
cacheOptions?: CacheOptions
|
|
77
|
+
cacheOptions?: CacheOptions;
|
|
81
78
|
op: "query";
|
|
82
79
|
[RequestSignature]?: RT;
|
|
83
80
|
};
|
|
84
|
-
export type PostQueryRequestOptions<
|
|
85
|
-
RT = unknown,
|
|
86
|
-
T = unknown
|
|
87
|
-
> = {
|
|
81
|
+
export type PostQueryRequestOptions<RT = unknown> = {
|
|
88
82
|
url: string;
|
|
89
83
|
method: "POST" | "QUERY";
|
|
90
84
|
headers: Headers;
|
|
91
85
|
body?: string | BodyInit | FormData;
|
|
92
|
-
cacheOptions: CacheOptions
|
|
86
|
+
cacheOptions: CacheOptions & {
|
|
93
87
|
key: string;
|
|
94
88
|
};
|
|
95
89
|
op: "query";
|
|
@@ -105,14 +99,14 @@ export type DeleteRequestOptions<
|
|
|
105
99
|
op: "deleteRecord";
|
|
106
100
|
body?: string | BodyInit | FormData;
|
|
107
101
|
data: {
|
|
108
|
-
record:
|
|
102
|
+
record: ResourceKey<TypeFromInstanceOrString<T>>;
|
|
109
103
|
};
|
|
110
104
|
records: [ResourceIdentifierObject<TypeFromInstanceOrString<T>>];
|
|
111
105
|
[RequestSignature]?: RT;
|
|
112
106
|
};
|
|
113
107
|
type ImmutableRequest<T> = Readonly<T> & {
|
|
114
108
|
readonly headers: ImmutableHeaders;
|
|
115
|
-
readonly records: [
|
|
109
|
+
readonly records: [ResourceKey];
|
|
116
110
|
};
|
|
117
111
|
export type UpdateRequestOptions<
|
|
118
112
|
RT = unknown,
|
|
@@ -124,7 +118,7 @@ export type UpdateRequestOptions<
|
|
|
124
118
|
op: "updateRecord";
|
|
125
119
|
body?: string | BodyInit | FormData;
|
|
126
120
|
data: {
|
|
127
|
-
record:
|
|
121
|
+
record: ResourceKey<TypeFromInstanceOrString<T>>;
|
|
128
122
|
};
|
|
129
123
|
records: [ResourceIdentifierObject<TypeFromInstanceOrString<T>>];
|
|
130
124
|
[RequestSignature]?: RT;
|
|
@@ -139,7 +133,7 @@ export type CreateRequestOptions<
|
|
|
139
133
|
op: "createRecord";
|
|
140
134
|
body?: string | BodyInit | FormData;
|
|
141
135
|
data: {
|
|
142
|
-
record:
|
|
136
|
+
record: ResourceKey<TypeFromInstanceOrString<T>>;
|
|
143
137
|
};
|
|
144
138
|
records: [ResourceIdentifierObject<TypeFromInstanceOrString<T>>];
|
|
145
139
|
[RequestSignature]?: RT;
|
|
@@ -152,17 +146,22 @@ export type RemotelyAccessibleIdentifier<T extends string = string> = {
|
|
|
152
146
|
type: T;
|
|
153
147
|
lid?: string;
|
|
154
148
|
};
|
|
155
|
-
export
|
|
149
|
+
export interface ConstrainedRequestOptions {
|
|
156
150
|
reload?: boolean;
|
|
157
151
|
backgroundReload?: boolean;
|
|
158
152
|
host?: string;
|
|
159
153
|
namespace?: string;
|
|
160
154
|
resourcePath?: string;
|
|
161
155
|
urlParamsSettings?: QueryParamsSerializationOptions;
|
|
162
|
-
}
|
|
163
|
-
export
|
|
164
|
-
include?:
|
|
165
|
-
}
|
|
156
|
+
}
|
|
157
|
+
export interface FindRecordOptions extends ConstrainedRequestOptions {
|
|
158
|
+
include?: string | string[];
|
|
159
|
+
}
|
|
160
|
+
/**
|
|
161
|
+
* When a handler chain resolves, it returns an object
|
|
162
|
+
* containing the original request, the response set by the handler
|
|
163
|
+
* chain (if any), and the processed content.
|
|
164
|
+
*/
|
|
166
165
|
export interface StructuredDataDocument<T> {
|
|
167
166
|
[STRUCTURED]?: true;
|
|
168
167
|
/**
|
|
@@ -172,6 +171,14 @@ export interface StructuredDataDocument<T> {
|
|
|
172
171
|
response: Response | ResponseInfo | null;
|
|
173
172
|
content: T;
|
|
174
173
|
}
|
|
174
|
+
/**
|
|
175
|
+
* When a handler chain rejects, it throws an Error that maintains the
|
|
176
|
+
* `{ request, response, content }` shape but is also an Error instance
|
|
177
|
+
* itself.
|
|
178
|
+
*
|
|
179
|
+
* If using the error originates from the {@link Fetch | Fetch Handler}
|
|
180
|
+
* the error will be a {@link FetchError}
|
|
181
|
+
*/
|
|
175
182
|
export interface StructuredErrorDocument<T = unknown> extends Error {
|
|
176
183
|
[STRUCTURED]?: true;
|
|
177
184
|
request: ImmutableRequestInfo;
|
|
@@ -179,14 +186,27 @@ export interface StructuredErrorDocument<T = unknown> extends Error {
|
|
|
179
186
|
error: string | object;
|
|
180
187
|
content?: T;
|
|
181
188
|
}
|
|
189
|
+
/**
|
|
190
|
+
* A union of the resolve/reject data types for a request.
|
|
191
|
+
*
|
|
192
|
+
* See the docs for:
|
|
193
|
+
*
|
|
194
|
+
* - {@link StructuredDataDocument} (resolved/successful requests)
|
|
195
|
+
* - {@link StructuredErrorDocument} (rejected/failed requests)
|
|
196
|
+
*/
|
|
182
197
|
export type StructuredDocument<T> = StructuredDataDocument<T> | StructuredErrorDocument<T>;
|
|
183
198
|
/**
|
|
184
|
-
*
|
|
199
|
+
* The {@link RequestInit} interface accepted by the native {@link fetch} API.
|
|
185
200
|
*
|
|
186
201
|
* WarpDrive provides our own typings due to incompleteness in the native typings.
|
|
187
202
|
*
|
|
203
|
+
* @privateRemarks
|
|
204
|
+
* - [MDN Reference (fetch)](https://developer.mozilla.org/docs/Web/API/Window/fetch)
|
|
205
|
+
* - [MDN Reference (RequestInit)](https://developer.mozilla.org/en-US/docs/Web/API/RequestInit)
|
|
206
|
+
* - [MDN Reference (Request)](https://developer.mozilla.org/docs/Web/API/Request)
|
|
207
|
+
*
|
|
188
208
|
*/
|
|
189
|
-
interface
|
|
209
|
+
interface NativeRequestInit {
|
|
190
210
|
/** 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
211
|
*/
|
|
192
212
|
cache?: RequestCache;
|
|
@@ -246,14 +266,21 @@ export interface ImmutableHeaders extends Headers {
|
|
|
246
266
|
toJSON(): [string, string][];
|
|
247
267
|
}
|
|
248
268
|
/**
|
|
249
|
-
* Extends JavaScript's native {@link
|
|
250
|
-
* properties specific to the RequestManager's capabilities.
|
|
269
|
+
* Extends JavaScript's native {@link fetch} {@link NativeRequestInit | RequestInit} with additional
|
|
270
|
+
* properties specific to the {@link RequestManager | RequestManager's} capabilities.
|
|
251
271
|
*
|
|
272
|
+
* This interface is used to define the shape of a request that can be made via
|
|
273
|
+
* either the {@link RequestManager.request} or {@link Store.request} methods.
|
|
274
|
+
*
|
|
275
|
+
* @privateRemarks
|
|
276
|
+
* - [MDN Reference (fetch)](https://developer.mozilla.org/docs/Web/API/Window/fetch)
|
|
277
|
+
* - [MDN Reference (RequestInit)](https://developer.mozilla.org/en-US/docs/Web/API/RequestInit)
|
|
278
|
+
* - [MDN Reference (Request)](https://developer.mozilla.org/docs/Web/API/Request)
|
|
279
|
+
*
|
|
280
|
+
* @public
|
|
281
|
+
* @since 4.12
|
|
252
282
|
*/
|
|
253
|
-
export interface RequestInfo<
|
|
254
|
-
RT = unknown,
|
|
255
|
-
T = unknown
|
|
256
|
-
> extends Request {
|
|
283
|
+
export interface RequestInfo<RT = unknown> extends NativeRequestInit {
|
|
257
284
|
/**
|
|
258
285
|
* If provided, used instead of the AbortController auto-configured for each request by the RequestManager
|
|
259
286
|
*
|
|
@@ -262,16 +289,16 @@ export interface RequestInfo<
|
|
|
262
289
|
/**
|
|
263
290
|
* @see {@link CacheOptions}
|
|
264
291
|
*/
|
|
265
|
-
cacheOptions?: CacheOptions
|
|
292
|
+
cacheOptions?: CacheOptions;
|
|
266
293
|
store?: Store;
|
|
267
294
|
op?: string;
|
|
268
295
|
/**
|
|
269
|
-
* The
|
|
296
|
+
* The {@link ResourceKey | ResourceKeys} of the primary resources involved in the request
|
|
270
297
|
* (if any). This may be used by handlers to perform transactional
|
|
271
298
|
* operations on the store.
|
|
272
299
|
*
|
|
273
300
|
*/
|
|
274
|
-
records?:
|
|
301
|
+
records?: ResourceKey[];
|
|
275
302
|
disableTestWaiter?: boolean;
|
|
276
303
|
/**
|
|
277
304
|
* data that a handler should convert into
|
|
@@ -283,7 +310,7 @@ export interface RequestInfo<
|
|
|
283
310
|
*/
|
|
284
311
|
data?: Record<string, unknown>;
|
|
285
312
|
/**
|
|
286
|
-
* options specifically intended for
|
|
313
|
+
* options specifically intended for {@link Handler | Handlers}
|
|
287
314
|
* to utilize to process the request
|
|
288
315
|
*
|
|
289
316
|
*/
|
|
@@ -295,11 +322,8 @@ export interface RequestInfo<
|
|
|
295
322
|
* Immutable version of {@link RequestInfo}. This is what is passed to handlers.
|
|
296
323
|
*
|
|
297
324
|
*/
|
|
298
|
-
export type ImmutableRequestInfo<
|
|
299
|
-
|
|
300
|
-
T = unknown
|
|
301
|
-
> = Readonly<Omit<RequestInfo<RT, T>, "controller">> & {
|
|
302
|
-
readonly cacheOptions?: Readonly<CacheOptions<T>>;
|
|
325
|
+
export type ImmutableRequestInfo<RT = unknown> = Readonly<Omit<RequestInfo<RT>, "controller">> & {
|
|
326
|
+
readonly cacheOptions?: Readonly<CacheOptions>;
|
|
303
327
|
readonly headers?: ImmutableHeaders;
|
|
304
328
|
readonly data?: Readonly<Record<string, unknown>>;
|
|
305
329
|
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<
|