@websolutespa/bom-core 1.7.15 → 1.8.0
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 +12 -0
- package/dist/index.d.ts +60 -6
- package/dist/index.js +66 -0
- package/dist/index.mjs +62 -0
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
# @websolutespa/bom-core
|
|
2
2
|
|
|
3
|
+
## 1.8.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- f8a1d97: Modified: extracted all website sample components & features
|
|
8
|
+
|
|
9
|
+
## 1.7.16
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- Added: MenuCategory strategy
|
|
14
|
+
|
|
3
15
|
## 1.7.15
|
|
4
16
|
|
|
5
17
|
### Patch Changes
|
package/dist/index.d.ts
CHANGED
|
@@ -130,6 +130,7 @@ type IAnchor = {
|
|
|
130
130
|
|
|
131
131
|
type IComponent = {
|
|
132
132
|
schema: string;
|
|
133
|
+
anchor?: IAnchor;
|
|
133
134
|
[key: string]: unknown;
|
|
134
135
|
};
|
|
135
136
|
|
|
@@ -154,12 +155,11 @@ type IFeature = Record<string, any> & {
|
|
|
154
155
|
id: IEquatable;
|
|
155
156
|
title: string;
|
|
156
157
|
};
|
|
157
|
-
type IFeatureType = {
|
|
158
|
+
type IFeatureType = IEntity & {
|
|
158
159
|
id: string;
|
|
159
|
-
schema?: string;
|
|
160
160
|
title: string;
|
|
161
161
|
mode: string;
|
|
162
|
-
features
|
|
162
|
+
features: IFeature[];
|
|
163
163
|
};
|
|
164
164
|
|
|
165
165
|
type IMediaType = 'image' | 'video' | 'json' | 'pdf' | string;
|
|
@@ -348,10 +348,30 @@ type IRouteParams = Record<string, any> & {
|
|
|
348
348
|
market: string;
|
|
349
349
|
};
|
|
350
350
|
|
|
351
|
+
/**
|
|
352
|
+
* Represents a listing item returned from the findMany method of a page collection.
|
|
353
|
+
* @template T - The type of the categorized item.
|
|
354
|
+
*/
|
|
355
|
+
type IPageItem<T extends ICategorized = ICategorized> = ILocalized<T> & {
|
|
356
|
+
schema: string;
|
|
357
|
+
category: ILocalized<ICategory> & {
|
|
358
|
+
href: string;
|
|
359
|
+
};
|
|
360
|
+
href: string;
|
|
361
|
+
locale: string;
|
|
362
|
+
market: string;
|
|
363
|
+
};
|
|
364
|
+
/**
|
|
365
|
+
* Represents a detail item returned from the findOne method of a page collection.
|
|
366
|
+
* @template T - The type of the categorized item.
|
|
367
|
+
*/
|
|
351
368
|
type IPage<T extends ICategorized = ICategorized> = ILocalized<T> & {
|
|
369
|
+
schema: string;
|
|
352
370
|
alternates: IRoute[];
|
|
353
371
|
breadcrumb: IRouteLink[];
|
|
354
|
-
category: ILocalized<ICategory
|
|
372
|
+
category: ILocalized<ICategory> & {
|
|
373
|
+
href: string;
|
|
374
|
+
};
|
|
355
375
|
href: string;
|
|
356
376
|
locale: string;
|
|
357
377
|
market: string;
|
|
@@ -359,6 +379,10 @@ type IPage<T extends ICategorized = ICategorized> = ILocalized<T> & {
|
|
|
359
379
|
slug: string;
|
|
360
380
|
title: string;
|
|
361
381
|
};
|
|
382
|
+
/**
|
|
383
|
+
* Represents the props for a page component.
|
|
384
|
+
* @template T - The type of the categorized item.
|
|
385
|
+
*/
|
|
362
386
|
type PageProps<T extends ICategorized = ICategorized> = {
|
|
363
387
|
layout: ILayout;
|
|
364
388
|
page: IPage<T>;
|
|
@@ -367,13 +391,24 @@ type PageProps<T extends ICategorized = ICategorized> = {
|
|
|
367
391
|
locale?: string;
|
|
368
392
|
defaultLocale?: string;
|
|
369
393
|
};
|
|
394
|
+
/**
|
|
395
|
+
* Represents the result of a page relation.
|
|
396
|
+
* @template T - The type of the categorized item.
|
|
397
|
+
*/
|
|
370
398
|
type IPageRelationResult<T extends ICategorized = ICategorized> = {
|
|
371
399
|
href: string;
|
|
372
400
|
} & T;
|
|
401
|
+
/**
|
|
402
|
+
* Represents a page relation.
|
|
403
|
+
* @template T - The type of the categorized item.
|
|
404
|
+
*/
|
|
373
405
|
type IPageRelation<T extends ICategorized = ICategorized> = {
|
|
374
406
|
relationTo: string;
|
|
375
|
-
value: IPageRelationResult<T
|
|
407
|
+
value: IPageRelationResult<T> | IPageRelationResult<T>[];
|
|
376
408
|
};
|
|
409
|
+
/**
|
|
410
|
+
* Represents an unresolved page relation.
|
|
411
|
+
*/
|
|
377
412
|
type IPageUnresolvedRelation = {
|
|
378
413
|
relationTo: string;
|
|
379
414
|
value: IEquatable | IEquatable[];
|
|
@@ -437,10 +472,15 @@ type IUndecoratedMenuBase = {
|
|
|
437
472
|
media?: IMedia;
|
|
438
473
|
type: string;
|
|
439
474
|
};
|
|
475
|
+
declare enum MenuCategoryStrategy {
|
|
476
|
+
Default = "default",// show hidden categories recursively,
|
|
477
|
+
ExcludeHidden = "exclude-hidden"
|
|
478
|
+
}
|
|
440
479
|
type IUndecoratedMenuCategory = Omit<IUndecoratedMenuBase, 'type'> & {
|
|
441
480
|
type: 'category';
|
|
442
481
|
category: string;
|
|
443
482
|
maxDepth?: number;
|
|
483
|
+
strategy?: MenuCategoryStrategy;
|
|
444
484
|
title?: ILocalizable;
|
|
445
485
|
};
|
|
446
486
|
type IUndecoratedMenuGroup = Omit<IUndecoratedMenuBase, 'type'> & {
|
|
@@ -732,6 +772,17 @@ declare function toValidCollectionName(text: string): string;
|
|
|
732
772
|
|
|
733
773
|
declare function consoleWarn(message: string, component?: string): void;
|
|
734
774
|
|
|
775
|
+
/**
|
|
776
|
+
* Retrieves the ID of a category or an object that implements IEquatable.
|
|
777
|
+
* @param value - The category or object to retrieve the ID from.
|
|
778
|
+
* @returns The ID of the category or object as a string.
|
|
779
|
+
*/
|
|
780
|
+
declare function asEntityId(value: undefined): undefined;
|
|
781
|
+
declare function asEntityId(value: string): string;
|
|
782
|
+
declare function asEntityId(value: number): number;
|
|
783
|
+
declare function asEntityId(value: IEntity | IEquatable): string | number;
|
|
784
|
+
declare function asEntityId(value: IEntity | IEquatable | undefined): string | number | undefined;
|
|
785
|
+
|
|
735
786
|
/**
|
|
736
787
|
* Performs an HTTP fetch request.
|
|
737
788
|
* @param url - The URL to fetch.
|
|
@@ -1012,6 +1063,8 @@ declare function getRouteHref(segments: {
|
|
|
1012
1063
|
slug: ILocalizable;
|
|
1013
1064
|
}[], market: IMarket, locale: ILocale, markets: IMarket[], locales: ILocale[]): string;
|
|
1014
1065
|
|
|
1066
|
+
declare function arrayShuffle<T extends IEntity>(items: T[]): T[];
|
|
1067
|
+
|
|
1015
1068
|
/**
|
|
1016
1069
|
* Converts a value to an `IEquatable` or `undefined`.
|
|
1017
1070
|
* If the value is an `IEntity`, it extracts the `id` property.
|
|
@@ -1073,6 +1126,7 @@ declare function toSnakeCase(unknownCase: string): string;
|
|
|
1073
1126
|
declare function cloneItem<T = unknown>(item: T): T;
|
|
1074
1127
|
|
|
1075
1128
|
declare function collectFeatureTypes<T extends IEntity = IEntity>(items: T[], ...keys: string[]): Promise<IFeatureType[]>;
|
|
1129
|
+
declare function collectFeatureTypes__<T extends IEntity = IEntity>(items: T[], ...keys: string[]): Promise<IFeatureType[]>;
|
|
1076
1130
|
|
|
1077
1131
|
/**
|
|
1078
1132
|
* Collects options from an array of items based on specified keys.
|
|
@@ -1224,4 +1278,4 @@ declare function asServerProps(props: any): any;
|
|
|
1224
1278
|
declare function awaitAll(array: any, callback: (item: any, index: number) => Promise<any>): Promise<any[]>;
|
|
1225
1279
|
declare function merge(target: any, source: any): any;
|
|
1226
1280
|
|
|
1227
|
-
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, RequireAtLeastOne, RouteStrategy, SchemaType, ServerSidePropsContext, StaticPropsContext, User, UserRole, UserWithRoles, ValueOf, Where, WhereAndOr, WhereBase, WhereField, asCategoryId, asEquatable, asEquatableNumber, asEquatableString, asServerProps, asSortedOptions, awaitAll, camelToSnakeCase, cloneItem, collectFeatureTypes, collectOptions, collectRoutes, consoleWarn, deepMerge, defaultLocale, defaultMarket, eachCategorized, eachMarketLocale, enumToList, findCategoryInCategories, findChildCategories, findRouteOfCategory, findRoutesOfCategory, getCategorySegments, getCategorySegmentsByCategory, getClassNames, getCollectionDescription, getEnv, getHost, getIsDevelopment, getIsProduction, getOrigin, getParentCategoriesById, getParentCategory, getProto, getRootCategory, getRouteHref, httpDelete, httpFetch, httpGet, httpPatch, httpPost, httpPut, isArray, isBrowser, 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, toCamelCase, toCharCase, toDisplayName, toFindParams, toKebabCase, toPascalCase, toPluralName, toSnakeCase, toTitleCase, toValidCollectionName, unknownCaseToPascalCase, uuidv4, withSchema };
|
|
1281
|
+
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, IPageItem, 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, MenuCategoryStrategy, NextApiRequestCookies, Operator, PageProps, Pagination, PreviewData, Primitive, QueryParams, RedirectReason, RequireAtLeastOne, RouteStrategy, SchemaType, ServerSidePropsContext, StaticPropsContext, User, UserRole, UserWithRoles, ValueOf, Where, WhereAndOr, WhereBase, WhereField, arrayShuffle, asCategoryId, asEntityId, asEquatable, asEquatableNumber, asEquatableString, asServerProps, asSortedOptions, awaitAll, camelToSnakeCase, cloneItem, collectFeatureTypes, collectFeatureTypes__, collectOptions, collectRoutes, consoleWarn, deepMerge, defaultLocale, defaultMarket, eachCategorized, eachMarketLocale, enumToList, findCategoryInCategories, findChildCategories, findRouteOfCategory, findRoutesOfCategory, getCategorySegments, getCategorySegmentsByCategory, getClassNames, getCollectionDescription, getEnv, getHost, getIsDevelopment, getIsProduction, getOrigin, getParentCategoriesById, getParentCategory, getProto, getRootCategory, getRouteHref, httpDelete, httpFetch, httpGet, httpPatch, httpPost, httpPut, isArray, isBrowser, 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, toCamelCase, toCharCase, toDisplayName, toFindParams, toKebabCase, toPascalCase, toPluralName, toSnakeCase, toTitleCase, toValidCollectionName, unknownCaseToPascalCase, uuidv4, withSchema };
|
package/dist/index.js
CHANGED
|
@@ -33,9 +33,12 @@ __export(src_exports, {
|
|
|
33
33
|
JsonService: () => JsonService,
|
|
34
34
|
Logger: () => Logger,
|
|
35
35
|
LoggerLevel: () => LoggerLevel,
|
|
36
|
+
MenuCategoryStrategy: () => MenuCategoryStrategy,
|
|
36
37
|
RedirectReason: () => RedirectReason,
|
|
37
38
|
RouteStrategy: () => RouteStrategy,
|
|
39
|
+
arrayShuffle: () => arrayShuffle,
|
|
38
40
|
asCategoryId: () => asCategoryId,
|
|
41
|
+
asEntityId: () => asEntityId,
|
|
39
42
|
asEquatable: () => asEquatable,
|
|
40
43
|
asEquatableNumber: () => asEquatableNumber,
|
|
41
44
|
asEquatableString: () => asEquatableString,
|
|
@@ -45,6 +48,7 @@ __export(src_exports, {
|
|
|
45
48
|
camelToSnakeCase: () => camelToSnakeCase,
|
|
46
49
|
cloneItem: () => cloneItem,
|
|
47
50
|
collectFeatureTypes: () => collectFeatureTypes,
|
|
51
|
+
collectFeatureTypes__: () => collectFeatureTypes__,
|
|
48
52
|
collectOptions: () => collectOptions,
|
|
49
53
|
collectRoutes: () => collectRoutes,
|
|
50
54
|
consoleWarn: () => consoleWarn,
|
|
@@ -137,6 +141,11 @@ __export(src_exports, {
|
|
|
137
141
|
});
|
|
138
142
|
module.exports = __toCommonJS(src_exports);
|
|
139
143
|
|
|
144
|
+
// src/utils/arrayShuffle.ts
|
|
145
|
+
function arrayShuffle(items) {
|
|
146
|
+
return items.map((item) => ({ item, order: Math.random() })).sort((a, b) => a.order - b.order).map(({ item }) => item);
|
|
147
|
+
}
|
|
148
|
+
|
|
140
149
|
// src/utils/typeGuards.ts
|
|
141
150
|
function isNumber(item) {
|
|
142
151
|
return typeof item === "number";
|
|
@@ -289,6 +298,49 @@ function cloneItem(item) {
|
|
|
289
298
|
|
|
290
299
|
// src/utils/collectFeatureTypes.ts
|
|
291
300
|
async function collectFeatureTypes(items, ...keys) {
|
|
301
|
+
const featureTypes = [];
|
|
302
|
+
if (keys.length > 0) {
|
|
303
|
+
items.forEach((item) => {
|
|
304
|
+
keys.forEach((key) => {
|
|
305
|
+
const value = item[key] || [];
|
|
306
|
+
const values = Array.isArray(value) ? value : [value];
|
|
307
|
+
values.forEach((value2) => {
|
|
308
|
+
let featureType = featureTypes.find((x) => x.id === key);
|
|
309
|
+
if (!featureType) {
|
|
310
|
+
featureType = {
|
|
311
|
+
id: key,
|
|
312
|
+
schema: "featureType",
|
|
313
|
+
title: key,
|
|
314
|
+
mode: "or",
|
|
315
|
+
features: []
|
|
316
|
+
};
|
|
317
|
+
featureTypes.push(featureType);
|
|
318
|
+
}
|
|
319
|
+
const features = featureType.features;
|
|
320
|
+
const option = isObject(value2) ? {
|
|
321
|
+
...value2,
|
|
322
|
+
title: value2.title || value2.name || value2.label || "Untitled"
|
|
323
|
+
} : {
|
|
324
|
+
id: value2,
|
|
325
|
+
title: String(value2)
|
|
326
|
+
};
|
|
327
|
+
if (features && !features.find((x) => x.id === option.id)) {
|
|
328
|
+
features.push(option);
|
|
329
|
+
}
|
|
330
|
+
});
|
|
331
|
+
});
|
|
332
|
+
});
|
|
333
|
+
}
|
|
334
|
+
featureTypes.forEach((featureType) => {
|
|
335
|
+
featureType.features.sort((a, b) => {
|
|
336
|
+
const textA = a.title.toUpperCase();
|
|
337
|
+
const textB = b.title.toUpperCase();
|
|
338
|
+
return textA < textB ? -1 : textA > textB ? 1 : 0;
|
|
339
|
+
});
|
|
340
|
+
});
|
|
341
|
+
return featureTypes;
|
|
342
|
+
}
|
|
343
|
+
async function collectFeatureTypes__(items, ...keys) {
|
|
292
344
|
const featureTypes = [];
|
|
293
345
|
if (keys.length > 0) {
|
|
294
346
|
items.forEach((item) => {
|
|
@@ -605,6 +657,11 @@ function consoleWarn(message, component) {
|
|
|
605
657
|
console.warn(log);
|
|
606
658
|
}
|
|
607
659
|
|
|
660
|
+
// src/entity/entity.ts
|
|
661
|
+
function asEntityId(value) {
|
|
662
|
+
return isEntity(value) ? value.id : value;
|
|
663
|
+
}
|
|
664
|
+
|
|
608
665
|
// src/http/http.service.ts
|
|
609
666
|
var defaultOptions = {
|
|
610
667
|
// method: 'POST', // *GET, POST, PUT, DELETE, etc.
|
|
@@ -1441,6 +1498,11 @@ function isMediaPdf(media) {
|
|
|
1441
1498
|
function isMenuHref(item) {
|
|
1442
1499
|
return ["category", "link", "page", "route"].includes(item.type);
|
|
1443
1500
|
}
|
|
1501
|
+
var MenuCategoryStrategy = /* @__PURE__ */ ((MenuCategoryStrategy2) => {
|
|
1502
|
+
MenuCategoryStrategy2["Default"] = "default";
|
|
1503
|
+
MenuCategoryStrategy2["ExcludeHidden"] = "exclude-hidden";
|
|
1504
|
+
return MenuCategoryStrategy2;
|
|
1505
|
+
})(MenuCategoryStrategy || {});
|
|
1444
1506
|
|
|
1445
1507
|
// src/types/querable.ts
|
|
1446
1508
|
function toFindParams(idOrParams) {
|
|
@@ -1465,9 +1527,12 @@ var RedirectReason = /* @__PURE__ */ ((RedirectReason2) => {
|
|
|
1465
1527
|
JsonService,
|
|
1466
1528
|
Logger,
|
|
1467
1529
|
LoggerLevel,
|
|
1530
|
+
MenuCategoryStrategy,
|
|
1468
1531
|
RedirectReason,
|
|
1469
1532
|
RouteStrategy,
|
|
1533
|
+
arrayShuffle,
|
|
1470
1534
|
asCategoryId,
|
|
1535
|
+
asEntityId,
|
|
1471
1536
|
asEquatable,
|
|
1472
1537
|
asEquatableNumber,
|
|
1473
1538
|
asEquatableString,
|
|
@@ -1477,6 +1542,7 @@ var RedirectReason = /* @__PURE__ */ ((RedirectReason2) => {
|
|
|
1477
1542
|
camelToSnakeCase,
|
|
1478
1543
|
cloneItem,
|
|
1479
1544
|
collectFeatureTypes,
|
|
1545
|
+
collectFeatureTypes__,
|
|
1480
1546
|
collectOptions,
|
|
1481
1547
|
collectRoutes,
|
|
1482
1548
|
consoleWarn,
|
package/dist/index.mjs
CHANGED
|
@@ -1,3 +1,8 @@
|
|
|
1
|
+
// src/utils/arrayShuffle.ts
|
|
2
|
+
function arrayShuffle(items) {
|
|
3
|
+
return items.map((item) => ({ item, order: Math.random() })).sort((a, b) => a.order - b.order).map(({ item }) => item);
|
|
4
|
+
}
|
|
5
|
+
|
|
1
6
|
// src/utils/typeGuards.ts
|
|
2
7
|
function isNumber(item) {
|
|
3
8
|
return typeof item === "number";
|
|
@@ -150,6 +155,49 @@ function cloneItem(item) {
|
|
|
150
155
|
|
|
151
156
|
// src/utils/collectFeatureTypes.ts
|
|
152
157
|
async function collectFeatureTypes(items, ...keys) {
|
|
158
|
+
const featureTypes = [];
|
|
159
|
+
if (keys.length > 0) {
|
|
160
|
+
items.forEach((item) => {
|
|
161
|
+
keys.forEach((key) => {
|
|
162
|
+
const value = item[key] || [];
|
|
163
|
+
const values = Array.isArray(value) ? value : [value];
|
|
164
|
+
values.forEach((value2) => {
|
|
165
|
+
let featureType = featureTypes.find((x) => x.id === key);
|
|
166
|
+
if (!featureType) {
|
|
167
|
+
featureType = {
|
|
168
|
+
id: key,
|
|
169
|
+
schema: "featureType",
|
|
170
|
+
title: key,
|
|
171
|
+
mode: "or",
|
|
172
|
+
features: []
|
|
173
|
+
};
|
|
174
|
+
featureTypes.push(featureType);
|
|
175
|
+
}
|
|
176
|
+
const features = featureType.features;
|
|
177
|
+
const option = isObject(value2) ? {
|
|
178
|
+
...value2,
|
|
179
|
+
title: value2.title || value2.name || value2.label || "Untitled"
|
|
180
|
+
} : {
|
|
181
|
+
id: value2,
|
|
182
|
+
title: String(value2)
|
|
183
|
+
};
|
|
184
|
+
if (features && !features.find((x) => x.id === option.id)) {
|
|
185
|
+
features.push(option);
|
|
186
|
+
}
|
|
187
|
+
});
|
|
188
|
+
});
|
|
189
|
+
});
|
|
190
|
+
}
|
|
191
|
+
featureTypes.forEach((featureType) => {
|
|
192
|
+
featureType.features.sort((a, b) => {
|
|
193
|
+
const textA = a.title.toUpperCase();
|
|
194
|
+
const textB = b.title.toUpperCase();
|
|
195
|
+
return textA < textB ? -1 : textA > textB ? 1 : 0;
|
|
196
|
+
});
|
|
197
|
+
});
|
|
198
|
+
return featureTypes;
|
|
199
|
+
}
|
|
200
|
+
async function collectFeatureTypes__(items, ...keys) {
|
|
153
201
|
const featureTypes = [];
|
|
154
202
|
if (keys.length > 0) {
|
|
155
203
|
items.forEach((item) => {
|
|
@@ -466,6 +514,11 @@ function consoleWarn(message, component) {
|
|
|
466
514
|
console.warn(log);
|
|
467
515
|
}
|
|
468
516
|
|
|
517
|
+
// src/entity/entity.ts
|
|
518
|
+
function asEntityId(value) {
|
|
519
|
+
return isEntity(value) ? value.id : value;
|
|
520
|
+
}
|
|
521
|
+
|
|
469
522
|
// src/http/http.service.ts
|
|
470
523
|
var defaultOptions = {
|
|
471
524
|
// method: 'POST', // *GET, POST, PUT, DELETE, etc.
|
|
@@ -1302,6 +1355,11 @@ function isMediaPdf(media) {
|
|
|
1302
1355
|
function isMenuHref(item) {
|
|
1303
1356
|
return ["category", "link", "page", "route"].includes(item.type);
|
|
1304
1357
|
}
|
|
1358
|
+
var MenuCategoryStrategy = /* @__PURE__ */ ((MenuCategoryStrategy2) => {
|
|
1359
|
+
MenuCategoryStrategy2["Default"] = "default";
|
|
1360
|
+
MenuCategoryStrategy2["ExcludeHidden"] = "exclude-hidden";
|
|
1361
|
+
return MenuCategoryStrategy2;
|
|
1362
|
+
})(MenuCategoryStrategy || {});
|
|
1305
1363
|
|
|
1306
1364
|
// src/types/querable.ts
|
|
1307
1365
|
function toFindParams(idOrParams) {
|
|
@@ -1325,9 +1383,12 @@ export {
|
|
|
1325
1383
|
JsonService,
|
|
1326
1384
|
Logger,
|
|
1327
1385
|
LoggerLevel,
|
|
1386
|
+
MenuCategoryStrategy,
|
|
1328
1387
|
RedirectReason,
|
|
1329
1388
|
RouteStrategy,
|
|
1389
|
+
arrayShuffle,
|
|
1330
1390
|
asCategoryId,
|
|
1391
|
+
asEntityId,
|
|
1331
1392
|
asEquatable,
|
|
1332
1393
|
asEquatableNumber,
|
|
1333
1394
|
asEquatableString,
|
|
@@ -1337,6 +1398,7 @@ export {
|
|
|
1337
1398
|
camelToSnakeCase,
|
|
1338
1399
|
cloneItem,
|
|
1339
1400
|
collectFeatureTypes,
|
|
1401
|
+
collectFeatureTypes__,
|
|
1340
1402
|
collectOptions,
|
|
1341
1403
|
collectRoutes,
|
|
1342
1404
|
consoleWarn,
|