@websolutespa/bom-core 2.0.1-next.0 → 2.0.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/dist/index.d.ts CHANGED
@@ -1,6 +1,6 @@
1
- import { IncomingMessage, ServerResponse, IncomingHttpHeaders } from 'node:http';
2
- import { ParsedUrlQuery } from 'node:querystring';
3
- import { FC } from 'react';
1
+ import { IncomingMessage, ServerResponse, IncomingHttpHeaders } from 'http';
2
+ import { ParsedUrlQuery } from 'querystring';
3
+ import React from 'react';
4
4
 
5
5
  declare function base64ToString(text: string): string;
6
6
  declare function stringToBase64(text: string): string;
@@ -20,13 +20,11 @@ type IContextParams = IContextBaseParams & {
20
20
  };
21
21
  type StaticPropsContext<Q extends ParsedUrlQuery = ParsedUrlQuery, D extends PreviewData = PreviewData> = {
22
22
  params: Q;
23
- draftMode?: boolean;
23
+ preview?: boolean;
24
+ previewData?: D;
24
25
  locale?: string;
25
26
  locales?: string[];
26
27
  defaultLocale?: string;
27
- revalidateReason?: 'build' | 'stale' | 'on-demand';
28
- preview?: boolean;
29
- previewData?: D;
30
28
  };
31
29
  type IStaticContext<T extends {} = {}> = StaticPropsContext<IContextParams & T>;
32
30
  declare type NextApiRequestCookies = Partial<{
@@ -38,15 +36,13 @@ type ServerSidePropsContext<Q extends ParsedUrlQuery = ParsedUrlQuery, D extends
38
36
  };
39
37
  res: ServerResponse;
40
38
  params: Q;
41
- draftMode?: boolean;
42
39
  query: ParsedUrlQuery;
40
+ preview?: boolean;
41
+ previewData?: D;
43
42
  resolvedUrl: string;
44
43
  locale?: string;
45
44
  locales?: string[];
46
45
  defaultLocale?: string;
47
- revalidateReason?: 'build' | 'stale' | 'on-demand';
48
- preview?: boolean;
49
- previewData?: D;
50
46
  };
51
47
  type IServerSideSplatContext<T extends {} = {}> = ServerSidePropsContext<IContextBaseParams & T>;
52
48
  type IServerSideContext<T extends {} = {}> = ServerSidePropsContext<IContextParams & T>;
