@websolutespa/bom-core 1.10.0-next.0 → 2.0.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 +369 -345
- package/dist/index.d.ts +81 -50
- package/dist/index.js +231 -38
- package/dist/{index.cjs → index.mjs} +61 -208
- package/package.json +9 -10
- package/dist/index.d.cts +0 -1363
package/dist/index.d.ts
CHANGED
|
@@ -63,14 +63,6 @@ type IOverride<T, FromType, ToType> = {
|
|
|
63
63
|
type RequireAtLeastOne<T> = {
|
|
64
64
|
[K in keyof T]-?: Required<Pick<T, K>> & Partial<Pick<T, Exclude<keyof T, K>>>;
|
|
65
65
|
}[keyof T];
|
|
66
|
-
type Shift<T extends any[]> = ((...t: T) => any) extends ((first: any, ...rest: infer Rest) => any) ? Rest : never;
|
|
67
|
-
type ShiftUnion<P extends PropertyKey, T extends any[]> = T extends any[] ? T[0] extends P ? Shift<T> : never : never;
|
|
68
|
-
type DeepRequiredProps<T, P extends string[]> = T extends object ? (Omit<T, Extract<keyof T, P[0]>> & Required<{
|
|
69
|
-
[K in Extract<keyof T, P[0]>]: NonNullable<DeepRequiredProps<T[K], ShiftUnion<K, P>>>;
|
|
70
|
-
}>) : T;
|
|
71
|
-
type DeepRequired<T> = {
|
|
72
|
-
[K in keyof T]: Required<DeepRequired<T[K]>>;
|
|
73
|
-
};
|
|
74
66
|
|
|
75
67
|
/**
|
|
76
68
|
* List of ISO 639 language codes (set 1)
|
|
@@ -140,45 +132,6 @@ type IAnchor = {
|
|
|
140
132
|
title: string;
|
|
141
133
|
};
|
|
142
134
|
|
|
143
|
-
type IEquatable = number | string;
|
|
144
|
-
type SchemaType = string;
|
|
145
|
-
type ISchema = {
|
|
146
|
-
id: IEquatable;
|
|
147
|
-
schema?: string;
|
|
148
|
-
};
|
|
149
|
-
type IEntity = ISchema & Record<string, unknown>;
|
|
150
|
-
type INamedEntity = IEntity & {
|
|
151
|
-
name: ILocalizable;
|
|
152
|
-
};
|
|
153
|
-
type ITitledEntity = IEntity & {
|
|
154
|
-
title: ILocalizable;
|
|
155
|
-
};
|
|
156
|
-
type IOption = Record<string, any> & {
|
|
157
|
-
id: IEquatable;
|
|
158
|
-
name: string;
|
|
159
|
-
};
|
|
160
|
-
type IFeature = Record<string, any> & {
|
|
161
|
-
id: IEquatable;
|
|
162
|
-
title: string;
|
|
163
|
-
};
|
|
164
|
-
type IFeatureType = IEntity & {
|
|
165
|
-
id: string;
|
|
166
|
-
title: string;
|
|
167
|
-
mode: string;
|
|
168
|
-
features: IFeature[];
|
|
169
|
-
};
|
|
170
|
-
|
|
171
|
-
type Headings = 'h1' | 'h2' | 'h3' | 'h4' | 'h5' | 'h6';
|
|
172
|
-
|
|
173
|
-
type IComponent = {
|
|
174
|
-
id?: IEquatable;
|
|
175
|
-
blockType?: string;
|
|
176
|
-
schema?: string;
|
|
177
|
-
anchor?: IAnchor;
|
|
178
|
-
seoWeight?: Headings;
|
|
179
|
-
[key: string]: unknown;
|
|
180
|
-
};
|
|
181
|
-
|
|
182
135
|
type IMediaType = 'image' | 'video' | 'json' | 'pdf' | string;
|
|
183
136
|
type IMediaInfo = {
|
|
184
137
|
id: string;
|
|
@@ -235,11 +188,74 @@ declare function isMediaPdf(media: {
|
|
|
235
188
|
}): media is IMediaPdf;
|
|
236
189
|
declare function isMedia(item: unknown): item is IMedia;
|
|
237
190
|
|
|
191
|
+
type IAppExtended = Record<string, any>;
|
|
192
|
+
type IApp<T extends IAppExtended = IAppExtended> = {
|
|
193
|
+
id: 'app';
|
|
194
|
+
brand: {
|
|
195
|
+
name: string;
|
|
196
|
+
businessName?: string;
|
|
197
|
+
appName?: string;
|
|
198
|
+
logo?: IMedia;
|
|
199
|
+
email?: string;
|
|
200
|
+
telephone?: string;
|
|
201
|
+
address?: string;
|
|
202
|
+
city?: string;
|
|
203
|
+
provinceCode?: string;
|
|
204
|
+
zipCode?: string;
|
|
205
|
+
countryCode?: string;
|
|
206
|
+
twitterName?: string;
|
|
207
|
+
social: {
|
|
208
|
+
key: string;
|
|
209
|
+
url: string;
|
|
210
|
+
}[];
|
|
211
|
+
};
|
|
212
|
+
} & T;
|
|
213
|
+
|
|
214
|
+
type IEquatable = number | string;
|
|
215
|
+
type SchemaType = string;
|
|
216
|
+
type ISchema = {
|
|
217
|
+
id: IEquatable;
|
|
218
|
+
schema?: string;
|
|
219
|
+
};
|
|
220
|
+
type IEntity = ISchema & Record<string, unknown>;
|
|
221
|
+
type INamedEntity = IEntity & {
|
|
222
|
+
name: ILocalizable;
|
|
223
|
+
};
|
|
224
|
+
type ITitledEntity = IEntity & {
|
|
225
|
+
title: ILocalizable;
|
|
226
|
+
};
|
|
227
|
+
type IOption = Record<string, any> & {
|
|
228
|
+
id: IEquatable;
|
|
229
|
+
name: string;
|
|
230
|
+
};
|
|
231
|
+
type IFeature = Record<string, any> & {
|
|
232
|
+
id: IEquatable;
|
|
233
|
+
title: string;
|
|
234
|
+
};
|
|
235
|
+
type IFeatureType = IEntity & {
|
|
236
|
+
id: string;
|
|
237
|
+
title: string;
|
|
238
|
+
mode: string;
|
|
239
|
+
features: IFeature[];
|
|
240
|
+
};
|
|
241
|
+
|
|
242
|
+
type Headings = 'h1' | 'h2' | 'h3' | 'h4' | 'h5' | 'h6';
|
|
243
|
+
|
|
244
|
+
type IComponent = {
|
|
245
|
+
id?: IEquatable;
|
|
246
|
+
blockType?: string;
|
|
247
|
+
schema?: string;
|
|
248
|
+
anchor?: IAnchor;
|
|
249
|
+
seoWeight?: Headings;
|
|
250
|
+
[key: string]: unknown;
|
|
251
|
+
};
|
|
252
|
+
|
|
238
253
|
type IMeta = {
|
|
239
254
|
title?: string;
|
|
240
255
|
description?: string;
|
|
241
256
|
keywords?: string;
|
|
242
257
|
robots?: string;
|
|
258
|
+
image?: IMedia;
|
|
243
259
|
};
|
|
244
260
|
|
|
245
261
|
type ICategory = IEntity & {
|
|
@@ -354,14 +370,16 @@ type IMarket = IEntity & {
|
|
|
354
370
|
|
|
355
371
|
type IRoute = {
|
|
356
372
|
category: IEquatable;
|
|
357
|
-
resolvedCategory: IEquatable;
|
|
358
373
|
id: string;
|
|
359
374
|
isDefault?: boolean;
|
|
375
|
+
isRoot?: boolean;
|
|
360
376
|
locale: string;
|
|
361
377
|
market: string;
|
|
362
378
|
media?: IMedia;
|
|
379
|
+
noindex?: boolean;
|
|
363
380
|
order?: number;
|
|
364
381
|
page: IEquatable;
|
|
382
|
+
resolvedCategory: IEquatable;
|
|
365
383
|
schema: string;
|
|
366
384
|
template?: string;
|
|
367
385
|
title: string;
|
|
@@ -557,12 +575,13 @@ type IUndecoratedMenu = IEntity & {
|
|
|
557
575
|
items: IUndecoratedMenuItem[];
|
|
558
576
|
};
|
|
559
577
|
|
|
560
|
-
type ILayout = {
|
|
578
|
+
type ILayout<T extends IAppExtended = IAppExtended> = {
|
|
561
579
|
labels: ILabel[];
|
|
562
580
|
locale: string;
|
|
563
581
|
locales: ILocale[];
|
|
564
582
|
market: string;
|
|
565
583
|
markets: IMarket[];
|
|
584
|
+
app: IPrettify<IApp<T>>;
|
|
566
585
|
menu: Record<string, ILocalizedMenu>;
|
|
567
586
|
topLevelHrefs: Record<string, string>;
|
|
568
587
|
topLevelRoutes: Record<string, IRouteLink>;
|
|
@@ -626,11 +645,19 @@ type QueryParams = {
|
|
|
626
645
|
sort?: string;
|
|
627
646
|
where?: Where;
|
|
628
647
|
};
|
|
648
|
+
type GlobalQueryParams = {
|
|
649
|
+
depth?: number;
|
|
650
|
+
draft?: boolean;
|
|
651
|
+
locale?: string;
|
|
652
|
+
market?: string;
|
|
653
|
+
richText?: boolean;
|
|
654
|
+
};
|
|
629
655
|
|
|
630
656
|
type IPagedResult<T extends IEntity = IEntity> = {
|
|
631
657
|
docs: T[];
|
|
632
658
|
} & Pagination;
|
|
633
659
|
type IQuerable<T extends IEntity = IEntity> = {
|
|
660
|
+
findGlobal<B extends T = T>(params?: GlobalQueryParams, token?: string): Promise<B | undefined>;
|
|
634
661
|
findOne<B extends T = T>(id: IEquatable, params?: QueryParams, token?: string): Promise<B | undefined>;
|
|
635
662
|
findMany<B extends T = T>(params?: QueryParams, token?: string): Promise<B[]>;
|
|
636
663
|
findPaged<B extends T = T>(params?: QueryParams, token?: string): Promise<IPagedResult<B>>;
|
|
@@ -886,6 +913,7 @@ declare class JsonService<T extends IEntity = IEntity> implements IQuerable<T> {
|
|
|
886
913
|
items: T[];
|
|
887
914
|
constructor(items: T[]);
|
|
888
915
|
getItems<B extends T = T>(): Promise<B[]>;
|
|
916
|
+
findGlobal<B extends T = T>(params?: GlobalQueryParams): Promise<B | undefined>;
|
|
889
917
|
findOne<B extends T = T>(id: IEquatable, params?: QueryParams): Promise<B | undefined>;
|
|
890
918
|
findMany<B extends T = T>(params?: QueryParams): Promise<B[]>;
|
|
891
919
|
findPaged<B extends T = T>(params?: QueryParams): Promise<IPagedResult<B>>;
|
|
@@ -1059,6 +1087,9 @@ declare function getOrigin(headers?: IncomingHttpHeaders | Headers): string;
|
|
|
1059
1087
|
|
|
1060
1088
|
/**
|
|
1061
1089
|
* Represents the route strategy options.
|
|
1090
|
+
* - **Auto** dynamically add/remove prefixes based on number of markets & languages.
|
|
1091
|
+
* - **Default** add prefixes based on !isDefault market or language flag.
|
|
1092
|
+
* - **Manual** add prefixes based on !isHidden market or language flag.
|
|
1062
1093
|
*/
|
|
1063
1094
|
declare enum RouteStrategy {
|
|
1064
1095
|
Auto = "auto",
|
|
@@ -1360,4 +1391,4 @@ declare function asServerProps(props: any): any;
|
|
|
1360
1391
|
declare function awaitAll(array: any, callback: (item: any, index: number) => Promise<any>): Promise<any[]>;
|
|
1361
1392
|
declare function merge(target: any, source: any): any;
|
|
1362
1393
|
|
|
1363
|
-
export {
|
|
1394
|
+
export { DeepPartial, Dynamic, FetchError, FetchRequestOptions, FetchService, FindParams, FindWhereParams, GlobalQueryParams, Headings, IAction, IActionEmailData, IAnchor, IApp, IAppExtended, ICategorized, ICategory, ICategoryItem, IClassName, IClassNameCollection, IClassNameValue, ICollectionDescription, IComponent, IConfig, IConsentPreference, IContextBaseParams, IContextParams, IDecoratedNav, IEmailConfig, IEndUser, IEntity, IEquatable, IFeature, IFeatureType, IImageResize, ILabel, ILayout, ILegalNotice, ILetter, ILocale, ILocaleId, ILocalizable, ILocalized, ILocalizedMenu, 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, ImageStrategy, 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, base64ToString, camelToSnakeCase, cloneItem, collectFeatureTypes, collectFeatureTypes__, collectOptions, collectRoutes, consoleWarn, decryptImageResize, deepMerge, defaultLocale, defaultMarket, eachCategorized, eachMarketLocale, eachMedia, eachValue, encryptImageToken, enumToList, excludeComponent, findCategoryInCategories, findChildCategories, findRouteOfCategory, findRoutesOfCategory, getCategorySegments, getCategorySegmentsByCategory, getClassNames, getCollectionDescription, getEnv, getHost, getIsDevelopment, getIsProduction, getOrigin, getParentCategoriesById, getParentCategory, getProto, getRootCategory, getRouteHref, groupComponents, hasComponents, hasMarket, httpDelete, httpFetch, httpGet, httpPatch, httpPost, httpPut, isArray, isBrowser, isComponent, isComponentOfType, isDevelopment, isEntity, isEquatable, isHeaders, isIncomingHttpHeaders, isLocalizedString, isMedia, isMediaImage, isMediaJson, isMediaPdf, isMediaVideo, isMenuCategory, isMenuGroup, isMenuHref, isMenuLink, isMenuPage, isMenuRoute, isNonEmptyArray, isNotNullString, isNumber, isObject, isProduction, isPromise, isRelation, isReservedCollectionDescription, isStage, isString, isUndecoratedCategory, isUndecoratedMenuCategory, isUndecoratedMenuItem, isUndecoratedMenuPage, isUndecoratedNav, isUnresolvedCategory, isUnresolvedRelation, isValidCollectionDescription, isValidString, localize, localizeItem, localizeValue, localizedToString, merge, pascalCaseToCamelCase, pascalCaseToCharCase, pascalCaseToKebabCase, pascalCaseToSnakeCase, passwordStrategy, pickComponent, pickHero, prependHero, qsDeserialize, qsDeserializeRaw, qsSerialize, qsSerializeRaw, resolveMediaType, stringToBase64, toCamelCase, toCharCase, toDisplayName, toFindParams, toKebabCase, toPascalCase, toPluralName, toSnakeCase, toTitleCase, toValidCollectionName, unknownCaseToPascalCase, uuidv4, withSchema };
|
package/dist/index.js
CHANGED
|
@@ -1,3 +1,172 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
+
};
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
+
mod
|
|
27
|
+
));
|
|
28
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
+
|
|
30
|
+
// src/index.ts
|
|
31
|
+
var src_exports = {};
|
|
32
|
+
__export(src_exports, {
|
|
33
|
+
ImageStrategy: () => ImageStrategy,
|
|
34
|
+
JsonService: () => JsonService,
|
|
35
|
+
Logger: () => Logger,
|
|
36
|
+
LoggerLevel: () => LoggerLevel,
|
|
37
|
+
MenuCategoryStrategy: () => MenuCategoryStrategy,
|
|
38
|
+
RedirectReason: () => RedirectReason,
|
|
39
|
+
RouteStrategy: () => RouteStrategy,
|
|
40
|
+
arrayShuffle: () => arrayShuffle,
|
|
41
|
+
asCategoryId: () => asCategoryId,
|
|
42
|
+
asEntityId: () => asEntityId,
|
|
43
|
+
asEquatable: () => asEquatable,
|
|
44
|
+
asEquatableNumber: () => asEquatableNumber,
|
|
45
|
+
asEquatableString: () => asEquatableString,
|
|
46
|
+
asServerProps: () => asServerProps,
|
|
47
|
+
asSortedOptions: () => asSortedOptions,
|
|
48
|
+
awaitAll: () => awaitAll,
|
|
49
|
+
base64ToString: () => base64ToString,
|
|
50
|
+
camelToSnakeCase: () => camelToSnakeCase,
|
|
51
|
+
cloneItem: () => cloneItem,
|
|
52
|
+
collectFeatureTypes: () => collectFeatureTypes,
|
|
53
|
+
collectFeatureTypes__: () => collectFeatureTypes__,
|
|
54
|
+
collectOptions: () => collectOptions,
|
|
55
|
+
collectRoutes: () => collectRoutes,
|
|
56
|
+
consoleWarn: () => consoleWarn,
|
|
57
|
+
decryptImageResize: () => decryptImageResize,
|
|
58
|
+
deepMerge: () => deepMerge,
|
|
59
|
+
defaultLocale: () => defaultLocale,
|
|
60
|
+
defaultMarket: () => defaultMarket,
|
|
61
|
+
eachCategorized: () => eachCategorized,
|
|
62
|
+
eachMarketLocale: () => eachMarketLocale,
|
|
63
|
+
eachMedia: () => eachMedia,
|
|
64
|
+
eachValue: () => eachValue,
|
|
65
|
+
encryptImageToken: () => encryptImageToken,
|
|
66
|
+
enumToList: () => enumToList,
|
|
67
|
+
excludeComponent: () => excludeComponent,
|
|
68
|
+
findCategoryInCategories: () => findCategoryInCategories,
|
|
69
|
+
findChildCategories: () => findChildCategories,
|
|
70
|
+
findRouteOfCategory: () => findRouteOfCategory,
|
|
71
|
+
findRoutesOfCategory: () => findRoutesOfCategory,
|
|
72
|
+
getCategorySegments: () => getCategorySegments,
|
|
73
|
+
getCategorySegmentsByCategory: () => getCategorySegmentsByCategory,
|
|
74
|
+
getClassNames: () => getClassNames,
|
|
75
|
+
getCollectionDescription: () => getCollectionDescription,
|
|
76
|
+
getEnv: () => getEnv,
|
|
77
|
+
getHost: () => getHost,
|
|
78
|
+
getIsDevelopment: () => getIsDevelopment,
|
|
79
|
+
getIsProduction: () => getIsProduction,
|
|
80
|
+
getOrigin: () => getOrigin,
|
|
81
|
+
getParentCategoriesById: () => getParentCategoriesById,
|
|
82
|
+
getParentCategory: () => getParentCategory,
|
|
83
|
+
getProto: () => getProto,
|
|
84
|
+
getRootCategory: () => getRootCategory,
|
|
85
|
+
getRouteHref: () => getRouteHref,
|
|
86
|
+
groupComponents: () => groupComponents,
|
|
87
|
+
hasComponents: () => hasComponents,
|
|
88
|
+
hasMarket: () => hasMarket,
|
|
89
|
+
httpDelete: () => httpDelete,
|
|
90
|
+
httpFetch: () => httpFetch,
|
|
91
|
+
httpGet: () => httpGet,
|
|
92
|
+
httpPatch: () => httpPatch,
|
|
93
|
+
httpPost: () => httpPost,
|
|
94
|
+
httpPut: () => httpPut,
|
|
95
|
+
isArray: () => isArray,
|
|
96
|
+
isBrowser: () => isBrowser,
|
|
97
|
+
isComponent: () => isComponent,
|
|
98
|
+
isComponentOfType: () => isComponentOfType,
|
|
99
|
+
isDevelopment: () => isDevelopment,
|
|
100
|
+
isEntity: () => isEntity,
|
|
101
|
+
isEquatable: () => isEquatable,
|
|
102
|
+
isHeaders: () => isHeaders,
|
|
103
|
+
isIncomingHttpHeaders: () => isIncomingHttpHeaders,
|
|
104
|
+
isLocalizedString: () => isLocalizedString,
|
|
105
|
+
isMedia: () => isMedia,
|
|
106
|
+
isMediaImage: () => isMediaImage,
|
|
107
|
+
isMediaJson: () => isMediaJson,
|
|
108
|
+
isMediaPdf: () => isMediaPdf,
|
|
109
|
+
isMediaVideo: () => isMediaVideo,
|
|
110
|
+
isMenuCategory: () => isMenuCategory,
|
|
111
|
+
isMenuGroup: () => isMenuGroup,
|
|
112
|
+
isMenuHref: () => isMenuHref,
|
|
113
|
+
isMenuLink: () => isMenuLink,
|
|
114
|
+
isMenuPage: () => isMenuPage,
|
|
115
|
+
isMenuRoute: () => isMenuRoute,
|
|
116
|
+
isNonEmptyArray: () => isNonEmptyArray,
|
|
117
|
+
isNotNullString: () => isNotNullString,
|
|
118
|
+
isNumber: () => isNumber,
|
|
119
|
+
isObject: () => isObject,
|
|
120
|
+
isProduction: () => isProduction,
|
|
121
|
+
isPromise: () => isPromise,
|
|
122
|
+
isRelation: () => isRelation,
|
|
123
|
+
isReservedCollectionDescription: () => isReservedCollectionDescription,
|
|
124
|
+
isStage: () => isStage,
|
|
125
|
+
isString: () => isString,
|
|
126
|
+
isUndecoratedCategory: () => isUndecoratedCategory,
|
|
127
|
+
isUndecoratedMenuCategory: () => isUndecoratedMenuCategory,
|
|
128
|
+
isUndecoratedMenuItem: () => isUndecoratedMenuItem,
|
|
129
|
+
isUndecoratedMenuPage: () => isUndecoratedMenuPage,
|
|
130
|
+
isUndecoratedNav: () => isUndecoratedNav,
|
|
131
|
+
isUnresolvedCategory: () => isUnresolvedCategory,
|
|
132
|
+
isUnresolvedRelation: () => isUnresolvedRelation,
|
|
133
|
+
isValidCollectionDescription: () => isValidCollectionDescription,
|
|
134
|
+
isValidString: () => isValidString,
|
|
135
|
+
localize: () => localize,
|
|
136
|
+
localizeItem: () => localizeItem,
|
|
137
|
+
localizeValue: () => localizeValue,
|
|
138
|
+
localizedToString: () => localizedToString,
|
|
139
|
+
merge: () => merge,
|
|
140
|
+
pascalCaseToCamelCase: () => pascalCaseToCamelCase,
|
|
141
|
+
pascalCaseToCharCase: () => pascalCaseToCharCase,
|
|
142
|
+
pascalCaseToKebabCase: () => pascalCaseToKebabCase,
|
|
143
|
+
pascalCaseToSnakeCase: () => pascalCaseToSnakeCase,
|
|
144
|
+
passwordStrategy: () => passwordStrategy,
|
|
145
|
+
pickComponent: () => pickComponent,
|
|
146
|
+
pickHero: () => pickHero,
|
|
147
|
+
prependHero: () => prependHero,
|
|
148
|
+
qsDeserialize: () => qsDeserialize,
|
|
149
|
+
qsDeserializeRaw: () => qsDeserializeRaw,
|
|
150
|
+
qsSerialize: () => qsSerialize,
|
|
151
|
+
qsSerializeRaw: () => qsSerializeRaw,
|
|
152
|
+
resolveMediaType: () => resolveMediaType,
|
|
153
|
+
stringToBase64: () => stringToBase64,
|
|
154
|
+
toCamelCase: () => toCamelCase,
|
|
155
|
+
toCharCase: () => toCharCase,
|
|
156
|
+
toDisplayName: () => toDisplayName,
|
|
157
|
+
toFindParams: () => toFindParams,
|
|
158
|
+
toKebabCase: () => toKebabCase,
|
|
159
|
+
toPascalCase: () => toPascalCase,
|
|
160
|
+
toPluralName: () => toPluralName,
|
|
161
|
+
toSnakeCase: () => toSnakeCase,
|
|
162
|
+
toTitleCase: () => toTitleCase,
|
|
163
|
+
toValidCollectionName: () => toValidCollectionName,
|
|
164
|
+
unknownCaseToPascalCase: () => unknownCaseToPascalCase,
|
|
165
|
+
uuidv4: () => uuidv4,
|
|
166
|
+
withSchema: () => withSchema
|
|
167
|
+
});
|
|
168
|
+
module.exports = __toCommonJS(src_exports);
|
|
169
|
+
|
|
1
170
|
// src/utils/arrayShuffle.ts
|
|
2
171
|
function arrayShuffle(items) {
|
|
3
172
|
return items.map((item) => ({ item, order: Math.random() })).sort((a, b) => a.order - b.order).map(({ item }) => item);
|
|
@@ -624,7 +793,7 @@ function classNameCollectionToString(className) {
|
|
|
624
793
|
let classNames = "";
|
|
625
794
|
for (let i = 0; i < total; i++) {
|
|
626
795
|
const key = keys[i];
|
|
627
|
-
const value = className[
|
|
796
|
+
const value = className[keys[i]];
|
|
628
797
|
if (!value) {
|
|
629
798
|
continue;
|
|
630
799
|
}
|
|
@@ -653,7 +822,7 @@ function getClassNames(...props) {
|
|
|
653
822
|
}
|
|
654
823
|
|
|
655
824
|
// src/collection/collection.ts
|
|
656
|
-
|
|
825
|
+
var import_pluralize = __toESM(require("pluralize"));
|
|
657
826
|
function getCollectionDescription(text) {
|
|
658
827
|
text = toValidCollectionName(text);
|
|
659
828
|
const displayName = toDisplayName(text);
|
|
@@ -693,7 +862,7 @@ function toDisplayName(text) {
|
|
|
693
862
|
return toTitleCase(text).replace(/\s/g, "");
|
|
694
863
|
}
|
|
695
864
|
function toPluralName(text) {
|
|
696
|
-
const plural =
|
|
865
|
+
const plural = import_pluralize.default.plural(text);
|
|
697
866
|
return plural === text ? `${plural}es` : plural;
|
|
698
867
|
}
|
|
699
868
|
function toTitleCase(text) {
|
|
@@ -823,13 +992,21 @@ function decryptImageResize(token) {
|
|
|
823
992
|
|
|
824
993
|
// src/json/json.service.ts
|
|
825
994
|
var JsonService = class {
|
|
826
|
-
items;
|
|
827
995
|
constructor(items) {
|
|
828
996
|
this.items = items;
|
|
829
997
|
}
|
|
830
998
|
async getItems() {
|
|
831
999
|
return this.items;
|
|
832
1000
|
}
|
|
1001
|
+
async findGlobal(params = {}) {
|
|
1002
|
+
const items = await this.getItems();
|
|
1003
|
+
if (items.length > 0) {
|
|
1004
|
+
return await this.decorateOne_(items[0], params);
|
|
1005
|
+
} else {
|
|
1006
|
+
console.log("JsonService.findGlobal.notfound", params);
|
|
1007
|
+
return void 0;
|
|
1008
|
+
}
|
|
1009
|
+
}
|
|
833
1010
|
async findOne(id, params = {}) {
|
|
834
1011
|
let items = await this.getItems();
|
|
835
1012
|
params.where = params.where || {};
|
|
@@ -1080,7 +1257,7 @@ var JsonService = class {
|
|
|
1080
1257
|
return false;
|
|
1081
1258
|
}
|
|
1082
1259
|
const [longitude, latitude, maxDistance, minDistance] = near;
|
|
1083
|
-
const distance =
|
|
1260
|
+
const distance = calculateDistanceInMeters_(itemLongitude, itemLatitude, longitude, latitude);
|
|
1084
1261
|
if (typeof maxDistance === "number" && typeof minDistance === "number") {
|
|
1085
1262
|
return distance <= maxDistance && distance >= minDistance;
|
|
1086
1263
|
} else if (typeof maxDistance === "number") {
|
|
@@ -1224,7 +1401,11 @@ function getValue(item, key) {
|
|
|
1224
1401
|
const keys = key.split(".");
|
|
1225
1402
|
const value = keys.reduce((p, c) => {
|
|
1226
1403
|
if (isObject(p)) {
|
|
1227
|
-
|
|
1404
|
+
const v = p[c];
|
|
1405
|
+
if (isUnresolvedRelation(v)) {
|
|
1406
|
+
return v.value;
|
|
1407
|
+
}
|
|
1408
|
+
return v;
|
|
1228
1409
|
} else {
|
|
1229
1410
|
return void 0;
|
|
1230
1411
|
}
|
|
@@ -1266,7 +1447,7 @@ function isLocalizedString(value) {
|
|
|
1266
1447
|
return isLocalizedString2;
|
|
1267
1448
|
}
|
|
1268
1449
|
function localizedToString(json, locale, defaultLocale2 = DEFAULT_LOCALE) {
|
|
1269
|
-
const localizedString = json[locale] || json[defaultLocale2] || Object.values(json)[0]
|
|
1450
|
+
const localizedString = json[locale] || json[defaultLocale2] || Object.values(json)[0];
|
|
1270
1451
|
return localizedString;
|
|
1271
1452
|
}
|
|
1272
1453
|
function localize(value, locale, defaultLocale2 = DEFAULT_LOCALE) {
|
|
@@ -1305,7 +1486,6 @@ var LoggerLevel = /* @__PURE__ */ ((LoggerLevel2) => {
|
|
|
1305
1486
|
return LoggerLevel2;
|
|
1306
1487
|
})(LoggerLevel || {});
|
|
1307
1488
|
var Logger = class {
|
|
1308
|
-
static level_ = 5 /* ALL */;
|
|
1309
1489
|
static setLevel(level) {
|
|
1310
1490
|
this.level_ = level;
|
|
1311
1491
|
}
|
|
@@ -1337,6 +1517,7 @@ var Logger = class {
|
|
|
1337
1517
|
}
|
|
1338
1518
|
}
|
|
1339
1519
|
};
|
|
1520
|
+
Logger.level_ = 5 /* ALL */;
|
|
1340
1521
|
|
|
1341
1522
|
// src/market/market.ts
|
|
1342
1523
|
function getDefaultMarket() {
|
|
@@ -1509,22 +1690,7 @@ var RouteStrategy = /* @__PURE__ */ ((RouteStrategy2) => {
|
|
|
1509
1690
|
RouteStrategy2["Manual"] = "manual";
|
|
1510
1691
|
return RouteStrategy2;
|
|
1511
1692
|
})(RouteStrategy || {});
|
|
1512
|
-
var ROUTE_STRATEGY = process.env.ROUTE_STRATEGY || "
|
|
1513
|
-
function getPickedProps(item) {
|
|
1514
|
-
const pickedProps = Object.fromEntries(Object.entries(item).filter(([k, v]) => [
|
|
1515
|
-
"category",
|
|
1516
|
-
"isDefault",
|
|
1517
|
-
"media",
|
|
1518
|
-
"order",
|
|
1519
|
-
"template",
|
|
1520
|
-
"updatedAt",
|
|
1521
|
-
"useSplat",
|
|
1522
|
-
// 'createdAt',
|
|
1523
|
-
"updatedAt",
|
|
1524
|
-
"_status"
|
|
1525
|
-
].includes(k)));
|
|
1526
|
-
return pickedProps;
|
|
1527
|
-
}
|
|
1693
|
+
var ROUTE_STRATEGY = process.env.ROUTE_STRATEGY || "manual" /* Manual */;
|
|
1528
1694
|
function collectRoutes(store, categories, markets, locales, medias) {
|
|
1529
1695
|
const routes = [];
|
|
1530
1696
|
if (locales.length > 0 && markets.length > 0) {
|
|
@@ -1538,31 +1704,57 @@ function collectRoutes(store, categories, markets, locales, medias) {
|
|
|
1538
1704
|
if (Boolean(item.isDefault) === false) {
|
|
1539
1705
|
slugs.push({ slug: item.slug });
|
|
1540
1706
|
}
|
|
1541
|
-
const defaultLocale2 = locales.find((x) => x.isDefault) || locales[0];
|
|
1542
|
-
const defaultMarket2 = markets.find((x) => x.isDefault) || markets[0];
|
|
1543
|
-
const defaultMarketLocale = defaultMarket2 && defaultMarket2.defaultLanguage ? asEntityId(defaultMarket2.defaultLanguage) : defaultLocale2.id;
|
|
1544
1707
|
const isRootCategory = rootCategory && item.category === rootCategory.id && item.isDefault;
|
|
1545
1708
|
eachMarketLocale(markets, locales, (market, locale, markets2, locales2) => {
|
|
1546
1709
|
if (hasMarket(item, market)) {
|
|
1547
1710
|
const title = localize(item.title, locale.id);
|
|
1548
1711
|
const id = getRouteHref(slugs, market, locale, markets2, locales2);
|
|
1549
|
-
const
|
|
1550
|
-
|
|
1712
|
+
const {
|
|
1713
|
+
_status,
|
|
1714
|
+
category,
|
|
1715
|
+
isDefault,
|
|
1716
|
+
media,
|
|
1717
|
+
order,
|
|
1718
|
+
template,
|
|
1719
|
+
updatedAt,
|
|
1720
|
+
useSplat
|
|
1721
|
+
} = item;
|
|
1551
1722
|
const route = {
|
|
1552
|
-
|
|
1553
|
-
|
|
1554
|
-
id: isDefaultRootCategory ?
|
|
1723
|
+
_status,
|
|
1724
|
+
category,
|
|
1725
|
+
// id: isDefaultRootCategory ? '/' : id,
|
|
1726
|
+
id,
|
|
1555
1727
|
locale: locale.id,
|
|
1556
1728
|
market: market.id,
|
|
1729
|
+
media,
|
|
1557
1730
|
page: item.id,
|
|
1731
|
+
resolvedCategory: visibleCategory.id,
|
|
1558
1732
|
schema: key,
|
|
1559
|
-
|
|
1733
|
+
template,
|
|
1734
|
+
title,
|
|
1735
|
+
updatedAt
|
|
1560
1736
|
};
|
|
1737
|
+
if (isDefault) {
|
|
1738
|
+
route.isDefault = true;
|
|
1739
|
+
}
|
|
1740
|
+
if (isRootCategory) {
|
|
1741
|
+
route.isRoot = true;
|
|
1742
|
+
}
|
|
1743
|
+
const noindex = (item.meta?.robots || "").includes("noindex");
|
|
1744
|
+
if (noindex) {
|
|
1745
|
+
route.noindex = true;
|
|
1746
|
+
}
|
|
1747
|
+
if (order != null) {
|
|
1748
|
+
route.order = order;
|
|
1749
|
+
}
|
|
1750
|
+
if (useSplat) {
|
|
1751
|
+
route.useSplat = true;
|
|
1752
|
+
}
|
|
1561
1753
|
const mediaId = typeof item.media === "string" ? item.media : void 0;
|
|
1562
1754
|
if (Array.isArray(medias) && mediaId) {
|
|
1563
|
-
const
|
|
1564
|
-
if (
|
|
1565
|
-
route.media =
|
|
1755
|
+
const media2 = item.media && medias.find((x) => x.id === mediaId);
|
|
1756
|
+
if (media2) {
|
|
1757
|
+
route.media = media2;
|
|
1566
1758
|
}
|
|
1567
1759
|
}
|
|
1568
1760
|
routes.push(route);
|
|
@@ -1642,7 +1834,8 @@ function getRouteHref(segments, market, locale, markets, locales) {
|
|
|
1642
1834
|
function hasMarket(item, market) {
|
|
1643
1835
|
return !item.markets || item.markets.length === 0 || item.markets.includes(market.id);
|
|
1644
1836
|
}
|
|
1645
|
-
export
|
|
1837
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
1838
|
+
0 && (module.exports = {
|
|
1646
1839
|
ImageStrategy,
|
|
1647
1840
|
JsonService,
|
|
1648
1841
|
Logger,
|
|
@@ -1777,4 +1970,4 @@ export {
|
|
|
1777
1970
|
unknownCaseToPascalCase,
|
|
1778
1971
|
uuidv4,
|
|
1779
1972
|
withSchema
|
|
1780
|
-
};
|
|
1973
|
+
});
|