@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,9 +1,9 @@
1
1
  import { QueryParamsSerializationOptions, QueryParamsSource, Serializable } from "@warp-drive-mirror/core/types/params";
2
- //#region src/index.d.ts
3
2
  /**
4
3
  * The global configuration used by {@link buildBaseURL} when a call does
5
4
  * not provide its own `host`/`namespace`. Set via {@link setBuildURLConfig}.
6
5
  *
6
+ * @summary The global `host` and `namespace` that `buildBaseURL` prefixes onto URLs when a call does not pass its own.
7
7
  * @public
8
8
  */
9
9
  interface BuildURLConfig {
@@ -23,6 +23,10 @@ interface BuildURLConfig {
23
23
  * These values may still be overridden by passing
24
24
  * them to buildBaseURL directly.
25
25
  *
26
+ * The [Basic Usage](/guides/the-manual/cookbook/basic-usage#step-2-configure-some-request-defaults)
27
+ * guide sets these defaults through the `@warp-drive-mirror/utilities/json-api` version of this function,
28
+ * which also sets this global configuration.
29
+ *
26
30
  * This method may be called as many times as needed.
27
31
  * host values of `''` or `'/'` are equivalent.
28
32
  *
@@ -49,12 +53,14 @@ interface BuildURLConfig {
49
53
  * });
50
54
  * ```
51
55
  *
56
+ * @summary Sets the app-wide default `host` and `namespace` used by `buildBaseURL` and the request builders.
52
57
  * @public
53
58
  */
54
59
  declare function setBuildURLConfig(config: BuildURLConfig): void;
55
60
  /**
56
61
  * {@link buildBaseURL} options for a `findRecord` request.
57
62
  *
63
+ * @summary Options passed to `buildBaseURL` to build the URL for fetching one resource by type and id.
58
64
  * @public
59
65
  */
60
66
  interface FindRecordUrlOptions {
@@ -91,6 +97,7 @@ interface FindRecordUrlOptions {
91
97
  /**
92
98
  * {@link buildBaseURL} options for a `query` request.
93
99
  *
100
+ * @summary Options passed to `buildBaseURL` to build the URL for querying a collection of one resource type.
94
101
  * @public
95
102
  */
96
103
  interface QueryUrlOptions {
@@ -123,6 +130,8 @@ interface QueryUrlOptions {
123
130
  /**
124
131
  * {@link buildBaseURL} options for a `findMany` request.
125
132
  *
133
+ * @summary Options passed to `buildBaseURL` to build the URL for fetching several resources, pathed by the first
134
+ * identifier's type.
126
135
  * @public
127
136
  */
128
137
  interface FindManyUrlOptions {
@@ -159,6 +168,8 @@ interface FindManyUrlOptions {
159
168
  /**
160
169
  * {@link buildBaseURL} options for a `findRelatedCollection` request.
161
170
  *
171
+ * @summary Options passed to `buildBaseURL` to build the URL for a record's has-many relationship, ending in the
172
+ * field name.
162
173
  * @public
163
174
  */
164
175
  interface FindRelatedCollectionUrlOptions {
@@ -199,6 +210,8 @@ interface FindRelatedCollectionUrlOptions {
199
210
  /**
200
211
  * {@link buildBaseURL} options for a `findRelatedRecord` request.
201
212
  *
213
+ * @summary Options passed to `buildBaseURL` to build the URL for a record's belongs-to relationship, ending in the
214
+ * field name.
202
215
  * @public
203
216
  */
204
217
  interface FindRelatedResourceUrlOptions {
@@ -239,6 +252,7 @@ interface FindRelatedResourceUrlOptions {
239
252
  /**
240
253
  * {@link buildBaseURL} options for a `createRecord` request.
241
254
  *
255
+ * @summary Options passed to `buildBaseURL` to build the collection URL a new record of a given type is saved to.
242
256
  * @public
243
257
  */
244
258
  interface CreateRecordUrlOptions {
@@ -271,6 +285,7 @@ interface CreateRecordUrlOptions {
271
285
  /**
272
286
  * {@link buildBaseURL} options for an `updateRecord` request.
273
287
  *
288
+ * @summary Options passed to `buildBaseURL` to build the URL for saving changes to an existing record by type and id.
274
289
  * @public
275
290
  */
276
291
  interface UpdateRecordUrlOptions {
@@ -307,6 +322,7 @@ interface UpdateRecordUrlOptions {
307
322
  /**
308
323
  * {@link buildBaseURL} options for a `deleteRecord` request.
309
324
  *
325
+ * @summary Options passed to `buildBaseURL` to build the URL for deleting an existing record by type and id.
310
326
  * @public
311
327
  */
312
328
  interface DeleteRecordUrlOptions {
@@ -344,6 +360,7 @@ interface DeleteRecordUrlOptions {
344
360
  * {@link buildBaseURL} options for building a URL directly from a `resourcePath`
345
361
  * without an associated request operation.
346
362
  *
363
+ * @summary Options passed to `buildBaseURL` to build a URL from an explicit `resourcePath` with no request `op`.
347
364
  * @public
348
365
  */
349
366
  interface GenericUrlOptions {
@@ -373,6 +390,7 @@ interface GenericUrlOptions {
373
390
  * - {@link DeleteRecordUrlOptions}
374
391
  * - {@link GenericUrlOptions}
375
392
  *
393
+ * @summary Any of the option shapes `buildBaseURL` accepts, one per request `op` plus a generic `resourcePath` form.
376
394
  * @public
377
395
  */
378
396
  type UrlOptions = FindRecordUrlOptions | QueryUrlOptions | FindManyUrlOptions | FindRelatedCollectionUrlOptions | FindRelatedResourceUrlOptions | CreateRecordUrlOptions | UpdateRecordUrlOptions | DeleteRecordUrlOptions | GenericUrlOptions;
@@ -381,6 +399,9 @@ type UrlOptions = FindRecordUrlOptions | QueryUrlOptions | FindManyUrlOptions |
381
399
  * Does not include support for building query params (see `buildQueryParams`)
382
400
  * so that it may be composed cleanly with other query-params strategies.
383
401
  *
402
+ * See the [Builders](/guides/the-manual/requests/builders) guide for writing your own request
403
+ * builders.
404
+ *
384
405
  * Usage:
385
406
  *
386
407
  * ```ts
@@ -410,6 +431,7 @@ type UrlOptions = FindRecordUrlOptions | QueryUrlOptions | FindManyUrlOptions |
410
431
  * - 'findRecord' 'query' 'findMany' 'findRelatedCollection' 'findRelatedRecord'` 'createRecord' 'updateRecord' 'deleteRecord'
411
432
  * - Depending on the value of `op`, `identifier` or `identifiers` will be required.
412
433
  *
434
+ * @summary Joins host, namespace, resource path, id, and relationship field into a request URL without query params.
413
435
  * @public
414
436
  */
415
437
  declare function buildBaseURL(urlOptions: UrlOptions): string;
@@ -417,6 +439,11 @@ declare function buildBaseURL(urlOptions: UrlOptions): string;
417
439
  * filter out keys of an object that have falsy values or point to empty arrays
418
440
  * returning a new object with only those keys that have truthy values / non-empty arrays
419
441
  *
442
+ * See [Cache Keys for Requests](/guides/the-manual/requests/builders#cache-keys-for-requests) for
443
+ * why builders need stable query params.
444
+ *
445
+ * @summary Returns a copy of an object without keys whose values are `undefined`, `null`, empty strings, or empty
446
+ * arrays.
420
447
  * @public
421
448
  * @param source object to filter keys with empty values from
422
449
  * @return A new object with the keys that contained empty values removed
@@ -426,8 +453,15 @@ declare function filterEmpty(source: Record<string, Serializable>): Record<strin
426
453
  * Sorts query params by both key and value returning a new URLSearchParams
427
454
  * object with the keys inserted in sorted order.
428
455
  *
456
+ * See [Cache Keys for Requests](/guides/the-manual/requests/builders#cache-keys-for-requests) for
457
+ * why builders need stable query params.
458
+ *
429
459
  * Treats `included` specially, splicing it into an array if it is a string and sorting the array.
430
460
  *
461
+ * The `params` given are never mutated: neither the object itself nor any array
462
+ * value it holds is reordered or replaced, so passing state that is also
463
+ * rendered (a tracked array of filter values, for instance) is safe.
464
+ *
431
465
  * Options:
432
466
  * - arrayFormat: 'bracket' | 'indices' | 'repeat' | 'comma'
433
467
  *
@@ -436,6 +470,8 @@ declare function filterEmpty(source: Record<string, Serializable>): Record<strin
436
470
  * 'repeat': appends the key for every value e.g. `&ids=1&ids=2`
437
471
  * 'comma' (default): appends the key once with a comma separated list of values e.g. `&ids=1,2`
438
472
  *
473
+ * @summary Builds a `URLSearchParams` with keys and array values sorted, so equivalent queries produce identical
474
+ * params.
439
475
  * @public
440
476
  * @return A {@link URLSearchParams} with keys inserted in sorted order
441
477
  */
@@ -443,8 +479,15 @@ declare function sortQueryParams(params: QueryParamsSource, options?: QueryParam
443
479
  /**
444
480
  * Sorts query params by both key and value, returning a query params string
445
481
  *
482
+ * See [Cache Keys for Requests](/guides/the-manual/requests/builders#cache-keys-for-requests) for
483
+ * why builders need stable query params.
484
+ *
446
485
  * Treats `included` specially, splicing it into an array if it is a string and sorting the array.
447
486
  *
487
+ * The `params` given are never mutated: neither the object itself nor any array
488
+ * value it holds is reordered or replaced, so passing state that is also
489
+ * rendered (a tracked array of filter values, for instance) is safe.
490
+ *
448
491
  * Options:
449
492
  * - arrayFormat: 'bracket' | 'indices' | 'repeat' | 'comma'
450
493
  *
@@ -453,10 +496,11 @@ declare function sortQueryParams(params: QueryParamsSource, options?: QueryParam
453
496
  * 'repeat': appends the key for every value e.g. `ids=1&ids=2`
454
497
  * 'comma' (default): appends the key once with a comma separated list of values e.g. `ids=1,2`
455
498
  *
499
+ * @summary Serializes query params into a string with keys and array values sorted, so equivalent queries share one
500
+ * URL.
456
501
  * @public
457
502
  * @return A sorted query params string without the leading `?`
458
503
  */
459
504
  declare function buildQueryParams(params: QueryParamsSource, options?: QueryParamsSerializationOptions): string;
460
- //#endregion
461
505
  export { FindRecordUrlOptions as a, GenericUrlOptions as c, UrlOptions as d, buildBaseURL as f, sortQueryParams as g, setBuildURLConfig as h, FindManyUrlOptions as i, QueryUrlOptions as l, filterEmpty as m, CreateRecordUrlOptions as n, FindRelatedCollectionUrlOptions as o, buildQueryParams as p, DeleteRecordUrlOptions as r, FindRelatedResourceUrlOptions as s, BuildURLConfig as t, UpdateRecordUrlOptions as u };
462
- //# sourceMappingURL=index-BeMAuqgZ.d.ts.map
506
+ //# sourceMappingURL=index-Dv5kZpGe.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index-Dv5kZpGe.d.ts","names":[],"sources":["../src/index.ts"],"mappings":";;;;;;;;UAqBiB;;;;EAIf;;;;EAIA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAgDc,kBAAkB,QAAQ;;;;;;;UA8BzB;;;;EAIf;;;;EAIA;;;;IAIE;;;;IAIA;;;;;EAKF;;;;EAIA;;;;EAIA;;;;;;;;UASe;;;;EAIf;;;;EAIA;;;;IAIE;;;;;EAKF;;;;EAIA;;;;EAIA;;;;;;;;;UAUe;;;;EAIf;;;;EAIA;;;;IAIE;;;;IAIA;;;;;EAKF;;;;EAIA;;;;EAIA;;;;;;;;;UASe;;;;EAIf;;;;EAIA;;;;IAIE;;;;IAIA;;;;;EAKF;;;;EAIA;;;;EAIA;;;;EAIA;;;;;;;;;UAUe;;;;EAIf;;;;EAIA;;;;IAIE;;;;IAIA;;;;;EAKF;;;;EAIA;;;;EAIA;;;;EAIA;;;;;;;;UASe;;;;EAIf;;;;EAIA;;;;IAIE;;;;;EAKF;;;;EAIA;;;;EAIA;;;;;;;;UASe;;;;EAIf;;;;EAIA;;;;IAIE;;;;IAIA;;;;;EAKF;;;;EAIA;;;;EAIA;;;;;;;;UASe;;;;EAIf;;;;EAIA;;;;IAIE;;;;IAIA;;;;;EAKF;;;;EAIA;;;;EAIA;;;;;;;;;UAUe;;;;EAIf;;;;EAIA;;;;EAIA;;;;;;;;;;;;;;;;;;KAmBU,aACR,uBACA,kBACA,qBACA,kCACA,gCACA,yBACA,yBACA,yBACA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAyEY,aAAa,YAAY;;;;;;;;;;;;;;iBAiIzB,YAAY,QAAQ,eAAe,gBAAgB,eAAe;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAwClE,gBAAgB,QAAQ,mBAAmB,UAAU,kCAAkC;;;;;;;;;;;;;;;;;;;;;;;;;;iBAwFvF,iBAAiB,QAAQ,mBAAmB,UAAU"}
package/dist/index.d.ts CHANGED
@@ -1,2 +1,2 @@
1
- import { a as FindRecordUrlOptions, c as GenericUrlOptions, d as UrlOptions, f as buildBaseURL, g as sortQueryParams, h as setBuildURLConfig, i as FindManyUrlOptions, l as QueryUrlOptions, m as filterEmpty, n as CreateRecordUrlOptions, o as FindRelatedCollectionUrlOptions, p as buildQueryParams, r as DeleteRecordUrlOptions, s as FindRelatedResourceUrlOptions, t as BuildURLConfig, u as UpdateRecordUrlOptions } from "./index-BeMAuqgZ.js";
1
+ import { a as FindRecordUrlOptions, c as GenericUrlOptions, d as UrlOptions, f as buildBaseURL, g as sortQueryParams, h as setBuildURLConfig, i as FindManyUrlOptions, l as QueryUrlOptions, m as filterEmpty, n as CreateRecordUrlOptions, o as FindRelatedCollectionUrlOptions, p as buildQueryParams, r as DeleteRecordUrlOptions, s as FindRelatedResourceUrlOptions, t as BuildURLConfig, u as UpdateRecordUrlOptions } from "./index-Dv5kZpGe.js";
2
2
  export { BuildURLConfig, CreateRecordUrlOptions, DeleteRecordUrlOptions, FindManyUrlOptions, FindRecordUrlOptions, FindRelatedCollectionUrlOptions, FindRelatedResourceUrlOptions, GenericUrlOptions, QueryUrlOptions, UpdateRecordUrlOptions, UrlOptions, buildBaseURL, buildQueryParams, filterEmpty, setBuildURLConfig, sortQueryParams };
package/dist/index.js CHANGED
@@ -1,8 +1,9 @@
1
1
  import { getOrSetGlobal } from "@warp-drive-mirror/core/types/-private";
2
2
  import { getGlobalConfig, macroCondition } from "@embroider/macros";
3
3
 
4
- //#region src/index.ts
4
+ // src/index.ts
5
5
  /**
6
+ * @summary Helpers for building request URLs and sorted query strings, with a configurable global host and namespace.
6
7
  * @module
7
8
  * @mergeModuleWith <project>
8
9
  */
@@ -10,6 +11,7 @@ import { getGlobalConfig, macroCondition } from "@embroider/macros";
10
11
  * The global configuration used by {@link buildBaseURL} when a call does
11
12
  * not provide its own `host`/`namespace`. Set via {@link setBuildURLConfig}.
12
13
  *
14
+ * @summary The global `host` and `namespace` that `buildBaseURL` prefixes onto URLs when a call does not pass its own.
13
15
  * @public
14
16
  */
15
17
  const CONFIG = getOrSetGlobal("CONFIG", {
@@ -23,6 +25,10 @@ const CONFIG = getOrSetGlobal("CONFIG", {
23
25
  * These values may still be overridden by passing
24
26
  * them to buildBaseURL directly.
25
27
  *
28
+ * The [Basic Usage](/guides/the-manual/cookbook/basic-usage#step-2-configure-some-request-defaults)
29
+ * guide sets these defaults through the `@warp-drive-mirror/utilities/json-api` version of this function,
30
+ * which also sets this global configuration.
31
+ *
26
32
  * This method may be called as many times as needed.
27
33
  * host values of `''` or `'/'` are equivalent.
28
34
  *
@@ -49,6 +55,7 @@ const CONFIG = getOrSetGlobal("CONFIG", {
49
55
  * });
50
56
  * ```
51
57
  *
58
+ * @summary Sets the app-wide default `host` and `namespace` used by `buildBaseURL` and the request builders.
52
59
  * @public
53
60
  */
54
61
  function setBuildURLConfig(config) {
@@ -73,47 +80,59 @@ function setBuildURLConfig(config) {
73
80
  /**
74
81
  * {@link buildBaseURL} options for a `findRecord` request.
75
82
  *
83
+ * @summary Options passed to `buildBaseURL` to build the URL for fetching one resource by type and id.
76
84
  * @public
77
85
  */
78
86
  /**
79
87
  * {@link buildBaseURL} options for a `query` request.
80
88
  *
89
+ * @summary Options passed to `buildBaseURL` to build the URL for querying a collection of one resource type.
81
90
  * @public
82
91
  */
83
92
  /**
84
93
  * {@link buildBaseURL} options for a `findMany` request.
85
94
  *
95
+ * @summary Options passed to `buildBaseURL` to build the URL for fetching several resources, pathed by the first
96
+ * identifier's type.
86
97
  * @public
87
98
  */
88
99
  /**
89
100
  * {@link buildBaseURL} options for a `findRelatedCollection` request.
90
101
  *
102
+ * @summary Options passed to `buildBaseURL` to build the URL for a record's has-many relationship, ending in the
103
+ * field name.
91
104
  * @public
92
105
  */
93
106
  /**
94
107
  * {@link buildBaseURL} options for a `findRelatedRecord` request.
95
108
  *
109
+ * @summary Options passed to `buildBaseURL` to build the URL for a record's belongs-to relationship, ending in the
110
+ * field name.
96
111
  * @public
97
112
  */
98
113
  /**
99
114
  * {@link buildBaseURL} options for a `createRecord` request.
100
115
  *
116
+ * @summary Options passed to `buildBaseURL` to build the collection URL a new record of a given type is saved to.
101
117
  * @public
102
118
  */
103
119
  /**
104
120
  * {@link buildBaseURL} options for an `updateRecord` request.
105
121
  *
122
+ * @summary Options passed to `buildBaseURL` to build the URL for saving changes to an existing record by type and id.
106
123
  * @public
107
124
  */
108
125
  /**
109
126
  * {@link buildBaseURL} options for a `deleteRecord` request.
110
127
  *
128
+ * @summary Options passed to `buildBaseURL` to build the URL for deleting an existing record by type and id.
111
129
  * @public
112
130
  */
113
131
  /**
114
132
  * {@link buildBaseURL} options for building a URL directly from a `resourcePath`
115
133
  * without an associated request operation.
116
134
  *
135
+ * @summary Options passed to `buildBaseURL` to build a URL from an explicit `resourcePath` with no request `op`.
117
136
  * @public
118
137
  */
119
138
  /**
@@ -129,6 +148,7 @@ function setBuildURLConfig(config) {
129
148
  * - {@link DeleteRecordUrlOptions}
130
149
  * - {@link GenericUrlOptions}
131
150
  *
151
+ * @summary Any of the option shapes `buildBaseURL` accepts, one per request `op` plus a generic `resourcePath` form.
132
152
  * @public
133
153
  */
134
154
  const OPERATIONS_WITH_PRIMARY_RECORDS = /* @__PURE__ */ new Set([
@@ -155,6 +175,9 @@ function resourcePathForType(options) {
155
175
  * Does not include support for building query params (see `buildQueryParams`)
156
176
  * so that it may be composed cleanly with other query-params strategies.
157
177
  *
178
+ * See the [Builders](/guides/the-manual/requests/builders) guide for writing your own request
179
+ * builders.
180
+ *
158
181
  * Usage:
159
182
  *
160
183
  * ```ts
@@ -184,6 +207,7 @@ function resourcePathForType(options) {
184
207
  * - 'findRecord' 'query' 'findMany' 'findRelatedCollection' 'findRelatedRecord'` 'createRecord' 'updateRecord' 'deleteRecord'
185
208
  * - Depending on the value of `op`, `identifier` or `identifiers` will be required.
186
209
  *
210
+ * @summary Joins host, namespace, resource path, id, and relationship field into a request URL without query params.
187
211
  * @public
188
212
  */
189
213
  function buildBaseURL(urlOptions) {
@@ -285,6 +309,11 @@ function handleInclude(include) {
285
309
  * filter out keys of an object that have falsy values or point to empty arrays
286
310
  * returning a new object with only those keys that have truthy values / non-empty arrays
287
311
  *
312
+ * See [Cache Keys for Requests](/guides/the-manual/requests/builders#cache-keys-for-requests) for
313
+ * why builders need stable query params.
314
+ *
315
+ * @summary Returns a copy of an object without keys whose values are `undefined`, `null`, empty strings, or empty
316
+ * arrays.
288
317
  * @public
289
318
  * @param source object to filter keys with empty values from
290
319
  * @return A new object with the keys that contained empty values removed
@@ -303,8 +332,15 @@ function filterEmpty(source) {
303
332
  * Sorts query params by both key and value returning a new URLSearchParams
304
333
  * object with the keys inserted in sorted order.
305
334
  *
335
+ * See [Cache Keys for Requests](/guides/the-manual/requests/builders#cache-keys-for-requests) for
336
+ * why builders need stable query params.
337
+ *
306
338
  * Treats `included` specially, splicing it into an array if it is a string and sorting the array.
307
339
  *
340
+ * The `params` given are never mutated: neither the object itself nor any array
341
+ * value it holds is reordered or replaced, so passing state that is also
342
+ * rendered (a tracked array of filter values, for instance) is safe.
343
+ *
308
344
  * Options:
309
345
  * - arrayFormat: 'bracket' | 'indices' | 'repeat' | 'comma'
310
346
  *
@@ -313,6 +349,8 @@ function filterEmpty(source) {
313
349
  * 'repeat': appends the key for every value e.g. `&ids=1&ids=2`
314
350
  * 'comma' (default): appends the key once with a comma separated list of values e.g. `&ids=1,2`
315
351
  *
352
+ * @summary Builds a `URLSearchParams` with keys and array values sorted, so equivalent queries produce identical
353
+ * params.
316
354
  * @public
317
355
  * @return A {@link URLSearchParams} with keys inserted in sorted order
318
356
  */
@@ -320,7 +358,7 @@ function sortQueryParams(params, options) {
320
358
  const opts = Object.assign({}, DEFAULT_QUERY_PARAMS_SERIALIZATION_OPTIONS, options);
321
359
  const paramsIsObject = !(params instanceof URLSearchParams);
322
360
  const urlParams = new URLSearchParams();
323
- const dictionaryParams = paramsIsObject ? params : {};
361
+ const dictionaryParams = paramsIsObject ? Object.assign({}, params) : {};
324
362
  if (!paramsIsObject) params.forEach((value, key) => {
325
363
  if (!(key in dictionaryParams)) dictionaryParams[key] = value;
326
364
  else {
@@ -333,25 +371,25 @@ function sortQueryParams(params, options) {
333
371
  Object.keys(dictionaryParams).sort().forEach((key) => {
334
372
  const value = dictionaryParams[key];
335
373
  if (Array.isArray(value)) {
336
- value.sort();
374
+ const sortedValue = value.toSorted();
337
375
  switch (opts.arrayFormat) {
338
376
  case "indices":
339
- value.forEach((v, i) => {
377
+ sortedValue.forEach((v, i) => {
340
378
  urlParams.append(`${key}[${i}]`, String(v));
341
379
  });
342
380
  return;
343
381
  case "bracket":
344
- value.forEach((v) => {
382
+ sortedValue.forEach((v) => {
345
383
  urlParams.append(`${key}[]`, String(v));
346
384
  });
347
385
  return;
348
386
  case "repeat":
349
- value.forEach((v) => {
387
+ sortedValue.forEach((v) => {
350
388
  urlParams.append(key, String(v));
351
389
  });
352
390
  return;
353
391
  default:
354
- urlParams.append(key, value.join(","));
392
+ urlParams.append(key, sortedValue.join(","));
355
393
  return;
356
394
  }
357
395
  } else urlParams.append(key, String(value));
@@ -361,8 +399,15 @@ function sortQueryParams(params, options) {
361
399
  /**
362
400
  * Sorts query params by both key and value, returning a query params string
363
401
  *
402
+ * See [Cache Keys for Requests](/guides/the-manual/requests/builders#cache-keys-for-requests) for
403
+ * why builders need stable query params.
404
+ *
364
405
  * Treats `included` specially, splicing it into an array if it is a string and sorting the array.
365
406
  *
407
+ * The `params` given are never mutated: neither the object itself nor any array
408
+ * value it holds is reordered or replaced, so passing state that is also
409
+ * rendered (a tracked array of filter values, for instance) is safe.
410
+ *
366
411
  * Options:
367
412
  * - arrayFormat: 'bracket' | 'indices' | 'repeat' | 'comma'
368
413
  *
@@ -371,6 +416,8 @@ function sortQueryParams(params, options) {
371
416
  * 'repeat': appends the key for every value e.g. `ids=1&ids=2`
372
417
  * 'comma' (default): appends the key once with a comma separated list of values e.g. `ids=1,2`
373
418
  *
419
+ * @summary Serializes query params into a string with keys and array values sorted, so equivalent queries share one
420
+ * URL.
374
421
  * @public
375
422
  * @return A sorted query params string without the leading `?`
376
423
  */
@@ -378,6 +425,5 @@ function buildQueryParams(params, options) {
378
425
  return sortQueryParams(params, options).toString();
379
426
  }
380
427
 
381
- //#endregion
382
428
  export { buildBaseURL, buildQueryParams, filterEmpty, setBuildURLConfig, sortQueryParams };
383
429
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":["getOrSetGlobal","macroCondition","getGlobalConfig","CONFIG","host","namespace","setBuildURLConfig","config","WarpDrive","env","DEBUG","test","Error","endsWith","startsWith","OPERATIONS_WITH_PRIMARY_RECORDS","Set","isOperationWithPrimaryRecord","options","has","op","hasResourcePath","resourcePath","length","resourcePathForType","identifiers","type","identifier","buildBaseURL","urlOptions","Object","assign","Array","isArray","every","i","id","idPath","encodeURIComponent","fieldPath","String","join","includes","hasHost","url","filter","Boolean","DEFAULT_QUERY_PARAMS_SERIALIZATION_OPTIONS","arrayFormat","handleInclude","include","split","filterEmpty","source","result","key","value","undefined","sortQueryParams","params","opts","paramsIsObject","URLSearchParams","urlParams","dictionaryParams","forEach","hasExisting","existingValue","push","sortedKeys","keys","sort","v","append","buildQueryParams","toString"],"sources":["../src/index.ts"],"sourcesContent":["/**\n * @module\n * @mergeModuleWith <project>\n */\n\nimport { assert } from '@warp-drive-mirror/core/build-config/macros';\nimport { getOrSetGlobal } from '@warp-drive-mirror/core/types/-private';\nimport type { QueryParamsSerializationOptions, QueryParamsSource, Serializable } from '@warp-drive-mirror/core/types/params';\n\n// prevents the final constructed object from needing to add\n// host and namespace which are provided by the final consuming\n// class to the prototype which can result in overwrite errors\n\n/**\n * The global configuration used by {@link buildBaseURL} when a call does\n * not provide its own `host`/`namespace`. Set via {@link setBuildURLConfig}.\n *\n * @public\n */\nexport interface BuildURLConfig {\n /**\n * The scheme, domain and port (if any) to prefix built URLs with, e.g. `'https://api.example.com'`.\n */\n host: string | null;\n /**\n * The path segment to insert between `host` and the resource path, e.g. `'api/v1'`.\n */\n namespace: string | null;\n}\n\nconst CONFIG: BuildURLConfig = getOrSetGlobal('CONFIG', {\n host: '',\n namespace: '',\n});\n\n/**\n * Sets the global configuration for `buildBaseURL`\n * for host and namespace values for the application.\n *\n * These values may still be overridden by passing\n * them to buildBaseURL directly.\n *\n * This method may be called as many times as needed.\n * host values of `''` or `'/'` are equivalent.\n *\n * Except for the value of `/` as host, host should not\n * end with `/`.\n *\n * namespace should not start or end with a `/`.\n *\n * ```ts\n * type BuildURLConfig = {\n * host: string;\n * namespace: string'\n * }\n * ```\n *\n * Example:\n *\n * ```ts\n * import { setBuildURLConfig } from '@warp-drive-mirror/utilities';\n *\n * setBuildURLConfig({\n * host: 'https://api.example.com',\n * namespace: 'api/v1'\n * });\n * ```\n *\n * @public\n */\nexport function setBuildURLConfig(config: BuildURLConfig): void {\n assert(`setBuildURLConfig: You must pass a config object`, config);\n assert(\n `setBuildURLConfig: You must pass a config object with a 'host' or 'namespace' property`,\n 'host' in config || 'namespace' in config\n );\n\n CONFIG.host = config.host || '';\n CONFIG.namespace = config.namespace || '';\n\n assert(\n `buildBaseURL: host must NOT end with '/', received '${CONFIG.host}'`,\n CONFIG.host === '/' || !CONFIG.host.endsWith('/')\n );\n assert(\n `buildBaseURL: namespace must NOT start with '/', received '${CONFIG.namespace}'`,\n !CONFIG.namespace.startsWith('/')\n );\n assert(\n `buildBaseURL: namespace must NOT end with '/', received '${CONFIG.namespace}'`,\n !CONFIG.namespace.endsWith('/')\n );\n}\n\n/**\n * {@link buildBaseURL} options for a `findRecord` request.\n *\n * @public\n */\nexport interface FindRecordUrlOptions {\n /**\n * The request operation this URL is for.\n */\n op: 'findRecord';\n /**\n * The type and id of the record to find.\n */\n identifier: {\n /**\n * The resource type.\n */\n type: string;\n /**\n * The resource id.\n */\n id: string;\n };\n /**\n * The path segment for the resource, defaults to `identifier.type` if not provided.\n */\n resourcePath?: string;\n /**\n * Overrides the globally configured host for this call only.\n */\n host?: string;\n /**\n * Overrides the globally configured namespace for this call only.\n */\n namespace?: string;\n}\n\n/**\n * {@link buildBaseURL} options for a `query` request.\n *\n * @public\n */\nexport interface QueryUrlOptions {\n /**\n * The request operation this URL is for.\n */\n op: 'query';\n /**\n * The type of the records to query.\n */\n identifier: {\n /**\n * The resource type.\n */\n type: string;\n };\n /**\n * The path segment for the resource, defaults to `identifier.type` if not provided.\n */\n resourcePath?: string;\n /**\n * Overrides the globally configured host for this call only.\n */\n host?: string;\n /**\n * Overrides the globally configured namespace for this call only.\n */\n namespace?: string;\n}\n\n/**\n * {@link buildBaseURL} options for a `findMany` request.\n *\n * @public\n */\nexport interface FindManyUrlOptions {\n /**\n * The request operation this URL is for.\n */\n op: 'findMany';\n /**\n * The type and id of each record to find.\n */\n identifiers: {\n /**\n * The resource type.\n */\n type: string;\n /**\n * The resource id.\n */\n id: string;\n }[];\n /**\n * The path segment for the resource, defaults to the first identifier's `type` if not provided.\n */\n resourcePath?: string;\n /**\n * Overrides the globally configured host for this call only.\n */\n host?: string;\n /**\n * Overrides the globally configured namespace for this call only.\n */\n namespace?: string;\n}\n/**\n * {@link buildBaseURL} options for a `findRelatedCollection` request.\n *\n * @public\n */\nexport interface FindRelatedCollectionUrlOptions {\n /**\n * The request operation this URL is for.\n */\n op: 'findRelatedCollection';\n /**\n * The type and id of the record whose relationship is being fetched.\n */\n identifier: {\n /**\n * The resource type.\n */\n type: string;\n /**\n * The resource id.\n */\n id: string;\n };\n /**\n * The relationship field name, appended to the resource path.\n */\n fieldPath: string;\n /**\n * The path segment for the resource, defaults to `identifier.type` if not provided.\n */\n resourcePath?: string;\n /**\n * Overrides the globally configured host for this call only.\n */\n host?: string;\n /**\n * Overrides the globally configured namespace for this call only.\n */\n namespace?: string;\n}\n\n/**\n * {@link buildBaseURL} options for a `findRelatedRecord` request.\n *\n * @public\n */\nexport interface FindRelatedResourceUrlOptions {\n /**\n * The request operation this URL is for.\n */\n op: 'findRelatedRecord';\n /**\n * The type and id of the record whose relationship is being fetched.\n */\n identifier: {\n /**\n * The resource type.\n */\n type: string;\n /**\n * The resource id.\n */\n id: string;\n };\n /**\n * The relationship field name, appended to the resource path.\n */\n fieldPath: string;\n /**\n * The path segment for the resource, defaults to `identifier.type` if not provided.\n */\n resourcePath?: string;\n /**\n * Overrides the globally configured host for this call only.\n */\n host?: string;\n /**\n * Overrides the globally configured namespace for this call only.\n */\n namespace?: string;\n}\n\n/**\n * {@link buildBaseURL} options for a `createRecord` request.\n *\n * @public\n */\nexport interface CreateRecordUrlOptions {\n /**\n * The request operation this URL is for.\n */\n op: 'createRecord';\n /**\n * The type of the record being created.\n */\n identifier: {\n /**\n * The resource type.\n */\n type: string;\n };\n /**\n * The path segment for the resource, defaults to `identifier.type` if not provided.\n */\n resourcePath?: string;\n /**\n * Overrides the globally configured host for this call only.\n */\n host?: string;\n /**\n * Overrides the globally configured namespace for this call only.\n */\n namespace?: string;\n}\n\n/**\n * {@link buildBaseURL} options for an `updateRecord` request.\n *\n * @public\n */\nexport interface UpdateRecordUrlOptions {\n /**\n * The request operation this URL is for.\n */\n op: 'updateRecord';\n /**\n * The type and id of the record being updated.\n */\n identifier: {\n /**\n * The resource type.\n */\n type: string;\n /**\n * The resource id.\n */\n id: string;\n };\n /**\n * The path segment for the resource, defaults to `identifier.type` if not provided.\n */\n resourcePath?: string;\n /**\n * Overrides the globally configured host for this call only.\n */\n host?: string;\n /**\n * Overrides the globally configured namespace for this call only.\n */\n namespace?: string;\n}\n\n/**\n * {@link buildBaseURL} options for a `deleteRecord` request.\n *\n * @public\n */\nexport interface DeleteRecordUrlOptions {\n /**\n * The request operation this URL is for.\n */\n op: 'deleteRecord';\n /**\n * The type and id of the record being deleted.\n */\n identifier: {\n /**\n * The resource type.\n */\n type: string;\n /**\n * The resource id.\n */\n id: string;\n };\n /**\n * The path segment for the resource, defaults to `identifier.type` if not provided.\n */\n resourcePath?: string;\n /**\n * Overrides the globally configured host for this call only.\n */\n host?: string;\n /**\n * Overrides the globally configured namespace for this call only.\n */\n namespace?: string;\n}\n\n/**\n * {@link buildBaseURL} options for building a URL directly from a `resourcePath`\n * without an associated request operation.\n *\n * @public\n */\nexport interface GenericUrlOptions {\n /**\n * The path segment for the resource.\n */\n resourcePath: string;\n /**\n * Overrides the globally configured host for this call only.\n */\n host?: string;\n /**\n * Overrides the globally configured namespace for this call only.\n */\n namespace?: string;\n}\n\n/**\n * The union of all `op`-specific option shapes accepted by {@link buildBaseURL}, one of:\n *\n * - {@link FindRecordUrlOptions}\n * - {@link QueryUrlOptions}\n * - {@link FindManyUrlOptions}\n * - {@link FindRelatedCollectionUrlOptions}\n * - {@link FindRelatedResourceUrlOptions}\n * - {@link CreateRecordUrlOptions}\n * - {@link UpdateRecordUrlOptions}\n * - {@link DeleteRecordUrlOptions}\n * - {@link GenericUrlOptions}\n *\n * @public\n */\nexport type UrlOptions =\n | FindRecordUrlOptions\n | QueryUrlOptions\n | FindManyUrlOptions\n | FindRelatedCollectionUrlOptions\n | FindRelatedResourceUrlOptions\n | CreateRecordUrlOptions\n | UpdateRecordUrlOptions\n | DeleteRecordUrlOptions\n | GenericUrlOptions;\n\nconst OPERATIONS_WITH_PRIMARY_RECORDS = new Set([\n 'findRecord',\n 'findRelatedRecord',\n 'findRelatedCollection',\n 'updateRecord',\n 'deleteRecord',\n]);\n\nfunction isOperationWithPrimaryRecord(\n options: UrlOptions\n): options is\n | FindRecordUrlOptions\n | FindRelatedCollectionUrlOptions\n | FindRelatedResourceUrlOptions\n | UpdateRecordUrlOptions\n | DeleteRecordUrlOptions {\n return 'op' in options && OPERATIONS_WITH_PRIMARY_RECORDS.has(options.op);\n}\n\nfunction hasResourcePath(options: UrlOptions): options is GenericUrlOptions {\n return 'resourcePath' in options && typeof options.resourcePath === 'string' && options.resourcePath.length > 0;\n}\n\nfunction resourcePathForType(options: UrlOptions): string {\n assert(\n `resourcePathForType: You must pass a valid op as part of options`,\n 'op' in options && typeof options.op === 'string'\n );\n return options.op === 'findMany' ? options.identifiers[0].type : options.identifier.type;\n}\n\n/**\n * Builds a URL for a request based on the provided options.\n * Does not include support for building query params (see `buildQueryParams`)\n * so that it may be composed cleanly with other query-params strategies.\n *\n * Usage:\n *\n * ```ts\n * import { buildBaseURL } from '@warp-drive-mirror/utilities';\n *\n * const url = buildBaseURL({\n * host: 'https://api.example.com',\n * namespace: 'api/v1',\n * resourcePath: 'emberDevelopers',\n * op: 'query',\n * identifier: { type: 'ember-developer' }\n * });\n *\n * // => 'https://api.example.com/api/v1/emberDevelopers'\n * ```\n *\n * On the surface this may seem like a lot of work to do something simple, but\n * it is designed to be composable with other utilities and interfaces that the\n * average product engineer will never need to see or use.\n *\n * A few notes:\n *\n * - `resourcePath` is optional, but if it is not provided, `identifier.type` will be used.\n * - `host` and `namespace` are optional, but if they are not provided, the values globally\n * configured via `setBuildURLConfig` will be used.\n * - `op` is required and must be one of the following:\n * - 'findRecord' 'query' 'findMany' 'findRelatedCollection' 'findRelatedRecord'` 'createRecord' 'updateRecord' 'deleteRecord'\n * - Depending on the value of `op`, `identifier` or `identifiers` will be required.\n *\n * @public\n */\nexport function buildBaseURL(urlOptions: UrlOptions): string {\n const options = Object.assign(\n {\n host: CONFIG.host,\n namespace: CONFIG.namespace,\n },\n urlOptions\n );\n assert(\n `buildBaseURL: You must pass \\`op\\` as part of options`,\n hasResourcePath(options) || (typeof options.op === 'string' && options.op.length > 0)\n );\n assert(\n `buildBaseURL: You must pass \\`identifier\\` as part of options`,\n hasResourcePath(options) ||\n options.op === 'findMany' ||\n (options.identifier && typeof options.identifier === 'object')\n );\n assert(\n `buildBaseURL: You must pass \\`identifiers\\` as part of options`,\n hasResourcePath(options) ||\n options.op !== 'findMany' ||\n (options.identifiers &&\n Array.isArray(options.identifiers) &&\n options.identifiers.length > 0 &&\n options.identifiers.every((i) => i && typeof i === 'object'))\n );\n assert(\n `buildBaseURL: You must pass valid \\`identifier\\` as part of options, expected 'id'`,\n hasResourcePath(options) ||\n !isOperationWithPrimaryRecord(options) ||\n (typeof options.identifier.id === 'string' && options.identifier.id.length > 0)\n );\n assert(\n `buildBaseURL: You must pass \\`identifiers\\` as part of options`,\n hasResourcePath(options) ||\n options.op !== 'findMany' ||\n options.identifiers.every((i) => typeof i.id === 'string' && i.id.length > 0)\n );\n assert(\n `buildBaseURL: You must pass valid \\`identifier\\` as part of options, expected 'type'`,\n hasResourcePath(options) ||\n options.op === 'findMany' ||\n (typeof options.identifier.type === 'string' && options.identifier.type.length > 0)\n );\n assert(\n `buildBaseURL: You must pass valid \\`identifiers\\` as part of options, expected 'type'`,\n hasResourcePath(options) ||\n options.op !== 'findMany' ||\n (typeof options.identifiers[0].type === 'string' && options.identifiers[0].type.length > 0)\n );\n\n // prettier-ignore\n const idPath: string =\n isOperationWithPrimaryRecord(options) ? encodeURIComponent(options.identifier.id)\n : '';\n const resourcePath = options.resourcePath || resourcePathForType(options);\n const { host, namespace } = options;\n const fieldPath = 'fieldPath' in options ? options.fieldPath : '';\n\n assert(\n `buildBaseURL: You tried to build a url for a ${String(\n 'op' in options ? options.op + ' ' : ''\n )}request to ${resourcePath} but resourcePath must be set or op must be one of \"${[\n 'findRecord',\n 'findRelatedRecord',\n 'findRelatedCollection',\n 'updateRecord',\n 'deleteRecord',\n 'createRecord',\n 'query',\n 'findMany',\n ].join('\",\"')}\".`,\n hasResourcePath(options) ||\n [\n 'findRecord',\n 'query',\n 'findMany',\n 'findRelatedCollection',\n 'findRelatedRecord',\n 'createRecord',\n 'updateRecord',\n 'deleteRecord',\n ].includes(options.op)\n );\n\n assert(`buildBaseURL: host must NOT end with '/', received '${host}'`, host === '/' || !host.endsWith('/'));\n assert(`buildBaseURL: namespace must NOT start with '/', received '${namespace}'`, !namespace.startsWith('/'));\n assert(`buildBaseURL: namespace must NOT end with '/', received '${namespace}'`, !namespace.endsWith('/'));\n assert(\n `buildBaseURL: resourcePath must NOT start with '/', received '${resourcePath}'`,\n !resourcePath.startsWith('/')\n );\n assert(`buildBaseURL: resourcePath must NOT end with '/', received '${resourcePath}'`, !resourcePath.endsWith('/'));\n assert(`buildBaseURL: fieldPath must NOT start with '/', received '${fieldPath}'`, !fieldPath.startsWith('/'));\n assert(`buildBaseURL: fieldPath must NOT end with '/', received '${fieldPath}'`, !fieldPath.endsWith('/'));\n assert(`buildBaseURL: idPath must NOT start with '/', received '${idPath}'`, !idPath.startsWith('/'));\n assert(`buildBaseURL: idPath must NOT end with '/', received '${idPath}'`, !idPath.endsWith('/'));\n\n const hasHost = host !== '' && host !== '/';\n const url = [hasHost ? host : '', namespace, resourcePath, idPath, fieldPath].filter(Boolean).join('/');\n return hasHost ? url : `/${url}`;\n}\n\nconst DEFAULT_QUERY_PARAMS_SERIALIZATION_OPTIONS: QueryParamsSerializationOptions = {\n arrayFormat: 'comma',\n};\n\nfunction handleInclude(include: string | string[]): string[] {\n assert(\n `Expected include to be a string or array, got ${typeof include}`,\n typeof include === 'string' || Array.isArray(include)\n );\n return typeof include === 'string' ? include.split(',') : include;\n}\n\n/**\n * filter out keys of an object that have falsy values or point to empty arrays\n * returning a new object with only those keys that have truthy values / non-empty arrays\n *\n * @public\n * @param source object to filter keys with empty values from\n * @return A new object with the keys that contained empty values removed\n */\nexport function filterEmpty(source: Record<string, Serializable>): Record<string, Serializable> {\n const result: Record<string, Serializable> = {};\n for (const key in source) {\n const value = source[key];\n // Allow `0` and `false` but filter falsy values that indicate \"empty\"\n if (value !== undefined && value !== null && value !== '') {\n if (!Array.isArray(value) || value.length > 0) {\n result[key] = source[key];\n }\n }\n }\n return result;\n}\n\n/**\n * Sorts query params by both key and value returning a new URLSearchParams\n * object with the keys inserted in sorted order.\n *\n * Treats `included` specially, splicing it into an array if it is a string and sorting the array.\n *\n * Options:\n * - arrayFormat: 'bracket' | 'indices' | 'repeat' | 'comma'\n *\n * 'bracket': appends [] to the key for every value e.g. `&ids[]=1&ids[]=2`\n * 'indices': appends [i] to the key for every value e.g. `&ids[0]=1&ids[1]=2`\n * 'repeat': appends the key for every value e.g. `&ids=1&ids=2`\n * 'comma' (default): appends the key once with a comma separated list of values e.g. `&ids=1,2`\n *\n * @public\n * @return A {@link URLSearchParams} with keys inserted in sorted order\n */\nexport function sortQueryParams(params: QueryParamsSource, options?: QueryParamsSerializationOptions): URLSearchParams {\n const opts = Object.assign({}, DEFAULT_QUERY_PARAMS_SERIALIZATION_OPTIONS, options);\n const paramsIsObject = !(params instanceof URLSearchParams);\n const urlParams = new URLSearchParams();\n const dictionaryParams: Record<string, Serializable> = paramsIsObject ? params : {};\n\n if (!paramsIsObject) {\n params.forEach((value, key) => {\n const hasExisting = key in dictionaryParams;\n if (!hasExisting) {\n dictionaryParams[key] = value;\n } else {\n const existingValue = dictionaryParams[key];\n if (Array.isArray(existingValue)) {\n existingValue.push(value);\n } else {\n dictionaryParams[key] = [existingValue, value];\n }\n }\n });\n }\n\n if ('include' in dictionaryParams) {\n dictionaryParams.include = handleInclude(dictionaryParams.include as string | string[]);\n }\n\n const sortedKeys = Object.keys(dictionaryParams).sort();\n sortedKeys.forEach((key) => {\n const value = dictionaryParams[key];\n if (Array.isArray(value)) {\n value.sort();\n switch (opts.arrayFormat) {\n case 'indices':\n value.forEach((v, i) => {\n urlParams.append(`${key}[${i}]`, String(v));\n });\n return;\n case 'bracket':\n value.forEach((v) => {\n urlParams.append(`${key}[]`, String(v));\n });\n return;\n case 'repeat':\n value.forEach((v) => {\n urlParams.append(key, String(v));\n });\n return;\n case 'comma':\n default:\n urlParams.append(key, value.join(','));\n return;\n }\n } else {\n urlParams.append(key, String(value));\n }\n });\n\n return urlParams;\n}\n\n/**\n * Sorts query params by both key and value, returning a query params string\n *\n * Treats `included` specially, splicing it into an array if it is a string and sorting the array.\n *\n * Options:\n * - arrayFormat: 'bracket' | 'indices' | 'repeat' | 'comma'\n *\n * 'bracket': appends [] to the key for every value e.g. `ids[]=1&ids[]=2`\n * 'indices': appends [i] to the key for every value e.g. `ids[0]=1&ids[1]=2`\n * 'repeat': appends the key for every value e.g. `ids=1&ids=2`\n * 'comma' (default): appends the key once with a comma separated list of values e.g. `ids=1,2`\n *\n * @public\n * @return A sorted query params string without the leading `?`\n */\nexport function buildQueryParams(params: QueryParamsSource, options?: QueryParamsSerializationOptions): string {\n return sortQueryParams(params, options).toString();\n}\n"],"mappings":";;;;;;;;;;;;;;AA8BA,MAAMG,SAAyBH,eAAe,UAAU;CACtDI,MAAM;CACNC,WAAW;AACb,CA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;EAEjD;CACF,CAAC;CAGH,IAAI,aAAaQ,kBACfA,iBAAiBd,UAAUD,cAAce,iBAAiBd,OAA4B;CAIxFmB,AADmBvC,OAAOwC,KAAKN,gBAAgB,CAAC,CAACO,KACjDF,CAAU,CAACJ,SAASV,QAAQ;EAC1B,MAAMC,QAAQQ,iBAAiBT;EAC/B,IAAIvB,MAAMC,QAAQuB,KAAK,GAAG;GACxBA,MAAMe,KAAK;GACX,QAAQX,KAAKZ,aAAb;IACE,KAAK;KACHQ,MAAMS,SAASO,GAAGrC,MAAM;MACtB4B,UAAUU,OAAO,GAAGlB,IAAG,GAAIpB,EAAC,IAAKK,OAAOgC,CAAC,CAAC;KAC5C,CAAC;KACD;IACF,KAAK;KACHhB,MAAMS,SAASO,MAAM;MACnBT,UAAUU,OAAO,GAAGlB,IAAG,KAAMf,OAAOgC,CAAC,CAAC;KACxC,CAAC;KACD;IACF,KAAK;KACHhB,MAAMS,SAASO,MAAM;MACnBT,UAAUU,OAAOlB,KAAKf,OAAOgC,CAAC,CAAC;KACjC,CAAC;KACD;IAEF;KACET,UAAUU,OAAOlB,KAAKC,MAAMf,KAAK,GAAG,CAAC;KACrC;GACJ;EACF,OACEsB,UAAUU,OAAOlB,KAAKf,OAAOgB,KAAK,CAAC;CAEvC,CAAC;CAED,OAAOO;AACT;;;;;;;;;;;;;;;;;AAkBA,SAAgBW,iBAAiBf,QAA2BzC,SAAmD;CAC7G,OAAOwC,gBAAgBC,QAAQzC,OAAO,CAAC,CAACyD,SAAS;AACnD"}
1
+ {"version":3,"file":"index.js","names":["getOrSetGlobal","macroCondition","getGlobalConfig","CONFIG","host","namespace","setBuildURLConfig","config","WarpDrive","env","DEBUG","test","Error","endsWith","startsWith","OPERATIONS_WITH_PRIMARY_RECORDS","Set","isOperationWithPrimaryRecord","options","has","op","hasResourcePath","resourcePath","length","resourcePathForType","identifiers","type","identifier","buildBaseURL","urlOptions","Object","assign","Array","isArray","every","i","id","idPath","encodeURIComponent","fieldPath","String","join","includes","hasHost","url","filter","Boolean","DEFAULT_QUERY_PARAMS_SERIALIZATION_OPTIONS","arrayFormat","handleInclude","include","split","filterEmpty","source","result","key","value","undefined","sortQueryParams","params","opts","paramsIsObject","URLSearchParams","urlParams","dictionaryParams","forEach","hasExisting","existingValue","push","sortedKeys","keys","sort","sortedValue","toSorted","v","append","buildQueryParams","toString"],"sources":["../src/index.ts"],"sourcesContent":["/**\n * @summary Helpers for building request URLs and sorted query strings, with a configurable global host and namespace.\n * @module\n * @mergeModuleWith <project>\n */\n\nimport { assert } from '@warp-drive-mirror/core/build-config/macros';\nimport { getOrSetGlobal } from '@warp-drive-mirror/core/types/-private';\nimport type { QueryParamsSerializationOptions, QueryParamsSource, Serializable } from '@warp-drive-mirror/core/types/params';\n\n// prevents the final constructed object from needing to add\n// host and namespace which are provided by the final consuming\n// class to the prototype which can result in overwrite errors\n\n/**\n * The global configuration used by {@link buildBaseURL} when a call does\n * not provide its own `host`/`namespace`. Set via {@link setBuildURLConfig}.\n *\n * @summary The global `host` and `namespace` that `buildBaseURL` prefixes onto URLs when a call does not pass its own.\n * @public\n */\nexport interface BuildURLConfig {\n /**\n * The scheme, domain and port (if any) to prefix built URLs with, e.g. `'https://api.example.com'`.\n */\n host: string | null;\n /**\n * The path segment to insert between `host` and the resource path, e.g. `'api/v1'`.\n */\n namespace: string | null;\n}\n\nconst CONFIG: BuildURLConfig = getOrSetGlobal('CONFIG', {\n host: '',\n namespace: '',\n});\n\n/**\n * Sets the global configuration for `buildBaseURL`\n * for host and namespace values for the application.\n *\n * These values may still be overridden by passing\n * them to buildBaseURL directly.\n *\n * The [Basic Usage](/guides/the-manual/cookbook/basic-usage#step-2-configure-some-request-defaults)\n * guide sets these defaults through the `@warp-drive-mirror/utilities/json-api` version of this function,\n * which also sets this global configuration.\n *\n * This method may be called as many times as needed.\n * host values of `''` or `'/'` are equivalent.\n *\n * Except for the value of `/` as host, host should not\n * end with `/`.\n *\n * namespace should not start or end with a `/`.\n *\n * ```ts\n * type BuildURLConfig = {\n * host: string;\n * namespace: string'\n * }\n * ```\n *\n * Example:\n *\n * ```ts\n * import { setBuildURLConfig } from '@warp-drive-mirror/utilities';\n *\n * setBuildURLConfig({\n * host: 'https://api.example.com',\n * namespace: 'api/v1'\n * });\n * ```\n *\n * @summary Sets the app-wide default `host` and `namespace` used by `buildBaseURL` and the request builders.\n * @public\n */\nexport function setBuildURLConfig(config: BuildURLConfig): void {\n assert(`setBuildURLConfig: You must pass a config object`, config);\n assert(\n `setBuildURLConfig: You must pass a config object with a 'host' or 'namespace' property`,\n 'host' in config || 'namespace' in config\n );\n\n CONFIG.host = config.host || '';\n CONFIG.namespace = config.namespace || '';\n\n assert(\n `buildBaseURL: host must NOT end with '/', received '${CONFIG.host}'`,\n CONFIG.host === '/' || !CONFIG.host.endsWith('/')\n );\n assert(\n `buildBaseURL: namespace must NOT start with '/', received '${CONFIG.namespace}'`,\n !CONFIG.namespace.startsWith('/')\n );\n assert(\n `buildBaseURL: namespace must NOT end with '/', received '${CONFIG.namespace}'`,\n !CONFIG.namespace.endsWith('/')\n );\n}\n\n/**\n * {@link buildBaseURL} options for a `findRecord` request.\n *\n * @summary Options passed to `buildBaseURL` to build the URL for fetching one resource by type and id.\n * @public\n */\nexport interface FindRecordUrlOptions {\n /**\n * The request operation this URL is for.\n */\n op: 'findRecord';\n /**\n * The type and id of the record to find.\n */\n identifier: {\n /**\n * The resource type.\n */\n type: string;\n /**\n * The resource id.\n */\n id: string;\n };\n /**\n * The path segment for the resource, defaults to `identifier.type` if not provided.\n */\n resourcePath?: string;\n /**\n * Overrides the globally configured host for this call only.\n */\n host?: string;\n /**\n * Overrides the globally configured namespace for this call only.\n */\n namespace?: string;\n}\n\n/**\n * {@link buildBaseURL} options for a `query` request.\n *\n * @summary Options passed to `buildBaseURL` to build the URL for querying a collection of one resource type.\n * @public\n */\nexport interface QueryUrlOptions {\n /**\n * The request operation this URL is for.\n */\n op: 'query';\n /**\n * The type of the records to query.\n */\n identifier: {\n /**\n * The resource type.\n */\n type: string;\n };\n /**\n * The path segment for the resource, defaults to `identifier.type` if not provided.\n */\n resourcePath?: string;\n /**\n * Overrides the globally configured host for this call only.\n */\n host?: string;\n /**\n * Overrides the globally configured namespace for this call only.\n */\n namespace?: string;\n}\n\n/**\n * {@link buildBaseURL} options for a `findMany` request.\n *\n * @summary Options passed to `buildBaseURL` to build the URL for fetching several resources, pathed by the first\n * identifier's type.\n * @public\n */\nexport interface FindManyUrlOptions {\n /**\n * The request operation this URL is for.\n */\n op: 'findMany';\n /**\n * The type and id of each record to find.\n */\n identifiers: {\n /**\n * The resource type.\n */\n type: string;\n /**\n * The resource id.\n */\n id: string;\n }[];\n /**\n * The path segment for the resource, defaults to the first identifier's `type` if not provided.\n */\n resourcePath?: string;\n /**\n * Overrides the globally configured host for this call only.\n */\n host?: string;\n /**\n * Overrides the globally configured namespace for this call only.\n */\n namespace?: string;\n}\n/**\n * {@link buildBaseURL} options for a `findRelatedCollection` request.\n *\n * @summary Options passed to `buildBaseURL` to build the URL for a record's has-many relationship, ending in the\n * field name.\n * @public\n */\nexport interface FindRelatedCollectionUrlOptions {\n /**\n * The request operation this URL is for.\n */\n op: 'findRelatedCollection';\n /**\n * The type and id of the record whose relationship is being fetched.\n */\n identifier: {\n /**\n * The resource type.\n */\n type: string;\n /**\n * The resource id.\n */\n id: string;\n };\n /**\n * The relationship field name, appended to the resource path.\n */\n fieldPath: string;\n /**\n * The path segment for the resource, defaults to `identifier.type` if not provided.\n */\n resourcePath?: string;\n /**\n * Overrides the globally configured host for this call only.\n */\n host?: string;\n /**\n * Overrides the globally configured namespace for this call only.\n */\n namespace?: string;\n}\n\n/**\n * {@link buildBaseURL} options for a `findRelatedRecord` request.\n *\n * @summary Options passed to `buildBaseURL` to build the URL for a record's belongs-to relationship, ending in the\n * field name.\n * @public\n */\nexport interface FindRelatedResourceUrlOptions {\n /**\n * The request operation this URL is for.\n */\n op: 'findRelatedRecord';\n /**\n * The type and id of the record whose relationship is being fetched.\n */\n identifier: {\n /**\n * The resource type.\n */\n type: string;\n /**\n * The resource id.\n */\n id: string;\n };\n /**\n * The relationship field name, appended to the resource path.\n */\n fieldPath: string;\n /**\n * The path segment for the resource, defaults to `identifier.type` if not provided.\n */\n resourcePath?: string;\n /**\n * Overrides the globally configured host for this call only.\n */\n host?: string;\n /**\n * Overrides the globally configured namespace for this call only.\n */\n namespace?: string;\n}\n\n/**\n * {@link buildBaseURL} options for a `createRecord` request.\n *\n * @summary Options passed to `buildBaseURL` to build the collection URL a new record of a given type is saved to.\n * @public\n */\nexport interface CreateRecordUrlOptions {\n /**\n * The request operation this URL is for.\n */\n op: 'createRecord';\n /**\n * The type of the record being created.\n */\n identifier: {\n /**\n * The resource type.\n */\n type: string;\n };\n /**\n * The path segment for the resource, defaults to `identifier.type` if not provided.\n */\n resourcePath?: string;\n /**\n * Overrides the globally configured host for this call only.\n */\n host?: string;\n /**\n * Overrides the globally configured namespace for this call only.\n */\n namespace?: string;\n}\n\n/**\n * {@link buildBaseURL} options for an `updateRecord` request.\n *\n * @summary Options passed to `buildBaseURL` to build the URL for saving changes to an existing record by type and id.\n * @public\n */\nexport interface UpdateRecordUrlOptions {\n /**\n * The request operation this URL is for.\n */\n op: 'updateRecord';\n /**\n * The type and id of the record being updated.\n */\n identifier: {\n /**\n * The resource type.\n */\n type: string;\n /**\n * The resource id.\n */\n id: string;\n };\n /**\n * The path segment for the resource, defaults to `identifier.type` if not provided.\n */\n resourcePath?: string;\n /**\n * Overrides the globally configured host for this call only.\n */\n host?: string;\n /**\n * Overrides the globally configured namespace for this call only.\n */\n namespace?: string;\n}\n\n/**\n * {@link buildBaseURL} options for a `deleteRecord` request.\n *\n * @summary Options passed to `buildBaseURL` to build the URL for deleting an existing record by type and id.\n * @public\n */\nexport interface DeleteRecordUrlOptions {\n /**\n * The request operation this URL is for.\n */\n op: 'deleteRecord';\n /**\n * The type and id of the record being deleted.\n */\n identifier: {\n /**\n * The resource type.\n */\n type: string;\n /**\n * The resource id.\n */\n id: string;\n };\n /**\n * The path segment for the resource, defaults to `identifier.type` if not provided.\n */\n resourcePath?: string;\n /**\n * Overrides the globally configured host for this call only.\n */\n host?: string;\n /**\n * Overrides the globally configured namespace for this call only.\n */\n namespace?: string;\n}\n\n/**\n * {@link buildBaseURL} options for building a URL directly from a `resourcePath`\n * without an associated request operation.\n *\n * @summary Options passed to `buildBaseURL` to build a URL from an explicit `resourcePath` with no request `op`.\n * @public\n */\nexport interface GenericUrlOptions {\n /**\n * The path segment for the resource.\n */\n resourcePath: string;\n /**\n * Overrides the globally configured host for this call only.\n */\n host?: string;\n /**\n * Overrides the globally configured namespace for this call only.\n */\n namespace?: string;\n}\n\n/**\n * The union of all `op`-specific option shapes accepted by {@link buildBaseURL}, one of:\n *\n * - {@link FindRecordUrlOptions}\n * - {@link QueryUrlOptions}\n * - {@link FindManyUrlOptions}\n * - {@link FindRelatedCollectionUrlOptions}\n * - {@link FindRelatedResourceUrlOptions}\n * - {@link CreateRecordUrlOptions}\n * - {@link UpdateRecordUrlOptions}\n * - {@link DeleteRecordUrlOptions}\n * - {@link GenericUrlOptions}\n *\n * @summary Any of the option shapes `buildBaseURL` accepts, one per request `op` plus a generic `resourcePath` form.\n * @public\n */\nexport type UrlOptions =\n | FindRecordUrlOptions\n | QueryUrlOptions\n | FindManyUrlOptions\n | FindRelatedCollectionUrlOptions\n | FindRelatedResourceUrlOptions\n | CreateRecordUrlOptions\n | UpdateRecordUrlOptions\n | DeleteRecordUrlOptions\n | GenericUrlOptions;\n\nconst OPERATIONS_WITH_PRIMARY_RECORDS = new Set([\n 'findRecord',\n 'findRelatedRecord',\n 'findRelatedCollection',\n 'updateRecord',\n 'deleteRecord',\n]);\n\nfunction isOperationWithPrimaryRecord(\n options: UrlOptions\n): options is\n | FindRecordUrlOptions\n | FindRelatedCollectionUrlOptions\n | FindRelatedResourceUrlOptions\n | UpdateRecordUrlOptions\n | DeleteRecordUrlOptions {\n return 'op' in options && OPERATIONS_WITH_PRIMARY_RECORDS.has(options.op);\n}\n\nfunction hasResourcePath(options: UrlOptions): options is GenericUrlOptions {\n return 'resourcePath' in options && typeof options.resourcePath === 'string' && options.resourcePath.length > 0;\n}\n\nfunction resourcePathForType(options: UrlOptions): string {\n assert(\n `resourcePathForType: You must pass a valid op as part of options`,\n 'op' in options && typeof options.op === 'string'\n );\n return options.op === 'findMany' ? options.identifiers[0].type : options.identifier.type;\n}\n\n/**\n * Builds a URL for a request based on the provided options.\n * Does not include support for building query params (see `buildQueryParams`)\n * so that it may be composed cleanly with other query-params strategies.\n *\n * See the [Builders](/guides/the-manual/requests/builders) guide for writing your own request\n * builders.\n *\n * Usage:\n *\n * ```ts\n * import { buildBaseURL } from '@warp-drive-mirror/utilities';\n *\n * const url = buildBaseURL({\n * host: 'https://api.example.com',\n * namespace: 'api/v1',\n * resourcePath: 'emberDevelopers',\n * op: 'query',\n * identifier: { type: 'ember-developer' }\n * });\n *\n * // => 'https://api.example.com/api/v1/emberDevelopers'\n * ```\n *\n * On the surface this may seem like a lot of work to do something simple, but\n * it is designed to be composable with other utilities and interfaces that the\n * average product engineer will never need to see or use.\n *\n * A few notes:\n *\n * - `resourcePath` is optional, but if it is not provided, `identifier.type` will be used.\n * - `host` and `namespace` are optional, but if they are not provided, the values globally\n * configured via `setBuildURLConfig` will be used.\n * - `op` is required and must be one of the following:\n * - 'findRecord' 'query' 'findMany' 'findRelatedCollection' 'findRelatedRecord'` 'createRecord' 'updateRecord' 'deleteRecord'\n * - Depending on the value of `op`, `identifier` or `identifiers` will be required.\n *\n * @summary Joins host, namespace, resource path, id, and relationship field into a request URL without query params.\n * @public\n */\nexport function buildBaseURL(urlOptions: UrlOptions): string {\n const options = Object.assign(\n {\n host: CONFIG.host,\n namespace: CONFIG.namespace,\n },\n urlOptions\n );\n assert(\n `buildBaseURL: You must pass \\`op\\` as part of options`,\n hasResourcePath(options) || (typeof options.op === 'string' && options.op.length > 0)\n );\n assert(\n `buildBaseURL: You must pass \\`identifier\\` as part of options`,\n hasResourcePath(options) ||\n options.op === 'findMany' ||\n (options.identifier && typeof options.identifier === 'object')\n );\n assert(\n `buildBaseURL: You must pass \\`identifiers\\` as part of options`,\n hasResourcePath(options) ||\n options.op !== 'findMany' ||\n (options.identifiers &&\n Array.isArray(options.identifiers) &&\n options.identifiers.length > 0 &&\n options.identifiers.every((i) => i && typeof i === 'object'))\n );\n assert(\n `buildBaseURL: You must pass valid \\`identifier\\` as part of options, expected 'id'`,\n hasResourcePath(options) ||\n !isOperationWithPrimaryRecord(options) ||\n (typeof options.identifier.id === 'string' && options.identifier.id.length > 0)\n );\n assert(\n `buildBaseURL: You must pass \\`identifiers\\` as part of options`,\n hasResourcePath(options) ||\n options.op !== 'findMany' ||\n options.identifiers.every((i) => typeof i.id === 'string' && i.id.length > 0)\n );\n assert(\n `buildBaseURL: You must pass valid \\`identifier\\` as part of options, expected 'type'`,\n hasResourcePath(options) ||\n options.op === 'findMany' ||\n (typeof options.identifier.type === 'string' && options.identifier.type.length > 0)\n );\n assert(\n `buildBaseURL: You must pass valid \\`identifiers\\` as part of options, expected 'type'`,\n hasResourcePath(options) ||\n options.op !== 'findMany' ||\n (typeof options.identifiers[0].type === 'string' && options.identifiers[0].type.length > 0)\n );\n\n // prettier-ignore\n const idPath: string =\n isOperationWithPrimaryRecord(options) ? encodeURIComponent(options.identifier.id)\n : '';\n const resourcePath = options.resourcePath || resourcePathForType(options);\n const { host, namespace } = options;\n const fieldPath = 'fieldPath' in options ? options.fieldPath : '';\n\n assert(\n `buildBaseURL: You tried to build a url for a ${String(\n 'op' in options ? options.op + ' ' : ''\n )}request to ${resourcePath} but resourcePath must be set or op must be one of \"${[\n 'findRecord',\n 'findRelatedRecord',\n 'findRelatedCollection',\n 'updateRecord',\n 'deleteRecord',\n 'createRecord',\n 'query',\n 'findMany',\n ].join('\",\"')}\".`,\n hasResourcePath(options) ||\n [\n 'findRecord',\n 'query',\n 'findMany',\n 'findRelatedCollection',\n 'findRelatedRecord',\n 'createRecord',\n 'updateRecord',\n 'deleteRecord',\n ].includes(options.op)\n );\n\n assert(`buildBaseURL: host must NOT end with '/', received '${host}'`, host === '/' || !host.endsWith('/'));\n assert(`buildBaseURL: namespace must NOT start with '/', received '${namespace}'`, !namespace.startsWith('/'));\n assert(`buildBaseURL: namespace must NOT end with '/', received '${namespace}'`, !namespace.endsWith('/'));\n assert(\n `buildBaseURL: resourcePath must NOT start with '/', received '${resourcePath}'`,\n !resourcePath.startsWith('/')\n );\n assert(`buildBaseURL: resourcePath must NOT end with '/', received '${resourcePath}'`, !resourcePath.endsWith('/'));\n assert(`buildBaseURL: fieldPath must NOT start with '/', received '${fieldPath}'`, !fieldPath.startsWith('/'));\n assert(`buildBaseURL: fieldPath must NOT end with '/', received '${fieldPath}'`, !fieldPath.endsWith('/'));\n assert(`buildBaseURL: idPath must NOT start with '/', received '${idPath}'`, !idPath.startsWith('/'));\n assert(`buildBaseURL: idPath must NOT end with '/', received '${idPath}'`, !idPath.endsWith('/'));\n\n const hasHost = host !== '' && host !== '/';\n const url = [hasHost ? host : '', namespace, resourcePath, idPath, fieldPath].filter(Boolean).join('/');\n return hasHost ? url : `/${url}`;\n}\n\nconst DEFAULT_QUERY_PARAMS_SERIALIZATION_OPTIONS: QueryParamsSerializationOptions = {\n arrayFormat: 'comma',\n};\n\nfunction handleInclude(include: string | string[]): string[] {\n assert(\n `Expected include to be a string or array, got ${typeof include}`,\n typeof include === 'string' || Array.isArray(include)\n );\n return typeof include === 'string' ? include.split(',') : include;\n}\n\n/**\n * filter out keys of an object that have falsy values or point to empty arrays\n * returning a new object with only those keys that have truthy values / non-empty arrays\n *\n * See [Cache Keys for Requests](/guides/the-manual/requests/builders#cache-keys-for-requests) for\n * why builders need stable query params.\n *\n * @summary Returns a copy of an object without keys whose values are `undefined`, `null`, empty strings, or empty\n * arrays.\n * @public\n * @param source object to filter keys with empty values from\n * @return A new object with the keys that contained empty values removed\n */\nexport function filterEmpty(source: Record<string, Serializable>): Record<string, Serializable> {\n const result: Record<string, Serializable> = {};\n for (const key in source) {\n const value = source[key];\n // Allow `0` and `false` but filter falsy values that indicate \"empty\"\n if (value !== undefined && value !== null && value !== '') {\n if (!Array.isArray(value) || value.length > 0) {\n result[key] = source[key];\n }\n }\n }\n return result;\n}\n\n/**\n * Sorts query params by both key and value returning a new URLSearchParams\n * object with the keys inserted in sorted order.\n *\n * See [Cache Keys for Requests](/guides/the-manual/requests/builders#cache-keys-for-requests) for\n * why builders need stable query params.\n *\n * Treats `included` specially, splicing it into an array if it is a string and sorting the array.\n *\n * The `params` given are never mutated: neither the object itself nor any array\n * value it holds is reordered or replaced, so passing state that is also\n * rendered (a tracked array of filter values, for instance) is safe.\n *\n * Options:\n * - arrayFormat: 'bracket' | 'indices' | 'repeat' | 'comma'\n *\n * 'bracket': appends [] to the key for every value e.g. `&ids[]=1&ids[]=2`\n * 'indices': appends [i] to the key for every value e.g. `&ids[0]=1&ids[1]=2`\n * 'repeat': appends the key for every value e.g. `&ids=1&ids=2`\n * 'comma' (default): appends the key once with a comma separated list of values e.g. `&ids=1,2`\n *\n * @summary Builds a `URLSearchParams` with keys and array values sorted, so equivalent queries produce identical\n * params.\n * @public\n * @return A {@link URLSearchParams} with keys inserted in sorted order\n */\nexport function sortQueryParams(params: QueryParamsSource, options?: QueryParamsSerializationOptions): URLSearchParams {\n const opts = Object.assign({}, DEFAULT_QUERY_PARAMS_SERIALIZATION_OPTIONS, options);\n const paramsIsObject = !(params instanceof URLSearchParams);\n const urlParams = new URLSearchParams();\n // shallow copy so that normalizing `include` below does not write back onto\n // the caller's object. Array values are still shared with the caller, so\n // everything downstream must sort copies rather than sorting in place.\n const dictionaryParams: Record<string, Serializable> = paramsIsObject ? Object.assign({}, params) : {};\n\n if (!paramsIsObject) {\n params.forEach((value, key) => {\n const hasExisting = key in dictionaryParams;\n if (!hasExisting) {\n dictionaryParams[key] = value;\n } else {\n const existingValue = dictionaryParams[key];\n if (Array.isArray(existingValue)) {\n existingValue.push(value);\n } else {\n dictionaryParams[key] = [existingValue, value];\n }\n }\n });\n }\n\n if ('include' in dictionaryParams) {\n dictionaryParams.include = handleInclude(dictionaryParams.include as string | string[]);\n }\n\n const sortedKeys = Object.keys(dictionaryParams).sort();\n sortedKeys.forEach((key) => {\n const value = dictionaryParams[key];\n if (Array.isArray(value)) {\n const sortedValue = value.toSorted();\n switch (opts.arrayFormat) {\n case 'indices':\n sortedValue.forEach((v, i) => {\n urlParams.append(`${key}[${i}]`, String(v));\n });\n return;\n case 'bracket':\n sortedValue.forEach((v) => {\n urlParams.append(`${key}[]`, String(v));\n });\n return;\n case 'repeat':\n sortedValue.forEach((v) => {\n urlParams.append(key, String(v));\n });\n return;\n case 'comma':\n default:\n urlParams.append(key, sortedValue.join(','));\n return;\n }\n } else {\n urlParams.append(key, String(value));\n }\n });\n\n return urlParams;\n}\n\n/**\n * Sorts query params by both key and value, returning a query params string\n *\n * See [Cache Keys for Requests](/guides/the-manual/requests/builders#cache-keys-for-requests) for\n * why builders need stable query params.\n *\n * Treats `included` specially, splicing it into an array if it is a string and sorting the array.\n *\n * The `params` given are never mutated: neither the object itself nor any array\n * value it holds is reordered or replaced, so passing state that is also\n * rendered (a tracked array of filter values, for instance) is safe.\n *\n * Options:\n * - arrayFormat: 'bracket' | 'indices' | 'repeat' | 'comma'\n *\n * 'bracket': appends [] to the key for every value e.g. `ids[]=1&ids[]=2`\n * 'indices': appends [i] to the key for every value e.g. `ids[0]=1&ids[1]=2`\n * 'repeat': appends the key for every value e.g. `ids=1&ids=2`\n * 'comma' (default): appends the key once with a comma separated list of values e.g. `ids=1,2`\n *\n * @summary Serializes query params into a string with keys and array values sorted, so equivalent queries share one\n * URL.\n * @public\n * @return A sorted query params string without the leading `?`\n */\nexport function buildQueryParams(params: QueryParamsSource, options?: QueryParamsSerializationOptions): string {\n return sortQueryParams(params, options).toString();\n}\n"],"mappings":";;;;;;;;;;;;;;;;AAgCA,MAAMG,SAAyBH,eAAe,UAAU;CACtDI,MAAM;C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B,MAAMC,QAAQkC,aAAa,GAC7BA,cAAcC,KAAKZ,KAAK;QAExBQ,iBAAiBT,OAAO,CAACY,eAAeX,KAAK;EAEjD;CACF,CAAC;CAGH,IAAI,aAAaQ,kBACfA,iBAAiBd,UAAUD,cAAce,iBAAiBd,OAA4B;CAIxFmB,AADmBvC,OAAOwC,KAAKN,gBAAgB,CAAC,CAACO,KACjDF,CAAU,CAACJ,SAASV,QAAQ;EAC1B,MAAMC,QAAQQ,iBAAiBT;EAC/B,IAAIvB,MAAMC,QAAQuB,KAAK,GAAG;GACxB,MAAMgB,cAAchB,MAAMiB,SAAS;GACnC,QAAQb,KAAKZ,aAAb;IACE,KAAK;KACHwB,YAAYP,SAASS,GAAGvC,MAAM;MAC5B4B,UAAUY,OAAO,GAAGpB,IAAG,GAAIpB,EAAC,IAAKK,OAAOkC,CAAC,CAAC;KAC5C,CAAC;KACD;IACF,KAAK;KACHF,YAAYP,SAASS,MAAM;MACzBX,UAAUY,OAAO,GAAGpB,IAAG,KAAMf,OAAOkC,CAAC,CAAC;KACxC,CAAC;KACD;IACF,KAAK;KACHF,YAAYP,SAASS,MAAM;MACzBX,UAAUY,OAAOpB,KAAKf,OAAOkC,CAAC,CAAC;KACjC,CAAC;KACD;IAEF;KACEX,UAAUY,OAAOpB,KAAKiB,YAAY/B,KAAK,GAAG,CAAC;KAC3C;GACJ;EACF,OACEsB,UAAUY,OAAOpB,KAAKf,OAAOgB,KAAK,CAAC;CAEvC,CAAC;CAED,OAAOO;AACT;;;;;;;;;;;;;;;;;;;;;;;;;;AA2BA,SAAgBa,iBAAiBjB,QAA2BzC,SAAmD;CAC7G,OAAOwC,gBAAgBC,QAAQzC,OAAO,CAAC,CAAC2D,SAAS;AACnD"}
@@ -1,4 +1,4 @@
1
- //#region src/-private/string/inflections.ts
1
+ // src/-private/string/inflections.ts
2
2
  const defaultRules = {
3
3
  plurals: [
4
4
  [/$/, "s"],
@@ -75,6 +75,5 @@ const defaultRules = {
75
75
  ]
76
76
  };
77
77
 
78
- //#endregion
79
78
  export { defaultRules as t };
80
- //# sourceMappingURL=inflections-DzBsjJqj.js.map
79
+ //# sourceMappingURL=inflections-CWdUh2K_.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"inflections-DzBsjJqj.js","names":[],"sources":["../src/-private/string/inflections.ts"],"sourcesContent":["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"],"mappings":";AAQA,MAAa,eAAiC;CAC5C,SAAS;EACP,CAAC,KAAK,GAAG;EACT,CAAC,OAAO,GAAG;EACX,CAAC,kBAAkB,MAAM;EACzB,CAAC,mBAAmB,KAAK;EACzB,CAAC,kBAAkB,KAAK;EACxB,CAAC,0BAA0B,MAAM;EACjC,CAAC,cAAc,OAAO;EACtB,CAAC,qBAAqB,OAAO;EAC7B,CAAC,cAAc,KAAK;EACpB,CAAC,aAAa,KAAK;EACnB,CAAC,SAAS,KAAK;EACf,CAAC,0BAA0B,SAAS;EACpC,CAAC,YAAY,KAAK;EAClB,CAAC,qBAAqB,OAAO;EAC7B,CAAC,kBAAkB,MAAM;EACzB,CAAC,8BAA8B,QAAQ;EACvC,CAAC,gBAAgB,OAAO;EACxB,CAAC,eAAe,OAAO;EACvB,CAAC,WAAW,MAAM;EAClB,CAAC,aAAa,IAAI;EAClB,CAAC,YAAY,OAAO;CACtB;CAEA,UAAU;EACR,CAAC,OAAO,EAAE;EACV,CAAC,UAAU,IAAI;EACf,CAAC,YAAY,OAAO;EACpB,CAAC,aAAa,MAAM;EACpB,CAAC,wEAAwE,OAAO;EAChF,CAAC,uBAAuB,OAAO;EAC/B,CAAC,eAAe,MAAM;EACtB,CAAC,aAAa,IAAI;EAClB,CAAC,aAAa,IAAI;EAClB,CAAC,eAAe,KAAK;EACrB,CAAC,uBAAuB,KAAK;EAC7B,CAAC,cAAc,SAAS;EACxB,CAAC,cAAc,QAAQ;EACvB,CAAC,oBAAoB,IAAI;EACzB,CAAC,eAAe,QAAQ;EACxB,CAAC,oBAAoB,IAAI;EACzB,CAAC,WAAW,IAAI;EAChB,CAAC,aAAa,IAAI;EAClB,CAAC,wBAAwB,MAAM;EAC/B,CAAC,gBAAgB,OAAO;EACxB,CAAC,uBAAuB,MAAM;EAC9B,CAAC,+BAA+B,IAAI;EACpC,CAAC,YAAY,IAAI;EACjB,CAAC,oBAAoB,MAAM;EAC3B,CAAC,gBAAgB,MAAM;EACvB,CAAC,eAAe,IAAI;EACpB,CAAC,iBAAiB,IAAI;CACxB;CAEA,gBAAgB;EACd,CAAC,UAAU,QAAQ;EACnB,CAAC,OAAO,KAAK;EACb,CAAC,SAAS,UAAU;EACpB,CAAC,OAAO,OAAO;EACf,CAAC,QAAQ,OAAO;EAChB,CAAC,OAAO,MAAM;EACd,CAAC,UAAU,SAAS;CACtB;CAEA,aAAa;EAAC;EAAa;EAAe;EAAQ;EAAS;EAAW;EAAU;EAAQ;EAAS;EAAS;CAAQ;AACpH"}
1
+ {"version":3,"file":"inflections-CWdUh2K_.js","names":[],"sources":["../src/-private/string/inflections.ts"],"sourcesContent":["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"],"mappings":";AAQA,MAAa,eAAiC;CAC5C,SAAS;EACP,CAAC,KAAK,GAAG;EACT,CAAC,OAAO,GAAG;EACX,CAAC,kBAAkB,MAAM;EACzB,CAAC,mBAAmB,KAAK;EACzB,CAAC,kBAAkB,KAAK;EACxB,CAAC,0BAA0B,MAAM;EACjC,CAAC,cAAc,OAAO;EACtB,CAAC,qBAAqB,OAAO;EAC7B,CAAC,cAAc,KAAK;EACpB,CAAC,aAAa,KAAK;EACnB,CAAC,SAAS,KAAK;EACf,CAAC,0BAA0B,SAAS;EACpC,CAAC,YAAY,KAAK;EAClB,CAAC,qBAAqB,OAAO;EAC7B,CAAC,kBAAkB,MAAM;EACzB,CAAC,8BAA8B,QAAQ;EACvC,CAAC,gBAAgB,OAAO;EACxB,CAAC,eAAe,OAAO;EACvB,CAAC,WAAW,MAAM;EAClB,CAAC,aAAa,IAAI;EAClB,CAAC,YAAY,OAAO;CACtB;CAEA,UAAU;EACR,CAAC,OAAO,EAAE;EACV,CAAC,UAAU,IAAI;EACf,CAAC,YAAY,OAAO;EACpB,CAAC,aAAa,MAAM;EACpB,CAAC,wEAAwE,OAAO;EAChF,CAAC,uBAAuB,OAAO;EAC/B,CAAC,eAAe,MAAM;EACtB,CAAC,aAAa,IAAI;EAClB,CAAC,aAAa,IAAI;EAClB,CAAC,eAAe,KAAK;EACrB,CAAC,uBAAuB,KAAK;EAC7B,CAAC,cAAc,SAAS;EACxB,CAAC,cAAc,QAAQ;EACvB,CAAC,oBAAoB,IAAI;EACzB,CAAC,eAAe,QAAQ;EACxB,CAAC,oBAAoB,IAAI;EACzB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