@websolutespa/bom-core 1.7.6 → 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 CHANGED
@@ -1,5 +1,12 @@
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
+
3
10
  ## 1.7.6
4
11
 
5
12
  ### Patch Changes
package/dist/index.d.ts CHANGED
@@ -148,21 +148,61 @@ type IFeatureType = {
148
148
  features?: IFeature[];
149
149
  };
150
150
 
151
- type IMediaType = 'image' | 'video' | string;
152
- type IMedia = Record<string, unknown> & {
153
- id?: string;
154
- abstract?: string;
151
+ type IMediaType = 'image' | 'video' | 'json' | 'pdf' | string;
152
+ type IMediaInfo = {
153
+ id: string;
155
154
  alt?: string;
156
- media?: IMedia;
157
- mimeType?: string;
158
- src: string;
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> & {
159
166
  title?: string;
167
+ abstract?: string;
160
168
  type: IMediaType;
161
- url?: string;
162
- width?: number;
163
- height?: number;
169
+ src: string;
170
+ media?: IMedia;
171
+ width?: string | number;
172
+ height?: string | number;
164
173
  };
165
- declare function resolveMediaType(media: IMedia): IMediaType;
174
+ type IMediaImage = Omit<IMedia, 'type'> & {
175
+ type: 'image';
176
+ };
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;
166
206
 
167
207
  type IMeta = {
168
208
  title?: string;
@@ -738,4 +778,4 @@ declare function asServerProps(props: any): any;
738
778
  declare function awaitAll(array: any, callback: (item: any, index: number) => Promise<any>): Promise<any[]>;
739
779
  declare function merge(target: any, source: any): any;
740
780
 
741
- 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, 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, getProto, 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
@@ -79,6 +79,10 @@ __export(src_exports, {
79
79
  isHeaders: () => isHeaders,
80
80
  isIncomingHttpHeaders: () => isIncomingHttpHeaders,
81
81
  isLocalizedString: () => isLocalizedString,
82
+ isMediaImage: () => isMediaImage,
83
+ isMediaJson: () => isMediaJson,
84
+ isMediaPdf: () => isMediaPdf,
85
+ isMediaVideo: () => isMediaVideo,
82
86
  isMenuHref: () => isMenuHref,
83
87
  isNotNullString: () => isNotNullString,
84
88
  isObject: () => isObject,
@@ -1214,7 +1218,46 @@ function textToSlug(title) {
1214
1218
 
1215
1219
  // src/types/media.ts
1216
1220
  function resolveMediaType(media) {
1217
- return media.type || (media.mimeType ? media.mimeType.split("/")[0] : "image");
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;
1218
1261
  }
1219
1262
 
1220
1263
  // src/types/menu.ts
@@ -1291,6 +1334,10 @@ var RedirectReason = /* @__PURE__ */ ((RedirectReason2) => {
1291
1334
  isHeaders,
1292
1335
  isIncomingHttpHeaders,
1293
1336
  isLocalizedString,
1337
+ isMediaImage,
1338
+ isMediaJson,
1339
+ isMediaPdf,
1340
+ isMediaVideo,
1294
1341
  isMenuHref,
1295
1342
  isNotNullString,
1296
1343
  isObject,
package/dist/index.mjs CHANGED
@@ -1090,7 +1090,46 @@ function textToSlug(title) {
1090
1090
 
1091
1091
  // src/types/media.ts
1092
1092
  function resolveMediaType(media) {
1093
- return media.type || (media.mimeType ? media.mimeType.split("/")[0] : "image");
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;
1094
1133
  }
1095
1134
 
1096
1135
  // src/types/menu.ts
@@ -1166,6 +1205,10 @@ export {
1166
1205
  isHeaders,
1167
1206
  isIncomingHttpHeaders,
1168
1207
  isLocalizedString,
1208
+ isMediaImage,
1209
+ isMediaJson,
1210
+ isMediaPdf,
1211
+ isMediaVideo,
1169
1212
  isMenuHref,
1170
1213
  isNotNullString,
1171
1214
  isObject,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@websolutespa/bom-core",
3
- "version": "1.7.6",
3
+ "version": "1.7.7",
4
4
  "description": "Core module of the BOM Repository",
5
5
  "keywords": [
6
6
  "bom",