@websolutespa/bom-core 0.4.0 → 0.4.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,50 +1,57 @@
1
- # @websolutespa/bom-core
2
-
3
- ## 0.4.0
4
-
5
- ### Minor Changes
6
-
7
- - Updating: next 13.
8
-
9
- ## 0.3.0
10
-
11
- ### Minor Changes
12
-
13
- - Modified: HttpService.
14
-
15
- ## 0.2.1
16
-
17
- ### Patch Changes
18
-
19
- - Added: env ROOT_CATEGORY.
20
-
21
- ## 0.2.0
22
-
23
- ### Minor Changes
24
-
25
- - Modified routes, added redirects.
26
-
27
- ## 0.1.2
28
-
29
- ### Patch Changes
30
-
31
- - Modified: MockMenuService.
32
-
33
- ## 0.1.1
34
-
35
- ### Patch Changes
36
-
37
- - Modified: ILocalizable.
38
-
39
- ## 0.1.0
40
-
41
- ### Minor Changes
42
-
43
- - Added: splat routes.
44
- - Added: variants.
45
-
46
- ## 0.0.1
47
-
48
- ### Patch Changes
49
-
50
- - Added: first release.
1
+ # @websolutespa/bom-core
2
+
3
+ ## 0.4.1
4
+
5
+ ### Patch Changes
6
+
7
+ - Added: IAnchor, babelCase.
8
+ - Modified: IApplication, IPageRelation.
9
+
10
+ ## 0.4.0
11
+
12
+ ### Minor Changes
13
+
14
+ - Updating: next 13.
15
+
16
+ ## 0.3.0
17
+
18
+ ### Minor Changes
19
+
20
+ - Modified: HttpService.
21
+
22
+ ## 0.2.1
23
+
24
+ ### Patch Changes
25
+
26
+ - Added: env ROOT_CATEGORY.
27
+
28
+ ## 0.2.0
29
+
30
+ ### Minor Changes
31
+
32
+ - Modified routes, added redirects.
33
+
34
+ ## 0.1.2
35
+
36
+ ### Patch Changes
37
+
38
+ - Modified: MockMenuService.
39
+
40
+ ## 0.1.1
41
+
42
+ ### Patch Changes
43
+
44
+ - Modified: ILocalizable.
45
+
46
+ ## 0.1.0
47
+
48
+ ### Minor Changes
49
+
50
+ - Added: splat routes.
51
+ - Added: variants.
52
+
53
+ ## 0.0.1
54
+
55
+ ### Patch Changes
56
+
57
+ - Added: first release.
package/dist/index.d.ts CHANGED
@@ -59,6 +59,11 @@ type ILocalizedString = Record<string, string>;
59
59
  type ILocalizable = string | ILocalizedString;
60
60
  type ILocalized<T> = IOverride<T, ILocalizable, string>;
61
61
 
62
+ type IAnchor = {
63
+ id: string;
64
+ title?: ILocalizable;
65
+ };
66
+
62
67
  type IEquatable = number | string;
63
68
  type SchemaType = string;
