@warp-drive/utilities 5.6.0-alpha.15 → 5.6.0-alpha.18
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/-private/active-record/find-record.d.ts +59 -60
- package/declarations/-private/active-record/query.d.ts +50 -51
- package/declarations/-private/active-record/save-record.d.ts +136 -134
- package/declarations/-private/builder-utils.d.ts +2 -3
- package/declarations/-private/handlers/auto-compress.d.ts +142 -143
- package/declarations/-private/handlers/gated.d.ts +12 -13
- package/declarations/-private/handlers/utils.d.ts +22 -23
- package/declarations/-private/json-api/-utils.d.ts +96 -97
- package/declarations/-private/json-api/find-record.d.ts +59 -60
- package/declarations/-private/json-api/query.d.ts +97 -98
- package/declarations/-private/json-api/save-record.d.ts +180 -178
- package/declarations/-private/json-api/serialize.d.ts +43 -44
- package/declarations/-private/rest/find-record.d.ts +59 -60
- package/declarations/-private/rest/query.d.ts +50 -51
- package/declarations/-private/rest/save-record.d.ts +136 -134
- package/declarations/-private/string/inflect.d.ts +60 -83
- package/declarations/-private/string/inflections.d.ts +4 -5
- package/declarations/-private/string/transform.d.ts +68 -80
- package/declarations/-private.d.ts +1 -2
- package/declarations/active-record.d.ts +3 -4
- package/declarations/handlers.d.ts +8 -9
- package/declarations/index.d.ts +180 -182
- package/declarations/json-api.d.ts +5 -6
- package/declarations/rest.d.ts +3 -4
- package/declarations/string.d.ts +13 -14
- package/dist/active-record.js +1 -1
- package/dist/{inflect-Dr20y6b1.js → inflect-BSG696t-.js} +0 -32
- package/dist/json-api.js +1 -1
- package/dist/rest.js +1 -1
- package/dist/string.cjs +0 -33
- package/dist/string.js +1 -1
- package/package.json +5 -5
- package/declarations/-private/active-record/find-record.d.ts.map +0 -1
- package/declarations/-private/active-record/query.d.ts.map +0 -1
- package/declarations/-private/active-record/save-record.d.ts.map +0 -1
- package/declarations/-private/builder-utils.d.ts.map +0 -1
- package/declarations/-private/derivations.d.ts +0 -23
- package/declarations/-private/derivations.d.ts.map +0 -1
- package/declarations/-private/handlers/auto-compress.d.ts.map +0 -1
- package/declarations/-private/handlers/gated.d.ts.map +0 -1
- package/declarations/-private/handlers/utils.d.ts.map +0 -1
- package/declarations/-private/json-api/-utils.d.ts.map +0 -1
- package/declarations/-private/json-api/find-record.d.ts.map +0 -1
- package/declarations/-private/json-api/find-record.type-test.d.ts +0 -2
- package/declarations/-private/json-api/find-record.type-test.d.ts.map +0 -1
- package/declarations/-private/json-api/query.d.ts.map +0 -1
- package/declarations/-private/json-api/query.type-test.d.ts +0 -2
- package/declarations/-private/json-api/query.type-test.d.ts.map +0 -1
- package/declarations/-private/json-api/save-record.d.ts.map +0 -1
- package/declarations/-private/json-api/serialize.d.ts.map +0 -1
- package/declarations/-private/rest/find-record.d.ts.map +0 -1
- package/declarations/-private/rest/query.d.ts.map +0 -1
- package/declarations/-private/rest/save-record.d.ts.map +0 -1
- package/declarations/-private/string/inflect.d.ts.map +0 -1
- package/declarations/-private/string/inflections.d.ts.map +0 -1
- package/declarations/-private/string/transform.d.ts.map +0 -1
- package/declarations/-private.d.ts.map +0 -1
- package/declarations/active-record.d.ts.map +0 -1
- package/declarations/handlers.d.ts.map +0 -1
- package/declarations/index.d.ts.map +0 -1
- package/declarations/json-api.d.ts.map +0 -1
- package/declarations/rest.d.ts.map +0 -1
- package/declarations/string.d.ts.map +0 -1
- package/dist/-private.js.map +0 -1
- package/dist/active-record.js.map +0 -1
- package/dist/builder-utils-Donkk-BZ.js.map +0 -1
- package/dist/handlers.js.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/inflect-Dr20y6b1.js.map +0 -1
- package/dist/json-api.js.map +0 -1
- package/dist/rest.js.map +0 -1
- package/dist/string.cjs.map +0 -1
- package/dist/string.js.map +0 -1
|
@@ -1,191 +1,193 @@
|
|
|
1
|
-
import type { TypedRecordInstance } from
|
|
2
|
-
import type { ConstrainedRequestOptions, CreateRequestOptions, DeleteRequestOptions, UpdateRequestOptions } from
|
|
3
|
-
import type { SingleResourceDataDocument } from
|
|
1
|
+
import type { TypedRecordInstance } from "@warp-drive/core/types/record";
|
|
2
|
+
import type { ConstrainedRequestOptions, CreateRequestOptions, DeleteRequestOptions, UpdateRequestOptions } from "@warp-drive/core/types/request";
|
|
3
|
+
import type { SingleResourceDataDocument } from "@warp-drive/core/types/spec/document";
|
|
4
4
|
/**
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
5
|
+
* Builds request options to delete record for resources,
|
|
6
|
+
* configured for the url, method and header expectations of most JSON:API APIs.
|
|
7
|
+
*
|
|
8
|
+
* **Basic Usage**
|
|
9
|
+
*
|
|
10
|
+
* ```ts
|
|
11
|
+
* import { deleteRecord } from '@warp-drive/utilities/json-api';
|
|
12
|
+
*
|
|
13
|
+
* const person = store.peekRecord('person', '1');
|
|
14
|
+
*
|
|
15
|
+
* // mark record as deleted
|
|
16
|
+
* store.deleteRecord(person);
|
|
17
|
+
*
|
|
18
|
+
* // persist deletion
|
|
19
|
+
* const data = await store.request(deleteRecord(person));
|
|
20
|
+
* ```
|
|
21
|
+
*
|
|
22
|
+
* **Supplying Options to Modify the Request Behavior**
|
|
23
|
+
*
|
|
24
|
+
* The following options are supported:
|
|
25
|
+
*
|
|
26
|
+
* - `host` - The host to use for the request, defaults to the `host` configured with `setBuildURLConfig`.
|
|
27
|
+
* - `namespace` - The namespace to use for the request, defaults to the `namespace` configured with `setBuildURLConfig`.
|
|
28
|
+
* - `resourcePath` - The resource path to use for the request, defaults to pluralizing the supplied type
|
|
29
|
+
* - `reload` - Whether to forcibly reload the request if it is already in the store, not supplying this
|
|
30
|
+
* option will delegate to the store's CachePolicy, defaulting to `false` if none is configured.
|
|
31
|
+
* - `backgroundReload` - Whether to reload the request if it is already in the store, but to also resolve the
|
|
32
|
+
* promise with the cached value, not supplying this option will delegate to the store's CachePolicy,
|
|
33
|
+
* defaulting to `false` if none is configured.
|
|
34
|
+
* - `urlParamsSetting` - an object containing options for how to serialize the query params (see `buildQueryParams`)
|
|
35
|
+
*
|
|
36
|
+
* ```ts
|
|
37
|
+
* import { deleteRecord } from '@warp-drive/utilities/json-api';
|
|
38
|
+
*
|
|
39
|
+
* const person = store.peekRecord('person', '1');
|
|
40
|
+
*
|
|
41
|
+
* // mark record as deleted
|
|
42
|
+
* store.deleteRecord(person);
|
|
43
|
+
*
|
|
44
|
+
* // persist deletion
|
|
45
|
+
* const options = deleteRecord(person, { namespace: 'api/v1' });
|
|
46
|
+
* const data = await store.request(options);
|
|
47
|
+
* ```
|
|
48
|
+
*
|
|
49
|
+
* @public
|
|
50
|
+
* @param record
|
|
51
|
+
* @param options
|
|
52
|
+
*/
|
|
53
53
|
export declare function deleteRecord<T>(record: T, options?: ConstrainedRequestOptions): DeleteRequestOptions<T>;
|
|
54
54
|
export declare function deleteRecord(record: unknown, options?: ConstrainedRequestOptions): DeleteRequestOptions;
|
|
55
55
|
/**
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
56
|
+
* Builds request options to create new record for resources,
|
|
57
|
+
* configured for the url, method and header expectations of most JSON:API APIs.
|
|
58
|
+
*
|
|
59
|
+
* **Basic Usage**
|
|
60
|
+
*
|
|
61
|
+
* ```ts
|
|
62
|
+
* import { createRecord } from '@warp-drive/utilities/json-api';
|
|
63
|
+
*
|
|
64
|
+
* const person = store.createRecord('person', { name: 'Ted' });
|
|
65
|
+
* const data = await store.request(createRecord(person));
|
|
66
|
+
* ```
|
|
67
|
+
*
|
|
68
|
+
* **Supplying Options to Modify the Request Behavior**
|
|
69
|
+
*
|
|
70
|
+
* The following options are supported:
|
|
71
|
+
*
|
|
72
|
+
* - `host` - The host to use for the request, defaults to the `host` configured with `setBuildURLConfig`.
|
|
73
|
+
* - `namespace` - The namespace to use for the request, defaults to the `namespace` configured with `setBuildURLConfig`.
|
|
74
|
+
* - `resourcePath` - The resource path to use for the request, defaults to pluralizing the supplied type
|
|
75
|
+
* - `reload` - Whether to forcibly reload the request if it is already in the store, not supplying this
|
|
76
|
+
* option will delegate to the store's CachePolicy, defaulting to `false` if none is configured.
|
|
77
|
+
* - `backgroundReload` - Whether to reload the request if it is already in the store, but to also resolve the
|
|
78
|
+
* promise with the cached value, not supplying this option will delegate to the store's CachePolicy,
|
|
79
|
+
* defaulting to `false` if none is configured.
|
|
80
|
+
* - `urlParamsSetting` - an object containing options for how to serialize the query params (see `buildQueryParams`)
|
|
81
|
+
*
|
|
82
|
+
* ```ts
|
|
83
|
+
* import { createRecord } from '@warp-drive/utilities/json-api';
|
|
84
|
+
*
|
|
85
|
+
* const person = store.createRecord('person', { name: 'Ted' });
|
|
86
|
+
* const options = createRecord(person, { namespace: 'api/v1' });
|
|
87
|
+
* const data = await store.request(options);
|
|
88
|
+
* ```
|
|
89
|
+
*
|
|
90
|
+
* @public
|
|
91
|
+
* @param record
|
|
92
|
+
* @param options
|
|
93
|
+
*/
|
|
94
94
|
export declare function createRecord<T>(record: T, options?: ConstrainedRequestOptions): CreateRequestOptions<T>;
|
|
95
95
|
export declare function createRecord(record: unknown, options?: ConstrainedRequestOptions): CreateRequestOptions;
|
|
96
96
|
/**
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
export declare function updateRecord<
|
|
139
|
-
|
|
97
|
+
* Builds request options to update existing record for resources,
|
|
98
|
+
* configured for the url, method and header expectations of most JSON:API APIs.
|
|
99
|
+
*
|
|
100
|
+
* **Basic Usage**
|
|
101
|
+
*
|
|
102
|
+
* ```ts
|
|
103
|
+
* import { updateRecord } from '@warp-drive/utilities/json-api';
|
|
104
|
+
*
|
|
105
|
+
* const person = store.peekRecord('person', '1');
|
|
106
|
+
* person.name = 'Chris';
|
|
107
|
+
* const data = await store.request(updateRecord(person));
|
|
108
|
+
* ```
|
|
109
|
+
*
|
|
110
|
+
* **Supplying Options to Modify the Request Behavior**
|
|
111
|
+
*
|
|
112
|
+
* The following options are supported:
|
|
113
|
+
*
|
|
114
|
+
* - `patch` - Allows caller to specify whether to use a PATCH request instead of a PUT request, defaults to `false`.
|
|
115
|
+
* - `host` - The host to use for the request, defaults to the `host` configured with `setBuildURLConfig`.
|
|
116
|
+
* - `namespace` - The namespace to use for the request, defaults to the `namespace` configured with `setBuildURLConfig`.
|
|
117
|
+
* - `resourcePath` - The resource path to use for the request, defaults to pluralizing the supplied type
|
|
118
|
+
* - `reload` - Whether to forcibly reload the request if it is already in the store, not supplying this
|
|
119
|
+
* option will delegate to the store's CachePolicy, defaulting to `false` if none is configured.
|
|
120
|
+
* - `backgroundReload` - Whether to reload the request if it is already in the store, but to also resolve the
|
|
121
|
+
* promise with the cached value, not supplying this option will delegate to the store's CachePolicy,
|
|
122
|
+
* defaulting to `false` if none is configured.
|
|
123
|
+
* - `urlParamsSetting` - an object containing options for how to serialize the query params (see `buildQueryParams`)
|
|
124
|
+
*
|
|
125
|
+
* ```ts
|
|
126
|
+
* import { updateRecord } from '@warp-drive/utilities/json-api';
|
|
127
|
+
*
|
|
128
|
+
* const person = store.peekRecord('person', '1');
|
|
129
|
+
* person.name = 'Chris';
|
|
130
|
+
* const options = updateRecord(person, { patch: true });
|
|
131
|
+
* const data = await store.request(options);
|
|
132
|
+
* ```
|
|
133
|
+
*
|
|
134
|
+
* @public
|
|
135
|
+
* @param record
|
|
136
|
+
* @param options
|
|
137
|
+
*/
|
|
138
|
+
export declare function updateRecord<
|
|
139
|
+
T extends TypedRecordInstance,
|
|
140
|
+
RT extends TypedRecordInstance = T
|
|
141
|
+
>(record: T, options?: ConstrainedRequestOptions & {
|
|
142
|
+
patch?: boolean;
|
|
140
143
|
}): UpdateRequestOptions<SingleResourceDataDocument<RT>, T>;
|
|
141
144
|
export declare function updateRecord(record: unknown, options?: ConstrainedRequestOptions & {
|
|
142
|
-
|
|
145
|
+
patch?: boolean;
|
|
143
146
|
}): UpdateRequestOptions;
|
|
144
147
|
/**
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
148
|
+
* Builds request options to update existing record for resources,
|
|
149
|
+
* configured for the url and header expectations of most JSON:API APIs
|
|
150
|
+
* for a PATCH request.
|
|
151
|
+
*
|
|
152
|
+
* Note: This is a convenience method that calls `updateRecord` with the
|
|
153
|
+
* supplied request with the `patch` option set to `true`.
|
|
154
|
+
*
|
|
155
|
+
* **Basic Usage**
|
|
156
|
+
*
|
|
157
|
+
* ```ts
|
|
158
|
+
* import { patchRecord } from '@warp-drive/utilities/json-api';
|
|
159
|
+
*
|
|
160
|
+
* const person = store.peekRecord('person', '1');
|
|
161
|
+
* person.name = 'Chris';
|
|
162
|
+
* const data = await store.request(patchRecord(person));
|
|
163
|
+
* ```
|
|
164
|
+
*
|
|
165
|
+
* **Supplying Options to Modify the Request Behavior**
|
|
166
|
+
*
|
|
167
|
+
* The following options are supported:
|
|
168
|
+
*
|
|
169
|
+
* - `host` - The host to use for the request, defaults to the `host` configured with `setBuildURLConfig`.
|
|
170
|
+
* - `namespace` - The namespace to use for the request, defaults to the `namespace` configured with `setBuildURLConfig`.
|
|
171
|
+
* - `resourcePath` - The resource path to use for the request, defaults to pluralizing the supplied type
|
|
172
|
+
* - `reload` - Whether to forcibly reload the request if it is already in the store, not supplying this
|
|
173
|
+
* option will delegate to the store's CachePolicy, defaulting to `false` if none is configured.
|
|
174
|
+
* - `backgroundReload` - Whether to reload the request if it is already in the store, but to also resolve the
|
|
175
|
+
* promise with the cached value, not supplying this option will delegate to the store's CachePolicy,
|
|
176
|
+
* defaulting to `false` if none is configured.
|
|
177
|
+
* - `urlParamsSetting` - an object containing options for how to serialize the query params (see `buildQueryParams`)
|
|
178
|
+
*
|
|
179
|
+
* ```ts
|
|
180
|
+
* import { patchRecord } from '@warp-drive/utilities/json-api';
|
|
181
|
+
*
|
|
182
|
+
* const person = store.peekRecord('person', '1');
|
|
183
|
+
* person.name = 'Chris';
|
|
184
|
+
* const options = patchRecord(person);
|
|
185
|
+
* const data = await store.request(options);
|
|
186
|
+
* ```
|
|
187
|
+
*
|
|
188
|
+
* @public
|
|
189
|
+
* @param record
|
|
190
|
+
* @param options
|
|
191
|
+
*/
|
|
189
192
|
export declare function patchRecord<T>(record: T, options?: ConstrainedRequestOptions): UpdateRequestOptions<T>;
|
|
190
193
|
export declare function patchRecord(record: unknown, options?: ConstrainedRequestOptions): UpdateRequestOptions;
|
|
191
|
-
//# sourceMappingURL=save-record.d.ts.map
|
|
@@ -1,57 +1,56 @@
|
|
|
1
|
-
import type { Cache } from
|
|
2
|
-
import type { StableRecordIdentifier } from
|
|
3
|
-
import type { Value } from
|
|
4
|
-
import type { InnerRelationshipDocument, ResourceObject } from
|
|
1
|
+
import type { Cache } from "@warp-drive/core/types/cache";
|
|
2
|
+
import type { StableRecordIdentifier } from "@warp-drive/core/types/identifier";
|
|
3
|
+
import type { Value } from "@warp-drive/core/types/json/raw";
|
|
4
|
+
import type { InnerRelationshipDocument, ResourceObject } from "@warp-drive/core/types/spec/json-api-raw";
|
|
5
5
|
type ChangedRelationshipData = InnerRelationshipDocument;
|
|
6
6
|
export type JsonApiResourcePatch = {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
7
|
+
type: string;
|
|
8
|
+
id: string;
|
|
9
|
+
attributes?: Record<string, Value>;
|
|
10
|
+
relationships?: Record<string, ChangedRelationshipData>;
|
|
11
11
|
} | {
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
12
|
+
type: string;
|
|
13
|
+
id: null;
|
|
14
|
+
lid: string;
|
|
15
|
+
attributes?: Record<string, Value>;
|
|
16
|
+
relationships?: Record<string, ChangedRelationshipData>;
|
|
17
17
|
};
|
|
18
18
|
/**
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
19
|
+
* Serializes the current state of a resource or array of resources for use with POST or PUT requests.
|
|
20
|
+
*
|
|
21
|
+
* @public
|
|
22
|
+
* @param {Cache} cache}
|
|
23
|
+
* @param {StableRecordIdentifier} identifier
|
|
24
|
+
* @return {Object} An object with a `data` property containing the serialized resource patch
|
|
25
|
+
*/
|
|
26
26
|
export declare function serializeResources(cache: Cache, identifiers: StableRecordIdentifier): {
|
|
27
|
-
|
|
27
|
+
data: ResourceObject;
|
|
28
28
|
};
|
|
29
29
|
export declare function serializeResources(cache: Cache, identifiers: StableRecordIdentifier[]): {
|
|
30
|
-
|
|
30
|
+
data: ResourceObject[];
|
|
31
31
|
};
|
|
32
32
|
/**
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
33
|
+
* Serializes changes to a resource for use with PATCH requests.
|
|
34
|
+
*
|
|
35
|
+
* Only attributes which are changed are serialized.
|
|
36
|
+
* Only relationships which are changed are serialized.
|
|
37
|
+
*
|
|
38
|
+
* Collection relationships serialize the collection as a whole.
|
|
39
|
+
*
|
|
40
|
+
* If you would like to serialize updates to a collection more granularly
|
|
41
|
+
* (for instance, as operations) request the diff from the store and
|
|
42
|
+
* serialize as desired:
|
|
43
|
+
*
|
|
44
|
+
* ```ts
|
|
45
|
+
* const relationshipDiffMap = cache.changedRelationships(identifier);
|
|
46
|
+
* ```
|
|
47
|
+
*
|
|
48
|
+
* @public
|
|
49
|
+
* @param {Cache} cache}
|
|
50
|
+
* @param {StableRecordIdentifier} identifier
|
|
51
|
+
* @return {Object} An object with a `data` property containing the serialized resource patch
|
|
52
|
+
*/
|
|
53
53
|
export declare function serializePatch(cache: Cache, identifier: StableRecordIdentifier): {
|
|
54
|
-
|
|
54
|
+
data: JsonApiResourcePatch;
|
|
55
55
|
};
|
|
56
56
|
export {};
|
|
57
|
-
//# sourceMappingURL=serialize.d.ts.map
|
|
@@ -1,66 +1,65 @@
|
|
|
1
|
-
import type { TypeFromInstance } from
|
|
2
|
-
import type { FindRecordOptions, FindRecordRequestOptions, RemotelyAccessibleIdentifier } from
|
|
3
|
-
import type { SingleResourceDataDocument } from
|
|
1
|
+
import type { TypeFromInstance } from "@warp-drive/core/types/record";
|
|
2
|
+
import type { FindRecordOptions, FindRecordRequestOptions, RemotelyAccessibleIdentifier } from "@warp-drive/core/types/request";
|
|
3
|
+
import type { SingleResourceDataDocument } from "@warp-drive/core/types/spec/document";
|
|
4
4
|
/**
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
export type FindRecordResultDocument<T> = Omit<SingleResourceDataDocument<T>,
|
|
60
|
-
|
|
5
|
+
* Builds request options to fetch a single resource by a known id or identifier
|
|
6
|
+
* configured for the url and header expectations of most REST APIs.
|
|
7
|
+
*
|
|
8
|
+
* **Basic Usage**
|
|
9
|
+
*
|
|
10
|
+
* ```ts
|
|
11
|
+
* import { findRecord } from '@warp-drive/utilities/rest';
|
|
12
|
+
*
|
|
13
|
+
* const data = await store.request(findRecord('person', '1'));
|
|
14
|
+
* ```
|
|
15
|
+
*
|
|
16
|
+
* **With Options**
|
|
17
|
+
*
|
|
18
|
+
* ```ts
|
|
19
|
+
* import { findRecord } from '@warp-drive/utilities/rest';
|
|
20
|
+
*
|
|
21
|
+
* const options = findRecord('person', '1', { include: ['pets', 'friends'] });
|
|
22
|
+
* const data = await store.request(options);
|
|
23
|
+
* ```
|
|
24
|
+
*
|
|
25
|
+
* **With an Identifier**
|
|
26
|
+
*
|
|
27
|
+
* ```ts
|
|
28
|
+
* import { findRecord } from '@warp-drive/utilities/rest';
|
|
29
|
+
*
|
|
30
|
+
* const options = findRecord({ type: 'person', id: '1' }, { include: ['pets', 'friends'] });
|
|
31
|
+
* const data = await store.request(options);
|
|
32
|
+
* ```
|
|
33
|
+
*
|
|
34
|
+
* **Supplying Options to Modify the Request Behavior**
|
|
35
|
+
*
|
|
36
|
+
* The following options are supported:
|
|
37
|
+
*
|
|
38
|
+
* - `host` - The host to use for the request, defaults to the `host` configured with `setBuildURLConfig`.
|
|
39
|
+
* - `namespace` - The namespace to use for the request, defaults to the `namespace` configured with `setBuildURLConfig`.
|
|
40
|
+
* - `resourcePath` - The resource path to use for the request, defaults to pluralizing and camelCasing the supplied type
|
|
41
|
+
* - `reload` - Whether to forcibly reload the request if it is already in the store, not supplying this
|
|
42
|
+
* option will delegate to the store's CachePolicy, defaulting to `false` if none is configured.
|
|
43
|
+
* - `backgroundReload` - Whether to reload the request if it is already in the store, but to also resolve the
|
|
44
|
+
* promise with the cached value, not supplying this option will delegate to the store's CachePolicy,
|
|
45
|
+
* defaulting to `false` if none is configured.
|
|
46
|
+
* - `urlParamsSetting` - an object containing options for how to serialize the query params (see `buildQueryParams`)
|
|
47
|
+
*
|
|
48
|
+
* ```ts
|
|
49
|
+
* import { findRecord } from '@warp-drive/utilities/rest';
|
|
50
|
+
*
|
|
51
|
+
* const options = findRecord('person', '1', { include: ['pets', 'friends'] }, { namespace: 'api/v2' });
|
|
52
|
+
* const data = await store.request(options);
|
|
53
|
+
* ```
|
|
54
|
+
*
|
|
55
|
+
* @public
|
|
56
|
+
* @param identifier
|
|
57
|
+
* @param options
|
|
58
|
+
*/
|
|
59
|
+
export type FindRecordResultDocument<T> = Omit<SingleResourceDataDocument<T>, "data"> & {
|
|
60
|
+
data: T;
|
|
61
61
|
};
|
|
62
62
|
export declare function findRecord<T>(identifier: RemotelyAccessibleIdentifier<TypeFromInstance<T>>, options?: FindRecordOptions<T>): FindRecordRequestOptions<FindRecordResultDocument<T>, T>;
|
|
63
63
|
export declare function findRecord(identifier: RemotelyAccessibleIdentifier, options?: FindRecordOptions): FindRecordRequestOptions;
|
|
64
64
|
export declare function findRecord<T>(type: TypeFromInstance<T>, id: string, options?: FindRecordOptions<T>): FindRecordRequestOptions<FindRecordResultDocument<T>, T>;
|
|
65
65
|
export declare function findRecord(type: string, id: string, options?: FindRecordOptions): FindRecordRequestOptions;
|
|
66
|
-
//# sourceMappingURL=find-record.d.ts.map
|