@warp-drive-mirror/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.
- package/README.md +92 -7
- package/cjs-dist/string.cjs +19 -0
- package/cjs-dist/string.cjs.map +1 -1
- package/dist/active-record.d.ts +21 -0
- package/dist/active-record.d.ts.map +1 -1
- package/dist/active-record.js +13 -1
- package/dist/active-record.js.map +1 -1
- package/dist/derivations.d.ts +2 -0
- package/dist/derivations.d.ts.map +1 -1
- package/dist/derivations.js +6 -0
- package/dist/derivations.js.map +1 -1
- package/dist/handlers.d.ts +15 -0
- package/dist/handlers.d.ts.map +1 -1
- package/dist/handlers.js +15 -0
- package/dist/handlers.js.map +1 -1
- package/dist/{index-D6QIwzqm.d.ts → index-Ds06tKwC.d.ts} +39 -1
- package/dist/index-Ds06tKwC.d.ts.map +1 -0
- package/dist/index.d.ts +1 -1
- package/dist/index.js +39 -0
- package/dist/index.js.map +1 -1
- package/dist/json-api.d.ts +36 -1
- package/dist/json-api.d.ts.map +1 -1
- package/dist/json-api.js +23 -1
- package/dist/json-api.js.map +1 -1
- package/dist/rest.d.ts +20 -0
- package/dist/rest.d.ts.map +1 -1
- package/dist/rest.js +13 -1
- package/dist/rest.js.map +1 -1
- package/dist/{string-CWmAluxh.js → string-BZACNuLp.js} +20 -1
- package/dist/string-BZACNuLp.js.map +1 -0
- package/dist/string.d.ts +19 -0
- package/dist/string.d.ts.map +1 -1
- package/dist/string.js +1 -1
- package/dist/unpkg/dev/active-record.js +13 -1
- package/dist/unpkg/dev/active-record.js.map +1 -1
- package/dist/unpkg/dev/derivations.js +6 -0
- package/dist/unpkg/dev/derivations.js.map +1 -1
- package/dist/unpkg/dev/handlers.js +15 -0
- package/dist/unpkg/dev/handlers.js.map +1 -1
- package/dist/unpkg/dev/index.js +39 -0
- package/dist/unpkg/dev/index.js.map +1 -1
- package/dist/unpkg/dev/json-api.js +23 -1
- package/dist/unpkg/dev/json-api.js.map +1 -1
- package/dist/unpkg/dev/rest.js +13 -1
- package/dist/unpkg/dev/rest.js.map +1 -1
- package/dist/unpkg/dev/{string-j4ur-TDs.js → string-I8KHJXV7.js} +20 -1
- package/dist/unpkg/dev/string-I8KHJXV7.js.map +1 -0
- package/dist/unpkg/dev/string.js +1 -1
- package/dist/unpkg/dev-deprecated/active-record.js +13 -1
- package/dist/unpkg/dev-deprecated/active-record.js.map +1 -1
- package/dist/unpkg/dev-deprecated/derivations.js +6 -0
- package/dist/unpkg/dev-deprecated/derivations.js.map +1 -1
- package/dist/unpkg/dev-deprecated/handlers.js +15 -0
- package/dist/unpkg/dev-deprecated/handlers.js.map +1 -1
- package/dist/unpkg/dev-deprecated/index.js +39 -0
- package/dist/unpkg/dev-deprecated/index.js.map +1 -1
- package/dist/unpkg/dev-deprecated/json-api.js +23 -1
- package/dist/unpkg/dev-deprecated/json-api.js.map +1 -1
- package/dist/unpkg/dev-deprecated/rest.js +13 -1
- package/dist/unpkg/dev-deprecated/rest.js.map +1 -1
- package/dist/unpkg/dev-deprecated/{string-j4ur-TDs.js → string-I8KHJXV7.js} +20 -1
- package/dist/unpkg/dev-deprecated/string-I8KHJXV7.js.map +1 -0
- package/dist/unpkg/dev-deprecated/string.js +1 -1
- package/dist/unpkg/prod/active-record.js +13 -1
- package/dist/unpkg/prod/active-record.js.map +1 -1
- package/dist/unpkg/prod/derivations.js +6 -0
- package/dist/unpkg/prod/derivations.js.map +1 -1
- package/dist/unpkg/prod/handlers.js +15 -0
- package/dist/unpkg/prod/handlers.js.map +1 -1
- package/dist/unpkg/prod/index.js +39 -0
- package/dist/unpkg/prod/index.js.map +1 -1
- package/dist/unpkg/prod/json-api.js +23 -1
- package/dist/unpkg/prod/json-api.js.map +1 -1
- package/dist/unpkg/prod/rest.js +13 -1
- package/dist/unpkg/prod/rest.js.map +1 -1
- package/dist/unpkg/prod/string-D8BEYx2W.js +302 -0
- package/dist/unpkg/prod/string-D8BEYx2W.js.map +1 -0
- package/dist/unpkg/prod/string.js +1 -1
- package/dist/unpkg/prod-deprecated/active-record.js +13 -1
- package/dist/unpkg/prod-deprecated/active-record.js.map +1 -1
- package/dist/unpkg/prod-deprecated/derivations.js +6 -0
- package/dist/unpkg/prod-deprecated/derivations.js.map +1 -1
- package/dist/unpkg/prod-deprecated/handlers.js +15 -0
- package/dist/unpkg/prod-deprecated/handlers.js.map +1 -1
- package/dist/unpkg/prod-deprecated/index.js +39 -0
- package/dist/unpkg/prod-deprecated/index.js.map +1 -1
- package/dist/unpkg/prod-deprecated/json-api.js +23 -1
- package/dist/unpkg/prod-deprecated/json-api.js.map +1 -1
- package/dist/unpkg/prod-deprecated/rest.js +13 -1
- package/dist/unpkg/prod-deprecated/rest.js.map +1 -1
- package/dist/unpkg/prod-deprecated/{string-T1ahjLdj.js → string-D8BEYx2W.js} +20 -1
- package/dist/unpkg/prod-deprecated/string-D8BEYx2W.js.map +1 -0
- package/dist/unpkg/prod-deprecated/string.js +1 -1
- package/package.json +6 -6
- package/dist/index-D6QIwzqm.d.ts.map +0 -1
- package/dist/string-CWmAluxh.js.map +0 -1
- package/dist/unpkg/dev/string-j4ur-TDs.js.map +0 -1
- package/dist/unpkg/dev-deprecated/string-j4ur-TDs.js.map +0 -1
- package/dist/unpkg/prod/string-T1ahjLdj.js +0 -283
- package/dist/unpkg/prod/string-T1ahjLdj.js.map +0 -1
- package/dist/unpkg/prod-deprecated/string-T1ahjLdj.js.map +0 -1
package/README.md
CHANGED
|
@@ -8,13 +8,11 @@
|
|
|
8
8
|
/>
|
|
9
9
|
</p>
|
|
10
10
|
|
|
11
|
-

