@warp-drive/core 5.7.0-alpha.2 → 5.7.0-alpha.21
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 +8 -8
- package/declarations/graph/-private/-edge-definition.d.ts +2 -2
- 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 +5 -5
- 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 +50 -25
- package/declarations/reactive/-private/schema.d.ts +18 -14
- 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 +2 -2
- package/declarations/request/-private/fetch.d.ts +2 -0
- package/declarations/request/-private/manager.d.ts +3 -6
- package/declarations/request/-private/types.d.ts +4 -4
- 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 +20 -18
- package/declarations/store/-private/default-cache-policy.d.ts +25 -38
- package/declarations/store/-private/managers/cache-capabilities-manager.d.ts +13 -11
- package/declarations/store/-private/{caches/identifier-cache.d.ts → managers/cache-key-manager.d.ts} +22 -19
- package/declarations/store/-private/managers/cache-manager.d.ts +46 -94
- package/declarations/store/-private/managers/notification-manager.d.ts +21 -25
- package/declarations/store/-private/managers/record-array-manager.d.ts +78 -27
- package/declarations/store/-private/network/request-cache.d.ts +11 -11
- package/declarations/store/-private/new-core-tmp/expensive-subscription.d.ts +24 -0
- package/declarations/store/-private/new-core-tmp/reactivity/signal.d.ts +1 -0
- package/declarations/store/-private/new-core-tmp/request-state.d.ts +15 -22
- package/declarations/store/-private/new-core-tmp/request-subscription.d.ts +4 -8
- package/declarations/store/-private/record-arrays/-utils.d.ts +82 -0
- package/declarations/store/-private/record-arrays/legacy-live-array.d.ts +89 -0
- package/declarations/store/-private/record-arrays/{many-array.d.ts → legacy-many-array.d.ts} +43 -101
- package/declarations/store/-private/record-arrays/legacy-query.d.ts +103 -0
- package/declarations/store/-private/record-arrays/resource-array.d.ts +82 -0
- package/declarations/store/-private/store-service.d.ts +78 -35
- package/declarations/store/-private.d.ts +5 -5
- 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/schema-service.d.ts +28 -40
- package/declarations/store/-types/q/store.d.ts +6 -7
- package/declarations/store/deprecated/-private.d.ts +12 -12
- 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 +60 -76
- package/declarations/types/params.d.ts +2 -3
- package/declarations/types/request.d.ts +47 -35
- 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/dist/{context-COmAnXUQ.js → context-kQXhkeBj.js} +13 -0
- package/dist/graph/-private.js +135 -139
- package/dist/index.js +6 -3
- package/dist/reactive/-private.js +1 -1
- package/dist/reactive.js +193 -1409
- package/dist/{request-state-CejVJgdj.js → request-state-glkInb2R.js} +5139 -2758
- package/dist/request.js +1 -1
- package/dist/store/-private.js +1 -2
- 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 +27 -0
- package/dist/types/schema/fields.js +23 -2
- package/package.json +3 -3
- 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/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,96 @@
|
|
|
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
|
+
/** @internal */
|
|
21
|
+
[CACHE_OWNER]: number | undefined;
|
|
22
|
+
}
|
|
23
|
+
/** @deprecated use {@link RequestKey} */
|
|
24
|
+
export type StableDocumentIdentifier = RequestKey;
|
|
36
25
|
/**
|
|
37
|
-
* Used when an
|
|
38
|
-
*
|
|
39
|
-
* @internal
|
|
26
|
+
* Used when an ResourceKey is known to be the stable version
|
|
40
27
|
*/
|
|
41
|
-
|
|
42
|
-
|
|
28
|
+
interface ResourceKeyBase<T extends string = string> {
|
|
29
|
+
/**
|
|
30
|
+
* A string representing a unique identity.
|
|
31
|
+
*
|
|
32
|
+
* @public
|
|
33
|
+
*/
|
|
34
|
+
lid: string;
|
|
35
|
+
/**
|
|
36
|
+
* the primary `ResourceType` or "model name" this ResourceKey belongs to.
|
|
37
|
+
*
|
|
38
|
+
* @public
|
|
39
|
+
*/
|
|
40
|
+
type: T;
|
|
41
|
+
/** @internal */
|
|
42
|
+
[CACHE_OWNER]: number | undefined;
|
|
43
|
+
/** @internal */
|
|
44
|
+
[DEBUG_CLIENT_ORIGINATED]?: boolean;
|
|
45
|
+
/** @internal */
|
|
46
|
+
[DEBUG_STALE_CACHE_OWNER]?: number | undefined;
|
|
43
47
|
}
|
|
44
48
|
/**
|
|
45
|
-
* Used when a
|
|
49
|
+
* Used when a ResourceKey was not created locally as part
|
|
46
50
|
* of a call to store.createRecord
|
|
47
51
|
*
|
|
48
|
-
* Distinguishing between this
|
|
49
|
-
*
|
|
52
|
+
* Distinguishing between this ResourceKey and one for a client created
|
|
53
|
+
* resource that was created with an ID is generally speaking not possible
|
|
50
54
|
* at runtime, so anything with an ID typically narrows to this.
|
|
51
|
-
*
|
|
52
|
-
* @internal
|
|
53
55
|
*/
|
|
54
|
-
export interface
|
|
56
|
+
export interface PersistedResourceKey<T extends string = string> extends ResourceKeyBase<T> {
|
|
57
|
+
/**
|
|
58
|
+
* the PrimaryKey for the resource this ResourceKey represents.
|
|
59
|
+
*
|
|
60
|
+
* @public
|
|
61
|
+
*/
|
|
55
62
|
id: string;
|
|
56
|
-
type: T;
|
|
57
|
-
[DEBUG_CLIENT_ORIGINATED]?: boolean;
|
|
58
|
-
[CACHE_OWNER]: number | undefined;
|
|
59
|
-
[DEBUG_STALE_CACHE_OWNER]?: number | undefined;
|
|
60
63
|
}
|
|
64
|
+
/** @deprecated use {@link PersistedResourceKey} */
|
|
65
|
+
export type StableExistingRecordIdentifier<T extends string = string> = PersistedResourceKey<T>;
|
|
61
66
|
/**
|
|
62
|
-
* Used when a
|
|
67
|
+
* Used when a ResourceKey was created locally
|
|
63
68
|
* (by a call to store.createRecord).
|
|
64
69
|
*
|
|
65
|
-
* It is possible in rare circumstances to have a
|
|
70
|
+
* It is possible in rare circumstances to have a ResourceKey
|
|
66
71
|
* that is not for a new record but does not have an ID. This would
|
|
67
72
|
* happen if a user intentionally created one for use with a secondary-index
|
|
68
73
|
* prior to the record having been fully loaded.
|
|
69
|
-
*
|
|
70
|
-
* @internal
|
|
71
74
|
*/
|
|
72
|
-
export interface
|
|
75
|
+
export interface NewResourceKey<T extends string = string> extends ResourceKeyBase<T> {
|
|
76
|
+
/**
|
|
77
|
+
* the PrimaryKey for the resource this ResourceKey represents. `null`
|
|
78
|
+
* if not yet assigned a PrimaryKey value.
|
|
79
|
+
*
|
|
80
|
+
* @public
|
|
81
|
+
*/
|
|
73
82
|
id: string | null;
|
|
74
|
-
type: T;
|
|
75
|
-
[DEBUG_CLIENT_ORIGINATED]?: boolean;
|
|
76
|
-
[CACHE_OWNER]: number | undefined;
|
|
77
|
-
[DEBUG_STALE_CACHE_OWNER]?: number | undefined;
|
|
78
83
|
}
|
|
79
84
|
/**
|
|
80
85
|
* A referentially stable object with a unique string (lid) that can be used
|
|
81
86
|
* as a reference to data in the cache.
|
|
82
87
|
*
|
|
83
|
-
* Every
|
|
88
|
+
* Every resource has a unique ResourceKey, and ResourceKeys may refer
|
|
84
89
|
* to data that has never been loaded (for instance, in an async relationship).
|
|
85
90
|
*
|
|
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
91
|
* @public
|
|
110
92
|
*/
|
|
111
|
-
export type
|
|
112
|
-
|
|
93
|
+
export type ResourceKey<T extends string = string> = PersistedResourceKey<T> | NewResourceKey<T>;
|
|
94
|
+
/** @deprecated use {@link ResourceKey} */
|
|
95
|
+
export type StableRecordIdentifier<T extends string = string> = ResourceKey<T>;
|
|
96
|
+
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,6 +1,6 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { ResourceKey } from "./identifier.js";
|
|
2
2
|
import type { QueryParamsSerializationOptions } from "./params.js";
|
|
3
|
-
import type {
|
|
3
|
+
import type { TypeFromInstanceOrString } from "./record.js";
|
|
4
4
|
import type { ResourceIdentifierObject } from "./spec/json-api-raw.js";
|
|
5
5
|
import type { RequestSignature } from "./symbols.js";
|
|
6
6
|
type Store = unknown;
|
|
@@ -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,6 +189,14 @@ 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
|
* JavaScript's native Request class.
|
|
@@ -250,10 +268,7 @@ export interface ImmutableHeaders extends Headers {
|
|
|
250
268
|
* properties specific to the RequestManager's capabilities.
|
|
251
269
|
*
|
|
252
270
|
*/
|
|
253
|
-
export interface RequestInfo<
|
|
254
|
-
RT = unknown,
|
|
255
|
-
T = unknown
|
|
256
|
-
> extends Request {
|
|
271
|
+
export interface RequestInfo<RT = unknown> extends Request {
|
|
257
272
|
/**
|
|
258
273
|
* If provided, used instead of the AbortController auto-configured for each request by the RequestManager
|
|
259
274
|
*
|
|
@@ -262,7 +277,7 @@ export interface RequestInfo<
|
|
|
262
277
|
/**
|
|
263
278
|
* @see {@link CacheOptions}
|
|
264
279
|
*/
|
|
265
|
-
cacheOptions?: CacheOptions
|
|
280
|
+
cacheOptions?: CacheOptions;
|
|
266
281
|
store?: Store;
|
|
267
282
|
op?: string;
|
|
268
283
|
/**
|
|
@@ -271,7 +286,7 @@ export interface RequestInfo<
|
|
|
271
286
|
* operations on the store.
|
|
272
287
|
*
|
|
273
288
|
*/
|
|
274
|
-
records?:
|
|
289
|
+
records?: ResourceKey[];
|
|
275
290
|
disableTestWaiter?: boolean;
|
|
276
291
|
/**
|
|
277
292
|
* data that a handler should convert into
|
|
@@ -295,11 +310,8 @@ export interface RequestInfo<
|
|
|
295
310
|
* Immutable version of {@link RequestInfo}. This is what is passed to handlers.
|
|
296
311
|
*
|
|
297
312
|
*/
|
|
298
|
-
export type ImmutableRequestInfo<
|
|
299
|
-
|
|
300
|
-
T = unknown
|
|
301
|
-
> = Readonly<Omit<RequestInfo<RT, T>, "controller">> & {
|
|
302
|
-
readonly cacheOptions?: Readonly<CacheOptions<T>>;
|
|
313
|
+
export type ImmutableRequestInfo<RT = unknown> = Readonly<Omit<RequestInfo<RT>, "controller">> & {
|
|
314
|
+
readonly cacheOptions?: Readonly<CacheOptions>;
|
|
303
315
|
readonly headers?: ImmutableHeaders;
|
|
304
316
|
readonly data?: Readonly<Record<string, unknown>>;
|
|
305
317
|
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<
|