@warp-drive/utilities 5.9.0-alpha.2 → 5.9.0-alpha.21

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 (150) hide show
  1. package/cjs-dist/string.cjs +448 -0
  2. package/cjs-dist/string.cjs.map +1 -0
  3. package/declarations/-private.d.ts +12 -1
  4. package/declarations/-private.d.ts.map +1 -0
  5. package/declarations/active-record.d.ts +260 -3
  6. package/declarations/active-record.d.ts.map +1 -0
  7. package/declarations/derivations.d.ts +26 -23
  8. package/declarations/derivations.d.ts.map +1 -0
  9. package/declarations/handlers.d.ts +282 -9
  10. package/declarations/handlers.d.ts.map +1 -0
  11. package/declarations/index-BeMAuqgZ.d.ts +462 -0
  12. package/declarations/index-BeMAuqgZ.d.ts.map +1 -0
  13. package/declarations/index.d.ts +2 -208
  14. package/declarations/json-api.d.ts +496 -5
  15. package/declarations/json-api.d.ts.map +1 -0
  16. package/declarations/rest.d.ts +258 -3
  17. package/declarations/rest.d.ts.map +1 -0
  18. package/declarations/string.d.ts +164 -13
  19. package/declarations/string.d.ts.map +1 -0
  20. package/dist/-private.js +2 -6
  21. package/dist/active-record.js +254 -379
  22. package/dist/active-record.js.map +1 -0
  23. package/dist/builder-utils-BkXwUT0x.js +16 -0
  24. package/dist/builder-utils-BkXwUT0x.js.map +1 -0
  25. package/dist/derivations.js +26 -26
  26. package/dist/derivations.js.map +1 -0
  27. package/dist/handlers.js +240 -283
  28. package/dist/handlers.js.map +1 -0
  29. package/dist/index.js +357 -335
  30. package/dist/index.js.map +1 -0
  31. package/dist/inflections-DzBsjJqj.js +80 -0
  32. package/dist/inflections-DzBsjJqj.js.map +1 -0
  33. package/dist/json-api.js +470 -706
  34. package/dist/json-api.js.map +1 -0
  35. package/dist/rest.js +254 -377
  36. package/dist/rest.js.map +1 -0
  37. package/dist/string-CWmAluxh.js +290 -0
  38. package/dist/string-CWmAluxh.js.map +1 -0
  39. package/dist/string.js +2 -427
  40. package/dist/unpkg/dev/-private.js +2 -6
  41. package/dist/unpkg/dev/active-record.js +253 -378
  42. package/dist/unpkg/dev/active-record.js.map +1 -0
  43. package/dist/unpkg/dev/builder-utils-BkXwUT0x.js +16 -0
  44. package/dist/unpkg/dev/builder-utils-BkXwUT0x.js.map +1 -0
  45. package/dist/unpkg/dev/derivations.js +26 -26
  46. package/dist/unpkg/dev/derivations.js.map +1 -0
  47. package/dist/unpkg/dev/handlers.js +238 -282
  48. package/dist/unpkg/dev/handlers.js.map +1 -0
  49. package/dist/unpkg/dev/index.js +356 -336
  50. package/dist/unpkg/dev/index.js.map +1 -0
  51. package/dist/unpkg/dev/inflections-DzBsjJqj.js +80 -0
  52. package/dist/unpkg/dev/inflections-DzBsjJqj.js.map +1 -0
  53. package/dist/unpkg/dev/json-api.js +469 -706
  54. package/dist/unpkg/dev/json-api.js.map +1 -0
  55. package/dist/unpkg/dev/rest.js +253 -376
  56. package/dist/unpkg/dev/rest.js.map +1 -0
  57. package/dist/unpkg/dev/string-j4ur-TDs.js +289 -0
  58. package/dist/unpkg/dev/string-j4ur-TDs.js.map +1 -0
  59. package/dist/unpkg/dev/string.js +3 -1
  60. package/dist/unpkg/dev-deprecated/-private.js +2 -6
  61. package/dist/unpkg/dev-deprecated/active-record.js +253 -378
  62. package/dist/unpkg/dev-deprecated/active-record.js.map +1 -0
  63. package/dist/unpkg/dev-deprecated/builder-utils-BkXwUT0x.js +16 -0
  64. package/dist/unpkg/dev-deprecated/builder-utils-BkXwUT0x.js.map +1 -0
  65. package/dist/unpkg/dev-deprecated/derivations.js +26 -26
  66. package/dist/unpkg/dev-deprecated/derivations.js.map +1 -0
  67. package/dist/unpkg/dev-deprecated/handlers.js +238 -282
  68. package/dist/unpkg/dev-deprecated/handlers.js.map +1 -0
  69. package/dist/unpkg/dev-deprecated/index.js +356 -336
  70. package/dist/unpkg/dev-deprecated/index.js.map +1 -0
  71. package/dist/unpkg/dev-deprecated/inflections-DzBsjJqj.js +80 -0
  72. package/dist/unpkg/dev-deprecated/inflections-DzBsjJqj.js.map +1 -0
  73. package/dist/unpkg/dev-deprecated/json-api.js +469 -706
  74. package/dist/unpkg/dev-deprecated/json-api.js.map +1 -0
  75. package/dist/unpkg/dev-deprecated/rest.js +253 -376
  76. package/dist/unpkg/dev-deprecated/rest.js.map +1 -0
  77. package/dist/unpkg/dev-deprecated/string-j4ur-TDs.js +289 -0
  78. package/dist/unpkg/dev-deprecated/string-j4ur-TDs.js.map +1 -0
  79. package/dist/unpkg/dev-deprecated/string.js +3 -1
  80. package/dist/unpkg/prod/-private.js +2 -6
  81. package/dist/unpkg/prod/active-record.js +236 -351
  82. package/dist/unpkg/prod/active-record.js.map +1 -0
  83. package/dist/unpkg/prod/builder-utils-BkXwUT0x.js +16 -0
  84. package/dist/unpkg/prod/builder-utils-BkXwUT0x.js.map +1 -0
  85. package/dist/unpkg/prod/derivations.js +26 -26
  86. package/dist/unpkg/prod/derivations.js.map +1 -0
  87. package/dist/unpkg/prod/handlers.js +231 -272
  88. package/dist/unpkg/prod/handlers.js.map +1 -0
  89. package/dist/unpkg/prod/index.js +265 -215
  90. package/dist/unpkg/prod/index.js.map +1 -0
  91. package/dist/unpkg/prod/inflections-DzBsjJqj.js +80 -0
  92. package/dist/unpkg/prod/inflections-DzBsjJqj.js.map +1 -0
  93. package/dist/unpkg/prod/json-api.js +446 -669
  94. package/dist/unpkg/prod/json-api.js.map +1 -0
  95. package/dist/unpkg/prod/rest.js +236 -349
  96. package/dist/unpkg/prod/rest.js.map +1 -0
  97. package/dist/unpkg/prod/string-T1ahjLdj.js +283 -0
  98. package/dist/unpkg/prod/string-T1ahjLdj.js.map +1 -0
  99. package/dist/unpkg/prod/string.js +3 -1
  100. package/dist/unpkg/prod-deprecated/-private.js +2 -6
  101. package/dist/unpkg/prod-deprecated/active-record.js +236 -351
  102. package/dist/unpkg/prod-deprecated/active-record.js.map +1 -0
  103. package/dist/unpkg/prod-deprecated/builder-utils-BkXwUT0x.js +16 -0
  104. package/dist/unpkg/prod-deprecated/builder-utils-BkXwUT0x.js.map +1 -0
  105. package/dist/unpkg/prod-deprecated/derivations.js +26 -26
  106. package/dist/unpkg/prod-deprecated/derivations.js.map +1 -0
  107. package/dist/unpkg/prod-deprecated/handlers.js +231 -272
  108. package/dist/unpkg/prod-deprecated/handlers.js.map +1 -0
  109. package/dist/unpkg/prod-deprecated/index.js +265 -215
  110. package/dist/unpkg/prod-deprecated/index.js.map +1 -0
  111. package/dist/unpkg/prod-deprecated/inflections-DzBsjJqj.js +80 -0
  112. package/dist/unpkg/prod-deprecated/inflections-DzBsjJqj.js.map +1 -0
  113. package/dist/unpkg/prod-deprecated/json-api.js +446 -669
  114. package/dist/unpkg/prod-deprecated/json-api.js.map +1 -0
  115. package/dist/unpkg/prod-deprecated/rest.js +236 -349
  116. package/dist/unpkg/prod-deprecated/rest.js.map +1 -0
  117. package/dist/unpkg/prod-deprecated/string-T1ahjLdj.js +283 -0
  118. package/dist/unpkg/prod-deprecated/string-T1ahjLdj.js.map +1 -0
  119. package/dist/unpkg/prod-deprecated/string.js +3 -1
  120. package/package.json +11 -10
  121. package/declarations/-private/active-record/find-record.d.ts +0 -64
  122. package/declarations/-private/active-record/query.d.ts +0 -53
  123. package/declarations/-private/active-record/save-record.d.ts +0 -146
  124. package/declarations/-private/builder-utils.d.ts +0 -4
  125. package/declarations/-private/handlers/auto-compress.d.ts +0 -158
  126. package/declarations/-private/handlers/gated.d.ts +0 -19
  127. package/declarations/-private/handlers/meta-doc.d.ts +0 -47
  128. package/declarations/-private/handlers/utils.d.ts +0 -41
  129. package/declarations/-private/json-api/-utils.d.ts +0 -109
  130. package/declarations/-private/json-api/find-record.d.ts +0 -84
  131. package/declarations/-private/json-api/query.d.ts +0 -100
  132. package/declarations/-private/json-api/save-record.d.ts +0 -228
  133. package/declarations/-private/json-api/serialize.d.ts +0 -70
  134. package/declarations/-private/rest/find-record.d.ts +0 -62
  135. package/declarations/-private/rest/query.d.ts +0 -53
  136. package/declarations/-private/rest/save-record.d.ts +0 -146
  137. package/declarations/-private/string/inflect.d.ts +0 -82
  138. package/declarations/-private/string/inflections.d.ts +0 -9
  139. package/declarations/-private/string/transform.d.ts +0 -77
  140. package/dist/builder-utils-Donkk-BZ.js +0 -22
  141. package/dist/inflect-BSG696t-.js +0 -344
  142. package/dist/string.cjs +0 -430
  143. package/dist/unpkg/dev/builder-utils-Donkk-BZ.js +0 -22
  144. package/dist/unpkg/dev/inflect-BEv8WqY1.js +0 -343
  145. package/dist/unpkg/dev-deprecated/builder-utils-Donkk-BZ.js +0 -22
  146. package/dist/unpkg/dev-deprecated/inflect-BEv8WqY1.js +0 -343
  147. package/dist/unpkg/prod/builder-utils-Donkk-BZ.js +0 -22
  148. package/dist/unpkg/prod/inflect-Dh9dyEYx.js +0 -333
  149. package/dist/unpkg/prod-deprecated/builder-utils-Donkk-BZ.js +0 -22
  150. package/dist/unpkg/prod-deprecated/inflect-Dh9dyEYx.js +0 -333
