@walkeros/cli 4.0.0-next-1777463920154 → 4.0.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/cli.js CHANGED
@@ -209,13 +209,13 @@ function L(e3, t3, n4) {
209
209
  }
210
210
  return r3;
211
211
  }
212
- function K(e3, t3, n4, o2, r3, i2) {
212
+ function B(e3, t3, n4, o2, r3, i2) {
213
213
  if ("string" == typeof e3) {
214
214
  const s4 = e3.match(M);
215
215
  if (s4) {
216
216
  const e4 = s4[1], a5 = s4[2];
217
217
  void 0 === n4[e4] && O(`Definition "${e4}" not found`);
218
- let c4 = K(n4[e4], t3, n4, o2, r3, i2);
218
+ let c4 = B(n4[e4], t3, n4, o2, r3, i2);
219
219
  return a5 && (c4 = L(c4, a5, `$def.${e4}`)), c4;
220
220
  }
221
221
  const a4 = e3.match(T);
@@ -245,30 +245,30 @@ function K(e3, t3, n4, o2, r3, i2) {
245
245
  } else a5 = L(a5, n5, `$flow.${t4}`);
246
246
  return a5;
247
247
  }
248
- let f2 = e3.replace(P, (e4, n5) => {
248
+ let l2 = e3.replace(P, (e4, n5) => {
249
249
  if (void 0 !== t3[n5]) return String(t3[n5]);
250
250
  O(`Variable "${n5}" not found`);
251
251
  });
252
- return f2 = f2.replace(R, (e4, t4, n5) => o2?.deferred ? void 0 !== n5 ? `${Z}${t4}:${n5}` : `${Z}${t4}` : "undefined" != typeof process && void 0 !== process.env?.[t4] ? process.env[t4] : void 0 !== n5 ? n5 : void O(`Environment variable "${t4}" not found and no default provided`)), f2;
252
+ return l2 = l2.replace(R, (e4, t4, n5) => o2?.deferred ? void 0 !== n5 ? `${Z}${t4}:${n5}` : `${Z}${t4}` : "undefined" != typeof process && void 0 !== process.env?.[t4] ? process.env[t4] : void 0 !== n5 ? n5 : void O(`Environment variable "${t4}" not found and no default provided`)), l2;
253
253
  }
254
- if (Array.isArray(e3)) return e3.map((e4) => K(e4, t3, n4, o2, r3, i2));
254
+ if (Array.isArray(e3)) return e3.map((e4) => B(e4, t3, n4, o2, r3, i2));
255
255
  if (null !== e3 && "object" == typeof e3) {
256
256
  const s4 = {};
257
- for (const [a4, c3] of Object.entries(e3)) s4[a4] = K(c3, t3, n4, o2, r3, i2);
257
+ for (const [a4, c3] of Object.entries(e3)) s4[a4] = B(c3, t3, n4, o2, r3, i2);
258
258
  return s4;
259
259
  }
260
260
  return e3;
261
261
  }
262
- function B(e3) {
262
+ function K(e3) {
263
263
  const t3 = e3.startsWith("@"), n4 = e3.replace("@", "").replace(/[/-]/g, "_").split("_").filter((e4) => e4.length > 0).map((e4, t4) => 0 === t4 ? e4 : e4.charAt(0).toUpperCase() + e4.slice(1)).join("");
264
264
  return t3 ? "_" + n4 : n4;
265
265
  }
266
- function J(e3, t3, n4) {
266
+ function V(e3, t3, n4) {
267
267
  if (t3) return t3;
268
268
  if (!e3 || !n4) return;
269
- return n4[e3] ? B(e3) : void 0;
269
+ return n4[e3] ? K(e3) : void 0;
270
270
  }
271
- function V(e3, t3, n4) {
271
+ function q(e3, t3, n4) {
272
272
  const o2 = /* @__PURE__ */ new Map(), r3 = /* @__PURE__ */ new Set(), i2 = [], s4 = (t4) => {
273
273
  if (o2.has(t4)) return o2.get(t4);
274
274
  const a5 = e3.flows[t4];
@@ -278,7 +278,7 @@ function V(e3, t3, n4) {
278
278
  }
279
279
  r3.add(t4), i2.push(t4);
280
280
  try {
281
- const r4 = F(e3.variables, a5.variables), i3 = U(e3.definitions, a5.definitions), c4 = K(a5.config ?? {}, r4, i3, n4, void 0, s4);
281
+ const r4 = F(e3.variables, a5.variables), i3 = U(e3.definitions, a5.definitions), c4 = B(a5.config ?? {}, r4, i3, n4, void 0, s4);
282
282
  return o2.set(t4, c4), c4;
283
283
  } finally {
284
284
  r3.delete(t4), i2.pop();
@@ -294,30 +294,30 @@ function V(e3, t3, n4) {
294
294
  let i3;
295
295
  if (e4.contract) {
296
296
  const r5 = F(e4.variables, t4.variables), s5 = U(e4.definitions, t4.definitions);
297
- i3 = E(K(e4.contract, r5, s5, n5, void 0, o3));
297
+ i3 = E(B(e4.contract, r5, s5, n5, void 0, o3));
298
298
  }
299
299
  if (r4.config) {
300
300
  const s5 = F(e4.variables, t4.variables), a5 = U(e4.definitions, t4.definitions);
301
- r4.config = K(r4.config, s5, a5, n5, i3, o3);
301
+ r4.config = B(r4.config, s5, a5, n5, i3, o3);
302
302
  }
303
303
  if (r4.sources) for (const [s5, a5] of Object.entries(r4.sources)) {
304
- const c4 = F(e4.variables, t4.variables, a5.variables), f2 = U(e4.definitions, t4.definitions, a5.definitions), l2 = K(a5.config, c4, f2, n5, i3, o3), u3 = K(a5.env, c4, f2, n5, i3, o3), p2 = J(a5.package, a5.code, r4.config?.bundle?.packages), d2 = "string" == typeof a5.code || "object" == typeof a5.code ? a5.code : void 0, m2 = p2 || d2;
305
- r4.sources[s5] = { package: a5.package, config: l2, env: u3, primary: a5.primary, variables: a5.variables, definitions: a5.definitions, before: a5.before, next: a5.next, cache: a5.cache, code: m2 };
304
+ const c4 = F(e4.variables, t4.variables, a5.variables), l2 = U(e4.definitions, t4.definitions, a5.definitions), f2 = B(a5.config, c4, l2, n5, i3, o3), u3 = B(a5.env, c4, l2, n5, i3, o3), p2 = V(a5.package, a5.code, r4.config?.bundle?.packages), d2 = "string" == typeof a5.code || "object" == typeof a5.code ? a5.code : void 0, m2 = p2 || d2;
305
+ r4.sources[s5] = { package: a5.package, config: f2, env: u3, primary: a5.primary, variables: a5.variables, definitions: a5.definitions, before: a5.before, next: a5.next, cache: a5.cache, code: m2 };
306
306
  }
307
307
  if (r4.destinations) for (const [s5, a5] of Object.entries(r4.destinations)) {
308
- const c4 = F(e4.variables, t4.variables, a5.variables), f2 = U(e4.definitions, t4.definitions, a5.definitions), l2 = K(a5.config, c4, f2, n5, i3, o3), u3 = K(a5.env, c4, f2, n5, i3, o3), p2 = J(a5.package, a5.code, r4.config?.bundle?.packages), d2 = "string" == typeof a5.code || "object" == typeof a5.code ? a5.code : void 0, m2 = p2 || d2;
309
- r4.destinations[s5] = { package: a5.package, config: l2, env: u3, variables: a5.variables, definitions: a5.definitions, before: a5.before, next: a5.next, cache: a5.cache, code: m2 };
308
+ const c4 = F(e4.variables, t4.variables, a5.variables), l2 = U(e4.definitions, t4.definitions, a5.definitions), f2 = B(a5.config, c4, l2, n5, i3, o3), u3 = B(a5.env, c4, l2, n5, i3, o3), p2 = V(a5.package, a5.code, r4.config?.bundle?.packages), d2 = "string" == typeof a5.code || "object" == typeof a5.code ? a5.code : void 0, m2 = p2 || d2;
309
+ r4.destinations[s5] = { package: a5.package, config: f2, env: u3, variables: a5.variables, definitions: a5.definitions, before: a5.before, next: a5.next, cache: a5.cache, code: m2 };
310
310
  }
311
311
  if (r4.stores) for (const [s5, a5] of Object.entries(r4.stores)) {
312
- const c4 = F(e4.variables, t4.variables, a5.variables), f2 = U(e4.definitions, t4.definitions, a5.definitions), l2 = K(a5.config, c4, f2, n5, i3, o3), u3 = K(a5.env, c4, f2, n5, i3, o3), p2 = J(a5.package, a5.code, r4.config?.bundle?.packages), d2 = "string" == typeof a5.code || "object" == typeof a5.code ? a5.code : void 0, m2 = p2 || d2;
313
- r4.stores[s5] = { package: a5.package, config: l2, env: u3, variables: a5.variables, definitions: a5.definitions, code: m2 };
312
+ const c4 = F(e4.variables, t4.variables, a5.variables), l2 = U(e4.definitions, t4.definitions, a5.definitions), f2 = B(a5.config, c4, l2, n5, i3, o3), u3 = B(a5.env, c4, l2, n5, i3, o3), p2 = V(a5.package, a5.code, r4.config?.bundle?.packages), d2 = "string" == typeof a5.code || "object" == typeof a5.code ? a5.code : void 0, m2 = p2 || d2;
313
+ r4.stores[s5] = { package: a5.package, config: f2, env: u3, variables: a5.variables, definitions: a5.definitions, code: m2 };
314
314
  }
315
315
  if (r4.transformers) for (const [s5, a5] of Object.entries(r4.transformers)) {
316
- const c4 = F(e4.variables, t4.variables, a5.variables), f2 = U(e4.definitions, t4.definitions, a5.definitions), l2 = K(a5.config, c4, f2, n5, i3, o3), u3 = K(a5.env, c4, f2, n5, i3, o3), p2 = J(a5.package, a5.code, r4.config?.bundle?.packages), d2 = "string" == typeof a5.code || "object" == typeof a5.code ? a5.code : void 0, m2 = p2 || d2;
317
- r4.transformers[s5] = { package: a5.package, config: l2, env: u3, variables: a5.variables, definitions: a5.definitions, before: a5.before, next: a5.next, cache: a5.cache, code: m2 };
316
+ const c4 = F(e4.variables, t4.variables, a5.variables), l2 = U(e4.definitions, t4.definitions, a5.definitions), f2 = B(a5.config, c4, l2, n5, i3, o3), u3 = B(a5.env, c4, l2, n5, i3, o3), p2 = V(a5.package, a5.code, r4.config?.bundle?.packages), d2 = "string" == typeof a5.code || "object" == typeof a5.code ? a5.code : void 0, m2 = p2 || d2;
317
+ r4.transformers[s5] = { package: a5.package, config: f2, env: u3, variables: a5.variables, definitions: a5.definitions, before: a5.before, next: a5.next, cache: a5.cache, code: m2 };
318
318
  }
319
319
  if (r4.collector) {
320
- const s5 = F(e4.variables, t4.variables), a5 = U(e4.definitions, t4.definitions), c4 = K(r4.collector, s5, a5, n5, i3, o3);
320
+ const s5 = F(e4.variables, t4.variables), a5 = U(e4.definitions, t4.definitions), c4 = B(r4.collector, s5, a5, n5, i3, o3);
321
321
  r4.collector = c4;
322
322
  }
323
323
  return r4;
@@ -326,7 +326,7 @@ function V(e3, t3, n4) {
326
326
  r3.delete(t3), i2.pop();
327
327
  }
328
328
  }
329
- function q(e3) {
329
+ function J(e3) {
330
330
  const t3 = e3.config?.platform;
331
331
  if ("web" === t3 || "server" === t3) return t3;
332
332
  O('Flow must have config.platform set to "web" or "server"');
@@ -363,20 +363,20 @@ function ae(e3, t3) {
363
363
  function ce(e3) {
364
364
  return "string" == typeof e3;
365
365
  }
366
- function fe(e3, t3 = /* @__PURE__ */ new WeakMap()) {
366
+ function le(e3, t3 = /* @__PURE__ */ new WeakMap()) {
367
367
  if ("object" != typeof e3 || null === e3) return e3;
368
368
  if (t3.has(e3)) return t3.get(e3);
369
369
  const n4 = Object.prototype.toString.call(e3);
370
370
  if ("[object Object]" === n4) {
371
371
  const n5 = {};
372
372
  t3.set(e3, n5);
373
- for (const o2 in e3) Object.prototype.hasOwnProperty.call(e3, o2) && (n5[o2] = fe(e3[o2], t3));
373
+ for (const o2 in e3) Object.prototype.hasOwnProperty.call(e3, o2) && (n5[o2] = le(e3[o2], t3));
374
374
  return n5;
375
375
  }
376
376
  if ("[object Array]" === n4) {
377
377
  const n5 = [];
378
378
  return t3.set(e3, n5), e3.forEach((e4) => {
379
- n5.push(fe(e4, t3));
379
+ n5.push(le(e4, t3));
380
380
  }), n5;
381
381
  }
382
382
  if ("[object Date]" === n4) return new Date(e3.getTime());
@@ -386,7 +386,7 @@ function fe(e3, t3 = /* @__PURE__ */ new WeakMap()) {
386
386
  }
387
387
  return e3;
388
388
  }
389
- function le(e3, t3 = "", n4) {
389
+ function fe(e3, t3 = "", n4) {
390
390
  const o2 = t3.split(".");
391
391
  let r3 = e3;
392
392
  for (let e4 = 0; e4 < o2.length; e4++) {
@@ -394,7 +394,7 @@ function le(e3, t3 = "", n4) {
394
394
  if ("*" === t4 && Y(r3)) {
395
395
  const t5 = o2.slice(e4 + 1).join("."), i2 = [];
396
396
  for (const e5 of r3) {
397
- const o3 = le(e5, t5, n4);
397
+ const o3 = fe(e5, t5, n4);
398
398
  i2.push(o3);
399
399
  }
400
400
  return i2;
@@ -405,7 +405,7 @@ function le(e3, t3 = "", n4) {
405
405
  }
406
406
  function ue(e3, t3, n4) {
407
407
  if (!se(e3)) return e3;
408
- const o2 = fe(e3), r3 = t3.split(".");
408
+ const o2 = le(e3), r3 = t3.split(".");
409
409
  let i2 = o2;
410
410
  for (let e4 = 0; e4 < r3.length; e4++) {
411
411
  const t4 = r3[e4];
@@ -527,64 +527,71 @@ function Te(e3, t3, n4) {
527
527
  }
528
528
  };
529
529
  }
530
- async function ze(e3, t3) {
531
- const [n4, o2] = (e3.name || "").split(" ");
532
- if (!t3 || !n4 || !o2) return {};
533
- let r3, i2 = "", s4 = n4, a4 = o2;
534
- const c3 = (t4) => {
535
- if (t4) return (t4 = Y(t4) ? t4 : [t4]).find((t5) => !t5.condition || t5.condition(e3));
530
+ async function ze(e3, t3, n4) {
531
+ const [o2, r3] = (e3.name || "").split(" ");
532
+ if (!t3 || !o2 || !r3) return {};
533
+ let i2, s4 = "", a4 = o2, c3 = r3;
534
+ const l2 = (t4) => {
535
+ if (!t4) return;
536
+ return (Y(t4) ? t4 : [t4]).find((t5) => {
537
+ if (!t5.condition) return true;
538
+ if (!n4) return Boolean(t5.condition(e3, void 0));
539
+ const o3 = { event: e3, mapping: t5, collector: n4, logger: n4.logger, consent: se(e3) && e3.consent || n4.consent };
540
+ return Boolean(t5.condition(e3, o3));
541
+ });
536
542
  };
537
- t3[s4] || (s4 = "*");
538
- const f2 = t3[s4];
539
- return f2 && (f2[a4] || (a4 = "*"), r3 = c3(f2[a4])), r3 || (s4 = "*", a4 = "*", r3 = c3(t3[s4]?.[a4])), r3 && (i2 = `${s4} ${a4}`), { eventMapping: r3, mappingKey: i2 };
543
+ t3[a4] || (a4 = "*");
544
+ const f2 = t3[a4];
545
+ return f2 && (f2[c3] || (c3 = "*"), i2 = l2(f2[c3])), i2 || (a4 = "*", c3 = "*", i2 = l2(t3[a4]?.[c3])), i2 && (s4 = `${a4} ${c3}`), { eventMapping: i2, mappingKey: s4 };
540
546
  }
541
547
  async function Ie(e3, t3 = {}, n4 = {}) {
542
548
  if (!ne(e3)) return;
543
- const o2 = se(e3) && e3.consent || n4.consent || n4.collector?.consent, r3 = Y(t3) ? t3 : [t3];
544
- for (const t4 of r3) {
545
- const r4 = await Te(He)(e3, t4, { ...n4, consent: o2 });
546
- if (ne(r4)) return r4;
547
- }
548
- }
549
- async function He(e3, t3, n4 = {}) {
550
- const { collector: o2, consent: r3 } = n4;
551
- return (Y(t3) ? t3 : [t3]).reduce(async (t4, i2) => {
552
- const s4 = await t4;
553
- if (s4) return s4;
554
- const a4 = ce(i2) ? { key: i2 } : i2;
555
- if (!Object.keys(a4).length) return;
556
- const { condition: c3, consent: f2, fn: l2, key: u3, loop: p2, map: d2, set: m2, validate: g2, value: y2 } = a4;
557
- if (c3 && !await Te(c3)(e3, i2, o2)) return;
558
- if (f2 && !ge(f2, r3)) return y2;
559
- let b2 = ne(y2) ? y2 : e3;
560
- if (l2 && (b2 = await Te(l2)(e3, i2, n4)), u3 && (b2 = le(e3, u3, y2)), p2) {
561
- const [t5, o3] = p2, r4 = "this" === t5 ? [e3] : await Ie(e3, t5, n4);
562
- Y(r4) && (b2 = (await Promise.all(r4.map((e4) => Ie(e4, o3, n4)))).filter(ne));
563
- } else d2 ? b2 = await Object.entries(d2).reduce(async (t5, [o3, r4]) => {
564
- const i3 = await t5, s5 = await Ie(e3, r4, n4);
565
- return ne(s5) && (i3[o3] = s5), i3;
566
- }, Promise.resolve({})) : m2 && (b2 = await Promise.all(m2.map((t5) => He(e3, t5, n4))));
567
- g2 && !await Te(g2)(b2) && (b2 = void 0);
568
- const h2 = Me(b2);
569
- return ne(h2) ? h2 : Me(y2);
549
+ const o2 = se(e3) && e3.consent || n4.consent || n4.collector?.consent, r3 = n4.event ?? (se(e3) ? e3 : {});
550
+ if (!n4.collector) throw new Error("getMappingValue: context.collector is required");
551
+ const i2 = { event: r3, mapping: t3, collector: n4.collector, logger: n4.collector.logger, consent: o2 }, s4 = Y(t3) ? t3 : [t3];
552
+ for (const t4 of s4) {
553
+ const n5 = await Te(He)(e3, t4, { ...i2, mapping: t4 });
554
+ if (ne(n5)) return n5;
555
+ }
556
+ }
557
+ async function He(e3, t3, n4) {
558
+ return (Y(t3) ? t3 : [t3]).reduce(async (t4, o2) => {
559
+ const r3 = await t4;
560
+ if (r3) return r3;
561
+ const i2 = ce(o2) ? { key: o2 } : o2;
562
+ if (!Object.keys(i2).length) return;
563
+ const { condition: s4, consent: a4, fn: c3, key: l2, loop: f2, map: u3, set: p2, validate: d2, value: m2 } = i2, g2 = { ...n4, mapping: o2 };
564
+ if (s4 && !await Te(s4)(e3, g2)) return;
565
+ if (a4 && !ge(a4, g2.consent)) return m2;
566
+ let y2 = ne(m2) ? m2 : e3;
567
+ if (c3 && (y2 = await Te(c3)(e3, g2)), l2 && (y2 = fe(e3, l2, m2)), f2) {
568
+ const [t5, n5] = f2, o3 = "this" === t5 ? [e3] : await Ie(e3, t5, g2);
569
+ Y(o3) && (y2 = (await Promise.all(o3.map((e4) => Ie(e4, n5, g2)))).filter(ne));
570
+ } else u3 ? y2 = await Object.entries(u3).reduce(async (t5, [n5, o3]) => {
571
+ const r4 = await t5, i3 = await Ie(e3, o3, g2);
572
+ return ne(i3) && (r4[n5] = i3), r4;
573
+ }, Promise.resolve({})) : p2 && (y2 = await Promise.all(p2.map((t5) => He(e3, t5, g2))));
574
+ d2 && !await Te(d2)(y2, g2) && (y2 = void 0);
575
+ const b2 = Me(y2);
576
+ return ne(b2) ? b2 : Me(m2);
570
577
  }, Promise.resolve(void 0));
571
578
  }
572
579
  async function We(e3, t3, n4) {
573
580
  t3.policy && await Promise.all(Object.entries(t3.policy).map(async ([t4, o3]) => {
574
- const r4 = await Ie(e3, o3, { collector: n4 });
581
+ const r4 = await Ie(e3, o3, { collector: n4, event: e3 });
575
582
  e3 = ue(e3, t4, r4);
576
583
  }));
577
- const { eventMapping: o2, mappingKey: r3 } = await ze(e3, t3.mapping);
584
+ const { eventMapping: o2, mappingKey: r3 } = await ze(e3, t3.mapping, n4);
578
585
  o2?.policy && await Promise.all(Object.entries(o2.policy).map(async ([t4, o3]) => {
579
- const r4 = await Ie(e3, o3, { collector: n4 });
586
+ const r4 = await Ie(e3, o3, { collector: n4, event: e3 });
580
587
  e3 = ue(e3, t4, r4);
581
588
  }));
582
- let i2 = t3.data && await Ie(e3, t3.data, { collector: n4 });
589
+ let i2 = t3.data && await Ie(e3, t3.data, { collector: n4, event: e3 });
583
590
  const s4 = Boolean(o2?.silent);
584
591
  if (o2) {
585
592
  if (o2.ignore) return { event: e3, data: i2, mapping: o2, mappingKey: r3, ignore: true, silent: s4 };
586
593
  if (o2.name && (e3.name = o2.name), o2.data) {
587
- const t4 = o2.data && await Ie(e3, o2.data, { collector: n4 });
594
+ const t4 = o2.data && await Ie(e3, o2.data, { collector: n4, event: e3 });
588
595
  i2 = se(i2) && se(t4) ? G(i2, t4) : t4;
589
596
  }
590
597
  }
@@ -595,28 +602,28 @@ async function We(e3, t3, n4) {
595
602
  }
596
603
  return { event: e3, data: i2, mapping: o2, mappingKey: r3, ignore: false, silent: s4 };
597
604
  }
598
- function Be(e3) {
605
+ function Ke(e3) {
599
606
  return void 0 === e3 || ae(e3, "") ? e3 : JSON.stringify(e3);
600
607
  }
601
- function Je(e3 = {}) {
608
+ function Ve(e3 = {}) {
602
609
  return G({ "Content-Type": "application/json; charset=utf-8" }, e3);
603
610
  }
604
- function qe(e3, t3, n4, o2) {
611
+ function Je(e3, t3, n4, o2) {
605
612
  return function(...r3) {
606
613
  let i2;
607
- const s4 = "pre" + t3, a4 = "post" + t3, c3 = n4[s4], f2 = n4[a4], l2 = (e4, t4) => {
614
+ const s4 = "pre" + t3, a4 = "post" + t3, c3 = n4[s4], l2 = n4[a4], f2 = (e4, t4) => {
608
615
  o2 ? o2.warn(e4, { error: t4 }) : console.warn(e4, t4);
609
616
  };
610
617
  if (c3) try {
611
618
  i2 = c3({ fn: e3 }, ...r3);
612
619
  } catch (t4) {
613
- l2(`Hook ${String(s4)} failed, falling back to original function`, t4), i2 = e3(...r3);
620
+ f2(`Hook ${String(s4)} failed, falling back to original function`, t4), i2 = e3(...r3);
614
621
  }
615
622
  else i2 = e3(...r3);
616
- if (f2) try {
617
- i2 = f2({ fn: e3, result: i2 }, ...r3);
623
+ if (l2) try {
624
+ i2 = l2({ fn: e3, result: i2 }, ...r3);
618
625
  } catch (e4) {
619
- l2(`Hook ${String(a4)} failed, keeping original result`, e4);
626
+ f2(`Hook ${String(a4)} failed, keeping original result`, e4);
620
627
  }
621
628
  return i2;
622
629
  };
@@ -637,13 +644,13 @@ async function at(e3, t3) {
637
644
  }
638
645
  const o3 = `https://cdn.jsdelivr.net/npm/${e3}@${n4}`, r4 = await ct(`${o3}/package.json`, s4, a4);
639
646
  return (function(e4, t4, n5, o4) {
640
- const r5 = o4.$meta || {}, i3 = o4.schemas || {}, s5 = o4.examples || {}, a5 = o4.hints, c3 = a5 ? Object.keys(a5) : [], f2 = [], l2 = s5.step || {};
641
- for (const [e5, t5] of Object.entries(l2)) {
647
+ const r5 = o4.$meta || {}, i3 = o4.schemas || {}, s5 = o4.examples || {}, a5 = o4.hints, c3 = a5 ? Object.keys(a5) : [], l2 = [], f2 = s5.step || {};
648
+ for (const [e5, t5] of Object.entries(f2)) {
642
649
  const n6 = t5, o5 = { name: e5 };
643
- "string" == typeof n6?.description && (o5.description = n6.description), f2.push(o5);
650
+ "string" == typeof n6?.description && (o5.description = n6.description), l2.push(o5);
644
651
  }
645
652
  const u3 = "string" == typeof r5.docs ? r5.docs : void 0, p2 = "string" == typeof r5.source ? r5.source : void 0;
646
- return { packageName: e4, version: "string" == typeof n5.version ? n5.version : t4, description: "string" == typeof n5.description ? n5.description : void 0, type: "string" == typeof r5.type ? r5.type : void 0, platform: st(r5.platform), schemas: i3, examples: s5, ...u3 ? { docs: u3 } : {}, ...p2 ? { source: p2 } : {}, ...a5 && Object.keys(a5).length > 0 ? { hints: a5 } : {}, hintKeys: c3, exampleSummaries: f2 };
653
+ return { packageName: e4, version: "string" == typeof n5.version ? n5.version : t4, description: "string" == typeof n5.description ? n5.description : void 0, type: "string" == typeof r5.type ? r5.type : void 0, platform: st(r5.platform), schemas: i3, examples: s5, ...u3 ? { docs: u3 } : {}, ...p2 ? { source: p2 } : {}, ...a5 && Object.keys(a5).length > 0 ? { hints: a5 } : {}, hintKeys: c3, exampleSummaries: l2 };
647
654
  })(e3, n4, r4, await ct(`${o3}/dist/walkerOS.json`, s4, a4));
648
655
  } finally {
649
656
  clearTimeout(i2);
@@ -654,7 +661,7 @@ async function ct(e3, t3, n4) {
654
661
  if (!o2.ok) throw new Error(`Failed to fetch ${e3} (HTTP ${o2.status})`);
655
662
  return await o2.json();
656
663
  }
657
- async function ft(e3, t3) {
664
+ async function lt(e3, t3) {
658
665
  const n4 = await at(e3, t3);
659
666
  return { packageName: n4.packageName, version: n4.version, type: n4.type, platform: n4.platform, schemas: n4.schemas, examples: n4.examples, ...n4.hints ? { hints: n4.hints } : {} };
660
667
  }
@@ -696,7 +703,7 @@ function dt(e3) {
696
703
  }
697
704
  })(n4, o2);
698
705
  return (e5) => {
699
- const n5 = le(e5, t3), o3 = i2(n5);
706
+ const n5 = fe(e5, t3), o3 = i2(n5);
700
707
  return r3 ? !o3 : o3;
701
708
  };
702
709
  })(e3);
@@ -733,7 +740,7 @@ function ht(e3) {
733
740
  function vt(e3, t3, n4, o2) {
734
741
  const r3 = e3.rules.find((e4) => e4.match(n4));
735
742
  if (!r3) return null;
736
- const i2 = r3.key.map((e4) => String(le(n4, e4) ?? ""));
743
+ const i2 = r3.key.map((e4) => String(fe(n4, e4) ?? ""));
737
744
  if (i2.every((e4) => "" === e4)) return null;
738
745
  const s4 = `${o2}:${i2.join(":")}`, a4 = t3.get(s4);
739
746
  return void 0 !== a4 ? { status: "HIT", key: s4, value: a4, rule: r3 } : { status: "MISS", key: s4, rule: r3 };
@@ -741,13 +748,13 @@ function vt(e3, t3, n4, o2) {
741
748
  function wt(e3, t3, n4, o2) {
742
749
  e3.set(t3, n4, 1e3 * o2);
743
750
  }
744
- async function jt(e3, t3, n4) {
751
+ async function jt(e3, t3, n4, o2) {
745
752
  if (!t3) return e3;
746
- let o2 = e3;
747
- for (const [e4, r3] of Object.entries(t3)) {
748
- o2 = ue(o2, e4, await Ie(n4, r3));
753
+ let r3 = e3;
754
+ for (const [e4, i2] of Object.entries(t3)) {
755
+ r3 = ue(r3, e4, await Ie(n4, i2, { collector: o2 }));
749
756
  }
750
- return o2;
757
+ return r3;
751
758
  }
752
759
  var e, a, c, S, A, P, M, R, T, z, Z, X, pe, Ee;
753
760
  var init_dist = __esm({
@@ -781,7 +788,7 @@ import * as r from "http";
781
788
  import * as s2 from "https";
782
789
  import { createHash as n2 } from "crypto";
783
790
  function a2(a4, n4, u3 = {}) {
784
- const i2 = Je(u3.headers), c3 = Be(n4), d2 = u3.method || "POST", m2 = u3.timeout || 5e3;
791
+ const i2 = Ve(u3.headers), c3 = Ke(n4), d2 = u3.method || "POST", m2 = u3.timeout || 5e3;
785
792
  return new Promise((t3) => {
786
793
  const e3 = new URL(a4), n5 = "https:" === e3.protocol ? s2 : r, u4 = { method: d2, headers: i2 }, p2 = n5.request(e3, u4, (e4) => {
787
794
  const r3 = [];
@@ -1569,7 +1576,7 @@ function tn(e3, i2, t3) {
1569
1576
  function nn(e3) {
1570
1577
  return n3.toJSONSchema(e3, { target: "draft-7" });
1571
1578
  }
1572
- var e2, i, t2, r2, a3, s3, c2, l, d, p, u2, m, f, g, b, h, S2, v, y, w, k2, C2, x, P2, D2, E2, j, I, J2, O2, L2, N2, z2, W, q2, B2, U2, $, H, A2, V2, G2, K2, Q, _2, X3, Y3, Z3, ee3, ie3, te2, ne3, oe2, re3, ae3, se3, ce3, le3, de3, pe3, ue3, me2, fe3, ge3, be2, he3, Se3, ve3, ye2, we2, ke, Ce2, xe3, Pe, De, Ee3, je2, Ie2, Je2, Oe, Fe, Re2, Me2, Te3, Le, Ne3, ze2, We2, qe3, Be2, Ue2, $e, He2, Ae3, Ve, Ge2, Ke, Qe, _e2, Xe, Ye, Ze, ei, ii, ti, ni, oi, ri, ai, si, ci, li, di, pi, ui, mi, fi, gi, bi, hi, Si, vi, yi, wi, ki, Ci, xi, Pi, Di, Ei, ji, Ii, Ji, Oi, Fi, Ri, Mi, Ti, Li, Ni, zi, Wi, qi, Bi, Ui, $i, Hi, Ai, Vi, Gi, Ki, Qi, _i, Xi, Yi, Zi, et, it, tt, nt, ot, rt, at2, st2, ct2, lt, dt2, pt, ut, mt2, ft2, gt2, bt2, ht2, St, vt2, yt2, wt2, kt, Ct, xt, It, Jt, Ot, Ft, Rt, Mt, Tt, Lt, Nt, Wt, qt, Bt, Ut, rn;
1579
+ var e2, i, t2, r2, a3, s3, c2, l, d, p, u2, m, f, g, b, h, S2, v, y, w, k2, C2, x, P2, D2, E2, j, I, J2, O2, L2, N2, z2, W, q2, B2, U2, $, H, A2, V2, G2, K2, Q, _2, X3, Y3, Z3, ee3, ie3, te2, ne3, oe2, re3, ae3, se3, ce3, le3, de3, pe3, ue3, me2, fe3, ge3, be2, he3, Se3, ve3, ye2, we2, ke2, Ce2, xe2, Pe, De2, Ee2, je2, Ie2, Je2, Oe, Fe, Re3, Me2, Te2, Le, Ne3, ze2, We2, qe2, Be2, Ue2, $e, He2, Ae3, Ve2, Ge2, Ke2, Qe, _e2, Xe, Ye, Ze, ei, ii, ti, ni, oi, ri, ai, si, ci, li, di, pi, ui, mi, fi, gi, bi, hi, Si, vi, yi, wi, ki, Ci, xi, Pi, Di, Ei, ji, Ii, Ji, Oi, Fi, Ri, Mi, Ti, Li, Ni, zi, Wi, qi, Bi, Ui, $i, Hi, Ai, Vi, Gi, Ki, Qi, _i, Xi, Yi, Zi, et, it, tt, nt, ot, rt, at2, st2, ct2, lt2, dt2, pt, ut, mt2, ft, gt2, bt2, ht2, St, vt2, yt2, wt2, kt, Ct, xt, It, Jt, Ot, Ft, Rt, Mt, Tt, Lt, Nt, Wt, qt, Bt, Ut, rn;
1573
1580
  var init_dev = __esm({
1574
1581
  "../core/dist/dev.mjs"() {
1575
1582
  "use strict";
@@ -1578,7 +1585,7 @@ var init_dev = __esm({
1578
1585
  for (var n4 in t3) e2(i2, n4, { get: t3[n4], enumerable: true });
1579
1586
  };
1580
1587
  t2 = {};
1581
- i(t2, { BaseContextConfig: () => N2, BatchConfig: () => z2, CacheRuleSchema: () => Be2, CacheSchema: () => Ue2, CacheSchemas: () => qe3, ClickIdEntrySchema: () => Ut, CodeSchema: () => Wt, CollectorSchemas: () => bi, ConsentSchema: () => Q, ContractActionsSchema: () => St, ContractRuleSchema: () => yt2, ContractSchema: () => wt2, ContractSchemaEntry: () => ht2, Counter: () => d, DeepPartialEventSchema: () => te2, DestinationSchemas: () => Fe, DestinationsMapConfig: () => B2, EntitiesSchema: () => Z3, EntitySchema: () => Y3, EventSchema: () => ee3, FlowBundlePackageSchema: () => st2, FlowBundleSchema: () => ct2, FlowCodeSchema: () => lt, FlowConfigSchema: () => kt, FlowDestinationSchema: () => gt2, FlowJsonSchema: () => xt, FlowSchema: () => Ct, FlowSchemas: () => it, FlowSourceSchema: () => mt2, FlowStoreSchema: () => bt2, FlowTransformerSchema: () => ft2, GenericEnvConfig: () => O2, GenericSettingsConfig: () => J2, HandlersConfig: () => x, HintSchema: () => qt, HintsSchema: () => Bt, IdConfig: () => E2, Identifier: () => c2, InitConfig: () => j, LoggerConfigSchema: () => He2, LoggerHandlerSchema: () => $e, LoopSchema: () => fe3, MapSchema: () => be2, MappingResultSchema: () => ke, MappingSchemas: () => pe3, MatchExpressionSchema: () => Le, MatcherSchemas: () => Re2, NextRuleSchema: () => We2, OptionalPrimitiveValue: () => u2, OrderedPropertiesSchema: () => G2, PartialEventSchema: () => ie3, PolicySchema: () => Se3, PrimaryConfig: () => I, PrimitiveSchema: () => tt, PrimitiveValue: () => p, ProcessingControlConfig: () => W, PropertiesSchema: () => V2, PropertySchema: () => A2, PropertyTypeSchema: () => H, QueueConfig: () => D2, RequiredBoolean: () => s3, RequiredNumber: () => a3, RequiredString: () => r2, RoutableNextSchema: () => ze2, RuleSchema: () => ve3, RulesSchema: () => ye2, RuntimeInstanceConfig: () => L2, SetSchema: () => ge3, SourceSchema: () => X3, SourceSchemas: () => Oi, SourceTypeSchema: () => K2, SourcesMapConfig: () => q2, StoreSchemas: () => _i, Timestamp: () => l, TransformerSchemas: () => Ai, UserSchema: () => _2, UtilitySchemas: () => m, ValueConfigSchema: () => he3, ValueSchema: () => ue3, ValuesSchema: () => me2, VerboseConfig: () => P2, WalkerOSSchemas: () => U2, configJsonSchema: () => It, consentJsonSchema: () => de3, contractJsonSchema: () => Nt, contractRuleJsonSchema: () => Lt, createArraySchema: () => Zt, createConsentConfig: () => T2, createDataTransformationConfig: () => F2, createEnumSchema: () => en, createMappingRulesConfig: () => R2, createObjectSchema: () => Xt, createPolicyConfig: () => M2, createTupleSchema: () => tn, destinationJsonSchema: () => Rt, entityJsonSchema: () => ce3, eventJsonSchema: () => ne3, flowConfigJsonSchema: () => Ot, flowJsonSchema: () => Jt, loopJsonSchema: () => Pe, mapJsonSchema: () => Ee3, orderedPropertiesJsonSchema: () => se3, parseConfig: () => Pt, parseFlow: () => Et, partialEventJsonSchema: () => oe2, policyJsonSchema: () => je2, propertiesJsonSchema: () => ae3, ruleJsonSchema: () => Ie2, rulesJsonSchema: () => Je2, safeParseConfig: () => Dt, safeParseFlow: () => jt2, setJsonSchema: () => De, sourceJsonSchema: () => Ft, sourceTypeJsonSchema: () => le3, storeJsonSchema: () => Tt, transformerJsonSchema: () => Mt, userJsonSchema: () => re3, validateFlowConfig: () => $t, valueConfigJsonSchema: () => xe3, valueJsonSchema: () => Ce2, z: () => n3, zodToSchema: () => nn });
1588
+ i(t2, { BaseContextConfig: () => N2, BatchConfig: () => z2, CacheRuleSchema: () => Be2, CacheSchema: () => Ue2, CacheSchemas: () => qe2, ClickIdEntrySchema: () => Ut, CodeSchema: () => Wt, CollectorSchemas: () => bi, ConsentSchema: () => Q, ContractActionsSchema: () => St, ContractRuleSchema: () => yt2, ContractSchema: () => wt2, ContractSchemaEntry: () => ht2, Counter: () => d, DeepPartialEventSchema: () => te2, DestinationSchemas: () => Fe, DestinationsMapConfig: () => B2, EntitiesSchema: () => Z3, EntitySchema: () => Y3, EventSchema: () => ee3, FlowBundlePackageSchema: () => st2, FlowBundleSchema: () => ct2, FlowCodeSchema: () => lt2, FlowConfigSchema: () => kt, FlowDestinationSchema: () => gt2, FlowJsonSchema: () => xt, FlowSchema: () => Ct, FlowSchemas: () => it, FlowSourceSchema: () => mt2, FlowStoreSchema: () => bt2, FlowTransformerSchema: () => ft, GenericEnvConfig: () => O2, GenericSettingsConfig: () => J2, HandlersConfig: () => x, HintSchema: () => qt, HintsSchema: () => Bt, IdConfig: () => E2, Identifier: () => c2, InitConfig: () => j, LoggerConfigSchema: () => He2, LoggerHandlerSchema: () => $e, LoopSchema: () => fe3, MapSchema: () => be2, MappingResultSchema: () => ke2, MappingSchemas: () => pe3, MatchExpressionSchema: () => Le, MatcherSchemas: () => Re3, NextRuleSchema: () => We2, OptionalPrimitiveValue: () => u2, OrderedPropertiesSchema: () => G2, PartialEventSchema: () => ie3, PolicySchema: () => Se3, PrimaryConfig: () => I, PrimitiveSchema: () => tt, PrimitiveValue: () => p, ProcessingControlConfig: () => W, PropertiesSchema: () => V2, PropertySchema: () => A2, PropertyTypeSchema: () => H, QueueConfig: () => D2, RequiredBoolean: () => s3, RequiredNumber: () => a3, RequiredString: () => r2, RoutableNextSchema: () => ze2, RuleSchema: () => ve3, RulesSchema: () => ye2, RuntimeInstanceConfig: () => L2, SetSchema: () => ge3, SourceSchema: () => X3, SourceSchemas: () => Oi, SourceTypeSchema: () => K2, SourcesMapConfig: () => q2, StoreSchemas: () => _i, Timestamp: () => l, TransformerSchemas: () => Ai, UserSchema: () => _2, UtilitySchemas: () => m, ValueConfigSchema: () => he3, ValueSchema: () => ue3, ValuesSchema: () => me2, VerboseConfig: () => P2, WalkerOSSchemas: () => U2, configJsonSchema: () => It, consentJsonSchema: () => de3, contractJsonSchema: () => Nt, contractRuleJsonSchema: () => Lt, createArraySchema: () => Zt, createConsentConfig: () => T2, createDataTransformationConfig: () => F2, createEnumSchema: () => en, createMappingRulesConfig: () => R2, createObjectSchema: () => Xt, createPolicyConfig: () => M2, createTupleSchema: () => tn, destinationJsonSchema: () => Rt, entityJsonSchema: () => ce3, eventJsonSchema: () => ne3, flowConfigJsonSchema: () => Ot, flowJsonSchema: () => Jt, loopJsonSchema: () => Pe, mapJsonSchema: () => Ee2, orderedPropertiesJsonSchema: () => se3, parseConfig: () => Pt, parseFlow: () => Et, partialEventJsonSchema: () => oe2, policyJsonSchema: () => je2, propertiesJsonSchema: () => ae3, ruleJsonSchema: () => Ie2, rulesJsonSchema: () => Je2, safeParseConfig: () => Dt, safeParseFlow: () => jt2, setJsonSchema: () => De2, sourceJsonSchema: () => Ft, sourceTypeJsonSchema: () => le3, storeJsonSchema: () => Tt, transformerJsonSchema: () => Mt, userJsonSchema: () => re3, validateFlowConfig: () => $t, valueConfigJsonSchema: () => xe2, valueJsonSchema: () => Ce2, z: () => n3, zodToSchema: () => nn });
1582
1589
  r2 = n3.string();
1583
1590
  a3 = n3.number();
1584
1591
  s3 = n3.boolean();
@@ -1637,7 +1644,7 @@ var init_dev = __esm({
1637
1644
  le3 = o(K2);
1638
1645
  de3 = o(Q);
1639
1646
  pe3 = {};
1640
- i(pe3, { ConfigSchema: () => we2, LoopSchema: () => fe3, MapSchema: () => be2, PolicySchema: () => Se3, ResultSchema: () => ke, RuleSchema: () => ve3, RulesSchema: () => ye2, SetSchema: () => ge3, ValueConfigSchema: () => he3, ValueSchema: () => ue3, ValuesSchema: () => me2, configJsonSchema: () => Oe, loopJsonSchema: () => Pe, mapJsonSchema: () => Ee3, policyJsonSchema: () => je2, ruleJsonSchema: () => Ie2, rulesJsonSchema: () => Je2, setJsonSchema: () => De, valueConfigJsonSchema: () => xe3, valueJsonSchema: () => Ce2 });
1647
+ i(pe3, { ConfigSchema: () => we2, LoopSchema: () => fe3, MapSchema: () => be2, PolicySchema: () => Se3, ResultSchema: () => ke2, RuleSchema: () => ve3, RulesSchema: () => ye2, SetSchema: () => ge3, ValueConfigSchema: () => he3, ValueSchema: () => ue3, ValuesSchema: () => me2, configJsonSchema: () => Oe, loopJsonSchema: () => Pe, mapJsonSchema: () => Ee2, policyJsonSchema: () => je2, ruleJsonSchema: () => Ie2, rulesJsonSchema: () => Je2, setJsonSchema: () => De2, valueConfigJsonSchema: () => xe2, valueJsonSchema: () => Ce2 });
1641
1648
  ue3 = n3.lazy(() => n3.union([n3.string().describe('String value or property path (e.g., "data.id")'), n3.number().describe("Numeric value"), n3.boolean().describe("Boolean value"), n3.lazy(() => $), n3.array(ue3).describe("Array of values")])).meta({ id: "MappingValue", title: "Mapping.Value", description: "Polymorphic transform primitive used in every mapping field. A string path, constant, operator object (map/loop/set/condition/consent), or array of values." });
1642
1649
  me2 = n3.array(ue3).meta({ id: "MappingValues", title: "Mapping.Values", description: "Array of transformation values." }).describe("Array of transformation values");
1643
1650
  fe3 = n3.lazy(() => n3.tuple([ue3, ue3]).describe("Loop transformation: [source, transform] tuple for array processing")).meta({ id: "MappingLoop", title: "Mapping.Loop", description: "Loop tuple [source, transform] for iterating and transforming arrays." });
@@ -1648,44 +1655,44 @@ var init_dev = __esm({
1648
1655
  ve3 = n3.object({ name: n3.string().optional().describe('Custom event name override (e.g., "view_item" for "product view")'), data: n3.union([ue3, me2]).optional().describe("Data transformation rules for event"), settings: n3.any().optional().describe("Destination-specific settings for this event mapping"), condition: n3.string().optional().describe("Condition function as string: return true to process event"), consent: Q.optional().describe("Required consent states to process this event"), policy: Se3.optional().describe("Event-level policy overrides (applied after config-level policy)"), batch: n3.number().optional().describe("Batch size: bundle N events for batch processing"), include: n3.array(n3.string()).optional().describe('Event sections (e.g. ["context", "globals"]) flattened into context.data'), ignore: n3.boolean().optional().describe("Skip the event entirely. No push, no side effects. Use for suppression."), silent: n3.boolean().optional().describe("Run side effects (settings.identify, ...) but suppress the destination default push call.") }).meta({ id: "MappingRule", title: "Mapping.Rule", description: "Configuration for transforming a single event at one stage of the flow (source or destination)." }).describe("Mapping rule for specific entity-action combination");
1649
1656
  ye2 = n3.record(n3.string(), n3.record(n3.string(), n3.union([ve3, n3.array(ve3)])).optional()).meta({ id: "MappingRules", title: "Mapping.Rules", description: 'Event mapping rules tree: entity \u2192 action \u2192 Rule (or Rule[]). Use "*" as wildcard for entity or action.' }).describe('Event mapping rules: entity \u2192 action \u2192 Rule. Keys match event name split by space. Use "*" as wildcard for entity or action. Priority: exact > entity wildcard > action wildcard > global wildcard (*\u2192*).');
1650
1657
  we2 = n3.object({ consent: Q.optional().describe("Required consent states to process any events"), data: n3.union([ue3, me2]).optional().describe("Global data transformation applied to all events"), include: n3.array(n3.string()).optional().describe("Event sections to flatten into context.data"), mapping: ye2.optional().describe("Entity-action specific mapping rules"), policy: Se3.optional().describe("Pre-processing policy rules applied before mapping") }).meta({ id: "MappingConfig", title: "Mapping.Config", description: "Shared mapping configuration (consent, data, include, mapping, policy)." }).describe("Shared mapping configuration for sources and destinations");
1651
- ke = n3.object({ eventMapping: ve3.optional().describe("Resolved mapping rule for event"), mappingKey: n3.string().optional().describe('Mapping key used (e.g., "product.view")') }).meta({ id: "MappingResult", title: "Mapping.Result", description: "Mapping resolution result (matched rule + key)." }).describe("Mapping resolution result");
1658
+ ke2 = n3.object({ eventMapping: ve3.optional().describe("Resolved mapping rule for event"), mappingKey: n3.string().optional().describe('Mapping key used (e.g., "product.view")') }).meta({ id: "MappingResult", title: "Mapping.Result", description: "Mapping resolution result (matched rule + key)." }).describe("Mapping resolution result");
1652
1659
  Ce2 = o(ue3);
1653
- xe3 = o(he3);
1660
+ xe2 = o(he3);
1654
1661
  Pe = o(fe3);
1655
- De = o(ge3);
1656
- Ee3 = o(be2);
1662
+ De2 = o(ge3);
1663
+ Ee2 = o(be2);
1657
1664
  je2 = o(Se3);
1658
1665
  Ie2 = o(ve3);
1659
1666
  Je2 = o(ye2);
1660
1667
  Oe = o(we2);
1661
1668
  Fe = {};
1662
- i(Fe, { BatchSchema: () => Ze, ConfigSchema: () => Ae3, ContextSchema: () => Ke, DLQSchema: () => ci, DataSchema: () => ei, DestinationPolicySchema: () => Ge2, DestinationsSchema: () => oi, InitDestinationsSchema: () => ni, InitSchema: () => ti, InstanceSchema: () => ii, PartialConfigSchema: () => Ve, PushBatchContextSchema: () => _e2, PushContextSchema: () => Qe, PushEventSchema: () => Xe, PushEventsSchema: () => Ye, PushResultSchema: () => ai, RefSchema: () => ri, ResultSchema: () => si, batchJsonSchema: () => mi, configJsonSchema: () => li, contextJsonSchema: () => pi, instanceJsonSchema: () => fi, partialConfigJsonSchema: () => di, pushContextJsonSchema: () => ui, resultJsonSchema: () => gi });
1663
- Re2 = {};
1664
- i(Re2, { MatchExpressionSchema: () => Le, NextRuleSchema: () => We2, RoutableNextSchema: () => ze2 });
1669
+ i(Fe, { BatchSchema: () => Ze, ConfigSchema: () => Ae3, ContextSchema: () => Ke2, DLQSchema: () => ci, DataSchema: () => ei, DestinationPolicySchema: () => Ge2, DestinationsSchema: () => oi, InitDestinationsSchema: () => ni, InitSchema: () => ti, InstanceSchema: () => ii, PartialConfigSchema: () => Ve2, PushBatchContextSchema: () => _e2, PushContextSchema: () => Qe, PushEventSchema: () => Xe, PushEventsSchema: () => Ye, PushResultSchema: () => ai, RefSchema: () => ri, ResultSchema: () => si, batchJsonSchema: () => mi, configJsonSchema: () => li, contextJsonSchema: () => pi, instanceJsonSchema: () => fi, partialConfigJsonSchema: () => di, pushContextJsonSchema: () => ui, resultJsonSchema: () => gi });
1670
+ Re3 = {};
1671
+ i(Re3, { MatchExpressionSchema: () => Le, NextRuleSchema: () => We2, RoutableNextSchema: () => ze2 });
1665
1672
  Me2 = n3.enum(["eq", "contains", "prefix", "suffix", "regex", "gt", "lt", "exists"]).meta({ id: "MatcherOperator", title: "Matcher.Operator", description: "Supported operators for a match condition." });
1666
- Te3 = n3.object({ key: n3.string(), operator: Me2, value: n3.string(), not: n3.boolean().optional() }).meta({ id: "MatcherCondition", title: "Matcher.Condition", description: "Single match condition (key, operator, value, optional not)." });
1667
- Le = n3.union([Te3, n3.object({ and: n3.array(n3.lazy(() => Le)) }), n3.object({ or: n3.array(n3.lazy(() => Le)) })]).meta({ id: "MatcherExpression", title: "Matcher.Expression", description: "Boolean expression tree of match conditions (leaf, and, or)." });
1673
+ Te2 = n3.object({ key: n3.string(), operator: Me2, value: n3.string(), not: n3.boolean().optional() }).meta({ id: "MatcherCondition", title: "Matcher.Condition", description: "Single match condition (key, operator, value, optional not)." });
1674
+ Le = n3.union([Te2, n3.object({ and: n3.array(n3.lazy(() => Le)) }), n3.object({ or: n3.array(n3.lazy(() => Le)) })]).meta({ id: "MatcherExpression", title: "Matcher.Expression", description: "Boolean expression tree of match conditions (leaf, and, or)." });
1668
1675
  Ne3 = n3.union([Le, n3.literal("*")]);
1669
1676
  ze2 = n3.union([n3.string(), n3.array(n3.string()), n3.array(n3.object({ match: Ne3, next: n3.lazy(() => ze2) }))]).meta({ id: "MatcherNext", title: "Matcher.Next", description: "Routable next target: ID, ID list, or list of {match, next} rules." });
1670
1677
  We2 = n3.object({ match: Ne3, next: n3.lazy(() => ze2) }).meta({ id: "MatcherNextRule", title: "Matcher.NextRule", description: "Single routing rule pairing a match expression with a next target." });
1671
- qe3 = {};
1672
- i(qe3, { CacheRuleSchema: () => Be2, CacheSchema: () => Ue2 });
1678
+ qe2 = {};
1679
+ i(qe2, { CacheRuleSchema: () => Be2, CacheSchema: () => Ue2 });
1673
1680
  Be2 = n3.object({ match: n3.union([Le, n3.literal("*")]).describe("Match expression or wildcard to determine when this rule applies"), key: n3.array(n3.string()).min(1).describe("Dot-path fields used to build the cache key"), ttl: n3.number().positive().describe("Time-to-live in seconds for cached entries"), update: n3.record(n3.string(), ue3).optional().describe("Response mutations applied on cache hit (key \u2192 Value mapping)") }).meta({ id: "CacheRule", title: "Cache.Rule", description: "Single caching rule: when it applies (match), what keys it keys off, TTL, and optional response mutations on hit." });
1674
1681
  Ue2 = n3.object({ full: n3.boolean().optional().describe("Stop flow on cache HIT (default: false). When true, skip remaining steps and return cached value."), store: n3.string().optional().describe("Store ID for persistent caching (references a configured store)"), rules: n3.array(Be2).min(1).describe("Cache rules \u2014 at least one required") }).meta({ id: "CacheConfig", title: "Cache.Config", description: "Top-level cache configuration for a pipeline step (destination / transformer / source ref)." });
1675
1682
  $e = n3.any().meta({ id: "LoggerHandler", title: "Logger.Handler", description: "Custom log handler function (level, ...args) => void" });
1676
1683
  He2 = n3.object({ level: n3.union([n3.number(), n3.enum(["ERROR", "WARN", "INFO", "DEBUG"])]).optional().describe("Minimum log level (default: ERROR)"), handler: $e.optional().describe("Custom log handler function") }).meta({ id: "LoggerConfig", title: "Logger.Config", description: "Logger configuration (level, handler) to override the collector defaults" });
1677
1684
  Ae3 = n3.object({ consent: Q.optional().describe("Required consent states to send events to this destination"), settings: n3.any().meta({ id: "DestinationSettings", title: "Destination.Settings", description: "Implementation-specific configuration (destination-defined shape)." }).describe("Implementation-specific configuration").optional(), data: n3.union([ue3, me2]).optional().describe("Global data transformation applied to all events for this destination"), include: n3.array(n3.string()).optional().describe("Event sections to flatten into context.data"), env: n3.any().meta({ id: "DestinationEnv", title: "Destination.Env", description: "Environment dependencies (destination-defined shape) \u2014 platform, SDK, or mock hook." }).describe("Environment dependencies (platform-specific)").optional(), id: c2.describe("Destination instance identifier (defaults to destination key)").optional(), init: n3.boolean().describe("Whether to initialize immediately").optional(), loadScript: n3.boolean().describe("Whether to load external script (for web destinations)").optional(), mapping: ye2.optional().describe("Entity-action specific mapping rules for this destination"), policy: Se3.optional().describe("Pre-processing policy rules applied before event mapping"), queue: n3.boolean().describe("Whether to queue events when consent is not granted").optional(), require: n3.array(n3.string()).optional().describe('Defer destination initialization until these collector events fire (e.g., ["consent"])'), logger: He2.optional().describe("Logger configuration (level, handler) to override the collector defaults"), before: ze2.optional().describe("Post-collector transformer chain applied before this destination receives the event"), next: ze2.optional().describe("Post-push transformer chain. Runs after destination push completes; push response is available at ingest._response"), cache: Ue2.optional().describe("Cache configuration for deduplication; skip push on cache HIT"), disabled: n3.boolean().describe("Completely skip this destination (no init, no push, no queue)").optional(), mock: n3.unknown().meta({ id: "DestinationMock", title: "Destination.Mock", description: "Return this value instead of calling push(). Dev/testing only." }).optional().describe("Return this value instead of calling push(). Dev/testing only.") }).meta({ id: "DestinationConfig", title: "Destination.Config", description: "Destination configuration: consent, settings, data, env, mapping rules, policy, queue, logger, before/next chains, cache." }).describe("Destination configuration");
1678
- Ve = Ae3.partial().meta({ id: "DestinationPartialConfig", title: "Destination.PartialConfig", description: "Partial destination configuration with all fields optional." }).describe("Partial destination configuration with all fields optional");
1685
+ Ve2 = Ae3.partial().meta({ id: "DestinationPartialConfig", title: "Destination.PartialConfig", description: "Partial destination configuration with all fields optional." }).describe("Partial destination configuration with all fields optional");
1679
1686
  Ge2 = Se3.describe("Destination policy rules for event pre-processing");
1680
- Ke = n3.object({ collector: n3.unknown().meta({ id: "DestinationContextCollector", title: "Collector.Instance", description: "Collector instance handed to the destination (runtime object)." }).describe("Collector instance (runtime object)"), config: Ae3.describe("Destination configuration"), data: n3.union([n3.unknown(), n3.array(n3.unknown())]).optional().describe("Transformed event data"), env: n3.unknown().meta({ id: "DestinationContextEnv", title: "Destination.Env", description: "Environment dependencies (destination-defined shape)." }).describe("Environment dependencies") }).meta({ id: "DestinationContext", title: "Destination.Context", description: "Destination context passed to init and push functions." }).describe("Destination context for init and push functions");
1681
- Qe = Ke.extend({ mapping: ve3.optional().describe("Resolved mapping rule for this specific event") }).meta({ id: "DestinationPushContext", title: "Destination.PushContext", description: "Destination context for push() with the resolved event mapping rule." }).describe("Push context with event-specific mapping");
1687
+ Ke2 = n3.object({ collector: n3.unknown().meta({ id: "DestinationContextCollector", title: "Collector.Instance", description: "Collector instance handed to the destination (runtime object)." }).describe("Collector instance (runtime object)"), config: Ae3.describe("Destination configuration"), data: n3.union([n3.unknown(), n3.array(n3.unknown())]).optional().describe("Transformed event data"), env: n3.unknown().meta({ id: "DestinationContextEnv", title: "Destination.Env", description: "Environment dependencies (destination-defined shape)." }).describe("Environment dependencies") }).meta({ id: "DestinationContext", title: "Destination.Context", description: "Destination context passed to init and push functions." }).describe("Destination context for init and push functions");
1688
+ Qe = Ke2.extend({ mapping: ve3.optional().describe("Resolved mapping rule for this specific event") }).meta({ id: "DestinationPushContext", title: "Destination.PushContext", description: "Destination context for push() with the resolved event mapping rule." }).describe("Push context with event-specific mapping");
1682
1689
  _e2 = Qe.describe("Batch push context with event-specific mapping");
1683
1690
  Xe = n3.object({ event: ee3.describe("The event to process"), mapping: ve3.optional().describe("Mapping rule for this event") }).meta({ id: "DestinationPushEvent", title: "Destination.PushEvent", description: "Single event paired with its resolved mapping rule (batch element)." }).describe("Event with optional mapping for batch processing");
1684
1691
  Ye = n3.array(Xe).meta({ id: "DestinationPushEvents", title: "Destination.PushEvents", description: "Array of events with mappings (batch input)." }).describe("Array of events with mappings");
1685
1692
  Ze = n3.object({ key: n3.string().describe('Batch key (usually mapping key like "product.view")'), events: n3.array(ee3).describe("Array of events in batch"), data: n3.array(n3.union([n3.unknown(), n3.array(n3.unknown())]).optional()).describe("Transformed data for each event"), mapping: ve3.optional().describe("Shared mapping rule for batch") }).meta({ id: "DestinationBatch", title: "Destination.Batch", description: "Batch of events grouped by mapping key for batch delivery." }).describe("Batch of events grouped by mapping key");
1686
1693
  ei = n3.union([n3.unknown(), n3.array(n3.unknown())]).meta({ id: "DestinationData", title: "Destination.Data", description: "Transformed event data delivered to the destination (Property, undefined, or array)." }).optional().describe("Transformed event data (Property, undefined, or array)");
1687
1694
  ii = n3.object({ config: Ae3.describe("Destination configuration"), queue: n3.array(ee3).optional().describe("Queued events awaiting consent"), dlq: n3.array(n3.tuple([ee3, n3.unknown()])).optional().describe("Dead letter queue (failed events with errors)"), type: n3.string().optional().describe("Destination type identifier"), env: n3.unknown().optional().describe("Environment dependencies"), init: n3.unknown().optional().describe("Initialization function"), push: n3.unknown().describe("Push function for single events"), pushBatch: n3.unknown().optional().describe("Batch push function"), on: n3.unknown().optional().describe("Event lifecycle hook function") }).meta({ id: "DestinationInstance", title: "Destination.Instance", description: "Destination instance (runtime object with init/push/pushBatch/on)." }).describe("Destination instance (runtime object with functions)");
1688
- ti = n3.object({ code: ii.describe("Destination instance with implementation"), config: Ve.optional().describe("Partial configuration overrides"), env: n3.unknown().optional().describe("Partial environment overrides") }).meta({ id: "DestinationInit", title: "Destination.Init", description: "Destination initialization bundle (instance code + config + env)." }).describe("Destination initialization configuration");
1695
+ ti = n3.object({ code: ii.describe("Destination instance with implementation"), config: Ve2.optional().describe("Partial configuration overrides"), env: n3.unknown().optional().describe("Partial environment overrides") }).meta({ id: "DestinationInit", title: "Destination.Init", description: "Destination initialization bundle (instance code + config + env)." }).describe("Destination initialization configuration");
1689
1696
  ni = n3.record(n3.string(), ti).meta({ id: "DestinationInitDestinations", title: "Destination.InitDestinations", description: "Map of destination IDs to initialization configurations." }).describe("Map of destination IDs to initialization configurations");
1690
1697
  oi = n3.record(n3.string(), ii).meta({ id: "DestinationDestinations", title: "Destination.Destinations", description: "Map of destination IDs to runtime destination instances." }).describe("Map of destination IDs to runtime instances");
1691
1698
  ri = n3.object({ type: n3.string().describe('Destination type ("gtag", "meta", "bigquery")'), data: n3.unknown().optional().describe("Response from push()"), error: n3.unknown().optional().describe("Error if failed") }).meta({ id: "DestinationRef", title: "Destination.Ref", description: "Reference to a destination outcome (type + response data or error)." }).describe("Destination reference with type and response data");
@@ -1693,8 +1700,8 @@ var init_dev = __esm({
1693
1700
  si = n3.object({ ok: n3.boolean().describe("True if nothing failed"), event: n3.unknown().optional().describe("The processed event"), done: n3.record(n3.string(), ri).optional().describe("Destinations that processed successfully"), queued: n3.record(n3.string(), ri).optional().describe("Destinations that queued events"), failed: n3.record(n3.string(), ri).optional().describe("Destinations that failed to process") }).meta({ id: "DestinationResult", title: "Destination.Result", description: "Overall push result aggregated across all destinations (done/queued/failed maps)." }).describe("Push result with destination outcomes");
1694
1701
  ci = n3.array(n3.tuple([ee3, n3.unknown()])).meta({ id: "DestinationDLQ", title: "Destination.DLQ", description: "Dead-letter queue: list of [event, error] tuples." }).describe("Dead letter queue: [(event, error), ...]");
1695
1702
  li = o(Ae3);
1696
- di = o(Ve);
1697
- pi = o(Ke);
1703
+ di = o(Ve2);
1704
+ pi = o(Ke2);
1698
1705
  ui = o(Qe);
1699
1706
  mi = o(Ze);
1700
1707
  fi = o(ii);
@@ -1743,7 +1750,7 @@ var init_dev = __esm({
1743
1750
  Zi = o(Xi);
1744
1751
  et = o(Yi);
1745
1752
  it = {};
1746
- i(it, { BundlePackageSchema: () => st2, BundleSchema: () => ct2, CodeSchema: () => lt, ConfigSchema: () => kt, ContractActionsSchema: () => St, ContractEventsSchema: () => vt2, ContractRuleSchema: () => yt2, ContractSchema: () => wt2, ContractSchemaEntry: () => ht2, DefinitionsSchema: () => ot, DestinationSchema: () => gt2, FlowSchema: () => Ct, JsonSchema: () => xt, PrimitiveSchema: () => tt, SettingsSchema: () => rt, SourceSchema: () => mt2, StepExampleSchema: () => pt, StepExamplesSchema: () => ut, StoreSchema: () => bt2, TransformerSchema: () => ft2, TriggerDescriptorSchema: () => dt2, VariablesSchema: () => nt, configJsonSchema: () => It, contractJsonSchema: () => Nt, contractRuleJsonSchema: () => Lt, destinationJsonSchema: () => Rt, flowConfigJsonSchema: () => Ot, flowJsonSchema: () => Jt, parseConfig: () => Pt, parseFlow: () => Et, safeParseConfig: () => Dt, safeParseFlow: () => jt2, sourceJsonSchema: () => Ft, storeJsonSchema: () => Tt, transformerJsonSchema: () => Mt });
1753
+ i(it, { BundlePackageSchema: () => st2, BundleSchema: () => ct2, CodeSchema: () => lt2, ConfigSchema: () => kt, ContractActionsSchema: () => St, ContractEventsSchema: () => vt2, ContractRuleSchema: () => yt2, ContractSchema: () => wt2, ContractSchemaEntry: () => ht2, DefinitionsSchema: () => ot, DestinationSchema: () => gt2, FlowSchema: () => Ct, JsonSchema: () => xt, PrimitiveSchema: () => tt, SettingsSchema: () => rt, SourceSchema: () => mt2, StepExampleSchema: () => pt, StepExamplesSchema: () => ut, StoreSchema: () => bt2, TransformerSchema: () => ft, TriggerDescriptorSchema: () => dt2, VariablesSchema: () => nt, configJsonSchema: () => It, contractJsonSchema: () => Nt, contractRuleJsonSchema: () => Lt, destinationJsonSchema: () => Rt, flowConfigJsonSchema: () => Ot, flowJsonSchema: () => Jt, parseConfig: () => Pt, parseFlow: () => Et, safeParseConfig: () => Dt, safeParseFlow: () => jt2, sourceJsonSchema: () => Ft, storeJsonSchema: () => Tt, transformerJsonSchema: () => Mt });
1747
1754
  tt = n3.union([n3.string(), n3.number(), n3.boolean()]).meta({ id: "FlowPrimitive", title: "Flow.Primitive", description: "Primitive value: string, number, or boolean." }).describe("Primitive value: string, number, or boolean");
1748
1755
  nt = n3.record(n3.string(), tt).meta({ id: "FlowVariables", title: "Flow.Variables", description: "Variables for interpolation (string/number/boolean values)." }).describe("Variables for interpolation");
1749
1756
  ot = n3.record(n3.string(), n3.unknown().meta({ id: "FlowDefinition", title: "Flow.Definition", description: "Single named definition value (arbitrary shape)." })).meta({ id: "FlowDefinitions", title: "Flow.Definitions", description: "Reusable configuration definitions referenced via $def.name." }).describe("Reusable configuration definitions");
@@ -1751,28 +1758,28 @@ var init_dev = __esm({
1751
1758
  at2 = /^(@[a-z0-9\-~][a-z0-9\-._~]*\/)?[a-z0-9\-~][a-z0-9\-._~]*$/;
1752
1759
  st2 = n3.object({ version: n3.string().optional(), imports: n3.array(n3.string()).optional(), path: n3.string().optional() }).meta({ id: "FlowBundlePackage", title: "Flow.BundlePackage", description: "Per-package bundle spec (version / imports / local path)." });
1753
1760
  ct2 = n3.object({ packages: n3.record(n3.string().regex(at2, "Invalid npm package name"), st2).optional().describe("NPM packages to bundle, keyed by package name"), overrides: n3.record(n3.string().regex(at2, "Invalid npm package name"), n3.string().min(1, "Override version cannot be empty")).optional().describe("Transitive dependency version pins") }).strict().meta({ id: "FlowBundle", title: "Flow.Bundle", description: "Bundle configuration (packages + overrides)." }).describe("Bundle configuration (packages + overrides)");
1754
- lt = n3.object({ push: n3.string().min(1, "Push function cannot be empty").describe('JavaScript function for processing events. Must start with "$code:" prefix.'), type: n3.string().optional().describe("Optional type identifier for the inline instance"), init: n3.string().optional().describe("Optional initialization function. Use $code: prefix for inline JavaScript.") }).meta({ id: "FlowCode", title: "Flow.Code", description: "Inline code block for custom sources / transformers / destinations / stores." }).describe("Inline code for custom components");
1761
+ lt2 = n3.object({ push: n3.string().min(1, "Push function cannot be empty").describe('JavaScript function for processing events. Must start with "$code:" prefix.'), type: n3.string().optional().describe("Optional type identifier for the inline instance"), init: n3.string().optional().describe("Optional initialization function. Use $code: prefix for inline JavaScript.") }).meta({ id: "FlowCode", title: "Flow.Code", description: "Inline code block for custom sources / transformers / destinations / stores." }).describe("Inline code for custom components");
1755
1762
  dt2 = n3.object({ type: n3.string().optional().describe("Trigger mechanism (e.g., click, POST, load)"), options: n3.unknown().optional().describe("Mechanism-specific options") }).meta({ id: "TriggerDescriptor", title: "Trigger.Descriptor", description: "Source trigger metadata (mechanism + options) used by step examples." });
1756
1763
  pt = n3.object({ title: n3.string().optional().describe("Human-readable title (overrides default heading)"), description: n3.string().optional().describe("Human-readable description"), public: n3.boolean().optional().describe("Whether this example is shown in docs/UI/MCP default output (default: true). Set false for test-only fixtures."), in: n3.unknown().optional().describe("Input to the step"), trigger: dt2.optional().describe("Source trigger metadata"), mapping: n3.unknown().optional().describe("Mapping configuration"), out: n3.unknown().optional().describe("Expected output from the step"), command: n3.enum(["config", "consent", "user", "run"]).optional().describe("Invoke elb('walker <command>', in) instead of pushing in as an event") }).meta({ id: "FlowStepExample", title: "Flow.StepExample", description: "Named example with input/output pair used for step testing." }).describe("Named example with input/output pair");
1757
1764
  ut = n3.record(n3.string(), pt).meta({ id: "FlowStepExamples", title: "Flow.StepExamples", description: "Named step examples keyed by scenario name." }).describe("Named step examples for testing and documentation");
1758
- mt2 = n3.object({ package: n3.string().min(1, "Package name cannot be empty").optional().describe('Package specifier with optional version (e.g., "@walkeros/web-source-browser@2.0.0")'), code: n3.union([n3.string(), lt]).optional().describe('Either a named export string (e.g., "sourceExpress") or an inline code object with push function'), config: n3.unknown().meta({ id: "FlowSourceConfig", title: "Source.Config", description: "Source-specific configuration object (Source.Config)." }).optional().describe("Source-specific configuration object"), env: n3.unknown().meta({ id: "FlowSourceEnv", title: "Source.BaseEnv", description: "Source environment configuration (Source.BaseEnv overrides)." }).optional().describe("Source environment configuration"), primary: n3.boolean().optional().describe("Mark as primary source (provides main elb). Only one source should be primary."), variables: nt.optional().describe("Source-level variables (highest priority in cascade)"), definitions: ot.optional().describe("Source-level definitions (highest priority in cascade)"), next: ze2.optional().describe("Pre-collector transformer chain. String, string[], or NextRule[] for conditional routing based on ingest data."), before: ze2.optional().describe("Pre-source transformer chain (consent-exempt). Handles transport-level preprocessing."), examples: ut.optional().describe("Named step examples for testing and documentation (stripped during bundling)"), cache: Ue2.optional().describe("Cache configuration for this source (match \u2192 key \u2192 ttl rules)") }).meta({ id: "FlowSource", title: "Flow.Source", description: "Source package reference with configuration, env, chains, and examples." }).describe("Source package reference with configuration");
1759
- ft2 = n3.object({ package: n3.string().min(1, "Package name cannot be empty").optional().describe('Package specifier with optional version (e.g., "@walkeros/transformer-enricher@1.0.0")'), code: n3.union([n3.string(), lt]).optional().describe('Either a named export string (e.g., "transformerEnricher") or an inline code object with push function'), config: n3.unknown().meta({ id: "FlowTransformerConfig", title: "Transformer.Config", description: "Transformer-specific configuration object." }).optional().describe("Transformer-specific configuration object"), env: n3.unknown().meta({ id: "FlowTransformerEnv", title: "Transformer.Env", description: "Transformer environment configuration." }).optional().describe("Transformer environment configuration"), before: ze2.optional().describe("Pre-transformer chain. Runs before this transformer push function."), next: ze2.optional().describe("Next transformer in chain. String, string[], or NextRule[] for conditional routing."), variables: nt.optional().describe("Transformer-level variables (highest priority in cascade)"), definitions: ot.optional().describe("Transformer-level definitions (highest priority in cascade)"), examples: ut.optional().describe("Named step examples for testing and documentation (stripped during bundling)"), cache: Ue2.optional().describe("Cache configuration for this transformer (match \u2192 key \u2192 ttl rules)") }).meta({ id: "FlowTransformer", title: "Flow.Transformer", description: "Transformer package reference with configuration, env, chains, and cache." }).describe("Transformer package reference with configuration");
1760
- gt2 = n3.object({ package: n3.string().min(1, "Package name cannot be empty").optional().describe('Package specifier with optional version (e.g., "@walkeros/web-destination-gtag@2.0.0")'), code: n3.union([n3.string(), lt]).optional().describe('Either a named export string (e.g., "destinationAnalytics") or an inline code object with push function'), config: n3.unknown().meta({ id: "FlowDestinationConfig", title: "Destination.Config", description: "Destination-specific configuration object." }).optional().describe("Destination-specific configuration object"), env: n3.unknown().meta({ id: "FlowDestinationEnv", title: "Destination.Env", description: "Destination environment configuration." }).optional().describe("Destination environment configuration"), variables: nt.optional().describe("Destination-level variables (highest priority in cascade)"), definitions: ot.optional().describe("Destination-level definitions (highest priority in cascade)"), before: ze2.optional().describe("Post-collector transformer chain. String, string[], or NextRule[] for conditional routing."), next: ze2.optional().describe("Post-push transformer chain. Push response available at context.ingest._response."), examples: ut.optional().describe("Named step examples for testing and documentation (stripped during bundling)"), cache: Ue2.optional().describe("Cache configuration for this destination (match \u2192 key \u2192 ttl rules)") }).meta({ id: "FlowDestination", title: "Flow.Destination", description: "Destination package reference with configuration, env, chains, and cache." }).describe("Destination package reference with configuration");
1761
- bt2 = n3.object({ package: n3.string().min(1, "Package name cannot be empty").optional().describe("Store package specifier with optional version"), code: n3.union([n3.string(), lt]).optional().describe("Named export string or inline code definition"), config: n3.unknown().meta({ id: "FlowStoreConfig", title: "Store.Config", description: "Store-specific configuration object." }).optional().describe("Store-specific configuration object"), env: n3.unknown().meta({ id: "FlowStoreEnv", title: "Store.Env", description: "Store environment configuration." }).optional().describe("Store environment configuration"), variables: nt.optional().describe("Store-level variables (highest priority in cascade)"), definitions: ot.optional().describe("Store-level definitions (highest priority in cascade)"), examples: ut.optional().describe("Named step examples for testing and documentation (stripped during bundling)") }).meta({ id: "FlowStore", title: "Flow.Store", description: "Store package reference with configuration, env, and examples." }).describe("Store package reference with configuration");
1765
+ mt2 = n3.object({ package: n3.string().min(1, "Package name cannot be empty").optional().describe('Package specifier with optional version (e.g., "@walkeros/web-source-browser@2.0.0")'), code: n3.union([n3.string(), lt2]).optional().describe('Either a named export string (e.g., "sourceExpress") or an inline code object with push function'), config: n3.unknown().meta({ id: "FlowSourceConfig", title: "Source.Config", description: "Source-specific configuration object (Source.Config)." }).optional().describe("Source-specific configuration object"), env: n3.unknown().meta({ id: "FlowSourceEnv", title: "Source.BaseEnv", description: "Source environment configuration (Source.BaseEnv overrides)." }).optional().describe("Source environment configuration"), primary: n3.boolean().optional().describe("Mark as primary source (provides main elb). Only one source should be primary."), variables: nt.optional().describe("Source-level variables (highest priority in cascade)"), definitions: ot.optional().describe("Source-level definitions (highest priority in cascade)"), next: ze2.optional().describe("Pre-collector transformer chain. String, string[], or NextRule[] for conditional routing based on ingest data."), before: ze2.optional().describe("Pre-source transformer chain (consent-exempt). Handles transport-level preprocessing."), examples: ut.optional().describe("Named step examples for testing and documentation (stripped during bundling)"), cache: Ue2.optional().describe("Cache configuration for this source (match \u2192 key \u2192 ttl rules)") }).meta({ id: "FlowSource", title: "Flow.Source", description: "Source package reference with configuration, env, chains, and examples." }).describe("Source package reference with configuration");
1766
+ ft = n3.object({ package: n3.string().min(1, "Package name cannot be empty").optional().describe('Package specifier with optional version (e.g., "@walkeros/transformer-enricher@1.0.0")'), code: n3.union([n3.string(), lt2]).optional().describe('Either a named export string (e.g., "transformerEnricher") or an inline code object with push function'), config: n3.unknown().meta({ id: "FlowTransformerConfig", title: "Transformer.Config", description: "Transformer-specific configuration object." }).optional().describe("Transformer-specific configuration object"), env: n3.unknown().meta({ id: "FlowTransformerEnv", title: "Transformer.Env", description: "Transformer environment configuration." }).optional().describe("Transformer environment configuration"), before: ze2.optional().describe("Pre-transformer chain. Runs before this transformer push function."), next: ze2.optional().describe("Next transformer in chain. String, string[], or NextRule[] for conditional routing."), variables: nt.optional().describe("Transformer-level variables (highest priority in cascade)"), definitions: ot.optional().describe("Transformer-level definitions (highest priority in cascade)"), examples: ut.optional().describe("Named step examples for testing and documentation (stripped during bundling)"), cache: Ue2.optional().describe("Cache configuration for this transformer (match \u2192 key \u2192 ttl rules)") }).meta({ id: "FlowTransformer", title: "Flow.Transformer", description: "Transformer package reference with configuration, env, chains, and cache." }).describe("Transformer package reference with configuration");
1767
+ gt2 = n3.object({ package: n3.string().min(1, "Package name cannot be empty").optional().describe('Package specifier with optional version (e.g., "@walkeros/web-destination-gtag@2.0.0")'), code: n3.union([n3.string(), lt2]).optional().describe('Either a named export string (e.g., "destinationAnalytics") or an inline code object with push function'), config: n3.unknown().meta({ id: "FlowDestinationConfig", title: "Destination.Config", description: "Destination-specific configuration object." }).optional().describe("Destination-specific configuration object"), env: n3.unknown().meta({ id: "FlowDestinationEnv", title: "Destination.Env", description: "Destination environment configuration." }).optional().describe("Destination environment configuration"), variables: nt.optional().describe("Destination-level variables (highest priority in cascade)"), definitions: ot.optional().describe("Destination-level definitions (highest priority in cascade)"), before: ze2.optional().describe("Post-collector transformer chain. String, string[], or NextRule[] for conditional routing."), next: ze2.optional().describe("Post-push transformer chain. Push response available at context.ingest._response."), examples: ut.optional().describe("Named step examples for testing and documentation (stripped during bundling)"), cache: Ue2.optional().describe("Cache configuration for this destination (match \u2192 key \u2192 ttl rules)") }).meta({ id: "FlowDestination", title: "Flow.Destination", description: "Destination package reference with configuration, env, chains, and cache." }).describe("Destination package reference with configuration");
1768
+ bt2 = n3.object({ package: n3.string().min(1, "Package name cannot be empty").optional().describe("Store package specifier with optional version"), code: n3.union([n3.string(), lt2]).optional().describe("Named export string or inline code definition"), config: n3.unknown().meta({ id: "FlowStoreConfig", title: "Store.Config", description: "Store-specific configuration object." }).optional().describe("Store-specific configuration object"), env: n3.unknown().meta({ id: "FlowStoreEnv", title: "Store.Env", description: "Store environment configuration." }).optional().describe("Store environment configuration"), variables: nt.optional().describe("Store-level variables (highest priority in cascade)"), definitions: ot.optional().describe("Store-level definitions (highest priority in cascade)"), examples: ut.optional().describe("Named step examples for testing and documentation (stripped during bundling)") }).meta({ id: "FlowStore", title: "Flow.Store", description: "Store package reference with configuration, env, and examples." }).describe("Store package reference with configuration");
1762
1769
  ht2 = n3.record(n3.string(), n3.unknown()).meta({ id: "FlowContractSchemaEntry", title: "Flow.ContractSchemaEntry", description: "JSON Schema object for event validation with description/examples annotations." }).describe("JSON Schema object for event validation with description/examples annotations");
1763
1770
  St = n3.record(n3.string(), ht2).meta({ id: "FlowContractActions", title: "Flow.ContractActions", description: "Action-level contract entries keyed by action name." }).describe("Action-level contract entries");
1764
1771
  vt2 = n3.record(n3.string(), St).meta({ id: "FlowContractEvents", title: "Flow.ContractEvents", description: "Entity-action event schemas (entity \u2192 action \u2192 schema)." }).describe("Entity-action event schemas");
1765
1772
  yt2 = n3.object({ extends: n3.string().optional().describe("Inherit from another named contract"), tagging: n3.number().optional().describe("Tagging level (used by validators / runtime tagging policy)"), description: n3.string().optional().describe("Human-readable description"), globals: ht2.optional().describe("JSON Schema for event.globals"), context: ht2.optional().describe("JSON Schema for event.context"), custom: ht2.optional().describe("JSON Schema for event.custom"), user: ht2.optional().describe("JSON Schema for event.user"), consent: ht2.optional().describe("JSON Schema for event.consent"), events: vt2.optional().describe("Entity-action event schemas") }).meta({ id: "FlowContractRule", title: "Flow.ContractRule", description: "Named contract rule with optional sections (globals/context/custom/user/consent) and event schemas." }).describe("Named contract rule with optional sections and events");
1766
1773
  wt2 = n3.record(n3.string(), yt2).meta({ id: "FlowContract", title: "Flow.Contract", description: "Named contracts map with optional extends inheritance." }).describe("Named contracts with optional extends inheritance");
1767
1774
  kt = n3.object({ platform: n3.enum(["web", "server"]).describe("Platform identity for this flow. Drives bundle target/format."), url: n3.string().min(1).optional().describe("Public URL where this flow is reachable (for cross-flow $flow.X.url references)."), settings: rt.optional().describe("Free-form key-value settings consumed by the platform runtime."), bundle: ct2.optional().describe("Bundle configuration: NPM packages, transitive dependency overrides.") }).meta({ id: "FlowConfig", title: "Flow.Config", description: "Per-flow configuration block: platform identity, optional public URL, settings, bundle." }).describe("Per-flow configuration block");
1768
- Ct = n3.object({ config: kt.optional().describe("Per-flow configuration: platform, url, settings, bundle."), sources: n3.record(n3.string(), mt2).optional().describe("Source configurations (data capture) keyed by unique identifier"), destinations: n3.record(n3.string(), gt2).optional().describe("Destination configurations (data output) keyed by unique identifier"), transformers: n3.record(n3.string(), ft2).optional().describe("Transformer configurations (event transformation) keyed by unique identifier"), stores: n3.record(n3.string(), bt2).optional().describe("Store configurations (key-value storage) keyed by unique identifier"), collector: n3.unknown().meta({ id: "FlowCollector", title: "Collector.InitConfig", description: "Collector configuration for event processing (Collector.InitConfig)." }).optional().describe("Collector configuration for event processing (uses Collector.InitConfig)"), variables: nt.optional().describe("Flow-level variables (override root variables, overridden by source/destination variables)"), definitions: ot.optional().describe("Flow-level definitions (extend root definitions, overridden by source/destination definitions)") }).meta({ id: "Flow", title: "Flow", description: "Single flow definition (one deployment target): config, sources, destinations, transformers, stores, collector." }).describe("Single flow definition for one deployment target");
1775
+ Ct = n3.object({ config: kt.optional().describe("Per-flow configuration: platform, url, settings, bundle."), sources: n3.record(n3.string(), mt2).optional().describe("Source configurations (data capture) keyed by unique identifier"), destinations: n3.record(n3.string(), gt2).optional().describe("Destination configurations (data output) keyed by unique identifier"), transformers: n3.record(n3.string(), ft).optional().describe("Transformer configurations (event transformation) keyed by unique identifier"), stores: n3.record(n3.string(), bt2).optional().describe("Store configurations (key-value storage) keyed by unique identifier"), collector: n3.unknown().meta({ id: "FlowCollector", title: "Collector.InitConfig", description: "Collector configuration for event processing (Collector.InitConfig)." }).optional().describe("Collector configuration for event processing (uses Collector.InitConfig)"), variables: nt.optional().describe("Flow-level variables (override root variables, overridden by source/destination variables)"), definitions: ot.optional().describe("Flow-level definitions (extend root definitions, overridden by source/destination definitions)") }).meta({ id: "Flow", title: "Flow", description: "Single flow definition (one deployment target): config, sources, destinations, transformers, stores, collector." }).describe("Single flow definition for one deployment target");
1769
1776
  xt = n3.object({ version: n3.literal(4).describe("Configuration schema version (v4, current)."), $schema: n3.string().url("Schema URL must be a valid URL").optional().describe('JSON Schema reference for IDE validation (e.g., "https://walkeros.io/schema/flow/v4.json")'), include: n3.array(n3.string()).optional().describe("Folders to include in the bundle output"), variables: nt.optional().describe("Shared variables for interpolation across all flows (use $var.name syntax)"), definitions: ot.optional().describe("Reusable configuration definitions (use $def.name syntax)"), contract: wt2.optional().describe("Named contracts with extends inheritance and dot-path references"), flows: n3.record(n3.string(), Ct).refine((e3) => Object.keys(e3).length > 0, { message: "At least one flow is required" }).describe("Named flow configurations (e.g., production, staging, development)") }).meta({ id: "FlowJson", title: "Flow.Json", description: "walkerOS root configuration (walkeros.config.json) v4: version, variables, definitions, contract, named flows." }).describe("walkerOS root configuration (walkeros.config.json)");
1770
1777
  It = n3.toJSONSchema(xt, { target: "draft-7" });
1771
1778
  Jt = o(Ct);
1772
1779
  Ot = o(kt);
1773
1780
  Ft = o(mt2);
1774
1781
  Rt = o(gt2);
1775
- Mt = o(ft2);
1782
+ Mt = o(ft);
1776
1783
  Tt = o(bt2);
1777
1784
  Lt = o(yt2);
1778
1785
  Nt = o(wt2);
@@ -1979,15 +1986,15 @@ function loadBundleConfig(rawConfig, options) {
1979
1986
  const config = validateFlowConfig(rawConfig);
1980
1987
  const availableFlows = getAvailableFlows(config);
1981
1988
  const flowName = resolveFlow(config, options.flowName, availableFlows);
1982
- let flowSettings = V(config, flowName, { deferred: true });
1983
- const platform = q(flowSettings);
1989
+ let flowSettings = q(config, flowName, { deferred: true });
1990
+ const platform = J(flowSettings);
1984
1991
  if (!platform) {
1985
1992
  throw new Error(
1986
1993
  `Invalid configuration: flow "${flowName}" must have config.platform set to "web" or "server".`
1987
1994
  );
1988
1995
  }
1989
1996
  if (platform === "web") {
1990
- flowSettings = V(config, flowName);
1997
+ flowSettings = q(config, flowName);
1991
1998
  }
1992
1999
  const buildDefaults = getBuildDefaults(platform);
1993
2000
  const packages = flowSettings.config?.bundle?.packages || {};
@@ -2794,7 +2801,7 @@ async function bundleCore(flowSettings, buildOptions, logger, showStats = false)
2794
2801
  for (const pkg of stepPackages) {
2795
2802
  const isLocalPath = pkg.startsWith(".") || pkg.startsWith("/");
2796
2803
  if (isLocalPath) {
2797
- const varName = B(pkg);
2804
+ const varName = K(pkg);
2798
2805
  if (!buildOptions.packages[varName]) {
2799
2806
  buildOptions.packages[varName] = {
2800
2807
  path: pkg,
@@ -3182,7 +3189,7 @@ async function generateImportStatements(packages, destinationPackages, sourcePac
3182
3189
  const hasExplicitCode = explicitCodeImports.has(packageName);
3183
3190
  const namedImportsToGenerate = [];
3184
3191
  if (isUsedByDestOrSource && !hasExplicitCode) {
3185
- const varName = B(packageName);
3192
+ const varName = K(packageName);
3186
3193
  importStatements.push(`import ${varName} from '${packageName}';`);
3187
3194
  }
3188
3195
  if (hasExplicitCode) {
@@ -3224,7 +3231,7 @@ async function generateImportStatements(packages, destinationPackages, sourcePac
3224
3231
  const pkgJson = await fs9.readJSON(pkgJsonPath);
3225
3232
  const exports = pkgJson.exports;
3226
3233
  if (exports && typeof exports === "object" && "./dev" in exports) {
3227
- const varName = `__dev_${B(packageName)}`;
3234
+ const varName = `__dev_${K(packageName)}`;
3228
3235
  importStatements.push(
3229
3236
  `import * as ${varName} from '${packageName}/dev';`
3230
3237
  );
@@ -3371,7 +3378,7 @@ function buildSplitConfigObject(flowSettings, explicitCodeImports) {
3371
3378
  if (step.code && typeof step.code === "string" && step.package && explicitCodeImports.has(step.package)) {
3372
3379
  return step.code;
3373
3380
  }
3374
- return B(step.package);
3381
+ return K(step.package);
3375
3382
  }
3376
3383
  function getStepProps(step) {
3377
3384
  const props = {};
@@ -3900,7 +3907,7 @@ async function bundleCommand(options) {
3900
3907
  }
3901
3908
  }
3902
3909
  if (options.dockerfile && options.output) {
3903
- const platform = q(flowSettings);
3910
+ const platform = J(flowSettings);
3904
3911
  if (platform) {
3905
3912
  const outputDir = path12.dirname(buildOptions.output);
3906
3913
  const customFile = typeof options.dockerfile === "string" ? options.dockerfile : void 0;
@@ -4043,22 +4050,22 @@ import {
4043
4050
  mkdirSync as mkdirSync3,
4044
4051
  copyFileSync,
4045
4052
  writeFileSync as writeFileSync3,
4046
- readFileSync as readFileSync4
4053
+ readFileSync as readFileSync3
4047
4054
  } from "fs";
4048
- import { join as join4 } from "path";
4055
+ import { join as join3 } from "path";
4049
4056
  function writeCache(cacheDir, bundlePath, configContent, version) {
4050
4057
  mkdirSync3(cacheDir, { recursive: true });
4051
- copyFileSync(bundlePath, join4(cacheDir, "bundle.mjs"));
4052
- writeFileSync3(join4(cacheDir, "config.json"), configContent, "utf-8");
4058
+ copyFileSync(bundlePath, join3(cacheDir, "bundle.mjs"));
4059
+ writeFileSync3(join3(cacheDir, "config.json"), configContent, "utf-8");
4053
4060
  const meta = { version, timestamp: Date.now() };
4054
- writeFileSync3(join4(cacheDir, "meta.json"), JSON.stringify(meta), "utf-8");
4061
+ writeFileSync3(join3(cacheDir, "meta.json"), JSON.stringify(meta), "utf-8");
4055
4062
  }
4056
4063
  function readCache(cacheDir) {
4057
4064
  try {
4058
- const metaPath = join4(cacheDir, "meta.json");
4059
- const bundlePath = join4(cacheDir, "bundle.mjs");
4065
+ const metaPath = join3(cacheDir, "meta.json");
4066
+ const bundlePath = join3(cacheDir, "bundle.mjs");
4060
4067
  if (!existsSync3(metaPath) || !existsSync3(bundlePath)) return null;
4061
- const meta = JSON.parse(readFileSync4(metaPath, "utf-8"));
4068
+ const meta = JSON.parse(readFileSync3(metaPath, "utf-8"));
4062
4069
  return { bundlePath, version: meta.version };
4063
4070
  } catch {
4064
4071
  return null;
@@ -4066,9 +4073,9 @@ function readCache(cacheDir) {
4066
4073
  }
4067
4074
  function readCacheConfig(cacheDir) {
4068
4075
  try {
4069
- const configPath = join4(cacheDir, "config.json");
4076
+ const configPath = join3(cacheDir, "config.json");
4070
4077
  if (!existsSync3(configPath)) return null;
4071
- return readFileSync4(configPath, "utf-8");
4078
+ return readFileSync3(configPath, "utf-8");
4072
4079
  } catch {
4073
4080
  return null;
4074
4081
  }
@@ -4570,11 +4577,6 @@ function printBanner(version) {
4570
4577
  console.error("");
4571
4578
  }
4572
4579
 
4573
- // src/telemetry/emitter.ts
4574
- import { readFileSync as readFileSync3 } from "fs";
4575
- import { join as join3, dirname as dirname2 } from "path";
4576
- import { fileURLToPath as fileURLToPath2 } from "url";
4577
-
4578
4580
  // ../collector/dist/index.mjs
4579
4581
  init_dist();
4580
4582
  init_dist();
@@ -4631,7 +4633,7 @@ async function ne2(e3, n4, t3) {
4631
4633
  if (n4.init && !n4.config.init) {
4632
4634
  const o2 = n4.type || "unknown", s4 = e3.logger.scope(`transformer:${o2}`), r3 = { collector: e3, logger: s4, id: t3, ingest: k(t3), config: n4.config, env: se2(n4.config.env) };
4633
4635
  s4.debug("init");
4634
- const a4 = await qe(n4.init, "TransformerInit", e3.hooks, e3.logger)(r3);
4636
+ const a4 = await Je(n4.init, "TransformerInit", e3.hooks, e3.logger)(r3);
4635
4637
  if (false === a4) return false;
4636
4638
  n4.config = { ...a4 || n4.config, env: a4?.env || n4.config.env, init: true }, s4.debug("init done");
4637
4639
  }
@@ -4640,7 +4642,7 @@ async function ne2(e3, n4, t3) {
4640
4642
  async function te(e3, n4, t3, o2, s4, r3) {
4641
4643
  const a4 = n4.type || "unknown", i2 = e3.logger.scope(`transformer:${a4}`), c3 = { collector: e3, logger: i2, id: t3, ingest: s4, config: n4.config, env: { ...se2(n4.config.env), ...r3 ? { respond: r3 } : {} } };
4642
4644
  i2.debug("push", { event: o2.name });
4643
- const u3 = await qe(n4.push, "TransformerPush", e3.hooks, e3.logger)(o2, c3);
4645
+ const u3 = await Je(n4.push, "TransformerPush", e3.hooks, e3.logger)(o2, c3);
4644
4646
  return i2.debug("push done"), u3;
4645
4647
  }
4646
4648
  async function oe(e3, n4, t3, o2, s4, r3, a4) {
@@ -4756,22 +4758,22 @@ async function re2(e3, n4, t3) {
4756
4758
  if (d2) {
4757
4759
  const t5 = X2(d2, e3);
4758
4760
  if (t5) {
4759
- const e4 = bt(l2), o4 = vt(d2, t5, e4, `s:${n4}`);
4760
- if (o4) {
4761
- if ("HIT" === o4.status && void 0 !== o4.value && d2.full) {
4762
- let n5 = o4.value;
4763
- return o4.rule.update && (n5 = await jt(n5, o4.rule.update, { ...e4, cache: { status: "HIT" } })), f2?.(n5), { ok: true };
4761
+ const o4 = bt(l2), s5 = vt(d2, t5, o4, `s:${n4}`);
4762
+ if (s5) {
4763
+ if ("HIT" === s5.status && void 0 !== s5.value && d2.full) {
4764
+ let n5 = s5.value;
4765
+ return s5.rule.update && (n5 = await jt(n5, s5.rule.update, { ...o4, cache: { status: "HIT" } }, e3)), f2?.(n5), { ok: true };
4764
4766
  }
4765
- if ("MISS" === o4.status && d2.full && f2) {
4766
- const n5 = f2, s5 = o4.rule.update, a6 = { ...e4, cache: { status: "MISS" } }, i4 = o4.key, c5 = o4.rule.ttl;
4767
- f2 = (e5) => {
4768
- wt(t5, i4, e5, c5), s5 ? r4 = (async () => {
4769
- const t6 = await jt(e5, s5, a6);
4767
+ if ("MISS" === s5.status && d2.full && f2) {
4768
+ const n5 = f2, a6 = s5.rule.update, i4 = { ...o4, cache: { status: "MISS" } }, c5 = s5.key, u5 = s5.rule.ttl;
4769
+ f2 = (o5) => {
4770
+ wt(t5, c5, o5, u5), a6 ? r4 = (async () => {
4771
+ const t6 = await jt(o5, a6, i4, e3);
4770
4772
  n5(t6);
4771
- })() : n5(e5);
4773
+ })() : n5(o5);
4772
4774
  };
4773
4775
  }
4774
- "MISS" !== o4.status || d2.full || wt(t5, o4.key, true, o4.rule.ttl);
4776
+ "MISS" !== s5.status || d2.full || wt(t5, s5.key, true, s5.rule.ttl);
4775
4777
  }
4776
4778
  }
4777
4779
  }
@@ -4801,18 +4803,21 @@ async function ae2(e3, n4 = {}) {
4801
4803
  }
4802
4804
  return t3;
4803
4805
  }
4804
- async function ie2(e3, n4, t3) {
4806
+ function ie2(e3, n4) {
4807
+ return { collector: e3, logger: e3.logger.scope("on").scope(String(n4)) };
4808
+ }
4809
+ async function ce2(e3, n4, t3) {
4805
4810
  const o2 = e3.on, s4 = o2[n4] || [], r3 = Y(t3) ? t3 : [t3];
4806
4811
  r3.forEach((e4) => {
4807
4812
  s4.push(e4);
4808
- }), o2[n4] = s4, ue2(e3, n4, r3);
4813
+ }), o2[n4] = s4, fe2(e3, n4, r3);
4809
4814
  }
4810
- function ce2(e3, n4, t3, o2, s4) {
4815
+ function ue2(e3, n4, t3, o2, s4) {
4811
4816
  if (!n4.on) return;
4812
- const r3 = n4.type || "unknown", a4 = e3.logger.scope(r3).scope("on").scope(o2), i2 = { collector: e3, logger: a4, id: t3, config: n4.config, data: s4, env: ve2(n4.env, n4.config.env) };
4817
+ const r3 = n4.type || "unknown", a4 = e3.logger.scope(r3).scope("on").scope(o2), i2 = { collector: e3, logger: a4, id: t3, config: n4.config, data: s4, env: ke(n4.env, n4.config.env) };
4813
4818
  Re(n4.on)(o2, i2);
4814
4819
  }
4815
- function ue2(e3, n4, o2, s4) {
4820
+ function fe2(e3, n4, o2, s4) {
4816
4821
  let r3;
4817
4822
  switch (n4) {
4818
4823
  case t.Commands.Consent:
@@ -4840,38 +4845,52 @@ function ue2(e3, n4, o2, s4) {
4840
4845
  }
4841
4846
  if (o2.length) switch (n4) {
4842
4847
  case t.Commands.Consent:
4843
- !(function(e4, n5, t3) {
4844
- const o3 = t3 || e4.consent;
4845
- n5.forEach((n6) => {
4846
- Object.keys(o3).filter((e5) => e5 in n6).forEach((t4) => {
4847
- Re(n6[t4])(e4, o3);
4848
+ !(function(e4, n5, o3) {
4849
+ const s5 = o3 || e4.consent, r4 = ie2(e4, t.Commands.Consent);
4850
+ n5.forEach((e5) => {
4851
+ Object.keys(s5).filter((n6) => n6 in e5).forEach((n6) => {
4852
+ Re(e5[n6])(s5, r4);
4848
4853
  });
4849
4854
  });
4850
4855
  })(e3, o2, s4);
4851
4856
  break;
4852
4857
  case t.Commands.Ready:
4858
+ !(function(e4, n5) {
4859
+ if (!e4.allowed) return;
4860
+ const o3 = ie2(e4, t.Commands.Ready);
4861
+ n5.forEach((e5) => {
4862
+ Re(e5)(void 0, o3);
4863
+ });
4864
+ })(e3, o2);
4865
+ break;
4853
4866
  case t.Commands.Run:
4854
4867
  !(function(e4, n5) {
4855
- e4.allowed && n5.forEach((n6) => {
4856
- Re(n6)(e4);
4868
+ if (!e4.allowed) return;
4869
+ const o3 = ie2(e4, t.Commands.Run);
4870
+ n5.forEach((e5) => {
4871
+ Re(e5)(void 0, o3);
4857
4872
  });
4858
4873
  })(e3, o2);
4859
4874
  break;
4860
4875
  case t.Commands.Session:
4861
4876
  !(function(e4, n5) {
4862
4877
  if (!e4.session) return;
4878
+ const o3 = ie2(e4, t.Commands.Session);
4863
4879
  n5.forEach((n6) => {
4864
- Re(n6)(e4, e4.session);
4880
+ Re(n6)(e4.session, o3);
4865
4881
  });
4866
4882
  })(e3, o2);
4867
4883
  break;
4868
- default:
4869
- o2.forEach((n5) => {
4870
- "function" == typeof n5 && Re(n5)(e3, r3);
4884
+ default: {
4885
+ const t3 = ie2(e3, n4);
4886
+ o2.forEach((e4) => {
4887
+ "function" == typeof e4 && Re(e4)(r3, t3);
4871
4888
  });
4889
+ break;
4890
+ }
4872
4891
  }
4873
4892
  }
4874
- async function fe2(e3, n4, o2, s4) {
4893
+ async function le2(e3, n4, o2, s4) {
4875
4894
  let r3, a4 = o2 || [];
4876
4895
  switch (o2 || (a4 = e3.on[n4] || []), n4) {
4877
4896
  case t.Commands.Consent:
@@ -4904,7 +4923,7 @@ async function fe2(e3, n4, o2, s4) {
4904
4923
  return Object.entries(e3.destinations).forEach(([t3, o3]) => {
4905
4924
  if (o3.on) {
4906
4925
  if (!o3.config.init) return o3.queueOn = o3.queueOn || [], void o3.queueOn.push({ type: n4, data: r3 });
4907
- ce2(e3, o3, t3, n4, r3);
4926
+ ue2(e3, o3, t3, n4, r3);
4908
4927
  }
4909
4928
  }), (Object.keys(e3.pending.sources).length > 0 || Object.keys(e3.pending.destinations).length > 0) && await (async function(e4, n5) {
4910
4929
  for (const [t3, o3] of Object.entries(e4.pending.sources)) {
@@ -4926,12 +4945,12 @@ async function fe2(e3, n4, o2, s4) {
4926
4945
  if (-1 === r4) continue;
4927
4946
  if (s5.splice(r4, 1), s5.length > 0) continue;
4928
4947
  delete e4.pending.destinations[t3];
4929
- const a5 = ye(o3);
4948
+ const a5 = be(o3);
4930
4949
  false !== a5.config.queue && (a5.queuePush = [...e4.queue]), e4.destinations[t3] = a5;
4931
4950
  }
4932
- })(e3, n4), ue2(e3, n4, a4, s4), !i2;
4951
+ })(e3, n4), fe2(e3, n4, a4, s4), !i2;
4933
4952
  }
4934
- function le2(e3, n4, t3, o2) {
4953
+ function de2(e3, n4, t3, o2) {
4935
4954
  if (!e3) return [];
4936
4955
  if (n4) {
4937
4956
  const e4 = yt(n4, bt(o2));
@@ -4939,31 +4958,31 @@ function le2(e3, n4, t3, o2) {
4939
4958
  }
4940
4959
  return ee2(e3, Y2(t3));
4941
4960
  }
4942
- async function de2(e3, n4, t3) {
4961
+ async function ge2(e3, n4, t3) {
4943
4962
  const { code: o2, config: s4 = {}, env: r3 = {}, before: a4, next: i2, cache: c3 } = n4;
4944
- if (!re(o2.push)) return he2({ ok: false, failed: { invalid: { type: "invalid", error: "Destination code must have a push method" } } });
4963
+ if (!re(o2.push)) return ye({ ok: false, failed: { invalid: { type: "invalid", error: "Destination code must have a push method" } } });
4945
4964
  const u3 = t3 || s4 || { init: false };
4946
4965
  let f2 = a4 ? { ...u3, before: a4 } : { ...u3 };
4947
4966
  i2 && (f2 = { ...f2, next: i2 }), c3 && (f2 = { ...f2, cache: c3 });
4948
- const l2 = { ...o2, config: f2, env: ve2(o2.env, r3) };
4967
+ const l2 = { ...o2, config: f2, env: ke(o2.env, r3) };
4949
4968
  let d2 = l2.config.id;
4950
4969
  if (!d2) do {
4951
4970
  d2 = je(5, "abcdefghijklmnopqrstuvwxyz");
4952
4971
  } while (e3.destinations[d2]);
4953
- return e3.destinations[d2] = l2, false !== l2.config.queue && (l2.queuePush = [...e3.queue]), ge2(e3, void 0, {}, { [d2]: l2 });
4972
+ return e3.destinations[d2] = l2, false !== l2.config.queue && (l2.queuePush = [...e3.queue]), me(e3, void 0, {}, { [d2]: l2 });
4954
4973
  }
4955
- async function ge2(e3, n4, t3 = {}, o2) {
4974
+ async function me(e3, n4, t3 = {}, o2) {
4956
4975
  const { allowed: s4, consent: r3, globals: a4, user: p2 } = e3;
4957
- if (!s4) return he2({ ok: false });
4976
+ if (!s4) return ye({ ok: false });
4958
4977
  n4 && (e3.queue.push(n4), e3.status.in++), o2 || (o2 = e3.destinations);
4959
4978
  const h2 = await Promise.all(Object.entries(o2 || {}).map(async ([o3, s5]) => {
4960
4979
  if (s5.config.disabled) return { id: o3, destination: s5, skipped: true };
4961
4980
  let h3 = (s5.queuePush || []).map((e4) => ({ ...e4, consent: r3 }));
4962
- s5.queuePush = [], n4 && h3.push(fe(n4));
4981
+ s5.queuePush = [], n4 && h3.push(le(n4));
4963
4982
  const b3 = t3.ingest ? { ...t3.ingest, _meta: { ...t3.ingest._meta, path: [...t3.ingest._meta.path] } } : k("unknown");
4964
4983
  if (!h3.length && !s5.queueOn?.length) return { id: o3, destination: s5, skipped: true };
4965
4984
  if (!h3.length && s5.queueOn?.length) {
4966
- const n5 = await Te(me)(e3, s5, o3);
4985
+ const n5 = await Te(pe2)(e3, s5, o3);
4967
4986
  return { id: o3, destination: s5, skipped: !n5 };
4968
4987
  }
4969
4988
  const v3 = [], k4 = h3.filter((e4) => {
@@ -4971,10 +4990,10 @@ async function ge2(e3, n4, t3 = {}, o2) {
4971
4990
  return !n5 || (e4.consent = n5, v3.push(e4), false);
4972
4991
  });
4973
4992
  if (s5.queuePush.push(...k4), !v3.length) return { id: o3, destination: s5, queue: h3 };
4974
- if (!await Te(me)(e3, s5, o3)) return { id: o3, destination: s5, queue: h3 };
4993
+ if (!await Te(pe2)(e3, s5, o3)) return { id: o3, destination: s5, queue: h3 };
4975
4994
  let C3, O3;
4976
4995
  s5.dlq || (s5.dlq = []);
4977
- const x2 = s5.config.before, A3 = le2(x2, x2 && mt(x2) ? gt(x2) : void 0, e3.transformers, b3), q3 = s5.config.next, S3 = q3 && mt(q3) ? gt(q3) : void 0, D3 = s5.config?.cache, $2 = D3 ? ht(D3) : void 0, _3 = $2 ? X2($2, e3) : void 0;
4996
+ const x2 = s5.config.before, A3 = de2(x2, x2 && mt(x2) ? gt(x2) : void 0, e3.transformers, b3), q3 = s5.config.next, S3 = q3 && mt(q3) ? gt(q3) : void 0, D3 = s5.config?.cache, $2 = D3 ? ht(D3) : void 0, _3 = $2 ? X2($2, e3) : void 0;
4978
4997
  let I2 = 0;
4979
4998
  return await Promise.all(v3.map(async (n5) => {
4980
4999
  let r4;
@@ -4996,13 +5015,13 @@ async function ge2(e3, n4, t3 = {}, o2) {
4996
5015
  }
4997
5016
  const g2 = Date.now();
4998
5017
  let m2 = false;
4999
- const h4 = await Te(pe2, (n6) => {
5018
+ const h4 = await Te(he2, (n6) => {
5000
5019
  const t4 = s5.type || "unknown";
5001
5020
  e3.logger.scope(t4).error("Push failed", { error: n6, event: u3.name }), C3 = n6, m2 = true, s5.dlq.push([u3, n6]);
5002
5021
  })(e3, s5, o3, u3, b3, f2);
5003
5022
  if (I2 += Date.now() - g2, r4 && _3 && void 0 === s5.config.mock && wt(_3, r4.key, h4 ?? true, r4.ttl), void 0 !== h4 && (O3 = h4), !m2 && q3) {
5004
5023
  void 0 !== h4 && (b3._response = h4);
5005
- const n6 = le2(q3, S3, e3.transformers, b3);
5024
+ const n6 = de2(q3, S3, e3.transformers, b3);
5006
5025
  if (n6.length > 0 && e3.transformers && Object.keys(e3.transformers).length > 0) {
5007
5026
  const t4 = await oe(e3, e3.transformers, n6, u3, b3, f2, `destination.${o3}.next`);
5008
5027
  t4.respond && (f2 = t4.respond);
@@ -5018,40 +5037,40 @@ async function ge2(e3, n4, t3 = {}, o2) {
5018
5037
  const o3 = e3.status.destinations[n5.id], s5 = Date.now();
5019
5038
  n5.error ? (t4.error = n5.error, k3[n5.id] = t4, o3.failed++, o3.lastAt = s5, o3.duration += n5.totalDuration || 0, e3.status.failed++) : n5.queue && n5.queue.length ? v2[n5.id] = t4 : (b2[n5.id] = t4, o3.count++, o3.lastAt = s5, o3.duration += n5.totalDuration || 0, e3.status.out++);
5020
5039
  }
5021
- return he2({ event: n4, ...Object.keys(b2).length && { done: b2 }, ...Object.keys(v2).length && { queued: v2 }, ...Object.keys(k3).length && { failed: k3 } });
5040
+ return ye({ event: n4, ...Object.keys(b2).length && { done: b2 }, ...Object.keys(v2).length && { queued: v2 }, ...Object.keys(k3).length && { failed: k3 } });
5022
5041
  }
5023
- async function me(e3, n4, t3) {
5042
+ async function pe2(e3, n4, t3) {
5024
5043
  if (n4.init && !n4.config.init) {
5025
- const o2 = n4.type || "unknown", s4 = e3.logger.scope(o2), r3 = { collector: e3, logger: s4, id: t3, config: n4.config, env: ve2(n4.env, n4.config.env) };
5044
+ const o2 = n4.type || "unknown", s4 = e3.logger.scope(o2), r3 = { collector: e3, logger: s4, id: t3, config: n4.config, env: ke(n4.env, n4.config.env) };
5026
5045
  s4.debug("init");
5027
- const a4 = await qe(n4.init, "DestinationInit", e3.hooks, e3.logger)(r3);
5046
+ const a4 = await Je(n4.init, "DestinationInit", e3.hooks, e3.logger)(r3);
5028
5047
  if (false === a4) return a4;
5029
5048
  if (n4.config = { ...a4 || n4.config, init: true }, n4.queueOn?.length) {
5030
5049
  const o3 = n4.queueOn;
5031
5050
  n4.queueOn = [];
5032
- for (const { type: s5, data: r4 } of o3) ce2(e3, n4, t3, s5, r4);
5051
+ for (const { type: s5, data: r4 } of o3) ue2(e3, n4, t3, s5, r4);
5033
5052
  }
5034
5053
  s4.debug("init done");
5035
5054
  }
5036
5055
  return true;
5037
5056
  }
5038
- async function pe2(e3, n4, t3, o2, s4, r3) {
5057
+ async function he2(e3, n4, t3, o2, s4, r3) {
5039
5058
  const { config: a4 } = n4, i2 = await We(o2, a4, e3);
5040
5059
  if (i2.ignore) return false;
5041
- const c3 = n4.type || "unknown", u3 = e3.logger.scope(c3), f2 = { collector: e3, logger: u3, id: t3, config: a4, data: i2.data, rule: i2.mapping, ingest: s4, env: { ...ve2(n4.env, a4.env), ...r3 ? { respond: r3 } : {} } };
5060
+ const c3 = n4.type || "unknown", u3 = e3.logger.scope(c3), f2 = { collector: e3, logger: u3, id: t3, config: a4, data: i2.data, rule: i2.mapping, ingest: s4, env: { ...ke(n4.env, a4.env), ...r3 ? { respond: r3 } : {} } };
5042
5061
  if (void 0 !== a4.mock) return u3.debug("mock", { event: i2.event.name }), a4.mock;
5043
5062
  const l2 = i2.mapping, d2 = i2.mappingKey || "* *";
5044
5063
  if (!l2?.batch || !n4.pushBatch || void 0 !== a4.mock) {
5045
5064
  u3.debug("push", { event: i2.event.name });
5046
- const t4 = await qe(n4.push, "DestinationPush", e3.hooks, e3.logger)(i2.event, f2);
5065
+ const t4 = await Je(n4.push, "DestinationPush", e3.hooks, e3.logger)(i2.event, f2);
5047
5066
  return u3.debug("push done"), t4;
5048
5067
  }
5049
5068
  {
5050
5069
  if (n4.batches = n4.batches || {}, !n4.batches[d2]) {
5051
5070
  const o4 = { key: d2, events: [], data: [] };
5052
5071
  n4.batches[d2] = { batched: o4, batchFn: xe(() => {
5053
- const o5 = n4.batches[d2].batched, i3 = { collector: e3, logger: u3, id: t3, config: a4, data: void 0, rule: l2, ingest: s4, env: { ...ve2(n4.env, a4.env), ...r3 ? { respond: r3 } : {} } };
5054
- u3.debug("push batch", { events: o5.events.length }), qe(n4.pushBatch, "DestinationPushBatch", e3.hooks, e3.logger)(o5, i3), u3.debug("push batch done"), o5.events = [], o5.data = [];
5072
+ const o5 = n4.batches[d2].batched, i3 = { collector: e3, logger: u3, id: t3, config: a4, data: void 0, rule: l2, ingest: s4, env: { ...ke(n4.env, a4.env), ...r3 ? { respond: r3 } : {} } };
5073
+ u3.debug("push batch", { events: o5.events.length }), Je(n4.pushBatch, "DestinationPushBatch", e3.hooks, e3.logger)(o5, i3), u3.debug("push batch done"), o5.events = [], o5.data = [];
5055
5074
  }, l2.batch) };
5056
5075
  }
5057
5076
  const o3 = n4.batches[d2];
@@ -5059,24 +5078,24 @@ async function pe2(e3, n4, t3, o2, s4, r3) {
5059
5078
  }
5060
5079
  return true;
5061
5080
  }
5062
- function he2(e3) {
5081
+ function ye(e3) {
5063
5082
  return { ok: !e3?.failed, ...e3 };
5064
5083
  }
5065
- function ye(e3) {
5084
+ function be(e3) {
5066
5085
  const { code: n4, config: t3 = {}, env: o2 = {}, cache: s4 } = e3, { config: r3 } = Z2(e3, "before"), { config: a4 } = Z2({ ...e3, config: r3 }, "next"), i2 = { ...n4.config, ...t3, ...a4 };
5067
5086
  s4 && (i2.cache = s4);
5068
- const c3 = ve2(n4.env, o2);
5087
+ const c3 = ke(n4.env, o2);
5069
5088
  return { ...n4, config: i2, env: c3 };
5070
5089
  }
5071
- async function be(e3, n4 = {}) {
5090
+ async function ve2(e3, n4 = {}) {
5072
5091
  const t3 = {};
5073
- for (const [o2, s4] of Object.entries(n4)) s4.config?.require?.length ? e3.pending.destinations[o2] = s4 : t3[o2] = ye(s4);
5092
+ for (const [o2, s4] of Object.entries(n4)) s4.config?.require?.length ? e3.pending.destinations[o2] = s4 : t3[o2] = be(s4);
5074
5093
  return t3;
5075
5094
  }
5076
- function ve2(e3, n4) {
5095
+ function ke(e3, n4) {
5077
5096
  return e3 || n4 ? n4 ? e3 && se(e3) && se(n4) ? { ...e3, ...n4 } : n4 : e3 : {};
5078
5097
  }
5079
- async function xe2(e3, n4, t3) {
5098
+ async function Ae2(e3, n4, t3) {
5080
5099
  const o2 = Object.entries(e3).map(async ([e4, o3]) => {
5081
5100
  const s4 = o3.destroy;
5082
5101
  if (!s4) return;
@@ -5089,7 +5108,7 @@ async function xe2(e3, n4, t3) {
5089
5108
  });
5090
5109
  await Promise.allSettled(o2);
5091
5110
  }
5092
- async function Ae2(e3, n4, o2, r3) {
5111
+ async function qe(e3, n4, o2, r3) {
5093
5112
  let a4, i2, c3 = false;
5094
5113
  switch (n4) {
5095
5114
  case t.Commands.Config:
@@ -5105,19 +5124,19 @@ async function Ae2(e3, n4, o2, r3) {
5105
5124
  se(o2) && (e3.custom = G(e3.custom, o2), i2 = o2, c3 = true);
5106
5125
  break;
5107
5126
  case t.Commands.Destination:
5108
- se(o2) && ("code" in o2 && se(o2.code) ? a4 = await de2(e3, o2, r3) : re(o2.push) && (a4 = await de2(e3, { code: o2 }, r3)));
5127
+ se(o2) && ("code" in o2 && se(o2.code) ? a4 = await ge2(e3, o2, r3) : re(o2.push) && (a4 = await ge2(e3, { code: o2 }, r3)));
5109
5128
  break;
5110
5129
  case t.Commands.Globals:
5111
5130
  se(o2) && (e3.globals = G(e3.globals, o2), i2 = o2, c3 = true);
5112
5131
  break;
5113
5132
  case t.Commands.On:
5114
- ce(o2) && await ie2(e3, o2, r3);
5133
+ ce(o2) && await ce2(e3, o2, r3);
5115
5134
  break;
5116
5135
  case t.Commands.Ready:
5117
5136
  c3 = true;
5118
5137
  break;
5119
5138
  case t.Commands.Run:
5120
- a4 = await Se2(e3, o2), c3 = true;
5139
+ a4 = await De(e3, o2), c3 = true;
5121
5140
  break;
5122
5141
  case t.Commands.Session:
5123
5142
  c3 = true;
@@ -5125,29 +5144,29 @@ async function Ae2(e3, n4, o2, r3) {
5125
5144
  case t.Commands.Shutdown:
5126
5145
  await (async function(e4) {
5127
5146
  const n5 = e4.logger;
5128
- await xe2(e4.sources, "source", n5), await xe2(e4.destinations, "destination", n5), await xe2(e4.transformers, "transformer", n5), await xe2(e4.stores, "store", n5);
5147
+ await Ae2(e4.sources, "source", n5), await Ae2(e4.destinations, "destination", n5), await Ae2(e4.transformers, "transformer", n5), await Ae2(e4.stores, "store", n5);
5129
5148
  })(e3);
5130
5149
  break;
5131
5150
  case t.Commands.User:
5132
5151
  se(o2) && (G(e3.user, o2, { shallow: false }), i2 = o2, c3 = true);
5133
5152
  }
5134
- return c3 && (await fe2(e3, n4, void 0, i2), a4 = await ge2(e3)), a4 || he2({ ok: true });
5153
+ return c3 && (await le2(e3, n4, void 0, i2), a4 = await me(e3)), a4 || ye({ ok: true });
5135
5154
  }
5136
- function qe2(e3, n4) {
5155
+ function Se2(e3, n4) {
5137
5156
  if (!n4.name) throw new Error("Event name is required");
5138
5157
  const [t3, o2] = n4.name.split(" ");
5139
5158
  if (!t3 || !o2) throw new Error("Event name is invalid");
5140
5159
  const { timestamp: s4 = Date.now(), name: r3 = `${t3} ${o2}`, data: a4 = {}, context: i2 = {}, globals: c3 = e3.globals, custom: u3 = {}, user: f2 = e3.user, nested: l2 = [], consent: d2 = e3.consent, id: g2 = he(), trigger: m2 = "", entity: p2 = t3, action: h2 = o2, timing: y2 = 0, source: b2 = { type: "collector", schema: "4" } } = n4;
5141
5160
  return { name: r3, data: a4, context: i2, globals: c3, custom: u3, user: f2, nested: l2, consent: d2, id: g2, trigger: m2, entity: p2, action: h2, timestamp: s4, timing: y2, source: b2 };
5142
5161
  }
5143
- async function Se2(e3, n4) {
5162
+ async function De(e3, n4) {
5144
5163
  e3.allowed = true, e3.timing = Date.now(), n4 && (n4.consent && (e3.consent = G(e3.consent, n4.consent)), n4.user && (e3.user = G(e3.user, n4.user)), n4.globals && (e3.globals = G(e3.config.globalsStatic || {}, n4.globals)), n4.custom && (e3.custom = G(e3.custom, n4.custom))), Object.values(e3.destinations).forEach((e4) => {
5145
5164
  e4.queuePush = [];
5146
5165
  }), e3.queue = [], e3.round++;
5147
- return await ge2(e3);
5166
+ return await me(e3);
5148
5167
  }
5149
- function Ee2(e3, n4) {
5150
- return qe(async (t3, o2 = {}) => await Te(async () => {
5168
+ function Re2(e3, n4) {
5169
+ return Je(async (t3, o2 = {}) => await Te(async () => {
5151
5170
  const s4 = Date.now(), { id: r3, ingest: a4, respond: i2, mapping: c3, preChain: u3, include: f2, exclude: l2 } = o2;
5152
5171
  let d2 = i2, g2 = t3;
5153
5172
  const m2 = f2 || l2 ? (function(e4, n5, t4) {
@@ -5156,49 +5175,49 @@ function Ee2(e3, n4) {
5156
5175
  })(e3.destinations, f2, l2) : void 0, p2 = a4 ?? k(r3 || "unknown");
5157
5176
  if (c3) {
5158
5177
  const n5 = await We(g2, c3, e3);
5159
- if (n5.ignore) return he2({ ok: true });
5178
+ if (n5.ignore) return ye({ ok: true });
5160
5179
  if (c3.consent) {
5161
- if (!ge(c3.consent, e3.consent, n5.event.consent)) return he2({ ok: true });
5180
+ if (!ge(c3.consent, e3.consent, n5.event.consent)) return ye({ ok: true });
5162
5181
  }
5163
5182
  g2 = n5.event;
5164
5183
  }
5165
5184
  if (u3?.length && e3.transformers && Object.keys(e3.transformers).length > 0) {
5166
5185
  const t4 = await oe(e3, e3.transformers, u3, g2, p2, d2, r3 ? `source.${r3}.next` : void 0);
5167
- if (null === t4.event) return he2({ ok: true });
5186
+ if (null === t4.event) return ye({ ok: true });
5168
5187
  if (t4.respond && (d2 = t4.respond), Array.isArray(t4.event)) {
5169
5188
  const o3 = await Promise.all(t4.event.map(async (t5) => {
5170
- const o4 = n4(t5), s5 = qe2(e3, o4);
5171
- return ge2(e3, s5, { id: r3, ingest: p2, respond: d2 }, m2);
5189
+ const o4 = n4(t5), s5 = Se2(e3, o4);
5190
+ return me(e3, s5, { id: r3, ingest: p2, respond: d2 }, m2);
5172
5191
  }));
5173
5192
  if (r3) {
5174
5193
  e3.status.sources[r3] || (e3.status.sources[r3] = { count: 0, duration: 0 });
5175
5194
  const n5 = e3.status.sources[r3];
5176
5195
  n5.count += t4.event.length, n5.lastAt = Date.now(), n5.duration += Date.now() - s4;
5177
5196
  }
5178
- return o3[0] ?? he2({ ok: true });
5197
+ return o3[0] ?? ye({ ok: true });
5179
5198
  }
5180
5199
  g2 = t4.event;
5181
5200
  }
5182
- const h2 = n4(g2), y2 = qe2(e3, h2), b2 = await ge2(e3, y2, { id: r3, ingest: p2, respond: d2 }, m2);
5201
+ const h2 = n4(g2), y2 = Se2(e3, h2), b2 = await me(e3, y2, { id: r3, ingest: p2, respond: d2 }, m2);
5183
5202
  if (r3) {
5184
5203
  e3.status.sources[r3] || (e3.status.sources[r3] = { count: 0, duration: 0 });
5185
5204
  const n5 = e3.status.sources[r3];
5186
5205
  n5.count++, n5.lastAt = Date.now(), n5.duration += Date.now() - s4;
5187
5206
  }
5188
5207
  return b2;
5189
- }, () => he2({ ok: false }))(), "Push", e3.hooks, e3.logger);
5208
+ }, () => ye({ ok: false }))(), "Push", e3.hooks, e3.logger);
5190
5209
  }
5191
- async function Te2(e3) {
5210
+ async function Ge(e3) {
5192
5211
  const n4 = G({ globalsStatic: {}, sessionStatic: {}, run: true }, e3, { merge: false, extend: false }), t3 = { level: e3.logger?.level, handler: e3.logger?.handler }, o2 = _e(t3), s4 = { ...n4.globalsStatic, ...e3.globals }, i2 = { allowed: false, config: n4, consent: e3.consent || {}, custom: e3.custom || {}, destinations: {}, transformers: {}, stores: {}, globals: s4, hooks: e3.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: e3.user || {}, sources: {}, pending: { sources: {}, destinations: {} }, push: void 0, command: void 0 };
5193
- i2.push = Ee2(i2, (e4) => ({ timing: Math.round((Date.now() - i2.timing) / 10) / 100, source: { type: "collector", schema: "4", version: "4.0.0-next-1777463920154" }, ...e4 })), i2.command = (function(e4, n5) {
5194
- return qe(async (t4, o3, s5) => await Te(async () => await n5(e4, t4, o3, s5), () => he2({ ok: false }))(), "Command", e4.hooks, e4.logger);
5195
- })(i2, Ae2);
5212
+ i2.push = Re2(i2, (e4) => ({ timing: Math.round((Date.now() - i2.timing) / 10) / 100, source: { type: "collector", schema: "4", version: "4.0.0" }, ...e4 })), i2.command = (function(e4, n5) {
5213
+ return Je(async (t4, o3, s5) => await Te(async () => await n5(e4, t4, o3, s5), () => ye({ ok: false }))(), "Command", e4.hooks, e4.logger);
5214
+ })(i2, qe);
5196
5215
  const c3 = e3.stores || {};
5197
5216
  if (i2.stores = await (async function(e4, n5 = {}) {
5198
5217
  const t4 = {};
5199
5218
  for (const [o3, s5] of Object.entries(n5)) {
5200
5219
  const { code: n6, config: r3 = {}, env: a4 = {} } = s5, i3 = e4.logger.scope("store").scope(o3), c4 = { collector: e4, logger: i3, id: o3, config: r3, env: a4 }, u3 = await n6(c4), f2 = u3.get, l2 = u3.set, d2 = u3.delete;
5201
- u3.get = qe(f2, "StoreGet", e4.hooks, e4.logger), u3.set = qe(l2, "StoreSet", e4.hooks, e4.logger), u3.delete = qe(d2, "StoreDelete", e4.hooks, e4.logger), t4[o3] = u3;
5220
+ u3.get = Je(f2, "StoreGet", e4.hooks, e4.logger), u3.set = Je(l2, "StoreSet", e4.hooks, e4.logger), u3.delete = Je(d2, "StoreDelete", e4.hooks, e4.logger), t4[o3] = u3;
5202
5221
  }
5203
5222
  return t4;
5204
5223
  })(i2, c3), (function(e4, n5, t4) {
@@ -5229,7 +5248,7 @@ async function Te2(e3) {
5229
5248
  e4.delete(n5);
5230
5249
  } };
5231
5250
  }
5232
- return i2.destinations = await be(i2, e3.destinations || {}), i2.transformers = await (async function(e4, n5 = {}) {
5251
+ return i2.destinations = await ve2(i2, e3.destinations || {}), i2.transformers = await (async function(e4, n5 = {}) {
5233
5252
  const t4 = {};
5234
5253
  for (const [o3, s5] of Object.entries(n5)) {
5235
5254
  const { code: n6, env: r3 = {} } = s5, { config: a4 } = Z2(s5, "before"), { config: i3 } = Z2({ ...s5, config: a4 }, "next"), c4 = Object.keys(r3).length > 0 ? { ...i3, env: r3 } : i3, { cache: u3 } = s5, f2 = u3 ? { ...c4, cache: u3 } : c4, l2 = e4.logger.scope("transformer").scope(o3), d2 = { collector: e4, logger: l2, id: o3, ingest: k(o3), config: f2, env: r3 }, g2 = await n6(d2);
@@ -5238,9 +5257,9 @@ async function Te2(e3) {
5238
5257
  return t4;
5239
5258
  })(i2, e3.transformers || {}), i2;
5240
5259
  }
5241
- async function Ge(e3) {
5260
+ async function Ne2(e3) {
5242
5261
  e3 = e3 || {};
5243
- const n4 = await Te2(e3), t3 = (o2 = n4, { type: "elb", config: {}, push: async (e4, n5, t4, s5, r4, a5) => {
5262
+ const n4 = await Ge(e3), t3 = (o2 = n4, { type: "elb", config: {}, push: async (e4, n5, t4, s5, r4, a5) => {
5244
5263
  if ("string" == typeof e4 && e4.startsWith("walker ")) {
5245
5264
  const s6 = e4.replace("walker ", "");
5246
5265
  return o2.command(s6, n5, t4);
@@ -5248,7 +5267,7 @@ async function Ge(e3) {
5248
5267
  let i3;
5249
5268
  if ("string" == typeof e4) i3 = { name: e4 }, n5 && "object" == typeof n5 && !Array.isArray(n5) && (i3.data = n5);
5250
5269
  else {
5251
- if (!e4 || "object" != typeof e4) return he2({ ok: false });
5270
+ if (!e4 || "object" != typeof e4) return ye({ ok: false });
5252
5271
  i3 = e4, n5 && "object" == typeof n5 && !Array.isArray(n5) && (i3.data = { ...i3.data || {}, ...n5 });
5253
5272
  }
5254
5273
  return s5 && "object" == typeof s5 && (i3.context = s5), r4 && Array.isArray(r4) && (i3.nested = r4), a5 && "object" == typeof a5 && (i3.custom = a5), o2.push(i3);
@@ -5263,15 +5282,15 @@ async function Ge(e3) {
5263
5282
  const f2 = Object.values(n4.sources).filter((e4) => "elb" !== e4.type), l2 = f2.find((e4) => e4.config.primary);
5264
5283
  return l2 ? u3 = l2.push : f2.length > 0 && (u3 = f2[0].push), { collector: n4, elb: u3 };
5265
5284
  }
5266
- function Ne2(e3) {
5285
+ function Ue(e3) {
5267
5286
  if (null === e3 || "object" != typeof e3) return e3;
5268
- if (Array.isArray(e3)) return e3.map(Ne2);
5287
+ if (Array.isArray(e3)) return e3.map(Ue);
5269
5288
  const n4 = {};
5270
- for (const [t3, o2] of Object.entries(e3)) n4[t3] = "function" == typeof o2 ? o2 : Ne2(o2);
5289
+ for (const [t3, o2] of Object.entries(e3)) n4[t3] = "function" == typeof o2 ? o2 : Ue(o2);
5271
5290
  return n4;
5272
5291
  }
5273
- function Ue(e3) {
5274
- const n4 = [], { simulation: t3, ...o2 } = e3, s4 = Ne2(o2);
5292
+ function Be(e3) {
5293
+ const n4 = [], { simulation: t3, ...o2 } = e3, s4 = Ue(o2);
5275
5294
  for (const e4 of t3) {
5276
5295
  const t4 = e4.startsWith("call:") ? e4.slice(5) : e4, o3 = t4.split(".");
5277
5296
  let r3 = s4;
@@ -5390,6 +5409,7 @@ function maybePrintFirstRunNotice() {
5390
5409
  }
5391
5410
 
5392
5411
  // src/telemetry/emitter.ts
5412
+ init_config_file();
5393
5413
  var SEND_TIMEOUT_MS = 1e3;
5394
5414
  async function createEmitter(opts) {
5395
5415
  if (!isTelemetryEnabled()) {
@@ -5407,7 +5427,7 @@ async function createEmitter(opts) {
5407
5427
  }
5408
5428
  const device = maybeDevice;
5409
5429
  const debug = isDebugMode();
5410
- const endpoint = process.env.TELEMETRY_ENDPOINT || loadFlowJsonEndpoint();
5430
+ const endpoint = resolveTelemetryEndpoint();
5411
5431
  if (!endpoint && !debug) {
5412
5432
  return {
5413
5433
  async send() {
@@ -5441,7 +5461,7 @@ async function createEmitter(opts) {
5441
5461
  }
5442
5462
  }
5443
5463
  };
5444
- const { elb } = await Ge(collectorConfig);
5464
+ const { elb } = await Ne2(collectorConfig);
5445
5465
  elbFn = elb;
5446
5466
  return elbFn;
5447
5467
  }
@@ -5482,15 +5502,10 @@ async function createEmitter(opts) {
5482
5502
  }
5483
5503
  };
5484
5504
  }
5485
- function loadFlowJsonEndpoint() {
5486
- try {
5487
- const here = dirname2(fileURLToPath2(import.meta.url));
5488
- const raw = JSON.parse(readFileSync3(join3(here, "flow.json"), "utf-8"));
5489
- const url = raw.flows?.default?.destinations?.api?.config?.url;
5490
- if (url && !url.startsWith("$")) return url;
5491
- } catch {
5492
- }
5493
- return void 0;
5505
+ function resolveTelemetryEndpoint() {
5506
+ const appUrl = resolveAppUrl();
5507
+ if (!appUrl) return void 0;
5508
+ return `${appUrl.replace(/\/$/, "")}/api/telemetry`;
5494
5509
  }
5495
5510
  async function withTimeout(p2, ms) {
5496
5511
  return Promise.race([
@@ -5798,7 +5813,51 @@ function installTimerInterception(options = {}) {
5798
5813
  }
5799
5814
  pending.clear();
5800
5815
  }
5801
- return { flush, countPending, restore };
5816
+ return { flush, countPending, restore, pending };
5817
+ }
5818
+
5819
+ // src/commands/push/async-drain-pump.ts
5820
+ var realSetImmediate = setImmediate;
5821
+ var DEFAULT_MAX_ITERATIONS = 1e3;
5822
+ var DEFAULT_MAX_WALL_MS = 3e4;
5823
+ var intervalRequeueCounter = -1;
5824
+ function startDrainPump(pending, options = {}) {
5825
+ const maxIterations = options.maxIterations ?? DEFAULT_MAX_ITERATIONS;
5826
+ const maxWallMs = options.maxWallMs ?? DEFAULT_MAX_WALL_MS;
5827
+ const start = Date.now();
5828
+ let running = true;
5829
+ let iterations = 0;
5830
+ const tick = () => {
5831
+ if (!running) return;
5832
+ if (iterations >= maxIterations) return;
5833
+ if (Date.now() - start > maxWallMs) return;
5834
+ if (pending.size === 0) {
5835
+ realSetImmediate(tick);
5836
+ return;
5837
+ }
5838
+ iterations += 1;
5839
+ const snapshot = [...pending.values()].filter((t3) => !t3.cleared).sort((a4, b2) => a4.delay - b2.delay);
5840
+ for (const timer of snapshot) {
5841
+ pending.delete(timer.id);
5842
+ try {
5843
+ timer.callback(...timer.args);
5844
+ } catch (err) {
5845
+ console.warn(`[async-drain] timer ${timer.id} threw during pump:`, err);
5846
+ }
5847
+ if (timer.type === "interval" && !timer.cleared) {
5848
+ const requeued = {
5849
+ ...timer,
5850
+ id: intervalRequeueCounter--
5851
+ };
5852
+ pending.set(requeued.id, requeued);
5853
+ }
5854
+ }
5855
+ realSetImmediate(tick);
5856
+ };
5857
+ realSetImmediate(tick);
5858
+ return () => {
5859
+ running = false;
5860
+ };
5802
5861
  }
5803
5862
 
5804
5863
  // src/commands/push/flow-context.ts
@@ -5810,7 +5869,8 @@ async function withFlowContext(options, fn) {
5810
5869
  snapshotCode,
5811
5870
  timeout,
5812
5871
  networkCalls,
5813
- asyncDrain
5872
+ asyncDrain,
5873
+ drainPump
5814
5874
  } = options;
5815
5875
  const startTime = Date.now();
5816
5876
  const g2 = global;
@@ -5873,7 +5933,13 @@ async function withFlowContext(options, fn) {
5873
5933
  __devExports: module.__devExports
5874
5934
  };
5875
5935
  if (timerControl) {
5876
- const result = await fn(flowModule);
5936
+ const stopPump = drainPump ? startDrainPump(timerControl.pending) : null;
5937
+ let result;
5938
+ try {
5939
+ result = await fn(flowModule);
5940
+ } finally {
5941
+ if (stopPump) stopPump();
5942
+ }
5877
5943
  await timerControl.flush(asyncDrain?.timeout ?? 5e3);
5878
5944
  return result;
5879
5945
  } else if (timeout) {
@@ -5971,7 +6037,7 @@ async function prepareFlow(input) {
5971
6037
  configPath: process.cwd(),
5972
6038
  flowName: input.flow
5973
6039
  });
5974
- const platform = q(flowSettings);
6040
+ const platform = J(flowSettings);
5975
6041
  const overrides = buildOverrides(
5976
6042
  { simulate: input.simulate, mock: input.mock },
5977
6043
  flowSettings
@@ -6017,6 +6083,145 @@ async function prepareFlow(input) {
6017
6083
 
6018
6084
  // src/commands/push/index.ts
6019
6085
  init_dev();
6086
+
6087
+ // src/commands/push/plan-simulate.ts
6088
+ function planSimulate(flags) {
6089
+ if (flags.length === 0) return { kind: "none", ids: [] };
6090
+ const parsed = flags.map((flag) => {
6091
+ const step = parseStep(flag);
6092
+ if (step.chainType) {
6093
+ throw new Error(
6094
+ `--simulate "${flag}": chain syntax (${step.type}.${step.name}.${step.chainType}.\u2026) is not supported for --simulate. Use --mock for path-specific overrides.`
6095
+ );
6096
+ }
6097
+ return step;
6098
+ });
6099
+ const types = new Set(parsed.map((p2) => p2.type));
6100
+ if (types.size > 1) {
6101
+ const sorted = [...types].sort();
6102
+ throw new Error(
6103
+ `Cannot --simulate ${sorted.join(" and ")} in the same invocation. Run separate commands for each step type.`
6104
+ );
6105
+ }
6106
+ const [type] = types;
6107
+ const ids = [...new Set(parsed.map((p2) => p2.name))];
6108
+ if ((type === "source" || type === "transformer") && ids.length > 1) {
6109
+ throw new Error(
6110
+ `--simulate ${type}.* expects a single target; got ${ids.length}. Run one --simulate ${type}.NAME per invocation.`
6111
+ );
6112
+ }
6113
+ return { kind: type, ids };
6114
+ }
6115
+
6116
+ // src/commands/push/dispatch-simulate.ts
6117
+ function dispatchSimulate(flags) {
6118
+ const plan = planSimulate(flags);
6119
+ return { route: plan.kind, ids: plan.ids };
6120
+ }
6121
+
6122
+ // src/commands/push/run.ts
6123
+ init_core();
6124
+ init_config();
6125
+ async function runPushCommand(options) {
6126
+ const startTime = Date.now();
6127
+ try {
6128
+ const plan = dispatchSimulate(options.simulate ?? []);
6129
+ let config;
6130
+ if (isStdinPiped() && !options.config) {
6131
+ config = await readStdinToTempFile("push");
6132
+ } else {
6133
+ config = options.config || "bundle.config.json";
6134
+ }
6135
+ let resolvedEvent = options.event;
6136
+ if (typeof options.event === "string") {
6137
+ resolvedEvent = await loadJsonFromSource(options.event, {
6138
+ name: "event"
6139
+ });
6140
+ }
6141
+ let result;
6142
+ switch (plan.route) {
6143
+ case "none":
6144
+ result = await push(config, resolvedEvent, {
6145
+ flow: options.flow,
6146
+ json: options.json,
6147
+ verbose: options.verbose,
6148
+ silent: options.silent,
6149
+ platform: options.platform,
6150
+ mock: options.mock,
6151
+ snapshot: options.snapshot
6152
+ });
6153
+ break;
6154
+ case "source":
6155
+ result = await simulateSource(config, resolvedEvent, {
6156
+ sourceId: plan.ids[0],
6157
+ flow: options.flow,
6158
+ silent: options.silent,
6159
+ verbose: options.verbose,
6160
+ snapshot: options.snapshot
6161
+ });
6162
+ break;
6163
+ case "transformer":
6164
+ result = await simulateTransformer(
6165
+ config,
6166
+ resolvedEvent,
6167
+ {
6168
+ transformerId: plan.ids[0],
6169
+ flow: options.flow,
6170
+ mock: options.mock,
6171
+ silent: options.silent,
6172
+ verbose: options.verbose,
6173
+ snapshot: options.snapshot
6174
+ }
6175
+ );
6176
+ break;
6177
+ case "destination":
6178
+ result = await runDestinationSimulationLoop(
6179
+ config,
6180
+ resolvedEvent,
6181
+ plan.ids,
6182
+ options
6183
+ );
6184
+ break;
6185
+ }
6186
+ return result;
6187
+ } catch (error) {
6188
+ return {
6189
+ success: false,
6190
+ duration: Date.now() - startTime,
6191
+ error: getErrorMessage(error)
6192
+ };
6193
+ }
6194
+ }
6195
+ async function runDestinationSimulationLoop(config, event, destinationIds, options) {
6196
+ const startTime = Date.now();
6197
+ const perDestination = {};
6198
+ for (const destinationId of destinationIds) {
6199
+ const r3 = await simulateDestination(config, event, {
6200
+ destinationId,
6201
+ flow: options.flow,
6202
+ mock: options.mock,
6203
+ silent: options.silent,
6204
+ verbose: options.verbose,
6205
+ snapshot: options.snapshot
6206
+ });
6207
+ perDestination[destinationId] = r3;
6208
+ if (!r3.success) {
6209
+ return {
6210
+ success: false,
6211
+ duration: Date.now() - startTime,
6212
+ error: `simulate destination.${destinationId}: ${r3.error ?? "unknown error"}`,
6213
+ perDestination
6214
+ };
6215
+ }
6216
+ }
6217
+ return {
6218
+ success: true,
6219
+ duration: Date.now() - startTime,
6220
+ perDestination
6221
+ };
6222
+ }
6223
+
6224
+ // src/commands/push/index.ts
6020
6225
  function resolveBeforeChain(before, transformers, ingest, event) {
6021
6226
  if (!before) return [];
6022
6227
  const next = before;
@@ -6095,108 +6300,32 @@ async function pushCore(inputPath, event, options = {}) {
6095
6300
  }
6096
6301
  }
6097
6302
  async function pushCommand(options) {
6098
- const logger = createCLILogger({ ...options, stderr: true });
6099
- const startTime = Date.now();
6100
- try {
6101
- let config;
6102
- if (isStdinPiped() && !options.config) {
6103
- config = await readStdinToTempFile("push");
6104
- } else {
6105
- config = options.config || "bundle.config.json";
6106
- }
6107
- let resolvedEvent = options.event;
6108
- if (typeof options.event === "string") {
6109
- resolvedEvent = await loadJsonFromSource(options.event, {
6110
- name: "event"
6111
- });
6112
- }
6113
- const simulateFlag = options.simulate?.[0];
6114
- let result;
6115
- if (simulateFlag?.startsWith("source.")) {
6116
- result = await simulateSource(config, resolvedEvent, {
6117
- sourceId: simulateFlag.replace("source.", ""),
6118
- flow: options.flow,
6119
- silent: options.silent,
6120
- verbose: options.verbose,
6121
- snapshot: options.snapshot
6122
- });
6123
- } else if (simulateFlag?.startsWith("transformer.")) {
6124
- result = await simulateTransformer(
6125
- config,
6126
- resolvedEvent,
6127
- {
6128
- transformerId: simulateFlag.replace("transformer.", ""),
6129
- flow: options.flow,
6130
- mock: options.mock,
6131
- silent: options.silent,
6132
- verbose: options.verbose,
6133
- snapshot: options.snapshot
6134
- }
6135
- );
6136
- } else if (simulateFlag?.startsWith("destination.")) {
6137
- result = await simulateDestination(
6138
- config,
6139
- resolvedEvent,
6140
- {
6141
- destinationId: simulateFlag.replace("destination.", ""),
6142
- flow: options.flow,
6143
- mock: options.mock,
6144
- silent: options.silent,
6145
- verbose: options.verbose,
6146
- snapshot: options.snapshot
6147
- }
6148
- );
6149
- } else {
6150
- result = await push(config, resolvedEvent, {
6151
- flow: options.flow,
6152
- json: options.json,
6153
- verbose: options.verbose,
6154
- silent: options.silent,
6155
- platform: options.platform,
6156
- mock: options.mock,
6157
- snapshot: options.snapshot
6158
- });
6159
- }
6160
- const duration = Date.now() - startTime;
6161
- let output;
6162
- if (options.json) {
6163
- output = JSON.stringify({ ...result, duration }, null, 2);
6164
- } else {
6165
- const lines = [];
6166
- if (result.success) {
6167
- lines.push("Event pushed successfully");
6168
- if (result.elbResult && typeof result.elbResult === "object") {
6169
- const pushResult = result.elbResult;
6170
- if ("id" in pushResult && pushResult.id)
6171
- lines.push(` Event ID: ${pushResult.id}`);
6172
- if ("entity" in pushResult && pushResult.entity)
6173
- lines.push(` Entity: ${pushResult.entity}`);
6174
- if ("action" in pushResult && pushResult.action)
6175
- lines.push(` Action: ${pushResult.action}`);
6176
- }
6177
- lines.push(` Duration: ${duration}ms`);
6178
- } else {
6179
- lines.push(`Error: ${result.error}`);
6180
- }
6181
- output = lines.join("\n");
6182
- }
6183
- await writeResult(output + "\n", { output: options.output });
6184
- process.exit(result.success ? 0 : 1);
6185
- } catch (error) {
6186
- const duration = Date.now() - startTime;
6187
- const errorMessage = getErrorMessage(error);
6188
- if (options.json) {
6189
- const errorOutput = JSON.stringify(
6190
- { success: false, error: errorMessage, duration },
6191
- null,
6192
- 2
6193
- );
6194
- await writeResult(errorOutput + "\n", { output: options.output });
6303
+ const result = await runPushCommand(options);
6304
+ const duration = result.duration;
6305
+ let output;
6306
+ if (options.json) {
6307
+ output = JSON.stringify({ ...result, duration }, null, 2);
6308
+ } else {
6309
+ const lines = [];
6310
+ if (result.success) {
6311
+ lines.push("Event pushed successfully");
6312
+ if (result.elbResult && typeof result.elbResult === "object") {
6313
+ const pushResult = result.elbResult;
6314
+ if ("id" in pushResult && pushResult.id)
6315
+ lines.push(` Event ID: ${pushResult.id}`);
6316
+ if ("entity" in pushResult && pushResult.entity)
6317
+ lines.push(` Entity: ${pushResult.entity}`);
6318
+ if ("action" in pushResult && pushResult.action)
6319
+ lines.push(` Action: ${pushResult.action}`);
6320
+ }
6321
+ lines.push(` Duration: ${duration}ms`);
6195
6322
  } else {
6196
- logger.error(`Error: ${errorMessage}`);
6323
+ lines.push(`Error: ${result.error}`);
6197
6324
  }
6198
- process.exit(1);
6325
+ output = lines.join("\n");
6199
6326
  }
6327
+ await writeResult(output + "\n", { output: options.output });
6328
+ process.exit(result.success ? 0 : 1);
6200
6329
  }
6201
6330
  async function push(configOrPath, event, options = {}) {
6202
6331
  if (typeof configOrPath !== "string") {
@@ -6228,7 +6357,7 @@ async function executeConfigPush(options, validatedEvent, logger, setTempDir, sn
6228
6357
  flowName: options.flow,
6229
6358
  logger
6230
6359
  });
6231
- const platform = q(flowSettings);
6360
+ const platform = J(flowSettings);
6232
6361
  const overrides = buildOverrides({ mock: options.mock }, flowSettings);
6233
6362
  logger.debug("Bundling flow configuration");
6234
6363
  const tempDir = getTmpPath(
@@ -6295,7 +6424,12 @@ async function executeDestinationPush(esmPath, event, logger, platform, override
6295
6424
  snapshotCode,
6296
6425
  timeout,
6297
6426
  networkCalls,
6298
- asyncDrain: { timeout: 5e3 }
6427
+ asyncDrain: { timeout: 5e3 },
6428
+ // Real push (non-simulate) needs the pump so destinations whose init
6429
+ // awaits a captured setTimeout (e.g., amplitude engagement plugin)
6430
+ // don't deadlock. Simulate routes use their own withFlowContext call
6431
+ // sites without `drainPump`, preserving snapshot ordering.
6432
+ drainPump: true
6299
6433
  },
6300
6434
  async (module) => {
6301
6435
  const config = module.wireConfig(module.__configData ?? void 0);
@@ -6645,7 +6779,7 @@ async function simulateDestination(configOrPath, event, options) {
6645
6779
  ...devEnv.push,
6646
6780
  simulation: devEnv.simulation
6647
6781
  };
6648
- const { wrappedEnv, calls } = Ue(combined);
6782
+ const { wrappedEnv, calls } = Be(combined);
6649
6783
  if (destConfig) destConfig.env = wrappedEnv;
6650
6784
  trackedCalls = calls;
6651
6785
  }
@@ -6695,12 +6829,12 @@ init_auth();
6695
6829
  import path17 from "path";
6696
6830
  import { writeFileSync as writeFileSync5 } from "fs";
6697
6831
  import { homedir as homedir2 } from "os";
6698
- import { join as join5 } from "path";
6832
+ import { join as join4 } from "path";
6699
6833
 
6700
6834
  // src/runtime/resolve-bundle.ts
6701
6835
  init_stdin();
6702
6836
  import { existsSync as existsSync2, mkdirSync as mkdirSync2, writeFileSync as writeFileSync2 } from "fs";
6703
- import { dirname as dirname3 } from "path";
6837
+ import { dirname as dirname2 } from "path";
6704
6838
  function getDefaultWritePath() {
6705
6839
  if (existsSync2("/app/flow")) return "/app/flow/bundle.mjs";
6706
6840
  return "/tmp/walkeros-bundle.mjs";
@@ -6709,7 +6843,7 @@ function isUrl2(value) {
6709
6843
  return value.startsWith("http://") || value.startsWith("https://");
6710
6844
  }
6711
6845
  function writeBundleToDisk(writePath, content) {
6712
- const dir = dirname3(writePath);
6846
+ const dir = dirname2(writePath);
6713
6847
  if (!existsSync2(dir)) {
6714
6848
  mkdirSync2(dir, { recursive: true });
6715
6849
  }
@@ -6985,7 +7119,7 @@ function createHealthServer(port, logger) {
6985
7119
  }
6986
7120
 
6987
7121
  // src/runtime/runner.ts
6988
- import { resolve as resolve2, dirname as dirname4 } from "path";
7122
+ import { resolve as resolve2, dirname as dirname3 } from "path";
6989
7123
 
6990
7124
  // src/runtime/load-bundle.ts
6991
7125
  import { resolve } from "path";
@@ -7016,7 +7150,7 @@ async function loadBundle(file, context2, logger) {
7016
7150
  // src/runtime/runner.ts
7017
7151
  async function loadFlow(file, config, logger, loggerConfig, healthServer) {
7018
7152
  const absolutePath = resolve2(file);
7019
- const flowDir = dirname4(absolutePath);
7153
+ const flowDir = dirname3(absolutePath);
7020
7154
  process.chdir(flowDir);
7021
7155
  const flowContext = {
7022
7156
  ...config,
@@ -7409,8 +7543,8 @@ async function injectSecrets(api, logger) {
7409
7543
  // src/commands/run/index.ts
7410
7544
  function defaultCacheDir() {
7411
7545
  const xdgCache = process.env.XDG_CACHE_HOME;
7412
- const base = xdgCache || join5(homedir2(), ".cache");
7413
- return join5(base, "walkeros");
7546
+ const base = xdgCache || join4(homedir2(), ".cache");
7547
+ return join4(base, "walkeros");
7414
7548
  }
7415
7549
  async function lazyPrepareBundleForRun(configPath, options) {
7416
7550
  const { prepareBundleForRun: prepareBundleForRun2 } = await Promise.resolve().then(() => (init_utils3(), utils_exports));
@@ -7883,7 +8017,7 @@ function validateFlow(input, options = {}) {
7883
8017
  const flowsToResolve = options.flow ? options.flow in flowsMap ? [options.flow] : [] : Object.keys(flowsMap);
7884
8018
  for (const name of flowsToResolve) {
7885
8019
  try {
7886
- V(input, name, {
8020
+ q(input, name, {
7887
8021
  deferred: true,
7888
8022
  // don't fail on missing $env when validating
7889
8023
  strictFlowRefs: false,
@@ -8098,7 +8232,7 @@ function validateMapping(input) {
8098
8232
  // src/commands/validate/validators/entry.ts
8099
8233
  init_dist();
8100
8234
  import Ajv from "ajv";
8101
- var CLIENT_HEADER = "walkeros-cli/4.0.0-next-1777463920154";
8235
+ var CLIENT_HEADER = "walkeros-cli/4.0.0";
8102
8236
  var SECTIONS = ["destinations", "sources", "transformers"];
8103
8237
  function resolveEntry(path18, flowConfig) {
8104
8238
  const flows = flowConfig.flows;
@@ -8174,7 +8308,7 @@ async function validateEntry(path18, flowConfig) {
8174
8308
  }
8175
8309
  let schemas;
8176
8310
  try {
8177
- const info = await ft(packageName, {
8311
+ const info = await lt(packageName, {
8178
8312
  client: CLIENT_HEADER
8179
8313
  });
8180
8314
  schemas = info.schemas;
@@ -9037,7 +9171,7 @@ async function createDeployCommand(config, options) {
9037
9171
  const result2 = await loadFlowConfig(config, {
9038
9172
  flowName: options.flow
9039
9173
  });
9040
- type = q(result2.flowSettings);
9174
+ type = J(result2.flowSettings);
9041
9175
  }
9042
9176
  const deployment = await createDeployment({
9043
9177
  type,
@@ -9250,7 +9384,7 @@ program.command("push [file]").description("Push an event through the flow with
9250
9384
  "event to push (JSON string, file path, or URL)"
9251
9385
  ).option("-o, --output <path>", "write result to file").option("-f, --flow <name>", "flow name for multi-flow configs").option("-p, --platform <platform>", "platform override (web or server)").option("--json", "output as JSON").option("-v, --verbose", "verbose output").option("-s, --silent", "suppress output").option(
9252
9386
  "--simulate <step>",
9253
- "simulate a destination step (repeatable)",
9387
+ "simulate a step (repeatable for destination.*; format: source.NAME | destination.NAME | transformer.NAME)",
9254
9388
  (val, arr) => {
9255
9389
  arr.push(val);
9256
9390
  return arr;