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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (150) hide show
  1. package/cjs-dist/string.cjs +448 -0
  2. package/cjs-dist/string.cjs.map +1 -0
  3. package/declarations/-private.d.ts +12 -1
  4. package/declarations/-private.d.ts.map +1 -0
  5. package/declarations/active-record.d.ts +260 -3
  6. package/declarations/active-record.d.ts.map +1 -0
  7. package/declarations/derivations.d.ts +26 -23
  8. package/declarations/derivations.d.ts.map +1 -0
  9. package/declarations/handlers.d.ts +282 -9
  10. package/declarations/handlers.d.ts.map +1 -0
  11. package/declarations/index-BeMAuqgZ.d.ts +462 -0
  12. package/declarations/index-BeMAuqgZ.d.ts.map +1 -0
  13. package/declarations/index.d.ts +2 -208
  14. package/declarations/json-api.d.ts +496 -5
  15. package/declarations/json-api.d.ts.map +1 -0
  16. package/declarations/rest.d.ts +258 -3
  17. package/declarations/rest.d.ts.map +1 -0
  18. package/declarations/string.d.ts +164 -13
  19. package/declarations/string.d.ts.map +1 -0
  20. package/dist/-private.js +2 -6
  21. package/dist/active-record.js +254 -379
  22. package/dist/active-record.js.map +1 -0
  23. package/dist/builder-utils-BkXwUT0x.js +16 -0
  24. package/dist/builder-utils-BkXwUT0x.js.map +1 -0
  25. package/dist/derivations.js +26 -26
  26. package/dist/derivations.js.map +1 -0
  27. package/dist/handlers.js +240 -283
  28. package/dist/handlers.js.map +1 -0
  29. package/dist/index.js +357 -335
  30. package/dist/index.js.map +1 -0
  31. package/dist/inflections-DzBsjJqj.js +80 -0
  32. package/dist/inflections-DzBsjJqj.js.map +1 -0
  33. package/dist/json-api.js +470 -706
  34. package/dist/json-api.js.map +1 -0
  35. package/dist/rest.js +254 -377
  36. package/dist/rest.js.map +1 -0
  37. package/dist/string-CWmAluxh.js +290 -0
  38. package/dist/string-CWmAluxh.js.map +1 -0
  39. package/dist/string.js +2 -427
  40. package/dist/unpkg/dev/-private.js +2 -6
  41. package/dist/unpkg/dev/active-record.js +253 -378
  42. package/dist/unpkg/dev/active-record.js.map +1 -0
  43. package/dist/unpkg/dev/builder-utils-BkXwUT0x.js +16 -0
  44. package/dist/unpkg/dev/builder-utils-BkXwUT0x.js.map +1 -0
  45. package/dist/unpkg/dev/derivations.js +26 -26
  46. package/dist/unpkg/dev/derivations.js.map +1 -0
  47. package/dist/unpkg/dev/handlers.js +238 -282
  48. package/dist/unpkg/dev/handlers.js.map +1 -0
  49. package/dist/unpkg/dev/index.js +356 -336
  50. package/dist/unpkg/dev/index.js.map +1 -0
  51. package/dist/unpkg/dev/inflections-DzBsjJqj.js +80 -0
  52. package/dist/unpkg/dev/inflections-DzBsjJqj.js.map +1 -0
  53. package/dist/unpkg/dev/json-api.js +469 -706
  54. package/dist/unpkg/dev/json-api.js.map +1 -0
  55. package/dist/unpkg/dev/rest.js +253 -376
  56. package/dist/unpkg/dev/rest.js.map +1 -0
  57. package/dist/unpkg/dev/string-j4ur-TDs.js +289 -0
  58. package/dist/unpkg/dev/string-j4ur-TDs.js.map +1 -0
  59. package/dist/unpkg/dev/string.js +3 -1
  60. package/dist/unpkg/dev-deprecated/-private.js +2 -6
  61. package/dist/unpkg/dev-deprecated/active-record.js +253 -378
  62. package/dist/unpkg/dev-deprecated/active-record.js.map +1 -0
  63. package/dist/unpkg/dev-deprecated/builder-utils-BkXwUT0x.js +16 -0
  64. package/dist/unpkg/dev-deprecated/builder-utils-BkXwUT0x.js.map +1 -0
  65. package/dist/unpkg/dev-deprecated/derivations.js +26 -26
  66. package/dist/unpkg/dev-deprecated/derivations.js.map +1 -0
  67. package/dist/unpkg/dev-deprecated/handlers.js +238 -282
  68. package/dist/unpkg/dev-deprecated/handlers.js.map +1 -0
  69. package/dist/unpkg/dev-deprecated/index.js +356 -336
  70. package/dist/unpkg/dev-deprecated/index.js.map +1 -0
  71. package/dist/unpkg/dev-deprecated/inflections-DzBsjJqj.js +80 -0
  72. package/dist/unpkg/dev-deprecated/inflections-DzBsjJqj.js.map +1 -0
  73. package/dist/unpkg/dev-deprecated/json-api.js +469 -706
  74. package/dist/unpkg/dev-deprecated/json-api.js.map +1 -0
  75. package/dist/unpkg/dev-deprecated/rest.js +253 -376
  76. package/dist/unpkg/dev-deprecated/rest.js.map +1 -0
  77. package/dist/unpkg/dev-deprecated/string-j4ur-TDs.js +289 -0
  78. package/dist/unpkg/dev-deprecated/string-j4ur-TDs.js.map +1 -0
  79. package/dist/unpkg/dev-deprecated/string.js +3 -1
  80. package/dist/unpkg/prod/-private.js +2 -6
  81. package/dist/unpkg/prod/active-record.js +236 -351
  82. package/dist/unpkg/prod/active-record.js.map +1 -0
  83. package/dist/unpkg/prod/builder-utils-BkXwUT0x.js +16 -0
  84. package/dist/unpkg/prod/builder-utils-BkXwUT0x.js.map +1 -0
  85. package/dist/unpkg/prod/derivations.js +26 -26
  86. package/dist/unpkg/prod/derivations.js.map +1 -0
  87. package/dist/unpkg/prod/handlers.js +231 -272
  88. package/dist/unpkg/prod/handlers.js.map +1 -0
  89. package/dist/unpkg/prod/index.js +265 -215
  90. package/dist/unpkg/prod/index.js.map +1 -0
  91. package/dist/unpkg/prod/inflections-DzBsjJqj.js +80 -0
  92. package/dist/unpkg/prod/inflections-DzBsjJqj.js.map +1 -0
  93. package/dist/unpkg/prod/json-api.js +446 -669
  94. package/dist/unpkg/prod/json-api.js.map +1 -0
  95. package/dist/unpkg/prod/rest.js +236 -349
  96. package/dist/unpkg/prod/rest.js.map +1 -0
  97. package/dist/unpkg/prod/string-T1ahjLdj.js +283 -0
  98. package/dist/unpkg/prod/string-T1ahjLdj.js.map +1 -0
  99. package/dist/unpkg/prod/string.js +3 -1
  100. package/dist/unpkg/prod-deprecated/-private.js +2 -6
  101. package/dist/unpkg/prod-deprecated/active-record.js +236 -351
  102. package/dist/unpkg/prod-deprecated/active-record.js.map +1 -0
  103. package/dist/unpkg/prod-deprecated/builder-utils-BkXwUT0x.js +16 -0
  104. package/dist/unpkg/prod-deprecated/builder-utils-BkXwUT0x.js.map +1 -0
  105. package/dist/unpkg/prod-deprecated/derivations.js +26 -26
  106. package/dist/unpkg/prod-deprecated/derivations.js.map +1 -0
  107. package/dist/unpkg/prod-deprecated/handlers.js +231 -272
  108. package/dist/unpkg/prod-deprecated/handlers.js.map +1 -0
  109. package/dist/unpkg/prod-deprecated/index.js +265 -215
  110. package/dist/unpkg/prod-deprecated/index.js.map +1 -0
  111. package/dist/unpkg/prod-deprecated/inflections-DzBsjJqj.js +80 -0
  112. package/dist/unpkg/prod-deprecated/inflections-DzBsjJqj.js.map +1 -0
  113. package/dist/unpkg/prod-deprecated/json-api.js +446 -669
  114. package/dist/unpkg/prod-deprecated/json-api.js.map +1 -0
  115. package/dist/unpkg/prod-deprecated/rest.js +236 -349
  116. package/dist/unpkg/prod-deprecated/rest.js.map +1 -0
  117. package/dist/unpkg/prod-deprecated/string-T1ahjLdj.js +283 -0
  118. package/dist/unpkg/prod-deprecated/string-T1ahjLdj.js.map +1 -0
  119. package/dist/unpkg/prod-deprecated/string.js +3 -1
  120. package/package.json +11 -10
  121. package/declarations/-private/active-record/find-record.d.ts +0 -64
  122. package/declarations/-private/active-record/query.d.ts +0 -53
  123. package/declarations/-private/active-record/save-record.d.ts +0 -146
  124. package/declarations/-private/builder-utils.d.ts +0 -4
  125. package/declarations/-private/handlers/auto-compress.d.ts +0 -158
  126. package/declarations/-private/handlers/gated.d.ts +0 -19
  127. package/declarations/-private/handlers/meta-doc.d.ts +0 -47
  128. package/declarations/-private/handlers/utils.d.ts +0 -41
  129. package/declarations/-private/json-api/-utils.d.ts +0 -109
  130. package/declarations/-private/json-api/find-record.d.ts +0 -84
  131. package/declarations/-private/json-api/query.d.ts +0 -100
  132. package/declarations/-private/json-api/save-record.d.ts +0 -228
  133. package/declarations/-private/json-api/serialize.d.ts +0 -70
  134. package/declarations/-private/rest/find-record.d.ts +0 -62
  135. package/declarations/-private/rest/query.d.ts +0 -53
  136. package/declarations/-private/rest/save-record.d.ts +0 -146
  137. package/declarations/-private/string/inflect.d.ts +0 -82
  138. package/declarations/-private/string/inflections.d.ts +0 -9
  139. package/declarations/-private/string/transform.d.ts +0 -77
  140. package/dist/builder-utils-Donkk-BZ.js +0 -22
  141. package/dist/inflect-BSG696t-.js +0 -344
  142. package/dist/string.cjs +0 -430
  143. package/dist/unpkg/dev/builder-utils-Donkk-BZ.js +0 -22
  144. package/dist/unpkg/dev/inflect-BEv8WqY1.js +0 -343
  145. package/dist/unpkg/dev-deprecated/builder-utils-Donkk-BZ.js +0 -22
  146. package/dist/unpkg/dev-deprecated/inflect-BEv8WqY1.js +0 -343
  147. package/dist/unpkg/prod/builder-utils-Donkk-BZ.js +0 -22
  148. package/dist/unpkg/prod/inflect-Dh9dyEYx.js +0 -333
  149. package/dist/unpkg/prod-deprecated/builder-utils-Donkk-BZ.js +0 -22
  150. package/dist/unpkg/prod-deprecated/inflect-Dh9dyEYx.js +0 -333
