@websolutespa/bom-core 1.8.22 → 1.8.24
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 +13 -1
- package/dist/index.d.ts +80 -42
- package/dist/index.js +48 -28
- package/dist/index.mjs +48 -28
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,10 +1,22 @@
|
|
|
1
1
|
# @websolutespa/bom-core
|
|
2
2
|
|
|
3
|
+
## 1.8.24
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Added: IApp global
|
|
8
|
+
|
|
9
|
+
## 1.8.23
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- 0c7f05f: Modified: IRoute isRoot noindex, routeService
|
|
14
|
+
|
|
3
15
|
## 1.8.22
|
|
4
16
|
|
|
5
17
|
### Patch Changes
|
|
6
18
|
|
|
7
|
-
- Fixing: JsonService
|
|
19
|
+
- Fixing: JsonService whereItem\_ unresolved relations
|
|
8
20
|
|
|
9
21
|
## 1.8.21
|
|
10
22
|
|
package/dist/index.d.ts
CHANGED
|
@@ -132,45 +132,6 @@ type IAnchor = {
|
|
|
132
132
|
title: string;
|
|
133
133
|
};
|
|
134
134
|
|
|
135
|
-
type IEquatable = number | string;
|
|
136
|
-
type SchemaType = string;
|
|
137
|
-
type ISchema = {
|
|
138
|
-
id: IEquatable;
|
|
139
|
-
schema?: string;
|
|
140
|
-
};
|
|
141
|
-
type IEntity = ISchema & Record<string, unknown>;
|
|
142
|
-
type INamedEntity = IEntity & {
|
|
143
|
-
name: ILocalizable;
|
|
144
|
-
};
|
|
145
|
-
type ITitledEntity = IEntity & {
|
|
146
|
-
title: ILocalizable;
|
|
147
|
-
};
|
|
148
|
-
type IOption = Record<string, any> & {
|
|
149
|
-
id: IEquatable;
|
|
150
|
-
name: string;
|
|
151
|
-
};
|
|
152
|
-
type IFeature = Record<string, any> & {
|
|
153
|
-
id: IEquatable;
|
|
154
|
-
title: string;
|
|
155
|
-
};
|
|
156
|
-
type IFeatureType = IEntity & {
|
|
157
|
-
id: string;
|
|
158
|
-
title: string;
|
|
159
|
-
mode: string;
|
|
160
|
-
features: IFeature[];
|
|
161
|
-
};
|
|
162
|
-
|
|
163
|
-
type Headings = 'h1' | 'h2' | 'h3' | 'h4' | 'h5' | 'h6';
|
|
164
|
-
|
|
165
|
-
type IComponent = {
|
|
166
|
-
id?: IEquatable;
|
|
167
|
-
blockType?: string;
|
|
168
|
-
schema?: string;
|
|
169
|
-
anchor?: IAnchor;
|
|
170
|
-
seoWeight?: Headings;
|
|
171
|
-
[key: string]: unknown;
|
|
172
|
-
};
|
|
173
|
-
|
|
174
135
|
type IMediaType = 'image' | 'video' | 'json' | 'pdf' | string;
|
|
175
136
|
type IMediaInfo = {
|
|
176
137
|
id: string;
|
|
@@ -227,6 +188,68 @@ declare function isMediaPdf(media: {
|
|
|
227
188
|
}): media is IMediaPdf;
|
|
228
189
|
declare function isMedia(item: unknown): item is IMedia;
|
|
229
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
|
+
|
|
230
253
|
type IMeta = {
|
|
231
254
|
title?: string;
|
|
232
255
|
description?: string;
|
|
@@ -347,14 +370,16 @@ type IMarket = IEntity & {
|
|
|
347
370
|
|
|
348
371
|
type IRoute = {
|
|
349
372
|
category: IEquatable;
|
|
350
|
-
resolvedCategory: IEquatable;
|
|
351
373
|
id: string;
|
|
352
374
|
isDefault?: boolean;
|
|
375
|
+
isRoot?: boolean;
|
|
353
376
|
locale: string;
|
|
354
377
|
market: string;
|
|
355
378
|
media?: IMedia;
|
|
379
|
+
noindex?: boolean;
|
|
356
380
|
order?: number;
|
|
357
381
|
page: IEquatable;
|
|
382
|
+
resolvedCategory: IEquatable;
|
|
358
383
|
schema: string;
|
|
359
384
|
template?: string;
|
|
360
385
|
title: string;
|
|
@@ -550,12 +575,13 @@ type IUndecoratedMenu = IEntity & {
|
|
|
550
575
|
items: IUndecoratedMenuItem[];
|
|
551
576
|
};
|
|
552
577
|
|
|
553
|
-
type ILayout = {
|
|
578
|
+
type ILayout<T extends IAppExtended = IAppExtended> = {
|
|
554
579
|
labels: ILabel[];
|
|
555
580
|
locale: string;
|
|
556
581
|
locales: ILocale[];
|
|
557
582
|
market: string;
|
|
558
583
|
markets: IMarket[];
|
|
584
|
+
app: IPrettify<IApp<T>>;
|
|
559
585
|
menu: Record<string, ILocalizedMenu>;
|
|
560
586
|
topLevelHrefs: Record<string, string>;
|
|
561
587
|
topLevelRoutes: Record<string, IRouteLink>;
|
|
@@ -619,11 +645,19 @@ type QueryParams = {
|
|
|
619
645
|
sort?: string;
|
|
620
646
|
where?: Where;
|
|
621
647
|
};
|
|
648
|
+
type GlobalQueryParams = {
|
|
649
|
+
depth?: number;
|
|
650
|
+
draft?: boolean;
|
|
651
|
+
locale?: string;
|
|
652
|
+
market?: string;
|
|
653
|
+
richText?: boolean;
|
|
654
|
+
};
|
|
622
655
|
|
|
623
656
|
type IPagedResult<T extends IEntity = IEntity> = {
|
|
624
657
|
docs: T[];
|
|
625
658
|
} & Pagination;
|
|
626
659
|
type IQuerable<T extends IEntity = IEntity> = {
|
|
660
|
+
findGlobal<B extends T = T>(params?: GlobalQueryParams, token?: string): Promise<B | undefined>;
|
|
627
661
|
findOne<B extends T = T>(id: IEquatable, params?: QueryParams, token?: string): Promise<B | undefined>;
|
|
628
662
|
findMany<B extends T = T>(params?: QueryParams, token?: string): Promise<B[]>;
|
|
629
663
|
findPaged<B extends T = T>(params?: QueryParams, token?: string): Promise<IPagedResult<B>>;
|
|
@@ -879,6 +913,7 @@ declare class JsonService<T extends IEntity = IEntity> implements IQuerable<T> {
|
|
|
879
913
|
items: T[];
|
|
880
914
|
constructor(items: T[]);
|
|
881
915
|
getItems<B extends T = T>(): Promise<B[]>;
|
|
916
|
+
findGlobal<B extends T = T>(params?: GlobalQueryParams): Promise<B | undefined>;
|
|
882
917
|
findOne<B extends T = T>(id: IEquatable, params?: QueryParams): Promise<B | undefined>;
|
|
883
918
|
findMany<B extends T = T>(params?: QueryParams): Promise<B[]>;
|
|
884
919
|
findPaged<B extends T = T>(params?: QueryParams): Promise<IPagedResult<B>>;
|
|
@@ -1052,6 +1087,9 @@ declare function getOrigin(headers?: IncomingHttpHeaders | Headers): string;
|
|
|
1052
1087
|
|
|
1053
1088
|
/**
|
|
1054
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.
|
|
1055
1093
|
*/
|
|
1056
1094
|
declare enum RouteStrategy {
|
|
1057
1095
|
Auto = "auto",
|
|
@@ -1353,4 +1391,4 @@ declare function asServerProps(props: any): any;
|
|
|
1353
1391
|
declare function awaitAll(array: any, callback: (item: any, index: number) => Promise<any>): Promise<any[]>;
|
|
1354
1392
|
declare function merge(target: any, source: any): any;
|
|
1355
1393
|
|
|
1356
|
-
export { DeepPartial, Dynamic, FetchError, FetchRequestOptions, FetchService, FindParams, FindWhereParams, Headings, IAction, IActionEmailData, IAnchor, 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 };
|
|
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
|
@@ -998,6 +998,15 @@ var JsonService = class {
|
|
|
998
998
|
async getItems() {
|
|
999
999
|
return this.items;
|
|
1000
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
|
+
}
|
|
1001
1010
|
async findOne(id, params = {}) {
|
|
1002
1011
|
let items = await this.getItems();
|
|
1003
1012
|
params.where = params.where || {};
|
|
@@ -1681,22 +1690,7 @@ var RouteStrategy = /* @__PURE__ */ ((RouteStrategy2) => {
|
|
|
1681
1690
|
RouteStrategy2["Manual"] = "manual";
|
|
1682
1691
|
return RouteStrategy2;
|
|
1683
1692
|
})(RouteStrategy || {});
|
|
1684
|
-
var ROUTE_STRATEGY = process.env.ROUTE_STRATEGY || "
|
|
1685
|
-
function getPickedProps(item) {
|
|
1686
|
-
const pickedProps = Object.fromEntries(Object.entries(item).filter(([k, v]) => [
|
|
1687
|
-
"category",
|
|
1688
|
-
"isDefault",
|
|
1689
|
-
"media",
|
|
1690
|
-
"order",
|
|
1691
|
-
"template",
|
|
1692
|
-
"updatedAt",
|
|
1693
|
-
"useSplat",
|
|
1694
|
-
// 'createdAt',
|
|
1695
|
-
"updatedAt",
|
|
1696
|
-
"_status"
|
|
1697
|
-
].includes(k)));
|
|
1698
|
-
return pickedProps;
|
|
1699
|
-
}
|
|
1693
|
+
var ROUTE_STRATEGY = process.env.ROUTE_STRATEGY || "manual" /* Manual */;
|
|
1700
1694
|
function collectRoutes(store, categories, markets, locales, medias) {
|
|
1701
1695
|
const routes = [];
|
|
1702
1696
|
if (locales.length > 0 && markets.length > 0) {
|
|
@@ -1710,31 +1704,57 @@ function collectRoutes(store, categories, markets, locales, medias) {
|
|
|
1710
1704
|
if (Boolean(item.isDefault) === false) {
|
|
1711
1705
|
slugs.push({ slug: item.slug });
|
|
1712
1706
|
}
|
|
1713
|
-
const defaultLocale2 = locales.find((x) => x.isDefault) || locales[0];
|
|
1714
|
-
const defaultMarket2 = markets.find((x) => x.isDefault) || markets[0];
|
|
1715
|
-
const defaultMarketLocale = defaultMarket2 && defaultMarket2.defaultLanguage ? asEntityId(defaultMarket2.defaultLanguage) : defaultLocale2.id;
|
|
1716
1707
|
const isRootCategory = rootCategory && item.category === rootCategory.id && item.isDefault;
|
|
1717
1708
|
eachMarketLocale(markets, locales, (market, locale, markets2, locales2) => {
|
|
1718
1709
|
if (hasMarket(item, market)) {
|
|
1719
1710
|
const title = localize(item.title, locale.id);
|
|
1720
1711
|
const id = getRouteHref(slugs, market, locale, markets2, locales2);
|
|
1721
|
-
const
|
|
1722
|
-
|
|
1712
|
+
const {
|
|
1713
|
+
_status,
|
|
1714
|
+
category,
|
|
1715
|
+
isDefault,
|
|
1716
|
+
media,
|
|
1717
|
+
order,
|
|
1718
|
+
template,
|
|
1719
|
+
updatedAt,
|
|
1720
|
+
useSplat
|
|
1721
|
+
} = item;
|
|
1723
1722
|
const route = {
|
|
1724
|
-
|
|
1725
|
-
|
|
1726
|
-
id: isDefaultRootCategory ?
|
|
1723
|
+
_status,
|
|
1724
|
+
category,
|
|
1725
|
+
// id: isDefaultRootCategory ? '/' : id,
|
|
1726
|
+
id,
|
|
1727
1727
|
locale: locale.id,
|
|
1728
1728
|
market: market.id,
|
|
1729
|
+
media,
|
|
1729
1730
|
page: item.id,
|
|
1731
|
+
resolvedCategory: visibleCategory.id,
|
|
1730
1732
|
schema: key,
|
|
1731
|
-
|
|
1733
|
+
template,
|
|
1734
|
+
title,
|
|
1735
|
+
updatedAt
|
|
1732
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
|
+
}
|
|
1733
1753
|
const mediaId = typeof item.media === "string" ? item.media : void 0;
|
|
1734
1754
|
if (Array.isArray(medias) && mediaId) {
|
|
1735
|
-
const
|
|
1736
|
-
if (
|
|
1737
|
-
route.media =
|
|
1755
|
+
const media2 = item.media && medias.find((x) => x.id === mediaId);
|
|
1756
|
+
if (media2) {
|
|
1757
|
+
route.media = media2;
|
|
1738
1758
|
}
|
|
1739
1759
|
}
|
|
1740
1760
|
routes.push(route);
|
package/dist/index.mjs
CHANGED
|
@@ -829,6 +829,15 @@ var JsonService = class {
|
|
|
829
829
|
async getItems() {
|
|
830
830
|
return this.items;
|
|
831
831
|
}
|
|
832
|
+
async findGlobal(params = {}) {
|
|
833
|
+
const items = await this.getItems();
|
|
834
|
+
if (items.length > 0) {
|
|
835
|
+
return await this.decorateOne_(items[0], params);
|
|
836
|
+
} else {
|
|
837
|
+
console.log("JsonService.findGlobal.notfound", params);
|
|
838
|
+
return void 0;
|
|
839
|
+
}
|
|
840
|
+
}
|
|
832
841
|
async findOne(id, params = {}) {
|
|
833
842
|
let items = await this.getItems();
|
|
834
843
|
params.where = params.where || {};
|
|
@@ -1512,22 +1521,7 @@ var RouteStrategy = /* @__PURE__ */ ((RouteStrategy2) => {
|
|
|
1512
1521
|
RouteStrategy2["Manual"] = "manual";
|
|
1513
1522
|
return RouteStrategy2;
|
|
1514
1523
|
})(RouteStrategy || {});
|
|
1515
|
-
var ROUTE_STRATEGY = process.env.ROUTE_STRATEGY || "
|
|
1516
|
-
function getPickedProps(item) {
|
|
1517
|
-
const pickedProps = Object.fromEntries(Object.entries(item).filter(([k, v]) => [
|
|
1518
|
-
"category",
|
|
1519
|
-
"isDefault",
|
|
1520
|
-
"media",
|
|
1521
|
-
"order",
|
|
1522
|
-
"template",
|
|
1523
|
-
"updatedAt",
|
|
1524
|
-
"useSplat",
|
|
1525
|
-
// 'createdAt',
|
|
1526
|
-
"updatedAt",
|
|
1527
|
-
"_status"
|
|
1528
|
-
].includes(k)));
|
|
1529
|
-
return pickedProps;
|
|
1530
|
-
}
|
|
1524
|
+
var ROUTE_STRATEGY = process.env.ROUTE_STRATEGY || "manual" /* Manual */;
|
|
1531
1525
|
function collectRoutes(store, categories, markets, locales, medias) {
|
|
1532
1526
|
const routes = [];
|
|
1533
1527
|
if (locales.length > 0 && markets.length > 0) {
|
|
@@ -1541,31 +1535,57 @@ function collectRoutes(store, categories, markets, locales, medias) {
|
|
|
1541
1535
|
if (Boolean(item.isDefault) === false) {
|
|
1542
1536
|
slugs.push({ slug: item.slug });
|
|
1543
1537
|
}
|
|
1544
|
-
const defaultLocale2 = locales.find((x) => x.isDefault) || locales[0];
|
|
1545
|
-
const defaultMarket2 = markets.find((x) => x.isDefault) || markets[0];
|
|
1546
|
-
const defaultMarketLocale = defaultMarket2 && defaultMarket2.defaultLanguage ? asEntityId(defaultMarket2.defaultLanguage) : defaultLocale2.id;
|
|
1547
1538
|
const isRootCategory = rootCategory && item.category === rootCategory.id && item.isDefault;
|
|
1548
1539
|
eachMarketLocale(markets, locales, (market, locale, markets2, locales2) => {
|
|
1549
1540
|
if (hasMarket(item, market)) {
|
|
1550
1541
|
const title = localize(item.title, locale.id);
|
|
1551
1542
|
const id = getRouteHref(slugs, market, locale, markets2, locales2);
|
|
1552
|
-
const
|
|
1553
|
-
|
|
1543
|
+
const {
|
|
1544
|
+
_status,
|
|
1545
|
+
category,
|
|
1546
|
+
isDefault,
|
|
1547
|
+
media,
|
|
1548
|
+
order,
|
|
1549
|
+
template,
|
|
1550
|
+
updatedAt,
|
|
1551
|
+
useSplat
|
|
1552
|
+
} = item;
|
|
1554
1553
|
const route = {
|
|
1555
|
-
|
|
1556
|
-
|
|
1557
|
-
id: isDefaultRootCategory ?
|
|
1554
|
+
_status,
|
|
1555
|
+
category,
|
|
1556
|
+
// id: isDefaultRootCategory ? '/' : id,
|
|
1557
|
+
id,
|
|
1558
1558
|
locale: locale.id,
|
|
1559
1559
|
market: market.id,
|
|
1560
|
+
media,
|
|
1560
1561
|
page: item.id,
|
|
1562
|
+
resolvedCategory: visibleCategory.id,
|
|
1561
1563
|
schema: key,
|
|
1562
|
-
|
|
1564
|
+
template,
|
|
1565
|
+
title,
|
|
1566
|
+
updatedAt
|
|
1563
1567
|
};
|
|
1568
|
+
if (isDefault) {
|
|
1569
|
+
route.isDefault = true;
|
|
1570
|
+
}
|
|
1571
|
+
if (isRootCategory) {
|
|
1572
|
+
route.isRoot = true;
|
|
1573
|
+
}
|
|
1574
|
+
const noindex = (item.meta?.robots || "").includes("noindex");
|
|
1575
|
+
if (noindex) {
|
|
1576
|
+
route.noindex = true;
|
|
1577
|
+
}
|
|
1578
|
+
if (order != null) {
|
|
1579
|
+
route.order = order;
|
|
1580
|
+
}
|
|
1581
|
+
if (useSplat) {
|
|
1582
|
+
route.useSplat = true;
|
|
1583
|
+
}
|
|
1564
1584
|
const mediaId = typeof item.media === "string" ? item.media : void 0;
|
|
1565
1585
|
if (Array.isArray(medias) && mediaId) {
|
|
1566
|
-
const
|
|
1567
|
-
if (
|
|
1568
|
-
route.media =
|
|
1586
|
+
const media2 = item.media && medias.find((x) => x.id === mediaId);
|
|
1587
|
+
if (media2) {
|
|
1588
|
+
route.media = media2;
|
|
1569
1589
|
}
|
|
1570
1590
|
}
|
|
1571
1591
|
routes.push(route);
|