@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,66 +1,65 @@
|
|
|
1
|
-
import type { TypeFromInstance } from
|
|
2
|
-
import type { FindRecordOptions, FindRecordRequestOptions, RemotelyAccessibleIdentifier } from
|
|
3
|
-
import type { SingleResourceDataDocument } from
|
|
4
|
-
export type FindRecordResultDocument<T> = Omit<SingleResourceDataDocument<T>,
|
|
5
|
-
|
|
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
|
+
export type FindRecordResultDocument<T> = Omit<SingleResourceDataDocument<T>, "data"> & {
|
|
5
|
+
data: T;
|
|
6
6
|
};
|
|
7
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
|
-
|
|
60
|
-
|
|
61
|
-
|
|
8
|
+
* Builds request options to fetch a single resource by a known id or identifier
|
|
9
|
+
* configured for the url and header expectations of most ActiveRecord APIs.
|
|
10
|
+
*
|
|
11
|
+
* **Basic Usage**
|
|
12
|
+
*
|
|
13
|
+
* ```ts
|
|
14
|
+
* import { findRecord } from '@warp-drive/utilities/active-record';
|
|
15
|
+
*
|
|
16
|
+
* const data = await store.request(findRecord('person', '1'));
|
|
17
|
+
* ```
|
|
18
|
+
*
|
|
19
|
+
* **With Options**
|
|
20
|
+
*
|
|
21
|
+
* ```ts
|
|
22
|
+
* import { findRecord } from '@warp-drive/utilities/active-record';
|
|
23
|
+
*
|
|
24
|
+
* const options = findRecord('person', '1', { include: ['pets', 'friends'] });
|
|
25
|
+
* const data = await store.request(options);
|
|
26
|
+
* ```
|
|
27
|
+
*
|
|
28
|
+
* **With an Identifier**
|
|
29
|
+
*
|
|
30
|
+
* ```ts
|
|
31
|
+
* import { findRecord } from '@warp-drive/utilities/active-record';
|
|
32
|
+
*
|
|
33
|
+
* const options = findRecord({ type: 'person', id: '1' }, { include: ['pets', 'friends'] });
|
|
34
|
+
* const data = await store.request(options);
|
|
35
|
+
* ```
|
|
36
|
+
*
|
|
37
|
+
* **Supplying Options to Modify the Request Behavior**
|
|
38
|
+
*
|
|
39
|
+
* The following options are supported:
|
|
40
|
+
*
|
|
41
|
+
* - `host` - The host to use for the request, defaults to the `host` configured with `setBuildURLConfig`.
|
|
42
|
+
* - `namespace` - The namespace to use for the request, defaults to the `namespace` configured with `setBuildURLConfig`.
|
|
43
|
+
* - `resourcePath` - The resource path to use for the request, defaults to pluralizing and underscoring the supplied type
|
|
44
|
+
* - `reload` - Whether to forcibly reload the request if it is already in the store, not supplying this
|
|
45
|
+
* option will delegate to the store's CachePolicy, defaulting to `false` if none is configured.
|
|
46
|
+
* - `backgroundReload` - Whether to reload the request if it is already in the store, but to also resolve the
|
|
47
|
+
* promise with the cached value, not supplying this option will delegate to the store's CachePolicy,
|
|
48
|
+
* defaulting to `false` if none is configured.
|
|
49
|
+
* - `urlParamsSetting` - an object containing options for how to serialize the query params (see `buildQueryParams`)
|
|
50
|
+
*
|
|
51
|
+
* ```ts
|
|
52
|
+
* import { findRecord } from '@warp-drive/utilities/active-record';
|
|
53
|
+
*
|
|
54
|
+
* const options = findRecord('person', '1', { include: ['pets', 'friends'] }, { namespace: 'api/v2' });
|
|
55
|
+
* const data = await store.request(options);
|
|
56
|
+
* ```
|
|
57
|
+
*
|
|
58
|
+
* @public
|
|
59
|
+
* @param identifier
|
|
60
|
+
* @param options
|
|
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
|
|
@@ -1,54 +1,53 @@
|
|
|
1
|
-
import type { QueryParamsSource } from
|
|
2
|
-
import type { TypeFromInstance } from
|
|
3
|
-
import type { ConstrainedRequestOptions, QueryRequestOptions } from
|
|
4
|
-
import type { CollectionResourceDataDocument } from
|
|
1
|
+
import type { QueryParamsSource } from "@warp-drive/core/types/params";
|
|
2
|
+
import type { TypeFromInstance } from "@warp-drive/core/types/record";
|
|
3
|
+
import type { ConstrainedRequestOptions, QueryRequestOptions } from "@warp-drive/core/types/request";
|
|
4
|
+
import type { CollectionResourceDataDocument } from "@warp-drive/core/types/spec/document";
|
|
5
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
|
-
|
|
6
|
+
* Builds request options to query for resources, usually by a primary
|
|
7
|
+
* type, configured for the url and header expectations of most ActiveRecord APIs.
|
|
8
|
+
*
|
|
9
|
+
* **Basic Usage**
|
|
10
|
+
*
|
|
11
|
+
* ```ts
|
|
12
|
+
* import { query } from '@warp-drive/utilities/active-record';
|
|
13
|
+
*
|
|
14
|
+
* const data = await store.request(query('person'));
|
|
15
|
+
* ```
|
|
16
|
+
*
|
|
17
|
+
* **With Query Params**
|
|
18
|
+
*
|
|
19
|
+
* ```ts
|
|
20
|
+
* import { query } from '@warp-drive/utilities/active-record';
|
|
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 underscoring 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
|
+
* - `urlParamsSetting` - an object containing options for how to serialize the query params (see `buildQueryParams`)
|
|
39
|
+
*
|
|
40
|
+
* ```ts
|
|
41
|
+
* import { query } from '@warp-drive/utilities/active-record';
|
|
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
52
|
export declare function query<T>(type: TypeFromInstance<T>, query?: QueryParamsSource, options?: ConstrainedRequestOptions): QueryRequestOptions<CollectionResourceDataDocument<T>, T>;
|
|
53
53
|
export declare function query(type: string, query?: QueryParamsSource, options?: ConstrainedRequestOptions): QueryRequestOptions;
|
|
54
|
-
//# sourceMappingURL=query.d.ts.map
|
|
@@ -1,144 +1,146 @@
|
|
|
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 ActiveRecord APIs.
|
|
7
|
+
*
|
|
8
|
+
* **Basic Usage**
|
|
9
|
+
*
|
|
10
|
+
* ```ts
|
|
11
|
+
* import { deleteRecord } from '@warp-drive/utilities/active-record';
|
|
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/active-record';
|
|
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 ActiveRecord APIs.
|
|
58
|
+
*
|
|
59
|
+
* **Basic Usage**
|
|
60
|
+
*
|
|
61
|
+
* ```ts
|
|
62
|
+
* import { createRecord } from '@warp-drive/utilities/active-record';
|
|
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/active-record';
|
|
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 ActiveRecord APIs.
|
|
99
|
+
*
|
|
100
|
+
* **Basic Usage**
|
|
101
|
+
*
|
|
102
|
+
* ```ts
|
|
103
|
+
* import { updateRecord } from '@warp-drive/utilities/active-record';
|
|
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/active-record';
|
|
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
|
-
//# sourceMappingURL=save-record.d.ts.map
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import type { CacheOptions, ConstrainedRequestOptions } from
|
|
2
|
-
import type { UrlOptions } from
|
|
1
|
+
import type { CacheOptions, ConstrainedRequestOptions } from "@warp-drive/core/types/request";
|
|
2
|
+
import type { UrlOptions } from "../index.js";
|
|
3
3
|
export declare function copyForwardUrlOptions(urlOptions: UrlOptions, options: ConstrainedRequestOptions): void;
|
|
4
4
|
export declare function extractCacheOptions(options: ConstrainedRequestOptions): CacheOptions;
|
|
5
|
-
//# sourceMappingURL=builder-utils.d.ts.map
|