64
69
  type IOption = Record<string, any> & {
@@ -217,9 +222,12 @@ type IPage = Record<string, any> & ICategorized & {
217
222
  slug: string;
218
223
  title: string;
219
224
  };
220
- type IPageRelation = {
225
+ type IPageRelationResult<T extends ICategorized = ICategorized> = {
226
+ href: string;
227
+ } & T;
228
+ type IPageRelation<T extends ICategorized = ICategorized> = {
221
229
  relationTo: string;
222
- value: ICategorized;
230
+ value: IPageRelationResult<T>;
223
231
  };
224
232
  type IPageResult<T extends ICategorized = ICategorized> = IPage & T;
225
233
  type PageProps<T extends ICategorized = ICategorized> = {
@@ -517,6 +525,24 @@ declare function getRouteHref(segments: ICategory[], market: IMarket, locale: IL
517
525
 
518
526
  declare function textToSlug(title: string): string;
519
527
 
528
+ /**
529
+ * PascalCase
530
+ * camelCase
531
+ * kebab-case
532
+ * snake_case
533
+ * char*case
534
+ **/
535
+ declare function unknownCaseToPascalCase(unknownCase: string): string;
536
+ declare function pascalCaseToCamelCase(pascalCase: string): string;
537
+ declare function pascalCaseToCharCase(pascalCase: string, char?: string): string;
538
+ declare function pascalCaseToKebabCase(pascalCase: string): string;
539
+ declare function pascalCaseToSnakeCase(pascalCase: string): string;
540
+ declare function toPascalCase(unknownCase: string): string;
541
+ declare function toCamelCase(unknownCase: string): string;
542
+ declare function toCharCase(unknownCase: string, char?: string): string;
543
+ declare function toKebabCase(unknownCase: string): string;
544
+ declare function toSnakeCase(unknownCase: string): string;
545
+
520
546
  type ListItem<T> = {
521
547
  [K in keyof T]: {
522
548
  readonly key: string;
@@ -542,4 +568,4 @@ declare function asServerProps(props: any): any;
542
568
  declare function awaitAll(array: any, callback: (item: any, index: number) => Promise<any>): Promise<any[]>;
543
569
  declare function merge(target: any, source: any): any;
544
570
 
545
- export { FetchError, FetchRequestOptions, FetchService, FindParams, FindWhereParams, ICategorized, ICategory, ICategoryItem, IClassName, IClassNameCollection, IClassNameValue, ICollectionDescription, IConfig, IContextBaseParams, IContextParams, IEntity, IEquatable, ILabel, ILayout, ILocale, ILocalizable, ILocalized, ILocalizedString, IMarket, IMedia, IMediaType, IMemoryStore, IMenu, IMenuBase, IMenuCategory, IMenuCustom, IMenuGroup, IMenuItem, IMenuLink, IMenuPage, IMenuRoute, INamedEntity, IOption, IOverride, IPackages, IPage, IPageRelation, IPageResult, IPartial, IPrettify, IQuerable, IRedirect, IRoute, IRouteCanonical, IRouteLink, IRouteParams, ISchema, ISerializedCollection, ISerializedStore, IServerSideContext, IServerSideSplatContext, IStaticContext, IStore, ITemplate, ITitledEntity, IUndecoratedMenu, IUndecoratedMenuBase, IUndecoratedMenuCategory, IUndecoratedMenuCustom, IUndecoratedMenuGroup, IUndecoratedMenuItem, IUndecoratedMenuLink, IUndecoratedMenuPage, Json, JsonService, LiteralUnion, NextApiRequestCookies, Operator, PageProps, Pagination, PreviewData, QueryParams, RedirectReason, RouteStrategy, SchemaType, ServerSidePropsContext, StateValue, StaticPropsContext, ValueOf, Where, WhereAndOr, WhereBase, WhereField, asCategoryId, asEquatable, asServerProps, awaitAll, camelToSnakeCase, collectRoutes, consoleWarn, deserializeKey, deserializeValue, eachCategorized, eachMarketLocale, enumToList, getCategorySegments, getCategorySegmentsByCategory, getClassNames, getCollectionDescription, getEnv, getIsDevelopment, getIsProduction, getParentCategoriesById, getRootCategory, getRouteHref, httpDelete, httpFetch, httpGet, httpPatch, httpPost, httpPut, isBrowser, isCategory, isDevelopment, isLocalizedString, isProduction, isStage, isValidCollectionDescription, localize, localizeItem, localizeValue, localizedToString, merge, qsDeserialize, qsSerialize, textToSlug, toDisplayName, toFindParams, toPluralName, toTitleCase, toValidCollectionName, withSchema };
571
+ export { FetchError, FetchRequestOptions, FetchService, FindParams, FindWhereParams, IAnchor, ICategorized, ICategory, ICategoryItem, IClassName, IClassNameCollection, IClassNameValue, ICollectionDescription, IConfig, IContextBaseParams, IContextParams, IEntity, IEquatable, ILabel, ILayout, ILocale, ILocalizable, ILocalized, ILocalizedString, IMarket, IMedia, IMediaType, IMemoryStore, IMenu, IMenuBase, IMenuCategory, IMenuCustom, IMenuGroup, IMenuItem, IMenuLink, IMenuPage, IMenuRoute, INamedEntity, IOption, IOverride, IPackages, IPage, IPageRelation, IPageRelationResult, IPageResult, IPartial, IPrettify, IQuerable, IRedirect, IRoute, IRouteCanonical, IRouteLink, IRouteParams, ISchema, ISerializedCollection, ISerializedStore, IServerSideContext, IServerSideSplatContext, IStaticContext, IStore, ITemplate, ITitledEntity, IUndecoratedMenu, IUndecoratedMenuBase, IUndecoratedMenuCategory, IUndecoratedMenuCustom, IUndecoratedMenuGroup, IUndecoratedMenuItem, IUndecoratedMenuLink, IUndecoratedMenuPage, Json, JsonService, LiteralUnion, NextApiRequestCookies, Operator, PageProps, Pagination, PreviewData, QueryParams, RedirectReason, RouteStrategy, SchemaType, ServerSidePropsContext, StateValue, StaticPropsContext, ValueOf, Where, WhereAndOr, WhereBase, WhereField, asCategoryId, asEquatable, asServerProps, awaitAll, camelToSnakeCase, collectRoutes, consoleWarn, deserializeKey, deserializeValue, eachCategorized, eachMarketLocale, enumToList, getCategorySegments, getCategorySegmentsByCategory, getClassNames, getCollectionDescription, getEnv, getIsDevelopment, getIsProduction, getParentCategoriesById, getRootCategory, getRouteHref, httpDelete, httpFetch, httpGet, httpPatch, httpPost, httpPut, isBrowser, isCategory, isDevelopment, isLocalizedString, isProduction, isStage, isValidCollectionDescription, localize, localizeItem, localizeValue, localizedToString, merge, pascalCaseToCamelCase, pascalCaseToCharCase, pascalCaseToKebabCase, pascalCaseToSnakeCase, qsDeserialize, qsSerialize, textToSlug, toCamelCase, toCharCase, toDisplayName, toFindParams, toKebabCase, toPascalCase, toPluralName, toSnakeCase, toTitleCase, toValidCollectionName, unknownCaseToPascalCase, withSchema };
package/dist/index.js CHANGED
@@ -73,14 +73,24 @@ __export(src_exports, {
73
73
  localizeValue: () => localizeValue,
74
74
  localizedToString: () => localizedToString,
75
75
  merge: () => merge,
76
+ pascalCaseToCamelCase: () => pascalCaseToCamelCase,
77
+ pascalCaseToCharCase: () => pascalCaseToCharCase,
78
+ pascalCaseToKebabCase: () => pascalCaseToKebabCase,
79
+ pascalCaseToSnakeCase: () => pascalCaseToSnakeCase,
76
80
  qsDeserialize: () => qsDeserialize,
77
81
  qsSerialize: () => qsSerialize,
78
82
  textToSlug: () => textToSlug,
83
+ toCamelCase: () => toCamelCase,
84
+ toCharCase: () => toCharCase,
79
85
  toDisplayName: () => toDisplayName,
80
86
  toFindParams: () => toFindParams,
87
+ toKebabCase: () => toKebabCase,
88
+ toPascalCase: () => toPascalCase,
81
89
  toPluralName: () => toPluralName,
90
+ toSnakeCase: () => toSnakeCase,
82
91
  toTitleCase: () => toTitleCase,
83
92
  toValidCollectionName: () => toValidCollectionName,
93
+ unknownCaseToPascalCase: () => unknownCaseToPascalCase,
84
94
  withSchema: () => withSchema
85
95
  });
86
96
  module.exports = __toCommonJS(src_exports);
@@ -251,6 +261,56 @@ function consoleWarn(message, component) {
251
261
  console.warn(log);
252
262
  }
253
263
 
264
+ // src/utils/babelCase.ts
265
+ function unknownCaseToPascalCase(unknownCase) {
266
+ const pascalCase = unknownCase.replace(
267
+ /(^[a-zA-Z])|(\W|_)+(\w?)([a-z0-9]*)?/g,
268
+ (m, g1, g2, g3, g4) => (g1 ? g1.toUpperCase() : "") + (g3 ? g3.toUpperCase() : "") + (g4 ? g4.toLowerCase() : "")
269
+ );
270
+ return pascalCase;
271
+ }
272
+ function pascalCaseToCamelCase(pascalCase) {
273
+ const camelCase = pascalCase.charAt(0).toLowerCase() + pascalCase.slice(1);
274
+ return camelCase;
275
+ }
276
+ function pascalCaseToCharCase(pascalCase, char = "-") {
277
+ const charCase = pascalCase.replace(
278
+ /([A-Z]+)/g,
279
+ (m, g1, index) => (index > 0 ? char : "") + m
280
+ ).toLowerCase();
281
+ return charCase;
282
+ }
283
+ function pascalCaseToKebabCase(pascalCase) {
284
+ const kebabCase = pascalCaseToCharCase(pascalCase, "-");
285
+ return kebabCase;
286
+ }
287
+ function pascalCaseToSnakeCase(pascalCase) {
288
+ const kebabCase = pascalCaseToCharCase(pascalCase, "_");
289
+ return kebabCase;
290
+ }
291
+ function toPascalCase(unknownCase) {
292
+ const pascalCase = unknownCaseToPascalCase(unknownCase);
293
+ return pascalCase;
294
+ }
295
+ function toCamelCase(unknownCase) {
296
+ const pascalCase = unknownCaseToPascalCase(unknownCase);
297
+ const camelCase = pascalCaseToCamelCase(pascalCase);
298
+ return camelCase;
299
+ }
300
+ function toCharCase(unknownCase, char = "-") {
301
+ const pascalCase = unknownCaseToPascalCase(unknownCase);
302
+ const charCase = pascalCaseToCharCase(pascalCase, char);
303
+ return charCase;
304
+ }
305
+ function toKebabCase(unknownCase) {
306
+ const kebabCase = toCharCase(unknownCase, "-");
307
+ return kebabCase;
308
+ }
309
+ function toSnakeCase(unknownCase) {
310
+ const snakeCase = toCharCase(unknownCase, "_");
311
+ return snakeCase;
312
+ }
313
+
254
314
  // src/utils/enumToList.ts
255
315
  function enumToList(enumeration, separatorRegex = /_/g) {
256
316
  const array = Object.keys(enumeration);
@@ -562,6 +622,16 @@ var JsonService = class {
562
622
  return items;
563
623
  }
564
624
  // ^ sort
625
+ // limit
626
+ /*
627
+ protected limitCollection_<B extends T = T>(items: B[], limit?: number): B[] {
628
+ if (limit) {
629
+ items = items.slice(0, Math.min(limit, items.length));
630
+ }
631
+ return items;
632
+ }
633
+ */
634
+ // ^ limit
565
635
  // pagination
566
636
  paginatedItems_(items, page = 1, limit = 10) {
567
637
  const totalDocs = items.length;
@@ -913,13 +983,23 @@ var RedirectReason = /* @__PURE__ */ ((RedirectReason2) => {
913
983
  localizeValue,
914
984
  localizedToString,
915
985
  merge,
986
+ pascalCaseToCamelCase,
987
+ pascalCaseToCharCase,
988
+ pascalCaseToKebabCase,
989
+ pascalCaseToSnakeCase,
916
990
  qsDeserialize,
917
991
  qsSerialize,
918
992
  textToSlug,
993
+ toCamelCase,
994
+ toCharCase,
919
995
  toDisplayName,
920
996
  toFindParams,
997
+ toKebabCase,
998
+ toPascalCase,
921
999
  toPluralName,
1000
+ toSnakeCase,
922
1001
  toTitleCase,
923
1002
  toValidCollectionName,
1003
+ unknownCaseToPascalCase,
924
1004
  withSchema
925
1005
  });
package/dist/index.mjs CHANGED
@@ -164,6 +164,56 @@ function consoleWarn(message, component) {
164
164
  console.warn(log);
165
165
  }
166
166
 
167
+ // src/utils/babelCase.ts
168
+ function unknownCaseToPascalCase(unknownCase) {
169
+ const pascalCase = unknownCase.replace(
170
+ /(^[a-zA-Z])|(\W|_)+(\w?)([a-z0-9]*)?/g,
171
+ (m, g1, g2, g3, g4) => (g1 ? g1.toUpperCase() : "") + (g3 ? g3.toUpperCase() : "") + (g4 ? g4.toLowerCase() : "")
172
+ );
173
+ return pascalCase;
174
+ }
175
+ function pascalCaseToCamelCase(pascalCase) {
176
+ const camelCase = pascalCase.charAt(0).toLowerCase() + pascalCase.slice(1);
177
+ return camelCase;
178
+ }
179
+ function pascalCaseToCharCase(pascalCase, char = "-") {
180
+ const charCase = pascalCase.replace(
181
+ /([A-Z]+)/g,
182
+ (m, g1, index) => (index > 0 ? char : "") + m
183
+ ).toLowerCase();
184
+ return charCase;
185
+ }
186
+ function pascalCaseToKebabCase(pascalCase) {
187
+ const kebabCase = pascalCaseToCharCase(pascalCase, "-");
188
+ return kebabCase;
189
+ }
190
+ function pascalCaseToSnakeCase(pascalCase) {
191
+ const kebabCase = pascalCaseToCharCase(pascalCase, "_");
192
+ return kebabCase;
193
+ }
194
+ function toPascalCase(unknownCase) {
195
+ const pascalCase = unknownCaseToPascalCase(unknownCase);
196
+ return pascalCase;
197
+ }
198
+ function toCamelCase(unknownCase) {
199
+ const pascalCase = unknownCaseToPascalCase(unknownCase);
200
+ const camelCase = pascalCaseToCamelCase(pascalCase);
201
+ return camelCase;
202
+ }
203
+ function toCharCase(unknownCase, char = "-") {
204
+ const pascalCase = unknownCaseToPascalCase(unknownCase);
205
+ const charCase = pascalCaseToCharCase(pascalCase, char);
206
+ return charCase;
207
+ }
208
+ function toKebabCase(unknownCase) {
209
+ const kebabCase = toCharCase(unknownCase, "-");
210
+ return kebabCase;
211
+ }
212
+ function toSnakeCase(unknownCase) {
213
+ const snakeCase = toCharCase(unknownCase, "_");
214
+ return snakeCase;
215
+ }
216
+
167
217
  // src/utils/enumToList.ts
168
218
  function enumToList(enumeration, separatorRegex = /_/g) {
169
219
  const array = Object.keys(enumeration);
@@ -475,6 +525,16 @@ var JsonService = class {
475
525
  return items;
476
526
  }
477
527
  // ^ sort
528
+ // limit
529
+ /*
530
+ protected limitCollection_<B extends T = T>(items: B[], limit?: number): B[] {
531
+ if (limit) {
532
+ items = items.slice(0, Math.min(limit, items.length));
533
+ }
534
+ return items;
535
+ }
536
+ */
537
+ // ^ limit
478
538
  // pagination
479
539
  paginatedItems_(items, page = 1, limit = 10) {
480
540
  const totalDocs = items.length;
@@ -825,13 +885,23 @@ export {
825
885
  localizeValue,
826
886
  localizedToString,
827
887
  merge,
888
+ pascalCaseToCamelCase,
889
+ pascalCaseToCharCase,
890
+ pascalCaseToKebabCase,
891
+ pascalCaseToSnakeCase,
828
892
  qsDeserialize,
829
893
  qsSerialize,
830
894
  textToSlug,
895
+ toCamelCase,
896
+ toCharCase,
831
897
  toDisplayName,
832
898
  toFindParams,
899
+ toKebabCase,
900
+ toPascalCase,
833
901
  toPluralName,
902
+ toSnakeCase,
834
903
  toTitleCase,
835
904
  toValidCollectionName,
905
+ unknownCaseToPascalCase,
836
906
  withSchema
837
907
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@websolutespa/bom-core",
3
- "version": "0.4.0",
3
+ "version": "0.4.1",
4
4
  "description": "Core module of the BOM Repository",
5
5
  "keywords": [
6
6
  "bom",