@@ -67,14 +63,6 @@ type IOverride<T, FromType, ToType> = {
67
63
  type RequireAtLeastOne<T> = {
68
64
  [K in keyof T]-?: Required<Pick<T, K>> & Partial<Pick<T, Exclude<keyof T, K>>>;
69
65
  }[keyof T];
70
- type Shift<T extends any[]> = ((...t: T) => any) extends ((first: any, ...rest: infer Rest) => any) ? Rest : never;
71
- type ShiftUnion<P extends PropertyKey, T extends any[]> = T extends any[] ? T[0] extends P ? Shift<T> : never : never;
72
- type DeepRequiredProps<T, P extends string[]> = T extends object ? (Omit<T, Extract<keyof T, P[0]>> & Required<{
73
- [K in Extract<keyof T, P[0]>]: NonNullable<DeepRequiredProps<T[K], ShiftUnion<K, P>>>;
74
- }>) : T;
75
- type DeepRequired<T> = {
76
- [K in keyof T]: Required<DeepRequired<T[K]>>;
77
- };
78
66
 
79
67
  /**
80
68
  * List of ISO 639 language codes (set 1)
@@ -144,45 +132,6 @@ type IAnchor = {
144
132
  title: string;
145
133
  };
146
134
 
147
- type IEquatable = number | string;
148
- type SchemaType = string;
149
- type ISchema = {
150
- id: IEquatable;
151
- schema?: string;
152
- };
153
- type IEntity = ISchema & Record<string, unknown>;
154
- type INamedEntity = IEntity & {
155
- name: ILocalizable;
156
- };
157
- type ITitledEntity = IEntity & {
158
- title: ILocalizable;
159
- };
160
- type IOption = Record<string, any> & {
161
- id: IEquatable;
162
- name: string;
163
- };
164
- type IFeature = Record<string, any> & {
165
- id: IEquatable;
166
- title: string;
167
- };
168
- type IFeatureType = IEntity & {
169
- id: string;
170
- title: string;
171
- mode: string;
172
- features: IFeature[];
173
- };
174
-
175
- type Headings = 'h1' | 'h2' | 'h3' | 'h4' | 'h5' | 'h6';
176
-
177
- type IComponent = {
178
- id?: IEquatable;
179
- blockType?: string;
180
- schema?: string;
181
- anchor?: IAnchor;
182
- seoWeight?: Headings;
183
- [key: string]: unknown;
184
- };
185
-
186
135
  type IMediaType = 'image' | 'video' | 'json' | 'pdf' | string;
187
136
  type IMediaInfo = {
188
137
  id: string;
@@ -239,6 +188,68 @@ declare function isMediaPdf(media: {
239
188
  }): media is IMediaPdf;
240
189
  declare function isMedia(item: unknown): item is IMedia;
241
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
+
242
253
  type IMeta = {
243
254
  title?: string;
244
255
  description?: string;
@@ -359,14 +370,16 @@ type IMarket = IEntity & {
359
370
 
360
371
  type IRoute = {
361
372
  category: IEquatable;
362
- resolvedCategory: IEquatable;
363
373
  id: string;
364
374
  isDefault?: boolean;
375
+ isRoot?: boolean;
365
376
  locale: string;
366
377
  market: string;
367
378
  media?: IMedia;
379
+ noindex?: boolean;
368
380
  order?: number;
369
381
  page: IEquatable;
382
+ resolvedCategory: IEquatable;
370
383
  schema: string;
371
384
  template?: string;
372
385
  title: string;
@@ -562,12 +575,13 @@ type IUndecoratedMenu = IEntity & {
562
575
  items: IUndecoratedMenuItem[];
563
576
  };
564
577
 
565
- type ILayout = {
578
+ type ILayout<T extends IAppExtended = IAppExtended> = {
566
579
  labels: ILabel[];
567
580
  locale: string;
568
581
  locales: ILocale[];
569
582
  market: string;
570
583
  markets: IMarket[];
584
+ app: IPrettify<IApp<T>>;
571
585
  menu: Record<string, ILocalizedMenu>;
572
586
  topLevelHrefs: Record<string, string>;
573
587
  topLevelRoutes: Record<string, IRouteLink>;
@@ -631,11 +645,19 @@ type QueryParams = {
631
645
  sort?: string;
632
646
  where?: Where;
633
647
  };
648
+ type GlobalQueryParams = {
649
+ depth?: number;
650
+ draft?: boolean;
651
+ locale?: string;
652
+ market?: string;
653
+ richText?: boolean;
654
+ };
634
655
 
635
656
  type IPagedResult<T extends IEntity = IEntity> = {
636
657
  docs: T[];
637
658
  } & Pagination;
638
659
  type IQuerable<T extends IEntity = IEntity> = {
660
+ findGlobal<B extends T = T>(params?: GlobalQueryParams, token?: string): Promise<B | undefined>;
639
661
  findOne<B extends T = T>(id: IEquatable, params?: QueryParams, token?: string): Promise<B | undefined>;
640
662
  findMany<B extends T = T>(params?: QueryParams, token?: string): Promise<B[]>;
641
663
  findPaged<B extends T = T>(params?: QueryParams, token?: string): Promise<IPagedResult<B>>;
@@ -891,7 +913,7 @@ declare class JsonService<T extends IEntity = IEntity> implements IQuerable<T> {
891
913
  items: T[];
892
914
  constructor(items: T[]);
893
915
  getItems<B extends T = T>(): Promise<B[]>;
894
- protected whereId_(id: IEquatable): WhereField;
916
+ findGlobal<B extends T = T>(params?: GlobalQueryParams): Promise<B | undefined>;
895
917
  findOne<B extends T = T>(id: IEquatable, params?: QueryParams): Promise<B | undefined>;
896
918
  findMany<B extends T = T>(params?: QueryParams): Promise<B[]>;
897
919
  findPaged<B extends T = T>(params?: QueryParams): Promise<IPagedResult<B>>;
@@ -1065,6 +1087,9 @@ declare function getOrigin(headers?: IncomingHttpHeaders | Headers): string;
1065
1087
 
1066
1088
  /**
1067
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.
1068
1093
  */
1069
1094
  declare enum RouteStrategy {
1070
1095
  Auto = "auto",
@@ -1361,9 +1386,9 @@ declare const isProduction: boolean;
1361
1386
  declare const isStage: boolean;
1362
1387
  declare const isBrowser: boolean;
1363
1388
  declare function getEnv(): Record<string, Json>;
1364
- declare function withSchema<Component extends FC<any>, Schema>(component: Component, schema: Schema): Component & Schema;
1389
+ declare function withSchema<Component extends React.FC<any>, Schema>(component: Component, schema: Schema): Component & Schema;
1365
1390
  declare function asServerProps(props: any): any;
1366
1391
  declare function awaitAll(array: any, callback: (item: any, index: number) => Promise<any>): Promise<any[]>;
1367
1392
  declare function merge(target: any, source: any): any;
1368
1393
 
1369
- export { type DeepPartial, type DeepRequired, type DeepRequiredProps, type Dynamic, type FetchError, type FetchRequestOptions, type FetchService, type FindParams, type FindWhereParams, type Headings, type IAction, type IActionEmailData, type IAnchor, type ICategorized, type ICategory, type ICategoryItem, type IClassName, type IClassNameCollection, type IClassNameValue, type ICollectionDescription, type IComponent, type IConfig, type IConsentPreference, type IContextBaseParams, type IContextParams, type IDecoratedNav, type IEmailConfig, type IEndUser, type IEntity, type IEquatable, type IFeature, type IFeatureType, type IImageResize, type ILabel, type ILayout, type ILegalNotice, type ILetter, type ILocale, type ILocaleId, type ILocalizable, type ILocalized, type ILocalizedMenu, type ILocalizedString, type IMarket, type IMedia, type IMediaImage, type IMediaInfo, type IMediaJson, type IMediaPdf, type IMediaType, type IMediaVideo, type IMemoryStore, type IMenu, type IMenuBase, type IMenuCategory, type IMenuCustom, type IMenuGroup, type IMenuHref, type IMenuItem, type IMenuLink, type IMenuPage, type IMenuRoute, type INamedEntity, type IOption, type IOverride, type IOverrideReturnValue, type IOverrideValue, type IPackages, type IPage, type IPageItem, type IPageRelation, type IPageRelationResult, type IPageUnresolvedRelation, type IPagedResult, type IPaginationResult, type IPartial, type IPreference, type IPrettify, type IQuerable, type IRedirect, type IRoute, type IRouteCanonical, type IRouteLink, type IRouteParams, type ISchema, type ISerializedCollection, type ISerializedStore, type IServerSideContext, type IServerSideSplatContext, type IStaticContext, type IStore, type ITemplate, type ITitledEntity, type IUndecoratedMenu, type IUndecoratedMenuBase, type IUndecoratedMenuCategory, type IUndecoratedMenuCustom, type IUndecoratedMenuGroup, type IUndecoratedMenuItem, type IUndecoratedMenuLink, type IUndecoratedMenuPage, type IUndecoratedNav, ImageStrategy, type Json, JsonService, type LiteralUnion, Logger, LoggerLevel, MenuCategoryStrategy, type NextApiRequestCookies, type Operator, type PageProps, type Pagination, type PreviewData, type Primitive, type QueryParams, RedirectReason, type RequireAtLeastOne, RouteStrategy, type SchemaType, type ServerSidePropsContext, type Shift, type ShiftUnion, type StaticPropsContext, type User, type UserRole, type UserWithRoles, type ValueOf, type Where, type WhereAndOr, type WhereBase, type 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 };
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[key];
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
- import pluralize from "pluralize";
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 = pluralize.plural(text);
865
+ const plural = import_pluralize.default.plural(text);
697
866
  return plural === text ? `${plural}es` : plural;
698
867
  }
699
868
  function toTitleCase(text) {
@@ -823,24 +992,25 @@ 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
  }
833
- whereId_(id) {
834
- return typeof id === "string" && /^[0-9]+$/.test(id) ? {
835
- in: [id, parseInt(id)]
836
- } : {
837
- equals: id
838
- };
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
+ }
839
1009
  }
