@warp-drive/utilities 5.10.0-alpha.10 → 5.10.0-alpha.13

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 (101) hide show
  1. package/README.md +92 -7
  2. package/cjs-dist/string.cjs +19 -0
  3. package/cjs-dist/string.cjs.map +1 -1
  4. package/dist/active-record.d.ts +21 -0
  5. package/dist/active-record.d.ts.map +1 -1
  6. package/dist/active-record.js +13 -1
  7. package/dist/active-record.js.map +1 -1
  8. package/dist/derivations.d.ts +2 -0
  9. package/dist/derivations.d.ts.map +1 -1
  10. package/dist/derivations.js +6 -0
  11. package/dist/derivations.js.map +1 -1
  12. package/dist/handlers.d.ts +15 -0
  13. package/dist/handlers.d.ts.map +1 -1
  14. package/dist/handlers.js +15 -0
  15. package/dist/handlers.js.map +1 -1
  16. package/dist/{index-D6QIwzqm.d.ts → index-Ds06tKwC.d.ts} +39 -1
  17. package/dist/index-Ds06tKwC.d.ts.map +1 -0
  18. package/dist/index.d.ts +1 -1
  19. package/dist/index.js +39 -0
  20. package/dist/index.js.map +1 -1
  21. package/dist/json-api.d.ts +36 -1
  22. package/dist/json-api.d.ts.map +1 -1
  23. package/dist/json-api.js +23 -1
  24. package/dist/json-api.js.map +1 -1
  25. package/dist/rest.d.ts +20 -0
  26. package/dist/rest.d.ts.map +1 -1
  27. package/dist/rest.js +13 -1
  28. package/dist/rest.js.map +1 -1
  29. package/dist/{string-CWmAluxh.js → string-BZACNuLp.js} +20 -1
  30. package/dist/string-BZACNuLp.js.map +1 -0
  31. package/dist/string.d.ts +19 -0
  32. package/dist/string.d.ts.map +1 -1
  33. package/dist/string.js +1 -1
  34. package/dist/unpkg/dev/active-record.js +13 -1
  35. package/dist/unpkg/dev/active-record.js.map +1 -1
  36. package/dist/unpkg/dev/derivations.js +6 -0
  37. package/dist/unpkg/dev/derivations.js.map +1 -1
  38. package/dist/unpkg/dev/handlers.js +15 -0
  39. package/dist/unpkg/dev/handlers.js.map +1 -1
  40. package/dist/unpkg/dev/index.js +39 -0
  41. package/dist/unpkg/dev/index.js.map +1 -1
  42. package/dist/unpkg/dev/json-api.js +23 -1
  43. package/dist/unpkg/dev/json-api.js.map +1 -1
  44. package/dist/unpkg/dev/rest.js +13 -1
  45. package/dist/unpkg/dev/rest.js.map +1 -1
  46. package/dist/unpkg/dev/{string-j4ur-TDs.js → string-I8KHJXV7.js} +20 -1
  47. package/dist/unpkg/dev/string-I8KHJXV7.js.map +1 -0
  48. package/dist/unpkg/dev/string.js +1 -1
  49. package/dist/unpkg/dev-deprecated/active-record.js +13 -1
  50. package/dist/unpkg/dev-deprecated/active-record.js.map +1 -1
  51. package/dist/unpkg/dev-deprecated/derivations.js +6 -0
  52. package/dist/unpkg/dev-deprecated/derivations.js.map +1 -1
  53. package/dist/unpkg/dev-deprecated/handlers.js +15 -0
  54. package/dist/unpkg/dev-deprecated/handlers.js.map +1 -1
  55. package/dist/unpkg/dev-deprecated/index.js +39 -0
  56. package/dist/unpkg/dev-deprecated/index.js.map +1 -1
  57. package/dist/unpkg/dev-deprecated/json-api.js +23 -1
  58. package/dist/unpkg/dev-deprecated/json-api.js.map +1 -1
  59. package/dist/unpkg/dev-deprecated/rest.js +13 -1
  60. package/dist/unpkg/dev-deprecated/rest.js.map +1 -1
  61. package/dist/unpkg/dev-deprecated/{string-j4ur-TDs.js → string-I8KHJXV7.js} +20 -1
  62. package/dist/unpkg/dev-deprecated/string-I8KHJXV7.js.map +1 -0
  63. package/dist/unpkg/dev-deprecated/string.js +1 -1
  64. package/dist/unpkg/prod/active-record.js +13 -1
  65. package/dist/unpkg/prod/active-record.js.map +1 -1
  66. package/dist/unpkg/prod/derivations.js +6 -0
  67. package/dist/unpkg/prod/derivations.js.map +1 -1
  68. package/dist/unpkg/prod/handlers.js +15 -0
  69. package/dist/unpkg/prod/handlers.js.map +1 -1
  70. package/dist/unpkg/prod/index.js +39 -0
  71. package/dist/unpkg/prod/index.js.map +1 -1
  72. package/dist/unpkg/prod/json-api.js +23 -1
  73. package/dist/unpkg/prod/json-api.js.map +1 -1
  74. package/dist/unpkg/prod/rest.js +13 -1
  75. package/dist/unpkg/prod/rest.js.map +1 -1
  76. package/dist/unpkg/prod/string-D8BEYx2W.js +302 -0
  77. package/dist/unpkg/prod/string-D8BEYx2W.js.map +1 -0
  78. package/dist/unpkg/prod/string.js +1 -1
  79. package/dist/unpkg/prod-deprecated/active-record.js +13 -1
  80. package/dist/unpkg/prod-deprecated/active-record.js.map +1 -1
  81. package/dist/unpkg/prod-deprecated/derivations.js +6 -0
  82. package/dist/unpkg/prod-deprecated/derivations.js.map +1 -1
  83. package/dist/unpkg/prod-deprecated/handlers.js +15 -0
  84. package/dist/unpkg/prod-deprecated/handlers.js.map +1 -1
  85. package/dist/unpkg/prod-deprecated/index.js +39 -0
  86. package/dist/unpkg/prod-deprecated/index.js.map +1 -1
  87. package/dist/unpkg/prod-deprecated/json-api.js +23 -1
  88. package/dist/unpkg/prod-deprecated/json-api.js.map +1 -1
  89. package/dist/unpkg/prod-deprecated/rest.js +13 -1
  90. package/dist/unpkg/prod-deprecated/rest.js.map +1 -1
  91. package/dist/unpkg/prod-deprecated/{string-T1ahjLdj.js → string-D8BEYx2W.js} +20 -1
  92. package/dist/unpkg/prod-deprecated/string-D8BEYx2W.js.map +1 -0
  93. package/dist/unpkg/prod-deprecated/string.js +1 -1
  94. package/package.json +6 -6
  95. package/dist/index-D6QIwzqm.d.ts.map +0 -1
  96. package/dist/string-CWmAluxh.js.map +0 -1
  97. package/dist/unpkg/dev/string-j4ur-TDs.js.map +0 -1
  98. package/dist/unpkg/dev-deprecated/string-j4ur-TDs.js.map +0 -1
  99. package/dist/unpkg/prod/string-T1ahjLdj.js +0 -283
  100. package/dist/unpkg/prod/string-T1ahjLdj.js.map +0 -1
  101. package/dist/unpkg/prod-deprecated/string-T1ahjLdj.js.map +0 -1
