@agentmark-ai/shared-utils 0.3.3 → 0.4.0
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/dist/index.d.mts +40 -1
- package/dist/index.d.ts +40 -1
- package/dist/index.js +34 -0
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +32 -0
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -2255,6 +2255,36 @@ function normalizeOtlpSpans(resourceSpans) {
|
|
|
2255
2255
|
}
|
|
2256
2256
|
return normalizedSpans;
|
|
2257
2257
|
}
|
|
2258
|
+
|
|
2259
|
+
// src/dataset-item-name.ts
|
|
2260
|
+
import { createHash } from "crypto";
|
|
2261
|
+
function computeDatasetItemName(input, fallbackIndex) {
|
|
2262
|
+
if (input === void 0 || input === null) {
|
|
2263
|
+
return String(fallbackIndex);
|
|
2264
|
+
}
|
|
2265
|
+
const canonical = canonicalJsonStringify(input);
|
|
2266
|
+
return createHash("md5").update(canonical).digest("hex").slice(0, 12);
|
|
2267
|
+
}
|
|
2268
|
+
function canonicalJsonStringify(value) {
|
|
2269
|
+
if (value === null) return "null";
|
|
2270
|
+
if (value === void 0) return JSON.stringify(String(void 0));
|
|
2271
|
+
const t = typeof value;
|
|
2272
|
+
if (t === "string" || t === "number" || t === "boolean") {
|
|
2273
|
+
return JSON.stringify(value);
|
|
2274
|
+
}
|
|
2275
|
+
if (t === "bigint" || t === "function" || t === "symbol") {
|
|
2276
|
+
return JSON.stringify(String(value));
|
|
2277
|
+
}
|
|
2278
|
+
if (Array.isArray(value)) {
|
|
2279
|
+
return "[" + value.map(canonicalJsonStringify).join(",") + "]";
|
|
2280
|
+
}
|
|
2281
|
+
const obj = value;
|
|
2282
|
+
const keys = Object.keys(obj).sort();
|
|
2283
|
+
const parts = keys.map((k) => {
|
|
2284
|
+
return JSON.stringify(k) + ":" + canonicalJsonStringify(obj[k]);
|
|
2285
|
+
});
|
|
2286
|
+
return "{" + parts.join(",") + "}";
|
|
2287
|
+
}
|
|
2258
2288
|
export {
|
|
2259
2289
|
AGENTMARK_SCOPE_NAME,
|
|
2260
2290
|
AgentMarkTransformer,
|
|
@@ -2266,6 +2296,8 @@ export {
|
|
|
2266
2296
|
SpanType,
|
|
2267
2297
|
TransformerRegistry,
|
|
2268
2298
|
TypeClassifier,
|
|
2299
|
+
canonicalJsonStringify,
|
|
2300
|
+
computeDatasetItemName,
|
|
2269
2301
|
convertOtlpAttributes,
|
|
2270
2302
|
createSignature,
|
|
2271
2303
|
detectVersion,
|