@warp-drive/core 5.7.0-alpha.3 → 5.7.0-alpha.30
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 -21
- 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 +16 -72
- 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 -3
- 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 +21 -19
- 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 +47 -95
- package/declarations/store/-private/managers/notification-manager.d.ts +30 -42
- package/declarations/store/-private/managers/record-array-manager.d.ts +45 -41
- package/declarations/store/-private/network/request-cache.d.ts +21 -21
- 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 +12 -29
- package/declarations/store/-private/new-core-tmp/reactivity/signal.d.ts +23 -3
- package/declarations/store/-private/new-core-tmp/request-state.d.ts +129 -22
- package/declarations/store/-private/new-core-tmp/request-subscription.d.ts +52 -121
- 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 +156 -101
- package/declarations/store/-private.d.ts +10 -7
- 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 +28 -40
- package/declarations/store/-types/q/store.d.ts +6 -7
- package/declarations/store/deprecated/-private.d.ts +12 -23
- package/declarations/store/deprecated/store.d.ts +11 -12
- 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 -113
- 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 +378 -14
- package/declarations/types/spec/document.d.ts +6 -6
- package/declarations/types/spec/json-api-raw.d.ts +6 -8
- package/declarations/utils/string.d.ts +2 -2
- package/dist/{configure-B48bFHOl.js → configure-CiFDHArV.js} +4 -4
- package/dist/configure.js +1 -1
- package/dist/{context-COmAnXUQ.js → context-Bh-MA_tH.js} +40 -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 +202 -1411
- package/dist/{request-state-CejVJgdj.js → request-state-B908BvPK.js} +5186 -2549
- 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/record-arrays/identifier-array.d.ts +0 -147
- package/declarations/store/-private/record-arrays/many-array.d.ts +0 -197
- package/dist/handler-D2jjnIA-.js +0 -339
|
@@ -1,46 +1,46 @@
|
|
|
1
1
|
import type { AddToResourceRelationshipMutation as AddResourceMutation, RemoveFromResourceRelationshipMutation as RemoveResourceMutation } from "./cache/mutations.js";
|
|
2
2
|
import type { AddToResourceRelationshipOperation as AddResourceOperation, RemoveFromResourceRelationshipOperation as RemoveResourceOperation, UpdateResourceRelationshipOperation } from "./cache/operations.js";
|
|
3
|
-
import type {
|
|
3
|
+
import type { ResourceKey } from "./identifier.js";
|
|
4
4
|
import type { CollectionResourceRelationship, SingleResourceRelationship } from "./spec/json-api-raw.js";
|
|
5
5
|
export interface Operation {
|
|
6
6
|
op: string;
|
|
7
7
|
}
|
|
8
8
|
export interface UpdateRelationshipOperation {
|
|
9
9
|
op: "updateRelationship";
|
|
10
|
-
record:
|
|
10
|
+
record: ResourceKey;
|
|
11
11
|
field: string;
|
|
12
12
|
value: SingleResourceRelationship | CollectionResourceRelationship;
|
|
13
13
|
}
|
|
14
14
|
export interface DeleteRecordOperation {
|
|
15
15
|
op: "deleteRecord";
|
|
16
|
-
record:
|
|
16
|
+
record: ResourceKey;
|
|
17
17
|
isNew: boolean;
|
|
18
18
|
}
|
|
19
19
|
export interface UnknownOperation {
|
|
20
20
|
op: "never";
|
|
21
|
-
record:
|
|
21
|
+
record: ResourceKey;
|
|
22
22
|
field: string;
|
|
23
23
|
}
|
|
24
24
|
export interface ReplaceRelatedRecordOperation {
|
|
25
25
|
op: "replaceRelatedRecord";
|
|
26
|
-
record:
|
|
26
|
+
record: ResourceKey;
|
|
27
27
|
field: string;
|
|
28
|
-
value:
|
|
29
|
-
prior?:
|
|
28
|
+
value: ResourceKey | null;
|
|
29
|
+
prior?: ResourceKey;
|
|
30
30
|
index?: number;
|
|
31
31
|
}
|
|
32
32
|
export interface SortRelatedRecords {
|
|
33
33
|
op: "sortRelatedRecords";
|
|
34
|
-
record:
|
|
34
|
+
record: ResourceKey;
|
|
35
35
|
field: string;
|
|
36
|
-
value:
|
|
36
|
+
value: ResourceKey[];
|
|
37
37
|
}
|
|
38
38
|
export interface ReplaceRelatedRecordsOperation {
|
|
39
39
|
op: "replaceRelatedRecords";
|
|
40
|
-
record:
|
|
40
|
+
record: ResourceKey;
|
|
41
41
|
field: string;
|
|
42
|
-
value:
|
|
43
|
-
prior?:
|
|
42
|
+
value: ResourceKey[];
|
|
43
|
+
prior?: ResourceKey[];
|
|
44
44
|
index?: number;
|
|
45
45
|
}
|
|
46
46
|
export type RemoteRelationshipOperation = UpdateResourceRelationshipOperation | UpdateRelationshipOperation | ReplaceRelatedRecordOperation | ReplaceRelatedRecordsOperation | RemoveResourceOperation | AddResourceOperation | DeleteRecordOperation | SortRelatedRecords;
|
|
@@ -1,112 +1,88 @@
|
|
|
1
1
|
// provided for additional debuggability
|
|
2
2
|
export declare const DEBUG_CLIENT_ORIGINATED: unique symbol;
|
|
3
|
-
export declare const
|
|
3
|
+
export declare const DEBUG_KEY_TYPE: unique symbol;
|
|
4
4
|
export declare const DEBUG_STALE_CACHE_OWNER: unique symbol;
|
|
5
5
|
// also present in production
|
|
6
6
|
export declare const CACHE_OWNER: "__$co";
|
|
7
|
-
export type
|
|
8
|
-
export interface Identifier {
|
|
9
|
-
lid: string;
|
|
10
|
-
clientId?: string;
|
|
11
|
-
}
|
|
12
|
-
export interface ExistingRecordIdentifier<T extends string = string> extends Identifier {
|
|
13
|
-
id: string;
|
|
14
|
-
type: T;
|
|
15
|
-
}
|
|
16
|
-
export interface NewRecordIdentifier<T extends string = string> extends Identifier {
|
|
17
|
-
id: string | null;
|
|
18
|
-
type: T;
|
|
19
|
-
}
|
|
20
|
-
export type StableDocumentIdentifier = {
|
|
21
|
-
lid: string;
|
|
22
|
-
};
|
|
23
|
-
export type RequestKey = StableDocumentIdentifier;
|
|
7
|
+
export type CacheKeyType = "record" | "document";
|
|
24
8
|
/**
|
|
25
|
-
*
|
|
26
|
-
*
|
|
9
|
+
* A referentially stable object with a unique string (lid) that can be used
|
|
10
|
+
* as a reference to request data in the cache.
|
|
27
11
|
*
|
|
28
|
-
*
|
|
29
|
-
*
|
|
30
|
-
* may also indicate that it was generated for a secondary
|
|
31
|
-
* index and the primary `id` index is not yet known.
|
|
12
|
+
* Only requests that are assigned a RequestKey are retrievable/replayable from
|
|
13
|
+
* the cache, though requests without RequestKeys may still update cache state.
|
|
32
14
|
*
|
|
33
|
-
* @
|
|
15
|
+
* @public
|
|
34
16
|
*/
|
|
35
|
-
export
|
|
17
|
+
export interface RequestKey {
|
|
18
|
+
lid: string;
|
|
19
|
+
type: "@document";
|
|
20
|
+
}
|
|
21
|
+
/** @deprecated use {@link RequestKey} */
|
|
22
|
+
export type StableDocumentIdentifier = RequestKey;
|
|
36
23
|
/**
|
|
37
|
-
* Used when an
|
|
38
|
-
*
|
|
39
|
-
* @internal
|
|
24
|
+
* Used when an ResourceKey is known to be the stable version
|
|
40
25
|
*/
|
|
41
|
-
|
|
42
|
-
|
|
26
|
+
interface ResourceKeyBase<T extends string = string> {
|
|
27
|
+
/**
|
|
28
|
+
* A string representing a unique identity.
|
|
29
|
+
*
|
|
30
|
+
* @public
|
|
31
|
+
*/
|
|
32
|
+
lid: string;
|
|
33
|
+
/**
|
|
34
|
+
* the primary `ResourceType` or "model name" this ResourceKey belongs to.
|
|
35
|
+
*
|
|
36
|
+
* @public
|
|
37
|
+
*/
|
|
38
|
+
type: T;
|
|
43
39
|
}
|
|
44
40
|
/**
|
|
45
|
-
* Used when a
|
|
41
|
+
* Used when a ResourceKey was not created locally as part
|
|
46
42
|
* of a call to store.createRecord
|
|
47
43
|
*
|
|
48
|
-
* Distinguishing between this
|
|
49
|
-
*
|
|
44
|
+
* Distinguishing between this ResourceKey and one for a client created
|
|
45
|
+
* resource that was created with an ID is generally speaking not possible
|
|
50
46
|
* at runtime, so anything with an ID typically narrows to this.
|
|
51
|
-
*
|
|
52
|
-
* @internal
|
|
53
47
|
*/
|
|
54
|
-
export interface
|
|
48
|
+
export interface PersistedResourceKey<T extends string = string> extends ResourceKeyBase<T> {
|
|
49
|
+
/**
|
|
50
|
+
* the PrimaryKey for the resource this ResourceKey represents.
|
|
51
|
+
*
|
|
52
|
+
* @public
|
|
53
|
+
*/
|
|
55
54
|
id: string;
|
|
56
|
-
type: T;
|
|
57
|
-
[DEBUG_CLIENT_ORIGINATED]?: boolean;
|
|
58
|
-
[CACHE_OWNER]: number | undefined;
|
|
59
|
-
[DEBUG_STALE_CACHE_OWNER]?: number | undefined;
|
|
60
55
|
}
|
|
56
|
+
/** @deprecated use {@link PersistedResourceKey} */
|
|
57
|
+
export type StableExistingRecordIdentifier<T extends string = string> = PersistedResourceKey<T>;
|
|
61
58
|
/**
|
|
62
|
-
* Used when a
|
|
59
|
+
* Used when a ResourceKey was created locally
|
|
63
60
|
* (by a call to store.createRecord).
|
|
64
61
|
*
|
|
65
|
-
* It is possible in rare circumstances to have a
|
|
62
|
+
* It is possible in rare circumstances to have a ResourceKey
|
|
66
63
|
* that is not for a new record but does not have an ID. This would
|
|
67
64
|
* happen if a user intentionally created one for use with a secondary-index
|
|
68
65
|
* prior to the record having been fully loaded.
|
|
69
|
-
*
|
|
70
|
-
* @internal
|
|
71
66
|
*/
|
|
72
|
-
export interface
|
|
67
|
+
export interface NewResourceKey<T extends string = string> extends ResourceKeyBase<T> {
|
|
68
|
+
/**
|
|
69
|
+
* the PrimaryKey for the resource this ResourceKey represents. `null`
|
|
70
|
+
* if not yet assigned a PrimaryKey value.
|
|
71
|
+
*
|
|
72
|
+
* @public
|
|
73
|
+
*/
|
|
73
74
|
id: string | null;
|
|
74
|
-
type: T;
|
|
75
|
-
[DEBUG_CLIENT_ORIGINATED]?: boolean;
|
|
76
|
-
[CACHE_OWNER]: number | undefined;
|
|
77
|
-
[DEBUG_STALE_CACHE_OWNER]?: number | undefined;
|
|
78
75
|
}
|
|
79
76
|
/**
|
|
80
77
|
* A referentially stable object with a unique string (lid) that can be used
|
|
81
78
|
* as a reference to data in the cache.
|
|
82
79
|
*
|
|
83
|
-
* Every
|
|
80
|
+
* Every resource has a unique ResourceKey, and ResourceKeys may refer
|
|
84
81
|
* to data that has never been loaded (for instance, in an async relationship).
|
|
85
82
|
*
|
|
86
|
-
* @class StableRecordIdentifier
|
|
87
|
-
* @public
|
|
88
|
-
*/
|
|
89
|
-
/**
|
|
90
|
-
* A string representing a unique identity.
|
|
91
|
-
*
|
|
92
|
-
* @property lid
|
|
93
|
-
* @type {String}
|
|
94
|
-
* @public
|
|
95
|
-
*/
|
|
96
|
-
/**
|
|
97
|
-
* the primary resource `type` or `modelName` this identity belongs to.
|
|
98
|
-
*
|
|
99
|
-
* @property type
|
|
100
|
-
* @type {String}
|
|
101
|
-
* @public
|
|
102
|
-
*/
|
|
103
|
-
/**
|
|
104
|
-
* the primary id for the record this identity belongs to. `null`
|
|
105
|
-
* if not yet assigned an id.
|
|
106
|
-
*
|
|
107
|
-
* @property id
|
|
108
|
-
* @type {String | null}
|
|
109
83
|
* @public
|
|
110
84
|
*/
|
|
111
|
-
export type
|
|
112
|
-
|
|
85
|
+
export type ResourceKey<T extends string = string> = PersistedResourceKey<T> | NewResourceKey<T>;
|
|
86
|
+
/** @deprecated use {@link ResourceKey} */
|
|
87
|
+
export type StableRecordIdentifier<T extends string = string> = ResourceKey<T>;
|
|
88
|
+
export {};
|
|
@@ -1,9 +1,8 @@
|
|
|
1
|
-
import type { Includes, TypedRecordInstance } from "./record.js";
|
|
2
1
|
export type SerializablePrimitive = string | number | boolean | null;
|
|
3
2
|
export type Serializable = SerializablePrimitive | SerializablePrimitive[];
|
|
4
3
|
export type QueryParamsSerializationOptions = {
|
|
5
4
|
arrayFormat?: "bracket" | "indices" | "repeat" | "comma";
|
|
6
5
|
};
|
|
7
|
-
export type QueryParamsSource
|
|
8
|
-
include?:
|
|
6
|
+
export type QueryParamsSource = ({
|
|
7
|
+
include?: string | string[];
|
|
9
8
|
} & Record<Exclude<string, "include">, Serializable>) | URLSearchParams;
|
|
@@ -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<
|