@websolutespa/bom-core 1.7.5 → 1.7.7
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 -0
- package/dist/index.d.ts +57 -12
- package/dist/index.js +60 -2
- package/dist/index.mjs +55 -2
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,18 @@
|
|
|
1
1
|
# @websolutespa/bom-core
|
|
2
2
|
|
|
3
|
+
## 1.7.7
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Modified: Media resolveMediaType
|
|
8
|
+
- Added: isMediaImage, isMediaVideo, isMediaJson, isMediaPdf
|
|
9
|
+
|
|
10
|
+
## 1.7.6
|
|
11
|
+
|
|
12
|
+
### Patch Changes
|
|
13
|
+
|
|
14
|
+
- Added: getProto
|
|
15
|
+
|
|
3
16
|
## 1.7.5
|
|
4
17
|
|
|
5
18
|
### Patch Changes
|
package/dist/index.d.ts
CHANGED
|
@@ -49,6 +49,9 @@ type StateValue = StateValue[] | {
|
|
|
49
49
|
type IPartial<T> = {
|
|
50
50
|
[P in keyof T]?: Partial<T[P]>;
|
|
51
51
|
};
|
|
52
|
+
type DeepPartial<T> = T extends object ? {
|
|
53
|
+
[P in keyof T]?: DeepPartial<T[P]>;
|
|
54
|
+
} : T;
|
|
52
55
|
type IPrettify<T> = {
|
|
53
56
|
[K in keyof T]: T[K];
|
|
54
57
|
} & {};
|
|
@@ -145,20 +148,61 @@ type IFeatureType = {
|
|
|
145
148
|
features?: IFeature[];
|
|
146
149
|
};
|
|
147
150
|
|
|
148
|
-
type IMediaType = 'image' | 'video' | string;
|
|
149
|
-
type
|
|
150
|
-
|
|
151
|
+
type IMediaType = 'image' | 'video' | 'json' | 'pdf' | string;
|
|
152
|
+
type IMediaInfo = {
|
|
153
|
+
id: string;
|
|
151
154
|
alt?: string;
|
|
152
|
-
|
|
153
|
-
mimeType
|
|
154
|
-
|
|
155
|
+
filename: string;
|
|
156
|
+
mimeType: string;
|
|
157
|
+
filesize: number;
|
|
158
|
+
sizes?: Record<string, {
|
|
159
|
+
url: string | null;
|
|
160
|
+
}>;
|
|
161
|
+
createdAt: Date | string;
|
|
162
|
+
updatedAt?: Date | string;
|
|
163
|
+
url: string;
|
|
164
|
+
};
|
|
165
|
+
type IMedia = Record<string, unknown> & Partial<IMediaInfo> & {
|
|
155
166
|
title?: string;
|
|
167
|
+
abstract?: string;
|
|
156
168
|
type: IMediaType;
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
169
|
+
src: string;
|
|
170
|
+
media?: IMedia;
|
|
171
|
+
width?: string | number;
|
|
172
|
+
height?: string | number;
|
|
173
|
+
};
|
|
174
|
+
type IMediaImage = Omit<IMedia, 'type'> & {
|
|
175
|
+
type: 'image';
|
|
160
176
|
};
|
|
161
|
-
|
|
177
|
+
type IMediaVideo = Omit<IMedia, 'type'> & {
|
|
178
|
+
type: 'video';
|
|
179
|
+
};
|
|
180
|
+
type IMediaJson = Omit<IMedia, 'type'> & {
|
|
181
|
+
type: 'json';
|
|
182
|
+
};
|
|
183
|
+
type IMediaPdf = Omit<IMedia, 'type'> & {
|
|
184
|
+
type: 'pdf';
|
|
185
|
+
};
|
|
186
|
+
declare function resolveMediaType(media: {
|
|
187
|
+
type?: string;
|
|
188
|
+
mimeType?: string;
|
|
189
|
+
}): IMediaType;
|
|
190
|
+
declare function isMediaImage(media: {
|
|
191
|
+
type?: string;
|
|
192
|
+
mimeType?: string;
|
|
193
|
+
}): media is IMediaImage;
|
|
194
|
+
declare function isMediaVideo(media: {
|
|
195
|
+
type?: string;
|
|
196
|
+
mimeType?: string;
|
|
197
|
+
}): media is IMediaVideo;
|
|
198
|
+
declare function isMediaJson(media: {
|
|
199
|
+
type?: string;
|
|
200
|
+
mimeType?: string;
|
|
201
|
+
}): media is IMediaJson;
|
|
202
|
+
declare function isMediaPdf(media: {
|
|
203
|
+
type?: string;
|
|
204
|
+
mimeType?: string;
|
|
205
|
+
}): media is IMediaPdf;
|
|
162
206
|
|
|
163
207
|
type IMeta = {
|
|
164
208
|
title?: string;
|
|
@@ -635,7 +679,8 @@ declare function qsDeserializeRaw(query?: string, deserializedParams?: {}): {};
|
|
|
635
679
|
declare function isHeaders(headers?: IncomingHttpHeaders | Headers): headers is Headers;
|
|
636
680
|
declare function isIncomingHttpHeaders(headers?: IncomingHttpHeaders | Headers): headers is IncomingHttpHeaders;
|
|
637
681
|
declare function getHost(headers?: IncomingHttpHeaders | Headers): string | null;
|
|
638
|
-
declare function
|
|
682
|
+
declare function getProto(headers?: IncomingHttpHeaders | Headers): string;
|
|
683
|
+
declare function getOrigin(headers?: IncomingHttpHeaders | Headers): string;
|
|
639
684
|
|
|
640
685
|
declare function collectRoutes(store: IMemoryStore<ICategorized>, categories: ICategory[], markets: IMarket[], locales: ILocale[]): IRoute[];
|
|
641
686
|
declare function eachMarketLocale(markets: IMarket[], locales: ILocale[], callback: (market: IMarket, locale: ILocale, markets: IMarket[], locales: ILocale[]) => void): void;
|
|
@@ -733,4 +778,4 @@ declare function asServerProps(props: any): any;
|
|
|
733
778
|
declare function awaitAll(array: any, callback: (item: any, index: number) => Promise<any>): Promise<any[]>;
|
|
734
779
|
declare function merge(target: any, source: any): any;
|
|
735
780
|
|
|
736
|
-
export { Dynamic, FetchError, FetchRequestOptions, FetchService, FindParams, FindWhereParams, IAction, IAnchor, ICategorized, ICategory, ICategoryItem, IClassName, IClassNameCollection, IClassNameValue, ICollectionDescription, IComponent, IConfig, IConsentPreference, IContextBaseParams, IContextParams, IDecoratedNav, IEndUser, IEntity, IEquatable, IFeature, IFeatureType, ILabel, ILayout, ILegalNotice, ILetter, ILocale, ILocaleId, ILocalizable, ILocalized, ILocalizedString, IMarket, IMedia, IMediaType, IMemoryStore, IMenu, IMenuBase, IMenuCategory, IMenuCustom, IMenuGroup, IMenuHref, IMenuItem, IMenuLink, IMenuPage, IMenuRoute, INamedEntity, IOption, IOverride, IOverrideReturnValue, IOverrideValue, IPackages, IPage, IPageRelation, IPageRelationResult, IPageUnresolvedRelation, IPagedResult, IPaginationResult, IPartial, IPreference, IPrettify, IQuerable, IRedirect, IRoute, IRouteCanonical, IRouteLink, IRouteParams, ISchema, ISerializedCollection, ISerializedStore, IServerSideContext, IServerSideSplatContext, IStaticContext, IStore, ITemplate, ITitledEntity, IUndecoratedMenu, IUndecoratedMenuBase, IUndecoratedMenuCategory, IUndecoratedMenuCustom, IUndecoratedMenuGroup, IUndecoratedMenuItem, IUndecoratedMenuLink, IUndecoratedMenuPage, IUndecoratedNav, Json, JsonService, LiteralUnion, Logger, LoggerLevel, NextApiRequestCookies, Operator, PageProps, Pagination, PreviewData, Primitive, QueryParams, RedirectReason, RouteStrategy, SchemaType, ServerSidePropsContext, StateValue, StaticPropsContext, User, UserRole, UserWithRoles, ValueOf, Where, WhereAndOr, WhereBase, WhereField, asCategoryId, asEquatable, asServerProps, awaitAll, camelToSnakeCase, cloneItem, collectFeatureTypes, collectOptions, collectRoutes, consoleWarn, deepMerge, defaultLocale, defaultMarket, eachCategorized, eachMarketLocale, enumToList, getCategorySegments, getCategorySegmentsByCategory, getClassNames, getCollectionDescription, getEnv, getHost, getIsDevelopment, getIsProduction, getOrigin, getParentCategoriesById, getRootCategory, getRouteHref, httpDelete, httpFetch, httpGet, httpPatch, httpPost, httpPut, isArray, isBrowser, isCategory, isDevelopment, isEntity, isEquatable, isHeaders, isIncomingHttpHeaders, isLocalizedString, isMenuHref, isNotNullString, isObject, isProduction, isRelation, isReservedCollectionDescription, isStage, isUndecoratedMenuCategory, isUndecoratedMenuItem, isUndecoratedMenuPage, isUndecoratedNav, isUnresolvedRelation, isValidCollectionDescription, localize, localizeItem, localizeValue, localizedToString, merge, pascalCaseToCamelCase, pascalCaseToCharCase, pascalCaseToKebabCase, pascalCaseToSnakeCase, qsDeserialize, qsDeserializeRaw, qsSerialize, qsSerializeRaw, resolveMediaType, textToSlug, toCamelCase, toCharCase, toDisplayName, toFindParams, toKebabCase, toPascalCase, toPluralName, toSnakeCase, toTitleCase, toValidCollectionName, unknownCaseToPascalCase, withSchema };
|
|
781
|
+
export { DeepPartial, Dynamic, FetchError, FetchRequestOptions, FetchService, FindParams, FindWhereParams, IAction, IAnchor, ICategorized, ICategory, ICategoryItem, IClassName, IClassNameCollection, IClassNameValue, ICollectionDescription, IComponent, IConfig, IConsentPreference, IContextBaseParams, IContextParams, IDecoratedNav, IEndUser, IEntity, IEquatable, IFeature, IFeatureType, ILabel, ILayout, ILegalNotice, ILetter, ILocale, ILocaleId, ILocalizable, ILocalized, ILocalizedString, IMarket, IMedia, IMediaImage, IMediaInfo, IMediaJson, IMediaPdf, IMediaType, IMediaVideo, IMemoryStore, IMenu, IMenuBase, IMenuCategory, IMenuCustom, IMenuGroup, IMenuHref, IMenuItem, IMenuLink, IMenuPage, IMenuRoute, INamedEntity, IOption, IOverride, IOverrideReturnValue, IOverrideValue, IPackages, IPage, IPageRelation, IPageRelationResult, IPageUnresolvedRelation, IPagedResult, IPaginationResult, IPartial, IPreference, IPrettify, IQuerable, IRedirect, IRoute, IRouteCanonical, IRouteLink, IRouteParams, ISchema, ISerializedCollection, ISerializedStore, IServerSideContext, IServerSideSplatContext, IStaticContext, IStore, ITemplate, ITitledEntity, IUndecoratedMenu, IUndecoratedMenuBase, IUndecoratedMenuCategory, IUndecoratedMenuCustom, IUndecoratedMenuGroup, IUndecoratedMenuItem, IUndecoratedMenuLink, IUndecoratedMenuPage, IUndecoratedNav, Json, JsonService, LiteralUnion, Logger, LoggerLevel, NextApiRequestCookies, Operator, PageProps, Pagination, PreviewData, Primitive, QueryParams, RedirectReason, RouteStrategy, SchemaType, ServerSidePropsContext, StateValue, StaticPropsContext, User, UserRole, UserWithRoles, ValueOf, Where, WhereAndOr, WhereBase, WhereField, asCategoryId, asEquatable, asServerProps, awaitAll, camelToSnakeCase, cloneItem, collectFeatureTypes, collectOptions, collectRoutes, consoleWarn, deepMerge, defaultLocale, defaultMarket, eachCategorized, eachMarketLocale, enumToList, getCategorySegments, getCategorySegmentsByCategory, getClassNames, getCollectionDescription, getEnv, getHost, getIsDevelopment, getIsProduction, getOrigin, getParentCategoriesById, getProto, getRootCategory, getRouteHref, httpDelete, httpFetch, httpGet, httpPatch, httpPost, httpPut, isArray, isBrowser, isCategory, isDevelopment, isEntity, isEquatable, isHeaders, isIncomingHttpHeaders, isLocalizedString, isMediaImage, isMediaJson, isMediaPdf, isMediaVideo, isMenuHref, isNotNullString, isObject, isProduction, isRelation, isReservedCollectionDescription, isStage, isUndecoratedMenuCategory, isUndecoratedMenuItem, isUndecoratedMenuPage, isUndecoratedNav, isUnresolvedRelation, isValidCollectionDescription, localize, localizeItem, localizeValue, localizedToString, merge, pascalCaseToCamelCase, pascalCaseToCharCase, pascalCaseToKebabCase, pascalCaseToSnakeCase, qsDeserialize, qsDeserializeRaw, qsSerialize, qsSerializeRaw, resolveMediaType, textToSlug, toCamelCase, toCharCase, toDisplayName, toFindParams, toKebabCase, toPascalCase, toPluralName, toSnakeCase, toTitleCase, toValidCollectionName, unknownCaseToPascalCase, withSchema };
|
package/dist/index.js
CHANGED
|
@@ -61,6 +61,7 @@ __export(src_exports, {
|
|
|
61
61
|
getIsProduction: () => getIsProduction,
|
|
62
62
|
getOrigin: () => getOrigin,
|
|
63
63
|
getParentCategoriesById: () => getParentCategoriesById,
|
|
64
|
+
getProto: () => getProto,
|
|
64
65
|
getRootCategory: () => getRootCategory,
|
|
65
66
|
getRouteHref: () => getRouteHref,
|
|
66
67
|
httpDelete: () => httpDelete,
|
|
@@ -78,6 +79,10 @@ __export(src_exports, {
|
|
|
78
79
|
isHeaders: () => isHeaders,
|
|
79
80
|
isIncomingHttpHeaders: () => isIncomingHttpHeaders,
|
|
80
81
|
isLocalizedString: () => isLocalizedString,
|
|
82
|
+
isMediaImage: () => isMediaImage,
|
|
83
|
+
isMediaJson: () => isMediaJson,
|
|
84
|
+
isMediaPdf: () => isMediaPdf,
|
|
85
|
+
isMediaVideo: () => isMediaVideo,
|
|
81
86
|
isMenuHref: () => isMenuHref,
|
|
82
87
|
isNotNullString: () => isNotNullString,
|
|
83
88
|
isObject: () => isObject,
|
|
@@ -1067,10 +1072,19 @@ function getHost(headers) {
|
|
|
1067
1072
|
return null;
|
|
1068
1073
|
}
|
|
1069
1074
|
}
|
|
1075
|
+
function getProto(headers) {
|
|
1076
|
+
if (isIncomingHttpHeaders(headers)) {
|
|
1077
|
+
return headers["x-forwarded-proto"] || "https://";
|
|
1078
|
+
} else if (isHeaders(headers)) {
|
|
1079
|
+
return headers.get("X-Forwarded-Proto") || "https://";
|
|
1080
|
+
} else {
|
|
1081
|
+
return "https://";
|
|
1082
|
+
}
|
|
1083
|
+
}
|
|
1070
1084
|
function getOrigin(headers) {
|
|
1071
1085
|
const host = getHost(headers);
|
|
1072
1086
|
if (host) {
|
|
1073
|
-
return host.indexOf("localhost") !== -1 ? "http://" + host :
|
|
1087
|
+
return host.indexOf("localhost") !== -1 ? "http://" + host : getProto(headers) + host;
|
|
1074
1088
|
} else {
|
|
1075
1089
|
return process.env.NEXT_PUBLIC_URL || "";
|
|
1076
1090
|
}
|
|
@@ -1204,7 +1218,46 @@ function textToSlug(title) {
|
|
|
1204
1218
|
|
|
1205
1219
|
// src/types/media.ts
|
|
1206
1220
|
function resolveMediaType(media) {
|
|
1207
|
-
|
|
1221
|
+
if (typeof media.type === "string" && media.type.length > 0) {
|
|
1222
|
+
return media.type;
|
|
1223
|
+
}
|
|
1224
|
+
if (typeof media.mimeType === "string" && media.mimeType.length > 0) {
|
|
1225
|
+
const mime = media.mimeType.split("/");
|
|
1226
|
+
return mime[0] === "application" ? mime[1] : mime[0];
|
|
1227
|
+
}
|
|
1228
|
+
return "unknown";
|
|
1229
|
+
}
|
|
1230
|
+
function isMediaImage(media) {
|
|
1231
|
+
const type = resolveMediaType(media);
|
|
1232
|
+
if (type === "image") {
|
|
1233
|
+
media.type = type;
|
|
1234
|
+
return true;
|
|
1235
|
+
}
|
|
1236
|
+
return false;
|
|
1237
|
+
}
|
|
1238
|
+
function isMediaVideo(media) {
|
|
1239
|
+
const type = resolveMediaType(media);
|
|
1240
|
+
if (type === "video") {
|
|
1241
|
+
media.type = type;
|
|
1242
|
+
return true;
|
|
1243
|
+
}
|
|
1244
|
+
return false;
|
|
1245
|
+
}
|
|
1246
|
+
function isMediaJson(media) {
|
|
1247
|
+
const type = resolveMediaType(media);
|
|
1248
|
+
if (type === "json") {
|
|
1249
|
+
media.type = type;
|
|
1250
|
+
return true;
|
|
1251
|
+
}
|
|
1252
|
+
return false;
|
|
1253
|
+
}
|
|
1254
|
+
function isMediaPdf(media) {
|
|
1255
|
+
const type = resolveMediaType(media);
|
|
1256
|
+
if (type === "pdf") {
|
|
1257
|
+
media.type = type;
|
|
1258
|
+
return true;
|
|
1259
|
+
}
|
|
1260
|
+
return false;
|
|
1208
1261
|
}
|
|
1209
1262
|
|
|
1210
1263
|
// src/types/menu.ts
|
|
@@ -1263,6 +1316,7 @@ var RedirectReason = /* @__PURE__ */ ((RedirectReason2) => {
|
|
|
1263
1316
|
getIsProduction,
|
|
1264
1317
|
getOrigin,
|
|
1265
1318
|
getParentCategoriesById,
|
|
1319
|
+
getProto,
|
|
1266
1320
|
getRootCategory,
|
|
1267
1321
|
getRouteHref,
|
|
1268
1322
|
httpDelete,
|
|
@@ -1280,6 +1334,10 @@ var RedirectReason = /* @__PURE__ */ ((RedirectReason2) => {
|
|
|
1280
1334
|
isHeaders,
|
|
1281
1335
|
isIncomingHttpHeaders,
|
|
1282
1336
|
isLocalizedString,
|
|
1337
|
+
isMediaImage,
|
|
1338
|
+
isMediaJson,
|
|
1339
|
+
isMediaPdf,
|
|
1340
|
+
isMediaVideo,
|
|
1283
1341
|
isMenuHref,
|
|
1284
1342
|
isNotNullString,
|
|
1285
1343
|
isObject,
|
package/dist/index.mjs
CHANGED
|
@@ -944,10 +944,19 @@ function getHost(headers) {
|
|
|
944
944
|
return null;
|
|
945
945
|
}
|
|
946
946
|
}
|
|
947
|
+
function getProto(headers) {
|
|
948
|
+
if (isIncomingHttpHeaders(headers)) {
|
|
949
|
+
return headers["x-forwarded-proto"] || "https://";
|
|
950
|
+
} else if (isHeaders(headers)) {
|
|
951
|
+
return headers.get("X-Forwarded-Proto") || "https://";
|
|
952
|
+
} else {
|
|
953
|
+
return "https://";
|
|
954
|
+
}
|
|
955
|
+
}
|
|
947
956
|
function getOrigin(headers) {
|
|
948
957
|
const host = getHost(headers);
|
|
949
958
|
if (host) {
|
|
950
|
-
return host.indexOf("localhost") !== -1 ? "http://" + host :
|
|
959
|
+
return host.indexOf("localhost") !== -1 ? "http://" + host : getProto(headers) + host;
|
|
951
960
|
} else {
|
|
952
961
|
return process.env.NEXT_PUBLIC_URL || "";
|
|
953
962
|
}
|
|
@@ -1081,7 +1090,46 @@ function textToSlug(title) {
|
|
|
1081
1090
|
|
|
1082
1091
|
// src/types/media.ts
|
|
1083
1092
|
function resolveMediaType(media) {
|
|
1084
|
-
|
|
1093
|
+
if (typeof media.type === "string" && media.type.length > 0) {
|
|
1094
|
+
return media.type;
|
|
1095
|
+
}
|
|
1096
|
+
if (typeof media.mimeType === "string" && media.mimeType.length > 0) {
|
|
1097
|
+
const mime = media.mimeType.split("/");
|
|
1098
|
+
return mime[0] === "application" ? mime[1] : mime[0];
|
|
1099
|
+
}
|
|
1100
|
+
return "unknown";
|
|
1101
|
+
}
|
|
1102
|
+
function isMediaImage(media) {
|
|
1103
|
+
const type = resolveMediaType(media);
|
|
1104
|
+
if (type === "image") {
|
|
1105
|
+
media.type = type;
|
|
1106
|
+
return true;
|
|
1107
|
+
}
|
|
1108
|
+
return false;
|
|
1109
|
+
}
|
|
1110
|
+
function isMediaVideo(media) {
|
|
1111
|
+
const type = resolveMediaType(media);
|
|
1112
|
+
if (type === "video") {
|
|
1113
|
+
media.type = type;
|
|
1114
|
+
return true;
|
|
1115
|
+
}
|
|
1116
|
+
return false;
|
|
1117
|
+
}
|
|
1118
|
+
function isMediaJson(media) {
|
|
1119
|
+
const type = resolveMediaType(media);
|
|
1120
|
+
if (type === "json") {
|
|
1121
|
+
media.type = type;
|
|
1122
|
+
return true;
|
|
1123
|
+
}
|
|
1124
|
+
return false;
|
|
1125
|
+
}
|
|
1126
|
+
function isMediaPdf(media) {
|
|
1127
|
+
const type = resolveMediaType(media);
|
|
1128
|
+
if (type === "pdf") {
|
|
1129
|
+
media.type = type;
|
|
1130
|
+
return true;
|
|
1131
|
+
}
|
|
1132
|
+
return false;
|
|
1085
1133
|
}
|
|
1086
1134
|
|
|
1087
1135
|
// src/types/menu.ts
|
|
@@ -1139,6 +1187,7 @@ export {
|
|
|
1139
1187
|
getIsProduction,
|
|
1140
1188
|
getOrigin,
|
|
1141
1189
|
getParentCategoriesById,
|
|
1190
|
+
getProto,
|
|
1142
1191
|
getRootCategory,
|
|
1143
1192
|
getRouteHref,
|
|
1144
1193
|
httpDelete,
|
|
@@ -1156,6 +1205,10 @@ export {
|
|
|
1156
1205
|
isHeaders,
|
|
1157
1206
|
isIncomingHttpHeaders,
|
|
1158
1207
|
isLocalizedString,
|
|
1208
|
+
isMediaImage,
|
|
1209
|
+
isMediaJson,
|
|
1210
|
+
isMediaPdf,
|
|
1211
|
+
isMediaVideo,
|
|
1159
1212
|
isMenuHref,
|
|
1160
1213
|
isNotNullString,
|
|
1161
1214
|
isObject,
|