@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.
Files changed (137) hide show
  1. package/dist/unpkg/dev/active-record.js +11 -12
  2. package/dist/unpkg/dev/handlers.js +4 -5
  3. package/dist/unpkg/dev/index.js +50 -49
  4. package/dist/unpkg/{prod-deprecated/inflect-BSG696t-.js → dev/inflect-BEv8WqY1.js} +4 -5
  5. package/dist/unpkg/dev/json-api.js +16 -16
  6. package/dist/unpkg/dev/rest.js +11 -12
  7. package/dist/unpkg/dev/string.js +1 -1
  8. package/dist/unpkg/dev-deprecated/active-record.js +11 -12
  9. package/dist/unpkg/dev-deprecated/handlers.js +4 -5
  10. package/dist/unpkg/dev-deprecated/index.js +50 -49
  11. package/dist/unpkg/dev-deprecated/{inflect-BSG696t-.js → inflect-BEv8WqY1.js} +4 -5
  12. package/dist/unpkg/dev-deprecated/json-api.js +16 -16
  13. package/dist/unpkg/dev-deprecated/rest.js +11 -12
  14. package/dist/unpkg/dev-deprecated/string.js +1 -1
  15. package/dist/unpkg/prod/active-record.js +1 -30
  16. package/dist/unpkg/prod/handlers.js +1 -13
  17. package/dist/unpkg/prod/index.js +2 -124
  18. package/dist/unpkg/{dev/inflect-BSG696t-.js → prod/inflect-Dh9dyEYx.js} +0 -11
  19. package/dist/unpkg/prod/json-api.js +2 -40
  20. package/dist/unpkg/prod/rest.js +1 -30
  21. package/dist/unpkg/prod/string.js +1 -1
  22. package/dist/unpkg/prod-deprecated/active-record.js +1 -30
  23. package/dist/unpkg/prod-deprecated/handlers.js +1 -13
  24. package/dist/unpkg/prod-deprecated/index.js +2 -124
  25. package/dist/unpkg/{prod/inflect-BSG696t-.js → prod-deprecated/inflect-Dh9dyEYx.js} +0 -11
  26. package/dist/unpkg/prod-deprecated/json-api.js +2 -40
  27. package/dist/unpkg/prod-deprecated/rest.js +1 -30
  28. package/dist/unpkg/prod-deprecated/string.js +1 -1
  29. package/package.json +12 -20
  30. package/dist/unpkg/dev/declarations/-private/active-record/find-record.d.ts +0 -64
  31. package/dist/unpkg/dev/declarations/-private/active-record/query.d.ts +0 -53
  32. package/dist/unpkg/dev/declarations/-private/active-record/save-record.d.ts +0 -146
  33. package/dist/unpkg/dev/declarations/-private/builder-utils.d.ts +0 -4
  34. package/dist/unpkg/dev/declarations/-private/handlers/auto-compress.d.ts +0 -158
  35. package/dist/unpkg/dev/declarations/-private/handlers/gated.d.ts +0 -19
  36. package/dist/unpkg/dev/declarations/-private/handlers/meta-doc.d.ts +0 -47
  37. package/dist/unpkg/dev/declarations/-private/handlers/utils.d.ts +0 -41
  38. package/dist/unpkg/dev/declarations/-private/json-api/-utils.d.ts +0 -109
  39. package/dist/unpkg/dev/declarations/-private/json-api/find-record.d.ts +0 -84
  40. package/dist/unpkg/dev/declarations/-private/json-api/query.d.ts +0 -100
  41. package/dist/unpkg/dev/declarations/-private/json-api/save-record.d.ts +0 -228
  42. package/dist/unpkg/dev/declarations/-private/json-api/serialize.d.ts +0 -70
  43. package/dist/unpkg/dev/declarations/-private/rest/find-record.d.ts +0 -62
  44. package/dist/unpkg/dev/declarations/-private/rest/query.d.ts +0 -53
  45. package/dist/unpkg/dev/declarations/-private/rest/save-record.d.ts +0 -146
  46. package/dist/unpkg/dev/declarations/-private/string/inflect.d.ts +0 -82
  47. package/dist/unpkg/dev/declarations/-private/string/inflections.d.ts +0 -9
  48. package/dist/unpkg/dev/declarations/-private/string/transform.d.ts +0 -77
  49. package/dist/unpkg/dev/declarations/-private.d.ts +0 -1
  50. package/dist/unpkg/dev/declarations/active-record.d.ts +0 -3
  51. package/dist/unpkg/dev/declarations/derivations.d.ts +0 -27
  52. package/dist/unpkg/dev/declarations/handlers.d.ts +0 -10
  53. package/dist/unpkg/dev/declarations/index.d.ts +0 -208
  54. package/dist/unpkg/dev/declarations/json-api.d.ts +0 -5
  55. package/dist/unpkg/dev/declarations/rest.d.ts +0 -3
  56. package/dist/unpkg/dev/declarations/string.d.ts +0 -14
  57. package/dist/unpkg/dev-deprecated/declarations/-private/active-record/find-record.d.ts +0 -64
  58. package/dist/unpkg/dev-deprecated/declarations/-private/active-record/query.d.ts +0 -53
  59. package/dist/unpkg/dev-deprecated/declarations/-private/active-record/save-record.d.ts +0 -146
  60. package/dist/unpkg/dev-deprecated/declarations/-private/builder-utils.d.ts +0 -4
  61. package/dist/unpkg/dev-deprecated/declarations/-private/handlers/auto-compress.d.ts +0 -158
  62. package/dist/unpkg/dev-deprecated/declarations/-private/handlers/gated.d.ts +0 -19
  63. package/dist/unpkg/dev-deprecated/declarations/-private/handlers/meta-doc.d.ts +0 -47
  64. package/dist/unpkg/dev-deprecated/declarations/-private/handlers/utils.d.ts +0 -41
  65. package/dist/unpkg/dev-deprecated/declarations/-private/json-api/-utils.d.ts +0 -109
  66. package/dist/unpkg/dev-deprecated/declarations/-private/json-api/find-record.d.ts +0 -84
  67. package/dist/unpkg/dev-deprecated/declarations/-private/json-api/query.d.ts +0 -100
  68. package/dist/unpkg/dev-deprecated/declarations/-private/json-api/save-record.d.ts +0 -228
  69. package/dist/unpkg/dev-deprecated/declarations/-private/json-api/serialize.d.ts +0 -70
  70. package/dist/unpkg/dev-deprecated/declarations/-private/rest/find-record.d.ts +0 -62
  71. package/dist/unpkg/dev-deprecated/declarations/-private/rest/query.d.ts +0 -53
  72. package/dist/unpkg/dev-deprecated/declarations/-private/rest/save-record.d.ts +0 -146
  73. package/dist/unpkg/dev-deprecated/declarations/-private/string/inflect.d.ts +0 -82
  74. package/dist/unpkg/dev-deprecated/declarations/-private/string/inflections.d.ts +0 -9
  75. package/dist/unpkg/dev-deprecated/declarations/-private/string/transform.d.ts +0 -77
  76. package/dist/unpkg/dev-deprecated/declarations/-private.d.ts +0 -1
  77. package/dist/unpkg/dev-deprecated/declarations/active-record.d.ts +0 -3
  78. package/dist/unpkg/dev-deprecated/declarations/derivations.d.ts +0 -27
  79. package/dist/unpkg/dev-deprecated/declarations/handlers.d.ts +0 -10
  80. package/dist/unpkg/dev-deprecated/declarations/index.d.ts +0 -208
  81. package/dist/unpkg/dev-deprecated/declarations/json-api.d.ts +0 -5
  82. package/dist/unpkg/dev-deprecated/declarations/rest.d.ts +0 -3
  83. package/dist/unpkg/dev-deprecated/declarations/string.d.ts +0 -14
  84. package/dist/unpkg/prod/declarations/-private/active-record/find-record.d.ts +0 -64
  85. package/dist/unpkg/prod/declarations/-private/active-record/query.d.ts +0 -53
  86. package/dist/unpkg/prod/declarations/-private/active-record/save-record.d.ts +0 -146
  87. package/dist/unpkg/prod/declarations/-private/builder-utils.d.ts +0 -4
  88. package/dist/unpkg/prod/declarations/-private/handlers/auto-compress.d.ts +0 -158
  89. package/dist/unpkg/prod/declarations/-private/handlers/gated.d.ts +0 -19
  90. package/dist/unpkg/prod/declarations/-private/handlers/meta-doc.d.ts +0 -47
  91. package/dist/unpkg/prod/declarations/-private/handlers/utils.d.ts +0 -41
  92. package/dist/unpkg/prod/declarations/-private/json-api/-utils.d.ts +0 -109
  93. package/dist/unpkg/prod/declarations/-private/json-api/find-record.d.ts +0 -84
  94. package/dist/unpkg/prod/declarations/-private/json-api/query.d.ts +0 -100
  95. package/dist/unpkg/prod/declarations/-private/json-api/save-record.d.ts +0 -228
  96. package/dist/unpkg/prod/declarations/-private/json-api/serialize.d.ts +0 -70
  97. package/dist/unpkg/prod/declarations/-private/rest/find-record.d.ts +0 -62
  98. package/dist/unpkg/prod/declarations/-private/rest/query.d.ts +0 -53
  99. package/dist/unpkg/prod/declarations/-private/rest/save-record.d.ts +0 -146
  100. package/dist/unpkg/prod/declarations/-private/string/inflect.d.ts +0 -82
  101. package/dist/unpkg/prod/declarations/-private/string/inflections.d.ts +0 -9
  102. package/dist/unpkg/prod/declarations/-private/string/transform.d.ts +0 -77
  103. package/dist/unpkg/prod/declarations/-private.d.ts +0 -1
  104. package/dist/unpkg/prod/declarations/active-record.d.ts +0 -3
  105. package/dist/unpkg/prod/declarations/derivations.d.ts +0 -27
  106. package/dist/unpkg/prod/declarations/handlers.d.ts +0 -10
  107. package/dist/unpkg/prod/declarations/index.d.ts +0 -208
  108. package/dist/unpkg/prod/declarations/json-api.d.ts +0 -5
  109. package/dist/unpkg/prod/declarations/rest.d.ts +0 -3
  110. package/dist/unpkg/prod/declarations/string.d.ts +0 -14
  111. package/dist/unpkg/prod-deprecated/declarations/-private/active-record/find-record.d.ts +0 -64
  112. package/dist/unpkg/prod-deprecated/declarations/-private/active-record/query.d.ts +0 -53
  113. package/dist/unpkg/prod-deprecated/declarations/-private/active-record/save-record.d.ts +0 -146
  114. package/dist/unpkg/prod-deprecated/declarations/-private/builder-utils.d.ts +0 -4
  115. package/dist/unpkg/prod-deprecated/declarations/-private/handlers/auto-compress.d.ts +0 -158
  116. package/dist/unpkg/prod-deprecated/declarations/-private/handlers/gated.d.ts +0 -19
  117. package/dist/unpkg/prod-deprecated/declarations/-private/handlers/meta-doc.d.ts +0 -47
  118. package/dist/unpkg/prod-deprecated/declarations/-private/handlers/utils.d.ts +0 -41
  119. package/dist/unpkg/prod-deprecated/declarations/-private/json-api/-utils.d.ts +0 -109
  120. package/dist/unpkg/prod-deprecated/declarations/-private/json-api/find-record.d.ts +0 -84
  121. package/dist/unpkg/prod-deprecated/declarations/-private/json-api/query.d.ts +0 -100
  122. package/dist/unpkg/prod-deprecated/declarations/-private/json-api/save-record.d.ts +0 -228
  123. package/dist/unpkg/prod-deprecated/declarations/-private/json-api/serialize.d.ts +0 -70
  124. package/dist/unpkg/prod-deprecated/declarations/-private/rest/find-record.d.ts +0 -62
  125. package/dist/unpkg/prod-deprecated/declarations/-private/rest/query.d.ts +0 -53
  126. package/dist/unpkg/prod-deprecated/declarations/-private/rest/save-record.d.ts +0 -146
  127. package/dist/unpkg/prod-deprecated/declarations/-private/string/inflect.d.ts +0 -82
  128. package/dist/unpkg/prod-deprecated/declarations/-private/string/inflections.d.ts +0 -9
  129. package/dist/unpkg/prod-deprecated/declarations/-private/string/transform.d.ts +0 -77
  130. package/dist/unpkg/prod-deprecated/declarations/-private.d.ts +0 -1
  131. package/dist/unpkg/prod-deprecated/declarations/active-record.d.ts +0 -3
  132. package/dist/unpkg/prod-deprecated/declarations/derivations.d.ts +0 -27
  133. package/dist/unpkg/prod-deprecated/declarations/handlers.d.ts +0 -10
  134. package/dist/unpkg/prod-deprecated/declarations/index.d.ts +0 -208
  135. package/dist/unpkg/prod-deprecated/declarations/json-api.d.ts +0 -5
  136. package/dist/unpkg/prod-deprecated/declarations/rest.d.ts +0 -3
  137. package/dist/unpkg/prod-deprecated/declarations/string.d.ts +0 -14
