@websolutespa/bom-core 1.8.23 → 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 +6 -0
- package/dist/index.d.ts +74 -41
- package/dist/index.js +9 -0
- package/dist/index.mjs +9 -0
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
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;
|
|
@@ -552,12 +575,13 @@ type IUndecoratedMenu = IEntity & {
|
|
|
552
575
|
items: IUndecoratedMenuItem[];
|
|
553
576
|
};
|
|
554
577
|
|
|
555
|
-
type ILayout = {
|
|
578
|
+
type ILayout<T extends IAppExtended = IAppExtended> = {
|
|
556
579
|
labels: ILabel[];
|
|
557
580
|
locale: string;
|
|
558
581
|
locales: ILocale[];
|
|
559
582
|
market: string;
|
|
560
583
|
markets: IMarket[];
|
|
584
|
+
app: IPrettify<IApp<T>>;
|
|
561
585
|
menu: Record<string, ILocalizedMenu>;
|
|
562
586
|
topLevelHrefs: Record<string, string>;
|
|
563
587
|
topLevelRoutes: Record<string, IRouteLink>;
|
|
@@ -621,11 +645,19 @@ type QueryParams = {
|
|
|
621
645
|
sort?: string;
|
|
622
646
|
where?: Where;
|
|
623
647
|
};
|
|
648
|
+
type GlobalQueryParams = {
|
|
649
|
+
depth?: number;
|
|
650
|
+
draft?: boolean;
|
|
651
|
+
locale?: string;
|
|
652
|
+
market?: string;
|
|
653
|
+
richText?: boolean;
|
|
654
|
+
};
|
|
624
655
|
|
|
625
656
|
type IPagedResult<T extends IEntity = IEntity> = {
|
|
626
657
|
docs: T[];
|
|
627
658
|
} & Pagination;
|
|
628
659
|
type IQuerable<T extends IEntity = IEntity> = {
|
|
660
|
+
findGlobal<B extends T = T>(params?: GlobalQueryParams, token?: string): Promise<B | undefined>;
|
|
629
661
|
findOne<B extends T = T>(id: IEquatable, params?: QueryParams, token?: string): Promise<B | undefined>;
|
|
630
662
|
findMany<B extends T = T>(params?: QueryParams, token?: string): Promise<B[]>;
|
|
631
663
|
findPaged<B extends T = T>(params?: QueryParams, token?: string): Promise<IPagedResult<B>>;
|
|
@@ -881,6 +913,7 @@ declare class JsonService<T extends IEntity = IEntity> implements IQuerable<T> {
|
|
|
881
913
|
items: T[];
|
|
882
914
|
constructor(items: T[]);
|
|
883
915
|
getItems<B extends T = T>(): Promise<B[]>;
|
|
916
|
+
findGlobal<B extends T = T>(params?: GlobalQueryParams): Promise<B | undefined>;
|
|
884
917
|
findOne<B extends T = T>(id: IEquatable, params?: QueryParams): Promise<B | undefined>;
|
|
885
918
|
findMany<B extends T = T>(params?: QueryParams): Promise<B[]>;
|
|
886
919
|
findPaged<B extends T = T>(params?: QueryParams): Promise<IPagedResult<B>>;
|
|
@@ -1358,4 +1391,4 @@ declare function asServerProps(props: any): any;
|
|
|
1358
1391
|
declare function awaitAll(array: any, callback: (item: any, index: number) => Promise<any>): Promise<any[]>;
|
|
1359
1392
|
declare function merge(target: any, source: any): any;
|
|
1360
1393
|
|
|
1361
|
-
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 || {};
|
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 || {};
|