b2b-platform-utils 1.1.39 → 1.1.41

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/errorsMap.js CHANGED
@@ -545,6 +545,24 @@ const STATIC_ERRORS = [
545
545
  httpCode: 422,
546
546
  description: "Balance set target bucket is missing or invalid.",
547
547
  },
548
+ {
549
+ errorCode: 1089,
550
+ errorKey: "pageSeoNotFound",
551
+ httpCode: 404,
552
+ description: "Page SEO was not found.",
553
+ },
554
+ {
555
+ errorCode: 1090,
556
+ errorKey: "pageSeoAttributesNotFound",
557
+ httpCode: 404,
558
+ description: "Page SEO attributes were not found.",
559
+ },
560
+ {
561
+ errorCode: 1091,
562
+ errorKey: "pageSeoAlreadyExists",
563
+ httpCode: 422,
564
+ description: "Page SEO already exists.",
565
+ },
548
566
  ];
549
567
 
550
568
  const STATIC_BY_KEY = Object.fromEntries(
package/optimizeMedia.js CHANGED
@@ -45,4 +45,45 @@ async function saveGameImageBufferWEBP(fileDataBuffer, quality = 80, maxWidth =
45
45
  .toBuffer();
46
46
  }
47
47
 
48
- module.exports = { optimizeImageBufferWEBP, saveGameImageBufferWEBP };
48
+ /**
49
+ * Buffer to WebP for game images: auto-rotate; optional resize when `width` and/or `height` is set (Sharp options).
50
+ * @param {Buffer} fileDataBuffer
51
+ * @param {object} [options]
52
+ * @returns {Promise<Buffer>}
53
+ */
54
+ async function saveGameImageBufferWEBPWithOptions(fileDataBuffer, options = {}) {
55
+ const {
56
+ quality = 80,
57
+ width,
58
+ height,
59
+ fit = 'inside',
60
+ withoutEnlargement = true,
61
+ effort = 5,
62
+ smartSubsample = true
63
+ } = options;
64
+
65
+ let pipeline = sharp(fileDataBuffer).rotate();
66
+
67
+ if (width != null || height != null) {
68
+ pipeline = pipeline.resize({
69
+ width,
70
+ height,
71
+ fit,
72
+ withoutEnlargement
73
+ });
74
+ }
75
+
76
+ return pipeline
77
+ .webp({
78
+ quality,
79
+ effort,
80
+ smartSubsample
81
+ })
82
+ .toBuffer();
83
+ }
84
+
85
+ module.exports = {
86
+ optimizeImageBufferWEBP,
87
+ saveGameImageBufferWEBP,
88
+ saveGameImageBufferWEBPWithOptions
89
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "b2b-platform-utils",
3
- "version": "1.1.39",
3
+ "version": "1.1.41",
4
4
  "description": "Shared utilities for Node.js microservices: errors map, local cache, logger, numbers, dates, filesystem, media optimization, paginator, slugger, crypto wrapper, sanitize HTML, sorting.",
5
5
  "type": "commonjs",
6
6
  "license": "KingSizer",