@websolutespa/bom-core 1.7.7 → 1.7.9

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,5 +1,18 @@
1
1
  # @websolutespa/bom-core
2
2
 
3
+ ## 1.7.9
4
+
5
+ ### Patch Changes
6
+
7
+ - Added: asSortedOptions
8
+ - Modified: type guards
9
+
10
+ ## 1.7.8
11
+
12
+ ### Patch Changes
13
+
14
+ - Fixing: downgrading eslint to v8.56.0
15
+
3
16
  ## 1.7.7
4
17
 
5
18
  ### Patch Changes
package/dist/index.d.ts CHANGED
@@ -43,9 +43,6 @@ type ServerSidePropsContext<Q extends ParsedUrlQuery = ParsedUrlQuery, D extends
43
43
  };
44
44
  type IServerSideSplatContext<T extends {} = {}> = ServerSidePropsContext<IContextBaseParams & T>;
45
45
  type IServerSideContext<T extends {} = {}> = ServerSidePropsContext<IContextParams & T>;
46
- type StateValue = StateValue[] | {
47
- [key: string]: StateValue;
48
- } | number | string | boolean | null | undefined;
49
46
  type IPartial<T> = {
50
47
  [P in keyof T]?: Partial<T[P]>;
51
48
  };
@@ -102,11 +99,25 @@ type IEndUser = UserWithRoles & {
102
99
 
103
100
  type IAction = Record<string, unknown> & {
104
101
  id: string;
102
+ collection: string;
105
103
  consentPreferences: IConsentPreference[];
104
+ consentsRevoked?: boolean;
105
+ consentsRevokedDate?: string | Date;
106
106
  endUser: IEndUser;
107
107
  loggedEndUser?: IEndUser;
108
108
  email?: string;
109
109
  password?: string;
110
+ createdAt?: string;
111
+ updatedAt?: string;
112
+ };
113
+ type IActionEmailData = {
114
+ id?: string;
115
+ from?: string;
116
+ to?: string;
117
+ cc?: string;
118
+ bcc?: string;
119
+ subject: string;
120
+ html: string;
110
121
  };
111
122
 
112
123
  type IAnchor = {
@@ -155,9 +166,6 @@ type IMediaInfo = {
155
166
  filename: string;
156
167
  mimeType: string;
157
168
  filesize: number;
158
- sizes?: Record<string, {
159
- url: string | null;
160
- }>;
161
169
  createdAt: Date | string;
162
170
  updatedAt?: Date | string;
163
171
  url: string;
@@ -244,6 +252,21 @@ type IClassNameValue = string | boolean | number | null | undefined;
244
252
  type IClassNameCollection = Record<string, IClassNameValue>;
245
253
  type IClassName = IClassNameCollection | IClassNameValue;
246
254
 
255
+ type IEmailConfig = IEntity & {
256
+ id: string;
257
+ subject: string;
258
+ fromAddress: string;
259
+ to: [{
260
+ address: string;
261
+ }];
262
+ cc: [{
263
+ address: string;
264
+ }];
265
+ bcc: [{
266
+ address: string;
267
+ }];
268
+ };
269
+
247
270
  type FetchRequestOptions = {
248
271
  method?: string;
249
272
  headers?: {
@@ -698,6 +721,8 @@ declare function textToSlug(title: string): string;
698
721
 
699
722
  declare function asEquatable(value: string): IEquatable;
700
723
 
724
+ declare function asSortedOptions<T extends INamedEntity = INamedEntity>(items: T[]): IOption[];
725
+
701
726
  /**
702
727
  * PascalCase
703
728
  * camelCase
@@ -754,8 +779,12 @@ type ListItem<T> = {
754
779
  */
755
780
  declare function enumToList<T extends Record<string, number | string>>(enumeration: T, separatorRegex?: RegExp): ListItem<T>[];
756
781
 
782
+ declare function isNumber(item: unknown): item is number;
783
+ declare function isString(item: unknown): item is string;
784
+ declare function isValidString(item: unknown): item is string;
757
785
  declare function isArray<T = unknown>(item: unknown): item is Array<T>;
758
786
  declare function isObject<T = Record<string, unknown>>(item: unknown): item is T;
787
+ declare function isPromise(result: unknown): result is Promise<unknown>;
759
788
  declare function isNotNullString(item: unknown): item is string;
760
789
  declare function isEquatable(item: unknown): item is IEquatable;
761
790
  declare function isEntity(item: unknown): item is IEntity;
@@ -778,4 +807,4 @@ declare function asServerProps(props: any): any;
778
807
  declare function awaitAll(array: any, callback: (item: any, index: number) => Promise<any>): Promise<any[]>;
779
808
  declare function merge(target: any, source: any): any;
780
809
 
781
- export { DeepPartial, Dynamic, FetchError, FetchRequestOptions, FetchService, FindParams, FindWhereParams, IAction, IAnchor, ICategorized, ICategory, ICategoryItem, IClassName, IClassNameCollection, IClassNameValue, ICollectionDescription, IComponent, IConfig, IConsentPreference, IContextBaseParams, IContextParams, IDecoratedNav, IEndUser, IEntity, IEquatable, IFeature, IFeatureType, ILabel, ILayout, ILegalNotice, ILetter, ILocale, ILocaleId, ILocalizable, ILocalized, ILocalizedString, IMarket, IMedia, IMediaImage, IMediaInfo, IMediaJson, IMediaPdf, IMediaType, IMediaVideo, IMemoryStore, IMenu, IMenuBase, IMenuCategory, IMenuCustom, IMenuGroup, IMenuHref, IMenuItem, IMenuLink, IMenuPage, IMenuRoute, INamedEntity, IOption, IOverride, IOverrideReturnValue, IOverrideValue, IPackages, IPage, IPageRelation, IPageRelationResult, IPageUnresolvedRelation, IPagedResult, IPaginationResult, IPartial, IPreference, IPrettify, IQuerable, IRedirect, IRoute, IRouteCanonical, IRouteLink, IRouteParams, ISchema, ISerializedCollection, ISerializedStore, IServerSideContext, IServerSideSplatContext, IStaticContext, IStore, ITemplate, ITitledEntity, IUndecoratedMenu, IUndecoratedMenuBase, IUndecoratedMenuCategory, IUndecoratedMenuCustom, IUndecoratedMenuGroup, IUndecoratedMenuItem, IUndecoratedMenuLink, IUndecoratedMenuPage, IUndecoratedNav, Json, JsonService, LiteralUnion, Logger, LoggerLevel, NextApiRequestCookies, Operator, PageProps, Pagination, PreviewData, Primitive, QueryParams, RedirectReason, RouteStrategy, SchemaType, ServerSidePropsContext, StateValue, StaticPropsContext, User, UserRole, UserWithRoles, ValueOf, Where, WhereAndOr, WhereBase, WhereField, asCategoryId, asEquatable, asServerProps, awaitAll, camelToSnakeCase, cloneItem, collectFeatureTypes, collectOptions, collectRoutes, consoleWarn, deepMerge, defaultLocale, defaultMarket, eachCategorized, eachMarketLocale, enumToList, getCategorySegments, getCategorySegmentsByCategory, getClassNames, getCollectionDescription, getEnv, getHost, getIsDevelopment, getIsProduction, getOrigin, getParentCategoriesById, getProto, getRootCategory, getRouteHref, httpDelete, httpFetch, httpGet, httpPatch, httpPost, httpPut, isArray, isBrowser, isCategory, isDevelopment, isEntity, isEquatable, isHeaders, isIncomingHttpHeaders, isLocalizedString, isMediaImage, isMediaJson, isMediaPdf, isMediaVideo, isMenuHref, isNotNullString, isObject, isProduction, isRelation, isReservedCollectionDescription, isStage, isUndecoratedMenuCategory, isUndecoratedMenuItem, isUndecoratedMenuPage, isUndecoratedNav, isUnresolvedRelation, isValidCollectionDescription, localize, localizeItem, localizeValue, localizedToString, merge, pascalCaseToCamelCase, pascalCaseToCharCase, pascalCaseToKebabCase, pascalCaseToSnakeCase, qsDeserialize, qsDeserializeRaw, qsSerialize, qsSerializeRaw, resolveMediaType, textToSlug, toCamelCase, toCharCase, toDisplayName, toFindParams, toKebabCase, toPascalCase, toPluralName, toSnakeCase, toTitleCase, toValidCollectionName, unknownCaseToPascalCase, withSchema };
810
+ export { DeepPartial, Dynamic, FetchError, FetchRequestOptions, FetchService, FindParams, FindWhereParams, IAction, IActionEmailData, IAnchor, ICategorized, ICategory, ICategoryItem, IClassName, IClassNameCollection, IClassNameValue, ICollectionDescription, IComponent, IConfig, IConsentPreference, IContextBaseParams, IContextParams, IDecoratedNav, IEmailConfig, IEndUser, IEntity, IEquatable, IFeature, IFeatureType, ILabel, ILayout, ILegalNotice, ILetter, ILocale, ILocaleId, ILocalizable, ILocalized, ILocalizedString, IMarket, IMedia, IMediaImage, IMediaInfo, IMediaJson, IMediaPdf, IMediaType, IMediaVideo, IMemoryStore, IMenu, IMenuBase, IMenuCategory, IMenuCustom, IMenuGroup, IMenuHref, IMenuItem, IMenuLink, IMenuPage, IMenuRoute, INamedEntity, IOption, IOverride, IOverrideReturnValue, IOverrideValue, IPackages, IPage, IPageRelation, IPageRelationResult, IPageUnresolvedRelation, IPagedResult, IPaginationResult, IPartial, IPreference, IPrettify, IQuerable, IRedirect, IRoute, IRouteCanonical, IRouteLink, IRouteParams, ISchema, ISerializedCollection, ISerializedStore, IServerSideContext, IServerSideSplatContext, IStaticContext, IStore, ITemplate, ITitledEntity, IUndecoratedMenu, IUndecoratedMenuBase, IUndecoratedMenuCategory, IUndecoratedMenuCustom, IUndecoratedMenuGroup, IUndecoratedMenuItem, IUndecoratedMenuLink, IUndecoratedMenuPage, IUndecoratedNav, Json, JsonService, LiteralUnion, Logger, LoggerLevel, NextApiRequestCookies, Operator, PageProps, Pagination, PreviewData, Primitive, QueryParams, RedirectReason, RouteStrategy, SchemaType, ServerSidePropsContext, StaticPropsContext, User, UserRole, UserWithRoles, ValueOf, Where, WhereAndOr, WhereBase, WhereField, asCategoryId, asEquatable, asServerProps, asSortedOptions, awaitAll, camelToSnakeCase, cloneItem, collectFeatureTypes, collectOptions, collectRoutes, consoleWarn, deepMerge, defaultLocale, defaultMarket, eachCategorized, eachMarketLocale, enumToList, getCategorySegments, getCategorySegmentsByCategory, getClassNames, getCollectionDescription, getEnv, getHost, getIsDevelopment, getIsProduction, getOrigin, getParentCategoriesById, getProto, getRootCategory, getRouteHref, httpDelete, httpFetch, httpGet, httpPatch, httpPost, httpPut, isArray, isBrowser, isCategory, isDevelopment, isEntity, isEquatable, isHeaders, isIncomingHttpHeaders, isLocalizedString, isMediaImage, isMediaJson, isMediaPdf, isMediaVideo, isMenuHref, isNotNullString, isNumber, isObject, isProduction, isPromise, isRelation, isReservedCollectionDescription, isStage, isString, isUndecoratedMenuCategory, isUndecoratedMenuItem, isUndecoratedMenuPage, isUndecoratedNav, isUnresolvedRelation, isValidCollectionDescription, isValidString, localize, localizeItem, localizeValue, localizedToString, merge, pascalCaseToCamelCase, pascalCaseToCharCase, pascalCaseToKebabCase, pascalCaseToSnakeCase, qsDeserialize, qsDeserializeRaw, qsSerialize, qsSerializeRaw, resolveMediaType, textToSlug, toCamelCase, toCharCase, toDisplayName, toFindParams, toKebabCase, toPascalCase, toPluralName, toSnakeCase, toTitleCase, toValidCollectionName, unknownCaseToPascalCase, withSchema };
package/dist/index.js CHANGED
@@ -38,6 +38,7 @@ __export(src_exports, {
38
38
  asCategoryId: () => asCategoryId,
39
39
  asEquatable: () => asEquatable,
40
40
  asServerProps: () => asServerProps,
41
+ asSortedOptions: () => asSortedOptions,
41
42
  awaitAll: () => awaitAll,
42
43
  camelToSnakeCase: () => camelToSnakeCase,
43
44
  cloneItem: () => cloneItem,
@@ -85,17 +86,21 @@ __export(src_exports, {
85
86
  isMediaVideo: () => isMediaVideo,
86
87
  isMenuHref: () => isMenuHref,
87
88
  isNotNullString: () => isNotNullString,
89
+ isNumber: () => isNumber,
88
90
  isObject: () => isObject,
89
91
  isProduction: () => isProduction,
92
+ isPromise: () => isPromise,
90
93
  isRelation: () => isRelation,
91
94
  isReservedCollectionDescription: () => isReservedCollectionDescription,
92
95
  isStage: () => isStage,
96
+ isString: () => isString,
93
97
  isUndecoratedMenuCategory: () => isUndecoratedMenuCategory,
94
98
  isUndecoratedMenuItem: () => isUndecoratedMenuItem,
95
99
  isUndecoratedMenuPage: () => isUndecoratedMenuPage,
96
100
  isUndecoratedNav: () => isUndecoratedNav,
97
101
  isUnresolvedRelation: () => isUnresolvedRelation,
98
102
  isValidCollectionDescription: () => isValidCollectionDescription,
103
+ isValidString: () => isValidString,
99
104
  localize: () => localize,
100
105
  localizeItem: () => localizeItem,
101
106
  localizeValue: () => localizeValue,
@@ -299,6 +304,16 @@ function asEquatable(value) {
299
304
  return value;
300
305
  }
301
306
 
307
+ // src/utils/asSortedOptions.ts
308
+ function asSortedOptions(items) {
309
+ items.sort((a, b) => {
310
+ const nameA = a.name.toLowerCase();
311
+ const nameB = b.name.toLowerCase();
312
+ return nameA < nameB ? -1 : nameA > nameB ? 1 : 0;
313
+ });
314
+ return items;
315
+ }
316
+
302
317
  // src/utils/babelCase.ts
303
318
  function unknownCaseToPascalCase(unknownCase) {
304
319
  const pascalCase = unknownCase.replace(
@@ -350,12 +365,24 @@ function toSnakeCase(unknownCase) {
350
365
  }
351
366
 
352
367
  // src/utils/typeGuards.ts
368
+ function isNumber(item) {
369
+ return typeof item === "number";
370
+ }
371
+ function isString(item) {
372
+ return typeof item === "string";
373
+ }
374
+ function isValidString(item) {
375
+ return typeof item === "string" && item.length > 0;
376
+ }
353
377
  function isArray(item) {
354
378
  return Array.isArray(item);
355
379
  }
356
380
  function isObject(item) {
357
381
  return item != null && typeof item === "object" && !isArray(item);
358
382
  }
383
+ function isPromise(result) {
384
+ return isObject(result) && typeof result.then === "function";
385
+ }
359
386
  function isNotNullString(item) {
360
387
  return typeof item === "string" && Boolean(item);
361
388
  }
@@ -1293,6 +1320,7 @@ var RedirectReason = /* @__PURE__ */ ((RedirectReason2) => {
1293
1320
  asCategoryId,
1294
1321
  asEquatable,
1295
1322
  asServerProps,
1323
+ asSortedOptions,
1296
1324
  awaitAll,
1297
1325
  camelToSnakeCase,
1298
1326
  cloneItem,
@@ -1340,17 +1368,21 @@ var RedirectReason = /* @__PURE__ */ ((RedirectReason2) => {
1340
1368
  isMediaVideo,
1341
1369
  isMenuHref,
1342
1370
  isNotNullString,
1371
+ isNumber,
1343
1372
  isObject,
1344
1373
  isProduction,
1374
+ isPromise,
1345
1375
  isRelation,
1346
1376
  isReservedCollectionDescription,
1347
1377
  isStage,
1378
+ isString,
1348
1379
  isUndecoratedMenuCategory,
1349
1380
  isUndecoratedMenuItem,
1350
1381
  isUndecoratedMenuPage,
1351
1382
  isUndecoratedNav,
1352
1383
  isUnresolvedRelation,
1353
1384
  isValidCollectionDescription,
1385
+ isValidString,
1354
1386
  localize,
1355
1387
  localizeItem,
1356
1388
  localizeValue,
package/dist/index.mjs CHANGED
@@ -171,6 +171,16 @@ function asEquatable(value) {
171
171
  return value;
172
172
  }
173
173
 
174
+ // src/utils/asSortedOptions.ts
175
+ function asSortedOptions(items) {
176
+ items.sort((a, b) => {
177
+ const nameA = a.name.toLowerCase();
178
+ const nameB = b.name.toLowerCase();
179
+ return nameA < nameB ? -1 : nameA > nameB ? 1 : 0;
180
+ });
181
+ return items;
182
+ }
183
+
174
184
  // src/utils/babelCase.ts
175
185
  function unknownCaseToPascalCase(unknownCase) {
176
186
  const pascalCase = unknownCase.replace(
@@ -222,12 +232,24 @@ function toSnakeCase(unknownCase) {
222
232
  }
223
233
 
224
234
  // src/utils/typeGuards.ts
235
+ function isNumber(item) {
236
+ return typeof item === "number";
237
+ }
238
+ function isString(item) {
239
+ return typeof item === "string";
240
+ }
241
+ function isValidString(item) {
242
+ return typeof item === "string" && item.length > 0;
243
+ }
225
244
  function isArray(item) {
226
245
  return Array.isArray(item);
227
246
  }
228
247
  function isObject(item) {
229
248
  return item != null && typeof item === "object" && !isArray(item);
230
249
  }
250
+ function isPromise(result) {
251
+ return isObject(result) && typeof result.then === "function";
252
+ }
231
253
  function isNotNullString(item) {
232
254
  return typeof item === "string" && Boolean(item);
233
255
  }
@@ -1164,6 +1186,7 @@ export {
1164
1186
  asCategoryId,
1165
1187
  asEquatable,
1166
1188
  asServerProps,
1189
+ asSortedOptions,
1167
1190
  awaitAll,
1168
1191
  camelToSnakeCase,
1169
1192
  cloneItem,
@@ -1211,17 +1234,21 @@ export {
1211
1234
  isMediaVideo,
1212
1235
  isMenuHref,
1213
1236
  isNotNullString,
1237
+ isNumber,
1214
1238
  isObject,
1215
1239
  isProduction,
1240
+ isPromise,
1216
1241
  isRelation,
1217
1242
  isReservedCollectionDescription,
1218
1243
  isStage,
1244
+ isString,
1219
1245
  isUndecoratedMenuCategory,
1220
1246
  isUndecoratedMenuItem,
1221
1247
  isUndecoratedMenuPage,
1222
1248
  isUndecoratedNav,
1223
1249
  isUnresolvedRelation,
1224
1250
  isValidCollectionDescription,
1251
+ isValidString,
1225
1252
  localize,
1226
1253
  localizeItem,
1227
1254
  localizeValue,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@websolutespa/bom-core",
3
- "version": "1.7.7",
3
+ "version": "1.7.9",
4
4
  "description": "Core module of the BOM Repository",
5
5
  "keywords": [
6
6
  "bom",
@@ -32,7 +32,7 @@
32
32
  "@websolutespa/bom-cli": "*",
33
33
  "@websolutespa/test": "*",
34
34
  "@websolutespa/tsconfig": "*",
35
- "eslint": "^9.0.0",
35
+ "eslint": "^8.56.0",
36
36
  "eslint-config-websolute": "*",
37
37
  "npm-run-all": "^4.1.5",
38
38
  "raw-loader": "^4.0.2",