@walkeros/cli 2.1.0 → 2.1.1

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/cli.js CHANGED
@@ -1590,7 +1590,7 @@ function $constructor(name, initializer3, params) {
1590
1590
  Object.defineProperty(inst, "_zod", {
1591
1591
  value: {
1592
1592
  def,
1593
- constr: _4,
1593
+ constr: _3,
1594
1594
  traits: /* @__PURE__ */ new Set()
1595
1595
  },
1596
1596
  enumerable: false
@@ -1601,7 +1601,7 @@ function $constructor(name, initializer3, params) {
1601
1601
  }
1602
1602
  inst._zod.traits.add(name);
1603
1603
  initializer3(inst, def);
1604
- const proto = _4.prototype;
1604
+ const proto = _3.prototype;
1605
1605
  const keys = Object.keys(proto);
1606
1606
  for (let i2 = 0; i2 < keys.length; i2++) {
1607
1607
  const k3 = keys[i2];
@@ -1614,7 +1614,7 @@ function $constructor(name, initializer3, params) {
1614
1614
  class Definition extends Parent {
1615
1615
  }
1616
1616
  Object.defineProperty(Definition, "name", { value: name });
1617
- function _4(def) {
1617
+ function _3(def) {
1618
1618
  var _a2;
1619
1619
  const inst = params?.Parent ? new Definition() : this;
1620
1620
  init(inst, def);
@@ -1624,16 +1624,16 @@ function $constructor(name, initializer3, params) {
1624
1624
  }
1625
1625
  return inst;
1626
1626
  }
1627
- Object.defineProperty(_4, "init", { value: init });
1628
- Object.defineProperty(_4, Symbol.hasInstance, {
1627
+ Object.defineProperty(_3, "init", { value: init });
1628
+ Object.defineProperty(_3, Symbol.hasInstance, {
1629
1629
  value: (inst) => {
1630
1630
  if (params?.Parent && inst instanceof params.Parent)
1631
1631
  return true;
1632
1632
  return inst?._zod?.traits?.has(name);
1633
1633
  }
1634
1634
  });
1635
- Object.defineProperty(_4, "name", { value: name });
1636
- return _4;
1635
+ Object.defineProperty(_3, "name", { value: name });
1636
+ return _3;
1637
1637
  }
1638
1638
  var $brand = /* @__PURE__ */ Symbol("zod_brand");
1639
1639
  var $ZodAsyncError = class extends Error {
@@ -1731,17 +1731,17 @@ function assertIs(_arg) {
1731
1731
  function assertNever(_x) {
1732
1732
  throw new Error("Unexpected value in exhaustive check");
1733
1733
  }
1734
- function assert(_4) {
1734
+ function assert(_3) {
1735
1735
  }
1736
1736
  function getEnumValues(entries) {
1737
1737
  const numericValues = Object.values(entries).filter((v2) => typeof v2 === "number");
1738
- const values = Object.entries(entries).filter(([k3, _4]) => numericValues.indexOf(+k3) === -1).map(([_4, v2]) => v2);
1738
+ const values = Object.entries(entries).filter(([k3, _3]) => numericValues.indexOf(+k3) === -1).map(([_3, v2]) => v2);
1739
1739
  return values;
1740
1740
  }
1741
1741
  function joinValues(array2, separator = "|") {
1742
1742
  return array2.map((val) => stringifyPrimitive(val)).join(separator);
1743
1743
  }
1744
- function jsonStringifyReplacer(_4, value) {
1744
+ function jsonStringifyReplacer(_3, value) {
1745
1745
  if (typeof value === "bigint")
1746
1746
  return value.toString();
1747
1747
  return value;
@@ -1870,7 +1870,7 @@ var allowsEval = cached(() => {
1870
1870
  const F4 = Function;
1871
1871
  new F4("");
1872
1872
  return true;
1873
- } catch (_4) {
1873
+ } catch (_3) {
1874
1874
  return false;
1875
1875
  }
1876
1876
  });
@@ -1980,31 +1980,31 @@ function normalizeParams(_params) {
1980
1980
  function createTransparentProxy(getter) {
1981
1981
  let target;
1982
1982
  return new Proxy({}, {
1983
- get(_4, prop, receiver) {
1983
+ get(_3, prop, receiver) {
1984
1984
  target ?? (target = getter());
1985
1985
  return Reflect.get(target, prop, receiver);
1986
1986
  },
1987
- set(_4, prop, value, receiver) {
1987
+ set(_3, prop, value, receiver) {
1988
1988
  target ?? (target = getter());
1989
1989
  return Reflect.set(target, prop, value, receiver);
1990
1990
  },
1991
- has(_4, prop) {
1991
+ has(_3, prop) {
1992
1992
  target ?? (target = getter());
1993
1993
  return Reflect.has(target, prop);
1994
1994
  },
1995
- deleteProperty(_4, prop) {
1995
+ deleteProperty(_3, prop) {
1996
1996
  target ?? (target = getter());
1997
1997
  return Reflect.deleteProperty(target, prop);
1998
1998
  },
1999
- ownKeys(_4) {
1999
+ ownKeys(_3) {
2000
2000
  target ?? (target = getter());
2001
2001
  return Reflect.ownKeys(target);
2002
2002
  },
2003
- getOwnPropertyDescriptor(_4, prop) {
2003
+ getOwnPropertyDescriptor(_3, prop) {
2004
2004
  target ?? (target = getter());
2005
2005
  return Reflect.getOwnPropertyDescriptor(target, prop);
2006
2006
  },
2007
- defineProperty(_4, prop, descriptor) {
2007
+ defineProperty(_3, prop, descriptor) {
2008
2008
  target ?? (target = getter());
2009
2009
  return Reflect.defineProperty(target, prop, descriptor);
2010
2010
  }
@@ -2287,7 +2287,7 @@ function issue(...args) {
2287
2287
  return { ...iss };
2288
2288
  }
2289
2289
  function cleanEnum(obj) {
2290
- return Object.entries(obj).filter(([k3, _4]) => {
2290
+ return Object.entries(obj).filter(([k3, _3]) => {
2291
2291
  return Number.isNaN(Number.parseInt(k3, 10));
2292
2292
  }).map((el) => el[1]);
2293
2293
  }
@@ -3339,13 +3339,13 @@ var $ZodType = /* @__PURE__ */ $constructor("$ZodType", (inst, def) => {
3339
3339
  continue;
3340
3340
  }
3341
3341
  const currLen = payload.issues.length;
3342
- const _4 = ch._zod.check(payload);
3343
- if (_4 instanceof Promise && ctx?.async === false) {
3342
+ const _3 = ch._zod.check(payload);
3343
+ if (_3 instanceof Promise && ctx?.async === false) {
3344
3344
  throw new $ZodAsyncError();
3345
3345
  }
3346
- if (asyncResult || _4 instanceof Promise) {
3346
+ if (asyncResult || _3 instanceof Promise) {
3347
3347
  asyncResult = (asyncResult ?? Promise.resolve()).then(async () => {
3348
- await _4;
3348
+ await _3;
3349
3349
  const nextLen = payload.issues.length;
3350
3350
  if (nextLen === currLen)
3351
3351
  return;
@@ -3407,7 +3407,7 @@ var $ZodType = /* @__PURE__ */ $constructor("$ZodType", (inst, def) => {
3407
3407
  try {
3408
3408
  const r2 = safeParse(inst, value);
3409
3409
  return r2.success ? { value: r2.data } : { issues: r2.error?.issues };
3410
- } catch (_4) {
3410
+ } catch (_3) {
3411
3411
  return safeParseAsync(inst, value).then((r2) => r2.success ? { value: r2.data } : { issues: r2.error?.issues });
3412
3412
  }
3413
3413
  },
@@ -3418,11 +3418,11 @@ var $ZodType = /* @__PURE__ */ $constructor("$ZodType", (inst, def) => {
3418
3418
  var $ZodString = /* @__PURE__ */ $constructor("$ZodString", (inst, def) => {
3419
3419
  $ZodType.init(inst, def);
3420
3420
  inst._zod.pattern = [...inst?._zod.bag?.patterns ?? []].pop() ?? string(inst._zod.bag);
3421
- inst._zod.parse = (payload, _4) => {
3421
+ inst._zod.parse = (payload, _3) => {
3422
3422
  if (def.coerce)
3423
3423
  try {
3424
3424
  payload.value = String(payload.value);
3425
- } catch (_5) {
3425
+ } catch (_4) {
3426
3426
  }
3427
3427
  if (typeof payload.value === "string")
3428
3428
  return payload;
@@ -3507,7 +3507,7 @@ var $ZodURL = /* @__PURE__ */ $constructor("$ZodURL", (inst, def) => {
3507
3507
  payload.value = trimmed;
3508
3508
  }
3509
3509
  return;
3510
- } catch (_4) {
3510
+ } catch (_3) {
3511
3511
  payload.issues.push({
3512
3512
  code: "invalid_format",
3513
3513
  format: "url",
@@ -3732,7 +3732,7 @@ var $ZodNumber = /* @__PURE__ */ $constructor("$ZodNumber", (inst, def) => {
3732
3732
  if (def.coerce)
3733
3733
  try {
3734
3734
  payload.value = Number(payload.value);
3735
- } catch (_4) {
3735
+ } catch (_3) {
3736
3736
  }
3737
3737
  const input = payload.value;
3738
3738
  if (typeof input === "number" && !Number.isNaN(input) && Number.isFinite(input)) {
@@ -3760,7 +3760,7 @@ var $ZodBoolean = /* @__PURE__ */ $constructor("$ZodBoolean", (inst, def) => {
3760
3760
  if (def.coerce)
3761
3761
  try {
3762
3762
  payload.value = Boolean(payload.value);
3763
- } catch (_4) {
3763
+ } catch (_3) {
3764
3764
  }
3765
3765
  const input = payload.value;
3766
3766
  if (typeof input === "boolean")
@@ -3781,7 +3781,7 @@ var $ZodBigInt = /* @__PURE__ */ $constructor("$ZodBigInt", (inst, def) => {
3781
3781
  if (def.coerce)
3782
3782
  try {
3783
3783
  payload.value = BigInt(payload.value);
3784
- } catch (_4) {
3784
+ } catch (_3) {
3785
3785
  }
3786
3786
  if (typeof payload.value === "bigint")
3787
3787
  return payload;
@@ -5245,7 +5245,7 @@ var $ZodLazy = /* @__PURE__ */ $constructor("$ZodLazy", (inst, def) => {
5245
5245
  var $ZodCustom = /* @__PURE__ */ $constructor("$ZodCustom", (inst, def) => {
5246
5246
  $ZodCheck.init(inst, def);
5247
5247
  $ZodType.init(inst, def);
5248
- inst._zod.parse = (payload, _4) => {
5248
+ inst._zod.parse = (payload, _3) => {
5249
5249
  return payload;
5250
5250
  };
5251
5251
  inst._zod.check = (payload) => {
@@ -12816,7 +12816,7 @@ function toJSONSchema(input, params) {
12816
12816
  const ctx2 = initializeContext({ ...params, processors: allProcessors });
12817
12817
  const defs = {};
12818
12818
  for (const entry of registry2._idmap.entries()) {
12819
- const [_4, schema] = entry;
12819
+ const [_3, schema] = entry;
12820
12820
  process2(schema, ctx2);
12821
12821
  }
12822
12822
  const schemas = {};
@@ -12915,7 +12915,7 @@ var JSONSchemaGenerator = class {
12915
12915
  }
12916
12916
  extractDefs(this.ctx, schema);
12917
12917
  const result = finalize(this.ctx, schema);
12918
- const { "~standard": _4, ...plainResult } = result;
12918
+ const { "~standard": _3, ...plainResult } = result;
12919
12919
  return plainResult;
12920
12920
  }
12921
12921
  };
@@ -15371,7 +15371,7 @@ async function getFlowConfigCacheKey(content, date5) {
15371
15371
  var PACKAGE_DOWNLOAD_TIMEOUT_MS = 6e4;
15372
15372
  async function withTimeout(promise2, ms, errorMessage) {
15373
15373
  let timer;
15374
- const timeout = new Promise((_4, reject) => {
15374
+ const timeout = new Promise((_3, reject) => {
15375
15375
  timer = setTimeout(() => reject(new Error(errorMessage)), ms);
15376
15376
  });
15377
15377
  try {
@@ -16681,18 +16681,15 @@ function s2(n3, e3) {
16681
16681
  }), n3.consent = H(n3.consent, s3), { update: s3, runQueue: t3 };
16682
16682
  }
16683
16683
  function D3(n3) {
16684
- return null != n3 && false !== n3 && "object" == typeof n3 && true === n3.__branch;
16685
- }
16686
- function A3(n3) {
16687
16684
  const e3 = {};
16688
16685
  for (const [t3, o2] of Object.entries(n3)) o2.config?.next ? e3[t3] = { next: o2.config.next } : e3[t3] = {};
16689
16686
  return e3;
16690
16687
  }
16691
- function E3(n3, e3) {
16688
+ function A3(n3, e3) {
16692
16689
  const t3 = n3.config || {}, o2 = n3[e3];
16693
16690
  return void 0 !== o2 ? { config: { ...t3, [e3]: o2 }, chainValue: o2 } : { config: t3, chainValue: void 0 };
16694
16691
  }
16695
- function P3(n3, e3 = {}) {
16692
+ function E3(n3, e3 = {}) {
16696
16693
  if (!n3) return [];
16697
16694
  if (Array.isArray(n3)) return n3;
16698
16695
  const t3 = [], o2 = /* @__PURE__ */ new Set();
@@ -16708,57 +16705,60 @@ function P3(n3, e3 = {}) {
16708
16705
  }
16709
16706
  return t3;
16710
16707
  }
16711
- async function x3(n3, e3, t3) {
16708
+ async function P3(n3, e3, t3) {
16712
16709
  if (e3.init && !e3.config.init) {
16713
- const o2 = e3.type || "unknown", s3 = n3.logger.scope(`transformer:${o2}`), r2 = { collector: n3, logger: s3, id: t3, config: e3.config, env: R3(e3.config.env) };
16710
+ const o2 = e3.type || "unknown", s3 = n3.logger.scope(`transformer:${o2}`), i2 = { collector: n3, logger: s3, id: t3, config: e3.config, env: $3(e3.config.env) };
16714
16711
  s3.debug("init");
16715
- const i2 = await Tt(e3.init, "TransformerInit", n3.hooks)(r2);
16716
- if (false === i2) return false;
16717
- e3.config = { ...i2 || e3.config, init: true }, s3.debug("init done");
16712
+ const r2 = await Tt(e3.init, "TransformerInit", n3.hooks)(i2);
16713
+ if (false === r2) return false;
16714
+ e3.config = { ...r2 || e3.config, init: true }, s3.debug("init done");
16718
16715
  }
16719
16716
  return true;
16720
16717
  }
16721
- async function S3(n3, e3, t3, o2, s3, r2) {
16722
- const i2 = e3.type || "unknown", a3 = n3.logger.scope(`transformer:${i2}`), c2 = { collector: n3, logger: a3, id: t3, ingest: s3, config: e3.config, env: { ...R3(e3.config.env), ...r2 ? { respond: r2 } : {} } };
16718
+ async function x3(n3, e3, t3, o2, s3, i2) {
16719
+ const r2 = e3.type || "unknown", a3 = n3.logger.scope(`transformer:${r2}`), c2 = { collector: n3, logger: a3, id: t3, ingest: s3, config: e3.config, env: { ...$3(e3.config.env), ...i2 ? { respond: i2 } : {} } };
16723
16720
  a3.debug("push", { event: o2.name });
16724
16721
  const u4 = await Tt(e3.push, "TransformerPush", n3.hooks)(o2, c2);
16725
16722
  return a3.debug("push done"), u4;
16726
16723
  }
16727
- async function $3(n3, e3, t3, o2, s3, r2) {
16728
- let i2 = o2;
16724
+ async function S3(n3, e3, t3, o2, s3, i2) {
16725
+ let r2 = o2, a3 = i2;
16729
16726
  for (const o3 of t3) {
16730
16727
  const t4 = e3[o3];
16731
16728
  if (!t4) {
16732
16729
  n3.logger.warn(`Transformer not found: ${o3}`);
16733
16730
  continue;
16734
16731
  }
16735
- if (!await bt(x3)(n3, t4, o3)) return n3.logger.error(`Transformer init failed: ${o3}`), null;
16736
- const a3 = await bt(S3, (e4) => (n3.logger.scope(`transformer:${t4.type || "unknown"}`).error("Push failed", { error: e4 }), false))(n3, t4, o3, i2, s3, r2);
16737
- if (false === a3) return null;
16738
- if (D3(a3)) {
16739
- const t5 = P3(a3.next, A3(e3));
16740
- return t5.length > 0 ? $3(n3, e3, t5, a3.event, s3, r2) : (n3.logger.warn(`Branch target not found: ${JSON.stringify(a3.next)}`), null);
16732
+ if (!await bt(P3)(n3, t4, o3)) return n3.logger.error(`Transformer init failed: ${o3}`), null;
16733
+ const i3 = await bt(x3, (e4) => (n3.logger.scope(`transformer:${t4.type || "unknown"}`).error("Push failed", { error: e4 }), false))(n3, t4, o3, r2, s3, a3);
16734
+ if (false === i3) return null;
16735
+ if (i3 && "object" == typeof i3) {
16736
+ const { event: t5, respond: o4, next: c2 } = i3;
16737
+ if (o4 && (a3 = o4), c2) {
16738
+ const o5 = E3(c2, D3(e3));
16739
+ return o5.length > 0 ? S3(n3, e3, o5, t5 || r2, s3, a3) : (n3.logger.warn(`Branch target not found: ${JSON.stringify(c2)}`), null);
16740
+ }
16741
+ t5 && (r2 = t5);
16741
16742
  }
16742
- void 0 !== a3 && (i2 = a3);
16743
16743
  }
16744
- return i2;
16744
+ return r2;
16745
16745
  }
16746
- function R3(n3) {
16746
+ function $3(n3) {
16747
16747
  return n3 && Z(n3) ? n3 : {};
16748
16748
  }
16749
- async function T3(n3, e3, t3) {
16750
- const { code: o2, config: s3 = {}, env: r2 = {}, primary: i2, next: a3 } = t3;
16749
+ async function R3(n3, e3, t3) {
16750
+ const { code: o2, config: s3 = {}, env: i2 = {}, primary: r2, next: a3 } = t3;
16751
16751
  let c2, u4;
16752
- const f2 = P3(a3, A3(n3.transformers)), l2 = n3.logger.scope("source").scope(e3), d2 = { push: (t4, o3 = {}) => n3.push(t4, { ...o3, id: e3, ingest: c2, respond: u4, mapping: s3, preChain: f2 }), command: n3.command, sources: n3.sources, elb: n3.sources.elb.push, logger: l2, ...r2 }, g2 = { collector: n3, logger: l2, id: e3, config: s3, env: d2, setIngest: async (e4) => {
16752
+ const f2 = E3(a3, D3(n3.transformers)), l2 = n3.logger.scope("source").scope(e3), d2 = { push: (t4, o3 = {}) => n3.push(t4, { ...o3, id: e3, ingest: c2, respond: u4, mapping: s3, preChain: f2 }), command: n3.command, sources: n3.sources, elb: n3.sources.elb.push, logger: l2, ...i2 }, g2 = { collector: n3, logger: l2, id: e3, config: s3, env: d2, setIngest: async (e4) => {
16753
16753
  c2 = s3.ingest ? await vt(e4, s3.ingest, { collector: n3 }) : void 0;
16754
16754
  }, setRespond: (n4) => {
16755
16755
  u4 = n4;
16756
16756
  } }, m2 = await bt(o2)(g2);
16757
16757
  if (!m2) return;
16758
16758
  const p2 = m2.type || "unknown", h2 = n3.logger.scope(p2).scope(e3);
16759
- return d2.logger = h2, i2 && (m2.config = { ...m2.config, primary: i2 }), m2;
16759
+ return d2.logger = h2, r2 && (m2.config = { ...m2.config, primary: r2 }), m2;
16760
16760
  }
16761
- async function I2(n3, e3 = {}) {
16761
+ async function T3(n3, e3 = {}) {
16762
16762
  const t3 = {};
16763
16763
  for (const [o2, s3] of Object.entries(e3)) {
16764
16764
  const { config: e4 = {} } = s3;
@@ -16766,81 +16766,81 @@ async function I2(n3, e3 = {}) {
16766
16766
  n3.pending.sources[o2] = s3;
16767
16767
  continue;
16768
16768
  }
16769
- const r2 = await T3(n3, o2, s3);
16770
- r2 && (t3[o2] = r2);
16769
+ const i2 = await R3(n3, o2, s3);
16770
+ i2 && (t3[o2] = i2);
16771
16771
  }
16772
16772
  return t3;
16773
16773
  }
16774
- async function B3(n3, e3, t3) {
16775
- const o2 = n3.on, s3 = o2[e3] || [], r2 = W(t3) ? t3 : [t3];
16776
- r2.forEach((n4) => {
16774
+ async function I2(n3, e3, t3) {
16775
+ const o2 = n3.on, s3 = o2[e3] || [], i2 = W(t3) ? t3 : [t3];
16776
+ i2.forEach((n4) => {
16777
16777
  s3.push(n4);
16778
- }), o2[e3] = s3, await H3(n3, e3, r2);
16778
+ }), o2[e3] = s3, await G3(n3, e3, i2);
16779
16779
  }
16780
- function G3(n3, e3, t3, o2, s3) {
16780
+ function B3(n3, e3, t3, o2, s3) {
16781
16781
  if (!e3.on) return;
16782
- const r2 = e3.type || "unknown", i2 = n3.logger.scope(r2).scope("on").scope(o2), a3 = { collector: n3, logger: i2, id: t3, config: e3.config, data: s3, env: L3(e3.env, e3.config.env) };
16782
+ const i2 = e3.type || "unknown", r2 = n3.logger.scope(i2).scope("on").scope(o2), a3 = { collector: n3, logger: r2, id: t3, config: e3.config, data: s3, env: L3(e3.env, e3.config.env) };
16783
16783
  yt(e3.on)(o2, a3);
16784
16784
  }
16785
- async function H3(n3, e3, o2, s3) {
16786
- let r2, i2 = o2 || [];
16787
- switch (o2 || (i2 = n3.on[e3] || []), e3) {
16785
+ async function G3(n3, e3, o2, s3) {
16786
+ let i2, r2 = o2 || [];
16787
+ switch (o2 || (r2 = n3.on[e3] || []), e3) {
16788
16788
  case t2.Commands.Consent:
16789
- r2 = s3 || n3.consent;
16789
+ i2 = s3 || n3.consent;
16790
16790
  break;
16791
16791
  case t2.Commands.Session:
16792
- r2 = n3.session;
16792
+ i2 = n3.session;
16793
16793
  break;
16794
16794
  case t2.Commands.User:
16795
- r2 = s3 || n3.user;
16795
+ i2 = s3 || n3.user;
16796
16796
  break;
16797
16797
  case t2.Commands.Custom:
16798
- r2 = s3 || n3.custom;
16798
+ i2 = s3 || n3.custom;
16799
16799
  break;
16800
16800
  case t2.Commands.Globals:
16801
- r2 = s3 || n3.globals;
16801
+ i2 = s3 || n3.globals;
16802
16802
  break;
16803
16803
  case t2.Commands.Config:
16804
- r2 = s3 || n3.config;
16804
+ i2 = s3 || n3.config;
16805
16805
  break;
16806
16806
  case t2.Commands.Ready:
16807
16807
  case t2.Commands.Run:
16808
16808
  default:
16809
- r2 = void 0;
16809
+ i2 = void 0;
16810
16810
  }
16811
16811
  let a3 = false;
16812
16812
  for (const t3 of Object.values(n3.sources)) if (t3.on) {
16813
- false === await bt(t3.on)(e3, r2) && (a3 = true);
16813
+ false === await bt(t3.on)(e3, i2) && (a3 = true);
16814
16814
  }
16815
16815
  if (Object.entries(n3.destinations).forEach(([t3, o3]) => {
16816
16816
  if (o3.on) {
16817
- if (!o3.config.init) return o3.queueOn = o3.queueOn || [], void o3.queueOn.push({ type: e3, data: r2 });
16818
- G3(n3, o3, t3, e3, r2);
16817
+ if (!o3.config.init) return o3.queueOn = o3.queueOn || [], void o3.queueOn.push({ type: e3, data: i2 });
16818
+ B3(n3, o3, t3, e3, i2);
16819
16819
  }
16820
16820
  }), (Object.keys(n3.pending.sources).length > 0 || Object.keys(n3.pending.destinations).length > 0) && await (async function(n4, e4) {
16821
16821
  for (const [t3, o3] of Object.entries(n4.pending.sources)) {
16822
16822
  if (!n4.pending.sources[t3] || n4.sources[t3]) continue;
16823
16823
  const s4 = o3.config?.require;
16824
16824
  if (!s4) continue;
16825
- const r3 = s4.indexOf(e4);
16826
- if (-1 === r3) continue;
16827
- if (s4.splice(r3, 1), s4.length > 0) continue;
16825
+ const i3 = s4.indexOf(e4);
16826
+ if (-1 === i3) continue;
16827
+ if (s4.splice(i3, 1), s4.length > 0) continue;
16828
16828
  delete n4.pending.sources[t3];
16829
- const i3 = await T3(n4, t3, o3);
16830
- i3 && (n4.sources[t3] = i3);
16829
+ const r3 = await R3(n4, t3, o3);
16830
+ r3 && (n4.sources[t3] = r3);
16831
16831
  }
16832
16832
  for (const [t3, o3] of Object.entries(n4.pending.destinations)) {
16833
16833
  if (!n4.pending.destinations[t3] || n4.destinations[t3]) continue;
16834
16834
  const s4 = o3.config?.require;
16835
16835
  if (!s4) continue;
16836
- const r3 = s4.indexOf(e4);
16837
- if (-1 === r3) continue;
16838
- if (s4.splice(r3, 1), s4.length > 0) continue;
16836
+ const i3 = s4.indexOf(e4);
16837
+ if (-1 === i3) continue;
16838
+ if (s4.splice(i3, 1), s4.length > 0) continue;
16839
16839
  delete n4.pending.destinations[t3];
16840
- const i3 = W3(o3);
16841
- false !== i3.config.queue && (i3.queuePush = [...n4.queue]), n4.destinations[t3] = i3;
16840
+ const r3 = W3(o3);
16841
+ false !== r3.config.queue && (r3.queuePush = [...n4.queue]), n4.destinations[t3] = r3;
16842
16842
  }
16843
- })(n3, e3), !i2.length) return !a3;
16843
+ })(n3, e3), !r2.length) return !a3;
16844
16844
  switch (e3) {
16845
16845
  case t2.Commands.Consent:
16846
16846
  !(function(n4, e4, t3) {
@@ -16850,7 +16850,7 @@ async function H3(n3, e3, o2, s3) {
16850
16850
  yt(e5[t4])(n4, o3);
16851
16851
  });
16852
16852
  });
16853
- })(n3, i2, s3);
16853
+ })(n3, r2, s3);
16854
16854
  break;
16855
16855
  case t2.Commands.Ready:
16856
16856
  case t2.Commands.Run:
@@ -16858,7 +16858,7 @@ async function H3(n3, e3, o2, s3) {
16858
16858
  n4.allowed && e4.forEach((e5) => {
16859
16859
  yt(e5)(n4);
16860
16860
  });
16861
- })(n3, i2);
16861
+ })(n3, r2);
16862
16862
  break;
16863
16863
  case t2.Commands.Session:
16864
16864
  !(function(n4, e4) {
@@ -16866,31 +16866,31 @@ async function H3(n3, e3, o2, s3) {
16866
16866
  e4.forEach((e5) => {
16867
16867
  yt(e5)(n4, n4.session);
16868
16868
  });
16869
- })(n3, i2);
16869
+ })(n3, r2);
16870
16870
  break;
16871
16871
  default:
16872
- i2.forEach((e4) => {
16873
- "function" == typeof e4 && yt(e4)(n3, r2);
16872
+ r2.forEach((e4) => {
16873
+ "function" == typeof e4 && yt(e4)(n3, i2);
16874
16874
  });
16875
16875
  }
16876
16876
  return !a3;
16877
16877
  }
16878
- async function U2(n3, e3, t3) {
16879
- const { code: o2, config: s3 = {}, env: r2 = {}, before: i2 } = e3;
16878
+ async function H3(n3, e3, t3) {
16879
+ const { code: o2, config: s3 = {}, env: i2 = {}, before: r2 } = e3;
16880
16880
  if (!B(o2.push)) return N3({ ok: false, failed: { invalid: { type: "invalid", error: "Destination code must have a push method" } } });
16881
- const a3 = t3 || s3 || { init: false }, c2 = i2 ? { ...a3, before: i2 } : a3, u4 = { ...o2, config: c2, env: L3(o2.env, r2) };
16881
+ const a3 = t3 || s3 || { init: false }, c2 = r2 ? { ...a3, before: r2 } : a3, u4 = { ...o2, config: c2, env: L3(o2.env, i2) };
16882
16882
  let l2 = u4.config.id;
16883
16883
  if (!l2) do {
16884
16884
  l2 = rt(4);
16885
16885
  } while (n3.destinations[l2]);
16886
- return n3.destinations[l2] = u4, false !== u4.config.queue && (u4.queuePush = [...n3.queue]), _3(n3, void 0, {}, { [l2]: u4 });
16886
+ return n3.destinations[l2] = u4, false !== u4.config.queue && (u4.queuePush = [...n3.queue]), U2(n3, void 0, {}, { [l2]: u4 });
16887
16887
  }
16888
- async function _3(n3, e3, t3 = {}, o2) {
16889
- const { allowed: s3, consent: r2, globals: i2, user: u4 } = n3;
16888
+ async function U2(n3, e3, t3 = {}, o2) {
16889
+ const { allowed: s3, consent: i2, globals: r2, user: u4 } = n3;
16890
16890
  if (!s3) return N3({ ok: false });
16891
16891
  e3 && (n3.queue.push(e3), n3.status.in++), o2 || (o2 = n3.destinations);
16892
16892
  const f2 = await Promise.all(Object.entries(o2 || {}).map(async ([o3, s4]) => {
16893
- let f3 = (s4.queuePush || []).map((n4) => ({ ...n4, consent: r2 }));
16893
+ let f3 = (s4.queuePush || []).map((n4) => ({ ...n4, consent: i2 }));
16894
16894
  if (s4.queuePush = [], e3) {
16895
16895
  const n4 = G(e3);
16896
16896
  f3.push(n4);
@@ -16901,7 +16901,7 @@ async function _3(n3, e3, t3 = {}, o2) {
16901
16901
  return { id: o3, destination: s4, skipped: !e4 };
16902
16902
  }
16903
16903
  const d3 = [], g3 = f3.filter((n4) => {
16904
- const e4 = tt(s4.config.consent, r2, n4.consent);
16904
+ const e4 = tt(s4.config.consent, i2, n4.consent);
16905
16905
  return !e4 || (n4.consent = e4, d3.push(n4), false);
16906
16906
  });
16907
16907
  if (s4.queuePush.push(...g3), !d3.length) return { id: o3, destination: s4, queue: f3 };
@@ -16910,21 +16910,21 @@ async function _3(n3, e3, t3 = {}, o2) {
16910
16910
  s4.dlq || (s4.dlq = []);
16911
16911
  const w2 = (function(n4, e4) {
16912
16912
  const t4 = n4.config.before;
16913
- return t4 ? P3(t4, A3(e4)) : [];
16913
+ return t4 ? E3(t4, D3(e4)) : [];
16914
16914
  })(s4, n3.transformers);
16915
16915
  let y2 = 0;
16916
16916
  return await Promise.all(d3.map(async (e4) => {
16917
- e4.globals = H(i2, e4.globals), e4.user = H(u4, e4.user);
16918
- let r3 = e4;
16917
+ e4.globals = H(r2, e4.globals), e4.user = H(u4, e4.user);
16918
+ let i3 = e4;
16919
16919
  if (w2.length > 0 && n3.transformers && Object.keys(n3.transformers).length > 0) {
16920
- const o4 = await $3(n3, n3.transformers, w2, e4, t3.ingest, t3.respond);
16920
+ const o4 = await S3(n3, n3.transformers, w2, e4, t3.ingest, t3.respond);
16921
16921
  if (null === o4) return e4;
16922
- r3 = o4;
16922
+ i3 = o4;
16923
16923
  }
16924
16924
  const c2 = Date.now(), f4 = await bt(J3, (e5) => {
16925
16925
  const t4 = s4.type || "unknown";
16926
- n3.logger.scope(t4).error("Push failed", { error: e5, event: r3.name }), m3 = e5, s4.dlq.push([r3, e5]);
16927
- })(n3, s4, o3, r3, t3.ingest, t3.respond);
16926
+ n3.logger.scope(t4).error("Push failed", { error: e5, event: i3.name }), m3 = e5, s4.dlq.push([i3, e5]);
16927
+ })(n3, s4, o3, i3, t3.ingest, t3.respond);
16928
16928
  return y2 += Date.now() - c2, void 0 !== f4 && (p2 = f4), e4;
16929
16929
  })), { id: o3, destination: s4, error: m3, response: p2, totalDuration: y2 };
16930
16930
  })), d2 = {}, g2 = {}, m2 = {};
@@ -16932,30 +16932,30 @@ async function _3(n3, e3, t3 = {}, o2) {
16932
16932
  if (e4.skipped) continue;
16933
16933
  const t4 = e4.destination, o3 = { type: t4.type || "unknown", data: e4.response };
16934
16934
  n3.status.destinations[e4.id] || (n3.status.destinations[e4.id] = { count: 0, failed: 0, duration: 0 });
16935
- const s4 = n3.status.destinations[e4.id], r3 = Date.now();
16936
- e4.error ? (o3.error = e4.error, m2[e4.id] = o3, s4.failed++, s4.lastAt = r3, s4.duration += e4.totalDuration || 0, n3.status.failed++) : e4.queue && e4.queue.length ? (t4.queuePush = (t4.queuePush || []).concat(e4.queue), g2[e4.id] = o3) : (d2[e4.id] = o3, s4.count++, s4.lastAt = r3, s4.duration += e4.totalDuration || 0, n3.status.out++);
16935
+ const s4 = n3.status.destinations[e4.id], i3 = Date.now();
16936
+ e4.error ? (o3.error = e4.error, m2[e4.id] = o3, s4.failed++, s4.lastAt = i3, s4.duration += e4.totalDuration || 0, n3.status.failed++) : e4.queue && e4.queue.length ? (t4.queuePush = (t4.queuePush || []).concat(e4.queue), g2[e4.id] = o3) : (d2[e4.id] = o3, s4.count++, s4.lastAt = i3, s4.duration += e4.totalDuration || 0, n3.status.out++);
16937
16937
  }
16938
16938
  return N3({ event: e3, ...Object.keys(d2).length && { done: d2 }, ...Object.keys(g2).length && { queued: g2 }, ...Object.keys(m2).length && { failed: m2 } });
16939
16939
  }
16940
16940
  async function F3(n3, e3, t3) {
16941
16941
  if (e3.init && !e3.config.init) {
16942
- const o2 = e3.type || "unknown", s3 = n3.logger.scope(o2), r2 = { collector: n3, logger: s3, id: t3, config: e3.config, env: L3(e3.env, e3.config.env) };
16942
+ const o2 = e3.type || "unknown", s3 = n3.logger.scope(o2), i2 = { collector: n3, logger: s3, id: t3, config: e3.config, env: L3(e3.env, e3.config.env) };
16943
16943
  s3.debug("init");
16944
- const i2 = await Tt(e3.init, "DestinationInit", n3.hooks)(r2);
16945
- if (false === i2) return i2;
16946
- if (e3.config = { ...i2 || e3.config, init: true }, e3.queueOn?.length) {
16944
+ const r2 = await Tt(e3.init, "DestinationInit", n3.hooks)(i2);
16945
+ if (false === r2) return r2;
16946
+ if (e3.config = { ...r2 || e3.config, init: true }, e3.queueOn?.length) {
16947
16947
  const o3 = e3.queueOn;
16948
16948
  e3.queueOn = [];
16949
- for (const { type: s4, data: r3 } of o3) G3(n3, e3, t3, s4, r3);
16949
+ for (const { type: s4, data: i3 } of o3) B3(n3, e3, t3, s4, i3);
16950
16950
  }
16951
16951
  s3.debug("init done");
16952
16952
  }
16953
16953
  return true;
16954
16954
  }
16955
- async function J3(n3, e3, t3, o2, s3, r2) {
16956
- const { config: i2 } = e3, a3 = await jt(o2, i2, n3);
16955
+ async function J3(n3, e3, t3, o2, s3, i2) {
16956
+ const { config: r2 } = e3, a3 = await jt(o2, r2, n3);
16957
16957
  if (a3.ignore) return false;
16958
- const c2 = e3.type || "unknown", f2 = n3.logger.scope(c2), l2 = { collector: n3, logger: f2, id: t3, config: i2, data: a3.data, rule: a3.mapping, ingest: s3, env: { ...L3(e3.env, i2.env), ...r2 ? { respond: r2 } : {} } }, g2 = a3.mapping, m2 = a3.mappingKey || "* *";
16958
+ const c2 = e3.type || "unknown", f2 = n3.logger.scope(c2), l2 = { collector: n3, logger: f2, id: t3, config: r2, data: a3.data, rule: a3.mapping, ingest: s3, env: { ...L3(e3.env, r2.env), ...i2 ? { respond: i2 } : {} } }, g2 = a3.mapping, m2 = a3.mappingKey || "* *";
16959
16959
  if (!g2?.batch || !e3.pushBatch) {
16960
16960
  f2.debug("push", { event: a3.event.name });
16961
16961
  const t4 = await Tt(e3.push, "DestinationPush", n3.hooks)(a3.event, l2);
@@ -16965,7 +16965,7 @@ async function J3(n3, e3, t3, o2, s3, r2) {
16965
16965
  if (e3.batches = e3.batches || {}, !e3.batches[m2]) {
16966
16966
  const o4 = { key: m2, events: [], data: [] };
16967
16967
  e3.batches[m2] = { batched: o4, batchFn: st(() => {
16968
- const o5 = e3.batches[m2].batched, a4 = { collector: n3, logger: f2, id: t3, config: i2, data: void 0, rule: g2, ingest: s3, env: { ...L3(e3.env, i2.env), ...r2 ? { respond: r2 } : {} } };
16968
+ const o5 = e3.batches[m2].batched, a4 = { collector: n3, logger: f2, id: t3, config: r2, data: void 0, rule: g2, ingest: s3, env: { ...L3(e3.env, r2.env), ...i2 ? { respond: i2 } : {} } };
16969
16969
  f2.debug("push batch", { events: o5.events.length }), Tt(e3.pushBatch, "DestinationPushBatch", n3.hooks)(o5, a4), f2.debug("push batch done"), o5.events = [], o5.data = [];
16970
16970
  }, g2.batch) };
16971
16971
  }
@@ -16978,8 +16978,8 @@ function N3(n3) {
16978
16978
  return { ok: !n3?.failed, ...n3 };
16979
16979
  }
16980
16980
  function W3(n3) {
16981
- const { code: e3, config: t3 = {}, env: o2 = {} } = n3, { config: s3 } = E3(n3, "before"), r2 = { ...e3.config, ...t3, ...s3 }, i2 = L3(e3.env, o2);
16982
- return { ...e3, config: r2, env: i2 };
16981
+ const { code: e3, config: t3 = {}, env: o2 = {} } = n3, { config: s3 } = A3(n3, "before"), i2 = { ...e3.config, ...t3, ...s3 }, r2 = L3(e3.env, o2);
16982
+ return { ...e3, config: i2, env: r2 };
16983
16983
  }
16984
16984
  async function z4(n3, e3 = {}) {
16985
16985
  const t3 = {};
@@ -16989,21 +16989,21 @@ async function z4(n3, e3 = {}) {
16989
16989
  function L3(n3, e3) {
16990
16990
  return n3 || e3 ? e3 ? n3 && Z(n3) && Z(e3) ? { ...n3, ...e3 } : e3 : n3 : {};
16991
16991
  }
16992
- async function Y2(n3, e3, t3) {
16992
+ async function X3(n3, e3, t3) {
16993
16993
  const o2 = Object.entries(n3).map(async ([n4, o3]) => {
16994
16994
  const s3 = o3.destroy;
16995
16995
  if (!s3) return;
16996
- const r2 = o3.type || "unknown", i2 = t3.scope(r2), a3 = { id: n4, config: o3.config, env: o3.env ?? {}, logger: i2 };
16996
+ const i2 = o3.type || "unknown", r2 = t3.scope(i2), a3 = { id: n4, config: o3.config, env: o3.env ?? {}, logger: r2 };
16997
16997
  try {
16998
16998
  await Promise.race([s3(a3), new Promise((t4, o4) => setTimeout(() => o4(new Error(`${e3} '${n4}' destroy timed out`)), 5e3))]);
16999
16999
  } catch (t4) {
17000
- i2.error(`${e3} '${n4}' destroy failed: ${t4}`);
17000
+ r2.error(`${e3} '${n4}' destroy failed: ${t4}`);
17001
17001
  }
17002
17002
  });
17003
17003
  await Promise.allSettled(o2);
17004
17004
  }
17005
- async function Z3(n3, e3, o2, r2) {
17006
- let i2, a3, c2 = false, u4 = false;
17005
+ async function Y2(n3, e3, o2, i2) {
17006
+ let r2, a3, c2 = false, u4 = false;
17007
17007
  switch (e3) {
17008
17008
  case t2.Commands.Config:
17009
17009
  Z(o2) && (H(n3.config, o2, { shallow: false }), a3 = o2, c2 = true);
@@ -17018,19 +17018,19 @@ async function Z3(n3, e3, o2, r2) {
17018
17018
  Z(o2) && (n3.custom = H(n3.custom, o2), a3 = o2, c2 = true);
17019
17019
  break;
17020
17020
  case t2.Commands.Destination:
17021
- Z(o2) && ("code" in o2 && Z(o2.code) ? i2 = await U2(n3, o2, r2) : B(o2.push) && (i2 = await U2(n3, { code: o2 }, r2)));
17021
+ Z(o2) && ("code" in o2 && Z(o2.code) ? r2 = await H3(n3, o2, i2) : B(o2.push) && (r2 = await H3(n3, { code: o2 }, i2)));
17022
17022
  break;
17023
17023
  case t2.Commands.Globals:
17024
17024
  Z(o2) && (n3.globals = H(n3.globals, o2), a3 = o2, c2 = true);
17025
17025
  break;
17026
17026
  case t2.Commands.On:
17027
- q(o2) && await B3(n3, o2, r2);
17027
+ q(o2) && await I2(n3, o2, i2);
17028
17028
  break;
17029
17029
  case t2.Commands.Ready:
17030
17030
  c2 = true;
17031
17031
  break;
17032
17032
  case t2.Commands.Run:
17033
- i2 = await en2(n3, o2), c2 = true;
17033
+ r2 = await nn2(n3, o2), c2 = true;
17034
17034
  break;
17035
17035
  case t2.Commands.Session:
17036
17036
  c2 = true;
@@ -17038,33 +17038,33 @@ async function Z3(n3, e3, o2, r2) {
17038
17038
  case t2.Commands.Shutdown:
17039
17039
  await (async function(n4) {
17040
17040
  const e4 = n4.logger;
17041
- await Y2(n4.sources, "source", e4), await Y2(n4.destinations, "destination", e4), await Y2(n4.transformers, "transformer", e4);
17041
+ await X3(n4.sources, "source", e4), await X3(n4.destinations, "destination", e4), await X3(n4.transformers, "transformer", e4);
17042
17042
  })(n3);
17043
17043
  break;
17044
17044
  case t2.Commands.User:
17045
17045
  Z(o2) && (H(n3.user, o2, { shallow: false }), a3 = o2, c2 = true);
17046
17046
  }
17047
- return c2 && await H3(n3, e3, void 0, a3), u4 && (i2 = await _3(n3)), i2 || N3({ ok: true });
17047
+ return c2 && await G3(n3, e3, void 0, a3), u4 && (r2 = await U2(n3)), r2 || N3({ ok: true });
17048
17048
  }
17049
- function nn2(n3, e3) {
17049
+ function Z3(n3, e3) {
17050
17050
  if (!e3.name) throw new Error("Event name is required");
17051
17051
  const [t3, o2] = e3.name.split(" ");
17052
17052
  if (!t3 || !o2) throw new Error("Event name is invalid");
17053
17053
  ++n3.count;
17054
- const { timestamp: s3 = Date.now(), group: r2 = n3.group, count: i2 = n3.count } = e3, { name: a3 = `${t3} ${o2}`, data: c2 = {}, context: u4 = {}, globals: f2 = n3.globals, custom: l2 = {}, user: d2 = n3.user, nested: g2 = [], consent: m2 = n3.consent, id: p2 = `${s3}-${r2}-${i2}`, trigger: h2 = "", entity: w2 = t3, action: y2 = o2, timing: b2 = 0, version: v2 = { source: n3.version, tagging: n3.config.tagging || 0 }, source: k3 = { type: "collector", id: "", previous_id: "" } } = e3;
17055
- return { name: a3, data: c2, context: u4, globals: f2, custom: l2, user: d2, nested: g2, consent: m2, id: p2, trigger: h2, entity: w2, action: y2, timestamp: s3, timing: b2, group: r2, count: i2, version: v2, source: k3 };
17054
+ const { timestamp: s3 = Date.now(), group: i2 = n3.group, count: r2 = n3.count } = e3, { name: a3 = `${t3} ${o2}`, data: c2 = {}, context: u4 = {}, globals: f2 = n3.globals, custom: l2 = {}, user: d2 = n3.user, nested: g2 = [], consent: m2 = n3.consent, id: p2 = `${s3}-${i2}-${r2}`, trigger: h2 = "", entity: w2 = t3, action: y2 = o2, timing: b2 = 0, version: v2 = { source: n3.version, tagging: n3.config.tagging || 0 }, source: k3 = { type: "collector", id: "", previous_id: "" } } = e3;
17055
+ return { name: a3, data: c2, context: u4, globals: f2, custom: l2, user: d2, nested: g2, consent: m2, id: p2, trigger: h2, entity: w2, action: y2, timestamp: s3, timing: b2, group: i2, count: r2, version: v2, source: k3 };
17056
17056
  }
17057
- async function en2(n3, e3) {
17057
+ async function nn2(n3, e3) {
17058
17058
  n3.allowed = true, n3.count = 0, n3.group = rt(), n3.timing = Date.now(), e3 && (e3.consent && (n3.consent = H(n3.consent, e3.consent)), e3.user && (n3.user = H(n3.user, e3.user)), e3.globals && (n3.globals = H(n3.config.globalsStatic || {}, e3.globals)), e3.custom && (n3.custom = H(n3.custom, e3.custom))), Object.values(n3.destinations).forEach((n4) => {
17059
17059
  n4.queuePush = [];
17060
17060
  }), n3.queue = [], n3.round++;
17061
- return await _3(n3);
17061
+ return await U2(n3);
17062
17062
  }
17063
- function an2(n3, e3) {
17063
+ function rn2(n3, e3) {
17064
17064
  return Tt(async (t3, o2 = {}) => await bt(async () => {
17065
- const s3 = Date.now(), { id: r2, ingest: i2, respond: a3, mapping: c2, preChain: u4 } = o2;
17065
+ const s3 = Date.now(), { id: i2, ingest: r2, respond: a3, mapping: c2, preChain: u4 } = o2;
17066
17066
  let f2 = t3;
17067
- const l2 = i2 ? Object.freeze(i2) : void 0;
17067
+ const l2 = r2 ? Object.freeze(r2) : void 0;
17068
17068
  if (c2) {
17069
17069
  const e4 = await jt(f2, c2, n3);
17070
17070
  if (e4.ignore) return N3({ ok: true });
@@ -17074,35 +17074,35 @@ function an2(n3, e3) {
17074
17074
  f2 = e4.event;
17075
17075
  }
17076
17076
  if (u4?.length && n3.transformers && Object.keys(n3.transformers).length > 0) {
17077
- const e4 = await $3(n3, n3.transformers, u4, f2, l2, a3);
17077
+ const e4 = await S3(n3, n3.transformers, u4, f2, l2, a3);
17078
17078
  if (null === e4) return N3({ ok: true });
17079
17079
  f2 = e4;
17080
17080
  }
17081
- const d2 = e3(f2), g2 = nn2(n3, d2), m2 = await _3(n3, g2, { id: r2, ingest: l2, respond: a3 });
17082
- if (r2) {
17083
- n3.status.sources[r2] || (n3.status.sources[r2] = { count: 0, duration: 0 });
17084
- const e4 = n3.status.sources[r2];
17081
+ const d2 = e3(f2), g2 = Z3(n3, d2), m2 = await U2(n3, g2, { id: i2, ingest: l2, respond: a3 });
17082
+ if (i2) {
17083
+ n3.status.sources[i2] || (n3.status.sources[i2] = { count: 0, duration: 0 });
17084
+ const e4 = n3.status.sources[i2];
17085
17085
  e4.count++, e4.lastAt = Date.now(), e4.duration += Date.now() - s3;
17086
17086
  }
17087
17087
  return m2;
17088
17088
  }, () => N3({ ok: false }))(), "Push", n3.hooks);
17089
17089
  }
17090
- async function fn2(n3) {
17091
- const e3 = H({ globalsStatic: {}, sessionStatic: {}, tagging: 0, run: true }, n3, { merge: false, extend: false }), t3 = { level: n3.logger?.level, handler: n3.logger?.handler }, o2 = lt(t3), s3 = { ...e3.globalsStatic, ...n3.globals }, a3 = { allowed: false, config: e3, consent: n3.consent || {}, count: 0, custom: n3.custom || {}, destinations: {}, transformers: {}, globals: s3, group: "", hooks: {}, logger: o2, on: {}, queue: [], round: 0, session: void 0, status: { startedAt: Date.now(), in: 0, out: 0, failed: 0, sources: {}, destinations: {} }, timing: Date.now(), user: n3.user || {}, version: "2.0.1", sources: {}, pending: { sources: {}, destinations: {} }, push: void 0, command: void 0 };
17092
- return a3.push = an2(a3, (n4) => ({ timing: Math.round((Date.now() - a3.timing) / 10) / 100, source: { type: "collector", id: "", previous_id: "" }, ...n4 })), a3.command = (function(n4, e4) {
17090
+ async function un2(n3) {
17091
+ const e3 = H({ globalsStatic: {}, sessionStatic: {}, tagging: 0, run: true }, n3, { merge: false, extend: false }), t3 = { level: n3.logger?.level, handler: n3.logger?.handler }, o2 = lt(t3), s3 = { ...e3.globalsStatic, ...n3.globals }, a3 = { allowed: false, config: e3, consent: n3.consent || {}, count: 0, custom: n3.custom || {}, destinations: {}, transformers: {}, globals: s3, group: "", hooks: {}, logger: o2, on: {}, queue: [], round: 0, session: void 0, status: { startedAt: Date.now(), in: 0, out: 0, failed: 0, sources: {}, destinations: {} }, timing: Date.now(), user: n3.user || {}, version: "2.1.0", sources: {}, pending: { sources: {}, destinations: {} }, push: void 0, command: void 0 };
17092
+ return a3.push = rn2(a3, (n4) => ({ timing: Math.round((Date.now() - a3.timing) / 10) / 100, source: { type: "collector", id: "", previous_id: "" }, ...n4 })), a3.command = (function(n4, e4) {
17093
17093
  return Tt(async (t4, o3, s4) => await bt(async () => await e4(n4, t4, o3, s4), () => N3({ ok: false }))(), "Command", n4.hooks);
17094
- })(a3, Z3), a3.destinations = await z4(a3, n3.destinations || {}), a3.transformers = await (async function(n4, e4 = {}) {
17094
+ })(a3, Y2), a3.destinations = await z4(a3, n3.destinations || {}), a3.transformers = await (async function(n4, e4 = {}) {
17095
17095
  const t4 = {};
17096
17096
  for (const [o3, s4] of Object.entries(e4)) {
17097
- const { code: e5, env: r2 = {} } = s4, { config: i2 } = E3(s4, "next"), a4 = n4.logger.scope("transformer").scope(o3), c2 = { collector: n4, logger: a4, id: o3, config: i2, env: r2 }, u4 = await e5(c2);
17097
+ const { code: e5, env: i2 = {} } = s4, { config: r2 } = A3(s4, "next"), a4 = n4.logger.scope("transformer").scope(o3), c2 = { collector: n4, logger: a4, id: o3, config: r2, env: i2 }, u4 = await e5(c2);
17098
17098
  t4[o3] = u4;
17099
17099
  }
17100
17100
  return t4;
17101
17101
  })(a3, n3.transformers || {}), a3;
17102
17102
  }
17103
- async function ln2(n3) {
17103
+ async function fn2(n3) {
17104
17104
  n3 = n3 || {};
17105
- const e3 = await fn2(n3), t3 = (o2 = e3, { type: "elb", config: {}, push: async (n4, e4, t4, s4, r3, i3) => {
17105
+ const e3 = await un2(n3), t3 = (o2 = e3, { type: "elb", config: {}, push: async (n4, e4, t4, s4, i3, r3) => {
17106
17106
  if ("string" == typeof n4 && n4.startsWith("walker ")) {
17107
17107
  const s5 = n4.replace("walker ", "");
17108
17108
  return o2.command(s5, e4, t4);
@@ -17113,76 +17113,76 @@ async function ln2(n3) {
17113
17113
  if (!n4 || "object" != typeof n4) return N3({ ok: false });
17114
17114
  a4 = n4, e4 && "object" == typeof e4 && !Array.isArray(e4) && (a4.data = { ...a4.data || {}, ...e4 });
17115
17115
  }
17116
- return s4 && "object" == typeof s4 && (a4.context = s4), r3 && Array.isArray(r3) && (a4.nested = r3), i3 && "object" == typeof i3 && (a4.custom = i3), o2.push(a4);
17116
+ return s4 && "object" == typeof s4 && (a4.context = s4), i3 && Array.isArray(i3) && (a4.nested = i3), r3 && "object" == typeof r3 && (a4.custom = r3), o2.push(a4);
17117
17117
  } });
17118
17118
  var o2;
17119
17119
  e3.sources.elb = t3;
17120
- const s3 = await I2(e3, n3.sources || {});
17120
+ const s3 = await T3(e3, n3.sources || {});
17121
17121
  Object.assign(e3.sources, s3);
17122
- const { consent: r2, user: i2, globals: a3, custom: c2 } = n3;
17123
- r2 && await e3.command("consent", r2), i2 && await e3.command("user", i2), a3 && Object.assign(e3.globals, a3), c2 && Object.assign(e3.custom, c2), e3.config.run && await e3.command("run");
17122
+ const { consent: i2, user: r2, globals: a3, custom: c2 } = n3;
17123
+ i2 && await e3.command("consent", i2), r2 && await e3.command("user", r2), a3 && Object.assign(e3.globals, a3), c2 && Object.assign(e3.custom, c2), e3.config.run && await e3.command("run");
17124
17124
  let u4 = t3.push;
17125
17125
  const f2 = Object.values(e3.sources).filter((n4) => "elb" !== n4.type), l2 = f2.find((n4) => n4.config.primary);
17126
17126
  return l2 ? u4 = l2.push : f2.length > 0 && (u4 = f2[0].push), { collector: e3, elb: u4 };
17127
17127
  }
17128
- function dn2(n3) {
17128
+ function ln2(n3) {
17129
17129
  if (null === n3 || "object" != typeof n3) return n3;
17130
- if (Array.isArray(n3)) return n3.map(dn2);
17130
+ if (Array.isArray(n3)) return n3.map(ln2);
17131
17131
  const e3 = {};
17132
- for (const [t3, o2] of Object.entries(n3)) e3[t3] = "function" == typeof o2 ? o2 : dn2(o2);
17132
+ for (const [t3, o2] of Object.entries(n3)) e3[t3] = "function" == typeof o2 ? o2 : ln2(o2);
17133
17133
  return e3;
17134
17134
  }
17135
- function gn2(n3) {
17136
- const e3 = [], { simulation: t3, ...o2 } = n3, s3 = dn2(o2);
17135
+ function dn2(n3) {
17136
+ const e3 = [], { simulation: t3, ...o2 } = n3, s3 = ln2(o2);
17137
17137
  for (const n4 of t3) {
17138
17138
  const t4 = n4.startsWith("call:") ? n4.slice(5) : n4, o3 = t4.split(".");
17139
- let r2 = s3;
17140
- for (let n5 = 0; n5 < o3.length - 1 && null != r2[o3[n5]]; n5++) r2 = r2[o3[n5]];
17141
- const i2 = o3[o3.length - 1];
17142
- if (null == r2 || !(i2 in r2)) continue;
17143
- const a3 = r2[i2];
17144
- "function" == typeof a3 && (r2[i2] = function(...n5) {
17139
+ let i2 = s3;
17140
+ for (let n5 = 0; n5 < o3.length - 1 && null != i2[o3[n5]]; n5++) i2 = i2[o3[n5]];
17141
+ const r2 = o3[o3.length - 1];
17142
+ if (null == i2 || !(r2 in i2)) continue;
17143
+ const a3 = i2[r2];
17144
+ "function" == typeof a3 && (i2[r2] = function(...n5) {
17145
17145
  return e3.push({ fn: t4, args: n5, ts: Date.now() }), a3.apply(this, n5);
17146
17146
  });
17147
17147
  }
17148
17148
  return { wrappedEnv: s3, calls: e3 };
17149
17149
  }
17150
- async function mn2(n3) {
17150
+ async function gn2(n3) {
17151
17151
  const e3 = Date.now();
17152
17152
  try {
17153
17153
  switch (n3.step) {
17154
17154
  case "transformer":
17155
17155
  return await (async function(n4, e4) {
17156
- const { code: t3, config: o2 = {}, event: s3 } = n4, { collector: r2 } = await ln2({ transformers: { sim: { code: t3, config: o2 } } }), i2 = r2.transformers?.sim;
17157
- if (!i2) throw new Error("Transformer failed to initialize");
17158
- const a3 = await i2.push(s3, { collector: r2, logger: r2.logger.scope("transformer").scope("sim"), id: "sim", config: i2.config, env: i2.config?.env || {} });
17156
+ const { code: t3, config: o2 = {}, event: s3 } = n4, { collector: i2 } = await fn2({ transformers: { sim: { code: t3, config: o2 } } }), r2 = i2.transformers?.sim;
17157
+ if (!r2) throw new Error("Transformer failed to initialize");
17158
+ const a3 = await r2.push(s3, { collector: i2, logger: i2.logger.scope("transformer").scope("sim"), id: "sim", config: r2.config, env: r2.config?.env || {} });
17159
17159
  let c2;
17160
- c2 = false === a3 ? [] : null == a3 ? [s3] : [a3];
17160
+ c2 = false === a3 ? [] : null == a3 ? [s3] : [a3.event || s3];
17161
17161
  return { step: "transformer", name: n4.name, events: c2, calls: [], duration: Date.now() - e4 };
17162
17162
  })(n3, e3);
17163
17163
  case "source":
17164
17164
  return await (async function(n4, e4) {
17165
- const { code: t3, config: o2 = {}, setup: s3, input: r2, env: i2, consent: a3 } = n4, c2 = { functional: true, marketing: true, analytics: true };
17165
+ const { code: t3, config: o2 = {}, setup: s3, input: i2, env: r2, consent: a3 } = n4, c2 = { functional: true, marketing: true, analytics: true };
17166
17166
  let u4;
17167
17167
  if (s3) {
17168
- const n5 = s3(r2, i2);
17168
+ const n5 = s3(i2, r2);
17169
17169
  "function" == typeof n5 && (u4 = n5);
17170
17170
  }
17171
- const f2 = [], { collector: l2 } = await ln2({ consent: a3 || c2, sources: { sim: { code: t3, config: o2, env: i2, next: "spy" } }, transformers: { spy: { code: () => ({ type: "spy", config: {}, push: (n5) => (f2.push(JSON.parse(JSON.stringify(n5))), n5) }) } } });
17171
+ const f2 = [], { collector: l2 } = await fn2({ consent: a3 || c2, sources: { sim: { code: t3, config: o2, env: r2, next: "spy" } }, transformers: { spy: { code: () => ({ type: "spy", config: {}, push: (n5) => (f2.push(JSON.parse(JSON.stringify(n5))), { event: n5 }) }) } } });
17172
17172
  u4 && u4();
17173
17173
  return { step: "source", name: n4.name, events: f2, calls: [], duration: Date.now() - e4 };
17174
17174
  })(n3, e3);
17175
17175
  case "destination":
17176
17176
  return await (async function(n4, e4) {
17177
- const { code: t3, config: o2 = {}, event: s3, consent: r2, env: i2, track: a3 } = n4, c2 = { functional: true, marketing: true, analytics: true };
17178
- let u4 = [], f2 = i2;
17179
- if (i2 && a3 && a3.length > 0) {
17180
- const n5 = gn2({ ...i2, simulation: a3 });
17177
+ const { code: t3, config: o2 = {}, event: s3, consent: i2, env: r2, track: a3 } = n4, c2 = { functional: true, marketing: true, analytics: true };
17178
+ let u4 = [], f2 = r2;
17179
+ if (r2 && a3 && a3.length > 0) {
17180
+ const n5 = dn2({ ...r2, simulation: a3 });
17181
17181
  f2 = n5.wrappedEnv, u4 = n5.calls;
17182
17182
  }
17183
17183
  const l2 = { ...o2 };
17184
17184
  f2 && (l2.env = f2);
17185
- const { collector: d2 } = await ln2({ consent: r2 || c2, destinations: { sim: { code: t3, config: l2 } } });
17185
+ const { collector: d2 } = await fn2({ consent: i2 || c2, destinations: { sim: { code: t3, config: l2 } } });
17186
17186
  return await d2.push(s3), { step: "destination", name: n4.name, events: [], calls: u4, duration: Date.now() - e4 };
17187
17187
  })(n3, e3);
17188
17188
  }
@@ -17396,7 +17396,7 @@ async function executeConfigSimulation(_content, configPath, typedEvent, tempDir
17396
17396
  const destinations = flowConfig.destinations;
17397
17397
  const envs = await loadDestinationEnvs(destinations || {});
17398
17398
  const destEnv = envs[step.name];
17399
- const result = await mn2({
17399
+ const result = await gn2({
17400
17400
  step: "destination",
17401
17401
  name: step.name,
17402
17402
  code,
@@ -17421,7 +17421,7 @@ async function executeConfigSimulation(_content, configPath, typedEvent, tempDir
17421
17421
  }
17422
17422
  const mod = await import(packageName);
17423
17423
  const code = mod.default || Object.values(mod)[0];
17424
- const result = await mn2({
17424
+ const result = await gn2({
17425
17425
  step: "transformer",
17426
17426
  name: step.name,
17427
17427
  code,
@@ -17493,7 +17493,7 @@ async function simulateSourceCLI(flowConfig, setupInput, options) {
17493
17493
  document: dom.window.document,
17494
17494
  localStorage: dom.window.localStorage
17495
17495
  };
17496
- const result = await mn2({
17496
+ const result = await gn2({
17497
17497
  step: "source",
17498
17498
  name: options.sourceStep,
17499
17499
  code,
@@ -18051,7 +18051,7 @@ async function executeServerPush(bundlePath, event, logger2, timeout = 6e4, cont
18051
18051
  const startTime = Date.now();
18052
18052
  let timer;
18053
18053
  try {
18054
- const timeoutPromise = new Promise((_4, reject) => {
18054
+ const timeoutPromise = new Promise((_3, reject) => {
18055
18055
  timer = setTimeout(
18056
18056
  () => reject(new Error(`Server push timeout after ${timeout}ms`)),
18057
18057
  timeout