@@ -0,0 +1,302 @@
1
+ import { t as defaultRules } from "./inflections-DzBsjJqj.js";
2
+ import { LRUCache, STRING_DASHERIZE_CACHE, dasherize } from "@warp-drive/core/utils/string";
3
+
4
+ //#region src/-private/string/transform.ts
5
+ const STRING_CAMELIZE_REGEXP_1 = /(\-|\_|\.|\s)+(.)?/g;
6
+ const STRING_CAMELIZE_REGEXP_2 = /(^|\/)([A-Z])/g;
7
+ const CAMELIZE_CACHE = new LRUCache((key) => key.replace(STRING_CAMELIZE_REGEXP_1, (_match, _separator, chr) => chr ? chr.toUpperCase() : "").replace(STRING_CAMELIZE_REGEXP_2, (match) => match.toLowerCase()));
8
+ const STRING_UNDERSCORE_REGEXP_1 = /([a-z\d])([A-Z]+)/g;
9
+ const STRING_UNDERSCORE_REGEXP_2 = /\-|\s+/g;
10
+ const UNDERSCORE_CACHE = new LRUCache((str) => str.replace(STRING_UNDERSCORE_REGEXP_1, "$1_$2").replace(STRING_UNDERSCORE_REGEXP_2, "_").toLowerCase());
11
+ const STRING_CAPITALIZE_REGEXP = /(^|\/)([a-z\u00C0-\u024F])/g;
12
+ const CAPITALIZE_CACHE = new LRUCache((str) => str.replace(STRING_CAPITALIZE_REGEXP, (match) => match.toUpperCase()));
13
+ /**
14
+ * Replaces underscores, spaces, or camelCase with dashes.
15
+ *
16
+ * ```js
17
+ * import { dasherize } from '@warp-drive/utilities/string';
18
+ *
19
+ * dasherize('innerHTML'); // 'inner-html'
20
+ * dasherize('action_name'); // 'action-name'
21
+ * dasherize('css-class-name'); // 'css-class-name'
22
+ * dasherize('my favorite items'); // 'my-favorite-items'
23
+ * dasherize('privateDocs/ownerInvoice'; // 'private-docs/owner-invoice'
24
+ * ```
25
+ *
26
+ * @summary Converts camelCase, underscored, or spaced strings to dasherized form, such as `innerHTML` to `inner-html`.
27
+ * @public
28
+ * @since 4.13.0
29
+ */
30
+ const dasherize$1 = dasherize;
31
+ /**
32
+ * Returns the lowerCamelCase form of a string.
33
+ *
34
+ * ```js
35
+ * import { camelize } from '@warp-drive/utilities/string';
36
+ *
37
+ * camelize('innerHTML'); // 'innerHTML'
38
+ * camelize('action_name'); // 'actionName'
39
+ * camelize('css-class-name'); // 'cssClassName'
40
+ * camelize('my favorite items'); // 'myFavoriteItems'
41
+ * camelize('My Favorite Items'); // 'myFavoriteItems'
42
+ * camelize('private-docs/owner-invoice'); // 'privateDocs/ownerInvoice'
43
+ * ```
44
+ *
45
+ * @summary Converts dashed, underscored, dotted, or spaced strings to lowerCamelCase, such as `action_name` to
46
+ * `actionName`.
47
+ * @public
48
+ * @since 4.13.0
49
+ */
50
+ function camelize(str) {
51
+ return CAMELIZE_CACHE.get(str);
52
+ }
53
+ /**
54
+ * Returns the lower\_case\_and\_underscored form of a string.
55
+ *
56
+ * ```js
57
+ * import { underscore } from '@warp-drive/utilities/string';
58
+ *
59
+ * underscore('innerHTML'); // 'inner_html'
60
+ * underscore('action_name'); // 'action_name'
61
+ * underscore('css-class-name'); // 'css_class_name'
62
+ * underscore('my favorite items'); // 'my_favorite_items'
63
+ * underscore('privateDocs/ownerInvoice'); // 'private_docs/owner_invoice'
64
+ * ```
65
+ *
66
+ * @summary Converts camelCase, dashed, or spaced strings to lowercase snake_case, such as `innerHTML` to `inner_html`.
67
+ * @public
68
+ * @since 4.13.0
69
+ */
70
+ function underscore(str) {
71
+ return UNDERSCORE_CACHE.get(str);
72
+ }
73
+ /**
74
+ * Returns the Capitalized form of a string
75
+ *
76
+ * ```js
77
+ * import { capitalize } from '@warp-drive/utilities/string';
78
+ *
79
+ * capitalize('innerHTML') // 'InnerHTML'
80
+ * capitalize('action_name') // 'Action_name'
81
+ * capitalize('css-class-name') // 'Css-class-name'
82
+ * capitalize('my favorite items') // 'My favorite items'
83
+ * capitalize('privateDocs/ownerInvoice'); // 'PrivateDocs/ownerInvoice'
84
+ * ```
85
+ *
86
+ * @summary Uppercases the first letter of a string, and of each `/`-separated path segment, leaving the rest unchanged.
87
+ * @public
88
+ * @since 4.13.0
89
+ */
90
+ function capitalize(str) {
91
+ return CAPITALIZE_CACHE.get(str);
92
+ }
93
+ /**
94
+ * Sets the maximum size of the LRUCache for all string transformation functions.
95
+ * The default size is 10,000.
96
+ *
97
+ * @summary Sets how many results the `camelize`, `underscore`, `capitalize`, and `dasherize` caches each keep (default
98
+ * 10,000).
99
+ * @public
100
+ * @since 4.13.0
101
+ */
102
+ function setMaxLRUCacheSize(size) {
103
+ CAMELIZE_CACHE.size = size;
104
+ UNDERSCORE_CACHE.size = size;
105
+ CAPITALIZE_CACHE.size = size;
106
+ STRING_DASHERIZE_CACHE.size = size;
107
+ }
108
+
109
+ //#endregion
110
+ //#region src/-private/string/inflect.ts
111
+ const BLANK_REGEX = /^\s*$/;
112
+ const LAST_WORD_DASHED_REGEX = /([\w/-]+[_/\s-])([a-z\d]+$)/;
113
+ const LAST_WORD_CAMELIZED_REGEX = /([\w/\s-]+)([A-Z][a-z\d]*$)/;
114
+ const CAMELIZED_REGEX = /[A-Z][a-z\d]*$/;
115
+ const SINGULARS = new LRUCache((word) => {
116
+ return _singularize(word);
117
+ });
118
+ const PLURALS = new LRUCache((word) => {
119
+ return _pluralize(word);
120
+ });
121
+ const UNCOUNTABLE = new Set(defaultRules.uncountable);
122
+ const IRREGULAR = /* @__PURE__ */ new Map();
123
+ const INVERSE_IRREGULAR = /* @__PURE__ */ new Map();
124
+ const SINGULAR_RULES = new Map(defaultRules.singular.reverse());
125
+ const PLURAL_RULES = new Map(defaultRules.plurals.reverse());
126
+ /**
127
+ * Marks a word as uncountable. Uncountable words are not pluralized
128
+ * or singularized.
129
+ *
130
+ * @summary Registers a word that `pluralize` and `singularize` should always return unchanged.
131
+ * @public
132
+ * @since 4.13.0
133
+ */
134
+ function uncountable(word) {
135
+ UNCOUNTABLE.add(word.toLowerCase());
136
+ }
137
+ /**
138
+ * Marks a list of words as uncountable. Uncountable words are not pluralized
139
+ * or singularized.
140
+ *
141
+ * @summary Registers a list of words that `pluralize` and `singularize` should always return unchanged.
142
+ * @public
143
+ * @since 4.13.0
144
+ */
145
+ function loadUncountable(uncountables) {
146
+ uncountables.forEach((word) => {
147
+ uncountable(word);
148
+ });
149
+ }
150
+ /**
151
+ * Marks a word as irregular. Irregular words have unique
152
+ * pluralization and singularization rules.
153
+ *
154
+ * @summary Registers a singular and plural word pair that `pluralize` and `singularize` map directly instead of
155
+ * applying rules.
156
+ * @public
157
+ * @since 4.13.0
158
+ */
159
+ function irregular(single, plur) {
160
+ IRREGULAR.set(single.toLowerCase(), plur);
161
+ IRREGULAR.set(plur.toLowerCase(), plur);
162
+ INVERSE_IRREGULAR.set(plur.toLowerCase(), single);
163
+ INVERSE_IRREGULAR.set(single.toLowerCase(), single);
164
+ }
165
+ /**
166
+ * Marks a list of word pairs as irregular. Irregular words have unique
167
+ * pluralization and singularization rules.
168
+ *
169
+ * @summary Registers a list of singular and plural word pairs that `pluralize` and `singularize` map directly.
170
+ * @public
171
+ * @since 4.13.0
172
+ */
173
+ function loadIrregular(irregularPairs) {
174
+ irregularPairs.forEach((pair) => {
175
+ IRREGULAR.set(pair[0].toLowerCase(), pair[1]);
176
+ IRREGULAR.set(pair[1].toLowerCase(), pair[1]);
177
+ INVERSE_IRREGULAR.set(pair[1].toLowerCase(), pair[0]);
178
+ INVERSE_IRREGULAR.set(pair[0].toLowerCase(), pair[0]);
179
+ });
180
+ }
181
+ loadIrregular(defaultRules.irregularPairs);
182
+ /**
183
+ * Clears the caches for singularize and pluralize.
184
+ *
185
+ * @summary Empties the cached results of `singularize` and `pluralize` while keeping all inflection rules.
186
+ * @public
187
+ * @since 4.13.0
188
+ */
189
+ function clear() {
190
+ SINGULARS.clear();
191
+ PLURALS.clear();
192
+ }
193
+ /**
194
+ * Resets the inflection rules to the defaults.
195
+ *
196
+ * @summary Discards all custom inflection rules and caches, then restores the built-in default rules.
197
+ * @public
198
+ * @since 4.13.0
199
+ */
200
+ function resetToDefaults() {
201
+ clearRules();
202
+ defaultRules.uncountable.forEach((v) => UNCOUNTABLE.add(v));
203
+ defaultRules.singular.forEach((v) => SINGULAR_RULES.set(v[0], v[1]));
204
+ defaultRules.plurals.forEach((v) => PLURAL_RULES.set(v[0], v[1]));
205
+ loadIrregular(defaultRules.irregularPairs);
206
+ }
207
+ /**
208
+ * Clears all inflection rules
209
+ * and resets the caches for singularize and pluralize.
210
+ *
211
+ * @summary Removes every inflection rule, including the defaults, and empties the `singularize` and `pluralize` caches.
212
+ * @public
213
+ * @since 4.13.0
214
+ */
215
+ function clearRules() {
216
+ SINGULARS.clear();
217
+ PLURALS.clear();
218
+ UNCOUNTABLE.clear();
219
+ IRREGULAR.clear();
220
+ INVERSE_IRREGULAR.clear();
221
+ SINGULAR_RULES.clear();
222
+ PLURAL_RULES.clear();
223
+ }
224
+ /**
225
+ * Singularizes a word.
226
+ *
227
+ * @summary Returns the singular form of an English word using the registered inflection rules, with cached results.
228
+ * @public
229
+ * @since 4.13.0
230
+ */
231
+ function singularize(word) {
232
+ if (!word) return "";
233
+ return SINGULARS.get(word);
234
+ }
235
+ /**
236
+ * Pluralizes a word.
237
+ *
238
+ * @summary Returns the plural form of an English word using the registered inflection rules, with cached results.
239
+ * @public
240
+ * @since 4.13.0
241
+ */
242
+ function pluralize(word) {
243
+ if (!word) return "";
244
+ return PLURALS.get(word);
245
+ }
246
+ function unshiftMap(v, map) {
247
+ const rules = [v, ...map.entries()];
248
+ map.clear();
249
+ rules.forEach((rule) => {
250
+ map.set(rule[0], rule[1]);
251
+ });
252
+ }
253
+ /**
254
+ * Adds a pluralization rule.
255
+ *
256
+ * @summary Adds a regex and replacement rule that `pluralize` checks before all existing plural rules.
257
+ * @public
258
+ * @since 4.13.0
259
+ */
260
+ function plural(regex, string) {
261
+ if (PLURAL_RULES.has(regex)) PLURAL_RULES.delete(regex);
262
+ unshiftMap([regex, string], PLURAL_RULES);
263
+ }
264
+ /**
265
+ * Adds a singularization rule.
266
+ *
267
+ * @summary Adds a regex and replacement rule that `singularize` checks before all existing singular rules.
268
+ * @public
269
+ * @since 4.13.0
270
+ */
271
+ function singular(regex, string) {
272
+ if (SINGULAR_RULES.has(regex)) SINGULAR_RULES.delete(regex);
273
+ unshiftMap([regex, string], SINGULAR_RULES);
274
+ }
275
+ function _pluralize(word) {
276
+ return inflect(word, PLURAL_RULES, IRREGULAR);
277
+ }
278
+ function _singularize(word) {
279
+ return inflect(word, SINGULAR_RULES, INVERSE_IRREGULAR);
280
+ }
281
+ function inflect(word, typeRules, irregulars) {
282
+ if (!word || BLANK_REGEX.test(word)) return word;
283
+ const lowercase = word.toLowerCase();
284
+ if (UNCOUNTABLE.has(lowercase)) return word;
285
+ const wordSplit = LAST_WORD_DASHED_REGEX.exec(word) || LAST_WORD_CAMELIZED_REGEX.exec(word);
286
+ const lastWord = wordSplit ? wordSplit[2].toLowerCase() : null;
287
+ if (lastWord && UNCOUNTABLE.has(lastWord)) return word;
288
+ const isCamelized = CAMELIZED_REGEX.test(word);
289
+ for (let [rule, substitution] of irregulars) if (lowercase.match(rule + "$")) {
290
+ if (isCamelized && lastWord && irregulars.has(lastWord)) {
291
+ substitution = capitalize(substitution);
292
+ rule = capitalize(rule);
293
+ }
294
+ return word.replace(new RegExp(rule, "i"), substitution);
295
+ }
296
+ for (const [rule, substitution] of typeRules) if (rule.test(word)) return word.replace(rule, substitution);
297
+ return word;
298
+ }
299
+
300
+ //#endregion
301
+ export { loadUncountable as a, resetToDefaults as c, uncountable as d, camelize as f, underscore as g, setMaxLRUCacheSize as h, loadIrregular as i, singular as l, dasherize$1 as m, clearRules as n, plural as o, capitalize as p, irregular as r, pluralize as s, clear as t, singularize as u };
302
+ //# sourceMappingURL=string-D8BEYx2W.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"string-D8BEYx2W.js","names":["dasherize","internalDasherize","LRUCache","defaultRules","capitalize","BLANK_REGEX","LAST_WORD_DASHED_REGEX","LAST_WORD_CAMELIZED_REGEX","CAMELIZED_REGEX","SINGULARS","word","_singularize","PLURALS","_pluralize","UNCOUNTABLE","Set","uncountable","IRREGULAR","Map","INVERSE_IRREGULAR","SINGULAR_RULES","singular","reverse","PLURAL_RULES","plurals","add","toLowerCase","loadUncountable","uncountables","forEach","irregular","single","plur","set","loadIrregular","irregularPairs","pair","clear","resetToDefaults","clearRules","v","singularize","get","pluralize","unshiftMap","map","rules","entries","rule","plural","regex","string","has","delete","inflect","typeRules","irregulars","isBlank","test","lowercase","wordSplit","exec","lastWord","isCamelized","substitution","match","replace","RegExp"],"sources":["../../../src/-private/string/transform.ts","../../../src/-private/string/inflect.ts"],"sourcesContent":["import { dasherize as internalDasherize, LRUCache, STRING_DASHERIZE_CACHE } from '@warp-drive/core/utils/string';\n\n// oxlint-disable-next-line no-useless-escape\nconst STRING_CAMELIZE_REGEXP_1 = /(\\-|\\_|\\.|\\s)+(.)?/g;\nconst STRING_CAMELIZE_REGEXP_2 = /(^|\\/)([A-Z])/g;\nconst CAMELIZE_CACHE = new LRUCache<string, string>((key: string) =>\n key\n .replace(STRING_CAMELIZE_REGEXP_1, (_match, _separator, chr: string | null) => (chr ? chr.toUpperCase() : ''))\n .replace(STRING_CAMELIZE_REGEXP_2, (match /*, separator, chr */) => match.toLowerCase())\n);\n\nconst STRING_UNDERSCORE_REGEXP_1 = /([a-z\\d])([A-Z]+)/g;\n// oxlint-disable-next-line no-useless-escape\nconst STRING_UNDERSCORE_REGEXP_2 = /\\-|\\s+/g;\nconst UNDERSCORE_CACHE = new LRUCache<string, string>((str: string) =>\n str.replace(STRING_UNDERSCORE_REGEXP_1, '$1_$2').replace(STRING_UNDERSCORE_REGEXP_2, '_').toLowerCase()\n);\n\nconst STRING_CAPITALIZE_REGEXP = /(^|\\/)([a-z\\u00C0-\\u024F])/g;\nconst CAPITALIZE_CACHE = new LRUCache<string, string>((str: string) =>\n str.replace(STRING_CAPITALIZE_REGEXP, (match /*, separator, chr */) => match.toUpperCase())\n);\n\n/**\n * Replaces underscores, spaces, or camelCase with dashes.\n *\n * ```js\n * import { dasherize } from '@warp-drive/utilities/string';\n *\n * dasherize('innerHTML'); // 'inner-html'\n * dasherize('action_name'); // 'action-name'\n * dasherize('css-class-name'); // 'css-class-name'\n * dasherize('my favorite items'); // 'my-favorite-items'\n * dasherize('privateDocs/ownerInvoice'; // 'private-docs/owner-invoice'\n * ```\n *\n * @summary Converts camelCase, underscored, or spaced strings to dasherized form, such as `innerHTML` to `inner-html`.\n * @public\n * @since 4.13.0\n */\nexport const dasherize: (str: string) => string = internalDasherize;\n\n/**\n * Returns the lowerCamelCase form of a string.\n *\n * ```js\n * import { camelize } from '@warp-drive/utilities/string';\n *\n * camelize('innerHTML'); // 'innerHTML'\n * camelize('action_name'); // 'actionName'\n * camelize('css-class-name'); // 'cssClassName'\n * camelize('my favorite items'); // 'myFavoriteItems'\n * camelize('My Favorite Items'); // 'myFavoriteItems'\n * camelize('private-docs/owner-invoice'); // 'privateDocs/ownerInvoice'\n * ```\n *\n * @summary Converts dashed, underscored, dotted, or spaced strings to lowerCamelCase, such as `action_name` to\n * `actionName`.\n * @public\n * @since 4.13.0\n */\nexport function camelize(str: string): string {\n return CAMELIZE_CACHE.get(str);\n}\n\n/**\n * Returns the lower\\_case\\_and\\_underscored form of a string.\n *\n * ```js\n * import { underscore } from '@warp-drive/utilities/string';\n *\n * underscore('innerHTML'); // 'inner_html'\n * underscore('action_name'); // 'action_name'\n * underscore('css-class-name'); // 'css_class_name'\n * underscore('my favorite items'); // 'my_favorite_items'\n * underscore('privateDocs/ownerInvoice'); // 'private_docs/owner_invoice'\n * ```\n *\n * @summary Converts camelCase, dashed, or spaced strings to lowercase snake_case, such as `innerHTML` to `inner_html`.\n * @public\n * @since 4.13.0\n */\nexport function underscore(str: string): string {\n return UNDERSCORE_CACHE.get(str);\n}\n\n/**\n * Returns the Capitalized form of a string\n *\n * ```js\n * import { capitalize } from '@warp-drive/utilities/string';\n *\n * capitalize('innerHTML') // 'InnerHTML'\n * capitalize('action_name') // 'Action_name'\n * capitalize('css-class-name') // 'Css-class-name'\n * capitalize('my favorite items') // 'My favorite items'\n * capitalize('privateDocs/ownerInvoice'); // 'PrivateDocs/ownerInvoice'\n * ```\n *\n * @summary Uppercases the first letter of a string, and of each `/`-separated path segment, leaving the rest unchanged.\n * @public\n * @since 4.13.0\n */\nexport function capitalize(str: string): string {\n return CAPITALIZE_CACHE.get(str);\n}\n\n/**\n * Sets the maximum size of the LRUCache for all string transformation functions.\n * The default size is 10,000.\n *\n * @summary Sets how many results the `camelize`, `underscore`, `capitalize`, and `dasherize` caches each keep (default\n * 10,000).\n * @public\n * @since 4.13.0\n */\nexport function setMaxLRUCacheSize(size: number): void {\n CAMELIZE_CACHE.size = size;\n UNDERSCORE_CACHE.size = size;\n CAPITALIZE_CACHE.size = size;\n STRING_DASHERIZE_CACHE.size = size;\n}\n","import { assert } from '@warp-drive/core/build-config/macros';\nimport { LRUCache } from '@warp-drive/core/utils/string';\n\nimport { defaultRules } from './inflections.ts';\nimport { capitalize } from './transform.ts';\n\nconst BLANK_REGEX = /^\\s*$/;\nconst LAST_WORD_DASHED_REGEX = /([\\w/-]+[_/\\s-])([a-z\\d]+$)/;\nconst LAST_WORD_CAMELIZED_REGEX = /([\\w/\\s-]+)([A-Z][a-z\\d]*$)/;\nconst CAMELIZED_REGEX = /[A-Z][a-z\\d]*$/;\n\nconst SINGULARS = new LRUCache<string, string>((word: string) => {\n return _singularize(word);\n});\nconst PLURALS = new LRUCache<string, string>((word: string) => {\n return _pluralize(word);\n});\nconst UNCOUNTABLE = new Set(defaultRules.uncountable);\nconst IRREGULAR: Map<string, string> = new Map();\nconst INVERSE_IRREGULAR: Map<string, string> = new Map();\nconst SINGULAR_RULES = new Map(defaultRules.singular.reverse());\nconst PLURAL_RULES = new Map(defaultRules.plurals.reverse());\n\n/**\n * Marks a word as uncountable. Uncountable words are not pluralized\n * or singularized.\n *\n * @summary Registers a word that `pluralize` and `singularize` should always return unchanged.\n * @public\n * @since 4.13.0\n */\nexport function uncountable(word: string): void {\n UNCOUNTABLE.add(word.toLowerCase());\n}\n\n/**\n * Marks a list of words as uncountable. Uncountable words are not pluralized\n * or singularized.\n *\n * @summary Registers a list of words that `pluralize` and `singularize` should always return unchanged.\n * @public\n * @since 4.13.0\n */\nexport function loadUncountable(uncountables: string[]): void {\n uncountables.forEach((word) => {\n uncountable(word);\n });\n}\n\n/**\n * Marks a word as irregular. Irregular words have unique\n * pluralization and singularization rules.\n *\n * @summary Registers a singular and plural word pair that `pluralize` and `singularize` map directly instead of\n * applying rules.\n * @public\n * @since 4.13.0\n */\nexport function irregular(single: string, plur: string): void {\n //pluralizing\n IRREGULAR.set(single.toLowerCase(), plur);\n IRREGULAR.set(plur.toLowerCase(), plur);\n\n //singularizing\n INVERSE_IRREGULAR.set(plur.toLowerCase(), single);\n INVERSE_IRREGULAR.set(single.toLowerCase(), single);\n}\n\n/**\n * Marks a list of word pairs as irregular. Irregular words have unique\n * pluralization and singularization rules.\n *\n * @summary Registers a list of singular and plural word pairs that `pluralize` and `singularize` map directly.\n * @public\n * @since 4.13.0\n */\nexport function loadIrregular(irregularPairs: Array<[string, string]>): void {\n irregularPairs.forEach((pair) => {\n //pluralizing\n IRREGULAR.set(pair[0].toLowerCase(), pair[1]);\n IRREGULAR.set(pair[1].toLowerCase(), pair[1]);\n\n //singularizing\n INVERSE_IRREGULAR.set(pair[1].toLowerCase(), pair[0]);\n INVERSE_IRREGULAR.set(pair[0].toLowerCase(), pair[0]);\n });\n}\nloadIrregular(defaultRules.irregularPairs);\n\n/**\n * Clears the caches for singularize and pluralize.\n *\n * @summary Empties the cached results of `singularize` and `pluralize` while keeping all inflection rules.\n * @public\n * @since 4.13.0\n */\nexport function clear(): void {\n SINGULARS.clear();\n PLURALS.clear();\n}\n\n/**\n * Resets the inflection rules to the defaults.\n *\n * @summary Discards all custom inflection rules and caches, then restores the built-in default rules.\n * @public\n * @since 4.13.0\n */\nexport function resetToDefaults(): void {\n clearRules();\n defaultRules.uncountable.forEach((v) => UNCOUNTABLE.add(v));\n defaultRules.singular.forEach((v) => SINGULAR_RULES.set(v[0], v[1]));\n defaultRules.plurals.forEach((v) => PLURAL_RULES.set(v[0], v[1]));\n loadIrregular(defaultRules.irregularPairs);\n}\n\n/**\n * Clears all inflection rules\n * and resets the caches for singularize and pluralize.\n *\n * @summary Removes every inflection rule, including the defaults, and empties the `singularize` and `pluralize` caches.\n * @public\n * @since 4.13.0\n */\nexport function clearRules(): void {\n SINGULARS.clear();\n PLURALS.clear();\n UNCOUNTABLE.clear();\n IRREGULAR.clear();\n INVERSE_IRREGULAR.clear();\n SINGULAR_RULES.clear();\n PLURAL_RULES.clear();\n}\n\n/**\n * Singularizes a word.\n *\n * @summary Returns the singular form of an English word using the registered inflection rules, with cached results.\n * @public\n * @since 4.13.0\n */\nexport function singularize(word: string): string {\n assert(`singularize expects to receive a non-empty string`, typeof word === 'string' && word.length > 0);\n if (!word) return '';\n return SINGULARS.get(word);\n}\n\n/**\n * Pluralizes a word.\n *\n * @summary Returns the plural form of an English word using the registered inflection rules, with cached results.\n * @public\n * @since 4.13.0\n */\nexport function pluralize(word: string): string {\n assert(`pluralize expects to receive a non-empty string`, typeof word === 'string' && word.length > 0);\n if (!word) return '';\n return PLURALS.get(word);\n}\n\nfunction unshiftMap<K, V>(v: [K, V], map: Map<K, V>) {\n // reorder\n const rules = [v, ...map.entries()];\n map.clear();\n rules.forEach((rule) => {\n map.set(rule[0], rule[1]);\n });\n}\n\n/**\n * Adds a pluralization rule.\n *\n * @summary Adds a regex and replacement rule that `pluralize` checks before all existing plural rules.\n * @public\n * @since 4.13.0\n */\nexport function plural(regex: RegExp, string: string): void {\n // rule requires reordering if exists, so remove it first\n if (PLURAL_RULES.has(regex)) {\n PLURAL_RULES.delete(regex);\n }\n\n // reorder\n unshiftMap([regex, string], PLURAL_RULES);\n}\n\n/**\n * Adds a singularization rule.\n *\n * @summary Adds a regex and replacement rule that `singularize` checks before all existing singular rules.\n * @public\n * @since 4.13.0\n */\nexport function singular(regex: RegExp, string: string): void {\n // rule requires reordering if exists, so remove it first\n if (SINGULAR_RULES.has(regex)) {\n SINGULAR_RULES.delete(regex);\n }\n\n // reorder\n unshiftMap([regex, string], SINGULAR_RULES);\n}\n\nfunction _pluralize(word: string) {\n return inflect(word, PLURAL_RULES, IRREGULAR);\n}\n\nfunction _singularize(word: string) {\n return inflect(word, SINGULAR_RULES, INVERSE_IRREGULAR);\n}\n\nfunction inflect(word: string, typeRules: Map<RegExp, string>, irregulars: Map<string, string>) {\n // empty strings\n const isBlank = !word || BLANK_REGEX.test(word);\n if (isBlank) {\n return word;\n }\n\n // basic uncountables\n const lowercase = word.toLowerCase();\n if (UNCOUNTABLE.has(lowercase)) {\n return word;\n }\n\n // adv uncountables\n const wordSplit = LAST_WORD_DASHED_REGEX.exec(word) || LAST_WORD_CAMELIZED_REGEX.exec(word);\n const lastWord = wordSplit ? wordSplit[2].toLowerCase() : null;\n if (lastWord && UNCOUNTABLE.has(lastWord)) {\n return word;\n }\n\n // handle irregulars\n const isCamelized = CAMELIZED_REGEX.test(word);\n for (let [rule, substitution] of irregulars) {\n if (lowercase.match(rule + '$')) {\n if (isCamelized && lastWord && irregulars.has(lastWord)) {\n substitution = capitalize(substitution);\n rule = capitalize(rule);\n }\n\n return word.replace(new RegExp(rule, 'i'), substitution);\n }\n }\n\n // do the actual inflection\n for (const [rule, substitution] of typeRules) {\n if (rule.test(word)) {\n return word.replace(rule, substitution);\n }\n }\n\n return word;\n}\n"],"mappings":";;;;AAGA,MAAM,2BAA2B;AACjC,MAAM,2BAA2B;AACjC,MAAM,iBAAiB,IAAI,UAA0B,QACnD,IACG,QAAQ,2BAA2B,QAAQ,YAAY,QAAwB,MAAM,IAAI,YAAY,IAAI,EAAG,CAAC,CAC7G,QAAQ,2BAA2B,UAAgC,MAAM,YAAY,CAAC,CAC3F;AAEA,MAAM,6BAA6B;AAEnC,MAAM,6BAA6B;AACnC,MAAM,mBAAmB,IAAI,UAA0B,QACrD,IAAI,QAAQ,4BAA4B,OAAO,CAAC,CAAC,QAAQ,4BAA4B,GAAG,CAAC,CAAC,YAAY,CACxG;AAEA,MAAM,2BAA2B;AACjC,MAAM,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ClC,YAAY,IAAI;CAC1D,IAAIoC,YAAYhD,YAAYsC,IAAIU,QAAQ,GACtC,OAAOpD;CAIT,MAAMqD,cAAcvD,gBAAgBkD,KAAKhD,IAAI;CAC7C,KAAK,IAAI,CAACsC,MAAMgB,iBAAiBR,YAC/B,IAAIG,UAAUM,MAAMjB,OAAO,GAAG,GAAG;EAC/B,IAAIe,eAAeD,YAAYN,WAAWJ,IAAIU,QAAQ,GAAG;GACvDE,eAAe5D,WAAW4D,YAAY;GACtChB,OAAO5C,WAAW4C,IAAI;EACxB;EAEA,OAAOtC,KAAKwD,QAAQ,IAAIC,OAAOnB,MAAM,GAAG,GAAGgB,YAAY;CACzD;CAIF,KAAK,MAAM,CAAChB,MAAMgB,iBAAiBT,WACjC,IAAIP,KAAKU,KAAKhD,IAAI,GAChB,OAAOA,KAAKwD,QAAQlB,MAAMgB,YAAY;CAI1C,OAAOtD;AACT"}
@@ -1,3 +1,3 @@
1
- import { a as loadUncountable, c as resetToDefaults, d as uncountable, f as camelize, g as underscore, h as setMaxLRUCacheSize, i as loadIrregular, l as singular, m as dasherize, n as clearRules, o as plural, p as capitalize, r as irregular, s as pluralize, t as clear, u as singularize } from "./string-T1ahjLdj.js";
1
+ import { a as loadUncountable, c as resetToDefaults, d as uncountable, f as camelize, g as underscore, h as setMaxLRUCacheSize, i as loadIrregular, l as singular, m as dasherize, n as clearRules, o as plural, p as capitalize, r as irregular, s as pluralize, t as clear, u as singularize } from "./string-D8BEYx2W.js";
2
2
 
