@warp-drive-mirror/utilities 5.10.0-alpha.2 → 5.10.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 (131) hide show
  1. package/README.md +92 -7
  2. package/cjs-dist/string.cjs +23 -8
  3. package/cjs-dist/string.cjs.map +1 -1
  4. package/dist/-private.d.ts +0 -2
  5. package/dist/-private.d.ts.map +1 -1
  6. package/dist/-private.js +1 -1
  7. package/dist/active-record.d.ts +21 -6
  8. package/dist/active-record.d.ts.map +1 -1
  9. package/dist/active-record.js +17 -8
  10. package/dist/active-record.js.map +1 -1
  11. package/dist/{builder-utils-BkXwUT0x.js → builder-utils-bjXbHa-m.js} +2 -3
  12. package/dist/{builder-utils-BkXwUT0x.js.map → builder-utils-bjXbHa-m.js.map} +1 -1
  13. package/dist/derivations.d.ts +3 -2
  14. package/dist/derivations.d.ts.map +1 -1
  15. package/dist/derivations.js +7 -2
  16. package/dist/derivations.js.map +1 -1
  17. package/dist/handlers.d.ts +26 -9
  18. package/dist/handlers.d.ts.map +1 -1
  19. package/dist/handlers.js +29 -9
  20. package/dist/handlers.js.map +1 -1
  21. package/dist/{index-BeMAuqgZ.d.ts → index-Dv5kZpGe.d.ts} +47 -3
  22. package/dist/index-Dv5kZpGe.d.ts.map +1 -0
  23. package/dist/index.d.ts +1 -1
  24. package/dist/index.js +54 -8
  25. package/dist/index.js.map +1 -1
  26. package/dist/{inflections-DzBsjJqj.js → inflections-CWdUh2K_.js} +2 -3
  27. package/dist/{inflections-DzBsjJqj.js.map → inflections-CWdUh2K_.js.map} +1 -1
  28. package/dist/json-api.d.ts +51 -11
  29. package/dist/json-api.d.ts.map +1 -1
  30. package/dist/json-api.js +43 -12
  31. package/dist/json-api.js.map +1 -1
  32. package/dist/rest.d.ts +20 -6
  33. package/dist/rest.d.ts.map +1 -1
  34. package/dist/rest.js +17 -8
  35. package/dist/rest.js.map +1 -1
  36. package/dist/{string-CWmAluxh.js → string-DFhbMVCj.js} +23 -6
  37. package/dist/string-DFhbMVCj.js.map +1 -0
  38. package/dist/string.d.ts +19 -4
  39. package/dist/string.d.ts.map +1 -1
  40. package/dist/string.js +1 -1
  41. package/dist/unpkg/dev/-private.js +1 -1
  42. package/dist/unpkg/dev/active-record.js +17 -8
  43. package/dist/unpkg/dev/active-record.js.map +1 -1
  44. package/dist/unpkg/dev/{builder-utils-BkXwUT0x.js → builder-utils-bjXbHa-m.js} +2 -3
  45. package/dist/unpkg/dev/{builder-utils-BkXwUT0x.js.map → builder-utils-bjXbHa-m.js.map} +1 -1
  46. package/dist/unpkg/dev/derivations.js +7 -2
  47. package/dist/unpkg/dev/derivations.js.map +1 -1
  48. package/dist/unpkg/dev/handlers.js +29 -9
  49. package/dist/unpkg/dev/handlers.js.map +1 -1
  50. package/dist/unpkg/dev/index.js +54 -8
  51. package/dist/unpkg/dev/index.js.map +1 -1
  52. package/dist/unpkg/dev/{inflections-DzBsjJqj.js → inflections-CWdUh2K_.js} +2 -3
  53. package/dist/unpkg/dev/{inflections-DzBsjJqj.js.map → inflections-CWdUh2K_.js.map} +1 -1
  54. package/dist/unpkg/dev/json-api.js +43 -12
  55. package/dist/unpkg/dev/json-api.js.map +1 -1
  56. package/dist/unpkg/dev/rest.js +17 -8
  57. package/dist/unpkg/dev/rest.js.map +1 -1
  58. package/dist/unpkg/dev/{string-j4ur-TDs.js → string-D9jrClhQ.js} +23 -6
  59. package/dist/unpkg/dev/string-D9jrClhQ.js.map +1 -0
  60. package/dist/unpkg/dev/string.js +1 -1
  61. package/dist/unpkg/dev-deprecated/-private.js +1 -1
  62. package/dist/unpkg/dev-deprecated/active-record.js +17 -8
  63. package/dist/unpkg/dev-deprecated/active-record.js.map +1 -1
  64. package/dist/unpkg/dev-deprecated/{builder-utils-BkXwUT0x.js → builder-utils-bjXbHa-m.js} +2 -3
  65. package/dist/unpkg/dev-deprecated/{builder-utils-BkXwUT0x.js.map → builder-utils-bjXbHa-m.js.map} +1 -1
  66. package/dist/unpkg/dev-deprecated/derivations.js +7 -2
  67. package/dist/unpkg/dev-deprecated/derivations.js.map +1 -1
  68. package/dist/unpkg/dev-deprecated/handlers.js +29 -9
  69. package/dist/unpkg/dev-deprecated/handlers.js.map +1 -1
  70. package/dist/unpkg/dev-deprecated/index.js +54 -8
  71. package/dist/unpkg/dev-deprecated/index.js.map +1 -1
  72. package/dist/unpkg/dev-deprecated/{inflections-DzBsjJqj.js → inflections-CWdUh2K_.js} +2 -3
  73. package/dist/unpkg/dev-deprecated/{inflections-DzBsjJqj.js.map → inflections-CWdUh2K_.js.map} +1 -1
  74. package/dist/unpkg/dev-deprecated/json-api.js +43 -12
  75. package/dist/unpkg/dev-deprecated/json-api.js.map +1 -1
  76. package/dist/unpkg/dev-deprecated/rest.js +17 -8
  77. package/dist/unpkg/dev-deprecated/rest.js.map +1 -1
  78. package/dist/unpkg/dev-deprecated/{string-j4ur-TDs.js → string-D9jrClhQ.js} +23 -6
  79. package/dist/unpkg/dev-deprecated/string-D9jrClhQ.js.map +1 -0
  80. package/dist/unpkg/dev-deprecated/string.js +1 -1
  81. package/dist/unpkg/prod/-private.js +1 -1
  82. package/dist/unpkg/prod/active-record.js +17 -8
  83. package/dist/unpkg/prod/active-record.js.map +1 -1
  84. package/dist/unpkg/prod/builder-utils-bjXbHa-m.js +15 -0
  85. package/dist/unpkg/prod/{builder-utils-BkXwUT0x.js.map → builder-utils-bjXbHa-m.js.map} +1 -1
  86. package/dist/unpkg/prod/derivations.js +7 -2
  87. package/dist/unpkg/prod/derivations.js.map +1 -1
  88. package/dist/unpkg/prod/handlers.js +29 -9
  89. package/dist/unpkg/prod/handlers.js.map +1 -1
  90. package/dist/unpkg/prod/index.js +54 -8
  91. package/dist/unpkg/prod/index.js.map +1 -1
  92. package/dist/unpkg/prod/inflections-CWdUh2K_.js +79 -0
  93. package/dist/unpkg/prod/{inflections-DzBsjJqj.js.map → inflections-CWdUh2K_.js.map} +1 -1
  94. package/dist/unpkg/prod/json-api.js +43 -12
  95. package/dist/unpkg/prod/json-api.js.map +1 -1
  96. package/dist/unpkg/prod/rest.js +17 -8
  97. package/dist/unpkg/prod/rest.js.map +1 -1
  98. package/dist/unpkg/prod/string-Du9nRZEd.js +300 -0
  99. package/dist/unpkg/prod/string-Du9nRZEd.js.map +1 -0
  100. package/dist/unpkg/prod/string.js +1 -1
  101. package/dist/unpkg/prod-deprecated/-private.js +1 -1
  102. package/dist/unpkg/prod-deprecated/active-record.js +17 -8
  103. package/dist/unpkg/prod-deprecated/active-record.js.map +1 -1
  104. package/dist/unpkg/prod-deprecated/{builder-utils-BkXwUT0x.js → builder-utils-bjXbHa-m.js} +2 -3
  105. package/dist/unpkg/prod-deprecated/{builder-utils-BkXwUT0x.js.map → builder-utils-bjXbHa-m.js.map} +1 -1
  106. package/dist/unpkg/prod-deprecated/derivations.js +7 -2
  107. package/dist/unpkg/prod-deprecated/derivations.js.map +1 -1
  108. package/dist/unpkg/prod-deprecated/handlers.js +29 -9
  109. package/dist/unpkg/prod-deprecated/handlers.js.map +1 -1
  110. package/dist/unpkg/prod-deprecated/index.js +54 -8
  111. package/dist/unpkg/prod-deprecated/index.js.map +1 -1
  112. package/dist/unpkg/prod-deprecated/{inflections-DzBsjJqj.js → inflections-CWdUh2K_.js} +2 -3
  113. package/dist/unpkg/prod-deprecated/{inflections-DzBsjJqj.js.map → inflections-CWdUh2K_.js.map} +1 -1
  114. package/dist/unpkg/prod-deprecated/json-api.js +43 -12
  115. package/dist/unpkg/prod-deprecated/json-api.js.map +1 -1
  116. package/dist/unpkg/prod-deprecated/rest.js +17 -8
  117. package/dist/unpkg/prod-deprecated/rest.js.map +1 -1
  118. package/dist/unpkg/prod-deprecated/{string-T1ahjLdj.js → string-Du9nRZEd.js} +23 -6
  119. package/dist/unpkg/prod-deprecated/string-Du9nRZEd.js.map +1 -0
  120. package/dist/unpkg/prod-deprecated/string.js +1 -1
  121. package/logos/README.md +1 -1
  122. package/package.json +9 -9
  123. package/dist/index-BeMAuqgZ.d.ts.map +0 -1
  124. package/dist/string-CWmAluxh.js.map +0 -1
  125. package/dist/unpkg/dev/string-j4ur-TDs.js.map +0 -1
  126. package/dist/unpkg/dev-deprecated/string-j4ur-TDs.js.map +0 -1
  127. package/dist/unpkg/prod/builder-utils-BkXwUT0x.js +0 -16
  128. package/dist/unpkg/prod/inflections-DzBsjJqj.js +0 -80
  129. package/dist/unpkg/prod/string-T1ahjLdj.js +0 -283
  130. package/dist/unpkg/prod/string-T1ahjLdj.js.map +0 -1
  131. package/dist/unpkg/prod-deprecated/string-T1ahjLdj.js.map +0 -1
