@warp-drive/utilities 5.6.0-alpha.15 → 5.6.0-alpha.17
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
|
|
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 JSON:API APIs.
|
|
7
|
+
*
|
|
8
|
+
* **Basic Usage**
|
|
9
|
+
*
|
|
10
|
+
* ```ts
|
|
11
|
+
* import { findRecord } from '@warp-drive/utilities/json-api';
|
|
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/json-api';
|
|
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/json-api';
|
|
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 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/json-api';
|
|
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
|
|
@@ -1,104 +1,103 @@
|
|
|
1
|
-
import type { QueryParamsSource } from
|
|
2
|
-
import type { TypedRecordInstance, TypeFromInstance } from
|
|
3
|
-
import type { ConstrainedRequestOptions, PostQueryRequestOptions, QueryRequestOptions } from
|
|
4
|
-
import type { CollectionResourceDataDocument } from
|
|
1
|
+
import type { QueryParamsSource } from "@warp-drive/core/types/params";
|
|
2
|
+
import type { TypedRecordInstance, TypeFromInstance } from "@warp-drive/core/types/record";
|
|
3
|
+
import type { ConstrainedRequestOptions, PostQueryRequestOptions, 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
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
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/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/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/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
|
+
* @param identifier
|
|
53
|
+
* @param query
|
|
54
|
+
* @param options
|
|
55
|
+
*/
|
|
56
56
|
export declare function query<T extends TypedRecordInstance>(type: TypeFromInstance<T>, query?: QueryParamsSource<T>, options?: ConstrainedRequestOptions): QueryRequestOptions<CollectionResourceDataDocument<T>, T>;
|
|
57
57
|
export declare function query(type: string, query?: QueryParamsSource, options?: ConstrainedRequestOptions): QueryRequestOptions;
|
|
58
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
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
59
|
+
* Builds request options to query for resources, usually by a primary
|
|
60
|
+
* type, configured for the url and header expectations of most JSON:API APIs.
|
|
61
|
+
*
|
|
62
|
+
* The key difference between this and `query` is that this method will send the query
|
|
63
|
+
* as the JSON body of a "POST" request instead of as query params in the url of a "GET"
|
|
64
|
+
* request.
|
|
65
|
+
*
|
|
66
|
+
* A CacheKey is generated from the url and query params, and used to cache the response
|
|
67
|
+
* in the store.
|
|
68
|
+
*
|
|
69
|
+
* ```ts
|
|
70
|
+
* import { postQuery } from '@warp-drive/utilities/json-api';
|
|
71
|
+
*
|
|
72
|
+
* const options = postQuery('person', { include: ['pets', 'friends'] });
|
|
73
|
+
* const data = await store.request(options);
|
|
74
|
+
* ```
|
|
75
|
+
*
|
|
76
|
+
* **Supplying Options to Modify the Request Behavior**
|
|
77
|
+
*
|
|
78
|
+
* The following options are supported:
|
|
79
|
+
*
|
|
80
|
+
* - `host` - The host to use for the request, defaults to the `host` configured with `setBuildURLConfig`.
|
|
81
|
+
* - `namespace` - The namespace to use for the request, defaults to the `namespace` configured with `setBuildURLConfig`.
|
|
82
|
+
* - `resourcePath` - The resource path to use for the request, defaults to pluralizing the supplied type
|
|
83
|
+
* - `reload` - Whether to forcibly reload the request if it is already in the store, not supplying this
|
|
84
|
+
* option will delegate to the store's CachePolicy, defaulting to `false` if none is configured.
|
|
85
|
+
* - `backgroundReload` - Whether to reload the request if it is already in the store, but to also resolve the
|
|
86
|
+
* promise with the cached value, not supplying this option will delegate to the store's CachePolicy,
|
|
87
|
+
* defaulting to `false` if none is configured.
|
|
88
|
+
* - `urlParamsSetting` - an object containing options for how to serialize the query params (see `buildQueryParams`)
|
|
89
|
+
*
|
|
90
|
+
* ```ts
|
|
91
|
+
* import { postQuery } from '@warp-drive/utilities/json-api';
|
|
92
|
+
*
|
|
93
|
+
* const options = postQuery('person', { include: ['pets', 'friends'] }, { reload: true });
|
|
94
|
+
* const data = await store.request(options);
|
|
95
|
+
* ```
|
|
96
|
+
*
|
|
97
|
+
* @public
|
|
98
|
+
* @param identifier
|
|
99
|
+
* @param query
|
|
100
|
+
* @param options
|
|
101
|
+
*/
|
|
102
102
|
export declare function postQuery<T>(type: TypeFromInstance<T>, query?: QueryParamsSource, options?: ConstrainedRequestOptions): PostQueryRequestOptions<CollectionResourceDataDocument<T>, T>;
|
|
103
103
|
export declare function postQuery(type: string, query?: QueryParamsSource, options?: ConstrainedRequestOptions): PostQueryRequestOptions;
|
|
104
|
-
//# sourceMappingURL=query.d.ts.map
|