840
1010
  async findOne(id, params = {}) {
841
1011
  let items = await this.getItems();
842
1012
  params.where = params.where || {};
843
- params.where.id = params.where.id || this.whereId_(id);
1013
+ params.where.id = params.where.id || { equals: id };
844
1014
  items = this.whereItems_(items, params.where);
845
1015
  if (items.length > 0) {
846
1016
  return await this.decorateOne_(items[0], params);
@@ -885,7 +1055,7 @@ var JsonService = class {
885
1055
  async updateOne(id, payload, params = {}) {
886
1056
  let items = await this.getItems();
887
1057
  params.where = params.where || {};
888
- params.where.id = params.where.id || this.whereId_(id);
1058
+ params.where.id = params.where.id || { equals: id };
889
1059
  const whereItems = this.whereItems_(items, params.where);
890
1060
  if (whereItems.length > 0) {
891
1061
  const index = items.indexOf(whereItems[0]);
@@ -923,7 +1093,7 @@ var JsonService = class {
923
1093
  async deleteOne(id, params = {}) {
924
1094
  let items = await this.getItems();
925
1095
  params.where = params.where || {};
926
- params.where.id = params.where.id || this.whereId_(id);
1096
+ params.where.id = params.where.id || { equals: id };
927
1097
  const whereItems = this.whereItems_(items, params.where);
928
1098
  if (whereItems.length > 0) {
929
1099
  const index = items.indexOf(whereItems[0]);
@@ -1087,7 +1257,7 @@ var JsonService = class {
1087
1257
  return false;
1088
1258
  }
1089
1259
  const [longitude, latitude, maxDistance, minDistance] = near;
1090
- const distance = longitude && latitude ? calculateDistanceInMeters_(itemLongitude, itemLatitude, longitude, latitude) : 0;
1260
+ const distance = calculateDistanceInMeters_(itemLongitude, itemLatitude, longitude, latitude);
1091
1261
  if (typeof maxDistance === "number" && typeof minDistance === "number") {
1092
1262
  return distance <= maxDistance && distance >= minDistance;
1093
1263
  } else if (typeof maxDistance === "number") {
@@ -1277,7 +1447,7 @@ function isLocalizedString(value) {
1277
1447
  return isLocalizedString2;
1278
1448
  }
1279
1449
  function localizedToString(json, locale, defaultLocale2 = DEFAULT_LOCALE) {
1280
- const localizedString = json[locale] || json[defaultLocale2] || Object.values(json)[0] || "";
1450
+ const localizedString = json[locale] || json[defaultLocale2] || Object.values(json)[0];
1281
1451
  return localizedString;
1282
1452
  }
1283
1453
  function localize(value, locale, defaultLocale2 = DEFAULT_LOCALE) {
@@ -1316,7 +1486,6 @@ var LoggerLevel = /* @__PURE__ */ ((LoggerLevel2) => {
1316
1486
  return LoggerLevel2;
1317
1487
  })(LoggerLevel || {});
1318
1488
  var Logger = class {
1319
- static level_ = 5 /* ALL */;
1320
1489
  static setLevel(level) {
1321
1490
  this.level_ = level;
1322
1491
  }
@@ -1348,6 +1517,7 @@ var Logger = class {
1348
1517
  }
1349
1518
  }
1350
1519
  };
1520
+ Logger.level_ = 5 /* ALL */;
1351
1521
 
1352
1522
  // src/market/market.ts
1353
1523
  function getDefaultMarket() {
@@ -1505,11 +1675,15 @@ function getProto(headers) {
1505
1675
  }
1506
1676
  }
1507
1677
  function getOrigin(headers) {
1508
- const host = getHost(headers);
1509
- if (host) {
1510
- return host.indexOf("localhost") !== -1 ? "http://" + host : getProto(headers) + "://" + host;
1678
+ if (process.env.NEXT_PUBLIC_URL) {
1679
+ return process.env.NEXT_PUBLIC_URL;
1511
1680
  } else {
1512
- return process.env.NEXT_PUBLIC_URL || "";
1681
+ const host = getHost(headers);
1682
+ if (host) {
1683
+ return host.indexOf("localhost") !== -1 ? "http://" + host : getProto(headers) + "://" + host;
1684
+ } else {
1685
+ return "";
1686
+ }
1513
1687
  }
1514
1688
  }
1515
1689
 
@@ -1520,22 +1694,7 @@ var RouteStrategy = /* @__PURE__ */ ((RouteStrategy2) => {
1520
1694
  RouteStrategy2["Manual"] = "manual";
1521
1695
  return RouteStrategy2;
1522
1696
  })(RouteStrategy || {});
1523
- var ROUTE_STRATEGY = process.env.ROUTE_STRATEGY || "auto" /* Auto */;
1524
- function getPickedProps(item) {
1525
- const pickedProps = Object.fromEntries(Object.entries(item).filter(([k, v]) => [
1526
- "category",
1527
- "isDefault",
1528
- "media",
1529
- "order",
1530
- "template",
1531
- "updatedAt",
1532
- "useSplat",
1533
- // 'createdAt',
1534
- "updatedAt",
1535
- "_status"
1536
- ].includes(k)));
1537
- return pickedProps;
1538
- }
1697
+ var ROUTE_STRATEGY = process.env.ROUTE_STRATEGY || "manual" /* Manual */;
1539
1698
  function collectRoutes(store, categories, markets, locales, medias) {
1540
1699
  const routes = [];
1541
1700
  if (locales.length > 0 && markets.length > 0) {
@@ -1549,31 +1708,57 @@ function collectRoutes(store, categories, markets, locales, medias) {
1549
1708
  if (Boolean(item.isDefault) === false) {
1550
1709
  slugs.push({ slug: item.slug });
1551
1710
  }
1552
- const defaultLocale2 = locales.find((x) => x.isDefault) || locales[0];
1553
- const defaultMarket2 = markets.find((x) => x.isDefault) || markets[0];
1554
- const defaultMarketLocale = defaultMarket2 && defaultMarket2.defaultLanguage ? asEntityId(defaultMarket2.defaultLanguage) : defaultLocale2.id;
1555
1711
  const isRootCategory = rootCategory && item.category === rootCategory.id && item.isDefault;
1556
1712
  eachMarketLocale(markets, locales, (market, locale, markets2, locales2) => {
1557
1713
  if (hasMarket(item, market)) {
1558
1714
  const title = localize(item.title, locale.id);
1559
1715
  const id = getRouteHref(slugs, market, locale, markets2, locales2);
1560
- const isDefaultRootCategory = isRootCategory && market.id === defaultMarket2.id && locale.id === defaultMarketLocale;
1561
- const pickedProps = getPickedProps(item);
1716
+ const {
1717
+ _status,
1718
+ category,
1719
+ isDefault,
1720
+ media,
1721
+ order,
1722
+ template,
1723
+ updatedAt,
1724
+ useSplat
1725
+ } = item;
1562
1726
  const route = {
1563
- ...pickedProps,
1564
- resolvedCategory: visibleCategory.id,
1565
- id: isDefaultRootCategory ? "/" : id,
1727
+ _status,
1728
+ category,
1729
+ // id: isDefaultRootCategory ? '/' : id,
1730
+ id,
1566
1731
  locale: locale.id,
1567
1732
  market: market.id,
1733
+ media,
1568
1734
  page: item.id,
1735
+ resolvedCategory: visibleCategory.id,
1569
1736
  schema: key,
1570
- title
1737
+ template,
1738
+ title,
1739
+ updatedAt
1571
1740
  };
1741
+ if (isDefault) {
1742
+ route.isDefault = true;
1743
+ }
1744
+ if (isRootCategory) {
1745
+ route.isRoot = true;
1746
+ }
1747
+ const noindex = (item.meta?.robots || "").includes("noindex");
1748
+ if (noindex) {
1749
+ route.noindex = true;
1750
+ }
1751
+ if (order != null) {
1752
+ route.order = order;
1753
+ }
1754
+ if (useSplat) {
1755
+ route.useSplat = true;
1756
+ }
1572
1757
  const mediaId = typeof item.media === "string" ? item.media : void 0;
1573
1758
  if (Array.isArray(medias) && mediaId) {
1574
- const media = item.media && medias.find((x) => x.id === mediaId);
1575
- if (media) {
1576
- route.media = media;
1759
+ const media2 = item.media && medias.find((x) => x.id === mediaId);
1760
+ if (media2) {
1761
+ route.media = media2;
1577
1762
  }
1578
1763
  }
1579
1764
  routes.push(route);
@@ -1653,7 +1838,8 @@ function getRouteHref(segments, market, locale, markets, locales) {
1653
1838
  function hasMarket(item, market) {
1654
1839
  return !item.markets || item.markets.length === 0 || item.markets.includes(market.id);
1655
1840
  }
1656
- export {
1841
+ // Annotate the CommonJS export names for ESM import in node:
1842
+ 0 && (module.exports = {
1657
1843
  ImageStrategy,
1658
1844
  JsonService,
1659
1845
  Logger,
@@ -1788,4 +1974,4 @@ export {
1788
1974
  unknownCaseToPascalCase,
1789
1975
  uuidv4,
1790
1976
  withSchema
1791
- };
1977
+ });