@@ -1,84 +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 JSON:API APIs.
7
- *
8
- * :::tabs
9
- *
10
- * == Basic Usage
11
- *
12
- * ```ts
13
- * import { findRecord } from '@warp-drive-mirror/utilities/json-api';
14
- * import type { Person } from '#/data/types';
15
- *
16
- * const result = await store.request(
17
- * findRecord<Person>('person', '1')
18
- * );
19
- * ```
20
- *
21
- * == With Options
22
- *
23
- * ```ts
24
- * import { findRecord } from '@warp-drive-mirror/utilities/json-api';
25
- * import type { Person } from '#/data/types';
26
- *
27
- * const data = await store.request(
28
- * findRecord<Person>(
29
- * 'person', '1',
30
- * { include: ['pets', 'friends'] }
31
- * )
32
- * );
33
- * ```
34
- *
35
- * == With an Identifier
36
- *
37
- * ```ts
38
- * import { findRecord } from '@warp-drive-mirror/utilities/json-api';
39
- * import type { Person } from '#/data/types';
40
- *
41
- * const data = await store.request(
42
- * findRecord<Person>(
43
- * { type: 'person', id: '1' },
44
- * { include: ['pets', 'friends'] }
45
- * )
46
- * );
47
- * ```
48
- *
49
- * :::
50
- *
51
- * **Supplying Options to Modify the Request Behavior**
52
- *
53
- * The following options are supported:
54
- *
55
- * - `host` - The host to use for the request, defaults to the `host` configured with `setBuildURLConfig`.
56
- * - `namespace` - The namespace to use for the request, defaults to the `namespace` configured with `setBuildURLConfig`.
57
- * - `resourcePath` - The resource path to use for the request, defaults to pluralizing the supplied type
58
- * - `reload` - Whether to forcibly reload the request if it is already in the store, not supplying this
59
- * option will delegate to the store's CachePolicy, defaulting to `false` if none is configured.
60
- * - `backgroundReload` - Whether to reload the request if it is already in the store, but to also resolve the
61
- * promise with the cached value, not supplying this option will delegate to the store's CachePolicy,
62
- * defaulting to `false` if none is configured.
63
- * - `urlParamsSetting` - an object containing options for how to serialize the query params (see `buildQueryParams`)
64
- *
65
- * ```ts
66
- * import { findRecord } from '@warp-drive-mirror/utilities/json-api';
67
- *
68
- * const data = await store.request(
69
- * findRecord(
70
- * 'person', '1',
71
- * { include: ['pets', 'friends'] },
72
- * { namespace: 'api/v2' }
73
- * )
74
- * );
75
- * ```
76
- *
77
- * @public
78
- */
79
- export declare function findRecord<T>(identifier: RemotelyAccessibleIdentifier<TypeFromInstance<T>>, options?: FindRecordOptions): FindRecordRequestOptions<ReactiveDataDocument<T>, T>;
80
- export declare function findRecord(identifier: RemotelyAccessibleIdentifier, options?: FindRecordOptions): FindRecordRequestOptions;
81
- export declare function findRecord<T>(type: TypeFromInstance<T>, id: string, options?: FindRecordOptions): FindRecordRequestOptions<ReactiveDataDocument<T>, T>;
82
- export declare function findRecord(type: string, id: string, options?: FindRecordOptions): FindRecordRequestOptions;
83
- /** @deprecated use {@link ReactiveDataDocument} */
84
- export type FindRecordResultDocument<T> = ReactiveDataDocument<T>;
@@ -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;