@@ -1,7 +1,7 @@
1
- import { t as defaultRules } from "./inflections-DzBsjJqj.js";
1
+ import { t as defaultRules } from "./inflections-CWdUh2K_.js";
2
2
  import { LRUCache, STRING_DASHERIZE_CACHE, dasherize } from "@warp-drive-mirror/core/utils/string";
3
3
 
4
- //#region src/-private/string/transform.ts
4
+ // src/-private/string/transform.ts
5
5
  const STRING_CAMELIZE_REGEXP_1 = /(\-|\_|\.|\s)+(.)?/g;
6
6
  const STRING_CAMELIZE_REGEXP_2 = /(^|\/)([A-Z])/g;
7
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()));
@@ -23,6 +23,7 @@ const CAPITALIZE_CACHE = new LRUCache((str) => str.replace(STRING_CAPITALIZE_REG
23
23
  * dasherize('privateDocs/ownerInvoice'; // 'private-docs/owner-invoice'
24
24
  * ```
25
25
  *
26
+ * @summary Converts camelCase, underscored, or spaced strings to dasherized form, such as `innerHTML` to `inner-html`.
26
27
  * @public
27
28
  * @since 4.13.0
28
29
  */
@@ -41,6 +42,8 @@ const dasherize$1 = dasherize;
41
42
  * camelize('private-docs/owner-invoice'); // 'privateDocs/ownerInvoice'
42
43
  * ```
43
44
  *
45
+ * @summary Converts dashed, underscored, dotted, or spaced strings to lowerCamelCase, such as `action_name` to
46
+ * `actionName`.
44
47
  * @public
45
48
  * @since 4.13.0
46
49
  */
@@ -60,6 +63,7 @@ function camelize(str) {
60
63
  * underscore('privateDocs/ownerInvoice'); // 'private_docs/owner_invoice'
61
64
  * ```
62
65
  *
66
+ * @summary Converts camelCase, dashed, or spaced strings to lowercase snake_case, such as `innerHTML` to `inner_html`.
63
67
  * @public
64
68
  * @since 4.13.0
65
69
  */
@@ -79,6 +83,7 @@ function underscore(str) {
79
83
  * capitalize('privateDocs/ownerInvoice'); // 'PrivateDocs/ownerInvoice'
80
84
  * ```
81
85
  *
86
+ * @summary Uppercases the first letter of a string, and of each `/`-separated path segment, leaving the rest unchanged.
82
87
  * @public
83
88
  * @since 4.13.0
84
89
  */
@@ -89,6 +94,8 @@ function capitalize(str) {
89
94
  * Sets the maximum size of the LRUCache for all string transformation functions.
90
95
  * The default size is 10,000.
91
96
  *
97
+ * @summary Sets how many results the `camelize`, `underscore`, `capitalize`, and `dasherize` caches each keep (default
98
+ * 10,000).
92
99
  * @public
93
100
  * @since 4.13.0
94
101
  */
@@ -99,8 +106,7 @@ function setMaxLRUCacheSize(size) {
99
106
  STRING_DASHERIZE_CACHE.size = size;
100
107
  }
101
108
 
102
- //#endregion
103
- //#region src/-private/string/inflect.ts
109
+ // src/-private/string/inflect.ts
104
110
  const BLANK_REGEX = /^\s*$/;
105
111
  const LAST_WORD_DASHED_REGEX = /([\w/-]+[_/\s-])([a-z\d]+$)/;
106
112
  const LAST_WORD_CAMELIZED_REGEX = /([\w/\s-]+)([A-Z][a-z\d]*$)/;
@@ -120,6 +126,7 @@ const PLURAL_RULES = new Map(defaultRules.plurals.reverse());
120
126
  * Marks a word as uncountable. Uncountable words are not pluralized
121
127
  * or singularized.
122
128
  *
129
+ * @summary Registers a word that `pluralize` and `singularize` should always return unchanged.
123
130
  * @public
124
131
  * @since 4.13.0
125
132
  */
@@ -130,6 +137,7 @@ function uncountable(word) {
130
137
  * Marks a list of words as uncountable. Uncountable words are not pluralized
131
138
  * or singularized.
132
139
  *
140
+ * @summary Registers a list of words that `pluralize` and `singularize` should always return unchanged.
133
141
  * @public
134
142
  * @since 4.13.0
135
143
  */
@@ -142,6 +150,8 @@ function loadUncountable(uncountables) {
142
150
  * Marks a word as irregular. Irregular words have unique
143
151
  * pluralization and singularization rules.
144
152
  *
153
+ * @summary Registers a singular and plural word pair that `pluralize` and `singularize` map directly instead of
154
+ * applying rules.
145
155
  * @public
146
156
  * @since 4.13.0
147
157
  */
@@ -155,6 +165,7 @@ function irregular(single, plur) {
155
165
  * Marks a list of word pairs as irregular. Irregular words have unique
156
166
  * pluralization and singularization rules.
157
167
  *
168
+ * @summary Registers a list of singular and plural word pairs that `pluralize` and `singularize` map directly.
158
169
  * @public
159
170
  * @since 4.13.0
160
171
  */
@@ -170,6 +181,7 @@ loadIrregular(defaultRules.irregularPairs);
170
181
  /**
171
182
  * Clears the caches for singularize and pluralize.
172
183
  *
184
+ * @summary Empties the cached results of `singularize` and `pluralize` while keeping all inflection rules.
173
185
  * @public
174
186
  * @since 4.13.0
175
187
  */
@@ -180,6 +192,7 @@ function clear() {
180
192
  /**
181
193
  * Resets the inflection rules to the defaults.
182
194
  *
195
+ * @summary Discards all custom inflection rules and caches, then restores the built-in default rules.
183
196
  * @public
184
197
  * @since 4.13.0
185
198
  */
@@ -194,6 +207,7 @@ function resetToDefaults() {
194
207
  * Clears all inflection rules
195
208
  * and resets the caches for singularize and pluralize.
196
209
  *
210
+ * @summary Removes every inflection rule, including the defaults, and empties the `singularize` and `pluralize` caches.
197
211
  * @public
198
212
  * @since 4.13.0
199
213
  */
@@ -209,6 +223,7 @@ function clearRules() {
209
223
  /**
210
224
  * Singularizes a word.
211
225
  *
226
+ * @summary Returns the singular form of an English word using the registered inflection rules, with cached results.
212
227
  * @public
213
228
  * @since 4.13.0
214
229
  */
@@ -222,6 +237,7 @@ function singularize(word) {
222
237
  /**
223
238
  * Pluralizes a word.
224
239
  *
240
+ * @summary Returns the plural form of an English word using the registered inflection rules, with cached results.
225
241
  * @public
226
242
  * @since 4.13.0
227
243
  */
@@ -242,6 +258,7 @@ function unshiftMap(v, map) {
242
258
  /**
243
259
  * Adds a pluralization rule.
244
260
  *
261
+ * @summary Adds a regex and replacement rule that `pluralize` checks before all existing plural rules.
245
262
  * @public
246
263
  * @since 4.13.0
247
264
  */
@@ -252,6 +269,7 @@ function plural(regex, string) {
252
269
  /**
253
270
  * Adds a singularization rule.
254
271
  *
272
+ * @summary Adds a regex and replacement rule that `singularize` checks before all existing singular rules.
255
273
  * @public
256
274
  * @since 4.13.0
257
275
  */
@@ -284,6 +302,5 @@ function inflect(word, typeRules, irregulars) {
284
302
  return word;
285
303
  }
286
304
 
287
- //#endregion
288
305
  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 };
289
- //# sourceMappingURL=string-j4ur-TDs.js.map
306
+ //# sourceMappingURL=string-D9jrClhQ.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"string-D9jrClhQ.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","test","Error","length","get","pluralize","unshiftMap","map","rules","entries","rule","plural","regex","string","has","delete","inflect","typeRules","irregulars","isBlank","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-mirror/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-mirror/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-mirror/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-mirror/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-mirror/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-mirror/core/build-config/macros';\nimport { LRUCache } from '@warp-drive-mirror/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,mBAAmB,IAAI,UAA0B,QACrD,IAAI,QAAQ,2BAA2B,UAAgC,MAAM,YAAY,CAAC,CAC5F;;;;;;;;;;;;;;;;;;AAmBA,MAAaA,cAAqCC;;;;;;;;;;;;;;;;;;;;AAqBlD,SAAgB,SAAS,KAAqB;CAC5C,OAAO,eAAe,IAAI,GAAG;AAC/B;;;;;;;;;;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sD,WAAWF,YAAYA,UAAU,EAAE,CAACpC,YAAY,IAAI;CAC1D,IAAIsC,YAAYlD,YAAYyC,IAAIS,QAAQ,GACtC,OAAOtD;CAIT,MAAMuD,cAAczD,gBAAgBkC,KAAKhC,IAAI;CAC7C,KAAK,IAAI,CAACyC,MAAMe,iBAAiBP,YAC/B,IAAIE,UAAUM,MAAMhB,OAAO,GAAG,GAAG;EAC/B,IAAIc,eAAeD,YAAYL,WAAWJ,IAAIS,QAAQ,GAAG;GACvDE,eAAe9D,WAAW8D,YAAY;GACtCf,OAAO/C,WAAW+C,IAAI;EACxB;EAEA,OAAOzC,KAAK0D,QAAQ,IAAIC,OAAOlB,MAAM,GAAG,GAAGe,YAAY;CACzD;CAIF,KAAK,MAAM,CAACf,MAAMe,iBAAiBR,WACjC,IAAIP,KAAKT,KAAKhC,IAAI,GAChB,OAAOA,KAAK0D,QAAQjB,MAAMe,YAAY;CAI1C,OAAOxD;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-j4ur-TDs.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-D9jrClhQ.js";
2
2
 
3
3
  export { camelize, capitalize, clear, clearRules, dasherize, irregular, loadIrregular, loadUncountable, plural, pluralize, resetToDefaults, setMaxLRUCacheSize, singular, singularize, uncountable, underscore };
@@ -1,3 +1,3 @@
1
- import { t as defaultRules } from "./inflections-DzBsjJqj.js";
1
+ import { t as defaultRules } from "./inflections-CWdUh2K_.js";
2
2
 
3
3
  export { defaultRules as InflectionRuleDefaults };
@@ -1,9 +1,9 @@
1
1
  import { buildBaseURL, buildQueryParams } from "./index.js";
2
- import { g as underscore, s as pluralize } from "./string-j4ur-TDs.js";
3
- import { n as extractCacheOptions, t as copyForwardUrlOptions } from "./builder-utils-BkXwUT0x.js";
2
+ import { g as underscore, s as pluralize } from "./string-D9jrClhQ.js";
3
+ import { n as extractCacheOptions, t as copyForwardUrlOptions } from "./builder-utils-bjXbHa-m.js";
4
4
  import { recordIdentifierFor } from "@warp-drive-mirror/core";
5
5
 
6
- //#region src/-private/active-record/find-record.ts
6
+ // src/-private/active-record/find-record.ts
7
7
  function findRecord(arg1, arg2, arg3) {
8
8
  const identifier = typeof arg1 === "string" ? {
9
9
  type: arg1,
@@ -30,8 +30,7 @@ function findRecord(arg1, arg2, arg3) {
30
30
  };
31
31
  }
32
32
 
33
- //#endregion
34
- //#region src/-private/active-record/query.ts
33
+ // src/-private/active-record/query.ts
35
34
  function query(type, query = {}, options = {}) {
36
35
  const cacheOptions = extractCacheOptions(options);
37
36
  const urlOptions = {
@@ -53,8 +52,7 @@ function query(type, query = {}, options = {}) {
53
52
  };
54
53
  }
55
54
 
56
- //#endregion
57
- //#region src/-private/active-record/save-record.ts
55
+ // src/-private/active-record/save-record.ts
58
56
  function isExisting(identifier) {
59
57
  return "id" in identifier && identifier.id !== null && "type" in identifier && identifier.type !== null;
60
58
  }
@@ -62,6 +60,9 @@ function isExisting(identifier) {
62
60
  * Builds request options to delete record for resources,
63
61
  * configured for the url, method and header expectations of ActiveRecord APIs.
64
62
  *
63
+ * See the [Builders](/guides/the-manual/requests/builders) guide for what request builders do and
64
+ * when to use one.
65
+ *
65
66
  * **Basic Usage**
66
67
  *
67
68
  * ```ts
@@ -103,6 +104,7 @@ function isExisting(identifier) {
103
104
  * const data = await store.request(options);
104
105
  * ```
105
106
  *
107
+ * @summary Builds a `DELETE` request that persists deletion of an existing record, using ActiveRecord-style URLs.
106
108
  * @public
107
109
  * @param record
108
110
  * @param options
@@ -137,6 +139,9 @@ function deleteRecord(record, options = {}) {
137
139
  * Builds request options to create new record for resources,
138
140
  * configured for the url, method and header expectations of most ActiveRecord APIs.
139
141
  *
142
+ * See the [Builders](/guides/the-manual/requests/builders) guide for what request builders do and
143
+ * when to use one.
144
+ *
140
145
  * **Basic Usage**
141
146
  *
142
147
  * ```ts
@@ -168,6 +173,7 @@ function deleteRecord(record, options = {}) {
168
173
  * const data = await store.request(options);
169
174
  * ```
170
175
  *
176
+ * @summary Builds a `POST` request that saves a newly created record, using ActiveRecord-style URLs.
171
177
  * @public
172
178
  * @param record
173
179
  * @param options
@@ -199,6 +205,9 @@ function createRecord(record, options = {}) {
199
205
  * Builds request options to update existing record for resources,
200
206
  * configured for the url, method and header expectations of most ActiveRecord APIs.
201
207
  *
208
+ * See the [Builders](/guides/the-manual/requests/builders) guide for what request builders do and
209
+ * when to use one.
210
+ *
202
211
  * **Basic Usage**
203
212
  *
204
213
  * ```ts
@@ -233,6 +242,7 @@ function createRecord(record, options = {}) {
233
242
  * const data = await store.request(options);
234
243
  * ```
235
244
  *
245
+ * @summary Builds a `PUT` (or `PATCH`) request that saves changes to an existing record, using ActiveRecord-style URLs.
236
246
  * @public
237
247
  * @param record
238
248
  * @param options
@@ -264,6 +274,5 @@ function updateRecord(record, options = {}) {
264
274
  };
265
275
  }
266
276
 
267
- //#endregion
268
277
  export { createRecord, deleteRecord, findRecord, query, updateRecord };
269
278
  //# sourceMappingURL=active-record.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"active-record.js","names":["recordIdentifierFor","buildBaseURL","pluralize","underscore","copyForwardUrlOptions","isExisting","identifier","id","type","deleteRecord","record","options","test","Error","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-mirror/core/reactive';\nimport type { TypeFromInstance } from '@warp-drive-mirror/core/types/record';\nimport type {\n FindRecordOptions,\n FindRecordRequestOptions,\n RemotelyAccessibleIdentifier,\n} from '@warp-drive-mirror/core/types/request';\nimport type { Meta } from '@warp-drive-mirror/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-mirror/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-mirror/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-mirror/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-mirror/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-mirror/core/reactive';\nimport type { QueryParamsSource } from '@warp-drive-mirror/core/types/params';\nimport type { TypeFromInstance } from '@warp-drive-mirror/core/types/record';\nimport type { ConstrainedRequestOptions, QueryRequestOptions } from '@warp-drive-mirror/core/types/request';\nimport type { Meta } from '@warp-drive-mirror/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-mirror/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-mirror/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-mirror/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-mirror/core';\nimport { assert } from '@warp-drive-mirror/core/build-config/macros';\nimport type { ReactiveDataDocument } from '@warp-drive-mirror/core/reactive';\nimport type { PersistedResourceKey, ResourceKey } from '@warp-drive-mirror/core/types/identifier';\nimport type { TypedRecordInstance } from '@warp-drive-mirror/core/types/record';\nimport type {\n ConstrainedRequestOptions,\n CreateRequestOptions,\n DeleteRequestOptions,\n UpdateRequestOptions,\n} from '@warp-drive-mirror/core/types/request';\nimport type { Meta } from '@warp-drive-mirror/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-mirror/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-mirror/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-mirror/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-mirror/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-mirror/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-mirror/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,oBAAoB,OAAO;CAChD,MAAM,aAA8B;EAClC,YAAY,EAAE,KAAK;EACnB,IAAI;EACJ,cAAc,UAAU,WAAW,IAAI,CAAC;CAC1C;CAEA,sBAAsB,YAAY,OAAO;CAEzC,MAAM,MAAM,aAAa,UAAU;CACnC,MAAM,UAAU,IAAI,QAAQ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,UAAU;CAE3D,MAAMQ,aAAqC;EAC7BR;EACZS,IAAI;EACJC,cAAcd,UAAUC,WAAWG,WAAWE,IAAI,CAAC;CACrD;CAEAJ,sBAAsBU,YAAYH,OAAO;CAEzC,MAAMM,MAAMhB,aAAaa,UAAU;CACnC,MAAMI,UAAU,IAAIC,QAAQ;CAC5BD,QAAQE,OAAO,UAAU,gCAAgC;CAEzD,OAAO;EACLH;EACAI,QAAQ;EACRH;EACAH,IAAI;EACJO,MAAM,EACJZ,QAAQJ,WACV;EACAiB,SAAS,CAACjB,UAAU;CACtB;AACF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAyDA,SAAgBmB,aACdf,QACAC,UAA2D,CAAC,GACtC;CACtB,MAAML,aAAaN,oBAAoBU,MAAM;CAC7C,EAAAE,SAAA;EAAA,IAAA,CAAAA,MAAA,MAAA,IAAAC,MAAO,wCAAwC;CAAA,EAAA,CAAEP,UAAU;CAC3D,EAAAM,SAAA;EAAA,IAAA,CAAAA,MAAA,MAAA,IAAAC,MAAO,sEAAsE;CAAA,EAAA,CAAER,WAAWC,UAAU,CAAC;CAErG,MAAMQ,aAAqC;EAC7BR;EACZS,IAAI;EACJC,cAAcd,UAAUC,WAAWG,WAAWE,IAAI,CAAC;CACrD;CAEAJ,sBAAsBU,YAAYH,OAAO;CAEzC,MAAMM,MAAMhB,aAAaa,UAAU;CACnC,MAAMI,UAAU,IAAIC,QAAQ;CAC5BD,QAAQE,OAAO,UAAU,gCAAgC;CAEzD,OAAO;EACLH;EACAI,QAAQV,QAAQe,QAAQ,UAAU;EAClCR;EACAH,IAAI;EACJO,MAAM,EACJZ,QAAQJ,WACV;EACAiB,SAAS,CAACjB,UAAU;CACtB;AACF"}
1
+ {"version":3,"file":"active-record.js","names":["recordIdentifierFor","buildBaseURL","pluralize","underscore","copyForwardUrlOptions","isExisting","identifier","id","type","deleteRecord","record","options","test","Error","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-mirror/core/reactive';\nimport type { TypeFromInstance } from '@warp-drive-mirror/core/types/record';\nimport type {\n FindRecordOptions,\n FindRecordRequestOptions,\n RemotelyAccessibleIdentifier,\n} from '@warp-drive-mirror/core/types/request';\nimport type { Meta } from '@warp-drive-mirror/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-mirror/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-mirror/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-mirror/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-mirror/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-mirror/core/reactive';\nimport type { QueryParamsSource } from '@warp-drive-mirror/core/types/params';\nimport type { TypeFromInstance } from '@warp-drive-mirror/core/types/record';\nimport type { ConstrainedRequestOptions, QueryRequestOptions } from '@warp-drive-mirror/core/types/request';\nimport type { Meta } from '@warp-drive-mirror/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-mirror/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-mirror/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-mirror/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-mirror/core';\nimport { assert } from '@warp-drive-mirror/core/build-config/macros';\nimport type { ReactiveDataDocument } from '@warp-drive-mirror/core/reactive';\nimport type { PersistedResourceKey, ResourceKey } from '@warp-drive-mirror/core/types/identifier';\nimport type { TypedRecordInstance } from '@warp-drive-mirror/core/types/record';\nimport type {\n ConstrainedRequestOptions,\n CreateRequestOptions,\n DeleteRequestOptions,\n UpdateRequestOptions,\n} from '@warp-drive-mirror/core/types/request';\nimport type { Meta } from '@warp-drive-mirror/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-mirror/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-mirror/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-mirror/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-mirror/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-mirror/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-mirror/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,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BAAoBU,MAAM;CAC7C,EAAAE,SAAA;EAAA,IAAA,CAAAA,MAAA,MAAA,IAAAC,MAAO,wCAAwC;CAAA,EAAA,CAAEP,UAAU;CAC3D,EAAAM,SAAA;EAAA,IAAA,CAAAA,MAAA,MAAA,IAAAC,MAAO,sEAAsE;CAAA,EAAA,CAAER,WAAWC,UAAU,CAAC;CAErG,MAAMQ,aAAqC;EAC7BR;EACZS,IAAI;EACJC,cAAcd,UAAUC,WAAWG,WAAWE,IAAI,CAAC;CACrD;CAEAJ,sBAAsBU,YAAYH,OAAO;CAEzC,MAAMM,MAAMhB,aAAaa,UAAU;CACnC,MAAMI,UAAU,IAAIC,QAAQ;CAC5BD,QAAQE,OAAO,UAAU,gCAAgC;CAEzD,OAAO;EACLH;EACAI,QAAQV,QAAQe,QAAQ,UAAU;EAClCR;EACAH,IAAI;EACJO,MAAM,EACJZ,QAAQJ,WACV;EACAiB,SAAS,CAACjB,UAAU;CACtB;AACF"}
@@ -1,4 +1,4 @@
1
- //#region src/-private/builder-utils.ts
1
+ // src/-private/builder-utils.ts
2
2
  function copyForwardUrlOptions(urlOptions, options) {
3
3
  if ("host" in options) urlOptions.host = options.host;
4
4
  if ("namespace" in options) urlOptions.namespace = options.namespace;
@@ -11,6 +11,5 @@ function extractCacheOptions(options) {
11
11
  return cacheOptions;
12
12
  }
13
13
 
14
- //#endregion
15
14
  export { extractCacheOptions as n, copyForwardUrlOptions as t };
16
- //# sourceMappingURL=builder-utils-BkXwUT0x.js.map
15
+ //# sourceMappingURL=builder-utils-bjXbHa-m.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"builder-utils-BkXwUT0x.js","names":[],"sources":["../../../src/-private/builder-utils.ts"],"sourcesContent":["import type { CacheOptions, ConstrainedRequestOptions } from '@warp-drive-mirror/core/types/request';\n\nimport type { UrlOptions } from '../index.ts';\n\nexport function copyForwardUrlOptions(urlOptions: UrlOptions, options: ConstrainedRequestOptions): void {\n if ('host' in options) {\n urlOptions.host = options.host;\n }\n if ('namespace' in options) {\n urlOptions.namespace = options.namespace;\n }\n if ('resourcePath' in options) {\n urlOptions.resourcePath = options.resourcePath;\n }\n}\n\nexport function extractCacheOptions(options: ConstrainedRequestOptions): CacheOptions {\n const cacheOptions: CacheOptions = {};\n if ('reload' in options) {\n cacheOptions.reload = options.reload;\n }\n if ('backgroundReload' in options) {\n cacheOptions.backgroundReload = options.backgroundReload;\n }\n return cacheOptions;\n}\n"],"mappings":";AAIA,SAAgB,sBAAsB,YAAwB,SAA0C;CACtG,IAAI,UAAU,SACZ,WAAW,OAAO,QAAQ;CAE5B,IAAI,eAAe,SACjB,WAAW,YAAY,QAAQ;CAEjC,IAAI,kBAAkB,SACpB,WAAW,eAAe,QAAQ;AAEtC;AAEA,SAAgB,oBAAoB,SAAkD;CACpF,MAAM,eAA6B,CAAC;CACpC,IAAI,YAAY,SACd,aAAa,SAAS,QAAQ;CAEhC,IAAI,sBAAsB,SACxB,aAAa,mBAAmB,QAAQ;CAE1C,OAAO;AACT"}
1
+ {"version":3,"file":"builder-utils-bjXbHa-m.js","names":[],"sources":["../../../src/-private/builder-utils.ts"],"sourcesContent":["import type { CacheOptions, ConstrainedRequestOptions } from '@warp-drive-mirror/core/types/request';\n\nimport type { UrlOptions } from '../index.ts';\n\nexport function copyForwardUrlOptions(urlOptions: UrlOptions, options: ConstrainedRequestOptions): void {\n if ('host' in options) {\n urlOptions.host = options.host;\n }\n if ('namespace' in options) {\n urlOptions.namespace = options.namespace;\n }\n if ('resourcePath' in options) {\n urlOptions.resourcePath = options.resourcePath;\n }\n}\n\nexport function extractCacheOptions(options: ConstrainedRequestOptions): CacheOptions {\n const cacheOptions: CacheOptions = {};\n if ('reload' in options) {\n cacheOptions.reload = options.reload;\n }\n if ('backgroundReload' in options) {\n cacheOptions.backgroundReload = options.backgroundReload;\n }\n return cacheOptions;\n}\n"],"mappings":";AAIA,SAAgB,sBAAsB,YAAwB,SAA0C;CACtG,IAAI,UAAU,SACZ,WAAW,OAAO,QAAQ;CAE5B,IAAI,eAAe,SACjB,WAAW,YAAY,QAAQ;CAEjC,IAAI,kBAAkB,SACpB,WAAW,eAAe,QAAQ;AAEtC;AAEA,SAAgB,oBAAoB,SAAkD;CACpF,MAAM,eAA6B,CAAC;CACpC,IAAI,YAAY,SACd,aAAa,SAAS,QAAQ;CAEhC,IAAI,sBAAsB,SACxB,aAAa,mBAAmB,QAAQ;CAE1C,OAAO;AACT"}
@@ -1,12 +1,18 @@
1
1
  import { Type } from "@warp-drive-mirror/core/types/symbols";
2
2
 
3
- //#region src/derivations.ts
3
+ // src/derivations.ts
4
+ /**
5
+ * @module
6
+ * @summary The `concat` derivation, which joins a record's listed fields into one string with an optional separator.
7
+ */
4
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',
@@ -25,6 +31,5 @@ const concat = (record, options, _prop) => {
25
31
  };
26
32
  concat[Type] = "concat";
27
33
 
28
- //#endregion
29
34
  export { concat };
30
35
  //# sourceMappingURL=derivations.js.map
@@ -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-mirror/core/reactive';\nimport { Type } from '@warp-drive-mirror/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-mirror/core/reactive';\nimport { Type } from '@warp-drive-mirror/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"}
@@ -1,4 +1,4 @@
1
- //#region src/-private/handlers/auto-compress.ts
1
+ // src/-private/handlers/auto-compress.ts
2
2
  function isCompressibleMethod(method) {
3
3
  return method === "POST" || method === "PUT" || method === "PATCH" || method === "DELETE";
4
4
  }
@@ -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 = (() => {
@@ -21,8 +23,17 @@ const SupportsRequestStreams = (() => {
21
23
  return duplexAccessed && !hasContentType;
22
24
  })();
23
25
  /**
24
- * Options for configuring the AutoCompress handler.
26
+ * The minimum body size, per body type, at which {@link AutoCompress} compresses a request
27
+ * body. Passed as {@link CompressionOptions.constraints}.
25
28
  *
29
+ * @summary Minimum request body sizes, per body type, at which `AutoCompress` compresses a body.
30
+ * @public
31
+ */
32
+ /**
33
+ * Options for configuring the {@link AutoCompress} handler.
34
+ *
35
+ * @summary Options for `new AutoCompress()`: the compression format, size constraints and whether to stream the body.
36
+ * @public
26
37
  */
27
38
  const DEFAULT_CONSTRAINTS = {
28
39
  Blob: 1e3,
@@ -56,6 +67,8 @@ const TypedArray = Object.getPrototypeOf(Uint8Array);
56
67
  * }
57
68
  * ```
58
69
  *
70
+ * @summary Request handler that compresses large `POST`, `PUT`, `PATCH`, and `DELETE` bodies with `CompressionStream`,
71
+ * optionally streaming them.
59
72
  * @group Handlers
60
73
  * @public
61
74
  * @since 5.5.0
@@ -117,14 +130,15 @@ function encodingForFormat(format) {
117
130
  }
118
131
  }
119
132
 
120
- //#endregion
121
- //#region src/-private/handlers/gated.ts
133
+ // src/-private/handlers/gated.ts
122
134
  /**
123
135
  * If CheckFn returns true, the wrapped handler will be used.
124
136
  * If CheckFn returns false, the wrapped handler will be skipped.
125
137
  */
126
138
  /**
127
139
  *
140
+ * @summary Request handler that wraps another handler and runs it only when a check function returns true for the
141
+ * request.
128
142
  * @group Handlers
129
143
  * @public
130
144
  */
@@ -145,8 +159,7 @@ var Gate = class {
145
159
  }
146
160
  };
147
161
 
148
- //#endregion
149
- //#region src/-private/handlers/meta-doc.ts
162
+ // src/-private/handlers/meta-doc.ts
150
163
  /**
151
164
  * MetaDocHandler processes requests that are marked as meta requests.
152
165
  *
@@ -190,6 +203,7 @@ var Gate = class {
190
203
  * Errors are not processed by this handler, so if the request fails and the error response
191
204
  * is not in {json:api} format additional processing may be needed.
192
205
  *
206
+ * @summary Request handler that wraps the whole response body in `meta` for requests with `options.isMetaRequest` set.
193
207
  * @group Handlers
194
208
  */
195
209
  const MetaDocHandler = { request(context, next) {
@@ -202,8 +216,7 @@ function processResponse(response) {
202
216
  return { meta: response.content };
203
217
  }
204
218
 
205
- //#endregion
206
- //#region src/-private/handlers/utils.ts
219
+ // src/-private/handlers/utils.ts
207
220
  if (typeof FastBoot === "undefined") globalThis.addEventListener("beforeunload", function() {
208
221
  sessionStorage.setItem("tab-closed", "true");
209
222
  });
@@ -222,12 +235,15 @@ function getTabId() {
222
235
  * useful for observability/tracing and deduping
223
236
  * across multiple tabs.
224
237
  *
238
+ * @summary Random UUID identifying the current browser tab, kept in `sessionStorage` across reloads, for request
239
+ * tracing.
225
240
  * @group Constants
226
241
  */
227
242
  const TAB_ID = getTabId();
228
243
  /**
229
244
  * The epoch seconds at which the tab id was generated
230
245
  *
246
+ * @summary Epoch seconds recorded when this module loaded, paired with `TAB_ID` in trace headers.
231
247
  * @group Constants
232
248
  */
233
249
  const TAB_ASSIGNED = Math.floor(Date.now() / 1e3);
@@ -240,6 +256,8 @@ const TAB_ASSIGNED = Math.floor(Date.now() / 1e3);
240
256
  *
241
257
  * Follows the template: `Root=1-${now}-${uuidv4};TabId=1-${epochSeconds}-${tab-uuid}`
242
258
  *
259
+ * @summary Sets an `X-Amzn-Trace-Id` header carrying a per-request id and the tab id, so requests can be traced to
260
+ * their browser tab.
243
261
  * @group Utility Functions
244
262
  */
245
263
  function addTraceHeader(headers) {
@@ -251,6 +269,7 @@ function addTraceHeader(headers) {
251
269
  * Source: https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/cloudfront-limits.html
252
270
  * As of 2024-12-05 the maximum URL length is 8192 bytes.
253
271
  *
272
+ * @summary The 8192-byte URL length limit, taken from AWS CloudFront, that `assertInvalidUrlLength` checks against.
254
273
  * @group Constants
255
274
  */
256
275
  const MAX_URL_LENGTH = 8192;
@@ -259,6 +278,8 @@ const MAX_URL_LENGTH = 8192;
259
278
  *
260
279
  * See also {@link MAX_URL_LENGTH}
261
280
  *
281
+ * @summary Dev-mode assertion that throws when a URL is longer than `MAX_URL_LENGTH`, suggesting a `POST` or `QUERY`
282
+ * request instead.
262
283
  * @group Utility Functions
263
284
  */
264
285
  function assertInvalidUrlLength(url) {
@@ -267,6 +288,5 @@ function assertInvalidUrlLength(url) {
267
288
  })(!url || url.length <= 8192);
268
289
  }
269
290
 
270
- //#endregion
271
291
  export { AutoCompress, Gate, MAX_URL_LENGTH, MetaDocHandler, SupportsRequestStreams, TAB_ASSIGNED, TAB_ID, addTraceHeader, assertInvalidUrlLength };
272
292
  //# sourceMappingURL=handlers.js.map