3
3
  export { camelize, capitalize, clear, clearRules, dasherize, irregular, loadIrregular, loadUncountable, plural, pluralize, resetToDefaults, setMaxLRUCacheSize, singular, singularize, uncountable, underscore };
@@ -1,5 +1,5 @@
1
1
  import { buildBaseURL, buildQueryParams } from "./index.js";
2
- import { g as underscore, s as pluralize } from "./string-T1ahjLdj.js";
2
+ import { g as underscore, s as pluralize } from "./string-D8BEYx2W.js";
3
3
  import { n as extractCacheOptions, t as copyForwardUrlOptions } from "./builder-utils-BkXwUT0x.js";
4
4
  import { recordIdentifierFor } from "@warp-drive/core";
5
5
 
@@ -59,6 +59,9 @@ function query(type, query = {}, options = {}) {
59
59
  * Builds request options to delete record for resources,
60
60
  * configured for the url, method and header expectations of ActiveRecord APIs.
61
61
  *
62
+ * See the [Builders](/guides/the-manual/requests/builders) guide for what request builders do and
63
+ * when to use one.
64
+ *
62
65
  * **Basic Usage**
63
66
  *
64
67
  * ```ts
@@ -100,6 +103,7 @@ function query(type, query = {}, options = {}) {
100
103
  * const data = await store.request(options);
101
104
  * ```
102
105
  *
106
+ * @summary Builds a `DELETE` request that persists deletion of an existing record, using ActiveRecord-style URLs.
103
107
  * @public
104
108
  * @param record
105
109
  * @param options
@@ -128,6 +132,9 @@ function deleteRecord(record, options = {}) {
128
132
  * Builds request options to create new record for resources,
129
133
  * configured for the url, method and header expectations of most ActiveRecord APIs.
130
134
  *
135
+ * See the [Builders](/guides/the-manual/requests/builders) guide for what request builders do and
136
+ * when to use one.
137
+ *
131
138
  * **Basic Usage**
132
139
  *
133
140
  * ```ts
@@ -159,6 +166,7 @@ function deleteRecord(record, options = {}) {
159
166
  * const data = await store.request(options);
160
167
  * ```
161
168
  *
169
+ * @summary Builds a `POST` request that saves a newly created record, using ActiveRecord-style URLs.
162
170
  * @public
163
171
  * @param record
164
172
  * @param options
@@ -187,6 +195,9 @@ function createRecord(record, options = {}) {
187
195
  * Builds request options to update existing record for resources,
188
196
  * configured for the url, method and header expectations of most ActiveRecord APIs.
189
197
  *
198
+ * See the [Builders](/guides/the-manual/requests/builders) guide for what request builders do and
199
+ * when to use one.
200
+ *
190
201
  * **Basic Usage**
191
202
  *
192
203
  * ```ts
@@ -221,6 +232,7 @@ function createRecord(record, options = {}) {
221
232
  * const data = await store.request(options);
222
233
  * ```
223
234
  *
235
+ * @summary Builds a `PUT` (or `PATCH`) request that saves changes to an existing record, using ActiveRecord-style URLs.
224
236
  * @public
225
237
  * @param record
226
238
  * @param options
@@ -1 +1 @@
1
- {"version":3,"file":"active-record.js","names":["recordIdentifierFor","buildBaseURL","pluralize","underscore","copyForwardUrlOptions","isExisting","identifier","id","type","deleteRecord","record","options","urlOptions","op","resourcePath","url","headers","Headers","append","method","data","records","createRecord","updateRecord","patch"],"sources":["../../../src/-private/active-record/find-record.ts","../../../src/-private/active-record/query.ts","../../../src/-private/active-record/save-record.ts"],"sourcesContent":["import type { ReactiveDataDocument } from '@warp-drive/core/reactive';\nimport type { TypeFromInstance } from '@warp-drive/core/types/record';\nimport type {\n FindRecordOptions,\n FindRecordRequestOptions,\n RemotelyAccessibleIdentifier,\n} from '@warp-drive/core/types/request';\nimport type { Meta } from '@warp-drive/core/types/spec/json-api-raw';\n\nimport { buildBaseURL, buildQueryParams, type FindRecordUrlOptions } from '../../index.ts';\nimport { pluralize, underscore } from '../../string.ts';\nimport { copyForwardUrlOptions, extractCacheOptions } from '../builder-utils.ts';\n\n/**\n * Builds request options to fetch a single resource by a known id or identifier\n * configured for the url and header expectations of most ActiveRecord APIs.\n *\n * **Basic Usage**\n *\n * ```ts\n * import { findRecord } from '@warp-drive/utilities/active-record';\n *\n * const data = await store.request(findRecord('person', '1'));\n * ```\n *\n * **With Options**\n *\n * ```ts\n * import { findRecord } from '@warp-drive/utilities/active-record';\n *\n * const options = findRecord('person', '1', { include: ['pets', 'friends'] });\n * const data = await store.request(options);\n * ```\n *\n * **With an Identifier**\n *\n * ```ts\n * import { findRecord } from '@warp-drive/utilities/active-record';\n *\n * const options = findRecord({ type: 'person', id: '1' }, { include: ['pets', 'friends'] });\n * const data = await store.request(options);\n * ```\n *\n * **Supplying Options to Modify the Request Behavior**\n *\n * The following options are supported:\n *\n * - `host` - The host to use for the request, defaults to the `host` configured with `setBuildURLConfig`.\n * - `namespace` - The namespace to use for the request, defaults to the `namespace` configured with `setBuildURLConfig`.\n * - `resourcePath` - The resource path to use for the request, defaults to pluralizing and underscoring the supplied type\n * - `reload` - Whether to forcibly reload the request if it is already in the store, not supplying this\n * option will delegate to the store's CachePolicy, defaulting to `false` if none is configured.\n * - `backgroundReload` - Whether to reload the request if it is already in the store, but to also resolve the\n * promise with the cached value, not supplying this option will delegate to the store's CachePolicy,\n * defaulting to `false` if none is configured.\n * - `urlParamsSetting` - an object containing options for how to serialize the query params (see `buildQueryParams`)\n *\n * ```ts\n * import { findRecord } from '@warp-drive/utilities/active-record';\n *\n * const options = findRecord('person', '1', { include: ['pets', 'friends'] }, { namespace: 'api/v2' });\n * const data = await store.request(options);\n * ```\n *\n * @public\n * @param identifier\n * @param options\n */\nexport function findRecord<T, M extends Meta | undefined = Meta | undefined, E extends object = object>(\n identifier: RemotelyAccessibleIdentifier<TypeFromInstance<T>>,\n options?: FindRecordOptions\n): FindRecordRequestOptions<ReactiveDataDocument<T, M, E>, T>;\nexport function findRecord(\n identifier: RemotelyAccessibleIdentifier,\n options?: FindRecordOptions\n): FindRecordRequestOptions;\nexport function findRecord<T, M extends Meta | undefined = Meta | undefined, E extends object = object>(\n type: TypeFromInstance<T>,\n id: string,\n options?: FindRecordOptions\n): FindRecordRequestOptions<ReactiveDataDocument<T, M, E>, T>;\nexport function findRecord(type: string, id: string, options?: FindRecordOptions): FindRecordRequestOptions;\nexport function findRecord(\n arg1: string | RemotelyAccessibleIdentifier,\n arg2: string | FindRecordOptions | undefined,\n arg3?: FindRecordOptions\n): FindRecordRequestOptions {\n const identifier: RemotelyAccessibleIdentifier = typeof arg1 === 'string' ? { type: arg1, id: arg2 as string } : arg1;\n const options = ((typeof arg1 === 'string' ? arg3 : arg2) || {}) as FindRecordOptions;\n const cacheOptions = extractCacheOptions(options);\n const urlOptions: FindRecordUrlOptions = {\n identifier,\n op: 'findRecord',\n resourcePath: pluralize(underscore(identifier.type)),\n };\n\n copyForwardUrlOptions(urlOptions, options);\n\n const url = buildBaseURL(urlOptions);\n const headers = new Headers();\n headers.append('Accept', 'application/json;charset=utf-8');\n\n return {\n url: options.include?.length\n ? `${url}?${buildQueryParams({ include: options.include }, options.urlParamsSettings)}`\n : url,\n method: 'GET',\n headers,\n cacheOptions,\n op: 'findRecord',\n records: [identifier],\n };\n}\n\n/** @deprecated use {@link ReactiveDataDocument} instead */\nexport type FindRecordResultDocument<\n T,\n M extends Meta | undefined = Meta | undefined,\n E extends object = object,\n> = ReactiveDataDocument<T, M, E>;\n","import type { ReactiveDataDocument } from '@warp-drive/core/reactive';\nimport type { QueryParamsSource } from '@warp-drive/core/types/params';\nimport type { TypeFromInstance } from '@warp-drive/core/types/record';\nimport type { ConstrainedRequestOptions, QueryRequestOptions } from '@warp-drive/core/types/request';\nimport type { Meta } from '@warp-drive/core/types/spec/json-api-raw';\n\nimport { buildBaseURL, buildQueryParams, type QueryUrlOptions } from '../../index.ts';\nimport { pluralize, underscore } from '../../string';\nimport { copyForwardUrlOptions, extractCacheOptions } from '../builder-utils.ts';\n\n/**\n * Builds request options to query for resources, usually by a primary\n * type, configured for the url and header expectations of most ActiveRecord APIs.\n *\n * **Basic Usage**\n *\n * ```ts\n * import { query } from '@warp-drive/utilities/active-record';\n *\n * const data = await store.request(query('person'));\n * ```\n *\n * **With Query Params**\n *\n * ```ts\n * import { query } from '@warp-drive/utilities/active-record';\n *\n * const options = query('person', { include: ['pets', 'friends'] });\n * const data = await store.request(options);\n * ```\n *\n * **Supplying Options to Modify the Request Behavior**\n *\n * The following options are supported:\n *\n * - `host` - The host to use for the request, defaults to the `host` configured with `setBuildURLConfig`.\n * - `namespace` - The namespace to use for the request, defaults to the `namespace` configured with `setBuildURLConfig`.\n * - `resourcePath` - The resource path to use for the request, defaults to pluralizing and underscoring the supplied type\n * - `reload` - Whether to forcibly reload the request if it is already in the store, not supplying this\n * option will delegate to the store's CachePolicy, defaulting to `false` if none is configured.\n * - `backgroundReload` - Whether to reload the request if it is already in the store, but to also resolve the\n * promise with the cached value, not supplying this option will delegate to the store's CachePolicy,\n * defaulting to `false` if none is configured.\n * - `urlParamsSetting` - an object containing options for how to serialize the query params (see `buildQueryParams`)\n *\n * ```ts\n * import { query } from '@warp-drive/utilities/active-record';\n *\n * const options = query('person', { include: ['pets', 'friends'] }, { reload: true });\n * const data = await store.request(options);\n * ```\n *\n * @public\n * @param identifier\n * @param query\n * @param options\n */\nexport function query<T, M extends Meta | undefined = Meta | undefined, E extends object = object>(\n type: TypeFromInstance<T>,\n query?: QueryParamsSource,\n options?: ConstrainedRequestOptions\n): QueryRequestOptions<ReactiveDataDocument<T[], M, E>>;\nexport function query(\n type: string,\n query?: QueryParamsSource,\n options?: ConstrainedRequestOptions\n): QueryRequestOptions;\nexport function query(\n type: string,\n // oxlint-disable-next-line no-shadow\n query: QueryParamsSource = {},\n options: ConstrainedRequestOptions = {}\n): QueryRequestOptions {\n const cacheOptions = extractCacheOptions(options);\n const urlOptions: QueryUrlOptions = {\n identifier: { type },\n op: 'query',\n resourcePath: pluralize(underscore(type)),\n };\n\n copyForwardUrlOptions(urlOptions, options);\n\n const url = buildBaseURL(urlOptions);\n const headers = new Headers();\n headers.append('Accept', 'application/json;charset=utf-8');\n const queryString = buildQueryParams(query, options.urlParamsSettings);\n\n return {\n url: queryString ? `${url}?${queryString}` : url,\n method: 'GET',\n headers,\n cacheOptions,\n op: 'query',\n };\n}\n","import { recordIdentifierFor } from '@warp-drive/core';\nimport { assert } from '@warp-drive/core/build-config/macros';\nimport type { ReactiveDataDocument } from '@warp-drive/core/reactive';\nimport type { PersistedResourceKey, ResourceKey } from '@warp-drive/core/types/identifier';\nimport type { TypedRecordInstance } from '@warp-drive/core/types/record';\nimport type {\n ConstrainedRequestOptions,\n CreateRequestOptions,\n DeleteRequestOptions,\n UpdateRequestOptions,\n} from '@warp-drive/core/types/request';\nimport type { Meta } from '@warp-drive/core/types/spec/json-api-raw';\n\nimport {\n buildBaseURL,\n type CreateRecordUrlOptions,\n type DeleteRecordUrlOptions,\n type UpdateRecordUrlOptions,\n} from '../../index.ts';\nimport { pluralize, underscore } from '../../string';\nimport { copyForwardUrlOptions } from '../builder-utils.ts';\n\nfunction isExisting(identifier: ResourceKey): identifier is PersistedResourceKey {\n return 'id' in identifier && identifier.id !== null && 'type' in identifier && identifier.type !== null;\n}\n\n/**\n * Builds request options to delete record for resources,\n * configured for the url, method and header expectations of ActiveRecord APIs.\n *\n * **Basic Usage**\n *\n * ```ts\n * import { deleteRecord } from '@warp-drive/utilities/active-record';\n *\n * const person = store.peekRecord('person', '1');\n *\n * // mark record as deleted\n * store.deleteRecord(person);\n *\n * // persist deletion\n * const data = await store.request(deleteRecord(person));\n * ```\n *\n * **Supplying Options to Modify the Request Behavior**\n *\n * The following options are supported:\n *\n * - `host` - The host to use for the request, defaults to the `host` configured with `setBuildURLConfig`.\n * - `namespace` - The namespace to use for the request, defaults to the `namespace` configured with `setBuildURLConfig`.\n * - `resourcePath` - The resource path to use for the request, defaults to pluralizing the supplied type\n * - `reload` - Whether to forcibly reload the request if it is already in the store, not supplying this\n * option will delegate to the store's CachePolicy, defaulting to `false` if none is configured.\n * - `backgroundReload` - Whether to reload the request if it is already in the store, but to also resolve the\n * promise with the cached value, not supplying this option will delegate to the store's CachePolicy,\n * defaulting to `false` if none is configured.\n * - `urlParamsSetting` - an object containing options for how to serialize the query params (see `buildQueryParams`)\n *\n * ```ts\n * import { deleteRecord } from '@warp-drive/utilities/active-record';\n *\n * const person = store.peekRecord('person', '1');\n *\n * // mark record as deleted\n * store.deleteRecord(person);\n *\n * // persist deletion\n * const options = deleteRecord(person, { namespace: 'api/v1' });\n * const data = await store.request(options);\n * ```\n *\n * @public\n * @param record\n * @param options\n */\nexport function deleteRecord<T>(record: T, options?: ConstrainedRequestOptions): DeleteRequestOptions<T>;\nexport function deleteRecord(record: unknown, options?: ConstrainedRequestOptions): DeleteRequestOptions;\nexport function deleteRecord(record: unknown, options: ConstrainedRequestOptions = {}): DeleteRequestOptions {\n const identifier = recordIdentifierFor(record);\n assert(`Expected to be given a record instance`, identifier);\n assert(`Cannot delete a record that does not have an associated type and id.`, isExisting(identifier));\n\n const urlOptions: DeleteRecordUrlOptions = {\n identifier: identifier,\n op: 'deleteRecord',\n resourcePath: pluralize(underscore(identifier.type)),\n };\n\n copyForwardUrlOptions(urlOptions, options);\n\n const url = buildBaseURL(urlOptions);\n const headers = new Headers();\n headers.append('Accept', 'application/json;charset=utf-8');\n\n return {\n url,\n method: 'DELETE',\n headers,\n op: 'deleteRecord',\n data: {\n record: identifier,\n },\n records: [identifier],\n };\n}\n\n/**\n * Builds request options to create new record for resources,\n * configured for the url, method and header expectations of most ActiveRecord APIs.\n *\n * **Basic Usage**\n *\n * ```ts\n * import { createRecord } from '@warp-drive/utilities/active-record';\n *\n * const person = store.createRecord('person', { name: 'Ted' });\n * const data = await store.request(createRecord(person));\n * ```\n *\n * **Supplying Options to Modify the Request Behavior**\n *\n * The following options are supported:\n *\n * - `host` - The host to use for the request, defaults to the `host` configured with `setBuildURLConfig`.\n * - `namespace` - The namespace to use for the request, defaults to the `namespace` configured with `setBuildURLConfig`.\n * - `resourcePath` - The resource path to use for the request, defaults to pluralizing the supplied type\n * - `reload` - Whether to forcibly reload the request if it is already in the store, not supplying this\n * option will delegate to the store's CachePolicy, defaulting to `false` if none is configured.\n * - `backgroundReload` - Whether to reload the request if it is already in the store, but to also resolve the\n * promise with the cached value, not supplying this option will delegate to the store's CachePolicy,\n * defaulting to `false` if none is configured.\n * - `urlParamsSetting` - an object containing options for how to serialize the query params (see `buildQueryParams`)\n *\n * ```ts\n * import { createRecord } from '@warp-drive/utilities/active-record';\n *\n * const person = store.createRecord('person', { name: 'Ted' });\n * const options = createRecord(person, { namespace: 'api/v1' });\n * const data = await store.request(options);\n * ```\n *\n * @public\n * @param record\n * @param options\n */\nexport function createRecord<T>(record: T, options?: ConstrainedRequestOptions): CreateRequestOptions<T>;\nexport function createRecord(record: unknown, options?: ConstrainedRequestOptions): CreateRequestOptions;\nexport function createRecord(record: unknown, options: ConstrainedRequestOptions = {}): CreateRequestOptions {\n const identifier = recordIdentifierFor(record);\n assert(`Expected to be given a record instance`, identifier);\n\n const urlOptions: CreateRecordUrlOptions = {\n identifier: identifier,\n op: 'createRecord',\n resourcePath: pluralize(underscore(identifier.type)),\n };\n\n copyForwardUrlOptions(urlOptions, options);\n\n const url = buildBaseURL(urlOptions);\n const headers = new Headers();\n headers.append('Accept', 'application/json;charset=utf-8');\n\n return {\n url,\n method: 'POST',\n headers,\n op: 'createRecord',\n data: {\n record: identifier,\n },\n records: [identifier],\n };\n}\n\n/**\n * Builds request options to update existing record for resources,\n * configured for the url, method and header expectations of most ActiveRecord APIs.\n *\n * **Basic Usage**\n *\n * ```ts\n * import { updateRecord } from '@warp-drive/utilities/active-record';\n *\n * const person = store.peekRecord('person', '1');\n * person.name = 'Chris';\n * const data = await store.request(updateRecord(person));\n * ```\n *\n * **Supplying Options to Modify the Request Behavior**\n *\n * The following options are supported:\n *\n * - `patch` - Allows caller to specify whether to use a PATCH request instead of a PUT request, defaults to `false`.\n * - `host` - The host to use for the request, defaults to the `host` configured with `setBuildURLConfig`.\n * - `namespace` - The namespace to use for the request, defaults to the `namespace` configured with `setBuildURLConfig`.\n * - `resourcePath` - The resource path to use for the request, defaults to pluralizing the supplied type\n * - `reload` - Whether to forcibly reload the request if it is already in the store, not supplying this\n * option will delegate to the store's CachePolicy, defaulting to `false` if none is configured.\n * - `backgroundReload` - Whether to reload the request if it is already in the store, but to also resolve the\n * promise with the cached value, not supplying this option will delegate to the store's CachePolicy,\n * defaulting to `false` if none is configured.\n * - `urlParamsSetting` - an object containing options for how to serialize the query params (see `buildQueryParams`)\n *\n * ```ts\n * import { updateRecord } from '@warp-drive/utilities/active-record';\n *\n * const person = store.peekRecord('person', '1');\n * person.name = 'Chris';\n * const options = updateRecord(person, { patch: true });\n * const data = await store.request(options);\n * ```\n *\n * @public\n * @param record\n * @param options\n */\nexport function updateRecord<\n T extends TypedRecordInstance,\n RT extends TypedRecordInstance = T,\n M extends Meta | undefined = Meta | undefined,\n E extends object = object,\n>(\n record: T,\n options?: ConstrainedRequestOptions & { patch?: boolean }\n): UpdateRequestOptions<ReactiveDataDocument<RT, M, E>, T>;\nexport function updateRecord(\n record: unknown,\n options?: ConstrainedRequestOptions & { patch?: boolean }\n): UpdateRequestOptions;\nexport function updateRecord(\n record: unknown,\n options: ConstrainedRequestOptions & { patch?: boolean } = {}\n): UpdateRequestOptions {\n const identifier = recordIdentifierFor(record);\n assert(`Expected to be given a record instance`, identifier);\n assert(`Cannot update a record that does not have an associated type and id.`, isExisting(identifier));\n\n const urlOptions: UpdateRecordUrlOptions = {\n identifier: identifier,\n op: 'updateRecord',\n resourcePath: pluralize(underscore(identifier.type)),\n };\n\n copyForwardUrlOptions(urlOptions, options);\n\n const url = buildBaseURL(urlOptions);\n const headers = new Headers();\n headers.append('Accept', 'application/json;charset=utf-8');\n\n return {\n url,\n method: options.patch ? 'PATCH' : 'PUT',\n headers,\n op: 'updateRecord',\n data: {\n record: identifier,\n },\n records: [identifier],\n };\n}\n"],"mappings":";;;;;;AAkFA,SAAgB,WACd,MACA,MACA,MAC0B;CAC1B,MAAM,aAA2C,OAAO,SAAS,WAAW;EAAE,MAAM;EAAM,IAAI;CAAe,IAAI;CACjH,MAAM,WAAY,OAAO,SAAS,WAAW,OAAO,SAAS,CAAC;CAC9D,MAAM,eAAe,oBAAoB,OAAO;CAChD,MAAM,aAAmC;EACvC;EACA,IAAI;EACJ,cAAc,UAAU,WAAW,WAAW,IAAI,CAAC;CACrD;CAEA,sBAAsB,YAAY,OAAO;CAEzC,MAAM,MAAM,aAAa,UAAU;CACnC,MAAM,UAAU,IAAI,QAAQ;CAC5B,QAAQ,OAAO,UAAU,gCAAgC;CAEzD,OAAO;EACL,KAAK,QAAQ,SAAS,SAClB,GAAG,IAAI,GAAG,iBAAiB,EAAE,SAAS,QAAQ,QAAQ,GAAG,QAAQ,iBAAiB,MAClF;EACJ,QAAQ;EACR;EACA;EACA,IAAI;EACJ,SAAS,CAAC,UAAU;CACtB;AACF;;;;AC7CA,SAAgB,MACd,MAEA,QAA2B,CAAC,GAC5B,UAAqC,CAAC,GACjB;CACrB,MAAM,eAAe,o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OAAO,UAAU,gCAAgC;CAEzD,OAAO;EACLH;EACAI,QAAQ;EACRH;EACAH,IAAI;EACJO,MAAM,EACJV,QAAQJ,WACV;EACAe,SAAS,CAACf,UAAU;CACtB;AACF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAyDA,SAAgBiB,aACdb,QACAC,UAA2D,CAAC,GACtC;CACtB,MAAML,aAAaN,oBAAoBU,MAAM;CAI7C,MAAME,aAAqC;EAC7BN;EACZO,IAAI;EACJC,cAAcZ,UAAUC,WAAWG,WAAWE,IAAI,CAAC;CACrD;CAEAJ,sBAAsBQ,YAAYD,OAAO;CAEzC,MAAMI,MAAMd,aAAaW,UAAU;CACnC,MAAMI,UAAU,IAAIC,QAAQ;CAC5BD,QAAQE,OAAO,UAAU,gCAAgC;CAEzD,OAAO;EACLH;EACAI,QAAQR,QAAQa,QAAQ,UAAU;EAClCR;EACAH,IAAI;EACJO,MAAM,EACJV,QAAQJ,WACV;EACAe,SAAS,CAACf,UAAU;CACtB;AACF"}
1
+ {"version":3,"file":"active-record.js","names":["recordIdentifierFor","buildBaseURL","pluralize","underscore","copyForwardUrlOptions","isExisting","identifier","id","type","deleteRecord","record","options","urlOptions","op","resourcePath","url","headers","Headers","append","method","data","records","createRecord","updateRecord","patch"],"sources":["../../../src/-private/active-record/find-record.ts","../../../src/-private/active-record/query.ts","../../../src/-private/active-record/save-record.ts"],"sourcesContent":["import type { ReactiveDataDocument } from '@warp-drive/core/reactive';\nimport type { TypeFromInstance } from '@warp-drive/core/types/record';\nimport type {\n FindRecordOptions,\n FindRecordRequestOptions,\n RemotelyAccessibleIdentifier,\n} from '@warp-drive/core/types/request';\nimport type { Meta } from '@warp-drive/core/types/spec/json-api-raw';\n\nimport { buildBaseURL, buildQueryParams, type FindRecordUrlOptions } from '../../index.ts';\nimport { pluralize, underscore } from '../../string.ts';\nimport { copyForwardUrlOptions, extractCacheOptions } from '../builder-utils.ts';\n\n/**\n * Builds request options to fetch a single resource by a known id or identifier\n * configured for the url and header expectations of most ActiveRecord APIs.\n *\n * See the [Builders](/guides/the-manual/requests/builders) guide for what request builders do and\n * when to use one.\n *\n * **Basic Usage**\n *\n * ```ts\n * import { findRecord } from '@warp-drive/utilities/active-record';\n *\n * const data = await store.request(findRecord('person', '1'));\n * ```\n *\n * **With Options**\n *\n * ```ts\n * import { findRecord } from '@warp-drive/utilities/active-record';\n *\n * const options = findRecord('person', '1', { include: ['pets', 'friends'] });\n * const data = await store.request(options);\n * ```\n *\n * **With an Identifier**\n *\n * ```ts\n * import { findRecord } from '@warp-drive/utilities/active-record';\n *\n * const options = findRecord({ type: 'person', id: '1' }, { include: ['pets', 'friends'] });\n * const data = await store.request(options);\n * ```\n *\n * **Supplying Options to Modify the Request Behavior**\n *\n * The following options are supported:\n *\n * - `host` - The host to use for the request, defaults to the `host` configured with `setBuildURLConfig`.\n * - `namespace` - The namespace to use for the request, defaults to the `namespace` configured with `setBuildURLConfig`.\n * - `resourcePath` - The resource path to use for the request, defaults to pluralizing and underscoring the supplied type\n * - `reload` - Whether to forcibly reload the request if it is already in the store, not supplying this\n * option will delegate to the store's CachePolicy, defaulting to `false` if none is configured.\n * - `backgroundReload` - Whether to reload the request if it is already in the store, but to also resolve the\n * promise with the cached value, not supplying this option will delegate to the store's CachePolicy,\n * defaulting to `false` if none is configured.\n * - `urlParamsSetting` - an object containing options for how to serialize the query params (see `buildQueryParams`)\n *\n * ```ts\n * import { findRecord } from '@warp-drive/utilities/active-record';\n *\n * const options = findRecord('person', '1', { include: ['pets', 'friends'] }, { namespace: 'api/v2' });\n * const data = await store.request(options);\n * ```\n *\n * @summary Builds a `GET` request for one resource by type and id, using ActiveRecord-style pluralized, underscored\n * URLs.\n * @public\n * @param identifier\n * @param options\n */\nexport function findRecord<T, M extends Meta | undefined = Meta | undefined, E extends object = object>(\n identifier: RemotelyAccessibleIdentifier<TypeFromInstance<T>>,\n options?: FindRecordOptions\n): FindRecordRequestOptions<ReactiveDataDocument<T, M, E>, T>;\nexport function findRecord(\n identifier: RemotelyAccessibleIdentifier,\n options?: FindRecordOptions\n): FindRecordRequestOptions;\nexport function findRecord<T, M extends Meta | undefined = Meta | undefined, E extends object = object>(\n type: TypeFromInstance<T>,\n id: string,\n options?: FindRecordOptions\n): FindRecordRequestOptions<ReactiveDataDocument<T, M, E>, T>;\nexport function findRecord(type: string, id: string, options?: FindRecordOptions): FindRecordRequestOptions;\nexport function findRecord(\n arg1: string | RemotelyAccessibleIdentifier,\n arg2: string | FindRecordOptions | undefined,\n arg3?: FindRecordOptions\n): FindRecordRequestOptions {\n const identifier: RemotelyAccessibleIdentifier = typeof arg1 === 'string' ? { type: arg1, id: arg2 as string } : arg1;\n const options = ((typeof arg1 === 'string' ? arg3 : arg2) || {}) as FindRecordOptions;\n const cacheOptions = extractCacheOptions(options);\n const urlOptions: FindRecordUrlOptions = {\n identifier,\n op: 'findRecord',\n resourcePath: pluralize(underscore(identifier.type)),\n };\n\n copyForwardUrlOptions(urlOptions, options);\n\n const url = buildBaseURL(urlOptions);\n const headers = new Headers();\n headers.append('Accept', 'application/json;charset=utf-8');\n\n return {\n url: options.include?.length\n ? `${url}?${buildQueryParams({ include: options.include }, options.urlParamsSettings)}`\n : url,\n method: 'GET',\n headers,\n cacheOptions,\n op: 'findRecord',\n records: [identifier],\n };\n}\n\n/** @deprecated use {@link ReactiveDataDocument} instead */\nexport type FindRecordResultDocument<\n T,\n M extends Meta | undefined = Meta | undefined,\n E extends object = object,\n> = ReactiveDataDocument<T, M, E>;\n","import type { ReactiveDataDocument } from '@warp-drive/core/reactive';\nimport type { QueryParamsSource } from '@warp-drive/core/types/params';\nimport type { TypeFromInstance } from '@warp-drive/core/types/record';\nimport type { ConstrainedRequestOptions, QueryRequestOptions } from '@warp-drive/core/types/request';\nimport type { Meta } from '@warp-drive/core/types/spec/json-api-raw';\n\nimport { buildBaseURL, buildQueryParams, type QueryUrlOptions } from '../../index.ts';\nimport { pluralize, underscore } from '../../string';\nimport { copyForwardUrlOptions, extractCacheOptions } from '../builder-utils.ts';\n\n/**\n * Builds request options to query for resources, usually by a primary\n * type, configured for the url and header expectations of most ActiveRecord APIs.\n *\n * See the [Builders](/guides/the-manual/requests/builders) guide for what request builders do and\n * when to use one.\n *\n * **Basic Usage**\n *\n * ```ts\n * import { query } from '@warp-drive/utilities/active-record';\n *\n * const data = await store.request(query('person'));\n * ```\n *\n * **With Query Params**\n *\n * ```ts\n * import { query } from '@warp-drive/utilities/active-record';\n *\n * const options = query('person', { include: ['pets', 'friends'] });\n * const data = await store.request(options);\n * ```\n *\n * **Supplying Options to Modify the Request Behavior**\n *\n * The following options are supported:\n *\n * - `host` - The host to use for the request, defaults to the `host` configured with `setBuildURLConfig`.\n * - `namespace` - The namespace to use for the request, defaults to the `namespace` configured with `setBuildURLConfig`.\n * - `resourcePath` - The resource path to use for the request, defaults to pluralizing and underscoring the supplied type\n * - `reload` - Whether to forcibly reload the request if it is already in the store, not supplying this\n * option will delegate to the store's CachePolicy, defaulting to `false` if none is configured.\n * - `backgroundReload` - Whether to reload the request if it is already in the store, but to also resolve the\n * promise with the cached value, not supplying this option will delegate to the store's CachePolicy,\n * defaulting to `false` if none is configured.\n * - `urlParamsSetting` - an object containing options for how to serialize the query params (see `buildQueryParams`)\n *\n * ```ts\n * import { query } from '@warp-drive/utilities/active-record';\n *\n * const options = query('person', { include: ['pets', 'friends'] }, { reload: true });\n * const data = await store.request(options);\n * ```\n *\n * @summary Builds a `GET` request that queries a resource type with query params, using ActiveRecord-style URLs.\n * @public\n * @param identifier\n * @param query\n * @param options\n */\nexport function query<T, M extends Meta | undefined = Meta | undefined, E extends object = object>(\n type: TypeFromInstance<T>,\n query?: QueryParamsSource,\n options?: ConstrainedRequestOptions\n): QueryRequestOptions<ReactiveDataDocument<T[], M, E>>;\nexport function query(\n type: string,\n query?: QueryParamsSource,\n options?: ConstrainedRequestOptions\n): QueryRequestOptions;\nexport function query(\n type: string,\n // oxlint-disable-next-line no-shadow\n query: QueryParamsSource = {},\n options: ConstrainedRequestOptions = {}\n): QueryRequestOptions {\n const cacheOptions = extractCacheOptions(options);\n const urlOptions: QueryUrlOptions = {\n identifier: { type },\n op: 'query',\n resourcePath: pluralize(underscore(type)),\n };\n\n copyForwardUrlOptions(urlOptions, options);\n\n const url = buildBaseURL(urlOptions);\n const headers = new Headers();\n headers.append('Accept', 'application/json;charset=utf-8');\n const queryString = buildQueryParams(query, options.urlParamsSettings);\n\n return {\n url: queryString ? `${url}?${queryString}` : url,\n method: 'GET',\n headers,\n cacheOptions,\n op: 'query',\n };\n}\n","import { recordIdentifierFor } from '@warp-drive/core';\nimport { assert } from '@warp-drive/core/build-config/macros';\nimport type { ReactiveDataDocument } from '@warp-drive/core/reactive';\nimport type { PersistedResourceKey, ResourceKey } from '@warp-drive/core/types/identifier';\nimport type { TypedRecordInstance } from '@warp-drive/core/types/record';\nimport type {\n ConstrainedRequestOptions,\n CreateRequestOptions,\n DeleteRequestOptions,\n UpdateRequestOptions,\n} from '@warp-drive/core/types/request';\nimport type { Meta } from '@warp-drive/core/types/spec/json-api-raw';\n\nimport {\n buildBaseURL,\n type CreateRecordUrlOptions,\n type DeleteRecordUrlOptions,\n type UpdateRecordUrlOptions,\n} from '../../index.ts';\nimport { pluralize, underscore } from '../../string';\nimport { copyForwardUrlOptions } from '../builder-utils.ts';\n\nfunction isExisting(identifier: ResourceKey): identifier is PersistedResourceKey {\n return 'id' in identifier && identifier.id !== null && 'type' in identifier && identifier.type !== null;\n}\n\n/**\n * Builds request options to delete record for resources,\n * configured for the url, method and header expectations of ActiveRecord APIs.\n *\n * See the [Builders](/guides/the-manual/requests/builders) guide for what request builders do and\n * when to use one.\n *\n * **Basic Usage**\n *\n * ```ts\n * import { deleteRecord } from '@warp-drive/utilities/active-record';\n *\n * const person = store.peekRecord('person', '1');\n *\n * // mark record as deleted\n * store.deleteRecord(person);\n *\n * // persist deletion\n * const data = await store.request(deleteRecord(person));\n * ```\n *\n * **Supplying Options to Modify the Request Behavior**\n *\n * The following options are supported:\n *\n * - `host` - The host to use for the request, defaults to the `host` configured with `setBuildURLConfig`.\n * - `namespace` - The namespace to use for the request, defaults to the `namespace` configured with `setBuildURLConfig`.\n * - `resourcePath` - The resource path to use for the request, defaults to pluralizing the supplied type\n * - `reload` - Whether to forcibly reload the request if it is already in the store, not supplying this\n * option will delegate to the store's CachePolicy, defaulting to `false` if none is configured.\n * - `backgroundReload` - Whether to reload the request if it is already in the store, but to also resolve the\n * promise with the cached value, not supplying this option will delegate to the store's CachePolicy,\n * defaulting to `false` if none is configured.\n * - `urlParamsSetting` - an object containing options for how to serialize the query params (see `buildQueryParams`)\n *\n * ```ts\n * import { deleteRecord } from '@warp-drive/utilities/active-record';\n *\n * const person = store.peekRecord('person', '1');\n *\n * // mark record as deleted\n * store.deleteRecord(person);\n *\n * // persist deletion\n * const options = deleteRecord(person, { namespace: 'api/v1' });\n * const data = await store.request(options);\n * ```\n *\n * @summary Builds a `DELETE` request that persists deletion of an existing record, using ActiveRecord-style URLs.\n * @public\n * @param record\n * @param options\n */\nexport function deleteRecord<T>(record: T, options?: ConstrainedRequestOptions): DeleteRequestOptions<T>;\nexport function deleteRecord(record: unknown, options?: ConstrainedRequestOptions): DeleteRequestOptions;\nexport function deleteRecord(record: unknown, options: ConstrainedRequestOptions = {}): DeleteRequestOptions {\n const identifier = recordIdentifierFor(record);\n assert(`Expected to be given a record instance`, identifier);\n assert(`Cannot delete a record that does not have an associated type and id.`, isExisting(identifier));\n\n const urlOptions: DeleteRecordUrlOptions = {\n identifier: identifier,\n op: 'deleteRecord',\n resourcePath: pluralize(underscore(identifier.type)),\n };\n\n copyForwardUrlOptions(urlOptions, options);\n\n const url = buildBaseURL(urlOptions);\n const headers = new Headers();\n headers.append('Accept', 'application/json;charset=utf-8');\n\n return {\n url,\n method: 'DELETE',\n headers,\n op: 'deleteRecord',\n data: {\n record: identifier,\n },\n records: [identifier],\n };\n}\n\n/**\n * Builds request options to create new record for resources,\n * configured for the url, method and header expectations of most ActiveRecord APIs.\n *\n * See the [Builders](/guides/the-manual/requests/builders) guide for what request builders do and\n * when to use one.\n *\n * **Basic Usage**\n *\n * ```ts\n * import { createRecord } from '@warp-drive/utilities/active-record';\n *\n * const person = store.createRecord('person', { name: 'Ted' });\n * const data = await store.request(createRecord(person));\n * ```\n *\n * **Supplying Options to Modify the Request Behavior**\n *\n * The following options are supported:\n *\n * - `host` - The host to use for the request, defaults to the `host` configured with `setBuildURLConfig`.\n * - `namespace` - The namespace to use for the request, defaults to the `namespace` configured with `setBuildURLConfig`.\n * - `resourcePath` - The resource path to use for the request, defaults to pluralizing the supplied type\n * - `reload` - Whether to forcibly reload the request if it is already in the store, not supplying this\n * option will delegate to the store's CachePolicy, defaulting to `false` if none is configured.\n * - `backgroundReload` - Whether to reload the request if it is already in the store, but to also resolve the\n * promise with the cached value, not supplying this option will delegate to the store's CachePolicy,\n * defaulting to `false` if none is configured.\n * - `urlParamsSetting` - an object containing options for how to serialize the query params (see `buildQueryParams`)\n *\n * ```ts\n * import { createRecord } from '@warp-drive/utilities/active-record';\n *\n * const person = store.createRecord('person', { name: 'Ted' });\n * const options = createRecord(person, { namespace: 'api/v1' });\n * const data = await store.request(options);\n * ```\n *\n * @summary Builds a `POST` request that saves a newly created record, using ActiveRecord-style URLs.\n * @public\n * @param record\n * @param options\n */\nexport function createRecord<T>(record: T, options?: ConstrainedRequestOptions): CreateRequestOptions<T>;\nexport function createRecord(record: unknown, options?: ConstrainedRequestOptions): CreateRequestOptions;\nexport function createRecord(record: unknown, options: ConstrainedRequestOptions = {}): CreateRequestOptions {\n const identifier = recordIdentifierFor(record);\n assert(`Expected to be given a record instance`, identifier);\n\n const urlOptions: CreateRecordUrlOptions = {\n identifier: identifier,\n op: 'createRecord',\n resourcePath: pluralize(underscore(identifier.type)),\n };\n\n copyForwardUrlOptions(urlOptions, options);\n\n const url = buildBaseURL(urlOptions);\n const headers = new Headers();\n headers.append('Accept', 'application/json;charset=utf-8');\n\n return {\n url,\n method: 'POST',\n headers,\n op: 'createRecord',\n data: {\n record: identifier,\n },\n records: [identifier],\n };\n}\n\n/**\n * Builds request options to update existing record for resources,\n * configured for the url, method and header expectations of most ActiveRecord APIs.\n *\n * See the [Builders](/guides/the-manual/requests/builders) guide for what request builders do and\n * when to use one.\n *\n * **Basic Usage**\n *\n * ```ts\n * import { updateRecord } from '@warp-drive/utilities/active-record';\n *\n * const person = store.peekRecord('person', '1');\n * person.name = 'Chris';\n * const data = await store.request(updateRecord(person));\n * ```\n *\n * **Supplying Options to Modify the Request Behavior**\n *\n * The following options are supported:\n *\n * - `patch` - Allows caller to specify whether to use a PATCH request instead of a PUT request, defaults to `false`.\n * - `host` - The host to use for the request, defaults to the `host` configured with `setBuildURLConfig`.\n * - `namespace` - The namespace to use for the request, defaults to the `namespace` configured with `setBuildURLConfig`.\n * - `resourcePath` - The resource path to use for the request, defaults to pluralizing the supplied type\n * - `reload` - Whether to forcibly reload the request if it is already in the store, not supplying this\n * option will delegate to the store's CachePolicy, defaulting to `false` if none is configured.\n * - `backgroundReload` - Whether to reload the request if it is already in the store, but to also resolve the\n * promise with the cached value, not supplying this option will delegate to the store's CachePolicy,\n * defaulting to `false` if none is configured.\n * - `urlParamsSetting` - an object containing options for how to serialize the query params (see `buildQueryParams`)\n *\n * ```ts\n * import { updateRecord } from '@warp-drive/utilities/active-record';\n *\n * const person = store.peekRecord('person', '1');\n * person.name = 'Chris';\n * const options = updateRecord(person, { patch: true });\n * const data = await store.request(options);\n * ```\n *\n * @summary Builds a `PUT` (or `PATCH`) request that saves changes to an existing record, using ActiveRecord-style URLs.\n * @public\n * @param record\n * @param options\n */\nexport function updateRecord<\n T extends TypedRecordInstance,\n RT extends TypedRecordInstance = T,\n M extends Meta | undefined = Meta | undefined,\n E extends object = object,\n>(\n record: T,\n options?: ConstrainedRequestOptions & { patch?: boolean }\n): UpdateRequestOptions<ReactiveDataDocument<RT, M, E>, T>;\nexport function updateRecord(\n record: unknown,\n options?: ConstrainedRequestOptions & { patch?: boolean }\n): UpdateRequestOptions;\nexport function updateRecord(\n record: unknown,\n options: ConstrainedRequestOptions & { patch?: boolean } = {}\n): UpdateRequestOptions {\n const identifier = recordIdentifierFor(record);\n assert(`Expected to be given a record instance`, identifier);\n assert(`Cannot update a record that does not have an associated type and id.`, isExisting(identifier));\n\n const urlOptions: UpdateRecordUrlOptions = {\n identifier: identifier,\n op: 'updateRecord',\n resourcePath: pluralize(underscore(identifier.type)),\n };\n\n copyForwardUrlOptions(urlOptions, options);\n\n const url = buildBaseURL(urlOptions);\n const headers = new Headers();\n headers.append('Accept', 'application/json;charset=utf-8');\n\n return {\n url,\n method: options.patch ? 'PATCH' : 'PUT',\n headers,\n op: 'updateRecord',\n data: {\n record: identifier,\n },\n records: [identifier],\n };\n}\n"],"mappings":";;;;;;AAuFA,SAAgB,WACd,MACA,MACA,MAC0B;CAC1B,MAAM,aAA2C,OAAO,SAAS,WAAW;EAAE,MAAM;EAAM,IAAI;CAAe,IAAI;CACjH,MAAM,WAAY,OAAO,SAAS,WAAW,OAAO,SAAS,CAAC;CAC9D,MAAM,eAAe,oBAAoB,OAAO;CAChD,MAAM,aAAmC;EACvC;EACA,IAAI;EACJ,cAAc,UAAU,WAAW,WAAW,IAAI,CAAC;CACrD;CAEA,sBAAsB,YAAY,OAAO;CAEzC,MAAM,MAAM,aAAa,UAAU;CACnC,MAAM,UAAU,IAAI,QAAQ;CAC5B,QAAQ,OAAO,UAAU,gCAAgC;CAEzD,OAAO;EACL,KAAK,QAAQ,SAAS,SAClB,GAAG,IAAI,GAAG,iBAAiB,EAAE,SAAS,QAAQ,QAAQ,GAAG,QAAQ,iBAAiB,MAClF;EACJ,QAAQ;EACR;EACA;EACA,IAAI;EACJ,SAAS,CAAC,UAAU;CACtB;AACF;;;;AC9CA,SAAgB,MACd,MAEA,QAA2B,CAAC,GAC5B,UAAqC,CAAC,GACjB;CACrB,MAAM,eAAe,oBAAoB,OAAO;CAChD,MAAM,aAA8B;EAClC,YAA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;EACLH;EACAI,QAAQ;EACRH;EACAH,IAAI;EACJO,MAAM,EACJV,QAAQJ,WACV;EACAe,SAAS,CAACf,UAAU;CACtB;AACF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA6DA,SAAgBiB,aACdb,QACAC,UAA2D,CAAC,GACtC;CACtB,MAAML,aAAaN,oBAAoBU,MAAM;CAI7C,MAAME,aAAqC;EAC7BN;EACZO,IAAI;EACJC,cAAcZ,UAAUC,WAAWG,WAAWE,IAAI,CAAC;CACrD;CAEAJ,sBAAsBQ,YAAYD,OAAO;CAEzC,MAAMI,MAAMd,aAAaW,UAAU;CACnC,MAAMI,UAAU,IAAIC,QAAQ;CAC5BD,QAAQE,OAAO,UAAU,gCAAgC;CAEzD,OAAO;EACLH;EACAI,QAAQR,QAAQa,QAAQ,UAAU;EAClCR;EACAH,IAAI;EACJO,MAAM,EACJV,QAAQJ,WACV;EACAe,SAAS,CAACf,UAAU;CACtB;AACF"}
@@ -2,11 +2,17 @@ import { Type } from "@warp-drive/core/types/symbols";
2
2
 
3
3
  //#region src/derivations.ts
4
4
  /**
5
+ * @module
6
+ * @summary The `concat` derivation, which joins a record's listed fields into one string with an optional separator.
7
+ */
8
+ /**
5
9
  * A derivation for use by {@link ReactiveResource} that joins the given fields
6
10
  * with the optional separator (or '' if no separator is provided).
7
11
  *
8
12
  * Generally you should not need to import and use this function directly.
9
13
  *
14
+ * @summary Derivation registered as `concat` that joins a record's listed `fields` into one string with an optional
15
+ * `separator`.
10
16
  * @example
11
17
  * {
12
18
  * name: 'fullName',
@@ -1 +1 @@
1
- {"version":3,"file":"derivations.js","names":["Type","concat","record","options","_prop","Error","opts","fields","map","field","join","separator"],"sources":["../../../src/derivations.ts"],"sourcesContent":["import type { ReactiveResource } from '@warp-drive/core/reactive';\nimport { Type } from '@warp-drive/core/types/symbols';\n\ninterface ConcatDerivation {\n (\n record: ReactiveResource & { [key: string]: unknown },\n options: Record<string, unknown> | null,\n _prop: string\n ): string;\n [Type]: 'concat';\n}\n\n/**\n * A derivation for use by {@link ReactiveResource} that joins the given fields\n * with the optional separator (or '' if no separator is provided).\n *\n * Generally you should not need to import and use this function directly.\n *\n * @example\n * {\n * name: 'fullName',\n * kind: 'derived',\n * type: 'concat',\n * options: {\n * fields: ['firstName', 'lastName'],\n * separator: ' ',\n * },\n * }\n */\nexport const concat: ConcatDerivation = (\n record: ReactiveResource & { [key: string]: unknown },\n options: Record<string, unknown> | null,\n _prop: string\n) => {\n if (!options) {\n throw new Error(`options is required`);\n }\n // SAFETY: we cast internally to a more specific type, for our own use\n // SAFETY: but provide the more general signature to the schema service\n const opts = options as { fields: string[]; separator?: string };\n return opts.fields.map((field) => record[field]).join(opts.separator ?? '');\n};\nconcat[Type] = 'concat';\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AA6BA,MAAaC,UACXC,QACAC,SACAC,UACG;CACH,IAAI,CAACD,SACH,MAAM,IAAIE,MAAM,qBAAqB;CAIvC,MAAMC,OAAOH;CACb,OAAOG,KAAKC,OAAOC,KAAKC,UAAUP,OAAOO,MAAM,CAAC,CAACC,KAAKJ,KAAKK,aAAa,EAAE;AAC5E;AACAV,OAAOD,QAAQ"}
1
+ {"version":3,"file":"derivations.js","names":["Type","concat","record","options","_prop","Error","opts","fields","map","field","join","separator"],"sources":["../../../src/derivations.ts"],"sourcesContent":["/**\n * @module\n * @summary The `concat` derivation, which joins a record's listed fields into one string with an optional separator.\n */\n\nimport type { ReactiveResource } from '@warp-drive/core/reactive';\nimport { Type } from '@warp-drive/core/types/symbols';\n\ninterface ConcatDerivation {\n (\n record: ReactiveResource & { [key: string]: unknown },\n options: Record<string, unknown> | null,\n _prop: string\n ): string;\n [Type]: 'concat';\n}\n\n/**\n * A derivation for use by {@link ReactiveResource} that joins the given fields\n * with the optional separator (or '' if no separator is provided).\n *\n * Generally you should not need to import and use this function directly.\n *\n * @summary Derivation registered as `concat` that joins a record's listed `fields` into one string with an optional\n * `separator`.\n * @example\n * {\n * name: 'fullName',\n * kind: 'derived',\n * type: 'concat',\n * options: {\n * fields: ['firstName', 'lastName'],\n * separator: ' ',\n * },\n * }\n */\nexport const concat: ConcatDerivation = (\n record: ReactiveResource & { [key: string]: unknown },\n options: Record<string, unknown> | null,\n _prop: string\n) => {\n if (!options) {\n throw new Error(`options is required`);\n }\n // SAFETY: we cast internally to a more specific type, for our own use\n // SAFETY: but provide the more general signature to the schema service\n const opts = options as { fields: string[]; separator?: string };\n return opts.fields.map((field) => record[field]).join(opts.separator ?? '');\n};\nconcat[Type] = 'concat';\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAoCA,MAAaC,UACXC,QACAC,SACAC,UACG;CACH,IAAI,CAACD,SACH,MAAM,IAAIE,MAAM,qBAAqB;CAIvC,MAAMC,OAAOH;CACb,OAAOG,KAAKC,OAAOC,KAAKC,UAAUP,OAAOO,MAAM,CAAC,CAACC,KAAKJ,KAAKK,aAAa,EAAE;AAC5E;AACAV,OAAOD,QAAQ"}
@@ -6,6 +6,8 @@ function isCompressibleMethod(method) {
6
6
  * Whether the browser supports `ReadableStream` as a request body
7
7
  * in a `POST` request.
8
8
  *
9
+ * @summary Whether the current browser can send a `ReadableStream` as a `fetch` request body, detected once at
10
+ * module load.
9
11
  * @group Constants
10
12
  */
11
13
  const SupportsRequestStreams = (() => {
@@ -56,6 +58,8 @@ const TypedArray = Object.getPrototypeOf(Uint8Array);
56
58
  * }
57
59
  * ```
58
60
  *
61
+ * @summary Request handler that compresses large `POST`, `PUT`, `PATCH`, and `DELETE` bodies with `CompressionStream`,
62
+ * optionally streaming them.
59
63
  * @group Handlers
60
64
  * @public
61
65
  * @since 5.5.0
@@ -121,6 +125,8 @@ function encodingForFormat(format) {
121
125
  */
122
126
  /**
123
127
  *
128
+ * @summary Request handler that wraps another handler and runs it only when a check function returns true for the
129
+ * request.
124
130
  * @group Handlers
125
131
  * @public
126
132
  */
@@ -186,6 +192,7 @@ var Gate = class {
186
192
  * Errors are not processed by this handler, so if the request fails and the error response
187
193
  * is not in {json:api} format additional processing may be needed.
188
194
  *
195
+ * @summary Request handler that wraps the whole response body in `meta` for requests with `options.isMetaRequest` set.
189
196
  * @group Handlers
190
197
  */
191
198
  const MetaDocHandler = { request(context, next) {
@@ -218,12 +225,15 @@ function getTabId() {
218
225
  * useful for observability/tracing and deduping
219
226
  * across multiple tabs.
220
227
  *
228
+ * @summary Random UUID identifying the current browser tab, kept in `sessionStorage` across reloads, for request
229
+ * tracing.
221
230
  * @group Constants
222
231
  */
223
232
  const TAB_ID = getTabId();
224
233
  /**
225
234
  * The epoch seconds at which the tab id was generated
226
235
  *
236
+ * @summary Epoch seconds recorded when this module loaded, paired with `TAB_ID` in trace headers.
227
237
  * @group Constants
228
238
  */
229
239
  const TAB_ASSIGNED = Math.floor(Date.now() / 1e3);
@@ -236,6 +246,8 @@ const TAB_ASSIGNED = Math.floor(Date.now() / 1e3);
236
246
  *
237
247
  * Follows the template: `Root=1-${now}-${uuidv4};TabId=1-${epochSeconds}-${tab-uuid}`
238
248
  *
249
+ * @summary Sets an `X-Amzn-Trace-Id` header carrying a per-request id and the tab id, so requests can be traced to
250
+ * their browser tab.
239
251
  * @group Utility Functions
240
252
  */
241
253
  function addTraceHeader(headers) {
@@ -247,6 +259,7 @@ function addTraceHeader(headers) {
247
259
  * Source: https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/cloudfront-limits.html
248
260
  * As of 2024-12-05 the maximum URL length is 8192 bytes.
249
261
  *
262
+ * @summary The 8192-byte URL length limit, taken from AWS CloudFront, that `assertInvalidUrlLength` checks against.
250
263
  * @group Constants
251
264
  */
252
265
  const MAX_URL_LENGTH = 8192;
@@ -255,6 +268,8 @@ const MAX_URL_LENGTH = 8192;
255
268
  *
256
269
  * See also {@link MAX_URL_LENGTH}
257
270
  *
271
+ * @summary Dev-mode assertion that throws when a URL is longer than `MAX_URL_LENGTH`, suggesting a `POST` or `QUERY`
272
+ * request instead.
258
273
  * @group Utility Functions
259
274
  */
260
275
  function assertInvalidUrlLength(url) {}