@warp-drive/core 5.7.0-alpha.9 → 5.7.0
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 +2 -2
- package/declarations/reactive/-private/document.d.ts +11 -27
- package/declarations/reactive/-private/fields/managed-array.d.ts +4 -6
- package/declarations/reactive/-private/fields/managed-object.d.ts +2 -8
- 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/record.d.ts +42 -30
- package/declarations/reactive/-private/schema.d.ts +11 -73
- package/declarations/reactive/-private/symbols.d.ts +2 -33
- package/declarations/reactive/-private.d.ts +1 -1
- package/declarations/reactive.d.ts +277 -1
- package/declarations/request/-private/context.d.ts +3 -5
- package/declarations/request/-private/fetch.d.ts +2 -2
- 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 +21 -20
- 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 +156 -106
- package/declarations/store/-private/utils/coerce-id.d.ts +0 -6
- package/declarations/store/-private.d.ts +11 -13
- 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 +9 -9
- package/declarations/store/-types/q/store.d.ts +6 -7
- package/declarations/store/deprecated/-private.d.ts +12 -24
- package/declarations/store/deprecated/store.d.ts +11 -16
- 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 -125
- 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 +30 -3
- 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 +0 -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 +144 -1926
- package/dist/{request-state-CeN66aML.js → request-state-C955e0AL.js} +5968 -3033
- 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 +6 -0
- package/dist/utils/string.js +2 -2
- package/package.json +11 -11
- 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-SdXlte1w.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,86 @@
|
|
|
1
|
-
// provided for additional debuggability
|
|
2
1
|
export declare const DEBUG_CLIENT_ORIGINATED: unique symbol;
|
|
3
|
-
export declare const
|
|
2
|
+
export declare const DEBUG_KEY_TYPE: unique symbol;
|
|
4
3
|
export declare const DEBUG_STALE_CACHE_OWNER: unique symbol;
|
|
5
|
-
// also present in production
|
|
6
4
|
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;
|
|
5
|
+
export type CacheKeyType = "record" | "document";
|
|
24
6
|
/**
|
|
25
|
-
*
|
|
26
|
-
*
|
|
7
|
+
* A referentially stable object with a unique string (lid) that can be used
|
|
8
|
+
* as a reference to request data in the cache.
|
|
27
9
|
*
|
|
28
|
-
*
|
|
29
|
-
*
|
|
30
|
-
* may also indicate that it was generated for a secondary
|
|
31
|
-
* index and the primary `id` index is not yet known.
|
|
10
|
+
* Only requests that are assigned a RequestKey are retrievable/replayable from
|
|
11
|
+
* the cache, though requests without RequestKeys may still update cache state.
|
|
32
12
|
*
|
|
33
|
-
* @
|
|
13
|
+
* @public
|
|
34
14
|
*/
|
|
35
|
-
export
|
|
15
|
+
export interface RequestKey {
|
|
16
|
+
lid: string;
|
|
17
|
+
type: "@document";
|
|
18
|
+
}
|
|
19
|
+
/** @deprecated use {@link RequestKey} */
|
|
20
|
+
export type StableDocumentIdentifier = RequestKey;
|
|
36
21
|
/**
|
|
37
|
-
* Used when an
|
|
38
|
-
*
|
|
39
|
-
* @internal
|
|
22
|
+
* Used when an ResourceKey is known to be the stable version
|
|
40
23
|
*/
|
|
41
|
-
|
|
42
|
-
|
|
24
|
+
interface ResourceKeyBase<T extends string = string> {
|
|
25
|
+
/**
|
|
26
|
+
* A string representing a unique identity.
|
|
27
|
+
*
|
|
28
|
+
* @public
|
|
29
|
+
*/
|
|
30
|
+
lid: string;
|
|
31
|
+
/**
|
|
32
|
+
* the primary `ResourceType` or "model name" this ResourceKey belongs to.
|
|
33
|
+
*
|
|
34
|
+
* @public
|
|
35
|
+
*/
|
|
36
|
+
type: T;
|
|
43
37
|
}
|
|
44
38
|
/**
|
|
45
|
-
* Used when a
|
|
39
|
+
* Used when a ResourceKey was not created locally as part
|
|
46
40
|
* of a call to store.createRecord
|
|
47
41
|
*
|
|
48
|
-
* Distinguishing between this
|
|
49
|
-
*
|
|
42
|
+
* Distinguishing between this ResourceKey and one for a client created
|
|
43
|
+
* resource that was created with an ID is generally speaking not possible
|
|
50
44
|
* at runtime, so anything with an ID typically narrows to this.
|
|
51
|
-
*
|
|
52
|
-
* @internal
|
|
53
45
|
*/
|
|
54
|
-
export interface
|
|
46
|
+
export interface PersistedResourceKey<T extends string = string> extends ResourceKeyBase<T> {
|
|
47
|
+
/**
|
|
48
|
+
* the PrimaryKey for the resource this ResourceKey represents.
|
|
49
|
+
*
|
|
50
|
+
* @public
|
|
51
|
+
*/
|
|
55
52
|
id: string;
|
|
56
|
-
type: T;
|
|
57
|
-
[DEBUG_CLIENT_ORIGINATED]?: boolean;
|
|
58
|
-
[CACHE_OWNER]: number | undefined;
|
|
59
|
-
[DEBUG_STALE_CACHE_OWNER]?: number | undefined;
|
|
60
53
|
}
|
|
54
|
+
/** @deprecated use {@link PersistedResourceKey} */
|
|
55
|
+
export type StableExistingRecordIdentifier<T extends string = string> = PersistedResourceKey<T>;
|
|
61
56
|
/**
|
|
62
|
-
* Used when a
|
|
57
|
+
* Used when a ResourceKey was created locally
|
|
63
58
|
* (by a call to store.createRecord).
|
|
64
59
|
*
|
|
65
|
-
* It is possible in rare circumstances to have a
|
|
60
|
+
* It is possible in rare circumstances to have a ResourceKey
|
|
66
61
|
* that is not for a new record but does not have an ID. This would
|
|
67
62
|
* happen if a user intentionally created one for use with a secondary-index
|
|
68
63
|
* prior to the record having been fully loaded.
|
|
69
|
-
*
|
|
70
|
-
* @internal
|
|
71
64
|
*/
|
|
72
|
-
export interface
|
|
65
|
+
export interface NewResourceKey<T extends string = string> extends ResourceKeyBase<T> {
|
|
66
|
+
/**
|
|
67
|
+
* the PrimaryKey for the resource this ResourceKey represents. `null`
|
|
68
|
+
* if not yet assigned a PrimaryKey value.
|
|
69
|
+
*
|
|
70
|
+
* @public
|
|
71
|
+
*/
|
|
73
72
|
id: string | null;
|
|
74
|
-
type: T;
|
|
75
|
-
[DEBUG_CLIENT_ORIGINATED]?: boolean;
|
|
76
|
-
[CACHE_OWNER]: number | undefined;
|
|
77
|
-
[DEBUG_STALE_CACHE_OWNER]?: number | undefined;
|
|
78
73
|
}
|
|
79
74
|
/**
|
|
80
75
|
* A referentially stable object with a unique string (lid) that can be used
|
|
81
76
|
* as a reference to data in the cache.
|
|
82
77
|
*
|
|
83
|
-
* Every
|
|
78
|
+
* Every resource has a unique ResourceKey, and ResourceKeys may refer
|
|
84
79
|
* to data that has never been loaded (for instance, in an async relationship).
|
|
85
80
|
*
|
|
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
81
|
* @public
|
|
110
82
|
*/
|
|
111
|
-
export type
|
|
112
|
-
|
|
83
|
+
export type ResourceKey<T extends string = string> = PersistedResourceKey<T> | NewResourceKey<T>;
|
|
84
|
+
/** @deprecated use {@link ResourceKey} */
|
|
85
|
+
export type StableRecordIdentifier<T extends string = string> = ResourceKey<T>;
|
|
86
|
+
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,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<
|
|
@@ -1,5 +1,15 @@
|
|
|
1
1
|
import type { ObjectValue, PrimitiveValue, Value } from "../json/raw.js";
|
|
2
2
|
/**
|
|
3
|
+
* Options signature for Legacy Attributes.
|
|
4
|
+
*/
|
|
5
|
+
export interface AttrOptions {
|
|
6
|
+
/**
|
|
7
|
+
* A primitive value or a function which produces a value.
|
|
8
|
+
*/
|
|
9
|
+
defaultValue?: PrimitiveValue | (() => Value);
|
|
10
|
+
[key: string]: Value | (() => Value) | undefined;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
3
13
|
* A generic "field" that can be used to define
|
|
4
14
|
* primitive value fields.
|
|
5
15
|
*
|
|
@@ -52,7 +62,7 @@ export interface GenericField {
|
|
|
52
62
|
*/
|
|
53
63
|
sourceKey?: string;
|
|
54
64
|
/**
|
|
55
|
-
* the name of the
|
|
65
|
+
* the name of the {@link Transformation} to use, if any
|
|
56
66
|
*
|
|
57
67
|
* @public
|
|
58
68
|
*/
|
|
@@ -463,7 +473,7 @@ export interface ObjectField {
|
|
|
463
473
|
* Configures which extensions this object should use.
|
|
464
474
|
*
|
|
465
475
|
* Extensions are registered with the store's schema service
|
|
466
|
-
* via {@link SchemaService.
|
|
476
|
+
* via {@link SchemaService.CAUTION_MEGA_DANGER_ZONE_registerExtension}
|
|
467
477
|
*
|
|
468
478
|
* Extensions should only be used for temporary enhancements
|
|
469
479
|
* to objects to support migrating away from deprecated patterns
|
|
@@ -545,6 +555,15 @@ export interface SchemaObjectField {
|
|
|
545
555
|
* @public
|
|
546
556
|
*/
|
|
547
557
|
options?: {
|
|
558
|
+
/**
|
|
559
|
+
* If true, if no value for this field exists in the cache,
|
|
560
|
+
* an empty `{}` will be used as the source for a new SchemaObject
|
|
561
|
+
* of the associated schema type, as opposed to the field's
|
|
562
|
+
* value being `null`.
|
|
563
|
+
*
|
|
564
|
+
* If `polymorphic` is `true`, defaultValue will be considered `false`.
|
|
565
|
+
*/
|
|
566
|
+
defaultValue?: boolean;
|
|
548
567
|
/**
|
|
549
568
|
* ::: warning ⚠️ Dangerous Feature Ahead
|
|
550
569
|
* :::
|
|
@@ -754,6 +773,13 @@ export interface SchemaArrayField {
|
|
|
754
773
|
* @public
|
|
755
774
|
*/
|
|
756
775
|
options?: {
|
|
776
|
+
/**
|
|
777
|
+
* If true, if no value for this field exists in the cache,
|
|
778
|
+
* an empty `[]` will be used as the value of the field,
|
|
779
|
+
* as opposed to the field's value being `null`.
|
|
780
|
+
*
|
|
781
|
+
*/
|
|
782
|
+
defaultValue?: boolean;
|
|
757
783
|
/**
|
|
758
784
|
* ::: warning ⚠️ Dangerous Feature Ahead
|
|
759
785
|
* :::
|
|
@@ -1172,8 +1198,9 @@ export interface LegacyAttributeField {
|
|
|
1172
1198
|
* Must comply to the specific transform's options
|
|
1173
1199
|
* schema.
|
|
1174
1200
|
*
|
|
1201
|
+
* See {@link AttrOptions} for more info.
|
|
1175
1202
|
*/
|
|
1176
|
-
options?:
|
|
1203
|
+
options?: AttrOptions;
|
|
1177
1204
|
}
|
|
1178
1205
|
/**
|
|
1179
1206
|
* > [!CAUTION]
|
|
@@ -1,37 +1,33 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { PersistedResourceKey } from "../identifier.js";
|
|
2
2
|
import type { ApiError } from "./error.js";
|
|
3
3
|
import type { Links, Meta, PaginationLinks } from "./json-api-raw.js";
|
|
4
4
|
export interface ResourceMetaDocument {
|
|
5
|
-
// the url or cache-key associated with the structured document
|
|
6
5
|
lid?: string;
|
|
7
6
|
meta: Meta;
|
|
8
7
|
links?: Links | PaginationLinks;
|
|
9
8
|
}
|
|
10
9
|
export interface SingleResourceDataDocument<
|
|
11
|
-
T =
|
|
12
|
-
R =
|
|
10
|
+
T = PersistedResourceKey,
|
|
11
|
+
R = PersistedResourceKey
|
|
13
12
|
> {
|
|
14
|
-
// the url or cache-key associated with the structured document
|
|
15
13
|
lid?: string;
|
|
16
14
|
links?: Links | PaginationLinks;
|
|
17
15
|
meta?: Meta;
|
|
18
16
|
data: T | null;
|
|
19
17
|
included?: R[];
|
|
20
18
|
}
|
|
21
|
-
export interface CollectionResourceDataDocument<T =
|
|
22
|
-
// the url or cache-key associated with the structured document
|
|
19
|
+
export interface CollectionResourceDataDocument<T = PersistedResourceKey> {
|
|
23
20
|
lid?: string;
|
|
24
21
|
links?: Links | PaginationLinks;
|
|
25
22
|
meta?: Meta;
|
|
26
23
|
data: T[];
|
|
27
24
|
included?: T[];
|
|
28
25
|
}
|
|
29
|
-
export type ResourceDataDocument<T =
|
|
26
|
+
export type ResourceDataDocument<T = PersistedResourceKey> = SingleResourceDataDocument<T> | CollectionResourceDataDocument<T>;
|
|
30
27
|
export interface ResourceErrorDocument {
|
|
31
|
-
// the url or cache-key associated with the structured document
|
|
32
28
|
lid?: string;
|
|
33
29
|
links?: Links | PaginationLinks;
|
|
34
30
|
meta?: Meta;
|
|
35
31
|
errors: ApiError[];
|
|
36
32
|
}
|
|
37
|
-
export type ResourceDocument<T =
|
|
33
|
+
export type ResourceDocument<T = PersistedResourceKey> = ResourceMetaDocument | SingleResourceDataDocument<T> | CollectionResourceDataDocument<T> | ResourceErrorDocument;
|