@@ -1,366 +1,251 @@
1
- import { buildBaseURL, buildQueryParams } from './index.js';
2
- import { p as pluralize, j as underscore } from "./inflect-Dh9dyEYx.js";
3
- import { e as extractCacheOptions, c as copyForwardUrlOptions } from "./builder-utils-Donkk-BZ.js";
4
- import { recordIdentifierFor } from '@warp-drive/core';
5
-
6
- /**
7
- * Builds request options to fetch a single resource by a known id or identifier
8
- * configured for the url and header expectations of most ActiveRecord APIs.
9
- *
10
- * **Basic Usage**
11
- *
12
- * ```ts
13
- * import { findRecord } from '@warp-drive/utilities/active-record';
14
- *
15
- * const data = await store.request(findRecord('person', '1'));
16
- * ```
17
- *
18
- * **With Options**
19
- *
20
- * ```ts
21
- * import { findRecord } from '@warp-drive/utilities/active-record';
22
- *
23
- * const options = findRecord('person', '1', { include: ['pets', 'friends'] });
24
- * const data = await store.request(options);
25
- * ```
26
- *
27
- * **With an Identifier**
28
- *
29
- * ```ts
30
- * import { findRecord } from '@warp-drive/utilities/active-record';
31
- *
32
- * const options = findRecord({ type: 'person', id: '1' }, { include: ['pets', 'friends'] });
33
- * const data = await store.request(options);
34
- * ```
35
- *
36
- * **Supplying Options to Modify the Request Behavior**
37
- *
38
- * The following options are supported:
39
- *
40
- * - `host` - The host to use for the request, defaults to the `host` configured with `setBuildURLConfig`.
41
- * - `namespace` - The namespace to use for the request, defaults to the `namespace` configured with `setBuildURLConfig`.
42
- * - `resourcePath` - The resource path to use for the request, defaults to pluralizing and underscoring the supplied type
43
- * - `reload` - Whether to forcibly reload the request if it is already in the store, not supplying this
44
- * option will delegate to the store's CachePolicy, defaulting to `false` if none is configured.
45
- * - `backgroundReload` - Whether to reload the request if it is already in the store, but to also resolve the
46
- * promise with the cached value, not supplying this option will delegate to the store's CachePolicy,
47
- * defaulting to `false` if none is configured.
48
- * - `urlParamsSetting` - an object containing options for how to serialize the query params (see `buildQueryParams`)
49
- *
50
- * ```ts
51
- * import { findRecord } from '@warp-drive/utilities/active-record';
52
- *
53
- * const options = findRecord('person', '1', { include: ['pets', 'friends'] }, { namespace: 'api/v2' });
54
- * const data = await store.request(options);
55
- * ```
56
- *
57
- * @public
58
- * @param identifier
59
- * @param options
60
- */
1
+ import { buildBaseURL, buildQueryParams } from "./index.js";
2
+ import { g as underscore, s as pluralize } from "./string-T1ahjLdj.js";
3
+ import { n as extractCacheOptions, t as copyForwardUrlOptions } from "./builder-utils-BkXwUT0x.js";
4
+ import { recordIdentifierFor } from "@warp-drive/core";
61
5
 
