@warp-drive-mirror/utilities 5.8.0-alpha.37 → 5.8.0-alpha.40
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/dist/unpkg/dev/active-record.js +11 -12
- package/dist/unpkg/dev/handlers.js +4 -5
- package/dist/unpkg/dev/index.js +50 -49
- package/dist/unpkg/{prod-deprecated/inflect-BSG696t-.js → dev/inflect-BEv8WqY1.js} +4 -5
- package/dist/unpkg/dev/json-api.js +16 -16
- package/dist/unpkg/dev/rest.js +11 -12
- package/dist/unpkg/dev/string.js +1 -1
- package/dist/unpkg/dev-deprecated/active-record.js +11 -12
- package/dist/unpkg/dev-deprecated/handlers.js +4 -5
- package/dist/unpkg/dev-deprecated/index.js +50 -49
- package/dist/unpkg/dev-deprecated/{inflect-BSG696t-.js → inflect-BEv8WqY1.js} +4 -5
- package/dist/unpkg/dev-deprecated/json-api.js +16 -16
- package/dist/unpkg/dev-deprecated/rest.js +11 -12
- package/dist/unpkg/dev-deprecated/string.js +1 -1
- package/dist/unpkg/prod/active-record.js +1 -30
- package/dist/unpkg/prod/handlers.js +1 -13
- package/dist/unpkg/prod/index.js +2 -124
- package/dist/unpkg/{dev/inflect-BSG696t-.js → prod/inflect-Dh9dyEYx.js} +0 -11
- package/dist/unpkg/prod/json-api.js +2 -40
- package/dist/unpkg/prod/rest.js +1 -30
- package/dist/unpkg/prod/string.js +1 -1
- package/dist/unpkg/prod-deprecated/active-record.js +1 -30
- package/dist/unpkg/prod-deprecated/handlers.js +1 -13
- package/dist/unpkg/prod-deprecated/index.js +2 -124
- package/dist/unpkg/{prod/inflect-BSG696t-.js → prod-deprecated/inflect-Dh9dyEYx.js} +0 -11
- package/dist/unpkg/prod-deprecated/json-api.js +2 -40
- package/dist/unpkg/prod-deprecated/rest.js +1 -30
- package/dist/unpkg/prod-deprecated/string.js +1 -1
- package/package.json +12 -20
- package/dist/unpkg/dev/declarations/-private/active-record/find-record.d.ts +0 -64
- package/dist/unpkg/dev/declarations/-private/active-record/query.d.ts +0 -53
- package/dist/unpkg/dev/declarations/-private/active-record/save-record.d.ts +0 -146
- package/dist/unpkg/dev/declarations/-private/builder-utils.d.ts +0 -4
- package/dist/unpkg/dev/declarations/-private/handlers/auto-compress.d.ts +0 -158
- package/dist/unpkg/dev/declarations/-private/handlers/gated.d.ts +0 -19
- package/dist/unpkg/dev/declarations/-private/handlers/meta-doc.d.ts +0 -47
- package/dist/unpkg/dev/declarations/-private/handlers/utils.d.ts +0 -41
- package/dist/unpkg/dev/declarations/-private/json-api/-utils.d.ts +0 -109
- package/dist/unpkg/dev/declarations/-private/json-api/find-record.d.ts +0 -84
- package/dist/unpkg/dev/declarations/-private/json-api/query.d.ts +0 -100
- package/dist/unpkg/dev/declarations/-private/json-api/save-record.d.ts +0 -228
- package/dist/unpkg/dev/declarations/-private/json-api/serialize.d.ts +0 -70
- package/dist/unpkg/dev/declarations/-private/rest/find-record.d.ts +0 -62
- package/dist/unpkg/dev/declarations/-private/rest/query.d.ts +0 -53
- package/dist/unpkg/dev/declarations/-private/rest/save-record.d.ts +0 -146
- package/dist/unpkg/dev/declarations/-private/string/inflect.d.ts +0 -82
- package/dist/unpkg/dev/declarations/-private/string/inflections.d.ts +0 -9
- package/dist/unpkg/dev/declarations/-private/string/transform.d.ts +0 -77
- package/dist/unpkg/dev/declarations/-private.d.ts +0 -1
- package/dist/unpkg/dev/declarations/active-record.d.ts +0 -3
- package/dist/unpkg/dev/declarations/derivations.d.ts +0 -27
- package/dist/unpkg/dev/declarations/handlers.d.ts +0 -10
- package/dist/unpkg/dev/declarations/index.d.ts +0 -208
- package/dist/unpkg/dev/declarations/json-api.d.ts +0 -5
- package/dist/unpkg/dev/declarations/rest.d.ts +0 -3
- package/dist/unpkg/dev/declarations/string.d.ts +0 -14
- package/dist/unpkg/dev-deprecated/declarations/-private/active-record/find-record.d.ts +0 -64
- package/dist/unpkg/dev-deprecated/declarations/-private/active-record/query.d.ts +0 -53
- package/dist/unpkg/dev-deprecated/declarations/-private/active-record/save-record.d.ts +0 -146
- package/dist/unpkg/dev-deprecated/declarations/-private/builder-utils.d.ts +0 -4
- package/dist/unpkg/dev-deprecated/declarations/-private/handlers/auto-compress.d.ts +0 -158
- package/dist/unpkg/dev-deprecated/declarations/-private/handlers/gated.d.ts +0 -19
- package/dist/unpkg/dev-deprecated/declarations/-private/handlers/meta-doc.d.ts +0 -47
- package/dist/unpkg/dev-deprecated/declarations/-private/handlers/utils.d.ts +0 -41
- package/dist/unpkg/dev-deprecated/declarations/-private/json-api/-utils.d.ts +0 -109
- package/dist/unpkg/dev-deprecated/declarations/-private/json-api/find-record.d.ts +0 -84
- package/dist/unpkg/dev-deprecated/declarations/-private/json-api/query.d.ts +0 -100
- package/dist/unpkg/dev-deprecated/declarations/-private/json-api/save-record.d.ts +0 -228
- package/dist/unpkg/dev-deprecated/declarations/-private/json-api/serialize.d.ts +0 -70
- package/dist/unpkg/dev-deprecated/declarations/-private/rest/find-record.d.ts +0 -62
- package/dist/unpkg/dev-deprecated/declarations/-private/rest/query.d.ts +0 -53
- package/dist/unpkg/dev-deprecated/declarations/-private/rest/save-record.d.ts +0 -146
- package/dist/unpkg/dev-deprecated/declarations/-private/string/inflect.d.ts +0 -82
- package/dist/unpkg/dev-deprecated/declarations/-private/string/inflections.d.ts +0 -9
- package/dist/unpkg/dev-deprecated/declarations/-private/string/transform.d.ts +0 -77
- package/dist/unpkg/dev-deprecated/declarations/-private.d.ts +0 -1
- package/dist/unpkg/dev-deprecated/declarations/active-record.d.ts +0 -3
- package/dist/unpkg/dev-deprecated/declarations/derivations.d.ts +0 -27
- package/dist/unpkg/dev-deprecated/declarations/handlers.d.ts +0 -10
- package/dist/unpkg/dev-deprecated/declarations/index.d.ts +0 -208
- package/dist/unpkg/dev-deprecated/declarations/json-api.d.ts +0 -5
- package/dist/unpkg/dev-deprecated/declarations/rest.d.ts +0 -3
- package/dist/unpkg/dev-deprecated/declarations/string.d.ts +0 -14
- package/dist/unpkg/prod/declarations/-private/active-record/find-record.d.ts +0 -64
- package/dist/unpkg/prod/declarations/-private/active-record/query.d.ts +0 -53
- package/dist/unpkg/prod/declarations/-private/active-record/save-record.d.ts +0 -146
- package/dist/unpkg/prod/declarations/-private/builder-utils.d.ts +0 -4
- package/dist/unpkg/prod/declarations/-private/handlers/auto-compress.d.ts +0 -158
- package/dist/unpkg/prod/declarations/-private/handlers/gated.d.ts +0 -19
- package/dist/unpkg/prod/declarations/-private/handlers/meta-doc.d.ts +0 -47
- package/dist/unpkg/prod/declarations/-private/handlers/utils.d.ts +0 -41
- package/dist/unpkg/prod/declarations/-private/json-api/-utils.d.ts +0 -109
- package/dist/unpkg/prod/declarations/-private/json-api/find-record.d.ts +0 -84
- package/dist/unpkg/prod/declarations/-private/json-api/query.d.ts +0 -100
- package/dist/unpkg/prod/declarations/-private/json-api/save-record.d.ts +0 -228
- package/dist/unpkg/prod/declarations/-private/json-api/serialize.d.ts +0 -70
- package/dist/unpkg/prod/declarations/-private/rest/find-record.d.ts +0 -62
- package/dist/unpkg/prod/declarations/-private/rest/query.d.ts +0 -53
- package/dist/unpkg/prod/declarations/-private/rest/save-record.d.ts +0 -146
- package/dist/unpkg/prod/declarations/-private/string/inflect.d.ts +0 -82
- package/dist/unpkg/prod/declarations/-private/string/inflections.d.ts +0 -9
- package/dist/unpkg/prod/declarations/-private/string/transform.d.ts +0 -77
- package/dist/unpkg/prod/declarations/-private.d.ts +0 -1
- package/dist/unpkg/prod/declarations/active-record.d.ts +0 -3
- package/dist/unpkg/prod/declarations/derivations.d.ts +0 -27
- package/dist/unpkg/prod/declarations/handlers.d.ts +0 -10
- package/dist/unpkg/prod/declarations/index.d.ts +0 -208
- package/dist/unpkg/prod/declarations/json-api.d.ts +0 -5
- package/dist/unpkg/prod/declarations/rest.d.ts +0 -3
- package/dist/unpkg/prod/declarations/string.d.ts +0 -14
- package/dist/unpkg/prod-deprecated/declarations/-private/active-record/find-record.d.ts +0 -64
- package/dist/unpkg/prod-deprecated/declarations/-private/active-record/query.d.ts +0 -53
- package/dist/unpkg/prod-deprecated/declarations/-private/active-record/save-record.d.ts +0 -146
- package/dist/unpkg/prod-deprecated/declarations/-private/builder-utils.d.ts +0 -4
- package/dist/unpkg/prod-deprecated/declarations/-private/handlers/auto-compress.d.ts +0 -158
- package/dist/unpkg/prod-deprecated/declarations/-private/handlers/gated.d.ts +0 -19
- package/dist/unpkg/prod-deprecated/declarations/-private/handlers/meta-doc.d.ts +0 -47
- package/dist/unpkg/prod-deprecated/declarations/-private/handlers/utils.d.ts +0 -41
- package/dist/unpkg/prod-deprecated/declarations/-private/json-api/-utils.d.ts +0 -109
- package/dist/unpkg/prod-deprecated/declarations/-private/json-api/find-record.d.ts +0 -84
- package/dist/unpkg/prod-deprecated/declarations/-private/json-api/query.d.ts +0 -100
- package/dist/unpkg/prod-deprecated/declarations/-private/json-api/save-record.d.ts +0 -228
- package/dist/unpkg/prod-deprecated/declarations/-private/json-api/serialize.d.ts +0 -70
- package/dist/unpkg/prod-deprecated/declarations/-private/rest/find-record.d.ts +0 -62
- package/dist/unpkg/prod-deprecated/declarations/-private/rest/query.d.ts +0 -53
- package/dist/unpkg/prod-deprecated/declarations/-private/rest/save-record.d.ts +0 -146
- package/dist/unpkg/prod-deprecated/declarations/-private/string/inflect.d.ts +0 -82
- package/dist/unpkg/prod-deprecated/declarations/-private/string/inflections.d.ts +0 -9
- package/dist/unpkg/prod-deprecated/declarations/-private/string/transform.d.ts +0 -77
- package/dist/unpkg/prod-deprecated/declarations/-private.d.ts +0 -1
- package/dist/unpkg/prod-deprecated/declarations/active-record.d.ts +0 -3
- package/dist/unpkg/prod-deprecated/declarations/derivations.d.ts +0 -27
- package/dist/unpkg/prod-deprecated/declarations/handlers.d.ts +0 -10
- package/dist/unpkg/prod-deprecated/declarations/index.d.ts +0 -208
- package/dist/unpkg/prod-deprecated/declarations/json-api.d.ts +0 -5
- package/dist/unpkg/prod-deprecated/declarations/rest.d.ts +0 -3
- package/dist/unpkg/prod-deprecated/declarations/string.d.ts +0 -14
|
@@ -1,100 +0,0 @@
|
|
|
1
|
-
import type { ReactiveDataDocument } from "@warp-drive-mirror/core/reactive";
|
|
2
|
-
import type { QueryParamsSource } from "@warp-drive-mirror/core/types/params";
|
|
3
|
-
import type { TypedRecordInstance, TypeFromInstance } from "@warp-drive-mirror/core/types/record";
|
|
4
|
-
import type { ConstrainedRequestOptions, PostQueryRequestOptions, QueryRequestOptions } from "@warp-drive-mirror/core/types/request";
|
|
5
|
-
/**
|
|
6
|
-
* Builds request options to query for resources, usually by a primary
|
|
7
|
-
* type, configured for the url and header expectations of most JSON:API APIs.
|
|
8
|
-
*
|
|
9
|
-
* The key difference between this and `postQuery` is that this method will send the query
|
|
10
|
-
* as query params in the url of a "GET" request instead of as the JSON body of a "POST"
|
|
11
|
-
* request.
|
|
12
|
-
*
|
|
13
|
-
* **Basic Usage**
|
|
14
|
-
*
|
|
15
|
-
* ```ts
|
|
16
|
-
* import { query } from '@warp-drive-mirror/utilities/json-api';
|
|
17
|
-
*
|
|
18
|
-
* const data = await store.request(query('person'));
|
|
19
|
-
* ```
|
|
20
|
-
*
|
|
21
|
-
* **With Query Params**
|
|
22
|
-
*
|
|
23
|
-
* ```ts
|
|
24
|
-
* import { query } from '@warp-drive-mirror/utilities/json-api';
|
|
25
|
-
*
|
|
26
|
-
* const options = query('person', { include: ['pets', 'friends'] });
|
|
27
|
-
* const data = await store.request(options);
|
|
28
|
-
* ```
|
|
29
|
-
*
|
|
30
|
-
* **Supplying Options to Modify the Request Behavior**
|
|
31
|
-
*
|
|
32
|
-
* The following options are supported:
|
|
33
|
-
*
|
|
34
|
-
* - `host` - The host to use for the request, defaults to the `host` configured with `setBuildURLConfig`.
|
|
35
|
-
* - `namespace` - The namespace to use for the request, defaults to the `namespace` configured with `setBuildURLConfig`.
|
|
36
|
-
* - `resourcePath` - The resource path to use for the request, defaults to pluralizing the supplied type
|
|
37
|
-
* - `reload` - Whether to forcibly reload the request if it is already in the store, not supplying this
|
|
38
|
-
* option will delegate to the store's CachePolicy, defaulting to `false` if none is configured.
|
|
39
|
-
* - `backgroundReload` - Whether to reload the request if it is already in the store, but to also resolve the
|
|
40
|
-
* promise with the cached value, not supplying this option will delegate to the store's CachePolicy,
|
|
41
|
-
* defaulting to `false` if none is configured.
|
|
42
|
-
* - `urlParamsSetting` - an object containing options for how to serialize the query params (see `buildQueryParams`)
|
|
43
|
-
*
|
|
44
|
-
* ```ts
|
|
45
|
-
* import { query } from '@warp-drive-mirror/utilities/json-api';
|
|
46
|
-
*
|
|
47
|
-
* const options = query('person', { include: ['pets', 'friends'] }, { reload: true });
|
|
48
|
-
* const data = await store.request(options);
|
|
49
|
-
* ```
|
|
50
|
-
*
|
|
51
|
-
* @public
|
|
52
|
-
*/
|
|
53
|
-
export declare function query<T extends TypedRecordInstance>(type: TypeFromInstance<T>, query?: QueryParamsSource, options?: ConstrainedRequestOptions): QueryRequestOptions<ReactiveDataDocument<T[]>>;
|
|
54
|
-
export declare function query(type: string, query?: QueryParamsSource, options?: ConstrainedRequestOptions): QueryRequestOptions;
|
|
55
|
-
/**
|
|
56
|
-
* Builds request options to query for resources, usually by a primary
|
|
57
|
-
* type, configured for the url and header expectations of most JSON:API APIs.
|
|
58
|
-
*
|
|
59
|
-
* The key difference between this and `query` is that this method will send the query
|
|
60
|
-
* as the JSON body of a "POST" request instead of as query params in the url of a "GET"
|
|
61
|
-
* request.
|
|
62
|
-
*
|
|
63
|
-
* A CacheKey is generated from the url and query params, and used to cache the response
|
|
64
|
-
* in the store.
|
|
65
|
-
*
|
|
66
|
-
* ```ts
|
|
67
|
-
* import { postQuery } from '@warp-drive-mirror/utilities/json-api';
|
|
68
|
-
*
|
|
69
|
-
* const options = postQuery('person', { include: ['pets', 'friends'] });
|
|
70
|
-
* const data = await store.request(options);
|
|
71
|
-
* ```
|
|
72
|
-
*
|
|
73
|
-
* **Supplying Options to Modify the Request Behavior**
|
|
74
|
-
*
|
|
75
|
-
* The following options are supported:
|
|
76
|
-
*
|
|
77
|
-
* - `host` - The host to use for the request, defaults to the `host` configured with `setBuildURLConfig`.
|
|
78
|
-
* - `namespace` - The namespace to use for the request, defaults to the `namespace` configured with `setBuildURLConfig`.
|
|
79
|
-
* - `resourcePath` - The resource path to use for the request, defaults to pluralizing the supplied type
|
|
80
|
-
* - `reload` - Whether to forcibly reload the request if it is already in the store, not supplying this
|
|
81
|
-
* option will delegate to the store's CachePolicy, defaulting to `false` if none is configured.
|
|
82
|
-
* - `backgroundReload` - Whether to reload the request if it is already in the store, but to also resolve the
|
|
83
|
-
* promise with the cached value, not supplying this option will delegate to the store's CachePolicy,
|
|
84
|
-
* defaulting to `false` if none is configured.
|
|
85
|
-
* - `urlParamsSetting` - an object containing options for how to serialize the query params (see `buildQueryParams`)
|
|
86
|
-
*
|
|
87
|
-
* ```ts
|
|
88
|
-
* import { postQuery } from '@warp-drive-mirror/utilities/json-api';
|
|
89
|
-
*
|
|
90
|
-
* const options = postQuery('person', { include: ['pets', 'friends'] }, { reload: true });
|
|
91
|
-
* const data = await store.request(options);
|
|
92
|
-
* ```
|
|
93
|
-
*
|
|
94
|
-
* @public
|
|
95
|
-
* @param identifier
|
|
96
|
-
* @param query
|
|
97
|
-
* @param options
|
|
98
|
-
*/
|
|
99
|
-
export declare function postQuery<T>(type: TypeFromInstance<T>, query?: QueryParamsSource, options?: ConstrainedRequestOptions): PostQueryRequestOptions<ReactiveDataDocument<T[]>>;
|
|
100
|
-
export declare function postQuery(type: string, query?: QueryParamsSource, options?: ConstrainedRequestOptions): PostQueryRequestOptions;
|
|
@@ -1,228 +0,0 @@
|
|
|
1
|
-
import type { ReactiveDataDocument } from "@warp-drive-mirror/core/reactive.js";
|
|
2
|
-
import type { TypedRecordInstance } from "@warp-drive-mirror/core/types/record";
|
|
3
|
-
import type { ConstrainedRequestOptions, CreateRequestOptions, DeleteRequestOptions, UpdateRequestOptions } from "@warp-drive-mirror/core/types/request";
|
|
4
|
-
/**
|
|
5
|
-
* :::warning ⚠️ **These Mutation Builders DO NOT Set The Request Body**
|
|
6
|
-
* While this may come as a surprise, the app providing the body ensures that only
|
|
7
|
-
* desired and correctly formatted data is sent with the request.
|
|
8
|
-
* :::
|
|
9
|
-
*
|
|
10
|
-
* Builds request options to delete record for resources,
|
|
11
|
-
* configured for the url, method and header expectations of most JSON:API APIs.
|
|
12
|
-
*
|
|
13
|
-
* **Basic Usage**
|
|
14
|
-
*
|
|
15
|
-
* ```ts
|
|
16
|
-
* import { deleteRecord } from '@warp-drive-mirror/utilities/json-api';
|
|
17
|
-
*
|
|
18
|
-
* const person = store.peekRecord('person', '1');
|
|
19
|
-
*
|
|
20
|
-
* // mark record as deleted
|
|
21
|
-
* store.deleteRecord(person);
|
|
22
|
-
*
|
|
23
|
-
* // persist deletion
|
|
24
|
-
* const data = await store.request(deleteRecord(person));
|
|
25
|
-
* ```
|
|
26
|
-
*
|
|
27
|
-
* **Supplying Options to Modify the Request Behavior**
|
|
28
|
-
*
|
|
29
|
-
* The following options are supported:
|
|
30
|
-
*
|
|
31
|
-
* - `host` - The host to use for the request, defaults to the `host` configured with `setBuildURLConfig`.
|
|
32
|
-
* - `namespace` - The namespace to use for the request, defaults to the `namespace` configured with `setBuildURLConfig`.
|
|
33
|
-
* - `resourcePath` - The resource path to use for the request, defaults to pluralizing the supplied type
|
|
34
|
-
* - `reload` - Whether to forcibly reload the request if it is already in the store, not supplying this
|
|
35
|
-
* option will delegate to the store's CachePolicy, defaulting to `false` if none is configured.
|
|
36
|
-
* - `backgroundReload` - Whether to reload the request if it is already in the store, but to also resolve the
|
|
37
|
-
* promise with the cached value, not supplying this option will delegate to the store's CachePolicy,
|
|
38
|
-
* defaulting to `false` if none is configured.
|
|
39
|
-
* - `urlParamsSetting` - an object containing options for how to serialize the query params (see `buildQueryParams`)
|
|
40
|
-
*
|
|
41
|
-
* ```ts
|
|
42
|
-
* import { deleteRecord } from '@warp-drive-mirror/utilities/json-api';
|
|
43
|
-
*
|
|
44
|
-
* const person = store.peekRecord('person', '1');
|
|
45
|
-
*
|
|
46
|
-
* // mark record as deleted
|
|
47
|
-
* store.deleteRecord(person);
|
|
48
|
-
*
|
|
49
|
-
* // persist deletion
|
|
50
|
-
* const options = deleteRecord(person, { namespace: 'api/v1' });
|
|
51
|
-
* const data = await store.request(options);
|
|
52
|
-
* ```
|
|
53
|
-
*
|
|
54
|
-
* @public
|
|
55
|
-
* @param record
|
|
56
|
-
* @param options
|
|
57
|
-
*/
|
|
58
|
-
export declare function deleteRecord<T>(record: T, options?: ConstrainedRequestOptions): DeleteRequestOptions<T>;
|
|
59
|
-
export declare function deleteRecord(record: unknown, options?: ConstrainedRequestOptions): DeleteRequestOptions;
|
|
60
|
-
/**
|
|
61
|
-
* :::warning ⚠️ **These Mutation Builders DO NOT Set The Necessary Request Body**
|
|
62
|
-
* While this may come as a surprise, the app providing the body ensures that only
|
|
63
|
-
* desired and correctly formatted data is sent with the request.
|
|
64
|
-
* :::
|
|
65
|
-
*
|
|
66
|
-
* Builds request options to create new record for resources,
|
|
67
|
-
* configured for the url, method and header expectations of most JSON:API APIs.
|
|
68
|
-
*
|
|
69
|
-
* **Basic Usage**
|
|
70
|
-
*
|
|
71
|
-
* ```ts
|
|
72
|
-
* import { cacheKeyFor } from '@warp-drive-mirror/core';
|
|
73
|
-
* import { createRecord } from '@warp-drive-mirror/utilities/json-api';
|
|
74
|
-
* import type { Person } from '#/data/types';
|
|
75
|
-
*
|
|
76
|
-
* const person = store.createRecord<Person>('person', { name: 'Ted' });
|
|
77
|
-
* const init = createRecord(person);
|
|
78
|
-
* init.body = JSON.stringify(
|
|
79
|
-
* {
|
|
80
|
-
* // it's likely you will want to transform this data
|
|
81
|
-
* // somewhat
|
|
82
|
-
* data: store.cache.peek(cacheKeyFor(person))
|
|
83
|
-
* }
|
|
84
|
-
* );
|
|
85
|
-
* const data = await store.request(init);
|
|
86
|
-
* ```
|
|
87
|
-
*
|
|
88
|
-
* **Supplying Options to Modify the Request Behavior**
|
|
89
|
-
*
|
|
90
|
-
* The following options are supported:
|
|
91
|
-
*
|
|
92
|
-
* - `host` - The host to use for the request, defaults to the `host` configured with `setBuildURLConfig`.
|
|
93
|
-
* - `namespace` - The namespace to use for the request, defaults to the `namespace` configured with `setBuildURLConfig`.
|
|
94
|
-
* - `resourcePath` - The resource path to use for the request, defaults to pluralizing the supplied type
|
|
95
|
-
* - `reload` - Whether to forcibly reload the request if it is already in the store, not supplying this
|
|
96
|
-
* option will delegate to the store's CachePolicy, defaulting to `false` if none is configured.
|
|
97
|
-
* - `backgroundReload` - Whether to reload the request if it is already in the store, but to also resolve the
|
|
98
|
-
* promise with the cached value, not supplying this option will delegate to the store's CachePolicy,
|
|
99
|
-
* defaulting to `false` if none is configured.
|
|
100
|
-
* - `urlParamsSetting` - an object containing options for how to serialize the query params (see `buildQueryParams`)
|
|
101
|
-
*
|
|
102
|
-
* ```ts
|
|
103
|
-
* import { createRecord } from '@warp-drive-mirror/utilities/json-api';
|
|
104
|
-
*
|
|
105
|
-
* const person = store.createRecord('person', { name: 'Ted' });
|
|
106
|
-
* const options = createRecord(person, { namespace: 'api/v1' });
|
|
107
|
-
* const data = await store.request(options);
|
|
108
|
-
* ```
|
|
109
|
-
*
|
|
110
|
-
* @public
|
|
111
|
-
* @param record
|
|
112
|
-
* @param options
|
|
113
|
-
*/
|
|
114
|
-
export declare function createRecord<T>(record: T, options?: ConstrainedRequestOptions): CreateRequestOptions<T>;
|
|
115
|
-
export declare function createRecord(record: unknown, options?: ConstrainedRequestOptions): CreateRequestOptions;
|
|
116
|
-
/**
|
|
117
|
-
* :::warning ⚠️ **These Mutation Builders DO NOT Set The Necessary Request Body**
|
|
118
|
-
* While this may come as a surprise, the app providing the body ensures that only
|
|
119
|
-
* desired and correctly formatted data is sent with the request.
|
|
120
|
-
* :::
|
|
121
|
-
*
|
|
122
|
-
* Builds request options to update existing record for resources,
|
|
123
|
-
* configured for the url, method and header expectations of most JSON:API APIs.
|
|
124
|
-
*
|
|
125
|
-
* **Example Usage**
|
|
126
|
-
*
|
|
127
|
-
* ```ts
|
|
128
|
-
* import { cacheKeyFor } from '@warp-drive-mirror/core';
|
|
129
|
-
* import { updateRecord } from '@warp-drive-mirror/utilities/json-api';
|
|
130
|
-
* import type { EditablePerson } from '#/data/types';
|
|
131
|
-
*
|
|
132
|
-
* const mutable = await checkout<EditablePerson>(person);
|
|
133
|
-
* mutable.name = 'Chris';
|
|
134
|
-
* const init = updateRecord(mutable);
|
|
135
|
-
*
|
|
136
|
-
* init.body = JSON.stringify(
|
|
137
|
-
* // it's likely you will want to transform this data
|
|
138
|
-
* // somewhat, or serialize only specific properties instead
|
|
139
|
-
* serializePatch(store.cache, cacheKeyFor(mutable))
|
|
140
|
-
* );
|
|
141
|
-
* const data = await store.request(init);
|
|
142
|
-
* ```
|
|
143
|
-
*
|
|
144
|
-
*
|
|
145
|
-
* **Supplying Options to Modify the Request Behavior**
|
|
146
|
-
*
|
|
147
|
-
* The following options are supported:
|
|
148
|
-
*
|
|
149
|
-
* - `patch` - Allows caller to specify whether to use a PATCH request instead of a PUT request, defaults to `false`.
|
|
150
|
-
* - `host` - The host to use for the request, defaults to the `host` configured with `setBuildURLConfig`.
|
|
151
|
-
* - `namespace` - The namespace to use for the request, defaults to the `namespace` configured with `setBuildURLConfig`.
|
|
152
|
-
* - `resourcePath` - The resource path to use for the request, defaults to pluralizing the supplied type
|
|
153
|
-
* - `reload` - Whether to forcibly reload the request if it is already in the store, not supplying this
|
|
154
|
-
* option will delegate to the store's CachePolicy, defaulting to `false` if none is configured.
|
|
155
|
-
* - `backgroundReload` - Whether to reload the request if it is already in the store, but to also resolve the
|
|
156
|
-
* promise with the cached value, not supplying this option will delegate to the store's CachePolicy,
|
|
157
|
-
* defaulting to `false` if none is configured.
|
|
158
|
-
* - `urlParamsSetting` - an object containing options for how to serialize the query params (see `buildQueryParams`)
|
|
159
|
-
*
|
|
160
|
-
* ```ts
|
|
161
|
-
* import { updateRecord } from '@warp-drive-mirror/utilities/json-api';
|
|
162
|
-
*
|
|
163
|
-
* const person = store.peekRecord('person', '1');
|
|
164
|
-
* person.name = 'Chris';
|
|
165
|
-
* const options = updateRecord(person, { patch: true });
|
|
166
|
-
* const data = await store.request(options);
|
|
167
|
-
* ```
|
|
168
|
-
*
|
|
169
|
-
* @public
|
|
170
|
-
* @param record
|
|
171
|
-
* @param options
|
|
172
|
-
*/
|
|
173
|
-
export declare function updateRecord<
|
|
174
|
-
T extends TypedRecordInstance,
|
|
175
|
-
RT extends TypedRecordInstance = T
|
|
176
|
-
>(record: T, options?: ConstrainedRequestOptions & {
|
|
177
|
-
patch?: boolean;
|
|
178
|
-
}): UpdateRequestOptions<ReactiveDataDocument<RT>, T>;
|
|
179
|
-
export declare function updateRecord(record: unknown, options?: ConstrainedRequestOptions & {
|
|
180
|
-
patch?: boolean;
|
|
181
|
-
}): UpdateRequestOptions;
|
|
182
|
-
/**
|
|
183
|
-
* Builds request options to update existing record for resources,
|
|
184
|
-
* configured for the url and header expectations of most JSON:API APIs
|
|
185
|
-
* for a PATCH request.
|
|
186
|
-
*
|
|
187
|
-
* Note: This is a convenience method that calls `updateRecord` with the
|
|
188
|
-
* supplied request with the `patch` option set to `true`.
|
|
189
|
-
*
|
|
190
|
-
* **Basic Usage**
|
|
191
|
-
*
|
|
192
|
-
* ```ts
|
|
193
|
-
* import { patchRecord } from '@warp-drive-mirror/utilities/json-api';
|
|
194
|
-
*
|
|
195
|
-
* const person = store.peekRecord('person', '1');
|
|
196
|
-
* person.name = 'Chris';
|
|
197
|
-
* const data = await store.request(patchRecord(person));
|
|
198
|
-
* ```
|
|
199
|
-
*
|
|
200
|
-
* **Supplying Options to Modify the Request Behavior**
|
|
201
|
-
*
|
|
202
|
-
* The following options are supported:
|
|
203
|
-
*
|
|
204
|
-
* - `host` - The host to use for the request, defaults to the `host` configured with `setBuildURLConfig`.
|
|
205
|
-
* - `namespace` - The namespace to use for the request, defaults to the `namespace` configured with `setBuildURLConfig`.
|
|
206
|
-
* - `resourcePath` - The resource path to use for the request, defaults to pluralizing the supplied type
|
|
207
|
-
* - `reload` - Whether to forcibly reload the request if it is already in the store, not supplying this
|
|
208
|
-
* option will delegate to the store's CachePolicy, defaulting to `false` if none is configured.
|
|
209
|
-
* - `backgroundReload` - Whether to reload the request if it is already in the store, but to also resolve the
|
|
210
|
-
* promise with the cached value, not supplying this option will delegate to the store's CachePolicy,
|
|
211
|
-
* defaulting to `false` if none is configured.
|
|
212
|
-
* - `urlParamsSetting` - an object containing options for how to serialize the query params (see `buildQueryParams`)
|
|
213
|
-
*
|
|
214
|
-
* ```ts
|
|
215
|
-
* import { patchRecord } from '@warp-drive-mirror/utilities/json-api';
|
|
216
|
-
*
|
|
217
|
-
* const person = store.peekRecord('person', '1');
|
|
218
|
-
* person.name = 'Chris';
|
|
219
|
-
* const options = patchRecord(person);
|
|
220
|
-
* const data = await store.request(options);
|
|
221
|
-
* ```
|
|
222
|
-
*
|
|
223
|
-
* @public
|
|
224
|
-
* @param record
|
|
225
|
-
* @param options
|
|
226
|
-
*/
|
|
227
|
-
export declare function patchRecord<T>(record: T, options?: ConstrainedRequestOptions): UpdateRequestOptions<T>;
|
|
228
|
-
export declare function patchRecord(record: unknown, options?: ConstrainedRequestOptions): UpdateRequestOptions;
|
|
@@ -1,70 +0,0 @@
|
|
|
1
|
-
import type { Cache } from "@warp-drive-mirror/core/types/cache";
|
|
2
|
-
import type { ResourceKey } from "@warp-drive-mirror/core/types/identifier";
|
|
3
|
-
import type { Value } from "@warp-drive-mirror/core/types/json/raw";
|
|
4
|
-
import type { InnerRelationshipDocument, ResourceObject } from "@warp-drive-mirror/core/types/spec/json-api-raw";
|
|
5
|
-
type ChangedRelationshipData = InnerRelationshipDocument;
|
|
6
|
-
export type JsonApiResourcePatch = {
|
|
7
|
-
type: string;
|
|
8
|
-
id: string;
|
|
9
|
-
attributes?: Record<string, Value>;
|
|
10
|
-
relationships?: Record<string, ChangedRelationshipData>;
|
|
11
|
-
} | {
|
|
12
|
-
type: string;
|
|
13
|
-
id: null;
|
|
14
|
-
lid: string;
|
|
15
|
-
attributes?: Record<string, Value>;
|
|
16
|
-
relationships?: Record<string, ChangedRelationshipData>;
|
|
17
|
-
};
|
|
18
|
-
/**
|
|
19
|
-
* :::warning ⚠️ **This util often won't produce the necessary body for a {json:api} request**
|
|
20
|
-
*
|
|
21
|
-
* While this may come as a surprise, they are intended to serialize cache state for more
|
|
22
|
-
* generalized usage. {json:api} has a large variance in acceptable shapes, and only your
|
|
23
|
-
* app can ensure that the body is correctly formatted and contains all necessary data.
|
|
24
|
-
* :::
|
|
25
|
-
*
|
|
26
|
-
* Serializes the current state of a resource or array of resources for use with POST or PUT requests.
|
|
27
|
-
*
|
|
28
|
-
* @public
|
|
29
|
-
* @param {Cache} cache}
|
|
30
|
-
* @param {ResourceKey} identifier
|
|
31
|
-
* @return {Object} An object with a `data` property containing the serialized resource patch
|
|
32
|
-
*/
|
|
33
|
-
export declare function serializeResources(cache: Cache, identifiers: ResourceKey): {
|
|
34
|
-
data: ResourceObject;
|
|
35
|
-
};
|
|
36
|
-
export declare function serializeResources(cache: Cache, identifiers: ResourceKey[]): {
|
|
37
|
-
data: ResourceObject[];
|
|
38
|
-
};
|
|
39
|
-
/**
|
|
40
|
-
* :::warning ⚠️ **This util often won't produce the necessary body for a {json:api} request**
|
|
41
|
-
*
|
|
42
|
-
* While this may come as a surprise, they are intended to serialize cache state for more
|
|
43
|
-
* generalized usage. {json:api} has a large variance in acceptable shapes, and only your
|
|
44
|
-
* app can ensure that the body is correctly formatted and contains all necessary data.
|
|
45
|
-
* :::
|
|
46
|
-
*
|
|
47
|
-
* Serializes changes to a resource. Useful for use with building bodies for PATCH requests.
|
|
48
|
-
*
|
|
49
|
-
* Only attributes which are changed are serialized.
|
|
50
|
-
* Only relationships which are changed are serialized.
|
|
51
|
-
*
|
|
52
|
-
* Collection relationships serialize the collection as a whole.
|
|
53
|
-
*
|
|
54
|
-
* If you would like to serialize updates to a collection more granularly
|
|
55
|
-
* (for instance, as operations) request the diff from the store and
|
|
56
|
-
* serialize as desired:
|
|
57
|
-
*
|
|
58
|
-
* ```ts
|
|
59
|
-
* const relationshipDiffMap = cache.changedRelationships(identifier);
|
|
60
|
-
* ```
|
|
61
|
-
*
|
|
62
|
-
* @public
|
|
63
|
-
* @param {Cache} cache}
|
|
64
|
-
* @param {ResourceKey} identifier
|
|
65
|
-
* @return {Object} An object with a `data` property containing the serialized resource patch
|
|
66
|
-
*/
|
|
67
|
-
export declare function serializePatch(cache: Cache, identifier: ResourceKey): {
|
|
68
|
-
data: JsonApiResourcePatch;
|
|
69
|
-
};
|
|
70
|
-
export {};
|
|
@@ -1,62 +0,0 @@
|
|
|
1
|
-
import type { ReactiveDataDocument } from "@warp-drive-mirror/core/reactive";
|
|
2
|
-
import type { TypeFromInstance } from "@warp-drive-mirror/core/types/record";
|
|
3
|
-
import type { FindRecordOptions, FindRecordRequestOptions, RemotelyAccessibleIdentifier } from "@warp-drive-mirror/core/types/request";
|
|
4
|
-
/**
|
|
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-mirror/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-mirror/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-mirror/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-mirror/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
|
-
*/
|
|
57
|
-
export declare function findRecord<T>(identifier: RemotelyAccessibleIdentifier<TypeFromInstance<T>>, options?: FindRecordOptions): FindRecordRequestOptions<ReactiveDataDocument<T>, T>;
|
|
58
|
-
export declare function findRecord(identifier: RemotelyAccessibleIdentifier, options?: FindRecordOptions): FindRecordRequestOptions;
|
|
59
|
-
export declare function findRecord<T>(type: TypeFromInstance<T>, id: string, options?: FindRecordOptions): FindRecordRequestOptions<ReactiveDataDocument<T>, T>;
|
|
60
|
-
export declare function findRecord(type: string, id: string, options?: FindRecordOptions): FindRecordRequestOptions;
|
|
61
|
-
/** @deprecated use {@link ReactiveDataDocument} instead */
|
|
62
|
-
export type FindRecordResultDocument<T> = ReactiveDataDocument<T>;
|
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
import type { ReactiveDataDocument } from "@warp-drive-mirror/core/reactive";
|
|
2
|
-
import type { QueryParamsSource } from "@warp-drive-mirror/core/types/params";
|
|
3
|
-
import type { TypeFromInstance } from "@warp-drive-mirror/core/types/record";
|
|
4
|
-
import type { ConstrainedRequestOptions, QueryRequestOptions } from "@warp-drive-mirror/core/types/request";
|
|
5
|
-
/**
|
|
6
|
-
* Builds request options to query for resources, usually by a primary
|
|
7
|
-
* type, configured for the url and header expectations of most REST APIs.
|
|
8
|
-
*
|
|
9
|
-
* **Basic Usage**
|
|
10
|
-
*
|
|
11
|
-
* ```ts
|
|
12
|
-
* import { query } from '@warp-drive-mirror/utilities/rest';
|
|
13
|
-
*
|
|
14
|
-
* const data = await store.request(query('person'));
|
|
15
|
-
* ```
|
|
16
|
-
*
|
|
17
|
-
* **With Query Params**
|
|
18
|
-
*
|
|
19
|
-
* ```ts
|
|
20
|
-
* import { query } from '@warp-drive-mirror/utilities/rest';
|
|
21
|
-
*
|
|
22
|
-
* const options = query('person', { include: ['pets', 'friends'] });
|
|
23
|
-
* const data = await store.request(options);
|
|
24
|
-
* ```
|
|
25
|
-
*
|
|
26
|
-
* **Supplying Options to Modify the Request Behavior**
|
|
27
|
-
*
|
|
28
|
-
* The following options are supported:
|
|
29
|
-
*
|
|
30
|
-
* - `host` - The host to use for the request, defaults to the `host` configured with `setBuildURLConfig`.
|
|
31
|
-
* - `namespace` - The namespace to use for the request, defaults to the `namespace` configured with `setBuildURLConfig`.
|
|
32
|
-
* - `resourcePath` - The resource path to use for the request, defaults to pluralizing and camelCasing the supplied type
|
|
33
|
-
* - `reload` - Whether to forcibly reload the request if it is already in the store, not supplying this
|
|
34
|
-
* option will delegate to the store's CachePolicy, defaulting to `false` if none is configured.
|
|
35
|
-
* - `backgroundReload` - Whether to reload the request if it is already in the store, but to also resolve the
|
|
36
|
-
* promise with the cached value, not supplying this option will delegate to the store's CachePolicy,
|
|
37
|
-
* defaulting to `false` if none is configured.
|
|
38
|
-
* - `urlParamsSettings` - an object containing options for how to serialize the query params (see `buildQueryParams`)
|
|
39
|
-
*
|
|
40
|
-
* ```ts
|
|
41
|
-
* import { query } from '@warp-drive-mirror/utilities/rest';
|
|
42
|
-
*
|
|
43
|
-
* const options = query('person', { include: ['pets', 'friends'] }, { reload: true });
|
|
44
|
-
* const data = await store.request(options);
|
|
45
|
-
* ```
|
|
46
|
-
*
|
|
47
|
-
* @public
|
|
48
|
-
* @param identifier
|
|
49
|
-
* @param query
|
|
50
|
-
* @param options
|
|
51
|
-
*/
|
|
52
|
-
export declare function query<T>(type: TypeFromInstance<T>, query?: QueryParamsSource, options?: ConstrainedRequestOptions): QueryRequestOptions<ReactiveDataDocument<T[]>>;
|
|
53
|
-
export declare function query(type: string, query?: QueryParamsSource, options?: ConstrainedRequestOptions): QueryRequestOptions;
|
|
@@ -1,146 +0,0 @@
|
|
|
1
|
-
import type { ReactiveDataDocument } from "@warp-drive-mirror/core/reactive";
|
|
2
|
-
import type { TypedRecordInstance } from "@warp-drive-mirror/core/types/record";
|
|
3
|
-
import type { ConstrainedRequestOptions, CreateRequestOptions, DeleteRequestOptions, UpdateRequestOptions } from "@warp-drive-mirror/core/types/request";
|
|
4
|
-
/**
|
|
5
|
-
* Builds request options to delete record for resources,
|
|
6
|
-
* configured for the url, method and header expectations of REST APIs.
|
|
7
|
-
*
|
|
8
|
-
* **Basic Usage**
|
|
9
|
-
*
|
|
10
|
-
* ```ts
|
|
11
|
-
* import { deleteRecord } from '@warp-drive-mirror/utilities/rest';
|
|
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-mirror/utilities/rest';
|
|
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
|
-
export declare function deleteRecord<T>(record: T, options?: ConstrainedRequestOptions): DeleteRequestOptions<T>;
|
|
54
|
-
export declare function deleteRecord(record: unknown, options?: ConstrainedRequestOptions): DeleteRequestOptions;
|
|
55
|
-
/**
|
|
56
|
-
* Builds request options to create new record for resources,
|
|
57
|
-
* configured for the url, method and header expectations of most REST APIs.
|
|
58
|
-
*
|
|
59
|
-
* **Basic Usage**
|
|
60
|
-
*
|
|
61
|
-
* ```ts
|
|
62
|
-
* import { createRecord } from '@warp-drive-mirror/utilities/rest';
|
|
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-mirror/utilities/rest';
|
|
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
|
-
export declare function createRecord<T>(record: T, options?: ConstrainedRequestOptions): CreateRequestOptions<T>;
|
|
95
|
-
export declare function createRecord(record: unknown, options?: ConstrainedRequestOptions): CreateRequestOptions;
|
|
96
|
-
/**
|
|
97
|
-
* Builds request options to update existing record for resources,
|
|
98
|
-
* configured for the url, method and header expectations of most REST APIs.
|
|
99
|
-
*
|
|
100
|
-
* **Basic Usage**
|
|
101
|
-
*
|
|
102
|
-
* ```ts
|
|
103
|
-
* import { updateRecord } from '@warp-drive-mirror/utilities/rest';
|
|
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-mirror/utilities/rest';
|
|
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;
|
|
143
|
-
}): UpdateRequestOptions<ReactiveDataDocument<RT>, T>;
|
|
144
|
-
export declare function updateRecord(record: unknown, options?: ConstrainedRequestOptions & {
|
|
145
|
-
patch?: boolean;
|
|
146
|
-
}): UpdateRequestOptions;
|