@sailfish-ai/sf-veritas 0.2.6 → 0.2.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.
@@ -1,28 +1,28 @@
1
- var ee = Object.defineProperty;
2
- var te = (r, e, n) => e in r ? ee(r, e, { enumerable: !0, configurable: !0, writable: !0, value: n }) : r[e] = n;
3
- var c = (r, e, n) => te(r, typeof e != "symbol" ? e + "" : e, n);
4
- import { AsyncLocalStorage as x, AsyncResource as re } from "async_hooks";
5
- import { appendFileSync as ne } from "fs";
6
- import { threadId as R } from "worker_threads";
1
+ var te = Object.defineProperty;
2
+ var re = (r, e, n) => e in r ? te(r, e, { enumerable: !0, configurable: !0, writable: !0, value: n }) : r[e] = n;
3
+ var c = (r, e, n) => re(r, typeof e != "symbol" ? e + "" : e, n);
4
+ import { AsyncLocalStorage as V, AsyncResource as ne } from "async_hooks";
5
+ import { appendFileSync as oe } from "fs";
6
+ import { threadId as w } from "worker_threads";
7
7
  const l = [];
8
8
  for (let r = 0; r < 256; ++r) l.push((r + 256).toString(16).slice(1));
9
- let O;
10
- const se = new Uint8Array(16), G = { randomUUID: typeof crypto < "u" && crypto.randomUUID && crypto.randomUUID.bind(crypto) };
9
+ let U;
10
+ const se = new Uint8Array(16), z = { randomUUID: typeof crypto < "u" && crypto.randomUUID && crypto.randomUUID.bind(crypto) };
11
11
  function C(r, e, n) {
12
- if (G.randomUUID && !r) return G.randomUUID();
12
+ if (z.randomUUID && !r) return z.randomUUID();
13
13
  const a = (r = r || {}).random ?? r.rng?.() ?? (function() {
14
- if (!O) {
14
+ if (!U) {
15
15
  if (typeof crypto > "u" || !crypto.getRandomValues) throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");
16
- O = crypto.getRandomValues.bind(crypto);
16
+ U = crypto.getRandomValues.bind(crypto);
17
17
  }
18
- return O(se);
18
+ return U(se);
19
19
  })();
20
20
  if (a.length < 16) throw new Error("Random bytes length must be >= 16");
21
- return a[6] = 15 & a[6] | 64, a[8] = 63 & a[8] | 128, (function(o, i = 0) {
22
- return (l[o[i + 0]] + l[o[i + 1]] + l[o[i + 2]] + l[o[i + 3]] + "-" + l[o[i + 4]] + l[o[i + 5]] + "-" + l[o[i + 6]] + l[o[i + 7]] + "-" + l[o[i + 8]] + l[o[i + 9]] + "-" + l[o[i + 10]] + l[o[i + 11]] + l[o[i + 12]] + l[o[i + 13]] + l[o[i + 14]] + l[o[i + 15]]).toLowerCase();
21
+ return a[6] = 15 & a[6] | 64, a[8] = 63 & a[8] | 128, (function(s, i = 0) {
22
+ return (l[s[i + 0]] + l[s[i + 1]] + l[s[i + 2]] + l[s[i + 3]] + "-" + l[s[i + 4]] + l[s[i + 5]] + "-" + l[s[i + 6]] + l[s[i + 7]] + "-" + l[s[i + 8]] + l[s[i + 9]] + "-" + l[s[i + 10]] + l[s[i + 11]] + l[s[i + 12]] + l[s[i + 13]] + l[s[i + 14]] + l[s[i + 15]]).toLowerCase();
23
23
  })(a);
24
24
  }
25
- class oe {
25
+ class ae {
26
26
  constructor(e) {
27
27
  c(this, "apiKey");
28
28
  c(this, "apiGraphqlEndpoint");
@@ -56,16 +56,16 @@ class oe {
56
56
  this._serviceIdentificationReceived = e;
57
57
  }
58
58
  }
59
- const Q = Symbol.for("sailfish.sf_config");
59
+ const Y = Symbol.for("sailfish.sf_config");
60
60
  function A() {
61
- return globalThis[Q];
61
+ return globalThis[Y];
62
62
  }
63
- function me(r) {
63
+ function Se(r) {
64
64
  const e = A();
65
65
  if (e) return { config: e };
66
- const n = new oe(r);
66
+ const n = new ae(r);
67
67
  return (function(a) {
68
- globalThis[Q] = a;
68
+ globalThis[Y] = a;
69
69
  })(n), n.sfDebug && console.log("[[getOrCreateConfig]] Created global config:", n), { config: n };
70
70
  }
71
71
  function f() {
@@ -73,7 +73,7 @@ function f() {
73
73
  if (!r) throw new Error("Configuration has not been initialized. Call getOrCreateConfig(options) first.");
74
74
  return r;
75
75
  }
76
- const z = Symbol.for("sf.ctx.storeAls"), h = globalThis, k = h[z] ?? (h[z] = new x()), ae = ["identitytoolkit.googleapis.com", "t.co", "*.twitter.com", "*.gravatar.com", "*.googleapis.com", "*.amazonaws.com", "*.smooch.io", "*.zendesk.com"], H = Symbol.for("sf.ctx.als"), E = h[H] ?? (h[H] = new x()), J = Symbol.for("sf.ctx.sessionRegistry"), $ = h[J] ?? (h[J] = /* @__PURE__ */ new Map()), D = { handledExceptions: /* @__PURE__ */ new Set(), reentrancyGuardLoggingActive: !1, reentrancyGuardLoggingPreActive: !1, reentrancyGuardPrintActive: !1, reentrancyGuardPrintPreActive: !1, reentrancyGuardExceptionActive: !1, reentrancyGuardExceptionPreActive: !1, excludedDomains: new Set(ae), supportedDomains: /* @__PURE__ */ new Set() }, _ = class _ {
76
+ const H = Symbol.for("sf.ctx.storeAls"), h = globalThis, k = h[H] ?? (h[H] = new V()), ie = ["identitytoolkit.googleapis.com", "t.co", "*.twitter.com", "*.gravatar.com", "*.googleapis.com", "*.amazonaws.com", "*.smooch.io", "*.zendesk.com"], J = Symbol.for("sf.ctx.als"), E = h[J] ?? (h[J] = new V()), j = Symbol.for("sf.ctx.sessionRegistry"), $ = h[j] ?? (h[j] = /* @__PURE__ */ new Map()), F = { handledExceptions: /* @__PURE__ */ new Set(), reentrancyGuardLoggingActive: !1, reentrancyGuardLoggingPreActive: !1, reentrancyGuardPrintActive: !1, reentrancyGuardPrintPreActive: !1, reentrancyGuardExceptionActive: !1, reentrancyGuardExceptionPreActive: !1, excludedDomains: new Set(ie), supportedDomains: /* @__PURE__ */ new Set() }, _ = class _ {
77
77
  constructor() {
78
78
  }
79
79
  current() {
@@ -86,26 +86,26 @@ const z = Symbol.for("sf.ctx.storeAls"), h = globalThis, k = h[z] ?? (h[z] = new
86
86
  return k.enterWith(n), n;
87
87
  }
88
88
  runWith(e, n) {
89
- const a = this.current() ?? /* @__PURE__ */ new Map(), o = new Map(a);
90
- for (const [i, t] of Object.entries(e)) o.set(i, t);
91
- return k.run(o, n);
89
+ const a = this.current() ?? /* @__PURE__ */ new Map(), s = new Map(a);
90
+ for (const [i, t] of Object.entries(e)) s.set(i, t);
91
+ return k.run(s, n);
92
92
  }
93
93
  static getInstance() {
94
94
  return h[_.GLOBAL_MANAGER_SYMBOL] || (h[_.GLOBAL_MANAGER_SYMBOL] = new _()), h[_.GLOBAL_MANAGER_SYMBOL];
95
95
  }
96
96
  getCurrentContext() {
97
- return E.getStore() || D;
97
+ return E.getStore() || F;
98
98
  }
99
99
  setCurrentContext(e) {
100
- const n = E.getStore() || D;
100
+ const n = E.getStore() || F;
101
101
  E.enterWith({ ...n, ...e });
102
102
  }
103
103
  ensureSession(e) {
104
104
  let n = $.get(e);
105
- return n || (n = { ...D }, $.set(e, n)), n;
105
+ return n || (n = { ...F }, $.set(e, n)), n;
106
106
  }
107
107
  getContextFor(e) {
108
- return $.get(e) ?? D;
108
+ return $.get(e) ?? F;
109
109
  }
110
110
  updateContextFor(e, n) {
111
111
  const a = this.ensureSession(e);
@@ -178,16 +178,16 @@ const z = Symbol.for("sf.ctx.storeAls"), h = globalThis, k = h[z] ?? (h[z] = new
178
178
  };
179
179
  c(_, "GLOBAL_MANAGER_SYMBOL", Symbol.for("sf.ctx.manager"));
180
180
  let I = _;
181
- function Se(r) {
181
+ function he(r) {
182
182
  const e = { ...I.getInstance().getCurrentContext() };
183
183
  E.run(e, () => {
184
184
  r();
185
185
  });
186
186
  }
187
- function he() {
187
+ function ye() {
188
188
  return I.getInstance().getCurrentFunctionSpanId();
189
189
  }
190
- class ie {
190
+ class ce {
191
191
  constructor() {
192
192
  c(this, "apiKey");
193
193
  c(this, "endpoint");
@@ -217,41 +217,41 @@ class ie {
217
217
  this.serviceUUID = e;
218
218
  }
219
219
  }
220
- const ce = fetch;
221
- let P = !1;
222
- async function j(r, e, n, a) {
220
+ const ue = fetch;
221
+ let D = !1;
222
+ async function q(r, e, n, a) {
223
223
  try {
224
- const o = f();
224
+ const s = f();
225
225
  let i;
226
226
  try {
227
227
  i = JSON.stringify({ query: n, variables: a, operationName: e });
228
228
  } catch {
229
229
  i = JSON.stringify({ query: n, operationName: e });
230
230
  }
231
- P = !0, ce(r, { method: "POST", headers: { "Content-Type": "application/json" }, body: i }).then(async (t) => {
232
- if (P = !1, !t.ok) return void (o.sfDebug && console.error(`GraphQL request failed with status ${t.status} for ${e}`));
233
- const s = await t.json();
234
- s.errors?.length ? (function(u, m, p) {
231
+ D = !0, ue(r, { method: "POST", headers: { "Content-Type": "application/json" }, body: i }).then(async (t) => {
232
+ if (D = !1, !t.ok) return void (s.sfDebug && console.error(`GraphQL request failed with status ${t.status} for ${e}`));
233
+ const o = await t.json();
234
+ o.errors?.length ? (function(u, m, p) {
235
235
  const g = u && typeof u == "object" && !Array.isArray(u) ? Object.keys(u)[0] : void 0;
236
236
  console.error(g === "identifyServiceDetails" ? `IdentifyServiceDetails NOT sent successfully for service: UUID=${p.serviceUUID}` : `GraphQL request failed with errors: ${JSON.stringify(m)} for operation key ${g}`);
237
- })(s.data, s.errors, o) : o.sfDebug && (function(u, m, p) {
237
+ })(o.data, o.errors, s) : s.sfDebug && (function(u, m, p) {
238
238
  const g = u && typeof u == "object" && !Array.isArray(u) ? Object.keys(u)[0] : void 0, d = u[g] || !1;
239
239
  g === "identifyServiceDetails" && (p.setServiceIdentificationReceived(d), f().sfDebug && console.log(`IdentifyServiceDetails sent successfully for service: UUID=${p.serviceUUID}; serviceIdentificationReceived=${g === "identifyServiceDetails" ? d : "N/A"}`));
240
- })(s.data, 0, o);
240
+ })(o.data, 0, s);
241
241
  }).catch((t) => {
242
- P = !1, o.sfDebug && (console.error(`[RequestUtils] Fetch error for ${e} to ${r}:`, t), t.cause && console.error("[RequestUtils] Error cause:", t.cause));
242
+ D = !1, s.sfDebug && (console.error(`[RequestUtils] Fetch error for ${e} to ${r}:`, t), t.cause && console.error("[RequestUtils] Error cause:", t.cause));
243
243
  });
244
- } catch (o) {
245
- P = !1, f().sfDebug && console.error("Error sending data to GraphQL server:", o);
244
+ } catch (s) {
245
+ D = !1, f().sfDebug && console.error("Error sending data to GraphQL server:", s);
246
246
  }
247
247
  }
248
- function ye() {
248
+ function Ne() {
249
249
  return { capture_arguments: b(process.env.SF_FUNCSPAN_CAPTURE_ARGUMENTS, !0), capture_return_value: b(process.env.SF_FUNCSPAN_CAPTURE_RETURN_VALUE, !0), arg_limit_mb: parseInt(process.env.SF_FUNCSPAN_ARG_LIMIT_MB || "1", 10), return_limit_mb: parseInt(process.env.SF_FUNCSPAN_RETURN_LIMIT_MB || "1", 10), autocapture_all_child_functions: b(process.env.SF_FUNCSPAN_AUTOCAPTURE_ALL_CHILD_FUNCTIONS, !1), sample_rate: parseFloat(process.env.SF_FUNCSPAN_SAMPLE_RATE || "1.0"), enable_sampling: b(process.env.SF_FUNCSPAN_ENABLE_SAMPLING, !1), capture_sf_veritas: b(process.env.SF_FUNCSPAN_CAPTURE_SF_VERITAS, !1), parse_json_strings: b(process.env.SF_FUNCSPAN_PARSE_JSON_STRINGS, !1) };
250
250
  }
251
- function Ne() {
251
+ function _e() {
252
252
  return { capture_arguments: !1, capture_return_value: !1, arg_limit_mb: 1, return_limit_mb: 1, autocapture_all_child_functions: !1, sample_rate: 0, enable_sampling: !1, capture_sf_veritas: !1, parse_json_strings: !1 };
253
253
  }
254
- function _e(r) {
254
+ function Ie(r) {
255
255
  try {
256
256
  const e = r.split("-");
257
257
  return e.length !== 9 ? (console.error(`[FuncSpan] Invalid header format: expected 9 parts, got ${e.length}`), null) : { capture_arguments: e[0] === "1", capture_return_value: e[1] === "1", arg_limit_mb: parseInt(e[2], 10), return_limit_mb: parseInt(e[3], 10), autocapture_all_child_functions: e[4] === "1", sample_rate: parseFloat(e[5]), enable_sampling: e[6] === "1", capture_sf_veritas: e[7] === "1", parse_json_strings: e[8] === "1" };
@@ -264,22 +264,34 @@ function b(r, e) {
264
264
  const n = r.toLowerCase();
265
265
  return n === "true" || n === "1" || n === "yes";
266
266
  }
267
- const M = new x();
268
- function Ie(r) {
269
- M.enterWith(r);
270
- }
271
- function ve() {
272
- return M.getStore();
267
+ const x = new V();
268
+ let L = !1;
269
+ function ve(r) {
270
+ x.enterWith(r);
273
271
  }
274
272
  function be() {
275
- M.enterWith(void 0);
273
+ if (L) return x.getStore();
274
+ try {
275
+ L = !0;
276
+ const r = x.getStore(), e = new Error().stack?.split(`
277
+ `).slice(1, 4).join(`
278
+ `);
279
+ return console.log(`[getFuncspanOverride] Called from:
280
+ ${e}`), console.log("[getFuncspanOverride] Returned value:", r), r;
281
+ } catch (r) {
282
+ return void console.error("[getFuncspanOverride] ❌ Error:", r);
283
+ } finally {
284
+ L = !1;
285
+ }
276
286
  }
277
- function Ce(...r) {
287
+ function Ce() {
288
+ }
289
+ function Te(...r) {
278
290
  const e = {};
279
291
  for (const n of r) for (const a in n) n[a] !== void 0 && (e[a] = n[a]);
280
292
  return e;
281
293
  }
282
- function Y(r, e) {
294
+ function X(r, e) {
283
295
  try {
284
296
  const n = JSON.stringify(r).length / 1048576;
285
297
  return n <= e ? r : { _truncated: !0, _originalSizeMB: n.toFixed(2), _limitMB: e, _preview: JSON.stringify(r).substring(0, 500) + "..." };
@@ -291,17 +303,17 @@ function N(r, e) {
291
303
  const n = process.env[r];
292
304
  return n === void 0 ? e : n === "true" || n === "1";
293
305
  }
294
- function q(r, e) {
306
+ function Q(r, e) {
295
307
  const n = process.env[r];
296
308
  if (n === void 0) return e;
297
309
  const a = parseFloat(n);
298
310
  return isNaN(a) ? e : a;
299
311
  }
300
- function V() {
301
- return { enabled: N("SF_WORKER_POOL_ENABLED", !0), trackFs: N("SF_WORKER_POOL_TRACK_FS", !1), trackDns: N("SF_WORKER_POOL_TRACK_DNS", !0), trackCrypto: N("SF_WORKER_POOL_TRACK_CRYPTO", !1), trackZlib: N("SF_WORKER_POOL_TRACK_ZLIB", !1), captureArguments: N("SF_WORKER_POOL_CAPTURE_ARGUMENTS", !0), captureReturnValue: N("SF_WORKER_POOL_CAPTURE_RETURN_VALUE", !0), argLimitMb: q("SF_WORKER_POOL_ARG_LIMIT_MB", 1), returnLimitMb: q("SF_WORKER_POOL_RETURN_LIMIT_MB", 1) };
312
+ function K() {
313
+ return { enabled: N("SF_WORKER_POOL_ENABLED", !0), trackFs: N("SF_WORKER_POOL_TRACK_FS", !1), trackDns: N("SF_WORKER_POOL_TRACK_DNS", !0), trackCrypto: N("SF_WORKER_POOL_TRACK_CRYPTO", !1), trackZlib: N("SF_WORKER_POOL_TRACK_ZLIB", !1), captureArguments: N("SF_WORKER_POOL_CAPTURE_ARGUMENTS", !0), captureReturnValue: N("SF_WORKER_POOL_CAPTURE_RETURN_VALUE", !0), argLimitMb: Q("SF_WORKER_POOL_ARG_LIMIT_MB", 1), returnLimitMb: Q("SF_WORKER_POOL_RETURN_LIMIT_MB", 1) };
302
314
  }
303
- function Te(r) {
304
- const e = V();
315
+ function $e(r) {
316
+ const e = K();
305
317
  if (!e.enabled) return !1;
306
318
  switch (r) {
307
319
  case "fs":
@@ -316,18 +328,18 @@ function Te(r) {
316
328
  return !1;
317
329
  }
318
330
  }
319
- function X(r, e, n, a) {
320
- let o;
331
+ function Z(r, e, n, a) {
332
+ let s;
321
333
  try {
322
334
  switch (r) {
323
335
  case "fs":
324
- o = (function(i, t) {
325
- const s = {};
336
+ s = (function(i, t) {
337
+ const o = {};
326
338
  switch (i) {
327
339
  case "readFile":
328
340
  case "writeFile":
329
341
  case "appendFile":
330
- s.path = String(t[0] || ""), t[1] && typeof t[1] == "object" ? (s.encoding = t[1].encoding || null, s.flag = t[1].flag || null) : typeof t[1] == "string" && (s.encoding = t[1]), i !== "writeFile" && i !== "appendFile" || (Buffer.isBuffer(t[1]) ? (s.dataType = "Buffer", s.dataSize = t[1].length) : typeof t[1] == "string" && (s.dataType = "string", s.dataSize = t[1].length));
342
+ o.path = String(t[0] || ""), t[1] && typeof t[1] == "object" ? (o.encoding = t[1].encoding || null, o.flag = t[1].flag || null) : typeof t[1] == "string" && (o.encoding = t[1]), i !== "writeFile" && i !== "appendFile" || (Buffer.isBuffer(t[1]) ? (o.dataType = "Buffer", o.dataSize = t[1].length) : typeof t[1] == "string" && (o.dataType = "string", o.dataSize = t[1].length));
331
343
  break;
332
344
  case "readdir":
333
345
  case "stat":
@@ -337,34 +349,34 @@ function X(r, e, n, a) {
337
349
  case "mkdir":
338
350
  case "rmdir":
339
351
  case "unlink":
340
- s.path = String(t[0] || ""), t[1] && typeof t[1] == "object" && (s.options = { ...t[1] }, delete s.options.callback);
352
+ o.path = String(t[0] || ""), t[1] && typeof t[1] == "object" && (o.options = { ...t[1] }, delete o.options.callback);
341
353
  break;
342
354
  case "rename":
343
- s.oldPath = String(t[0] || ""), s.newPath = String(t[1] || "");
355
+ o.oldPath = String(t[0] || ""), o.newPath = String(t[1] || "");
344
356
  break;
345
357
  case "open":
346
- s.path = String(t[0] || ""), s.flags = t[1], s.mode = t[2];
358
+ o.path = String(t[0] || ""), o.flags = t[1], o.mode = t[2];
347
359
  break;
348
360
  case "close":
349
361
  case "fstat":
350
- s.fd = t[0];
362
+ o.fd = t[0];
351
363
  break;
352
364
  case "read":
353
365
  case "write":
354
- s.fd = t[0], Buffer.isBuffer(t[1]) && (s.bufferSize = t[1].length), s.offset = t[2], s.length = t[3], s.position = t[4];
366
+ o.fd = t[0], Buffer.isBuffer(t[1]) && (o.bufferSize = t[1].length), o.offset = t[2], o.length = t[3], o.position = t[4];
355
367
  break;
356
368
  default:
357
- s.argsCount = t.length - 1;
369
+ o.argsCount = t.length - 1;
358
370
  }
359
- return s;
371
+ return o;
360
372
  })(e, n);
361
373
  break;
362
374
  case "dns":
363
- o = (function(i, t) {
364
- const s = {};
375
+ s = (function(i, t) {
376
+ const o = {};
365
377
  switch (i) {
366
378
  case "lookup":
367
- s.hostname = String(t[0] || ""), typeof t[1] == "object" ? (s.family = t[1].family, s.all = t[1].all) : typeof t[1] == "number" && (s.family = t[1]);
379
+ o.hostname = String(t[0] || ""), typeof t[1] == "object" ? (o.family = t[1].family, o.all = t[1].all) : typeof t[1] == "number" && (o.family = t[1]);
368
380
  break;
369
381
  case "resolve":
370
382
  case "resolve4":
@@ -373,59 +385,59 @@ function X(r, e, n, a) {
373
385
  case "resolveMx":
374
386
  case "resolveNs":
375
387
  case "resolveTxt":
376
- s.hostname = String(t[0] || "");
388
+ o.hostname = String(t[0] || "");
377
389
  break;
378
390
  case "reverse":
379
- s.ip = String(t[0] || "");
391
+ o.ip = String(t[0] || "");
380
392
  break;
381
393
  default:
382
- s.argsCount = t.length - 1;
394
+ o.argsCount = t.length - 1;
383
395
  }
384
- return s;
396
+ return o;
385
397
  })(e, n);
386
398
  break;
387
399
  case "crypto":
388
- o = (function(i, t) {
389
- const s = {};
400
+ s = (function(i, t) {
401
+ const o = {};
390
402
  switch (i) {
391
403
  case "pbkdf2":
392
- s.passwordType = typeof t[0], s.saltType = typeof t[1], s.iterations = t[2], s.keylen = t[3], s.digest = t[4];
404
+ o.passwordType = typeof t[0], o.saltType = typeof t[1], o.iterations = t[2], o.keylen = t[3], o.digest = t[4];
393
405
  break;
394
406
  case "scrypt":
395
- s.passwordType = typeof t[0], s.saltType = typeof t[1], s.keylen = t[2], typeof t[3] == "object" && (s.N = t[3].N, s.r = t[3].r, s.p = t[3].p);
407
+ o.passwordType = typeof t[0], o.saltType = typeof t[1], o.keylen = t[2], typeof t[3] == "object" && (o.N = t[3].N, o.r = t[3].r, o.p = t[3].p);
396
408
  break;
397
409
  case "randomBytes":
398
- s.size = t[0];
410
+ o.size = t[0];
399
411
  break;
400
412
  case "generateKeyPair":
401
- s.type = t[0], typeof t[1] == "object" && (s.modulusLength = t[1].modulusLength, s.namedCurve = t[1].namedCurve);
413
+ o.type = t[0], typeof t[1] == "object" && (o.modulusLength = t[1].modulusLength, o.namedCurve = t[1].namedCurve);
402
414
  break;
403
415
  default:
404
- s.argsCount = t.length - 1;
416
+ o.argsCount = t.length - 1;
405
417
  }
406
- return s;
418
+ return o;
407
419
  })(e, n);
408
420
  break;
409
421
  case "zlib":
410
- o = (function(i, t) {
411
- const s = {};
412
- return Buffer.isBuffer(t[0]) ? (s.inputType = "Buffer", s.inputSize = t[0].length) : typeof t[0] == "string" ? (s.inputType = "string", s.inputSize = t[0].length) : s.inputType = typeof t[0], t[1] && typeof t[1] == "object" && typeof t[1] != "function" && (s.options = { ...t[1] }), s;
422
+ s = (function(i, t) {
423
+ const o = {};
424
+ return Buffer.isBuffer(t[0]) ? (o.inputType = "Buffer", o.inputSize = t[0].length) : typeof t[0] == "string" ? (o.inputType = "string", o.inputSize = t[0].length) : o.inputType = typeof t[0], t[1] && typeof t[1] == "object" && typeof t[1] != "function" && (o.options = { ...t[1] }), o;
413
425
  })(0, n);
414
426
  break;
415
427
  default:
416
428
  return null;
417
429
  }
418
- return a > 0 ? Y(o, a) : o;
430
+ return a > 0 ? X(s, a) : s;
419
431
  } catch {
420
432
  return { error: "Failed to capture arguments", argsCount: n.length - 1 };
421
433
  }
422
434
  }
423
- function Z(r, e, n, a) {
424
- let o;
435
+ function ee(r, e, n, a) {
436
+ let s;
425
437
  try {
426
438
  switch (r) {
427
439
  case "fs":
428
- o = (function(i, t) {
440
+ s = (function(i, t) {
429
441
  if (!t) return null;
430
442
  switch (i) {
431
443
  case "readFile":
@@ -448,7 +460,7 @@ function Z(r, e, n, a) {
448
460
  })(e, n);
449
461
  break;
450
462
  case "dns":
451
- o = (function(i, t) {
463
+ s = (function(i, t) {
452
464
  if (!t) return null;
453
465
  switch (i) {
454
466
  case "lookup":
@@ -469,7 +481,7 @@ function Z(r, e, n, a) {
469
481
  })(e, n);
470
482
  break;
471
483
  case "crypto":
472
- o = (function(i, t) {
484
+ s = (function(i, t) {
473
485
  if (!t) return null;
474
486
  switch (i) {
475
487
  case "pbkdf2":
@@ -484,22 +496,22 @@ function Z(r, e, n, a) {
484
496
  })(e, n);
485
497
  break;
486
498
  case "zlib":
487
- o = (function(i, t) {
499
+ s = (function(i, t) {
488
500
  return t ? Buffer.isBuffer(t) ? { type: "Buffer", size: t.length } : typeof t == "string" ? { type: "string", size: t.length } : { type: typeof t } : null;
489
501
  })(0, n);
490
502
  break;
491
503
  default:
492
504
  return null;
493
505
  }
494
- return a > 0 ? Y(o, a) : o;
506
+ return a > 0 ? X(s, a) : s;
495
507
  } catch {
496
508
  return { error: "Failed to capture result", type: typeof n };
497
509
  }
498
510
  }
499
- function ue(r) {
511
+ function le(r) {
500
512
  return r.operationType === "worker_pool";
501
513
  }
502
- class le extends ie {
514
+ class pe extends ce {
503
515
  constructor() {
504
516
  super(), this.operationName = "CollectFunctionSpans";
505
517
  }
@@ -507,20 +519,20 @@ class le extends ie {
507
519
  const n = f().sfDebug;
508
520
  n && console.log(`[FunctionSpanTransmitter] Preparing to send ${e.length} function span(s)`);
509
521
  for (const a of e) try {
510
- if (ue(a)) {
522
+ if (le(a)) {
511
523
  this.sendWorkerPoolSpan(a, n);
512
524
  continue;
513
525
  }
514
- const o = a;
526
+ const s = a;
515
527
  let i;
516
- if (o.result !== void 0 && o.result !== null) {
517
- const s = typeof o.result;
518
- i = JSON.stringify({ type: s, has_value: !0, value: o.result });
519
- } else i = o.result === null ? JSON.stringify({ type: "null", has_value: !0, value: null }) : JSON.stringify({ type: "undefined", has_value: !1, value: null });
520
- const t = this.getVariables({ library: "JS/TS BACKEND", version: f().version, spanId: o.spanId, parentSpanId: o.parentSpanId, filePath: o.filePath, lineNumber: o.metadata.line, columnNumber: o.metadata.column, functionName: o.functionName, arguments: JSON.stringify(o.args || {}), returnValue: i, startTimeNs: (1e6 * Date.now() - 1e6 * o.duration).toString(), durationNs: (1e6 * o.duration).toString() });
521
- n && (console.log(`[FunctionSpanTransmitter] Sending GraphQL mutation to ${this.endpoint}`), console.log("[FunctionSpanTransmitter] Variables:", JSON.stringify(t, null, 2))), j(this.endpoint, this.operationName, this.getQuery(), t), n && console.log(`[FunctionSpanTransmitter] Queued function span for ${o.functionName}`);
522
- } catch (o) {
523
- console.error(`[FunctionSpanTransmitter] Error preparing function span for ${a.functionName}:`, o);
528
+ if (s.result !== void 0 && s.result !== null) {
529
+ const o = typeof s.result;
530
+ i = JSON.stringify({ type: o, has_value: !0, value: s.result });
531
+ } else i = s.result === null ? JSON.stringify({ type: "null", has_value: !0, value: null }) : JSON.stringify({ type: "undefined", has_value: !1, value: null });
532
+ const t = this.getVariables({ library: "JS/TS BACKEND", version: f().version, spanId: s.spanId, parentSpanId: s.parentSpanId, filePath: s.filePath, lineNumber: s.metadata.line, columnNumber: s.metadata.column, functionName: s.functionName, arguments: JSON.stringify(s.args || {}), returnValue: i, startTimeNs: (1e6 * Date.now() - 1e6 * s.duration).toString(), durationNs: (1e6 * s.duration).toString() });
533
+ n && (console.log(`[FunctionSpanTransmitter] Sending GraphQL mutation to ${this.endpoint}`), console.log("[FunctionSpanTransmitter] Variables:", JSON.stringify(t, null, 2))), q(this.endpoint, this.operationName, this.getQuery(), t), n && console.log(`[FunctionSpanTransmitter] Queued function span for ${s.functionName}`);
534
+ } catch (s) {
535
+ console.error(`[FunctionSpanTransmitter] Error preparing function span for ${a.functionName}:`, s);
524
536
  }
525
537
  }
526
538
  sendWorkerPoolSpan(e, n) {
@@ -530,8 +542,8 @@ class le extends ie {
530
542
  const i = typeof e.result;
531
543
  a = JSON.stringify({ type: i, has_value: !0, value: e.result });
532
544
  } else a = e.result === null ? JSON.stringify({ type: "null", has_value: !0, value: null }) : JSON.stringify({ type: "undefined", has_value: !1, value: null });
533
- const o = this.getVariables({ library: "JS/TS BACKEND", version: f().version, spanId: e.spanId, operationName: e.operationName, moduleName: e.moduleName, methodName: e.methodName, startTimeNs: e.startTimeNs, durationNs: e.durationNs, arguments: JSON.stringify(e.args || {}), returnValue: a, error: e.error, pid: e.pid, threadId: e.threadId });
534
- n && (console.log(`[FunctionSpanTransmitter] Sending worker pool span: ${e.operationName}`), console.log("[FunctionSpanTransmitter] Variables:", JSON.stringify(o, null, 2))), j(this.endpoint, "CollectWorkerPoolSpans", this.getWorkerPoolQuery(), o), n && console.log(`[FunctionSpanTransmitter] Queued worker pool span for ${e.operationName}`);
545
+ const s = this.getVariables({ library: "JS/TS BACKEND", version: f().version, spanId: e.spanId, operationName: e.operationName, moduleName: e.moduleName, methodName: e.methodName, startTimeNs: e.startTimeNs, durationNs: e.durationNs, arguments: JSON.stringify(e.args || {}), returnValue: a, error: e.error, pid: e.pid, threadId: e.threadId });
546
+ n && (console.log(`[FunctionSpanTransmitter] Sending worker pool span: ${e.operationName}`), console.log("[FunctionSpanTransmitter] Variables:", JSON.stringify(s, null, 2))), q(this.endpoint, "CollectWorkerPoolSpans", this.getWorkerPoolQuery(), s), n && console.log(`[FunctionSpanTransmitter] Queued worker pool span for ${e.operationName}`);
535
547
  } catch (a) {
536
548
  console.error(`[FunctionSpanTransmitter] Error preparing worker pool span for ${e.operationName}:`, a);
537
549
  }
@@ -623,83 +635,84 @@ class le extends ie {
623
635
  `;
624
636
  }
625
637
  }
626
- let L = null;
627
- function $e(r, e, n, a, o) {
638
+ let R = null;
639
+ function Ee(r, e, n, a, s) {
628
640
  const i = A(), t = i?.sfDebug || !1;
629
641
  t && console.log(`[WorkerPool] Capturing ${r}.${e}`);
630
- const s = V(), u = I.getInstance().getCurrentFunctionSpanId(), m = C();
642
+ const o = K(), u = I.getInstance().getCurrentFunctionSpanId(), m = C();
631
643
  t && console.log(`[WorkerPool] Span ID: ${m}, Parent: ${u || "none"}`);
632
- const p = new re("WorkerPoolOperation"), g = process.hrtime.bigint();
644
+ const p = new ne("WorkerPoolOperation"), g = process.hrtime.bigint();
633
645
  let d = null;
634
- s.captureArguments && (d = X(r, e, a, s.argLimitMb));
646
+ o.captureArguments && (d = Z(r, e, a, o.argLimitMb));
635
647
  const S = a.findIndex((v) => typeof v == "function");
636
- if (S === -1) return t && console.log(`[WorkerPool] No callback found for ${r}.${e}`), n.apply(o, a);
648
+ if (S === -1) return t && console.log(`[WorkerPool] No callback found for ${r}.${e}`), n.apply(s, a);
637
649
  const y = a[S], T = [...a];
638
- return T[S] = function(v, ...F) {
639
- const U = process.hrtime.bigint() - g, K = Number(U) / 1e6;
640
- y(v, ...F), p.runInAsyncScope(() => {
641
- t && console.log(`[WorkerPool] ${r}.${e} completed in ${K.toFixed(3)}ms (${U}ns)`);
642
- let B = null, W = null;
643
- v ? W = v?.message || String(v) : s.captureReturnValue && F.length > 0 && (B = Z(r, e, F[0], s.returnLimitMb)), w({ operationType: "worker_pool", operationName: `${r}.${e}`, moduleName: r, methodName: e, duration: K, durationNs: U.toString(), startTimeNs: g.toString(), args: d, result: B, error: W, spanId: m, parentSpanId: u, pid: process.pid, threadId: R });
650
+ return T[S] = function(v, ...P) {
651
+ const O = process.hrtime.bigint() - g, B = Number(O) / 1e6;
652
+ y(v, ...P), p.runInAsyncScope(() => {
653
+ t && console.log(`[WorkerPool] ${r}.${e} completed in ${B.toFixed(3)}ms (${O}ns)`);
654
+ let W = null, G = null;
655
+ v ? G = v?.message || String(v) : o.captureReturnValue && P.length > 0 && (W = ee(r, e, P[0], o.returnLimitMb)), M({ operationType: "worker_pool", operationName: `${r}.${e}`, moduleName: r, methodName: e, duration: B, durationNs: O.toString(), startTimeNs: g.toString(), args: d, result: W, error: G, spanId: m, parentSpanId: u, pid: process.pid, threadId: w });
644
656
  }), p.emitDestroy();
645
- }, n.apply(o, T);
657
+ }, n.apply(s, T);
646
658
  }
647
- function Ee(r, e, n, a, o) {
659
+ function Ae(r, e, n, a, s) {
648
660
  const i = A(), t = i?.sfDebug || !1;
649
661
  t && console.log(`[WorkerPool] Capturing ${r}.${e} (Promise)`);
650
- const s = V(), u = I.getInstance().getCurrentFunctionSpanId(), m = C();
662
+ const o = K(), u = I.getInstance().getCurrentFunctionSpanId(), m = C();
651
663
  t && console.log(`[WorkerPool] Span ID: ${m}, Parent: ${u || "none"}`);
652
664
  const p = process.hrtime.bigint();
653
665
  let g = null;
654
- return s.captureArguments && (g = X(r, e, a, s.argLimitMb)), n.apply(o, a).then((d) => {
666
+ return o.captureArguments && (g = Z(r, e, a, o.argLimitMb)), n.apply(s, a).then((d) => {
655
667
  const S = process.hrtime.bigint() - p, y = Number(S) / 1e6;
656
668
  t && console.log(`[WorkerPool] ${r}.${e} completed in ${y.toFixed(3)}ms (${S}ns)`);
657
669
  let T = null;
658
- return s.captureReturnValue && (T = Z(r, e, d, s.returnLimitMb)), w({ operationType: "worker_pool", operationName: `${r}.${e}`, moduleName: r, methodName: e, duration: y, durationNs: S.toString(), startTimeNs: p.toString(), args: g, result: T, error: null, spanId: m, parentSpanId: u, pid: process.pid, threadId: R }), d;
670
+ return o.captureReturnValue && (T = ee(r, e, d, o.returnLimitMb)), M({ operationType: "worker_pool", operationName: `${r}.${e}`, moduleName: r, methodName: e, duration: y, durationNs: S.toString(), startTimeNs: p.toString(), args: g, result: T, error: null, spanId: m, parentSpanId: u, pid: process.pid, threadId: w }), d;
659
671
  }, (d) => {
660
672
  const S = process.hrtime.bigint() - p, y = Number(S) / 1e6;
661
- throw t && console.log(`[WorkerPool] ${r}.${e} failed in ${y.toFixed(3)}ms: ${d?.message || d}`), w({ operationType: "worker_pool", operationName: `${r}.${e}`, moduleName: r, methodName: e, duration: y, durationNs: S.toString(), startTimeNs: p.toString(), args: g, result: null, error: d?.message || String(d), spanId: m, parentSpanId: u, pid: process.pid, threadId: R }), d;
673
+ throw t && console.log(`[WorkerPool] ${r}.${e} failed in ${y.toFixed(3)}ms: ${d?.message || d}`), M({ operationType: "worker_pool", operationName: `${r}.${e}`, moduleName: r, methodName: e, duration: y, durationNs: S.toString(), startTimeNs: p.toString(), args: g, result: null, error: d?.message || String(d), spanId: m, parentSpanId: u, pid: process.pid, threadId: w }), d;
662
674
  });
663
675
  }
664
- function w(r) {
676
+ function M(r) {
665
677
  const e = A(), n = e?.sfDebug || !1;
666
678
  n && console.log("[WorkerPool] Capturing span:", { operation: r.operationName, duration: `${r.duration}ms`, error: r.error, spanId: r.spanId, parentSpanId: r.parentSpanId }), process.env.SF_FUNCSPAN_CONSOLE_OUTPUT === "true" && console.log(`
667
679
  ⚙️ Worker Pool Operation:`, { operation: r.operationName, duration: `${r.duration.toFixed(2)}ms`, arguments: r.args, result: r.error ? `Error: ${r.error}` : r.result, spanId: r.spanId, parentSpanId: r.parentSpanId || "none" });
668
680
  const a = process.env.SF_FUNCSPAN_JSONL_FILE;
669
681
  if (a) try {
670
- const o = a === "true" || a === "1" ? "funcspans.jsonl" : a, i = Date.now(), t = process.hrtime.bigint(), s = BigInt(r.startTimeNs), u = Number(t - s) / 1e6, m = new Date(i - u).toISOString(), p = JSON.stringify({ timestamp: m, operationType: r.operationType, operationName: r.operationName, moduleName: r.moduleName, methodName: r.methodName, duration: r.duration, durationNs: r.durationNs, startTimeNs: r.startTimeNs, arguments: r.args, returnValue: r.error ? { error: String(r.error) } : r.result, spanId: r.spanId, parentSpanId: r.parentSpanId, pid: r.pid, threadId: r.threadId }) + `
682
+ const s = a === "true" || a === "1" ? "funcspans.jsonl" : a, i = Date.now(), t = process.hrtime.bigint(), o = BigInt(r.startTimeNs), u = Number(t - o) / 1e6, m = new Date(i - u).toISOString(), p = JSON.stringify({ timestamp: m, operationType: r.operationType, operationName: r.operationName, moduleName: r.moduleName, methodName: r.methodName, duration: r.duration, durationNs: r.durationNs, startTimeNs: r.startTimeNs, arguments: r.args, returnValue: r.error ? { error: String(r.error) } : r.result, spanId: r.spanId, parentSpanId: r.parentSpanId, pid: r.pid, threadId: r.threadId }) + `
671
683
  `;
672
- ne(o, p, "utf-8");
673
- } catch (o) {
674
- console.error("[WorkerPool] Error writing to JSONL file:", o);
684
+ oe(s, p, "utf-8");
685
+ } catch (s) {
686
+ console.error("[WorkerPool] Error writing to JSONL file:", s);
675
687
  }
676
688
  if (n && console.log("[WorkerPool] Sending span to transmitter"), process.env.SF_FUNCSPAN_SKIP_BACKEND !== "true") try {
677
- (L || (L = new le()), L).send([r]), n && console.log("[WorkerPool] Span sent successfully");
678
- } catch (o) {
679
- n && console.error("[WorkerPool] Error sending span:", o);
689
+ (R || (R = new pe()), R).send([r]), n && console.log("[WorkerPool] Span sent successfully");
690
+ } catch (s) {
691
+ n && console.error("[WorkerPool] Error sending span:", s);
680
692
  }
681
693
  }
682
694
  export {
683
- ie as B,
695
+ ce as B,
684
696
  I as C,
685
- ae as D,
686
- le as F,
697
+ ie as D,
698
+ pe as F,
687
699
  be as a,
688
- ve as b,
689
- $e as c,
690
- he as d,
691
- ye as e,
692
- Ne as f,
700
+ ye as b,
701
+ Ee as c,
702
+ Ne as d,
703
+ _e as e,
704
+ x as f,
693
705
  f as g,
694
- Ee as h,
695
- Te as i,
696
- me as j,
706
+ Ae as h,
707
+ $e as i,
708
+ Se as j,
697
709
  A as k,
698
- Ce as m,
699
- j as n,
700
- _e as p,
701
- Se as r,
702
- Ie as s,
703
- Y as t,
710
+ Ce as l,
711
+ Te as m,
712
+ q as n,
713
+ Ie as p,
714
+ he as r,
715
+ ve as s,
716
+ X as t,
704
717
  C as v
705
718
  };