@@ -1,3 +1,258 @@
1
- export { findRecord } from "./-private/rest/find-record.js";
2
- export { query } from "./-private/rest/query.js";
3
- export { deleteRecord, createRecord, updateRecord } from "./-private/rest/save-record.js";
1
+ import { ReactiveDataDocument } from "@warp-drive/core/reactive";
2
+ import { TypeFromInstance, TypedRecordInstance } from "@warp-drive/core/types/record";
3
+ import { ConstrainedRequestOptions, CreateRequestOptions, DeleteRequestOptions, FindRecordOptions, FindRecordRequestOptions, QueryRequestOptions, RemotelyAccessibleIdentifier, UpdateRequestOptions } from "@warp-drive/core/types/request";
4
+ import { QueryParamsSource } from "@warp-drive/core/types/params";
5
+ //#region src/-private/rest/find-record.d.ts
6
+ /**
7
+ * Builds request options to fetch a single resource by a known id or identifier
8
+ * configured for the url and header expectations of most REST APIs.
9
+ *
10
+ * **Basic Usage**
11
+ *
12
+ * ```ts
13
+ * import { findRecord } from '@warp-drive/utilities/rest';
14
+ *
15
+ * const data = await store.request(findRecord('person', '1'));
16
+ * ```
17
+ *
18
+ * **With Options**
19
+ *
20
+ * ```ts
21
+ * import { findRecord } from '@warp-drive/utilities/rest';
22
+ *
23
+ * const options = findRecord('person', '1', { include: ['pets', 'friends'] });
24
+ * const data = await store.request(options);
25
+ * ```
26
+ *
27
+ * **With an Identifier**
28
+ *
29
+ * ```ts
30
+ * import { findRecord } from '@warp-drive/utilities/rest';
31
+ *
32
+ * const options = findRecord({ type: 'person', id: '1' }, { include: ['pets', 'friends'] });
33
+ * const data = await store.request(options);
34
+ * ```
35
+ *
36
+ * **Supplying Options to Modify the Request Behavior**
37
+ *
38
+ * The following options are supported:
39
+ *
40
+ * - `host` - The host to use for the request, defaults to the `host` configured with `setBuildURLConfig`.
41
+ * - `namespace` - The namespace to use for the request, defaults to the `namespace` configured with `setBuildURLConfig`.
42
+ * - `resourcePath` - The resource path to use for the request, defaults to pluralizing and camelCasing the supplied type
43
+ * - `reload` - Whether to forcibly reload the request if it is already in the store, not supplying this
44
+ * option will delegate to the store's CachePolicy, defaulting to `false` if none is configured.
45
+ * - `backgroundReload` - Whether to reload the request if it is already in the store, but to also resolve the
46
+ * promise with the cached value, not supplying this option will delegate to the store's CachePolicy,
47
+ * defaulting to `false` if none is configured.
48
+ * - `urlParamsSetting` - an object containing options for how to serialize the query params (see `buildQueryParams`)
49
+ *
50
+ * ```ts
51
+ * import { findRecord } from '@warp-drive/utilities/rest';
52
+ *
53
+ * const options = findRecord('person', '1', { include: ['pets', 'friends'] }, { namespace: 'api/v2' });
54
+ * const data = await store.request(options);
55
+ * ```
56
+ *
57
+ * @public
58
+ */
59
+ declare function findRecord<T>(identifier: RemotelyAccessibleIdentifier<TypeFromInstance<T>>, options?: FindRecordOptions): FindRecordRequestOptions<ReactiveDataDocument<T>, T>;
60
+ declare function findRecord(identifier: RemotelyAccessibleIdentifier, options?: FindRecordOptions): FindRecordRequestOptions;
61
+ declare function findRecord<T>(type: TypeFromInstance<T>, id: string, options?: FindRecordOptions): FindRecordRequestOptions<ReactiveDataDocument<T>, T>;
62
+ declare function findRecord(type: string, id: string, options?: FindRecordOptions): FindRecordRequestOptions;
63
+ //#endregion
64
+ //#region src/-private/rest/query.d.ts
65
+ /**
66
+ * Builds request options to query for resources, usually by a primary
67
+ * type, configured for the url and header expectations of most REST APIs.
68
+ *
69
+ * **Basic Usage**
70
+ *
71
+ * ```ts
72
+ * import { query } from '@warp-drive/utilities/rest';
73
+ *
74
+ * const data = await store.request(query('person'));
75
+ * ```
76
+ *
77
+ * **With Query Params**
78
+ *
79
+ * ```ts
80
+ * import { query } from '@warp-drive/utilities/rest';
81
+ *
82
+ * const options = query('person', { include: ['pets', 'friends'] });
83
+ * const data = await store.request(options);
84
+ * ```
85
+ *
86
+ * **Supplying Options to Modify the Request Behavior**
87
+ *
88
+ * The following options are supported:
89
+ *
90
+ * - `host` - The host to use for the request, defaults to the `host` configured with `setBuildURLConfig`.
91
+ * - `namespace` - The namespace to use for the request, defaults to the `namespace` configured with `setBuildURLConfig`.
92
+ * - `resourcePath` - The resource path to use for the request, defaults to pluralizing and camelCasing the supplied type
93
+ * - `reload` - Whether to forcibly reload the request if it is already in the store, not supplying this
94
+ * option will delegate to the store's CachePolicy, defaulting to `false` if none is configured.
95
+ * - `backgroundReload` - Whether to reload the request if it is already in the store, but to also resolve the
96
+ * promise with the cached value, not supplying this option will delegate to the store's CachePolicy,
97
+ * defaulting to `false` if none is configured.
98
+ * - `urlParamsSettings` - an object containing options for how to serialize the query params (see `buildQueryParams`)
99
+ *
100
+ * ```ts
101
+ * import { query } from '@warp-drive/utilities/rest';
102
+ *
103
+ * const options = query('person', { include: ['pets', 'friends'] }, { reload: true });
104
+ * const data = await store.request(options);
105
+ * ```
106
+ *
107
+ * @public
108
+ * @param identifier
109
+ * @param query
110
+ * @param options
111
+ */
112
+ declare function query<T>(type: TypeFromInstance<T>, query?: QueryParamsSource, options?: ConstrainedRequestOptions): QueryRequestOptions<ReactiveDataDocument<T[]>>;
113
+ declare function query(type: string, query?: QueryParamsSource, options?: ConstrainedRequestOptions): QueryRequestOptions;
114
+ //#endregion
115
+ //#region src/-private/rest/save-record.d.ts
116
+ /**
117
+ * Builds request options to delete record for resources,
118
+ * configured for the url, method and header expectations of REST APIs.
119
+ *
120
+ * **Basic Usage**
121
+ *
122
+ * ```ts
123
+ * import { deleteRecord } from '@warp-drive/utilities/rest';
124
+ *
125
+ * const person = store.peekRecord('person', '1');
126
+ *
127
+ * // mark record as deleted
128
+ * store.deleteRecord(person);
129
+ *
130
+ * // persist deletion
131
+ * const data = await store.request(deleteRecord(person));
132
+ * ```
133
+ *
134
+ * **Supplying Options to Modify the Request Behavior**
135
+ *
136
+ * The following options are supported:
137
+ *
138
+ * - `host` - The host to use for the request, defaults to the `host` configured with `setBuildURLConfig`.
139
+ * - `namespace` - The namespace to use for the request, defaults to the `namespace` configured with `setBuildURLConfig`.
140
+ * - `resourcePath` - The resource path to use for the request, defaults to pluralizing the supplied type
141
+ * - `reload` - Whether to forcibly reload the request if it is already in the store, not supplying this
142
+ * option will delegate to the store's CachePolicy, defaulting to `false` if none is configured.
143
+ * - `backgroundReload` - Whether to reload the request if it is already in the store, but to also resolve the
144
+ * promise with the cached value, not supplying this option will delegate to the store's CachePolicy,
145
+ * defaulting to `false` if none is configured.
146
+ * - `urlParamsSetting` - an object containing options for how to serialize the query params (see `buildQueryParams`)
147
+ *
148
+ * ```ts
149
+ * import { deleteRecord } from '@warp-drive/utilities/rest';
150
+ *
151
+ * const person = store.peekRecord('person', '1');
152
+ *
153
+ * // mark record as deleted
154
+ * store.deleteRecord(person);
155
+ *
156
+ * // persist deletion
157
+ * const options = deleteRecord(person, { namespace: 'api/v1' });
158
+ * const data = await store.request(options);
159
+ * ```
160
+ *
161
+ * @public
162
+ * @param record
163
+ * @param options
164
+ */
165
+ declare function deleteRecord<T>(record: T, options?: ConstrainedRequestOptions): DeleteRequestOptions<T>;
166
+ declare function deleteRecord(record: unknown, options?: ConstrainedRequestOptions): DeleteRequestOptions;
167
+ /**
168
+ * Builds request options to create new record for resources,
169
+ * configured for the url, method and header expectations of most REST APIs.
170
+ *
171
+ * **Basic Usage**
172
+ *
173
+ * ```ts
174
+ * import { createRecord } from '@warp-drive/utilities/rest';
175
+ *
176
+ * const person = store.createRecord('person', { name: 'Ted' });
177
+ * const data = await store.request(createRecord(person));
178
+ * ```
179
+ *
180
+ * **Supplying Options to Modify the Request Behavior**
181
+ *
182
+ * The following options are supported:
183
+ *
184
+ * - `host` - The host to use for the request, defaults to the `host` configured with `setBuildURLConfig`.
185
+ * - `namespace` - The namespace to use for the request, defaults to the `namespace` configured with `setBuildURLConfig`.
186
+ * - `resourcePath` - The resource path to use for the request, defaults to pluralizing the supplied type
187
+ * - `reload` - Whether to forcibly reload the request if it is already in the store, not supplying this
188
+ * option will delegate to the store's CachePolicy, defaulting to `false` if none is configured.
189
+ * - `backgroundReload` - Whether to reload the request if it is already in the store, but to also resolve the
190
+ * promise with the cached value, not supplying this option will delegate to the store's CachePolicy,
191
+ * defaulting to `false` if none is configured.
192
+ * - `urlParamsSetting` - an object containing options for how to serialize the query params (see `buildQueryParams`)
193
+ *
194
+ * ```ts
195
+ * import { createRecord } from '@warp-drive/utilities/rest';
196
+ *
197
+ * const person = store.createRecord('person', { name: 'Ted' });
198
+ * const options = createRecord(person, { namespace: 'api/v1' });
199
+ * const data = await store.request(options);
200
+ * ```
201
+ *
202
+ * @public
203
+ * @param record
204
+ * @param options
205
+ */
206
+ declare function createRecord<T>(record: T, options?: ConstrainedRequestOptions): CreateRequestOptions<T>;
207
+ declare function createRecord(record: unknown, options?: ConstrainedRequestOptions): CreateRequestOptions;
208
+ /**
209
+ * Builds request options to update existing record for resources,
210
+ * configured for the url, method and header expectations of most REST APIs.
211
+ *
212
+ * **Basic Usage**
213
+ *
214
+ * ```ts
215
+ * import { updateRecord } from '@warp-drive/utilities/rest';
216
+ *
217
+ * const person = store.peekRecord('person', '1');
218
+ * person.name = 'Chris';
219
+ * const data = await store.request(updateRecord(person));
220
+ * ```
221
+ *
222
+ * **Supplying Options to Modify the Request Behavior**
223
+ *
224
+ * The following options are supported:
225
+ *
226
+ * - `patch` - Allows caller to specify whether to use a PATCH request instead of a PUT request, defaults to `false`.
227
+ * - `host` - The host to use for the request, defaults to the `host` configured with `setBuildURLConfig`.
228
+ * - `namespace` - The namespace to use for the request, defaults to the `namespace` configured with `setBuildURLConfig`.
229
+ * - `resourcePath` - The resource path to use for the request, defaults to pluralizing the supplied type
230
+ * - `reload` - Whether to forcibly reload the request if it is already in the store, not supplying this
231
+ * option will delegate to the store's CachePolicy, defaulting to `false` if none is configured.
232
+ * - `backgroundReload` - Whether to reload the request if it is already in the store, but to also resolve the
233
+ * promise with the cached value, not supplying this option will delegate to the store's CachePolicy,
234
+ * defaulting to `false` if none is configured.
235
+ * - `urlParamsSetting` - an object containing options for how to serialize the query params (see `buildQueryParams`)
236
+ *
237
+ * ```ts
238
+ * import { updateRecord } from '@warp-drive/utilities/rest';
239
+ *
240
+ * const person = store.peekRecord('person', '1');
241
+ * person.name = 'Chris';
242
+ * const options = updateRecord(person, { patch: true });
243
+ * const data = await store.request(options);
244
+ * ```
245
+ *
246
+ * @public
247
+ * @param record
248
+ * @param options
249
+ */
250
+ declare function updateRecord<T extends TypedRecordInstance, RT extends TypedRecordInstance = T>(record: T, options?: ConstrainedRequestOptions & {
251
+ patch?: boolean;
252
+ }): UpdateRequestOptions<ReactiveDataDocument<RT>, T>;
253
+ declare function updateRecord(record: unknown, options?: ConstrainedRequestOptions & {
254
+ patch?: boolean;
255
+ }): UpdateRequestOptions;
256
+ //#endregion
257
+ export { createRecord, deleteRecord, findRecord, query, updateRecord };
258
+ //# sourceMappingURL=rest.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"rest.d.ts","names":[],"sources":["../src/-private/rest/find-record.ts","../src/-private/rest/query.ts","../src/-private/rest/save-record.ts"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAiEgB,WAAW,GACzB,YAAY,6BAA6B,iBAAiB,KAC1D,UAAU,oBACT,yBAAyB,qBAAqB,IAAI;iBACrC,WACd,YAAY,8BACZ,UAAU,oBACT;iBACa,WAAW,GACzB,MAAM,iBAAiB,IACvB,YACA,UAAU,oBACT,yBAAyB,qBAAqB,IAAI;iBACrC,WAAW,cAAc,YAAY,UAAU,oBAAoB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBCtBnE,MAAM,GACpB,MAAM,iBAAiB,IACvB,QAAQ,mBACR,UAAU,4BACT,oBAAoB,qBAAqB;iBAC5B,MACd,cACA,QAAQ,mBACR,UAAU,4BACT;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBCSa,aAAa,GAAG,QAAQ,GAAG,UAAU,4BAA4B,qBAAqB;iBACtF,aAAa,iBAAiB,UAAU,4BAA4B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAqEpE,aAAa,GAAG,QAAQ,GAAG,UAAU,4BAA4B,qBAAqB;iBACtF,aAAa,iBAAiB,UAAU,4BAA4B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAuEpE,aAAa,UAAU,qBAAqB,WAAW,sBAAsB,GAC3F,QAAQ,GACR,UAAU;EAA8B;IACvC,qBAAqB,qBAAqB,KAAK;iBAClC,aACd,iBACA,UAAU;EAA8B;IACvC"}
@@ -1,14 +1,165 @@
1
+ //#region src/-private/string/inflect.d.ts
1
2
  /**
2
- * String utilities for transforming and inflecting strings useful for
3
- * when the format provided by the server is not the format you want to use
4
- * in your application.
5
- *
6
- * Each transformation function stores its results in an LRUCache to avoid
7
- * recomputing the same value multiple times. The cache size can be set
8
- * using the `setMaxLRUCacheSize` function. The default size is 10,000.
9
- *
10
- * @module
11
- * @public
12
- */
13
- export { pluralize, singularize, singular, plural, loadIrregular, loadUncountable, irregular, uncountable, resetToDefaults, clear, clearRules } from "./-private/string/inflect.js";
14
- export { dasherize, camelize, capitalize, underscore, setMaxLRUCacheSize } from "./-private/string/transform.js";
3
+ * Marks a word as uncountable. Uncountable words are not pluralized
4
+ * or singularized.
5
+ *
6
+ * @public
7
+ * @since 4.13.0
8
+ */
9
+ declare function uncountable(word: string): void;
10
+ /**
11
+ * Marks a list of words as uncountable. Uncountable words are not pluralized
12
+ * or singularized.
13
+ *
14
+ * @public
15
+ * @since 4.13.0
16
+ */
17
+ declare function loadUncountable(uncountables: string[]): void;
18
+ /**
19
+ * Marks a word as irregular. Irregular words have unique
20
+ * pluralization and singularization rules.
21
+ *
22
+ * @public
23
+ * @since 4.13.0
24
+ */
25
+ declare function irregular(single: string, plur: string): void;
26
+ /**
27
+ * Marks a list of word pairs as irregular. Irregular words have unique
28
+ * pluralization and singularization rules.
29
+ *
30
+ * @public
31
+ * @since 4.13.0
32
+ */
33
+ declare function loadIrregular(irregularPairs: Array<[string, string]>): void;
34
+ /**
35
+ * Clears the caches for singularize and pluralize.
36
+ *
37
+ * @public
38
+ * @since 4.13.0
39
+ */
40
+ declare function clear(): void;
41
+ /**
42
+ * Resets the inflection rules to the defaults.
43
+ *
44
+ * @public
45
+ * @since 4.13.0
46
+ */
47
+ declare function resetToDefaults(): void;
48
+ /**
49
+ * Clears all inflection rules
50
+ * and resets the caches for singularize and pluralize.
51
+ *
52
+ * @public
53
+ * @since 4.13.0
54
+ */
55
+ declare function clearRules(): void;
56
+ /**
57
+ * Singularizes a word.
58
+ *
59
+ * @public
60
+ * @since 4.13.0
61
+ */
62
+ declare function singularize(word: string): string;
63
+ /**
64
+ * Pluralizes a word.
65
+ *
66
+ * @public
67
+ * @since 4.13.0
68
+ */
69
+ declare function pluralize(word: string): string;
70
+ /**
71
+ * Adds a pluralization rule.
72
+ *
73
+ * @public
74
+ * @since 4.13.0
75
+ */
76
+ declare function plural(regex: RegExp, string: string): void;
77
+ /**
78
+ * Adds a singularization rule.
79
+ *
80
+ * @public
81
+ * @since 4.13.0
82
+ */
83
+ declare function singular(regex: RegExp, string: string): void;
84
+ //#endregion
85
+ //#region src/-private/string/transform.d.ts
86
+ /**
87
+ * Replaces underscores, spaces, or camelCase with dashes.
88
+ *
89
+ * ```js
90
+ * import { dasherize } from '@warp-drive/utilities/string';
91
+ *
92
+ * dasherize('innerHTML'); // 'inner-html'
93
+ * dasherize('action_name'); // 'action-name'
94
+ * dasherize('css-class-name'); // 'css-class-name'
95
+ * dasherize('my favorite items'); // 'my-favorite-items'
96
+ * dasherize('privateDocs/ownerInvoice'; // 'private-docs/owner-invoice'
97
+ * ```
98
+ *
99
+ * @public
100
+ * @since 4.13.0
101
+ */
102
+ declare const dasherize: (str: string) => string;
103
+ /**
104
+ * Returns the lowerCamelCase form of a string.
105
+ *
106
+ * ```js
107
+ * import { camelize } from '@warp-drive/utilities/string';
108
+ *
109
+ * camelize('innerHTML'); // 'innerHTML'
110
+ * camelize('action_name'); // 'actionName'
111
+ * camelize('css-class-name'); // 'cssClassName'
112
+ * camelize('my favorite items'); // 'myFavoriteItems'
113
+ * camelize('My Favorite Items'); // 'myFavoriteItems'
114
+ * camelize('private-docs/owner-invoice'); // 'privateDocs/ownerInvoice'
115
+ * ```
116
+ *
117
+ * @public
118
+ * @since 4.13.0
119
+ */
120
+ declare function camelize(str: string): string;
121
+ /**
122
+ * Returns the lower\_case\_and\_underscored form of a string.
123
+ *
124
+ * ```js
125
+ * import { underscore } from '@warp-drive/utilities/string';
126
+ *
127
+ * underscore('innerHTML'); // 'inner_html'
128
+ * underscore('action_name'); // 'action_name'
129
+ * underscore('css-class-name'); // 'css_class_name'
130
+ * underscore('my favorite items'); // 'my_favorite_items'
131
+ * underscore('privateDocs/ownerInvoice'); // 'private_docs/owner_invoice'
132
+ * ```
133
+ *
134
+ * @public
135
+ * @since 4.13.0
136
+ */
137
+ declare function underscore(str: string): string;
138
+ /**
139
+ * Returns the Capitalized form of a string
140
+ *
141
+ * ```js
142
+ * import { capitalize } from '@warp-drive/utilities/string';
143
+ *
144
+ * capitalize('innerHTML') // 'InnerHTML'
145
+ * capitalize('action_name') // 'Action_name'
146
+ * capitalize('css-class-name') // 'Css-class-name'
147
+ * capitalize('my favorite items') // 'My favorite items'
148
+ * capitalize('privateDocs/ownerInvoice'); // 'PrivateDocs/ownerInvoice'
149
+ * ```
150
+ *
151
+ * @public
152
+ * @since 4.13.0
153
+ */
154
+ declare function capitalize(str: string): string;
155
+ /**
156
+ * Sets the maximum size of the LRUCache for all string transformation functions.
157
+ * The default size is 10,000.
158
+ *
159
+ * @public
160
+ * @since 4.13.0
161
+ */
162
+ declare function setMaxLRUCacheSize(size: number): void;
163
+ //#endregion
164
+ export { camelize, capitalize, clear, clearRules, dasherize, irregular, loadIrregular, loadUncountable, plural, pluralize, resetToDefaults, setMaxLRUCacheSize, singular, singularize, uncountable, underscore };
165
+ //# sourceMappingURL=string.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"string.d.ts","names":[],"sources":["../src/-private/string/inflect.ts","../src/-private/string/transform.ts"],"mappings":";;;;;;;;iBA8BgB,YAAY;;;;;;;;iBAWZ,gBAAgB;;;;;;;;iBAahB,UAAU,gBAAgB;;;;;;;;iBAiB1B,cAAc,gBAAgB;;;;;;;iBAmB9B;;;;;;;iBAWA;;;;;;;;iBAeA;;;;;;;iBAgBA,YAAY;;;;;;;iBAYZ,UAAU;;;;;;;iBAqBV,OAAO,OAAO,QAAQ;;;;;;;iBAgBtB,SAAS,OAAO,QAAQ;;;;;;;;;;;;;;;;;;;cC9I3B,YAAY;;;;;;;;;;;;;;;;;;iBAmBT,SAAS;;;;;;;;;;;;;;;;;iBAoBT,WAAW;;;;;;;;;;;;;;;;;iBAoBX,WAAW;;;;;;;;iBAWX,mBAAmB"}
package/dist/-private.js CHANGED
@@ -1,7 +1,3 @@
1
- const defaultRules = {
2
- plurals: [[/$/, 's'], [/s$/i, 's'], [/^(ax|test)is$/i, '$1es'], [/(octop|vir)us$/i, '$1i'], [/(octop|vir)i$/i, '$1i'], [/(alias|status|bonus)$/i, '$1es'], [/(bu)s$/i, '$1ses'], [/(buffal|tomat)o$/i, '$1oes'], [/([ti])um$/i, '$1a'], [/([ti])a$/i, '$1a'], [/sis$/i, 'ses'], [/(?:([^f])fe|([lr])f)$/i, '$1$2ves'], [/(hive)$/i, '$1s'], [/([^aeiouy]|qu)y$/i, '$1ies'], [/(x|ch|ss|sh)$/i, '$1es'], [/(matr|vert|ind)(?:ix|ex)$/i, '$1ices'], [/^(m|l)ouse$/i, '$1ice'], [/^(m|l)ice$/i, '$1ice'], [/^(ox)$/i, '$1en'], [/^(oxen)$/i, '$1'], [/(quiz)$/i, '$1zes']],
3
- singular: [[/s$/i, ''], [/(ss)$/i, '$1'], [/(n)ews$/i, '$1ews'], [/([ti])a$/i, '$1um'], [/((a)naly|(b)a|(d)iagno|(p)arenthe|(p)rogno|(s)ynop|(t)he)(sis|ses)$/i, '$1sis'], [/(^analy)(sis|ses)$/i, '$1sis'], [/([^f])ves$/i, '$1fe'], [/(hive)s$/i, '$1'], [/(tive)s$/i, '$1'], [/([lr])ves$/i, '$1f'], [/([^aeiouy]|qu)ies$/i, '$1y'], [/(s)eries$/i, '$1eries'], [/(m)ovies$/i, '$1ovie'], [/(x|ch|ss|sh)es$/i, '$1'], [/^(m|l)ice$/i, '$1ouse'], [/(bus)(es)?$/i, '$1'], [/(o)es$/i, '$1'], [/(shoe)s$/i, '$1'], [/(cris|test)(is|es)$/i, '$1is'], [/^(a)x[ie]s$/i, '$1xis'], [/(octop|vir)(us|i)$/i, '$1us'], [/(alias|status|bonus)(es)?$/i, '$1'], [/^(ox)en/i, '$1'], [/(vert|ind)ices$/i, '$1ex'], [/(matr)ices$/i, '$1ix'], [/(quiz)zes$/i, '$1'], [/(database)s$/i, '$1']],
4
- irregularPairs: [['person', 'people'], ['man', 'men'], ['child', 'children'], ['sex', 'sexes'], ['move', 'moves'], ['cow', 'kine'], ['zombie', 'zombies']],
5
- uncountable: ['equipment', 'information', 'rice', 'money', 'species', 'series', 'fish', 'sheep', 'jeans', 'police']
6
- };
1
+ import { t as defaultRules } from "./inflections-DzBsjJqj.js";
2
+
7
3
  export { defaultRules as InflectionRuleDefaults };