6
+ //#region src/-private/active-record/find-record.ts
62
7
  function findRecord(arg1, arg2, arg3) {
63
- const identifier = typeof arg1 === 'string' ? {
64
- type: arg1,
65
- id: arg2
66
- } : arg1;
67
- const options = (typeof arg1 === 'string' ? arg3 : arg2) || {};
68
- const cacheOptions = extractCacheOptions(options);
69
- const urlOptions = {
70
- identifier,
71
- op: 'findRecord',
72
- resourcePath: pluralize(underscore(identifier.type))
73
- };
74
- copyForwardUrlOptions(urlOptions, options);
75
- const url = buildBaseURL(urlOptions);
76
- const headers = new Headers();
77
- headers.append('Accept', 'application/json;charset=utf-8');
78
- return {
79
- url: options.include?.length ? `${url}?${buildQueryParams({
80
- include: options.include
81
- }, options.urlParamsSettings)}` : url,
82
- method: 'GET',
83
- headers,
84
- cacheOptions,
85
- op: 'findRecord',
86
- records: [identifier]
87
- };
8
+ const identifier = typeof arg1 === "string" ? {
9
+ type: arg1,
10
+ id: arg2
11
+ } : arg1;
12
+ const options = (typeof arg1 === "string" ? arg3 : arg2) || {};
13
+ const cacheOptions = extractCacheOptions(options);
14
+ const urlOptions = {
15
+ identifier,
16
+ op: "findRecord",
17
+ resourcePath: pluralize(underscore(identifier.type))
18
+ };
19
+ copyForwardUrlOptions(urlOptions, options);
20
+ const url = buildBaseURL(urlOptions);
21
+ const headers = new Headers();
22
+ headers.append("Accept", "application/json;charset=utf-8");
23
+ return {
24
+ url: options.include?.length ? `${url}?${buildQueryParams({ include: options.include }, options.urlParamsSettings)}` : url,
25
+ method: "GET",
26
+ headers,
27
+ cacheOptions,
28
+ op: "findRecord",
29
+ records: [identifier]
30
+ };
88
31
  }