|
|
12
|
+

|
|
13
13
|

|
|
14
|
-
[](https://discord.gg/zT3asNS
|
|
15
|
-
)
|
|
16
|
-
[](https://discord.gg/PHBbnWJx5S
|
|
17
|
-
)
|
|
14
|
+
[](https://discord.gg/zT3asNS)
|
|
15
|
+
[](https://discord.gg/PHBbnWJx5S)
|
|
18
16
|
|
|
19
17
|
# @warp-drive-mirror/utilities
|
|
20
18
|
|
|
@@ -25,12 +23,39 @@
|
|
|
25
23
|
Utilities that Apps building with <em>Warp</em><strong>Drive</strong> may find useful.
|
|
26
24
|
</p>
|
|
27
25
|
|
|
26
|
+
## Usage
|
|
27
|
+
|
|
28
|
+
Build URLs and query strings, or use the request builders that compose them:
|
|
29
|
+
|
|
30
|
+
```ts
|
|
31
|
+
import { buildBaseURL, buildQueryParams } from '@warp-drive-mirror/utilities';
|
|
32
|
+
|
|
33
|
+
const baseURL = buildBaseURL({
|
|
34
|
+
host: 'https://api.example.com',
|
|
35
|
+
namespace: 'api/v1',
|
|
36
|
+
resourcePath: 'emberDevelopers',
|
|
37
|
+
op: 'query',
|
|
38
|
+
identifier: { type: 'ember-developer' }
|
|
39
|
+
});
|
|
40
|
+
const url = `${baseURL}?${buildQueryParams({ name: 'Chris', include:['pets'] })}`;
|
|
41
|
+
// => 'https://api.example.com/api/v1/emberDevelopers?include=pets&name=Chris'
|
|
42
|
+
```
|
|
43
|
+
|
|
28
44
|
<br>
|
|
29
45
|
|
|
30
46
|
## Documentation
|
|
31
47
|
|
|
32
|
-
*Get Started* → [Guides](https://
|
|
48
|
+
*Get Started* → [Guides](https://warp-drive.io/guides/)
|
|
49
|
+
|
|
50
|
+
API docs for this package → [@warp-drive-mirror/utilities](https://warp-drive.io/api/@warp-drive-mirror/utilities/)
|
|
33
51
|
|
|
52
|
+
- [Installation](https://warp-drive.io/guides/installation/#other-packages): install `@warp-drive-mirror/utilities` at the same version as `@warp-drive-mirror/core`.
|
|
53
|
+
- [Builders](https://warp-drive.io/guides/the-manual/requests/builders): write request builders, and keep cache keys stable with `sortQueryParams`, `buildQueryParams` and `filterEmpty`.
|
|
54
|
+
- [Making Requests](https://warp-drive.io/guides/the-manual/requests/): make a request with the `findRecord` builder, and the `AutoCompress` and `Gate` handlers.
|
|
55
|
+
- [Handlers](https://warp-drive.io/guides/the-manual/requests/handlers): normalize a response with `dasherize` and `singularize` from `@warp-drive-mirror/utilities/string`.
|
|
56
|
+
- [Typing Requests](https://warp-drive.io/guides/the-manual/requests/typing-requests): pass a response's meta type to the builders.
|
|
57
|
+
- [Basic Usage](https://warp-drive.io/guides/the-manual/cookbook/basic-usage): configure `setBuildURLConfig` and page through results with the `query` builder.
|
|
58
|
+
- [Naming Conventions](https://warp-drive.io/guides/the-manual/cookbook/naming-conventions): how `findRecord` turns a resource type into a URL path.
|
|
34
59
|
|
|
35
60
|
<br>
|
|
36
61
|
|
|
@@ -43,3 +68,63 @@ Refer to the [Code of Conduct](https://github.com/warp-drive-data/warp-drive/blo
|
|
|
43
68
|
### License
|
|
44
69
|
|
|
45
70
|
This project is licensed under the [MIT License](LICENSE.md).
|
|
71
|
+
|
|
72
|
+
### ♥️ Credits
|
|
73
|
+
|
|
74
|
+
<details>
|
|
75
|
+
<summary>Brought to you with ♥️ love by <a href="https://emberjs.com" title="EmberJS">🐹 Ember</a></summary>
|
|
76
|
+
|
|
77
|
+
<style type="text/css">
|
|
78
|
+
img.project-logo {
|
|
79
|
+
padding: 0 5em 1em 5em;
|
|
80
|
+
width: 100px;
|
|
81
|
+
border-bottom: 2px solid #bbb;
|
|
82
|
+
margin: 0 auto;
|
|
83
|
+
display: block;
|
|
84
|
+
}
|
|
85
|
+
details > summary {
|
|
86
|
+
font-size: 1.1rem;
|
|
87
|
+
line-height: 1rem;
|
|
88
|
+
margin-bottom: 1rem;
|
|
89
|
+
}
|
|
90
|
+
details {
|
|
91
|
+
font-size: 1rem;
|
|
92
|
+
}
|
|
93
|
+
details > summary strong {
|
|
94
|
+
display: inline-block;
|
|
95
|
+
padding: .2rem 0;
|
|
96
|
+
color: #000;
|
|
97
|
+
border-bottom: 3px solid #bbb;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
details > details {
|
|
101
|
+
margin-left: 2rem;
|
|
102
|
+
}
|
|
103
|
+
details > details > summary {
|
|
104
|
+
font-size: 1rem;
|
|
105
|
+
line-height: 1rem;
|
|
106
|
+
margin-bottom: 1rem;
|
|
107
|
+
}
|
|
108
|
+
details > details > summary strong {
|
|
109
|
+
display: inline-block;
|
|
110
|
+
padding: .2rem 0;
|
|
111
|
+
color: #555;
|
|
112
|
+
border-bottom: 2px solid #555;
|
|
113
|
+
}
|
|
114
|
+
details > details {
|
|
115
|
+
font-size: .85rem;
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
@media (prefers-color-scheme: dark) {
|
|
119
|
+
details > summary strong {
|
|
120
|
+
color: #fff;
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
@media (prefers-color-scheme: dark) {
|
|
124
|
+
details > details > summary strong {
|
|
125
|
+
color: #afaba0;
|
|
126
|
+
border-bottom: 2px solid #afaba0;
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
</style>
|
|
130
|
+
</details>
|
package/cjs-dist/string.cjs
CHANGED
|
@@ -173,6 +173,7 @@ const CAPITALIZE_CACHE = new LRUCache((str) => str.replace(STRING_CAPITALIZE_REG
|
|
|
173
173
|
* dasherize('privateDocs/ownerInvoice'; // 'private-docs/owner-invoice'
|
|
174
174
|
* ```
|
|
175
175
|
*
|
|
176
|
+
* @summary Converts camelCase, underscored, or spaced strings to dasherized form, such as `innerHTML` to `inner-html`.
|
|
176
177
|
* @public
|
|
177
178
|
* @since 4.13.0
|
|
178
179
|
*/
|
|
@@ -191,6 +192,8 @@ const dasherize = dasherize$1;
|
|
|
191
192
|
* camelize('private-docs/owner-invoice'); // 'privateDocs/ownerInvoice'
|
|
192
193
|
* ```
|
|
193
194
|
*
|
|
195
|
+
* @summary Converts dashed, underscored, dotted, or spaced strings to lowerCamelCase, such as `action_name` to
|
|
196
|
+
* `actionName`.
|
|
194
197
|
* @public
|
|
195
198
|
* @since 4.13.0
|
|
196
199
|
*/
|
|
@@ -210,6 +213,7 @@ function camelize(str) {
|
|
|
210
213
|
* underscore('privateDocs/ownerInvoice'); // 'private_docs/owner_invoice'
|
|
211
214
|
* ```
|
|
212
215
|
*
|
|
216
|
+
* @summary Converts camelCase, dashed, or spaced strings to lowercase snake_case, such as `innerHTML` to `inner_html`.
|
|
213
217
|
* @public
|
|
214
218
|
* @since 4.13.0
|
|
215
219
|
*/
|
|
@@ -229,6 +233,7 @@ function underscore(str) {
|
|
|
229
233
|
* capitalize('privateDocs/ownerInvoice'); // 'PrivateDocs/ownerInvoice'
|
|
230
234
|
* ```
|
|
231
235
|
*
|
|
236
|
+
* @summary Uppercases the first letter of a string, and of each `/`-separated path segment, leaving the rest unchanged.
|
|
232
237
|
* @public
|
|
233
238
|
* @since 4.13.0
|
|
234
239
|
*/
|
|
@@ -239,6 +244,8 @@ function capitalize(str) {
|
|
|
239
244
|
* Sets the maximum size of the LRUCache for all string transformation functions.
|
|
240
245
|
* The default size is 10,000.
|
|
241
246
|
*
|
|
247
|
+
* @summary Sets how many results the `camelize`, `underscore`, `capitalize`, and `dasherize` caches each keep (default
|
|
248
|
+
* 10,000).
|
|
242
249
|
* @public
|
|
243
250
|
* @since 4.13.0
|
|
244
251
|
*/
|
|
@@ -270,6 +277,7 @@ const PLURAL_RULES = new Map(defaultRules.plurals.reverse());
|
|
|
270
277
|
* Marks a word as uncountable. Uncountable words are not pluralized
|
|
271
278
|
* or singularized.
|
|
272
279
|
*
|
|
280
|
+
* @summary Registers a word that `pluralize` and `singularize` should always return unchanged.
|
|
273
281
|
* @public
|
|
274
282
|
* @since 4.13.0
|
|
275
283
|
*/
|
|
@@ -280,6 +288,7 @@ function uncountable(word) {
|
|
|
280
288
|
* Marks a list of words as uncountable. Uncountable words are not pluralized
|
|
281
289
|
* or singularized.
|
|
282
290
|
*
|
|
291
|
+
* @summary Registers a list of words that `pluralize` and `singularize` should always return unchanged.
|
|
283
292
|
* @public
|
|
284
293
|
* @since 4.13.0
|
|
285
294
|
*/
|
|
@@ -292,6 +301,8 @@ function loadUncountable(uncountables) {
|
|
|
292
301
|
* Marks a word as irregular. Irregular words have unique
|
|
293
302
|
* pluralization and singularization rules.
|
|
294
303
|
*
|
|
304
|
+
* @summary Registers a singular and plural word pair that `pluralize` and `singularize` map directly instead of
|
|
305
|
+
* applying rules.
|
|
295
306
|
* @public
|
|
296
307
|
* @since 4.13.0
|
|
297
308
|
*/
|
|
@@ -305,6 +316,7 @@ function irregular(single, plur) {
|
|
|
305
316
|
* Marks a list of word pairs as irregular. Irregular words have unique
|
|
306
317
|
* pluralization and singularization rules.
|
|
307
318
|
*
|
|
319
|
+
* @summary Registers a list of singular and plural word pairs that `pluralize` and `singularize` map directly.
|
|
308
320
|
* @public
|
|
309
321
|
* @since 4.13.0
|
|
310
322
|
*/
|
|
@@ -320,6 +332,7 @@ loadIrregular(defaultRules.irregularPairs);
|
|
|
320
332
|
/**
|
|
321
333
|
* Clears the caches for singularize and pluralize.
|
|
322
334
|
*
|
|
335
|
+
* @summary Empties the cached results of `singularize` and `pluralize` while keeping all inflection rules.
|
|
323
336
|
* @public
|
|
324
337
|
* @since 4.13.0
|
|
325
338
|
*/
|
|
@@ -330,6 +343,7 @@ function clear() {
|
|
|
330
343
|
/**
|
|
331
344
|
* Resets the inflection rules to the defaults.
|
|
332
345
|
*
|
|
346
|
+
* @summary Discards all custom inflection rules and caches, then restores the built-in default rules.
|
|
333
347
|
* @public
|
|
334
348
|
* @since 4.13.0
|
|
335
349
|
*/
|
|
@@ -344,6 +358,7 @@ function resetToDefaults() {
|
|
|
344
358
|
* Clears all inflection rules
|
|
345
359
|
* and resets the caches for singularize and pluralize.
|
|
346
360
|
*
|
|
361
|
+
* @summary Removes every inflection rule, including the defaults, and empties the `singularize` and `pluralize` caches.
|
|
347
362
|
* @public
|
|
348
363
|
* @since 4.13.0
|
|
349
364
|
*/
|
|
@@ -359,6 +374,7 @@ function clearRules() {
|
|
|
359
374
|
/**
|
|
360
375
|
* Singularizes a word.
|
|
361
376
|
*
|
|
377
|
+
* @summary Returns the singular form of an English word using the registered inflection rules, with cached results.
|
|
362
378
|
* @public
|
|
363
379
|
* @since 4.13.0
|
|
364
380
|
*/
|
|
@@ -369,6 +385,7 @@ function singularize(word) {
|
|
|
369
385
|
/**
|
|
370
386
|
* Pluralizes a word.
|
|
371
387
|
*
|
|
388
|
+
* @summary Returns the plural form of an English word using the registered inflection rules, with cached results.
|
|
372
389
|
* @public
|
|
373
390
|
* @since 4.13.0
|
|
374
391
|
*/
|
|
@@ -386,6 +403,7 @@ function unshiftMap(v, map) {
|
|
|
386
403
|
/**
|
|
387
404
|
* Adds a pluralization rule.
|
|
388
405
|
*
|
|
406
|
+
* @summary Adds a regex and replacement rule that `pluralize` checks before all existing plural rules.
|
|
389
407
|
* @public
|
|
390
408
|
* @since 4.13.0
|
|
391
409
|
*/
|
|
@@ -396,6 +414,7 @@ function plural(regex, string) {
|
|
|
396
414
|
/**
|
|
397
415
|
* Adds a singularization rule.
|
|
398
416
|
*
|
|
417
|
+
* @summary Adds a regex and replacement rule that `singularize` checks before all existing singular rules.
|
|
399
418
|
* @public
|
|
400
419
|
* @since 4.13.0
|
|
401
420
|
*/
|
package/cjs-dist/string.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"string.cjs","names":["DEFAULT_MAX_CACHE_SIZE","LRUCache","constructor","doWork","size","state","Map","get","key","value","delete","set","newValue","k","clear","STRING_DASHERIZE_REGEXP","STRING_DECAMELIZE_REGEXP","STRING_DASHERIZE_CACHE","replace","toLowerCase","dasherize","str","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":["../../../node_modules/.pnpm/@warp-d_5e1563e0e582c8365bb74466d3761d6d/node_modules/@warp-drive-mirror/core/dist/utils/string.js","../src/-private/string/inflections.ts","../src/-private/string/transform.ts","../src/-private/string/inflect.ts"],"sourcesContent":["import { DEBUG } from '@warp-drive-mirror/core/build-config/env';\n\nconst DEFAULT_MAX_CACHE_SIZE = 10_000;\n\n/**\n * An LRUCache implementation with upsert semantics.\n *\n * This implementation is *not* generic, but focuses on\n * performance tuning for the string transformation cases\n * where the key maps to the value very simply.\n *\n * It takes a work function that should generate a new value\n * for a given key when called. It will be called when the key\n * is not found in the cache.\n *\n * It keeps track of the number of hits, misses, and ejections\n * in DEBUG envs, which is useful for tuning the cache size.\n *\n * This is an internal utility class for use by this module\n * and by `@warp-drive-mirror/utilities/string`. It is not intended\n * for use outside of these modules at this time.\n *\n * @private\n */\nexport class LRUCache<T, V> {\n declare size: number;\n declare state: Map<T, V>;\n declare doWork: (k: T) => V;\n\n // debug stats\n declare _hits: number;\n declare _misses: number;\n declare _ejected: number;\n\n constructor(doWork: (k: T) => V, size?: number) {\n this.size = size || DEFAULT_MAX_CACHE_SIZE;\n this.state = new Map();\n this.doWork = doWork;\n\n if (DEBUG) {\n this._hits = 0;\n this._misses = 0;\n this._ejected = 0;\n }\n }\n\n get(key: T): V {\n const value = this.state.get(key);\n if (value) {\n if (DEBUG) {\n this._hits++;\n }\n this.state.delete(key);\n this.state.set(key, value);\n return value;\n }\n if (DEBUG) {\n this._misses++;\n }\n\n const newValue = this.doWork(key);\n this.set(key, newValue);\n return newValue;\n }\n\n set(key: T, value: V): void {\n if (this.state.size === this.size) {\n for (const [k] of this.state) {\n if (DEBUG) {\n this._ejected++;\n }\n this.state.delete(k);\n break;\n }\n }\n this.state.set(key, value);\n }\n\n clear(): void {\n this.state.clear();\n if (DEBUG) {\n this._hits = 0;\n this._misses = 0;\n this._ejected = 0;\n }\n }\n}\n\nconst STRING_DASHERIZE_REGEXP = /[ _]/g;\nconst STRING_DECAMELIZE_REGEXP = /([a-z\\d])([A-Z])/g;\n/**\n * The {@link LRUCache} backing {@link dasherize}, keyed by the original\n * (un-dasherized) string.\n *\n * @private\n */\nexport const STRING_DASHERIZE_CACHE: LRUCache<string, string> = new LRUCache<string, string>((key: string) =>\n key.replace(STRING_DECAMELIZE_REGEXP, '$1_$2').toLowerCase().replace(STRING_DASHERIZE_REGEXP, '-')\n);\n\n/**\n * This is an internal utility function that converts a string\n * to a dasherized format. Library consumers should use the\n * re-exported version from `@warp-drive-mirror/utilities/string` instead.\n *\n * This version is only in this location to support a deprecated\n * behavior in the core package and will be removed in a future.\n *\n * @private\n */\nexport function dasherize(str: string): string {\n return STRING_DASHERIZE_CACHE.get(str);\n}\n","export type RulesArray = Array<[RegExp, string]>;\ntype DefaultRulesType = {\n plurals: RulesArray;\n singular: RulesArray;\n irregularPairs: Array<[string, string]>;\n uncountable: string[];\n};\n\nexport const defaultRules: DefaultRulesType = {\n plurals: [\n [/$/, 's'],\n [/s$/i, 's'],\n [/^(ax|test)is$/i, '$1es'],\n [/(octop|vir)us$/i, '$1i'],\n [/(octop|vir)i$/i, '$1i'],\n [/(alias|status|bonus)$/i, '$1es'],\n [/(tu|bu)s$/i, '$1ses'],\n [/(buffal|tomat)o$/i, '$1oes'],\n [/([ti])um$/i, '$1a'],\n [/([ti])a$/i, '$1a'],\n [/sis$/i, 'ses'],\n [/(?:([^f])fe|([lr])f)$/i, '$1$2ves'],\n [/(hive)$/i, '$1s'],\n [/([^aeiouy]|qu)y$/i, '$1ies'],\n [/(x|ch|ss|sh)$/i, '$1es'],\n [/(matr|vert|ind)(?:ix|ex)$/i, '$1ices'],\n [/^(m|l)ouse$/i, '$1ice'],\n [/^(m|l)ice$/i, '$1ice'],\n [/^(ox)$/i, '$1en'],\n [/^(oxen)$/i, '$1'],\n [/(quiz)$/i, '$1zes'],\n ],\n\n singular: [\n [/s$/i, ''],\n [/(ss)$/i, '$1'],\n [/(n)ews$/i, '$1ews'],\n [/([ti])a$/i, '$1um'],\n [/((a)naly|(b)a|(d)iagno|(p)arenthe|(p)rogno|(s)ynop|(t)he)(sis|ses)$/i, '$1sis'],\n [/(^analy)(sis|ses)$/i, '$1sis'],\n [/([^f])ves$/i, '$1fe'],\n [/(hive)s$/i, '$1'],\n [/(tive)s$/i, '$1'],\n [/([lr])ves$/i, '$1f'],\n [/([^aeiouy]|qu)ies$/i, '$1y'],\n [/(s)eries$/i, '$1eries'],\n [/(m)ovies$/i, '$1ovie'],\n [/(x|ch|ss|sh)es$/i, '$1'],\n [/^(m|l)ice$/i, '$1ouse'],\n [/(tus|bus)(es)?$/i, '$1'],\n [/(o)es$/i, '$1'],\n [/(shoe)s$/i, '$1'],\n [/(cris|test)(is|es)$/i, '$1is'],\n [/^(a)x[ie]s$/i, '$1xis'],\n [/(octop|vir)(us|i)$/i, '$1us'],\n [/(alias|status|bonus)(es)?$/i, '$1'],\n [/^(ox)en/i, '$1'],\n [/(vert|ind)ices$/i, '$1ex'],\n [/(matr)ices$/i, '$1ix'],\n [/(quiz)zes$/i, '$1'],\n [/(database)s$/i, '$1'],\n ],\n\n irregularPairs: [\n ['person', 'people'],\n ['man', 'men'],\n ['child', 'children'],\n ['sex', 'sexes'],\n ['move', 'moves'],\n ['cow', 'kine'],\n ['zombie', 'zombies'],\n ],\n\n uncountable: ['equipment', 'information', 'rice', 'money', 'species', 'series', 'fish', 'sheep', 'jeans', 'police'],\n};\n","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 * @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 * @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 * @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 * @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 * @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 * @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 * @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 * @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 * @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 * @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 * @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 * @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 * @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 * @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 * @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 * @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"],"x_google_ignoreList":[0],"mappings":";;AAEA,MAAMA,yBAAyB;;;;;;;;;;;;;;;;;;;;;AAsB/B,IAAaC,WAAb,MAA4B;CAU1BC,YAAYC,QAAqBC,MAAe;EAC9C,KAAKA,OAAOA,QAAQJ;EACpB,KAAKK,wBAAQ,IAAIC,IAAI;EACrB,KAAKH,SAASA;CAOhB;CAEAI,IAAIC,KAAW;EACb,MAAMC,QAAQ,KAAKJ,MAAME,IAAIC,GAAG;EAChC,IAAIC,OAAO;GAIT,KAAKJ,MAAMK,OAAOF,GAAG;GACrB,KAAKH,MAAMM,IAAIH,KAAKC,KAAK;GACzB,OAAOA;EACT;EAKA,MAAMG,WAAW,KAAKT,OAAOK,GAAG;EAChC,KAAKG,IAAIH,KAAKI,QAAQ;EACtB,OAAOA;CACT;C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AAE,CAAClC,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
|
+
{"version":3,"file":"string.cjs","names":["DEFAULT_MAX_CACHE_SIZE","LRUCache","constructor","doWork","size","state","Map","get","key","value","delete","set","newValue","k","clear","STRING_DASHERIZE_REGEXP","STRING_DECAMELIZE_REGEXP","STRING_DASHERIZE_CACHE","replace","toLowerCase","dasherize","str","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":["../../../node_modules/.pnpm/@warp-d_5e1563e0e582c8365bb74466d3761d6d/node_modules/@warp-drive-mirror/core/dist/utils/string.js","../src/-private/string/inflections.ts","../src/-private/string/transform.ts","../src/-private/string/inflect.ts"],"sourcesContent":["import { DEBUG } from '@warp-drive-mirror/core/build-config/env';\n\nconst DEFAULT_MAX_CACHE_SIZE = 10_000;\n\n/**\n * An LRUCache implementation with upsert semantics.\n *\n * This implementation is *not* generic, but focuses on\n * performance tuning for the string transformation cases\n * where the key maps to the value very simply.\n *\n * It takes a work function that should generate a new value\n * for a given key when called. It will be called when the key\n * is not found in the cache.\n *\n * It keeps track of the number of hits, misses, and ejections\n * in DEBUG envs, which is useful for tuning the cache size.\n *\n * This is an internal utility class for use by this module\n * and by `@warp-drive-mirror/utilities/string`. It is not intended\n * for use outside of these modules at this time.\n *\n * @private\n */\nexport class LRUCache<T, V> {\n declare size: number;\n declare state: Map<T, V>;\n declare doWork: (k: T) => V;\n\n // debug stats\n declare _hits: number;\n declare _misses: number;\n declare _ejected: number;\n\n constructor(doWork: (k: T) => V, size?: number) {\n this.size = size || DEFAULT_MAX_CACHE_SIZE;\n this.state = new Map();\n this.doWork = doWork;\n\n if (DEBUG) {\n this._hits = 0;\n this._misses = 0;\n this._ejected = 0;\n }\n }\n\n get(key: T): V {\n const value = this.state.get(key);\n if (value) {\n if (DEBUG) {\n this._hits++;\n }\n this.state.delete(key);\n this.state.set(key, value);\n return value;\n }\n if (DEBUG) {\n this._misses++;\n }\n\n const newValue = this.doWork(key);\n this.set(key, newValue);\n return newValue;\n }\n\n set(key: T, value: V): void {\n if (this.state.size === this.size) {\n for (const [k] of this.state) {\n if (DEBUG) {\n this._ejected++;\n }\n this.state.delete(k);\n break;\n }\n }\n this.state.set(key, value);\n }\n\n clear(): void {\n this.state.clear();\n if (DEBUG) {\n this._hits = 0;\n this._misses = 0;\n this._ejected = 0;\n }\n }\n}\n\nconst STRING_DASHERIZE_REGEXP = /[ _]/g;\nconst STRING_DECAMELIZE_REGEXP = /([a-z\\d])([A-Z])/g;\n/**\n * The {@link LRUCache} backing {@link dasherize}, keyed by the original\n * (un-dasherized) string.\n *\n * @private\n */\nexport const STRING_DASHERIZE_CACHE: LRUCache<string, string> = new LRUCache<string, string>((key: string) =>\n key.replace(STRING_DECAMELIZE_REGEXP, '$1_$2').toLowerCase().replace(STRING_DASHERIZE_REGEXP, '-')\n);\n\n/**\n * This is an internal utility function that converts a string\n * to a dasherized format. Library consumers should use the\n * re-exported version from `@warp-drive-mirror/utilities/string` instead.\n *\n * This version is only in this location to support a deprecated\n * behavior in the core package and will be removed in a future.\n *\n * @private\n */\nexport function dasherize(str: string): string {\n return STRING_DASHERIZE_CACHE.get(str);\n}\n","export type RulesArray = Array<[RegExp, string]>;\ntype DefaultRulesType = {\n plurals: RulesArray;\n singular: RulesArray;\n irregularPairs: Array<[string, string]>;\n uncountable: string[];\n};\n\nexport const defaultRules: DefaultRulesType = {\n plurals: [\n [/$/, 's'],\n [/s$/i, 's'],\n [/^(ax|test)is$/i, '$1es'],\n [/(octop|vir)us$/i, '$1i'],\n [/(octop|vir)i$/i, '$1i'],\n [/(alias|status|bonus)$/i, '$1es'],\n [/(tu|bu)s$/i, '$1ses'],\n [/(buffal|tomat)o$/i, '$1oes'],\n [/([ti])um$/i, '$1a'],\n [/([ti])a$/i, '$1a'],\n [/sis$/i, 'ses'],\n [/(?:([^f])fe|([lr])f)$/i, '$1$2ves'],\n [/(hive)$/i, '$1s'],\n [/([^aeiouy]|qu)y$/i, '$1ies'],\n [/(x|ch|ss|sh)$/i, '$1es'],\n [/(matr|vert|ind)(?:ix|ex)$/i, '$1ices'],\n [/^(m|l)ouse$/i, '$1ice'],\n [/^(m|l)ice$/i, '$1ice'],\n [/^(ox)$/i, '$1en'],\n [/^(oxen)$/i, '$1'],\n [/(quiz)$/i, '$1zes'],\n ],\n\n singular: [\n [/s$/i, ''],\n [/(ss)$/i, '$1'],\n [/(n)ews$/i, '$1ews'],\n [/([ti])a$/i, '$1um'],\n [/((a)naly|(b)a|(d)iagno|(p)arenthe|(p)rogno|(s)ynop|(t)he)(sis|ses)$/i, '$1sis'],\n [/(^analy)(sis|ses)$/i, '$1sis'],\n [/([^f])ves$/i, '$1fe'],\n [/(hive)s$/i, '$1'],\n [/(tive)s$/i, '$1'],\n [/([lr])ves$/i, '$1f'],\n [/([^aeiouy]|qu)ies$/i, '$1y'],\n [/(s)eries$/i, '$1eries'],\n [/(m)ovies$/i, '$1ovie'],\n [/(x|ch|ss|sh)es$/i, '$1'],\n [/^(m|l)ice$/i, '$1ouse'],\n [/(tus|bus)(es)?$/i, '$1'],\n [/(o)es$/i, '$1'],\n [/(shoe)s$/i, '$1'],\n [/(cris|test)(is|es)$/i, '$1is'],\n [/^(a)x[ie]s$/i, '$1xis'],\n [/(octop|vir)(us|i)$/i, '$1us'],\n [/(alias|status|bonus)(es)?$/i, '$1'],\n [/^(ox)en/i, '$1'],\n [/(vert|ind)ices$/i, '$1ex'],\n [/(matr)ices$/i, '$1ix'],\n [/(quiz)zes$/i, '$1'],\n [/(database)s$/i, '$1'],\n ],\n\n irregularPairs: [\n ['person', 'people'],\n ['man', 'men'],\n ['child', 'children'],\n ['sex', 'sexes'],\n ['move', 'moves'],\n ['cow', 'kine'],\n ['zombie', 'zombies'],\n ],\n\n uncountable: ['equipment', 'information', 'rice', 'money', 'species', 'series', 'fish', 'sheep', 'jeans', 'police'],\n};\n","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"],"x_google_ignoreList":[0],"mappings":";;AAEA,MAAMA,yBAAyB;;;;;;;;;;;;;;;;;;;;;AAsB/B,IAAaC,WAAb,MAA4B;CAU1BC,YAAYC,QAAqBC,MAAe;EAC9C,KAAKA,OAAOA,QAAQJ;EACpB,KAAKK,wBAAQ,IAAIC,IAAI;EACrB,KAAKH,SAASA;CAOhB;CAEAI,IAAIC,KAAW;EACb,MAAMC,QAAQ,KAAKJ,MAAME,IAAIC,GAAG;EAChC,IAAIC,OAAO;GAIT,KAAKJ,MAAMK,OAAOF,GAAG;GACrB,KAAKH,MAAMM,IAAIH,KAAKC,KAAK;GACzB,OAAOA;EACT;EAKA,MAAMG,WAAW,KAAKT,OAAOK,GAAG;EAChC,KAAKG,IAAIH,KAAKI,QAAQ;EACtB,OAAOA;CACT;CAEAD,IAAIH,KAAQC,OAAgB;EAC1B,IAAI,KAAKJ,MAAMD,SAAS,KAAKA,MAC3B,KAAK,MAAM,CAACS,MAAM,KAAKR,OAAO;GAI5B,KAAKA,MAAMK,OAAOG,CAAC;GACnB;EACF;EAEF,KAAKR,MAAMM,IAAIH,KAAKC,KAAK;CAC3B;CAEAK,QAAc;EACZ,KAAKT,MAAMS,MAAM;CAMnB;AACF;AAEA,MAAMC,0BAA0B;AAChC,MAAMC,2BAA2B;;;;;;;AAOjC,MAAaC,yBAAmD,IAAIhB,UAA0BO,QAC5FA,IAAIU,QAAQF,0BAA0B,OAAO,CAAC,CAACG,YAAY,CAAC,CAACD,QAAQH,yBAAyB,GAAG,CACnG;;;;;;;;;;;AAYA,SAAgBK,YAAUC,KAAqB;CAC7C,OAAOJ,uBAAuBV,IAAIc,GAAG;AACvC;;;;ACxG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A,KAAKwD,QAAQlB,MAAMgB,YAAY;CAI1C,OAAOtD;AACT"}
|
package/dist/active-record.d.ts
CHANGED
|
@@ -8,6 +8,9 @@ import { QueryParamsSource } from "@warp-drive-mirror/core/types/params";
|
|
|
8
8
|
* Builds request options to fetch a single resource by a known id or identifier
|
|
9
9
|
* configured for the url and header expectations of most ActiveRecord APIs.
|
|
10
10
|
*
|
|
11
|
+
* See the [Builders](/guides/the-manual/requests/builders) guide for what request builders do and
|
|
12
|
+
* when to use one.
|
|
13
|
+
*
|
|
11
14
|
* **Basic Usage**
|
|
12
15
|
*
|
|
13
16
|
* ```ts
|
|
@@ -55,6 +58,8 @@ import { QueryParamsSource } from "@warp-drive-mirror/core/types/params";
|
|
|
55
58
|
* const data = await store.request(options);
|
|
56
59
|
* ```
|
|
57
60
|
*
|
|
61
|
+
* @summary Builds a `GET` request for one resource by type and id, using ActiveRecord-style pluralized, underscored
|
|
62
|
+
* URLs.
|
|
58
63
|
* @public
|
|
59
64
|
* @param identifier
|
|
60
65
|
* @param options
|
|
@@ -69,6 +74,9 @@ export declare function findRecord(type: string, id: string, options?: FindRecor
|
|
|
69
74
|
* Builds request options to query for resources, usually by a primary
|
|
70
75
|
* type, configured for the url and header expectations of most ActiveRecord APIs.
|
|
71
76
|
*
|
|
77
|
+
* See the [Builders](/guides/the-manual/requests/builders) guide for what request builders do and
|
|
78
|
+
* when to use one.
|
|
79
|
+
*
|
|
72
80
|
* **Basic Usage**
|
|
73
81
|
*
|
|
74
82
|
* ```ts
|
|
@@ -107,6 +115,7 @@ export declare function findRecord(type: string, id: string, options?: FindRecor
|
|
|
107
115
|
* const data = await store.request(options);
|
|
108
116
|
* ```
|
|
109
117
|
*
|
|
118
|
+
* @summary Builds a `GET` request that queries a resource type with query params, using ActiveRecord-style URLs.
|
|
110
119
|
* @public
|
|
111
120
|
* @param identifier
|
|
112
121
|
* @param query
|
|
@@ -120,6 +129,9 @@ export declare function query(type: string, query?: QueryParamsSource, options?:
|
|
|
120
129
|
* Builds request options to delete record for resources,
|
|
121
130
|
* configured for the url, method and header expectations of ActiveRecord APIs.
|
|
122
131
|
*
|
|
132
|
+
* See the [Builders](/guides/the-manual/requests/builders) guide for what request builders do and
|
|
133
|
+
* when to use one.
|
|
134
|
+
*
|
|
123
135
|
* **Basic Usage**
|
|
124
136
|
*
|
|
125
137
|
* ```ts
|
|
@@ -161,6 +173,7 @@ export declare function query(type: string, query?: QueryParamsSource, options?:
|
|
|
161
173
|
* const data = await store.request(options);
|
|
162
174
|
* ```
|
|
163
175
|
*
|
|
176
|
+
* @summary Builds a `DELETE` request that persists deletion of an existing record, using ActiveRecord-style URLs.
|
|
164
177
|
* @public
|
|
165
178
|
* @param record
|
|
166
179
|
* @param options
|
|
@@ -171,6 +184,9 @@ export declare function deleteRecord(record: unknown, options?: ConstrainedReque
|
|
|
171
184
|
* Builds request options to create new record for resources,
|
|
172
185
|
* configured for the url, method and header expectations of most ActiveRecord APIs.
|
|
173
186
|
*
|
|
187
|
+
* See the [Builders](/guides/the-manual/requests/builders) guide for what request builders do and
|
|
188
|
+
* when to use one.
|
|
189
|
+
*
|
|
174
190
|
* **Basic Usage**
|
|
175
191
|
*
|
|
176
192
|
* ```ts
|
|
@@ -202,6 +218,7 @@ export declare function deleteRecord(record: unknown, options?: ConstrainedReque
|
|
|
202
218
|
* const data = await store.request(options);
|
|
203
219
|
* ```
|
|
204
220
|
*
|
|
221
|
+
* @summary Builds a `POST` request that saves a newly created record, using ActiveRecord-style URLs.
|
|
205
222
|
* @public
|
|
206
223
|
* @param record
|
|
207
224
|
* @param options
|
|
@@ -212,6 +229,9 @@ export declare function createRecord(record: unknown, options?: ConstrainedReque
|
|
|
212
229
|
* Builds request options to update existing record for resources,
|
|
213
230
|
* configured for the url, method and header expectations of most ActiveRecord APIs.
|
|
214
231
|
*
|
|
232
|
+
* See the [Builders](/guides/the-manual/requests/builders) guide for what request builders do and
|
|
233
|
+
* when to use one.
|
|
234
|
+
*
|
|
215
235
|
* **Basic Usage**
|
|
216
236
|
*
|
|
217
237
|
* ```ts
|
|
@@ -246,6 +266,7 @@ export declare function createRecord(record: unknown, options?: ConstrainedReque
|
|
|
246
266
|
* const data = await store.request(options);
|
|
247
267
|
* ```
|
|
248
268
|
*
|
|
269
|
+
* @summary Builds a `PUT` (or `PATCH`) request that saves changes to an existing record, using ActiveRecord-style URLs.
|
|
249
270
|
* @public
|
|
250
271
|
* @param record
|
|
251
272
|
* @param options
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"active-record.d.ts","names":[],"sources":["../src/-private/active-record/find-record.ts","../src/-private/active-record/query.ts","../src/-private/active-record/save-record.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"active-record.d.ts","names":[],"sources":["../src/-private/active-record/find-record.ts","../src/-private/active-record/query.ts","../src/-private/active-record/save-record.ts"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;wBAyEgB,WAAW,GAAG,UAAU,mBAAmB,kBAAkB,2BAC3E,YAAY,6BAA6B,iBAAiB,KAC1D,UAAU,oBACT,yBAAyB,qBAAqB,GAAG,GAAG,IAAI;wBAC3C,WACd,YAAY,8BACZ,UAAU,oBACT;wBACa,WAAW,GAAG,UAAU,mBAAmB,kBAAkB,2BAC3E,MAAM,iBAAiB,IACvB,YACA,UAAU,oBACT,yBAAyB,qBAAqB,GAAG,GAAG,IAAI;wBAC3C,WAAW,cAAc,YAAY,UAAU,oBAAoB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;wBCzBnE,MAAM,GAAG,UAAU,mBAAmB,kBAAkB,2BACtE,MAAM,iBAAiB,IACvB,QAAQ,mBACR,UAAU,4BACT,oBAAoB,qBAAqB,KAAK,GAAG;wBACpC,MACd,cACA,QAAQ,mBACR,UAAU,4BACT;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;wBCSa,aAAa,GAAG,QAAQ,GAAG,UAAU,4BAA4B,qBAAqB;wBACtF,aAAa,iBAAiB,UAAU,4BAA4B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;wBAyEpE,aAAa,GAAG,QAAQ,GAAG,UAAU,4BAA4B,qBAAqB;wBACtF,aAAa,iBAAiB,UAAU,4BAA4B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;wBA2EpE,aACd,UAAU,qBACV,WAAW,sBAAsB,GACjC,UAAU,mBAAmB,kBAC7B,2BAEA,QAAQ,GACR,UAAU;EAA8B;IACvC,qBAAqB,qBAAqB,IAAI,GAAG,IAAI;wBACxC,aACd,iBACA,UAAU;EAA8B;IACvC"}
|
package/dist/active-record.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { buildBaseURL, buildQueryParams } from "./index.js";
|
|
2
|
-
import { g as underscore, s as pluralize } from "./string-
|
|
2
|
+
import { g as underscore, s as pluralize } from "./string-BZACNuLp.js";
|
|
3
3
|
import { n as extractCacheOptions, t as copyForwardUrlOptions } from "./builder-utils-BkXwUT0x.js";
|
|
4
4
|
import { getGlobalConfig, macroCondition } from "@embroider/macros";
|
|
5
5
|
import { recordIdentifierFor } from "@warp-drive-mirror/core";
|
|
@@ -63,6 +63,9 @@ function isExisting(identifier) {
|
|
|
63
63
|
* Builds request options to delete record for resources,
|
|
64
64
|
* configured for the url, method and header expectations of ActiveRecord APIs.
|
|
65
65
|
*
|
|
66
|
+
* See the [Builders](/guides/the-manual/requests/builders) guide for what request builders do and
|
|
67
|
+
* when to use one.
|
|
68
|
+
*
|
|
66
69
|
* **Basic Usage**
|
|
67
70
|
*
|
|
68
71
|
* ```ts
|
|
@@ -104,6 +107,7 @@ function isExisting(identifier) {
|
|
|
104
107
|
* const data = await store.request(options);
|
|
105
108
|
* ```
|
|
106
109
|
*
|
|
110
|
+
* @summary Builds a `DELETE` request that persists deletion of an existing record, using ActiveRecord-style URLs.
|
|
107
111
|
* @public
|
|
108
112
|
* @param record
|
|
109
113
|
* @param options
|
|
@@ -138,6 +142,9 @@ function deleteRecord(record, options = {}) {
|
|
|
138
142
|
* Builds request options to create new record for resources,
|
|
139
143
|
* configured for the url, method and header expectations of most ActiveRecord APIs.
|
|
140
144
|
*
|
|
145
|
+
* See the [Builders](/guides/the-manual/requests/builders) guide for what request builders do and
|
|
146
|
+
* when to use one.
|
|
147
|
+
*
|
|
141
148
|
* **Basic Usage**
|
|
142
149
|
*
|
|
143
150
|
* ```ts
|
|
@@ -169,6 +176,7 @@ function deleteRecord(record, options = {}) {
|
|
|
169
176
|
* const data = await store.request(options);
|
|
170
177
|
* ```
|
|
171
178
|
*
|
|
179
|
+
* @summary Builds a `POST` request that saves a newly created record, using ActiveRecord-style URLs.
|
|
172
180
|
* @public
|
|
173
181
|
* @param record
|
|
174
182
|
* @param options
|
|
@@ -200,6 +208,9 @@ function createRecord(record, options = {}) {
|
|
|
200
208
|
* Builds request options to update existing record for resources,
|
|
201
209
|
* configured for the url, method and header expectations of most ActiveRecord APIs.
|
|
202
210
|
*
|
|
211
|
+
* See the [Builders](/guides/the-manual/requests/builders) guide for what request builders do and
|
|
212
|
+
* when to use one.
|
|
213
|
+
*
|
|
203
214
|
* **Basic Usage**
|
|
204
215
|
*
|
|
205
216
|
* ```ts
|
|
@@ -234,6 +245,7 @@ function createRecord(record, options = {}) {
|
|
|
234
245
|
* const data = await store.request(options);
|
|
235
246
|
* ```
|
|
236
247
|
*
|
|
248
|
+
* @summary Builds a `PUT` (or `PATCH`) request that saves changes to an existing record, using ActiveRecord-style URLs.
|
|
237
249
|
* @public
|
|
238
250
|
* @param record
|
|
239
251
|
* @param options
|