@oondemand/oon-core-back 0.3.66 → 0.3.67

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@oondemand/oon-core-back",
3
- "version": "0.3.66",
3
+ "version": "0.3.67",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "git+https://github.com/oondemand/oon-platform.git",
@@ -13,6 +13,21 @@ function truncate(value, limit) {
13
13
  return `${value.slice(0, limit)}…[truncado:${value.length - limit}]`;
14
14
  }
15
15
 
16
+ function binarySummary(value) {
17
+ const size = Number(value?.byteLength ?? value?.length ?? 0);
18
+ const type = value?.constructor?.name || "Binary";
19
+ return `[${type}:${size} bytes]`;
20
+ }
21
+
22
+ function bsonObjectId(value) {
23
+ if (!value || typeof value !== "object") return null;
24
+ const isObjectId = value._bsontype === "ObjectId" || value.constructor?.name === "ObjectId";
25
+ if (!isObjectId) return null;
26
+ if (typeof value.toHexString === "function") return value.toHexString();
27
+ const text = String(value);
28
+ return /^[a-f\d]{24}$/i.test(text) ? text : null;
29
+ }
30
+
16
31
  function sanitizeIntegrationValue(value, options = {}, state = { depth: 0, seen: new WeakSet() }) {
17
32
  const config = { ...DEFAULTS, ...options };
18
33
  if (value == null || typeof value === "boolean" || typeof value === "number") return value;
@@ -28,6 +43,12 @@ function sanitizeIntegrationValue(value, options = {}, state = { depth: 0, seen:
28
43
  };
29
44
  }
30
45
  if (typeof value !== "object") return truncate(String(value), config.maxStringLength);
46
+
47
+ const objectId = bsonObjectId(value);
48
+ if (objectId) return objectId;
49
+ if (Buffer.isBuffer(value) || ArrayBuffer.isView(value)) return binarySummary(value);
50
+ if (value instanceof ArrayBuffer) return binarySummary(value);
51
+
31
52
  if (state.depth >= config.maxDepth) return "[limite-de-profundidade]";
32
53
  if (state.seen.has(value)) return "[referência-circular]";
33
54
  state.seen.add(value);