89
32
 
90
- /** @deprecated use {@link ReactiveDataDocument} instead */
91
-
92
- /**
93
- * Builds request options to query for resources, usually by a primary
94
- * type, configured for the url and header expectations of most ActiveRecord APIs.
95
- *
96
- * **Basic Usage**
97
- *
98
- * ```ts
99
- * import { query } from '@warp-drive/utilities/active-record';
100
- *
101
- * const data = await store.request(query('person'));
102
- * ```
103
- *
104
- * **With Query Params**
105
- *
106
- * ```ts
107
- * import { query } from '@warp-drive/utilities/active-record';
108
- *
109
- * const options = query('person', { include: ['pets', 'friends'] });
110
- * const data = await store.request(options);
111
- * ```
112
- *
113
- * **Supplying Options to Modify the Request Behavior**
114
- *
115
- * The following options are supported:
116
- *
117
- * - `host` - The host to use for the request, defaults to the `host` configured with `setBuildURLConfig`.
118
- * - `namespace` - The namespace to use for the request, defaults to the `namespace` configured with `setBuildURLConfig`.
119
- * - `resourcePath` - The resource path to use for the request, defaults to pluralizing and underscoring the supplied type
120
- * - `reload` - Whether to forcibly reload the request if it is already in the store, not supplying this
121
- * option will delegate to the store's CachePolicy, defaulting to `false` if none is configured.
122
- * - `backgroundReload` - Whether to reload the request if it is already in the store, but to also resolve the
123
- * promise with the cached value, not supplying this option will delegate to the store's CachePolicy,
124
- * defaulting to `false` if none is configured.
125
- * - `urlParamsSetting` - an object containing options for how to serialize the query params (see `buildQueryParams`)
126
- *
127
- * ```ts
128
- * import { query } from '@warp-drive/utilities/active-record';
129
- *
130
- * const options = query('person', { include: ['pets', 'friends'] }, { reload: true });
131
- * const data = await store.request(options);
132
- * ```
133
- *
134
- * @public
135
- * @param identifier
136
- * @param query
137
- * @param options
138
- */
139
-
140
- function query(type,
141
- // eslint-disable-next-line @typescript-eslint/no-shadow
142
- query = {}, options = {}) {
143
- const cacheOptions = extractCacheOptions(options);
144
- const urlOptions = {
145
- identifier: {
146
- type
147
- },
148
- op: 'query',
149
- resourcePath: pluralize(underscore(type))
150
- };
151
- copyForwardUrlOptions(urlOptions, options);
152
- const url = buildBaseURL(urlOptions);
153
- const headers = new Headers();
154
- headers.append('Accept', 'application/json;charset=utf-8');
155
- const queryString = buildQueryParams(query, options.urlParamsSettings);
156
- return {
157
- url: queryString ? `${url}?${queryString}` : url,
158
- method: 'GET',
159
- headers,
160
- cacheOptions,
161
- op: 'query'
162
- };
33
+ //#endregion
34
+ //#region src/-private/active-record/query.ts
35
+ function query(type, query = {}, options = {}) {
36
+ const cacheOptions = extractCacheOptions(options);
37
+ const urlOptions = {
38
+ identifier: { type },
39
+ op: "query",
40
+ resourcePath: pluralize(underscore(type))
41
+ };
42
+ copyForwardUrlOptions(urlOptions, options);
43
+ const url = buildBaseURL(urlOptions);
44
+ const headers = new Headers();
45
+ headers.append("Accept", "application/json;charset=utf-8");
46
+ const queryString = buildQueryParams(query, options.urlParamsSettings);
47
+ return {
48
+ url: queryString ? `${url}?${queryString}` : url,
49
+ method: "GET",
50
+ headers,
51
+ cacheOptions,
52
+ op: "query"
53
+ };
163
54
  }
164
55
 
56
+ //#endregion
57
+ //#region src/-private/active-record/save-record.ts
165
58
  /**
166
- * Builds request options to delete record for resources,
167
- * configured for the url, method and header expectations of ActiveRecord APIs.
168
- *
169
- * **Basic Usage**
170
- *
171
- * ```ts
172
- * import { deleteRecord } from '@warp-drive/utilities/active-record';
173
- *
174
- * const person = store.peekRecord('person', '1');
175
- *
176
- * // mark record as deleted
177
- * store.deleteRecord(person);
178
- *
179
- * // persist deletion
180
- * const data = await store.request(deleteRecord(person));
181
- * ```
182
- *
183
- * **Supplying Options to Modify the Request Behavior**
184
- *
185
- * The following options are supported:
186
- *
187
- * - `host` - The host to use for the request, defaults to the `host` configured with `setBuildURLConfig`.
188
- * - `namespace` - The namespace to use for the request, defaults to the `namespace` configured with `setBuildURLConfig`.
189
- * - `resourcePath` - The resource path to use for the request, defaults to pluralizing the supplied type
190
- * - `reload` - Whether to forcibly reload the request if it is already in the store, not supplying this
191
- * option will delegate to the store's CachePolicy, defaulting to `false` if none is configured.
192
- * - `backgroundReload` - Whether to reload the request if it is already in the store, but to also resolve the
193
- * promise with the cached value, not supplying this option will delegate to the store's CachePolicy,
194
- * defaulting to `false` if none is configured.
195
- * - `urlParamsSetting` - an object containing options for how to serialize the query params (see `buildQueryParams`)
196
- *
197
- * ```ts
198
- * import { deleteRecord } from '@warp-drive/utilities/active-record';
199
- *
200
- * const person = store.peekRecord('person', '1');
201
- *
202
- * // mark record as deleted
203
- * store.deleteRecord(person);
204
- *
205
- * // persist deletion
206
- * const options = deleteRecord(person, { namespace: 'api/v1' });
207
- * const data = await store.request(options);
208
- * ```
209
- *
210
- * @public
211
- * @param record
212
- * @param options
213
- */
214
-
59
+ * Builds request options to delete record for resources,
60
+ * configured for the url, method and header expectations of ActiveRecord APIs.
61
+ *
62
+ * **Basic Usage**
63
+ *
64
+ * ```ts
65
+ * import { deleteRecord } from '@warp-drive/utilities/active-record';
66
+ *
67
+ * const person = store.peekRecord('person', '1');
68
+ *
69
+ * // mark record as deleted
70
+ * store.deleteRecord(person);
71
+ *
72
+ * // persist deletion
73
+ * const data = await store.request(deleteRecord(person));
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 { deleteRecord } from '@warp-drive/utilities/active-record';
92
+ *
93
+ * const person = store.peekRecord('person', '1');
94
+ *
95
+ * // mark record as deleted
96
+ * store.deleteRecord(person);
97
+ *
98
+ * // persist deletion
99
+ * const options = deleteRecord(person, { namespace: 'api/v1' });
100
+ * const data = await store.request(options);
101
+ * ```
102
+ *
103
+ * @public
104
+ * @param record
105
+ * @param options
106
+ */
215
107
  function deleteRecord(record, options = {}) {
216
- const identifier = recordIdentifierFor(record);
217
- const urlOptions = {
218
- identifier: identifier,
219
- op: 'deleteRecord',
220
- resourcePath: pluralize(underscore(identifier.type))
221
- };
222
- copyForwardUrlOptions(urlOptions, options);
223
- const url = buildBaseURL(urlOptions);
224
- const headers = new Headers();
225
- headers.append('Accept', 'application/json;charset=utf-8');
226
- return {
227
- url,
228
- method: 'DELETE',
229
- headers,
230
- op: 'deleteRecord',
231
- data: {
232
- record: identifier
233
- },
234
- records: [identifier]
235
- };
108
+ const identifier = recordIdentifierFor(record);
109
+ const urlOptions = {
110
+ identifier,
111
+ op: "deleteRecord",
112
+ resourcePath: pluralize(underscore(identifier.type))
113
+ };
114
+ copyForwardUrlOptions(urlOptions, options);
115
+ const url = buildBaseURL(urlOptions);
116
+ const headers = new Headers();
117
+ headers.append("Accept", "application/json;charset=utf-8");
118
+ return {
119
+ url,
120
+ method: "DELETE",
121
+ headers,
122
+ op: "deleteRecord",
123
+ data: { record: identifier },
124
+ records: [identifier]
125
+ };
236
126
  }
237
-
238
127
  /**
239
- * Builds request options to create new record for resources,
240
- * configured for the url, method and header expectations of most ActiveRecord APIs.
241
- *
242
- * **Basic Usage**
243
- *
244
- * ```ts
245
- * import { createRecord } from '@warp-drive/utilities/active-record';
246
- *
247
- * const person = store.createRecord('person', { name: 'Ted' });
248
- * const data = await store.request(createRecord(person));
249
- * ```
250
- *
251
- * **Supplying Options to Modify the Request Behavior**
252
- *
253
- * The following options are supported:
254
- *
255
- * - `host` - The host to use for the request, defaults to the `host` configured with `setBuildURLConfig`.
256
- * - `namespace` - The namespace to use for the request, defaults to the `namespace` configured with `setBuildURLConfig`.
257
- * - `resourcePath` - The resource path to use for the request, defaults to pluralizing the supplied type
258
- * - `reload` - Whether to forcibly reload the request if it is already in the store, not supplying this
259
- * option will delegate to the store's CachePolicy, defaulting to `false` if none is configured.
260
- * - `backgroundReload` - Whether to reload the request if it is already in the store, but to also resolve the
261
- * promise with the cached value, not supplying this option will delegate to the store's CachePolicy,
262
- * defaulting to `false` if none is configured.
263
- * - `urlParamsSetting` - an object containing options for how to serialize the query params (see `buildQueryParams`)
264
- *
265
- * ```ts
266
- * import { createRecord } from '@warp-drive/utilities/active-record';
267
- *
268
- * const person = store.createRecord('person', { name: 'Ted' });
269
- * const options = createRecord(person, { namespace: 'api/v1' });
270
- * const data = await store.request(options);
271
- * ```
272
- *
273
- * @public
274
- * @param record
275
- * @param options
276
- */
277
-
128
+ * Builds request options to create new record for resources,
129
+ * configured for the url, method and header expectations of most ActiveRecord APIs.
130
+ *
131
+ * **Basic Usage**
132
+ *
133
+ * ```ts
134
+ * import { createRecord } from '@warp-drive/utilities/active-record';
135
+ *
136
+ * const person = store.createRecord('person', { name: 'Ted' });
137
+ * const data = await store.request(createRecord(person));
138
+ * ```
139
+ *
140
+ * **Supplying Options to Modify the Request Behavior**
141
+ *
142
+ * The following options are supported:
143
+ *
144
+ * - `host` - The host to use for the request, defaults to the `host` configured with `setBuildURLConfig`.
145
+ * - `namespace` - The namespace to use for the request, defaults to the `namespace` configured with `setBuildURLConfig`.
146
+ * - `resourcePath` - The resource path to use for the request, defaults to pluralizing the supplied type
147
+ * - `reload` - Whether to forcibly reload the request if it is already in the store, not supplying this
148
+ * option will delegate to the store's CachePolicy, defaulting to `false` if none is configured.
149
+ * - `backgroundReload` - Whether to reload the request if it is already in the store, but to also resolve the
150
+ * promise with the cached value, not supplying this option will delegate to the store's CachePolicy,
151
+ * defaulting to `false` if none is configured.
152
+ * - `urlParamsSetting` - an object containing options for how to serialize the query params (see `buildQueryParams`)
153
+ *
154
+ * ```ts
155
+ * import { createRecord } from '@warp-drive/utilities/active-record';
156
+ *
157
+ * const person = store.createRecord('person', { name: 'Ted' });
158
+ * const options = createRecord(person, { namespace: 'api/v1' });
159
+ * const data = await store.request(options);
160
+ * ```
161
+ *
162
+ * @public
163
+ * @param record
164
+ * @param options
165
+ */
278
166
  function createRecord(record, options = {}) {
279
- const identifier = recordIdentifierFor(record);
280
- const urlOptions = {
281
- identifier: identifier,
282
- op: 'createRecord',
283
- resourcePath: pluralize(underscore(identifier.type))
284
- };
285
- copyForwardUrlOptions(urlOptions, options);
286
- const url = buildBaseURL(urlOptions);
287
- const headers = new Headers();
288
- headers.append('Accept', 'application/json;charset=utf-8');
289
- return {
290
- url,
291
- method: 'POST',
292
- headers,
293
- op: 'createRecord',
294
- data: {
295
- record: identifier
296
- },
297
- records: [identifier]
298
- };
167
+ const identifier = recordIdentifierFor(record);
168
+ const urlOptions = {
169
+ identifier,
170
+ op: "createRecord",
171
+ resourcePath: pluralize(underscore(identifier.type))
172
+ };
173
+ copyForwardUrlOptions(urlOptions, options);
174
+ const url = buildBaseURL(urlOptions);
175
+ const headers = new Headers();
176
+ headers.append("Accept", "application/json;charset=utf-8");
177
+ return {
178
+ url,
179
+ method: "POST",
180
+ headers,
181
+ op: "createRecord",
182
+ data: { record: identifier },
183
+ records: [identifier]
184
+ };
299
185
  }
300
-
301
186
  /**
302
- * Builds request options to update existing record for resources,
303
- * configured for the url, method and header expectations of most ActiveRecord APIs.
304
- *
305
- * **Basic Usage**
306
- *
307
- * ```ts
308
- * import { updateRecord } from '@warp-drive/utilities/active-record';
309
- *
310
- * const person = store.peekRecord('person', '1');
311
- * person.name = 'Chris';
312
- * const data = await store.request(updateRecord(person));
313
- * ```
314
- *
315
- * **Supplying Options to Modify the Request Behavior**
316
- *
317
- * The following options are supported:
318
- *
319
- * - `patch` - Allows caller to specify whether to use a PATCH request instead of a PUT request, defaults to `false`.
320
- * - `host` - The host to use for the request, defaults to the `host` configured with `setBuildURLConfig`.
321
- * - `namespace` - The namespace to use for the request, defaults to the `namespace` configured with `setBuildURLConfig`.
322
- * - `resourcePath` - The resource path to use for the request, defaults to pluralizing the supplied type
323
- * - `reload` - Whether to forcibly reload the request if it is already in the store, not supplying this
324
- * option will delegate to the store's CachePolicy, defaulting to `false` if none is configured.
325
- * - `backgroundReload` - Whether to reload the request if it is already in the store, but to also resolve the
326
- * promise with the cached value, not supplying this option will delegate to the store's CachePolicy,
327
- * defaulting to `false` if none is configured.
328
- * - `urlParamsSetting` - an object containing options for how to serialize the query params (see `buildQueryParams`)
329
- *
330
- * ```ts
331
- * import { updateRecord } from '@warp-drive/utilities/active-record';
332
- *
333
- * const person = store.peekRecord('person', '1');
334
- * person.name = 'Chris';
335
- * const options = updateRecord(person, { patch: true });
336
- * const data = await store.request(options);
337
- * ```
338
- *
339
- * @public
340
- * @param record
341
- * @param options
342
- */
343
-
187
+ * Builds request options to update existing record for resources,
188
+ * configured for the url, method and header expectations of most ActiveRecord APIs.
189
+ *
190
+ * **Basic Usage**
191
+ *
192
+ * ```ts
193
+ * import { updateRecord } from '@warp-drive/utilities/active-record';
194
+ *
195
+ * const person = store.peekRecord('person', '1');
196
+ * person.name = 'Chris';
197
+ * const data = await store.request(updateRecord(person));
198
+ * ```
199
+ *
200
+ * **Supplying Options to Modify the Request Behavior**
201
+ *
202
+ * The following options are supported:
203
+ *
204
+ * - `patch` - Allows caller to specify whether to use a PATCH request instead of a PUT request, defaults to `false`.
205
+ * - `host` - The host to use for the request, defaults to the `host` configured with `setBuildURLConfig`.
206
+ * - `namespace` - The namespace to use for the request, defaults to the `namespace` configured with `setBuildURLConfig`.
207
+ * - `resourcePath` - The resource path to use for the request, defaults to pluralizing the supplied type
208
+ * - `reload` - Whether to forcibly reload the request if it is already in the store, not supplying this
209
+ * option will delegate to the store's CachePolicy, defaulting to `false` if none is configured.
210
+ * - `backgroundReload` - Whether to reload the request if it is already in the store, but to also resolve the
211
+ * promise with the cached value, not supplying this option will delegate to the store's CachePolicy,
212
+ * defaulting to `false` if none is configured.
213
+ * - `urlParamsSetting` - an object containing options for how to serialize the query params (see `buildQueryParams`)
214
+ *
215
+ * ```ts
216
+ * import { updateRecord } from '@warp-drive/utilities/active-record';
217
+ *
218
+ * const person = store.peekRecord('person', '1');
219
+ * person.name = 'Chris';
220
+ * const options = updateRecord(person, { patch: true });
221
+ * const data = await store.request(options);
222
+ * ```
223
+ *
224
+ * @public
225
+ * @param record
226
+ * @param options
227
+ */
344
228
  function updateRecord(record, options = {}) {
345
- const identifier = recordIdentifierFor(record);
346
- const urlOptions = {
347
- identifier: identifier,
348
- op: 'updateRecord',
349
- resourcePath: pluralize(underscore(identifier.type))
350
- };
351
- copyForwardUrlOptions(urlOptions, options);
352
- const url = buildBaseURL(urlOptions);
353
- const headers = new Headers();
354
- headers.append('Accept', 'application/json;charset=utf-8');
355
- return {
356
- url,
357
- method: options.patch ? 'PATCH' : 'PUT',
358
- headers,
359
- op: 'updateRecord',
360
- data: {
361
- record: identifier
362
- },
363
- records: [identifier]
364
- };
229
+ const identifier = recordIdentifierFor(record);
230
+ const urlOptions = {
231
+ identifier,
232
+ op: "updateRecord",
233
+ resourcePath: pluralize(underscore(identifier.type))
234
+ };
235
+ copyForwardUrlOptions(urlOptions, options);
236
+ const url = buildBaseURL(urlOptions);
237
+ const headers = new Headers();
238
+ headers.append("Accept", "application/json;charset=utf-8");
239
+ return {
240
+ url,
241
+ method: options.patch ? "PATCH" : "PUT",
242
+ headers,
243
+ op: "updateRecord",
244
+ data: { record: identifier },
245
+ records: [identifier]
246
+ };
365
247
  }
366
- export { createRecord, deleteRecord, findRecord, query, updateRecord };
248
+
249
+ //#endregion
250
+ export { createRecord, deleteRecord, findRecord, query, updateRecord };
251
+ //# sourceMappingURL=active-record.js.map