@walkeros/cli 4.1.2 → 4.1.3-next-1780071196115
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/CHANGELOG.md +18 -0
- package/dist/cli.js +1102 -1056
- package/dist/examples/flow-complete.json +4 -6
- package/dist/examples/flow-complete.md +9 -9
- package/dist/examples/index.js +4 -6
- package/dist/examples/index.js.map +1 -1
- package/dist/index.js +1 -1
- package/examples/flow-complete.json +4 -6
- package/examples/flow-complete.md +9 -9
- package/package.json +7 -7
package/dist/cli.js
CHANGED
|
@@ -128,10 +128,10 @@ function I(e4) {
|
|
|
128
128
|
function r4(o3) {
|
|
129
129
|
if (t4[o3]) return t4[o3];
|
|
130
130
|
n4.has(o3) && T(`Circular extend chain detected: ${[...n4, o3].join(" \u2192 ")}`);
|
|
131
|
-
const
|
|
132
|
-
|
|
131
|
+
const i3 = e4[o3];
|
|
132
|
+
i3 || T(`Contract "${o3}" not found`), n4.add(o3);
|
|
133
133
|
let a4 = {};
|
|
134
|
-
if (
|
|
134
|
+
if (i3.extend) {
|
|
135
135
|
a4 = (function(e5, t5) {
|
|
136
136
|
const n5 = {};
|
|
137
137
|
void 0 === e5.tagging && void 0 === t5.tagging || (n5.tagging = t5.tagging ?? e5.tagging);
|
|
@@ -140,26 +140,26 @@ function I(e4) {
|
|
|
140
140
|
if (e5.events || t5.events) {
|
|
141
141
|
const r5 = {}, o4 = /* @__PURE__ */ new Set([...Object.keys(e5.events || {}), ...Object.keys(t5.events || {})]);
|
|
142
142
|
for (const n6 of o4) {
|
|
143
|
-
const o5 = e5.events?.[n6] || {},
|
|
143
|
+
const o5 = e5.events?.[n6] || {}, i4 = t5.events?.[n6] || {}, a5 = /* @__PURE__ */ new Set([...Object.keys(o5), ...Object.keys(i4)]);
|
|
144
144
|
r5[n6] = {};
|
|
145
145
|
for (const e6 of a5) {
|
|
146
|
-
const t6 = o5[e6], a6 =
|
|
146
|
+
const t6 = o5[e6], a6 = i4[e6];
|
|
147
147
|
r5[n6][e6] = t6 && a6 ? z(t6, a6) : { ...t6 || a6 };
|
|
148
148
|
}
|
|
149
149
|
}
|
|
150
150
|
n5.events = r5;
|
|
151
151
|
}
|
|
152
152
|
return n5;
|
|
153
|
-
})(r4(
|
|
154
|
-
} else a4 = { ...
|
|
153
|
+
})(r4(i3.extend), i3);
|
|
154
|
+
} else a4 = { ...i3 };
|
|
155
155
|
if (delete a4.extend, a4.events && (a4.events = (function(e5) {
|
|
156
156
|
const t5 = {};
|
|
157
157
|
for (const n5 of Object.keys(e5)) if ("*" !== n5) {
|
|
158
158
|
t5[n5] = {};
|
|
159
159
|
for (const r5 of Object.keys(e5[n5] || {})) {
|
|
160
160
|
let o4 = {};
|
|
161
|
-
const
|
|
162
|
-
|
|
161
|
+
const i4 = e5["*"]?.["*"];
|
|
162
|
+
i4 && (o4 = z(o4, i4));
|
|
163
163
|
const a5 = e5["*"]?.[r5];
|
|
164
164
|
a5 && "*" !== r5 && (o4 = z(o4, a5));
|
|
165
165
|
const s5 = e5[n5]?.["*"];
|
|
@@ -186,8 +186,8 @@ function I(e4) {
|
|
|
186
186
|
function z(e4, t4) {
|
|
187
187
|
const n4 = { ...e4 };
|
|
188
188
|
for (const r4 of Object.keys(t4)) {
|
|
189
|
-
const o3 = e4[r4],
|
|
190
|
-
"required" === r4 && Array.isArray(o3) && Array.isArray(
|
|
189
|
+
const o3 = e4[r4], i3 = t4[r4];
|
|
190
|
+
"required" === r4 && Array.isArray(o3) && Array.isArray(i3) ? n4[r4] = [.../* @__PURE__ */ new Set([...o3, ...i3])] : M(o3) && M(i3) ? n4[r4] = z(o3, i3) : n4[r4] = i3;
|
|
191
191
|
}
|
|
192
192
|
return n4;
|
|
193
193
|
}
|
|
@@ -199,222 +199,222 @@ function P(e4) {
|
|
|
199
199
|
function M(e4) {
|
|
200
200
|
return "object" == typeof e4 && null !== e4 && !Array.isArray(e4);
|
|
201
201
|
}
|
|
202
|
-
function
|
|
202
|
+
function q(...e4) {
|
|
203
203
|
const t4 = {};
|
|
204
204
|
for (const n4 of e4) n4 && Object.assign(t4, n4);
|
|
205
205
|
return t4;
|
|
206
206
|
}
|
|
207
|
-
function
|
|
207
|
+
function J(e4, t4, n4) {
|
|
208
208
|
const r4 = `$flow.${e4}${t4 ? `.${t4}` : ""}`;
|
|
209
209
|
if ("unknown-flow" === n4) return `${r4} cannot resolve: flow "${e4}" does not exist in this config.`;
|
|
210
210
|
return `${r4} is empty. Set ${t4 ? `flows.${e4}.config.${t4}` : `flows.${e4}.config`}, or run \`walkeros deploy ${e4}\` first.`;
|
|
211
211
|
}
|
|
212
|
-
function
|
|
212
|
+
function G(e4, t4, n4) {
|
|
213
213
|
const r4 = t4.split(".");
|
|
214
214
|
let o3 = e4;
|
|
215
215
|
for (let e5 = 0; e5 < r4.length; e5++) {
|
|
216
|
-
const
|
|
216
|
+
const i3 = r4[e5];
|
|
217
217
|
if (null == o3 || "object" != typeof o3) {
|
|
218
218
|
const o4 = r4.slice(0, e5).join(".");
|
|
219
|
-
T(`Path "${t4}" not found in "${n4}": "${
|
|
219
|
+
T(`Path "${t4}" not found in "${n4}": "${i3}" does not exist${o4 ? ` in "${o4}"` : ""}`);
|
|
220
220
|
}
|
|
221
221
|
const a4 = o3;
|
|
222
|
-
if (!(
|
|
222
|
+
if (!(i3 in a4)) {
|
|
223
223
|
const o4 = r4.slice(0, e5).join(".");
|
|
224
|
-
T(`Path "${t4}" not found in "${n4}": "${
|
|
224
|
+
T(`Path "${t4}" not found in "${n4}": "${i3}" does not exist${o4 ? ` in "${o4}"` : ""}`);
|
|
225
225
|
}
|
|
226
|
-
o3 = a4[
|
|
226
|
+
o3 = a4[i3];
|
|
227
227
|
}
|
|
228
228
|
return o3;
|
|
229
229
|
}
|
|
230
|
-
function
|
|
230
|
+
function X(e4, t4, n4, r4, o3, i3) {
|
|
231
231
|
if ("string" == typeof e4) {
|
|
232
232
|
const a4 = e4.match(R);
|
|
233
233
|
if (a4) {
|
|
234
234
|
const e5 = a4[1].split("."), s6 = e5[0], c3 = e5.slice(1).join(".");
|
|
235
235
|
void 0 === t4[s6] && T(`Variable "${s6}" not found`);
|
|
236
|
-
const l3 =
|
|
236
|
+
const l3 = i3 ?? /* @__PURE__ */ new Set();
|
|
237
237
|
if (l3.has(s6)) {
|
|
238
238
|
T(`Cyclic $var reference: ${[...l3, s6].join(" -> ")}`);
|
|
239
239
|
}
|
|
240
|
-
let
|
|
240
|
+
let u3;
|
|
241
241
|
l3.add(s6);
|
|
242
242
|
try {
|
|
243
|
-
|
|
243
|
+
u3 = X(t4[s6], t4, n4, r4, o3, l3);
|
|
244
244
|
} finally {
|
|
245
245
|
l3.delete(s6);
|
|
246
246
|
}
|
|
247
|
-
return c3 && (
|
|
247
|
+
return c3 && (u3 = G(u3, c3, `$var.${s6}`)), u3;
|
|
248
248
|
}
|
|
249
249
|
const s5 = e4.match(U);
|
|
250
250
|
if (s5 && r4) {
|
|
251
251
|
const e5 = s5[1], t5 = s5[2];
|
|
252
252
|
e5 in r4 || T(`Contract "${e5}" not found`);
|
|
253
253
|
let n5 = r4[e5];
|
|
254
|
-
return t5 && (n5 =
|
|
254
|
+
return t5 && (n5 = G(n5, t5, `$contract.${e5}`)), n5;
|
|
255
255
|
}
|
|
256
256
|
const c2 = e4.match(Z);
|
|
257
257
|
if (c2) {
|
|
258
|
-
const t5 = c2[1], r5 = c2[2],
|
|
258
|
+
const t5 = c2[1], r5 = c2[2], i4 = false === n4?.strictFlowRefs;
|
|
259
259
|
o3 || T(`$flow.${t5}${r5 ? `.${r5}` : ""} cannot be resolved without a flow resolver`);
|
|
260
260
|
const a5 = o3(t5);
|
|
261
261
|
if (!a5) {
|
|
262
|
-
if (
|
|
262
|
+
if (i4) return n4?.onWarning?.(J(t5, r5, "unknown-flow")), e4;
|
|
263
263
|
T(`Flow "${t5}" not found in $flow.${t5}`);
|
|
264
264
|
}
|
|
265
265
|
let s6 = a5;
|
|
266
|
-
if (r5) if (
|
|
266
|
+
if (r5) if (i4) {
|
|
267
267
|
try {
|
|
268
|
-
s6 =
|
|
268
|
+
s6 = G(s6, r5, `$flow.${t5}`);
|
|
269
269
|
} catch {
|
|
270
|
-
return n4?.onWarning?.(
|
|
270
|
+
return n4?.onWarning?.(J(t5, r5, "missing-key")), e4;
|
|
271
271
|
}
|
|
272
|
-
if (null == s6 || "" === s6) return n4?.onWarning?.(
|
|
273
|
-
} else s6 =
|
|
272
|
+
if (null == s6 || "" === s6) return n4?.onWarning?.(J(t5, r5, "missing-key")), e4;
|
|
273
|
+
} else s6 = G(s6, r5, `$flow.${t5}`);
|
|
274
274
|
return s6;
|
|
275
275
|
}
|
|
276
276
|
let l2 = e4.replace(D, (e5, a5) => {
|
|
277
277
|
const s6 = a5.split("."), c3 = s6[0], l3 = s6.slice(1).join(".");
|
|
278
278
|
void 0 === t4[c3] && T(`Variable "${c3}" not found`);
|
|
279
|
-
const
|
|
280
|
-
if (
|
|
281
|
-
T(`Cyclic $var reference: ${[...
|
|
279
|
+
const u3 = i3 ?? /* @__PURE__ */ new Set();
|
|
280
|
+
if (u3.has(c3)) {
|
|
281
|
+
T(`Cyclic $var reference: ${[...u3, c3].join(" -> ")}`);
|
|
282
282
|
}
|
|
283
283
|
let f3;
|
|
284
|
-
|
|
284
|
+
u3.add(c3);
|
|
285
285
|
try {
|
|
286
|
-
f3 =
|
|
286
|
+
f3 = X(t4[c3], t4, n4, r4, o3, u3);
|
|
287
287
|
} finally {
|
|
288
|
-
|
|
288
|
+
u3.delete(c3);
|
|
289
289
|
}
|
|
290
|
-
if (l3 && (f3 =
|
|
290
|
+
if (l3 && (f3 = G(f3, l3, `$var.${c3}`)), null === f3 || "string" != typeof f3 && "number" != typeof f3 && "boolean" != typeof f3) {
|
|
291
291
|
T(`Variable "${a5}" resolves to non-scalar (${Array.isArray(f3) ? "array" : typeof f3}) and cannot be inlined into a string. Use it as a whole-string reference: "$var.${a5}"`);
|
|
292
292
|
}
|
|
293
293
|
return String(f3);
|
|
294
294
|
});
|
|
295
|
-
return l2 = l2.replace(F, (e5, t5, r5) => n4?.deferred ? void 0 !== r5 ? `${
|
|
295
|
+
return l2 = l2.replace(F, (e5, t5, r5) => n4?.deferred ? void 0 !== r5 ? `${B}${t5}:${r5}` : `${B}${t5}` : "undefined" != typeof process && void 0 !== process.env?.[t5] ? process.env[t5] : void 0 !== r5 ? r5 : void T(`Environment variable "${t5}" not found and no default provided`)), l2;
|
|
296
296
|
}
|
|
297
|
-
if (Array.isArray(e4)) return e4.map((e5) =>
|
|
297
|
+
if (Array.isArray(e4)) return e4.map((e5) => X(e5, t4, n4, r4, o3, i3));
|
|
298
298
|
if (null !== e4 && "object" == typeof e4) {
|
|
299
299
|
const a4 = {};
|
|
300
|
-
for (const [s5, c2] of Object.entries(e4)) a4[s5] =
|
|
300
|
+
for (const [s5, c2] of Object.entries(e4)) a4[s5] = X(c2, t4, n4, r4, o3, i3);
|
|
301
301
|
return a4;
|
|
302
302
|
}
|
|
303
303
|
return e4;
|
|
304
304
|
}
|
|
305
|
-
function
|
|
305
|
+
function Y(e4) {
|
|
306
306
|
const t4 = e4.startsWith("@"), n4 = e4.replace("@", "").replace(/[/-]/g, "_").split("_").filter((e5) => e5.length > 0).map((e5, t5) => 0 === t5 ? e5 : e5.charAt(0).toUpperCase() + e5.slice(1)).join("");
|
|
307
307
|
return t4 ? "_" + n4 : n4;
|
|
308
308
|
}
|
|
309
|
-
function
|
|
310
|
-
const r4 = /* @__PURE__ */ new Map(), o3 = /* @__PURE__ */ new Set(),
|
|
309
|
+
function Q(e4, t4, n4) {
|
|
310
|
+
const r4 = /* @__PURE__ */ new Map(), o3 = /* @__PURE__ */ new Set(), i3 = [], a4 = (t5) => {
|
|
311
311
|
if (r4.has(t5)) return r4.get(t5);
|
|
312
312
|
const s6 = e4.flows[t5];
|
|
313
313
|
if (s6) {
|
|
314
314
|
if (o3.has(t5)) {
|
|
315
|
-
T(`Cyclic $flow reference: ${[...
|
|
315
|
+
T(`Cyclic $flow reference: ${[...i3, t5].join(" -> ")}`);
|
|
316
316
|
}
|
|
317
|
-
o3.add(t5),
|
|
317
|
+
o3.add(t5), i3.push(t5);
|
|
318
318
|
try {
|
|
319
|
-
const o4 =
|
|
320
|
-
return r4.set(t5,
|
|
319
|
+
const o4 = q(e4.variables, s6.variables), i4 = X(s6.config ?? {}, o4, n4, void 0, a4);
|
|
320
|
+
return r4.set(t5, i4), i4;
|
|
321
321
|
} finally {
|
|
322
|
-
o3.delete(t5),
|
|
322
|
+
o3.delete(t5), i3.pop();
|
|
323
323
|
}
|
|
324
324
|
}
|
|
325
325
|
}, s5 = Object.keys(e4.flows);
|
|
326
326
|
t4 || (1 === s5.length ? t4 = s5[0] : T(`Multiple flows found (${s5.join(", ")}). Please specify a flow.`));
|
|
327
327
|
const c2 = e4.flows[t4];
|
|
328
|
-
c2 || T(`Flow "${t4}" not found. Available: ${s5.join(", ")}`), o3.add(t4),
|
|
328
|
+
c2 || T(`Flow "${t4}" not found. Available: ${s5.join(", ")}`), o3.add(t4), i3.push(t4);
|
|
329
329
|
try {
|
|
330
330
|
return (function(e5, t5, n5, r5) {
|
|
331
331
|
const o4 = JSON.parse(JSON.stringify(t5));
|
|
332
|
-
let
|
|
332
|
+
let i4;
|
|
333
333
|
if (e5.contract) {
|
|
334
|
-
const o5 =
|
|
335
|
-
|
|
334
|
+
const o5 = q(e5.variables, t5.variables);
|
|
335
|
+
i4 = I(X(e5.contract, o5, n5, void 0, r5));
|
|
336
336
|
}
|
|
337
337
|
if (o4.config) {
|
|
338
|
-
const a5 =
|
|
339
|
-
o4.config =
|
|
338
|
+
const a5 = q(e5.variables, t5.variables);
|
|
339
|
+
o4.config = X(o4.config, a5, n5, i4, r5);
|
|
340
340
|
}
|
|
341
341
|
if (o4.sources) for (const [a5, s6] of Object.entries(o4.sources)) {
|
|
342
|
-
const c3 =
|
|
343
|
-
o4.sources[a5] = { package: s6.package, import: s6.import, config: l2, env:
|
|
342
|
+
const c3 = q(e5.variables, t5.variables, s6.variables), l2 = X(s6.config, c3, n5, i4, r5), u3 = X(s6.env, c3, n5, i4, r5);
|
|
343
|
+
o4.sources[a5] = { package: s6.package, import: s6.import, config: l2, env: u3, primary: s6.primary, variables: s6.variables, before: s6.before, next: s6.next, cache: s6.cache, validate: s6.validate, code: s6.code };
|
|
344
344
|
}
|
|
345
345
|
if (o4.destinations) for (const [a5, s6] of Object.entries(o4.destinations)) {
|
|
346
|
-
const c3 =
|
|
347
|
-
o4.destinations[a5] = { package: s6.package, import: s6.import, config: l2, env:
|
|
346
|
+
const c3 = q(e5.variables, t5.variables, s6.variables), l2 = X(s6.config, c3, n5, i4, r5), u3 = X(s6.env, c3, n5, i4, r5);
|
|
347
|
+
o4.destinations[a5] = { package: s6.package, import: s6.import, config: l2, env: u3, variables: s6.variables, before: s6.before, next: s6.next, cache: s6.cache, validate: s6.validate, code: s6.code };
|
|
348
348
|
}
|
|
349
349
|
if (o4.stores) for (const [a5, s6] of Object.entries(o4.stores)) {
|
|
350
|
-
const c3 =
|
|
351
|
-
o4.stores[a5] = { package: s6.package, import: s6.import, config: l2, env:
|
|
350
|
+
const c3 = q(e5.variables, t5.variables, s6.variables), l2 = X(s6.config, c3, n5, i4, r5), u3 = X(s6.env, c3, n5, i4, r5);
|
|
351
|
+
o4.stores[a5] = { package: s6.package, import: s6.import, config: l2, env: u3, cache: s6.cache, variables: s6.variables, code: s6.code };
|
|
352
352
|
}
|
|
353
353
|
if (o4.transformers) for (const [a5, s6] of Object.entries(o4.transformers)) {
|
|
354
|
-
const c3 =
|
|
355
|
-
o4.transformers[a5] = { package: s6.package, import: s6.import, config: l2, env:
|
|
354
|
+
const c3 = q(e5.variables, t5.variables, s6.variables), l2 = X(s6.config, c3, n5, i4, r5), u3 = X(s6.env, c3, n5, i4, r5);
|
|
355
|
+
o4.transformers[a5] = { package: s6.package, import: s6.import, config: l2, env: u3, variables: s6.variables, before: s6.before, next: s6.next, cache: s6.cache, validate: s6.validate, code: s6.code };
|
|
356
356
|
}
|
|
357
357
|
if (o4.collector) {
|
|
358
|
-
const a5 =
|
|
358
|
+
const a5 = q(e5.variables, t5.variables), s6 = X(o4.collector, a5, n5, i4, r5);
|
|
359
359
|
o4.collector = s6;
|
|
360
360
|
}
|
|
361
361
|
return o4;
|
|
362
362
|
})(e4, c2, n4, a4);
|
|
363
363
|
} finally {
|
|
364
|
-
o3.delete(t4),
|
|
364
|
+
o3.delete(t4), i3.pop();
|
|
365
365
|
}
|
|
366
366
|
}
|
|
367
|
-
function
|
|
367
|
+
function ee(e4) {
|
|
368
368
|
const t4 = e4.config?.platform;
|
|
369
369
|
if ("web" === t4 || "server" === t4) return t4;
|
|
370
370
|
T('Flow must have config.platform set to "web" or "server"');
|
|
371
371
|
}
|
|
372
|
-
function
|
|
373
|
-
n4 = { ...
|
|
372
|
+
function ne(e4, t4 = {}, n4 = {}) {
|
|
373
|
+
n4 = { ...te, ...n4 };
|
|
374
374
|
const r4 = Object.entries(t4).reduce((t5, [r5, o3]) => {
|
|
375
|
-
const
|
|
376
|
-
return n4.merge && Array.isArray(
|
|
375
|
+
const i3 = e4[r5];
|
|
376
|
+
return n4.merge && Array.isArray(i3) && Array.isArray(o3) ? t5[r5] = o3.reduce((e5, t6) => e5.includes(t6) ? e5 : [...e5, t6], [...i3]) : (n4.extend || r5 in e4) && (t5[r5] = o3), t5;
|
|
377
377
|
}, {});
|
|
378
378
|
return n4.shallow ? { ...e4, ...r4 } : (Object.assign(e4, r4), e4);
|
|
379
379
|
}
|
|
380
|
-
function
|
|
380
|
+
function oe(e4) {
|
|
381
381
|
return Array.isArray(e4);
|
|
382
382
|
}
|
|
383
|
-
function
|
|
383
|
+
function ie(e4) {
|
|
384
384
|
return "boolean" == typeof e4;
|
|
385
385
|
}
|
|
386
|
-
function
|
|
386
|
+
function se(e4) {
|
|
387
387
|
return void 0 !== e4;
|
|
388
388
|
}
|
|
389
|
-
function
|
|
389
|
+
function le(e4) {
|
|
390
390
|
return "function" == typeof e4;
|
|
391
391
|
}
|
|
392
|
-
function
|
|
392
|
+
function ue(e4) {
|
|
393
393
|
return "number" == typeof e4 && !Number.isNaN(e4);
|
|
394
394
|
}
|
|
395
|
-
function
|
|
396
|
-
return "object" == typeof e4 && null !== e4 && !
|
|
395
|
+
function fe(e4) {
|
|
396
|
+
return "object" == typeof e4 && null !== e4 && !oe(e4) && "[object Object]" === Object.prototype.toString.call(e4);
|
|
397
397
|
}
|
|
398
|
-
function
|
|
398
|
+
function pe(e4, t4) {
|
|
399
399
|
return typeof e4 == typeof t4;
|
|
400
400
|
}
|
|
401
|
-
function
|
|
401
|
+
function de(e4) {
|
|
402
402
|
return "string" == typeof e4;
|
|
403
403
|
}
|
|
404
|
-
function
|
|
404
|
+
function me(e4, t4 = /* @__PURE__ */ new WeakMap()) {
|
|
405
405
|
if ("object" != typeof e4 || null === e4) return e4;
|
|
406
406
|
if (t4.has(e4)) return t4.get(e4);
|
|
407
407
|
const n4 = Object.prototype.toString.call(e4);
|
|
408
408
|
if ("[object Object]" === n4) {
|
|
409
409
|
const n5 = {};
|
|
410
410
|
t4.set(e4, n5);
|
|
411
|
-
for (const r4 in e4) Object.prototype.hasOwnProperty.call(e4, r4) && (n5[r4] =
|
|
411
|
+
for (const r4 in e4) Object.prototype.hasOwnProperty.call(e4, r4) && (n5[r4] = me(e4[r4], t4));
|
|
412
412
|
return n5;
|
|
413
413
|
}
|
|
414
414
|
if ("[object Array]" === n4) {
|
|
415
415
|
const n5 = [];
|
|
416
416
|
return t4.set(e4, n5), e4.forEach((e5) => {
|
|
417
|
-
n5.push(
|
|
417
|
+
n5.push(me(e5, t4));
|
|
418
418
|
}), n5;
|
|
419
419
|
}
|
|
420
420
|
if ("[object Date]" === n4) return new Date(e4.getTime());
|
|
@@ -424,64 +424,64 @@ function pe(e4, t4 = /* @__PURE__ */ new WeakMap()) {
|
|
|
424
424
|
}
|
|
425
425
|
return e4;
|
|
426
426
|
}
|
|
427
|
-
function
|
|
427
|
+
function ge(e4, t4 = "", n4) {
|
|
428
428
|
const r4 = t4.split(".");
|
|
429
429
|
let o3 = e4;
|
|
430
430
|
for (let e5 = 0; e5 < r4.length; e5++) {
|
|
431
431
|
const t5 = r4[e5];
|
|
432
|
-
if ("*" === t5 &&
|
|
433
|
-
const t6 = r4.slice(e5 + 1).join("."),
|
|
432
|
+
if ("*" === t5 && oe(o3)) {
|
|
433
|
+
const t6 = r4.slice(e5 + 1).join("."), i3 = [];
|
|
434
434
|
for (const e6 of o3) {
|
|
435
|
-
const r5 =
|
|
436
|
-
|
|
435
|
+
const r5 = ge(e6, t6, n4);
|
|
436
|
+
i3.push(r5);
|
|
437
437
|
}
|
|
438
|
-
return
|
|
438
|
+
return i3;
|
|
439
439
|
}
|
|
440
|
-
if (o3 =
|
|
440
|
+
if (o3 = fe(o3) || oe(o3) ? o3[t5] : void 0, void 0 === o3) break;
|
|
441
441
|
}
|
|
442
|
-
return
|
|
442
|
+
return se(o3) ? o3 : n4;
|
|
443
443
|
}
|
|
444
|
-
function
|
|
445
|
-
if (!
|
|
446
|
-
const r4 =
|
|
447
|
-
let
|
|
444
|
+
function ye(e4, t4, n4) {
|
|
445
|
+
if (!fe(e4)) return e4;
|
|
446
|
+
const r4 = me(e4), o3 = t4.split(".");
|
|
447
|
+
let i3 = r4;
|
|
448
448
|
for (let e5 = 0; e5 < o3.length; e5++) {
|
|
449
449
|
const t5 = o3[e5];
|
|
450
|
-
e5 === o3.length - 1 ?
|
|
450
|
+
e5 === o3.length - 1 ? i3[t5] = n4 : (t5 in i3 && "object" == typeof i3[t5] && null !== i3[t5] || (i3[t5] = {}), i3 = i3[t5]);
|
|
451
451
|
}
|
|
452
452
|
return r4;
|
|
453
453
|
}
|
|
454
|
-
function
|
|
455
|
-
if (!
|
|
456
|
-
const n4 =
|
|
454
|
+
function he(e4, t4) {
|
|
455
|
+
if (!fe(e4) && !oe(e4)) return e4;
|
|
456
|
+
const n4 = me(e4), r4 = t4.split(".");
|
|
457
457
|
let o3 = n4;
|
|
458
458
|
for (let e5 = 0; e5 < r4.length; e5++) {
|
|
459
|
-
const t5 = r4[e5],
|
|
460
|
-
if (
|
|
459
|
+
const t5 = r4[e5], i3 = e5 === r4.length - 1;
|
|
460
|
+
if (oe(o3)) {
|
|
461
461
|
const e6 = Number(t5);
|
|
462
462
|
if (!Number.isInteger(e6) || e6 < 0 || e6 >= o3.length) return n4;
|
|
463
|
-
if (
|
|
463
|
+
if (i3) o3.splice(e6, 1);
|
|
464
464
|
else {
|
|
465
465
|
const t6 = o3[e6];
|
|
466
|
-
if (!
|
|
466
|
+
if (!fe(t6) && !oe(t6)) return n4;
|
|
467
467
|
o3 = t6;
|
|
468
468
|
}
|
|
469
|
-
} else if (
|
|
469
|
+
} else if (i3) delete o3[t5];
|
|
470
470
|
else {
|
|
471
471
|
const e6 = o3[t5];
|
|
472
|
-
if (!
|
|
472
|
+
if (!fe(e6) && !oe(e6)) return n4;
|
|
473
473
|
o3 = e6;
|
|
474
474
|
}
|
|
475
475
|
}
|
|
476
476
|
return n4;
|
|
477
477
|
}
|
|
478
|
-
function
|
|
479
|
-
const n4 = {}, r4 = t4.includes("all") ? Object.keys(
|
|
478
|
+
function be(e4, t4) {
|
|
479
|
+
const n4 = {}, r4 = t4.includes("all") ? Object.keys(ve) : t4;
|
|
480
480
|
for (const t5 of r4) {
|
|
481
|
-
const r5 =
|
|
481
|
+
const r5 = ve[t5];
|
|
482
482
|
if (!r5) continue;
|
|
483
483
|
const o3 = r5(e4);
|
|
484
|
-
if (
|
|
484
|
+
if (fe(o3)) for (const [e5, r6] of Object.entries(o3)) {
|
|
485
485
|
if (void 0 === r6) continue;
|
|
486
486
|
const o4 = "context" === t5 && Array.isArray(r6) ? r6[0] : r6;
|
|
487
487
|
n4[`${t5}_${e5}`] = o4;
|
|
@@ -489,31 +489,31 @@ function he(e4, t4) {
|
|
|
489
489
|
}
|
|
490
490
|
return n4;
|
|
491
491
|
}
|
|
492
|
-
function
|
|
492
|
+
function ke(e4, t4 = {}, n4 = {}) {
|
|
493
493
|
const r4 = { ...t4, ...n4 }, o3 = {};
|
|
494
|
-
let
|
|
494
|
+
let i3 = !e4 || 0 === Object.keys(e4).length;
|
|
495
495
|
return Object.keys(r4).forEach((t5) => {
|
|
496
|
-
r4[t5] && (o3[t5] = true, e4 && e4[t5] && (
|
|
497
|
-
}), !!
|
|
496
|
+
r4[t5] && (o3[t5] = true, e4 && e4[t5] && (i3 = true));
|
|
497
|
+
}), !!i3 && o3;
|
|
498
498
|
}
|
|
499
|
-
function
|
|
499
|
+
function xe() {
|
|
500
500
|
let e4 = "";
|
|
501
501
|
for (let t4 = 0; t4 < 16; t4++) e4 += (16 * Math.random() | 0).toString(16);
|
|
502
502
|
return e4;
|
|
503
503
|
}
|
|
504
|
-
function
|
|
505
|
-
const t4 = e4.timestamp || (/* @__PURE__ */ new Date()).setHours(0, 13, 37, 0), n4 =
|
|
504
|
+
function Ae(e4 = {}) {
|
|
505
|
+
const t4 = e4.timestamp || (/* @__PURE__ */ new Date()).setHours(0, 13, 37, 0), n4 = ne({ name: "entity action", data: { string: "foo", number: 1, boolean: true, array: [0, "text", false], not: void 0 }, context: { dev: ["test", 1] }, globals: { lang: "elb" }, custom: { completely: "random" }, user: { id: "us3r", device: "c00k13", session: "s3ss10n" }, nested: [{ entity: "child", data: { is: "subordinated" } }], consent: { functional: true }, id: e4.id || xe(), trigger: "test", entity: "entity", action: "action", timestamp: t4, timing: 3.14, source: { type: "collector", schema: "4" } }, e4, { merge: false });
|
|
506
506
|
if (e4.name) {
|
|
507
507
|
const [t5, r4] = e4.name.split(" ") ?? [];
|
|
508
508
|
t5 && r4 && (n4.entity = t5, n4.action = r4);
|
|
509
509
|
}
|
|
510
510
|
return n4;
|
|
511
511
|
}
|
|
512
|
-
function
|
|
512
|
+
function Oe(e4 = "entity action", t4 = {}) {
|
|
513
513
|
const n4 = t4.timestamp || (/* @__PURE__ */ new Date()).setHours(0, 13, 37, 0), r4 = { data: { id: "ers", name: "Everyday Ruck Snack", color: "black", size: "l", price: 420 } }, o3 = { data: { id: "cc", name: "Cool Cap", size: "one size", price: 42 } };
|
|
514
|
-
return
|
|
514
|
+
return Ae({ ...{ "cart view": { data: { currency: "EUR", value: 2 * r4.data.price }, context: { shopping: ["cart", 0] }, globals: { pagegroup: "shop" }, nested: [{ entity: "product", data: { ...r4.data, quantity: 2 }, context: { shopping: ["cart", 0] }, nested: [] }], trigger: "load" }, "checkout view": { data: { step: "payment", currency: "EUR", value: r4.data.price + o3.data.price }, context: { shopping: ["checkout", 0] }, globals: { pagegroup: "shop" }, nested: [{ entity: "product", ...r4, context: { shopping: ["checkout", 0] }, nested: [] }, { entity: "product", ...o3, context: { shopping: ["checkout", 0] }, nested: [] }], trigger: "load" }, "order complete": { data: { id: "0rd3r1d", currency: "EUR", shipping: 5.22, taxes: 73.76, total: 555 }, context: { shopping: ["complete", 0] }, globals: { pagegroup: "shop" }, nested: [{ entity: "product", ...r4, context: { shopping: ["complete", 0] }, nested: [] }, { entity: "product", ...o3, context: { shopping: ["complete", 0] }, nested: [] }, { entity: "gift", data: { name: "Surprise" }, context: { shopping: ["complete", 0] }, nested: [] }], trigger: "load" }, "page view": { data: { domain: "www.example.com", title: "walkerOS documentation", referrer: "https://www.walkeros.io/", search: "?foo=bar", hash: "#hash", id: "/docs/" }, globals: { pagegroup: "docs" }, trigger: "load" }, "product add": { ...r4, context: { shopping: ["intent", 0] }, globals: { pagegroup: "shop" }, nested: [], trigger: "click" }, "product view": { ...r4, context: { shopping: ["detail", 0] }, globals: { pagegroup: "shop" }, nested: [], trigger: "load" }, "product visible": { data: { ...r4.data, position: 3, promo: true }, context: { shopping: ["discover", 0] }, globals: { pagegroup: "shop" }, nested: [], trigger: "load" }, "promotion visible": { data: { name: "Setting up tracking easily", position: "hero" }, context: { ab_test: ["engagement", 0] }, globals: { pagegroup: "homepage" }, trigger: "visible" }, "session start": { data: { id: "s3ss10n", start: n4, isNew: true, count: 1, runs: 1, isStart: true, storage: true, referrer: "", device: "c00k13" }, user: { id: "us3r", device: "c00k13", session: "s3ss10n", hash: "h4sh", address: "street number", email: "user@example.com", phone: "+49 123 456 789", userAgent: "Mozilla...", browser: "Chrome", browserVersion: "90", deviceType: "desktop", language: "de-DE", country: "DE", region: "HH", city: "Hamburg", zip: "20354", timezone: "Berlin", os: "walkerOS", osVersion: "1.0", screenSize: "1337x420", ip: "127.0.0.0", internal: true, custom: "value" } } }[e4], ...t4, name: e4 });
|
|
515
515
|
}
|
|
516
|
-
function
|
|
516
|
+
function Se(e4 = 6, t4) {
|
|
517
517
|
if (t4) {
|
|
518
518
|
const n5 = t4.length;
|
|
519
519
|
let r4 = "";
|
|
@@ -524,12 +524,12 @@ function Ae(e4 = 6, t4) {
|
|
|
524
524
|
for (let t5 = 36; n4.length < e4; ) n4 += (Math.random() * t5 | 0).toString(t5);
|
|
525
525
|
return n4;
|
|
526
526
|
}
|
|
527
|
-
function
|
|
527
|
+
function Ne(e4, t4) {
|
|
528
528
|
return "number" == typeof e4 ? { wait: e4 } : e4 ? { wait: e4.wait ?? t4, size: e4.size, age: e4.age } : { wait: t4 };
|
|
529
529
|
}
|
|
530
|
-
function
|
|
531
|
-
const { wait: r4, size: o3, age:
|
|
532
|
-
let a4, s5, c2 = null, l2 = null,
|
|
530
|
+
function Te(e4, t4 = 1e3, n4 = false) {
|
|
531
|
+
const { wait: r4, size: o3, age: i3 } = Ne(t4, 1e3);
|
|
532
|
+
let a4, s5, c2 = null, l2 = null, u3 = false, f3 = [], p2 = 0;
|
|
533
533
|
const d2 = () => {
|
|
534
534
|
c2 && (clearTimeout(c2), c2 = null), l2 && (clearTimeout(l2), l2 = null), p2 = 0, s5 = void 0;
|
|
535
535
|
}, m3 = () => {
|
|
@@ -537,14 +537,14 @@ function _e(e4, t4 = 1e3, n4 = false) {
|
|
|
537
537
|
if (d2(), f3 = [], t5) return a4 = e4(...t5), n5.forEach((e5) => e5(a4)), a4;
|
|
538
538
|
n5.forEach((e5) => e5(void 0));
|
|
539
539
|
}, g3 = (...t5) => new Promise((d3) => {
|
|
540
|
-
const g4 = n4 && !
|
|
540
|
+
const g4 = n4 && !u3;
|
|
541
541
|
if (s5 = t5, p2 += 1, f3.push(d3), c2 && clearTimeout(c2), c2 = setTimeout(() => {
|
|
542
|
-
c2 = null, n4 && !
|
|
543
|
-
}, r4), void 0 ===
|
|
542
|
+
c2 = null, n4 && !u3 || m3();
|
|
543
|
+
}, r4), void 0 === i3 || l2 || (l2 = setTimeout(() => {
|
|
544
544
|
l2 = null, m3();
|
|
545
|
-
},
|
|
545
|
+
}, i3)), void 0 !== o3 && p2 >= o3) m3();
|
|
546
546
|
else if (g4) {
|
|
547
|
-
|
|
547
|
+
u3 = true, a4 = e4(...t5);
|
|
548
548
|
const n5 = f3;
|
|
549
549
|
f3 = [], n5.forEach((e5) => e5(a4));
|
|
550
550
|
}
|
|
@@ -556,39 +556,39 @@ function _e(e4, t4 = 1e3, n4 = false) {
|
|
|
556
556
|
f3 = [], d2(), e5.forEach((e6) => e6(void 0));
|
|
557
557
|
}, g3.size = () => p2, g3;
|
|
558
558
|
}
|
|
559
|
-
function
|
|
559
|
+
function Ie(e4) {
|
|
560
560
|
return { message: e4.message, name: e4.name, stack: e4.stack, cause: e4.cause };
|
|
561
561
|
}
|
|
562
|
-
function
|
|
562
|
+
function ze(e4, t4) {
|
|
563
563
|
let n4, r4 = {};
|
|
564
|
-
return e4 instanceof Error ? (n4 = e4.message, r4.error =
|
|
564
|
+
return e4 instanceof Error ? (n4 = e4.message, r4.error = Ie(e4)) : n4 = e4, void 0 !== t4 && (t4 instanceof Error ? r4.error = Ie(t4) : "object" == typeof t4 && null !== t4 ? (r4 = { ...r4, ...t4 }, "error" in r4 && r4.error instanceof Error && (r4.error = Ie(r4.error))) : r4.value = t4), { message: n4, context: r4 };
|
|
565
565
|
}
|
|
566
|
-
function
|
|
567
|
-
return
|
|
566
|
+
function Me(e4 = {}) {
|
|
567
|
+
return Re({ level: void 0 !== e4.level ? (function(e5) {
|
|
568
568
|
return "string" == typeof e5 ? f[e5] : e5;
|
|
569
569
|
})(e4.level) : 0, handler: e4.handler, jsonHandler: e4.jsonHandler, scope: [] });
|
|
570
570
|
}
|
|
571
|
-
function
|
|
572
|
-
const { level: t4, handler: n4, jsonHandler: r4, scope: o3 } = e4,
|
|
571
|
+
function Re(e4) {
|
|
572
|
+
const { level: t4, handler: n4, jsonHandler: r4, scope: o3 } = e4, i3 = (e5, r5, i4) => {
|
|
573
573
|
if (e5 <= t4) {
|
|
574
|
-
const t5 =
|
|
575
|
-
n4 ? n4(e5, t5.message, t5.context, o3,
|
|
574
|
+
const t5 = ze(r5, i4);
|
|
575
|
+
n4 ? n4(e5, t5.message, t5.context, o3, Pe) : Pe(e5, t5.message, t5.context, o3);
|
|
576
576
|
}
|
|
577
577
|
};
|
|
578
|
-
return { error: (e5, t5) =>
|
|
579
|
-
const r5 =
|
|
580
|
-
throw n4 ? n4(0, r5.message, r5.context, o3,
|
|
578
|
+
return { error: (e5, t5) => i3(0, e5, t5), warn: (e5, t5) => i3(1, e5, t5), info: (e5, t5) => i3(2, e5, t5), debug: (e5, t5) => i3(3, e5, t5), throw: (e5, t5) => {
|
|
579
|
+
const r5 = ze(e5, t5);
|
|
580
|
+
throw n4 ? n4(0, r5.message, r5.context, o3, Pe) : Pe(0, r5.message, r5.context, o3), new Error(r5.message);
|
|
581
581
|
}, json: (e5) => {
|
|
582
582
|
r4 ? r4(e5) : console.log(JSON.stringify(e5, null, 2));
|
|
583
|
-
}, scope: (e5) =>
|
|
584
|
-
}
|
|
585
|
-
function Me(e4) {
|
|
586
|
-
return re(e4) || fe(e4) || ce(e4) || !ie(e4) || ne(e4) && e4.every(Me) || le(e4) && Object.values(e4).every(Me);
|
|
583
|
+
}, scope: (e5) => Re({ level: t4, handler: n4, jsonHandler: r4, scope: [...o3, e5] }) };
|
|
587
584
|
}
|
|
588
585
|
function De(e4) {
|
|
589
|
-
return
|
|
586
|
+
return ie(e4) || de(e4) || ue(e4) || !se(e4) || oe(e4) && e4.every(De) || fe(e4) && Object.values(e4).every(De);
|
|
590
587
|
}
|
|
591
|
-
function
|
|
588
|
+
function Ue(e4) {
|
|
589
|
+
return De(e4) ? e4 : void 0;
|
|
590
|
+
}
|
|
591
|
+
function Ze(e4, t4, n4) {
|
|
592
592
|
return function(...r4) {
|
|
593
593
|
try {
|
|
594
594
|
return e4(...r4);
|
|
@@ -600,7 +600,7 @@ function Fe(e4, t4, n4) {
|
|
|
600
600
|
}
|
|
601
601
|
};
|
|
602
602
|
}
|
|
603
|
-
function
|
|
603
|
+
function We(e4, t4, n4) {
|
|
604
604
|
return async function(...r4) {
|
|
605
605
|
try {
|
|
606
606
|
return await e4(...r4);
|
|
@@ -612,122 +612,122 @@ function Ue(e4, t4, n4) {
|
|
|
612
612
|
}
|
|
613
613
|
};
|
|
614
614
|
}
|
|
615
|
-
async function
|
|
615
|
+
async function Le(e4, t4, n4) {
|
|
616
616
|
const [r4, o3] = (e4.name || "").split(" ");
|
|
617
617
|
if (!t4 || !r4 || !o3) return {};
|
|
618
|
-
let
|
|
618
|
+
let i3, a4 = "", s5 = r4, c2 = o3;
|
|
619
619
|
const l2 = (t5) => {
|
|
620
620
|
if (!t5) return;
|
|
621
|
-
return (
|
|
621
|
+
return (oe(t5) ? t5 : [t5]).find((t6) => {
|
|
622
622
|
if (!t6.condition) return true;
|
|
623
623
|
if (!n4) return Boolean(t6.condition(e4, void 0));
|
|
624
|
-
const r5 = { event: e4, mapping: t6, collector: n4, logger: n4.logger, consent:
|
|
624
|
+
const r5 = { event: e4, mapping: t6, collector: n4, logger: n4.logger, consent: fe(e4) && e4.consent || n4.consent };
|
|
625
625
|
return Boolean(t6.condition(e4, r5));
|
|
626
626
|
});
|
|
627
627
|
};
|
|
628
628
|
t4[s5] || (s5 = "*");
|
|
629
|
-
const
|
|
630
|
-
return
|
|
629
|
+
const u3 = t4[s5];
|
|
630
|
+
return u3 && (u3[c2] || (c2 = "*"), i3 = l2(u3[c2])), i3 || (s5 = "*", c2 = "*", i3 = l2(t4[s5]?.[c2])), i3 && (a4 = `${s5} ${c2}`), { eventMapping: i3, mappingKey: a4 };
|
|
631
631
|
}
|
|
632
|
-
async function
|
|
633
|
-
if (!
|
|
634
|
-
const r4 =
|
|
632
|
+
async function Ke(e4, t4 = {}, n4 = {}) {
|
|
633
|
+
if (!se(e4)) return;
|
|
634
|
+
const r4 = fe(e4) && e4.consent || n4.consent || n4.collector?.consent, o3 = n4.event ?? (fe(e4) ? e4 : {});
|
|
635
635
|
if (!n4.collector) throw new Error("getMappingValue: context.collector is required");
|
|
636
|
-
const
|
|
636
|
+
const i3 = { event: o3, mapping: t4, collector: n4.collector, logger: n4.collector.logger, consent: r4 }, a4 = oe(t4) ? t4 : [t4];
|
|
637
637
|
for (const t5 of a4) {
|
|
638
|
-
const r5 = await
|
|
639
|
-
if (e5 instanceof
|
|
640
|
-
n4.collector && n4.collector.status.failed++,
|
|
641
|
-
})(e4, t5, { ...
|
|
642
|
-
if (
|
|
638
|
+
const r5 = await We(Ve, (e5) => {
|
|
639
|
+
if (e5 instanceof He) throw e5;
|
|
640
|
+
n4.collector && n4.collector.status.failed++, i3.logger.error("mapping processing failed", { event: o3, error: e5 });
|
|
641
|
+
})(e4, t5, { ...i3, mapping: t5 });
|
|
642
|
+
if (se(r5)) return r5;
|
|
643
643
|
}
|
|
644
644
|
}
|
|
645
|
-
async function
|
|
646
|
-
return (
|
|
645
|
+
async function Ve(e4, t4, n4) {
|
|
646
|
+
return (oe(t4) ? t4 : [t4]).reduce(async (t5, r4) => {
|
|
647
647
|
const o3 = await t5;
|
|
648
648
|
if (o3) return o3;
|
|
649
|
-
const
|
|
650
|
-
if (!Object.keys(
|
|
651
|
-
const { condition: a4, consent: s5, fn: c2, key: l2, loop:
|
|
652
|
-
if (a4 && !await
|
|
653
|
-
if (e5 instanceof
|
|
649
|
+
const i3 = de(r4) ? { key: r4 } : r4;
|
|
650
|
+
if (!Object.keys(i3).length) return;
|
|
651
|
+
const { condition: a4, consent: s5, fn: c2, key: l2, loop: u3, map: f3, set: p2, validate: d2, value: m3 } = i3, g3 = { ...n4, mapping: r4 };
|
|
652
|
+
if (a4 && !await We(a4, (e5) => {
|
|
653
|
+
if (e5 instanceof He) throw e5;
|
|
654
654
|
return g3.logger.error("mapping condition failed", { event: g3.event, error: e5 }), false;
|
|
655
655
|
})(e4, g3)) return;
|
|
656
|
-
if (s5 && !
|
|
657
|
-
let y2 =
|
|
658
|
-
if (c2 && (y2 = await
|
|
659
|
-
if (e5 instanceof
|
|
656
|
+
if (s5 && !ke(s5, g3.consent)) return m3;
|
|
657
|
+
let y2 = se(m3) ? m3 : e4;
|
|
658
|
+
if (c2 && (y2 = await We(c2, (e5) => {
|
|
659
|
+
if (e5 instanceof He) throw e5;
|
|
660
660
|
g3.logger.error("mapping fn failed", { event: g3.event, error: e5 });
|
|
661
|
-
})(e4, g3)), l2 && (y2 =
|
|
662
|
-
const [t6, n5] =
|
|
663
|
-
|
|
661
|
+
})(e4, g3)), l2 && (y2 = ge(e4, l2, m3)), u3) {
|
|
662
|
+
const [t6, n5] = u3, r5 = "this" === t6 ? [e4] : await Ke(e4, t6, g3);
|
|
663
|
+
oe(r5) && (y2 = (await Promise.all(r5.map((e5) => Ke(e5, n5, g3)))).filter(se));
|
|
664
664
|
} else f3 ? y2 = await Object.entries(f3).reduce(async (t6, [n5, r5]) => {
|
|
665
|
-
const o4 = await t6,
|
|
666
|
-
return
|
|
667
|
-
}, Promise.resolve({})) : p2 && (y2 = await Promise.all(p2.map((t6) =>
|
|
668
|
-
d2 && !await
|
|
669
|
-
if (e5 instanceof
|
|
665
|
+
const o4 = await t6, i4 = await Ke(e4, r5, g3);
|
|
666
|
+
return se(i4) && (o4[n5] = i4), o4;
|
|
667
|
+
}, Promise.resolve({})) : p2 && (y2 = await Promise.all(p2.map((t6) => Ve(e4, t6, g3))));
|
|
668
|
+
d2 && !await We(d2, (e5) => {
|
|
669
|
+
if (e5 instanceof He) throw e5;
|
|
670
670
|
return g3.logger.error("mapping validate failed", { event: g3.event, error: e5 }), false;
|
|
671
671
|
})(y2, g3) && (y2 = void 0);
|
|
672
|
-
const h3 =
|
|
673
|
-
return
|
|
672
|
+
const h3 = Ue(y2);
|
|
673
|
+
return se(h3) ? h3 : Ue(m3);
|
|
674
674
|
}, Promise.resolve(void 0));
|
|
675
675
|
}
|
|
676
|
-
async function
|
|
676
|
+
async function qe(e4, t4, n4) {
|
|
677
677
|
t4.policy && await Promise.all(Object.entries(t4.policy).map(async ([t5, r5]) => {
|
|
678
|
-
const o4 = await
|
|
679
|
-
e4 =
|
|
678
|
+
const o4 = await Ke(e4, r5, { collector: n4, event: e4 });
|
|
679
|
+
e4 = ye(e4, t5, o4);
|
|
680
680
|
}));
|
|
681
|
-
const { eventMapping: r4, mappingKey: o3 } = await
|
|
681
|
+
const { eventMapping: r4, mappingKey: o3 } = await Le(e4, t4.mapping, n4);
|
|
682
682
|
r4?.policy && await Promise.all(Object.entries(r4.policy).map(async ([t5, r5]) => {
|
|
683
|
-
const o4 = await
|
|
684
|
-
e4 =
|
|
683
|
+
const o4 = await Ke(e4, r5, { collector: n4, event: e4 });
|
|
684
|
+
e4 = ye(e4, t5, o4);
|
|
685
685
|
}));
|
|
686
|
-
let
|
|
686
|
+
let i3 = t4.data && await Ke(e4, t4.data, { collector: n4, event: e4 });
|
|
687
687
|
const a4 = Boolean(r4?.silent);
|
|
688
688
|
if (r4) {
|
|
689
|
-
if (r4.ignore) return { event: e4, data:
|
|
689
|
+
if (r4.ignore) return { event: e4, data: i3, mapping: r4, mappingKey: o3, ignore: true, silent: a4 };
|
|
690
690
|
if (r4.name && (e4.name = r4.name), r4.data) {
|
|
691
|
-
const t5 = r4.data && await
|
|
692
|
-
|
|
691
|
+
const t5 = r4.data && await Ke(e4, r4.data, { collector: n4, event: e4 });
|
|
692
|
+
i3 = fe(i3) && fe(t5) ? ne(i3, t5) : t5;
|
|
693
693
|
}
|
|
694
694
|
}
|
|
695
695
|
const s5 = r4?.include ?? t4.include;
|
|
696
696
|
if (s5 && s5.length > 0) {
|
|
697
|
-
const t5 =
|
|
698
|
-
Object.keys(t5).length > 0 && (
|
|
697
|
+
const t5 = be(e4, s5);
|
|
698
|
+
Object.keys(t5).length > 0 && (i3 = fe(i3) ? ne(t5, i3) : i3 ?? t5);
|
|
699
699
|
}
|
|
700
|
-
if (r4?.remove &&
|
|
701
|
-
return { event: e4, data:
|
|
700
|
+
if (r4?.remove && fe(i3)) for (const e5 of r4.remove) i3 = he(i3, e5);
|
|
701
|
+
return { event: e4, data: i3, mapping: r4, mappingKey: o3, ignore: false, silent: a4 };
|
|
702
702
|
}
|
|
703
|
-
function
|
|
704
|
-
return void 0 === e4 ||
|
|
703
|
+
function nt(e4) {
|
|
704
|
+
return void 0 === e4 || pe(e4, "") ? e4 : JSON.stringify(e4);
|
|
705
705
|
}
|
|
706
|
-
function
|
|
707
|
-
return
|
|
706
|
+
function rt(e4 = {}) {
|
|
707
|
+
return ne({ "Content-Type": "application/json; charset=utf-8" }, e4);
|
|
708
708
|
}
|
|
709
|
-
function
|
|
709
|
+
function at(e4, t4, n4, r4) {
|
|
710
710
|
const o3 = e4;
|
|
711
711
|
return function(...e5) {
|
|
712
|
-
let
|
|
713
|
-
const a4 = "pre" + t4, s5 = "post" + t4, c2 = n4[a4], l2 = n4[s5],
|
|
712
|
+
let i3;
|
|
713
|
+
const a4 = "pre" + t4, s5 = "post" + t4, c2 = n4[a4], l2 = n4[s5], u3 = (e6, t5) => {
|
|
714
714
|
r4 ? r4.warn(e6, { error: t5 }) : console.warn(e6, t5);
|
|
715
715
|
};
|
|
716
716
|
if (c2) try {
|
|
717
|
-
|
|
717
|
+
i3 = c2({ fn: o3 }, ...e5);
|
|
718
718
|
} catch (t5) {
|
|
719
|
-
|
|
719
|
+
u3(`Hook ${String(a4)} failed, falling back to original function`, t5), i3 = o3(...e5);
|
|
720
720
|
}
|
|
721
|
-
else
|
|
721
|
+
else i3 = o3(...e5);
|
|
722
722
|
if (l2) try {
|
|
723
|
-
|
|
723
|
+
i3 = l2({ fn: o3, result: i3 }, ...e5);
|
|
724
724
|
} catch (e6) {
|
|
725
|
-
|
|
725
|
+
u3(`Hook ${String(s5)} failed, keeping original result`, e6);
|
|
726
726
|
}
|
|
727
|
-
return
|
|
727
|
+
return i3;
|
|
728
728
|
};
|
|
729
729
|
}
|
|
730
|
-
function
|
|
730
|
+
function st(e4, t4) {
|
|
731
731
|
if (t4 >= 1) return true;
|
|
732
732
|
if (t4 <= 0) return false;
|
|
733
733
|
return (function(e5) {
|
|
@@ -736,24 +736,24 @@ function it(e4, t4) {
|
|
|
736
736
|
return t5 >>> 0;
|
|
737
737
|
})(e4) / 4294967295 < t4;
|
|
738
738
|
}
|
|
739
|
-
function
|
|
739
|
+
function ct(e4, t4) {
|
|
740
740
|
const n4 = "function" == typeof t4 ? t4 : () => t4;
|
|
741
741
|
return function(t5) {
|
|
742
742
|
const r4 = n4();
|
|
743
743
|
if (!r4) return;
|
|
744
744
|
const o3 = r4.level ?? "standard";
|
|
745
745
|
if ("off" === o3) return;
|
|
746
|
-
const
|
|
747
|
-
if (t5.eventId && !
|
|
748
|
-
const s5 = r4.includeIn ?? "trace" === o3, c2 = r4.includeOut ?? "trace" === o3, l2 = r4.includeMappingKey ?? "trace" === o3,
|
|
749
|
-
s5 || delete
|
|
746
|
+
const i3 = r4.sample, a4 = "number" == typeof i3 && Number.isFinite(i3) ? i3 : 1;
|
|
747
|
+
if (t5.eventId && !st(t5.eventId, a4)) return;
|
|
748
|
+
const s5 = r4.includeIn ?? "trace" === o3, c2 = r4.includeOut ?? "trace" === o3, l2 = r4.includeMappingKey ?? "trace" === o3, u3 = { ...t5 };
|
|
749
|
+
s5 || delete u3.inEvent, c2 || delete u3.outEvent, l2 || delete u3.mappingKey, "trace" !== o3 && u3.error?.message && u3.error.message.length > 256 && (u3.error = { ...u3.error, message: u3.error.message.slice(0, 256) + "\u2026" });
|
|
750
750
|
try {
|
|
751
|
-
e4(
|
|
751
|
+
e4(u3);
|
|
752
752
|
} catch {
|
|
753
753
|
}
|
|
754
754
|
};
|
|
755
755
|
}
|
|
756
|
-
function
|
|
756
|
+
function ut(e4) {
|
|
757
757
|
const t4 = e4.env ?? ("undefined" != typeof process ? process.env : {}), n4 = e4.now ?? (() => Date.now()), r4 = t4.WALKEROS_TRACE_UNTIL;
|
|
758
758
|
if ("string" == typeof r4 && r4.length > 0) {
|
|
759
759
|
const t5 = Date.parse(r4);
|
|
@@ -761,10 +761,10 @@ function ct(e4) {
|
|
|
761
761
|
}
|
|
762
762
|
const o3 = e4.observe?.level ?? "standard";
|
|
763
763
|
if ("off" === o3) return null;
|
|
764
|
-
const
|
|
765
|
-
return { flowId: e4.flowId, level: o3, sample:
|
|
764
|
+
const i3 = e4.observe?.sample ?? 1;
|
|
765
|
+
return { flowId: e4.flowId, level: o3, sample: i3 };
|
|
766
766
|
}
|
|
767
|
-
function
|
|
767
|
+
function ft(e4, t4) {
|
|
768
768
|
if (0 === e4.observers.size) return;
|
|
769
769
|
const n4 = Array.from(e4.observers);
|
|
770
770
|
for (const e5 of n4) try {
|
|
@@ -772,14 +772,14 @@ function lt(e4, t4) {
|
|
|
772
772
|
} catch {
|
|
773
773
|
}
|
|
774
774
|
}
|
|
775
|
-
function
|
|
776
|
-
const t4 = e4.batchMs, n4 = "number" == typeof t4 && Number.isFinite(t4) && t4 > 0 ? Math.floor(t4) : 50, r4 = e4.batchSize, o3 = "number" == typeof r4 && Number.isFinite(r4) && r4 >= 1 ? Math.floor(r4) : 50,
|
|
775
|
+
function pt(e4) {
|
|
776
|
+
const t4 = e4.batchMs, n4 = "number" == typeof t4 && Number.isFinite(t4) && t4 > 0 ? Math.floor(t4) : 50, r4 = e4.batchSize, o3 = "number" == typeof r4 && Number.isFinite(r4) && r4 >= 1 ? Math.floor(r4) : 50, i3 = e4.fetch ?? ((e5, t5) => globalThis.fetch(e5, t5)), a4 = e4.onError ?? (() => {
|
|
777
777
|
});
|
|
778
778
|
let s5 = [], c2 = null;
|
|
779
779
|
function l2() {
|
|
780
780
|
if (0 === s5.length) return;
|
|
781
781
|
const t5 = s5;
|
|
782
|
-
s5 = [], c2 && (clearTimeout(c2), c2 = null), Promise.resolve().then(() =>
|
|
782
|
+
s5 = [], c2 && (clearTimeout(c2), c2 = null), Promise.resolve().then(() => i3(e4.url, { method: "POST", headers: { "Content-Type": "application/json", Authorization: `Bearer ${e4.token}` }, body: JSON.stringify(t5) })).then((e5) => {
|
|
783
783
|
e5 && "object" == typeof e5 && "ok" in e5 && !e5.ok && a4(new Error(`Observer responded ${e5.status}`));
|
|
784
784
|
}).catch((e5) => {
|
|
785
785
|
a4(e5);
|
|
@@ -789,55 +789,55 @@ function ut(e4) {
|
|
|
789
789
|
s5.push(e5), s5.length >= o3 ? l2() : null === c2 && (c2 = setTimeout(l2, n4));
|
|
790
790
|
};
|
|
791
791
|
}
|
|
792
|
-
function
|
|
792
|
+
function jt(e4) {
|
|
793
793
|
return "string" == typeof e4 || Array.isArray(e4) && e4.every((e5) => "string" == typeof e5) ? e4 : void 0;
|
|
794
794
|
}
|
|
795
|
-
async function
|
|
796
|
-
const n4 = t4?.version || "latest", r4 = t4?.timeout || 1e4, o3 = new AbortController(),
|
|
795
|
+
async function xt(e4, t4) {
|
|
796
|
+
const n4 = t4?.version || "latest", r4 = t4?.timeout || 1e4, o3 = new AbortController(), i3 = setTimeout(() => o3.abort(), r4), a4 = o3.signal, s5 = t4?.client ? { "X-Walkeros-Client": t4.client } : void 0;
|
|
797
797
|
try {
|
|
798
798
|
if (t4?.baseUrl) {
|
|
799
799
|
const r6 = `${t4.baseUrl}/api/packages/${encodeURIComponent(e4)}?version=${encodeURIComponent(n4)}&expand=all`, o5 = await fetch(r6, { signal: a4, ...s5 && { headers: s5 } });
|
|
800
800
|
if (!o5.ok) throw new Error(`Failed to fetch ${r6} (HTTP ${o5.status})`);
|
|
801
801
|
return (function(e5, t5, n5) {
|
|
802
|
-
const r7 = n5.schemas || {}, o6 = n5.examples || {},
|
|
803
|
-
return { packageName: n5.package || e5, version: "string" == typeof n5.version ? n5.version : t5, ...void 0 !== n5.description && { description: n5.description }, ...void 0 !== n5.type && { type: n5.type }, ...void 0 !== c2 && { platform: c2 }, schemas: r7, examples: o6, ...void 0 !== n5.docs && { docs: n5.docs }, ...void 0 !== n5.source && { source: n5.source }, ...
|
|
802
|
+
const r7 = n5.schemas || {}, o6 = n5.examples || {}, i4 = n5.hints, a5 = n5.hintKeys ?? (i4 ? Object.keys(i4) : []), s6 = n5.exampleSummaries ?? [], c2 = n5.platform;
|
|
803
|
+
return { packageName: n5.package || e5, version: "string" == typeof n5.version ? n5.version : t5, ...void 0 !== n5.description && { description: n5.description }, ...void 0 !== n5.type && { type: n5.type }, ...void 0 !== c2 && { platform: c2 }, schemas: r7, examples: o6, ...void 0 !== n5.docs && { docs: n5.docs }, ...void 0 !== n5.source && { source: n5.source }, ...i4 && Object.keys(i4).length > 0 ? { hints: i4 } : {}, hintKeys: a5, exampleSummaries: s6 };
|
|
804
804
|
})(e4, n4, await o5.json());
|
|
805
805
|
}
|
|
806
|
-
const r5 = `https://cdn.jsdelivr.net/npm/${e4}@${n4}`, o4 = await
|
|
806
|
+
const r5 = `https://cdn.jsdelivr.net/npm/${e4}@${n4}`, o4 = await At(`${r5}/package.json`, a4, s5);
|
|
807
807
|
return (function(e5, t5, n5, r6) {
|
|
808
|
-
const o5 = r6.$meta || {},
|
|
809
|
-
for (const [e6, t6] of Object.entries(
|
|
808
|
+
const o5 = r6.$meta || {}, i4 = r6.schemas || {}, a5 = r6.examples || {}, s6 = r6.hints, c2 = s6 ? Object.keys(s6) : [], l2 = [], u3 = a5.step || {};
|
|
809
|
+
for (const [e6, t6] of Object.entries(u3)) {
|
|
810
810
|
const n6 = t6, r7 = { name: e6 };
|
|
811
811
|
"string" == typeof n6?.description && (r7.description = n6.description), l2.push(r7);
|
|
812
812
|
}
|
|
813
813
|
const f3 = "string" == typeof o5.docs ? o5.docs : void 0, p2 = "string" == typeof o5.source ? o5.source : void 0;
|
|
814
|
-
return { packageName: e5, version: "string" == typeof n5.version ? n5.version : t5, description: "string" == typeof n5.description ? n5.description : void 0, type: "string" == typeof o5.type ? o5.type : void 0, platform:
|
|
815
|
-
})(e4, n4, o4, await
|
|
814
|
+
return { packageName: e5, version: "string" == typeof n5.version ? n5.version : t5, description: "string" == typeof n5.description ? n5.description : void 0, type: "string" == typeof o5.type ? o5.type : void 0, platform: jt(o5.platform), schemas: i4, examples: a5, ...f3 ? { docs: f3 } : {}, ...p2 ? { source: p2 } : {}, ...s6 && Object.keys(s6).length > 0 ? { hints: s6 } : {}, hintKeys: c2, exampleSummaries: l2 };
|
|
815
|
+
})(e4, n4, o4, await At(`${r5}/dist/walkerOS.json`, a4, s5));
|
|
816
816
|
} finally {
|
|
817
|
-
clearTimeout(
|
|
817
|
+
clearTimeout(i3);
|
|
818
818
|
}
|
|
819
819
|
}
|
|
820
|
-
async function
|
|
820
|
+
async function At(e4, t4, n4) {
|
|
821
821
|
const r4 = await fetch(e4, { signal: t4, ...n4 && { headers: n4 } });
|
|
822
822
|
if (!r4.ok) throw new Error(`Failed to fetch ${e4} (HTTP ${r4.status})`);
|
|
823
823
|
return await r4.json();
|
|
824
824
|
}
|
|
825
|
-
async function
|
|
826
|
-
const n4 = await
|
|
825
|
+
async function Ot(e4, t4) {
|
|
826
|
+
const n4 = await xt(e4, t4);
|
|
827
827
|
return { packageName: n4.packageName, version: n4.version, type: n4.type, platform: n4.platform, schemas: n4.schemas, examples: n4.examples, ...n4.hints ? { hints: n4.hints } : {} };
|
|
828
828
|
}
|
|
829
|
-
function
|
|
829
|
+
function Nt(e4) {
|
|
830
830
|
if (void 0 === e4 || "*" === e4) return () => true;
|
|
831
831
|
if ("and" in e4) {
|
|
832
|
-
const t4 = e4.and.map(
|
|
832
|
+
const t4 = e4.and.map(Nt);
|
|
833
833
|
return (e5) => t4.every((t5) => t5(e5));
|
|
834
834
|
}
|
|
835
835
|
if ("or" in e4) {
|
|
836
|
-
const t4 = e4.or.map(
|
|
836
|
+
const t4 = e4.or.map(Nt);
|
|
837
837
|
return (e5) => t4.some((t5) => t5(e5));
|
|
838
838
|
}
|
|
839
839
|
return (function(e5) {
|
|
840
|
-
const { key: t4, operator: n4, value: r4, not: o3 } = e5,
|
|
840
|
+
const { key: t4, operator: n4, value: r4, not: o3 } = e5, i3 = (function(e6, t5) {
|
|
841
841
|
switch (e6) {
|
|
842
842
|
case "eq":
|
|
843
843
|
return (e7) => String(e7 ?? "") === t5;
|
|
@@ -864,74 +864,75 @@ function Et(e4) {
|
|
|
864
864
|
}
|
|
865
865
|
})(n4, r4);
|
|
866
866
|
return (e6) => {
|
|
867
|
-
const n5 =
|
|
867
|
+
const n5 = ge(e6, t4), r5 = i3(n5);
|
|
868
868
|
return o3 ? !r5 : r5;
|
|
869
869
|
};
|
|
870
870
|
})(e4);
|
|
871
871
|
}
|
|
872
|
-
function
|
|
873
|
-
return Array.isArray(e4) && e4
|
|
874
|
-
return "object" == typeof e6 && null !== e6 && !Array.isArray(e6) && ("match" in e6 || "next" in e6 || "one" in e6 || "many" in e6);
|
|
875
|
-
})(e5));
|
|
872
|
+
function Tt(e4) {
|
|
873
|
+
return "object" == typeof e4 && null !== e4 && !Array.isArray(e4) && ("match" in e4 || "next" in e4 || "one" in e4 || "many" in e4);
|
|
876
874
|
}
|
|
877
|
-
function
|
|
875
|
+
function Ct(e4) {
|
|
876
|
+
return Array.isArray(e4) && e4.length > 0 && e4.every((e5) => Tt(e5));
|
|
877
|
+
}
|
|
878
|
+
function It(e4) {
|
|
878
879
|
return e4.map((e5) => {
|
|
879
880
|
if ("string" == typeof e5) return { match: () => true, next: { type: "static", value: e5 } };
|
|
880
|
-
if (Array.isArray(e5)) return { match: () => true, next:
|
|
881
|
+
if (Array.isArray(e5)) return { match: () => true, next: zt(e5) ?? { type: "chain", value: [] } };
|
|
881
882
|
const t4 = e5;
|
|
882
|
-
return { match: t4.match ?
|
|
883
|
+
return { match: t4.match ? Nt(t4.match) : () => true, next: zt(t4) ?? { type: "chain", value: [] } };
|
|
883
884
|
});
|
|
884
885
|
}
|
|
885
|
-
function
|
|
886
|
+
function zt(e4) {
|
|
886
887
|
if (null == e4) return;
|
|
887
888
|
if ("string" == typeof e4) return { type: "static", value: e4 };
|
|
888
889
|
if (Array.isArray(e4)) {
|
|
889
890
|
if (0 === e4.length) return;
|
|
890
|
-
if (
|
|
891
|
+
if (Ct(e4)) return zt({ one: e4 });
|
|
891
892
|
if (e4.every((e5) => "string" == typeof e5)) return { type: "chain", value: e4 };
|
|
892
893
|
const t5 = [];
|
|
893
894
|
for (const n4 of e4) {
|
|
894
|
-
const e5 =
|
|
895
|
+
const e5 = zt(n4);
|
|
895
896
|
void 0 !== e5 && t5.push(e5);
|
|
896
897
|
}
|
|
897
898
|
if (0 === t5.length) return;
|
|
898
899
|
return { type: "sequence", value: t5 };
|
|
899
900
|
}
|
|
900
901
|
const t4 = e4;
|
|
901
|
-
if ("next" in t4 && void 0 !== t4.next) return t4.match ? { type: "gate", match:
|
|
902
|
+
if ("next" in t4 && void 0 !== t4.next) return t4.match ? { type: "gate", match: Nt(t4.match), next: zt(t4.next) } : zt(t4.next);
|
|
902
903
|
if ("one" in t4 && t4.one) {
|
|
903
|
-
const e5 =
|
|
904
|
-
return t4.match ? { type: "gate", match:
|
|
904
|
+
const e5 = It(t4.one);
|
|
905
|
+
return t4.match ? { type: "gate", match: Nt(t4.match), next: { type: "one", routes: e5 } } : { type: "one", routes: e5 };
|
|
905
906
|
}
|
|
906
907
|
if ("many" in t4 && t4.many) {
|
|
907
|
-
const e5 =
|
|
908
|
-
return t4.match ? { type: "gate", match:
|
|
908
|
+
const e5 = It(t4.many);
|
|
909
|
+
return t4.match ? { type: "gate", match: Nt(t4.match), next: { type: "many", routes: e5 } } : { type: "many", routes: e5 };
|
|
909
910
|
}
|
|
910
|
-
return t4.match ? { type: "gate", match:
|
|
911
|
+
return t4.match ? { type: "gate", match: Nt(t4.match) } : void 0;
|
|
911
912
|
}
|
|
912
|
-
function
|
|
913
|
+
function Mt(e4, t4 = {}) {
|
|
913
914
|
if (null == e4) return [];
|
|
914
915
|
let n4;
|
|
915
916
|
if ("object" == typeof e4) {
|
|
916
|
-
const t5 =
|
|
917
|
-
t5 ? n4 = t5 : (n4 =
|
|
918
|
-
} else n4 =
|
|
917
|
+
const t5 = Pt.get(e4);
|
|
918
|
+
t5 ? n4 = t5 : (n4 = zt(e4), n4 && Pt.set(e4, n4));
|
|
919
|
+
} else n4 = zt(e4);
|
|
919
920
|
if (!n4) return [];
|
|
920
|
-
const r4 =
|
|
921
|
+
const r4 = Rt(n4, t4);
|
|
921
922
|
return void 0 === r4 ? [] : Array.isArray(r4) ? r4 : [r4];
|
|
922
923
|
}
|
|
923
|
-
function
|
|
924
|
+
function Rt(e4, t4 = {}) {
|
|
924
925
|
if (e4) {
|
|
925
926
|
if ("static" === e4.type) return e4.value;
|
|
926
927
|
if ("chain" === e4.type) return e4.value;
|
|
927
928
|
if ("gate" === e4.type) {
|
|
928
929
|
if (!e4.match(t4)) return;
|
|
929
|
-
return
|
|
930
|
+
return Rt(e4.next, t4);
|
|
930
931
|
}
|
|
931
932
|
if ("sequence" === e4.type) {
|
|
932
933
|
const n4 = [];
|
|
933
934
|
for (const r4 of e4.value) {
|
|
934
|
-
const e5 =
|
|
935
|
+
const e5 = Rt(r4, t4);
|
|
935
936
|
void 0 !== e5 && (Array.isArray(e5) ? n4.push(...e5) : n4.push(e5));
|
|
936
937
|
}
|
|
937
938
|
return n4.length > 0 ? n4 : void 0;
|
|
@@ -940,52 +941,80 @@ function zt(e4, t4 = {}) {
|
|
|
940
941
|
const n4 = [];
|
|
941
942
|
for (const r4 of e4.routes) {
|
|
942
943
|
if (!r4.match(t4)) continue;
|
|
943
|
-
const e5 =
|
|
944
|
+
const e5 = Rt(r4.next, t4);
|
|
944
945
|
void 0 !== e5 && (Array.isArray(e5) ? n4.push(...e5) : n4.push(e5));
|
|
945
946
|
}
|
|
946
947
|
return n4.length > 0 ? n4 : void 0;
|
|
947
948
|
}
|
|
948
|
-
for (const n4 of e4.routes) if (n4.match(t4)) return
|
|
949
|
+
for (const n4 of e4.routes) if (n4.match(t4)) return Rt(n4.next, t4);
|
|
949
950
|
}
|
|
950
951
|
}
|
|
951
|
-
function
|
|
952
|
+
function Dt(e4, t4) {
|
|
952
953
|
const n4 = { ingest: e4 ?? {} };
|
|
953
954
|
return void 0 !== t4 && (n4.event = t4), n4;
|
|
954
955
|
}
|
|
955
|
-
function
|
|
956
|
-
return { stop: e4.stop ?? false, storeId: e4.store, namespace: e4.namespace, rules: e4.rules.map((e5) => ({ match: e5.match ?
|
|
956
|
+
function Ft(e4) {
|
|
957
|
+
return { stop: e4.stop ?? false, storeId: e4.store, namespace: e4.namespace, rules: e4.rules.map((e5) => ({ match: e5.match ? Nt(e5.match) : () => true, key: e5.key, ttl: e5.ttl, update: e5.update })) };
|
|
957
958
|
}
|
|
958
|
-
async function
|
|
959
|
+
async function Ut(e4, t4, n4, r4) {
|
|
959
960
|
const o3 = e4.rules.find((e5) => e5.match(n4));
|
|
960
961
|
if (!o3) return null;
|
|
961
|
-
const
|
|
962
|
-
if (
|
|
963
|
-
const a4 =
|
|
962
|
+
const i3 = o3.key.map((e5) => String(ge(n4, e5) ?? ""));
|
|
963
|
+
if (i3.every((e5) => "" === e5)) return null;
|
|
964
|
+
const a4 = i3.join(":"), s5 = r4 ?? e4.namespace, c2 = s5 ? `${s5}:${a4}` : a4, l2 = await t4.get(c2);
|
|
964
965
|
return void 0 !== l2 ? { status: "HIT", key: c2, value: l2, rule: o3 } : { status: "MISS", key: c2, rule: o3 };
|
|
965
966
|
}
|
|
966
|
-
function
|
|
967
|
+
function Zt(e4, t4, n4, r4) {
|
|
967
968
|
e4.set(t4, n4, 1e3 * r4);
|
|
968
969
|
}
|
|
969
|
-
async function
|
|
970
|
+
async function Wt(e4, t4, n4, r4) {
|
|
970
971
|
if (!t4) return e4;
|
|
971
972
|
let o3 = e4;
|
|
972
|
-
for (const [e5,
|
|
973
|
-
o3 =
|
|
973
|
+
for (const [e5, i3] of Object.entries(t4)) {
|
|
974
|
+
o3 = ye(o3, e5, await Ke(n4, i3, { collector: r4 }));
|
|
974
975
|
}
|
|
975
976
|
return o3;
|
|
976
977
|
}
|
|
977
|
-
function
|
|
978
|
+
function Ht(e4) {
|
|
979
|
+
return oe(e4) ? e4 : [e4];
|
|
980
|
+
}
|
|
981
|
+
async function Lt(e4, t4, n4, r4) {
|
|
982
|
+
let o3 = n4;
|
|
983
|
+
for (const n5 of e4) await We(async () => {
|
|
984
|
+
const e5 = t4(n5.store);
|
|
985
|
+
if (!e5) return;
|
|
986
|
+
const i3 = await Ke(o3, n5.key, { collector: r4, event: o3 });
|
|
987
|
+
if (!de(i3)) return;
|
|
988
|
+
const a4 = n5.store ? i3 : `state:${i3}`;
|
|
989
|
+
if ("set" === n5.mode) {
|
|
990
|
+
const t5 = await Ke(o3, n5.value, { collector: r4, event: o3 });
|
|
991
|
+
if (!se(t5)) return;
|
|
992
|
+
await e5.set(a4, t5);
|
|
993
|
+
} else {
|
|
994
|
+
const t5 = de(s5 = n5.value) ? s5 : fe(s5) && de(s5.key) ? s5.key : void 0;
|
|
995
|
+
if (!t5) return;
|
|
996
|
+
const r5 = await e5.get(a4);
|
|
997
|
+
if (!se(r5)) return;
|
|
998
|
+
o3 = ye(o3, t5, r5);
|
|
999
|
+
}
|
|
1000
|
+
var s5;
|
|
1001
|
+
}, (e5) => {
|
|
1002
|
+
r4.logger?.error?.("[state] operation failed", e5);
|
|
1003
|
+
})();
|
|
1004
|
+
return o3;
|
|
1005
|
+
}
|
|
1006
|
+
function Jt(e4, t4) {
|
|
978
1007
|
const n4 = (function(e5) {
|
|
979
|
-
return /* @__PURE__ */ new Set([...
|
|
1008
|
+
return /* @__PURE__ */ new Set([...Kt[e5], ...Vt, ...qt[e5]]);
|
|
980
1009
|
})(t4);
|
|
981
1010
|
for (const r5 of Object.keys(e4)) if (!n4.has(r5)) return { ok: false, code: "UNKNOWN_KEY", key: r5, reason: `Unknown key "${r5}" on ${t4}. Allowed: ${[...n4].sort().join(", ")}.` };
|
|
982
|
-
const r4 = void 0 !== e4.package, o3 = void 0 !== e4.import,
|
|
983
|
-
return
|
|
1011
|
+
const r4 = void 0 !== e4.package, o3 = void 0 !== e4.import, i3 = void 0 !== e4.code;
|
|
1012
|
+
return i3 && "string" == typeof e4.code ? { ok: false, code: "OBSOLETE_CODE_STRING", key: "code", reason: `code: "<name>" is no longer supported. Use import: "${e4.code}" with the package field instead.` } : i3 && ("object" != typeof e4.code && "function" != typeof e4.code || null === e4.code || Array.isArray(e4.code)) ? { ok: false, code: "INVALID_CODE_SHAPE", key: "code", reason: "code must be an object ({ push, type?, init? }) or a resolved function value." } : i3 && r4 ? { ok: false, code: "CONFLICT", key: "package", reason: "Cannot specify both `code` and `package`. Use one or the other." } : i3 && o3 ? { ok: false, code: "CONFLICT", key: "import", reason: "Cannot specify both `code` and `import`." } : o3 && !r4 ? { ok: false, code: "MISSING_PACKAGE", key: "import", reason: "`import` requires `package` to be set." } : !o3 || "string" == typeof e4.import && Bt.test(e4.import) ? { ok: true } : { ok: false, code: "INVALID_IMPORT", key: "import", reason: `import must match ${Bt.source}. Got: ${JSON.stringify(e4.import)}.` };
|
|
984
1013
|
}
|
|
985
|
-
function
|
|
986
|
-
return "Transformer" === t4 && (void 0 === e4.code && void 0 === e4.package && void 0 === e4.import && (void 0 !== e4.before || void 0 !== e4.next || void 0 !== e4.cache || void 0 !== e4.mapping));
|
|
1014
|
+
function Gt(e4, t4) {
|
|
1015
|
+
return "Transformer" === t4 && (void 0 === e4.code && void 0 === e4.package && void 0 === e4.import && (void 0 !== e4.before || void 0 !== e4.next || void 0 !== e4.cache || void 0 !== e4.state || void 0 !== e4.mapping));
|
|
987
1016
|
}
|
|
988
|
-
var e, t, r, a, u, f, m, h, b, C, R, D, F, U, Z,
|
|
1017
|
+
var e, t, r, a, u, f, m, h, b, C, R, D, F, U, Z, B, te, ve, Pe, He, Pt, Kt, Vt, qt, Bt;
|
|
989
1018
|
var init_dist = __esm({
|
|
990
1019
|
"../core/dist/index.mjs"() {
|
|
991
1020
|
"use strict";
|
|
@@ -1012,23 +1041,23 @@ var init_dist = __esm({
|
|
|
1012
1041
|
F = /\$env\.([a-zA-Z_][a-zA-Z0-9_]*)(?::([^"}\s]*))?/g;
|
|
1013
1042
|
U = /^\$contract\.([a-zA-Z_][a-zA-Z0-9_]*)(?:\.(.+))?$/;
|
|
1014
1043
|
Z = /^\$flow\.([a-zA-Z_][a-zA-Z0-9_]*)(?:\.([a-zA-Z0-9_.]+))?$/;
|
|
1015
|
-
|
|
1016
|
-
|
|
1017
|
-
|
|
1018
|
-
|
|
1019
|
-
const o3 = `${f[e4]}${r4.length > 0 ? ` [${r4.join(":")}]` : ""}`,
|
|
1020
|
-
|
|
1044
|
+
B = "__WALKEROS_ENV:";
|
|
1045
|
+
te = { merge: true, shallow: true, extend: true };
|
|
1046
|
+
ve = { data: (e4) => e4.data, globals: (e4) => e4.globals, context: (e4) => e4.context, user: (e4) => e4.user, source: (e4) => e4.source, event: (e4) => ({ entity: e4.entity, action: e4.action, id: e4.id, timestamp: e4.timestamp, name: e4.name, trigger: e4.trigger, timing: e4.timing }) };
|
|
1047
|
+
Pe = (e4, t4, n4, r4) => {
|
|
1048
|
+
const o3 = `${f[e4]}${r4.length > 0 ? ` [${r4.join(":")}]` : ""}`, i3 = Object.keys(n4).length > 0, a4 = 0 === e4 ? console.error : 1 === e4 ? console.warn : console.log;
|
|
1049
|
+
i3 ? a4(o3, t4, n4) : a4(o3, t4);
|
|
1021
1050
|
};
|
|
1022
|
-
|
|
1051
|
+
He = class e2 extends Error {
|
|
1023
1052
|
constructor(t4, n4) {
|
|
1024
1053
|
super(t4, n4), this.name = "FatalError", Object.setPrototypeOf(this, e2.prototype);
|
|
1025
1054
|
}
|
|
1026
1055
|
};
|
|
1027
|
-
|
|
1028
|
-
|
|
1029
|
-
|
|
1030
|
-
|
|
1031
|
-
|
|
1056
|
+
Pt = /* @__PURE__ */ new WeakMap();
|
|
1057
|
+
Kt = { Source: ["code", "package", "import", "before", "next", "cache", "state"], Transformer: ["code", "package", "import", "before", "next", "cache", "state", "mapping"], Destination: ["code", "package", "import", "before", "next", "cache", "state"], Store: ["code", "package", "import", "cache"] };
|
|
1058
|
+
Vt = ["config", "env", "validate", "variables", "examples", "disabled", "id", "logger", "mock", "chainMocks"];
|
|
1059
|
+
qt = { Source: ["primary"], Transformer: [], Destination: [], Store: [] };
|
|
1060
|
+
Bt = /^[A-Za-z_$][A-Za-z0-9_$]*$/;
|
|
1032
1061
|
}
|
|
1033
1062
|
});
|
|
1034
1063
|
|
|
@@ -1036,15 +1065,15 @@ var init_dist = __esm({
|
|
|
1036
1065
|
import * as r2 from "http";
|
|
1037
1066
|
import * as s3 from "https";
|
|
1038
1067
|
import { createHash as n2 } from "crypto";
|
|
1039
|
-
function a2(a4, n4,
|
|
1040
|
-
const
|
|
1068
|
+
function a2(a4, n4, i3 = {}) {
|
|
1069
|
+
const u3 = rt(i3.headers), c2 = nt(n4), m3 = i3.method || "POST", d2 = i3.timeout || 5e3;
|
|
1041
1070
|
return new Promise((t4) => {
|
|
1042
|
-
const e4 = new URL(a4), n5 = "https:" === e4.protocol ? s3 : r2,
|
|
1071
|
+
const e4 = new URL(a4), n5 = "https:" === e4.protocol ? s3 : r2, i4 = { method: m3, headers: u3 }, p2 = n5.request(e4, i4, (e5) => {
|
|
1043
1072
|
const r4 = [];
|
|
1044
1073
|
e5.on("data", (t5) => {
|
|
1045
1074
|
r4.push(t5);
|
|
1046
1075
|
}), e5.on("end", () => {
|
|
1047
|
-
const s5 = !!(e5.statusCode && e5.statusCode >= 200 && e5.statusCode < 300), a5 = Buffer.concat(r4).toString(), n6 =
|
|
1076
|
+
const s5 = !!(e5.statusCode && e5.statusCode >= 200 && e5.statusCode < 300), a5 = Buffer.concat(r4).toString(), n6 = Ze(JSON.parse, () => a5)(a5);
|
|
1048
1077
|
t4({ ok: s5, data: n6, error: s5 ? void 0 : `${e5.statusCode} ${e5.statusMessage}` });
|
|
1049
1078
|
});
|
|
1050
1079
|
});
|
|
@@ -1052,14 +1081,15 @@ function a2(a4, n4, u4 = {}) {
|
|
|
1052
1081
|
t4({ ok: false, error: e5.message });
|
|
1053
1082
|
}), p2.on("timeout", () => {
|
|
1054
1083
|
p2.destroy(), t4({ ok: false, error: "Request timeout" });
|
|
1055
|
-
}), p2.setTimeout(
|
|
1084
|
+
}), p2.setTimeout(d2), c2 && p2.write(c2), p2.end();
|
|
1056
1085
|
});
|
|
1057
1086
|
}
|
|
1058
|
-
async function
|
|
1059
|
-
|
|
1060
|
-
|
|
1061
|
-
|
|
1062
|
-
|
|
1087
|
+
async function i(t4, e4, o3 = {}) {
|
|
1088
|
+
const r4 = o3.algorithm ?? "sha256";
|
|
1089
|
+
return (await (async function(t5, e5) {
|
|
1090
|
+
const o4 = n2(e5);
|
|
1091
|
+
return o4.update(t5), o4.digest("hex");
|
|
1092
|
+
})(t4, r4)).slice(0, e4);
|
|
1063
1093
|
}
|
|
1064
1094
|
var init_dist2 = __esm({
|
|
1065
1095
|
"../server/core/dist/index.mjs"() {
|
|
@@ -1150,7 +1180,7 @@ function createCLILogger(options = {}) {
|
|
|
1150
1180
|
stderr = false
|
|
1151
1181
|
} = options;
|
|
1152
1182
|
const out = stderr ? console.error : console.log;
|
|
1153
|
-
return
|
|
1183
|
+
return Me({
|
|
1154
1184
|
// Let handler control visibility — pass everything through
|
|
1155
1185
|
level: f.DEBUG,
|
|
1156
1186
|
handler: (level, message, _context, scope) => {
|
|
@@ -1647,9 +1677,9 @@ var init_sse = __esm({
|
|
|
1647
1677
|
|
|
1648
1678
|
// ../core/dist/dev.mjs
|
|
1649
1679
|
import { z as n3 } from "zod";
|
|
1650
|
-
import { z as
|
|
1651
|
-
function o2(e4, t4,
|
|
1652
|
-
return n3.toJSONSchema(e4, { target:
|
|
1680
|
+
import { z as en } from "zod";
|
|
1681
|
+
function o2(e4, t4, i3 = "draft-7") {
|
|
1682
|
+
return n3.toJSONSchema(e4, { target: i3 });
|
|
1653
1683
|
}
|
|
1654
1684
|
function R2(e4, t4) {
|
|
1655
1685
|
return n3.object({ data: n3.union([e4, t4]).optional().describe("Data transformation rules") }).partial();
|
|
@@ -1657,81 +1687,81 @@ function R2(e4, t4) {
|
|
|
1657
1687
|
function M2(e4) {
|
|
1658
1688
|
return n3.object({ mapping: e4.optional().describe("Event mapping rules") }).partial();
|
|
1659
1689
|
}
|
|
1660
|
-
function
|
|
1690
|
+
function F2(e4) {
|
|
1661
1691
|
return n3.object({ policy: e4.optional().describe("Pre-processing policy rules") }).partial();
|
|
1662
1692
|
}
|
|
1663
|
-
function
|
|
1693
|
+
function T2(e4) {
|
|
1664
1694
|
return n3.object({ consent: e4.optional().describe("Required consent states") }).partial();
|
|
1665
1695
|
}
|
|
1666
|
-
function
|
|
1696
|
+
function ji(e4, t4) {
|
|
1667
1697
|
void 0 !== e4.import && (void 0 !== e4.code && t4.addIssue({ code: "custom", message: "`import` cannot be combined with inline `code`", path: ["import"] }), void 0 === e4.package && t4.addIssue({ code: "custom", message: "`import` requires `package`", path: ["import"] }));
|
|
1668
1698
|
}
|
|
1669
|
-
function $i(e4) {
|
|
1670
|
-
return Li.parse(e4);
|
|
1671
|
-
}
|
|
1672
1699
|
function qi(e4) {
|
|
1673
|
-
return
|
|
1700
|
+
return $i.parse(e4);
|
|
1701
|
+
}
|
|
1702
|
+
function Ai(e4) {
|
|
1703
|
+
return $i.safeParse(e4);
|
|
1674
1704
|
}
|
|
1675
1705
|
function Ni(e4) {
|
|
1676
|
-
return
|
|
1706
|
+
return Li.parse(e4);
|
|
1677
1707
|
}
|
|
1678
|
-
function
|
|
1679
|
-
return
|
|
1708
|
+
function Wi(e4) {
|
|
1709
|
+
return Li.safeParse(e4);
|
|
1680
1710
|
}
|
|
1681
|
-
function
|
|
1711
|
+
function an(e4) {
|
|
1682
1712
|
let t4;
|
|
1683
1713
|
try {
|
|
1684
1714
|
t4 = JSON.parse(e4);
|
|
1685
1715
|
} catch (t5) {
|
|
1686
|
-
const { line:
|
|
1716
|
+
const { line: i4, column: n5 } = (function(e5, t6) {
|
|
1687
1717
|
if (e5 instanceof SyntaxError) {
|
|
1688
|
-
const
|
|
1689
|
-
if (
|
|
1690
|
-
return
|
|
1718
|
+
const i5 = e5.message.match(/position\s+(\d+)/);
|
|
1719
|
+
if (i5) {
|
|
1720
|
+
return pn(t6, parseInt(i5[1], 10));
|
|
1691
1721
|
}
|
|
1692
1722
|
const n6 = e5.message.match(/line\s+(\d+)\s+column\s+(\d+)/);
|
|
1693
1723
|
if (n6) return { line: parseInt(n6[1], 10), column: parseInt(n6[2], 10) };
|
|
1694
1724
|
}
|
|
1695
1725
|
return { line: 1, column: 1 };
|
|
1696
1726
|
})(t5, e4);
|
|
1697
|
-
return { valid: false, errors: [{ message: t5 instanceof Error ? t5.message : "Invalid JSON", severity: "error", line:
|
|
1727
|
+
return { valid: false, errors: [{ message: t5 instanceof Error ? t5.message : "Invalid JSON", severity: "error", line: i4, column: n5 }], warnings: [] };
|
|
1698
1728
|
}
|
|
1699
|
-
const
|
|
1729
|
+
const i3 = [], n4 = [], o3 = $i.safeParse(t4);
|
|
1700
1730
|
if (!o3.success) for (const t5 of o3.error.issues) {
|
|
1701
|
-
const n5 = t5.path.join("."), o4 =
|
|
1702
|
-
|
|
1731
|
+
const n5 = t5.path.join("."), o4 = mn(e4, t5.path);
|
|
1732
|
+
i3.push({ message: t5.message, severity: "error", path: n5 || "root", ...o4 });
|
|
1703
1733
|
}
|
|
1704
1734
|
const r4 = (function(e5) {
|
|
1705
|
-
if (!(
|
|
1706
|
-
const t5 = {},
|
|
1735
|
+
if (!(fn(e5) && "version" in e5 && "flows" in e5 && fn(e5.flows))) return;
|
|
1736
|
+
const t5 = {}, i4 = [], n5 = [], o4 = [], r5 = [], a4 = [], s5 = [];
|
|
1707
1737
|
let c2;
|
|
1708
1738
|
const l2 = Object.keys(e5.flows);
|
|
1709
|
-
|
|
1710
|
-
if (!
|
|
1711
|
-
for (const [,
|
|
1712
|
-
if (!
|
|
1713
|
-
const t7 =
|
|
1714
|
-
if (
|
|
1715
|
-
if (!
|
|
1716
|
-
const t8 = e6.find((e7) => e7.entity ===
|
|
1739
|
+
gn(t5, e5.variables), (function(e6, t6) {
|
|
1740
|
+
if (!fn(t6)) return;
|
|
1741
|
+
for (const [, i5] of Object.entries(t6)) {
|
|
1742
|
+
if (!fn(i5)) continue;
|
|
1743
|
+
const t7 = i5.events;
|
|
1744
|
+
if (fn(t7)) for (const [i6, n6] of Object.entries(t7)) {
|
|
1745
|
+
if (!fn(n6)) continue;
|
|
1746
|
+
const t8 = e6.find((e7) => e7.entity === i6), o5 = Object.keys(n6);
|
|
1717
1747
|
if (t8) for (const e7 of o5) t8.actions.includes(e7) || t8.actions.push(e7);
|
|
1718
|
-
else e6.push({ entity:
|
|
1748
|
+
else e6.push({ entity: i6, actions: o5 });
|
|
1719
1749
|
}
|
|
1720
1750
|
}
|
|
1721
1751
|
})(s5, e5.contract);
|
|
1722
|
-
for (const s6 of Object.values(e5.flows)) if (
|
|
1752
|
+
for (const s6 of Object.values(e5.flows)) if (fn(s6)) {
|
|
1723
1753
|
if (!c2) {
|
|
1724
1754
|
const e6 = s6.config;
|
|
1725
|
-
!
|
|
1755
|
+
!fn(e6) || "web" !== e6.platform && "server" !== e6.platform || (c2 = e6.platform);
|
|
1726
1756
|
}
|
|
1727
|
-
|
|
1757
|
+
gn(t5, s6.variables);
|
|
1728
1758
|
for (const e6 of ["sources", "destinations", "transformers"]) {
|
|
1729
|
-
const r6 = "sources" === e6 ? "source" : "destinations" === e6 ? "destination" : "transformer", l3 = "sources" === e6 ?
|
|
1730
|
-
if (
|
|
1759
|
+
const r6 = "sources" === e6 ? "source" : "destinations" === e6 ? "destination" : "transformer", l3 = "sources" === e6 ? i4 : "destinations" === e6 ? n5 : o4;
|
|
1760
|
+
if (fn(s6[e6])) for (const [i5, n6] of Object.entries(s6[e6])) l3.push(i5), fn(n6) && (gn(t5, n6.variables), "string" == typeof n6.package && a4.push({ package: n6.package, shortName: i5, type: r6, platform: c2 || "web" }));
|
|
1731
1761
|
}
|
|
1732
|
-
if (
|
|
1762
|
+
if (fn(s6.stores)) for (const [e6, i5] of Object.entries(s6.stores)) r5.push(e6), fn(i5) && gn(t5, i5.variables);
|
|
1733
1763
|
}
|
|
1734
|
-
const d2 = { variables: t5, stepNames: { sources:
|
|
1764
|
+
const d2 = { variables: t5, stepNames: { sources: i4, destinations: n5, transformers: o4, stores: r5 }, flowNames: l2 };
|
|
1735
1765
|
c2 && (d2.platform = c2);
|
|
1736
1766
|
a4.length > 0 && (d2.packages = a4);
|
|
1737
1767
|
s5.length > 0 && (d2.contract = s5);
|
|
@@ -1739,138 +1769,138 @@ function rn(e4) {
|
|
|
1739
1769
|
})(t4);
|
|
1740
1770
|
if (r4) {
|
|
1741
1771
|
const t5 = (function(e5, t6) {
|
|
1742
|
-
const
|
|
1743
|
-
return (function(e6, t7,
|
|
1772
|
+
const i4 = [];
|
|
1773
|
+
return (function(e6, t7, i5) {
|
|
1744
1774
|
let n5;
|
|
1745
|
-
|
|
1746
|
-
for (; null !== (n5 =
|
|
1747
|
-
const t8 = n5[0], o4 = n5[1], r5 = n5[2], a4 =
|
|
1748
|
-
|
|
1775
|
+
dn.lastIndex = 0;
|
|
1776
|
+
for (; null !== (n5 = dn.exec(e6)); ) {
|
|
1777
|
+
const t8 = n5[0], o4 = n5[1], r5 = n5[2], a4 = un(e6, n5.index, t8.length);
|
|
1778
|
+
i5.push({ message: `Malformed reference "${t8}", use a dot, not a colon: "$${o4}.${r5}".`, severity: "warning", path: t8, ...a4 });
|
|
1749
1779
|
}
|
|
1750
|
-
})(e5, 0,
|
|
1780
|
+
})(e5, 0, i4), (function(e6, t7, i5) {
|
|
1751
1781
|
if (!t7.variables) return;
|
|
1752
1782
|
const n5 = /\$var\.(\w+)/g;
|
|
1753
1783
|
let o4;
|
|
1754
1784
|
for (; null !== (o4 = n5.exec(e6)); ) if (!(o4[1] in t7.variables)) {
|
|
1755
|
-
const n6 =
|
|
1756
|
-
|
|
1785
|
+
const n6 = un(e6, o4.index, o4[0].length);
|
|
1786
|
+
i5.push({ message: `Unknown variable "$var.${o4[1]}". Defined: ${Object.keys(t7.variables).join(", ") || "none"}`, severity: "warning", path: `$var.${o4[1]}`, ...n6 });
|
|
1757
1787
|
}
|
|
1758
|
-
})(e5, t6,
|
|
1788
|
+
})(e5, t6, i4), (function(e6, t7, i5) {
|
|
1759
1789
|
const n5 = t7.stepNames?.stores ?? [];
|
|
1760
1790
|
let o4;
|
|
1761
|
-
|
|
1762
|
-
for (; null !== (o4 =
|
|
1763
|
-
const t8 =
|
|
1764
|
-
|
|
1791
|
+
sn.lastIndex = 0;
|
|
1792
|
+
for (; null !== (o4 = sn.exec(e6)); ) if (!n5.includes(o4[1])) {
|
|
1793
|
+
const t8 = un(e6, o4.index, o4[0].length);
|
|
1794
|
+
i5.push({ message: `Unknown store "$store.${o4[1]}". Defined: ${n5.join(", ") || "none"}`, severity: "warning", path: `$store.${o4[1]}`, ...t8 });
|
|
1765
1795
|
}
|
|
1766
|
-
})(e5, t6,
|
|
1796
|
+
})(e5, t6, i4), (function(e6, t7, i5) {
|
|
1767
1797
|
let n5;
|
|
1768
|
-
|
|
1769
|
-
for (; null !== (n5 =
|
|
1770
|
-
const t8 = n5[0], o4 = n5[1], r5 = n5[2], a4 =
|
|
1771
|
-
r5 ?
|
|
1798
|
+
cn.lastIndex = 0;
|
|
1799
|
+
for (; null !== (n5 = cn.exec(e6)); ) {
|
|
1800
|
+
const t8 = n5[0], o4 = n5[1], r5 = n5[2], a4 = un(e6, n5.index, t8.length);
|
|
1801
|
+
r5 ? i5.push({ message: `Malformed $env reference "${t8}". Use ":" for default values, not "=" (e.g., "$env.${o4}:fallback").`, severity: "warning", path: t8, ...a4 }) : /^[A-Z][A-Z0-9_]*$/.test(o4) || i5.push({ message: `$env.${o4} should use UPPER_SNAKE_CASE by convention (e.g., $env.${o4.toUpperCase()}).`, severity: "warning", path: t8, ...a4 });
|
|
1772
1802
|
}
|
|
1773
|
-
})(e5, 0,
|
|
1803
|
+
})(e5, 0, i4), (function(e6, t7, i5) {
|
|
1774
1804
|
const n5 = t7.flowNames ?? [];
|
|
1775
1805
|
if (0 === n5.length) return;
|
|
1776
1806
|
let o4;
|
|
1777
|
-
|
|
1778
|
-
for (; null !== (o4 =
|
|
1807
|
+
ln.lastIndex = 0;
|
|
1808
|
+
for (; null !== (o4 = ln.exec(e6)); ) {
|
|
1779
1809
|
const t8 = o4[0], r5 = o4[1];
|
|
1780
1810
|
if (!n5.includes(r5)) {
|
|
1781
|
-
const a4 =
|
|
1782
|
-
|
|
1811
|
+
const a4 = un(e6, o4.index, t8.length);
|
|
1812
|
+
i5.push({ message: `Unknown flow "$flow.${r5}". Defined: ${n5.join(", ")}`, severity: "warning", path: t8, ...a4 });
|
|
1783
1813
|
}
|
|
1784
1814
|
}
|
|
1785
|
-
})(e5, t6,
|
|
1815
|
+
})(e5, t6, i4), i4;
|
|
1786
1816
|
})(e4, r4);
|
|
1787
1817
|
n4.push(...t5);
|
|
1788
1818
|
}
|
|
1789
|
-
return { valid: 0 ===
|
|
1819
|
+
return { valid: 0 === i3.length, errors: i3, warnings: n4, context: r4 };
|
|
1790
1820
|
}
|
|
1791
|
-
function
|
|
1792
|
-
let
|
|
1793
|
-
for (let o3 = 0; o3 < t4 && o3 < e4.length; o3++) "\n" === e4[o3] ? (
|
|
1794
|
-
return { line:
|
|
1821
|
+
function pn(e4, t4) {
|
|
1822
|
+
let i3 = 1, n4 = 1;
|
|
1823
|
+
for (let o3 = 0; o3 < t4 && o3 < e4.length; o3++) "\n" === e4[o3] ? (i3++, n4 = 1) : n4++;
|
|
1824
|
+
return { line: i3, column: n4 };
|
|
1795
1825
|
}
|
|
1796
|
-
function
|
|
1797
|
-
const n4 =
|
|
1826
|
+
function un(e4, t4, i3) {
|
|
1827
|
+
const n4 = pn(e4, t4), o3 = pn(e4, t4 + i3);
|
|
1798
1828
|
return { line: n4.line, column: n4.column, endLine: o3.line, endColumn: o3.column };
|
|
1799
1829
|
}
|
|
1800
|
-
function
|
|
1830
|
+
function mn(e4, t4) {
|
|
1801
1831
|
if (0 === t4.length) return { line: 1, column: 1 };
|
|
1802
|
-
const
|
|
1803
|
-
if ("string" == typeof
|
|
1804
|
-
const t5 = `"${
|
|
1805
|
-
if (-1 !== n4) return
|
|
1832
|
+
const i3 = t4[t4.length - 1];
|
|
1833
|
+
if ("string" == typeof i3) {
|
|
1834
|
+
const t5 = `"${i3}"`, n4 = e4.lastIndexOf(t5);
|
|
1835
|
+
if (-1 !== n4) return pn(e4, n4);
|
|
1806
1836
|
}
|
|
1807
1837
|
return { line: 1, column: 1 };
|
|
1808
1838
|
}
|
|
1809
|
-
function
|
|
1839
|
+
function fn(e4) {
|
|
1810
1840
|
return "object" == typeof e4 && null !== e4 && !Array.isArray(e4);
|
|
1811
1841
|
}
|
|
1812
|
-
function fn(e4, t4) {
|
|
1813
|
-
if (mn(t4)) for (const [i2, n4] of Object.entries(t4)) e4[i2] = n4;
|
|
1814
|
-
}
|
|
1815
1842
|
function gn(e4, t4) {
|
|
1816
|
-
|
|
1843
|
+
if (fn(t4)) for (const [i3, n4] of Object.entries(t4)) e4[i3] = n4;
|
|
1844
|
+
}
|
|
1845
|
+
function hn(e4, t4) {
|
|
1846
|
+
const i3 = [], n4 = {};
|
|
1817
1847
|
for (const [t5, o4] of Object.entries(e4)) {
|
|
1818
|
-
o4.required &&
|
|
1848
|
+
o4.required && i3.push(t5);
|
|
1819
1849
|
const e5 = { type: o4.type };
|
|
1820
1850
|
if (o4.description && (e5.description = o4.description), o4.pattern && (e5.pattern = o4.pattern), void 0 !== o4.minLength && (e5.minLength = o4.minLength), void 0 !== o4.maxLength && (e5.maxLength = o4.maxLength), void 0 !== o4.minimum && (e5.minimum = o4.minimum), void 0 !== o4.maximum && (e5.maximum = o4.maximum), o4.enum && (e5.enum = [...o4.enum]), void 0 !== o4.default && (e5.default = o4.default), "object" === o4.type && o4.properties) {
|
|
1821
1851
|
const t6 = {};
|
|
1822
|
-
for (const [e6,
|
|
1852
|
+
for (const [e6, i4] of Object.entries(o4.properties)) t6[e6] = bn(i4);
|
|
1823
1853
|
e5.properties = t6;
|
|
1824
1854
|
}
|
|
1825
|
-
"array" === o4.type && o4.items && (e5.items =
|
|
1855
|
+
"array" === o4.type && o4.items && (e5.items = bn(o4.items)), n4[t5] = e5;
|
|
1826
1856
|
}
|
|
1827
1857
|
const o3 = { type: "object", properties: n4 };
|
|
1828
|
-
return t4 && (o3.title = t4),
|
|
1858
|
+
return t4 && (o3.title = t4), i3.length > 0 && (o3.required = i3), o3;
|
|
1829
1859
|
}
|
|
1830
|
-
function
|
|
1860
|
+
function bn(e4) {
|
|
1831
1861
|
const t4 = { type: e4.type };
|
|
1832
1862
|
if (e4.description && (t4.description = e4.description), e4.pattern && (t4.pattern = e4.pattern), void 0 !== e4.minLength && (t4.minLength = e4.minLength), void 0 !== e4.maxLength && (t4.maxLength = e4.maxLength), void 0 !== e4.minimum && (t4.minimum = e4.minimum), void 0 !== e4.maximum && (t4.maximum = e4.maximum), e4.enum && (t4.enum = [...e4.enum]), void 0 !== e4.default && (t4.default = e4.default), "object" === e4.type && e4.properties) {
|
|
1833
|
-
const
|
|
1834
|
-
for (const [t5, n4] of Object.entries(e4.properties))
|
|
1835
|
-
t4.properties =
|
|
1863
|
+
const i3 = {};
|
|
1864
|
+
for (const [t5, n4] of Object.entries(e4.properties)) i3[t5] = bn(n4);
|
|
1865
|
+
t4.properties = i3;
|
|
1836
1866
|
}
|
|
1837
|
-
return "array" === e4.type && e4.items && (t4.items =
|
|
1867
|
+
return "array" === e4.type && e4.items && (t4.items = bn(e4.items)), t4;
|
|
1838
1868
|
}
|
|
1839
|
-
function
|
|
1840
|
-
const
|
|
1841
|
-
return void 0 !== t4?.minItems && (
|
|
1869
|
+
function vn(e4, t4) {
|
|
1870
|
+
const i3 = { type: "array", items: bn(e4) };
|
|
1871
|
+
return void 0 !== t4?.minItems && (i3.minItems = t4.minItems), void 0 !== t4?.maxItems && (i3.maxItems = t4.maxItems), t4?.description && (i3.description = t4.description), t4?.title && (i3.title = t4.title), i3;
|
|
1842
1872
|
}
|
|
1843
|
-
function
|
|
1873
|
+
function Sn(e4, t4 = "string", i3) {
|
|
1844
1874
|
const n4 = { type: t4, enum: [...e4] };
|
|
1845
|
-
return
|
|
1875
|
+
return i3?.description && (n4.description = i3.description), i3?.title && (n4.title = i3.title), n4;
|
|
1846
1876
|
}
|
|
1847
|
-
function
|
|
1848
|
-
return
|
|
1877
|
+
function yn(e4, t4, i3) {
|
|
1878
|
+
return vn({ type: "object" }, { minItems: 2, maxItems: 2, description: i3 || "Tuple with exactly 2 elements [source, transform]" });
|
|
1849
1879
|
}
|
|
1850
|
-
function
|
|
1880
|
+
function wn(e4) {
|
|
1851
1881
|
const t4 = n3.toJSONSchema(e4, { target: "draft-7" });
|
|
1852
|
-
return
|
|
1882
|
+
return kn(t4), t4;
|
|
1853
1883
|
}
|
|
1854
|
-
function
|
|
1884
|
+
function kn(e4) {
|
|
1855
1885
|
const t4 = e4.properties;
|
|
1856
1886
|
if (t4 && "object" == typeof t4) {
|
|
1857
1887
|
Array.isArray(e4.required) && (e4.required = e4.required.filter((e5) => {
|
|
1858
|
-
const
|
|
1859
|
-
return !(
|
|
1888
|
+
const i3 = t4[e5];
|
|
1889
|
+
return !(i3 && "object" == typeof i3 && "default" in i3);
|
|
1860
1890
|
}));
|
|
1861
|
-
for (const [e5,
|
|
1891
|
+
for (const [e5, i3] of Object.entries(t4)) i3 && "object" == typeof i3 && ("object" === i3.type && i3.properties && "string" != typeof i3.title && (i3.title = e5), kn(i3));
|
|
1862
1892
|
}
|
|
1863
1893
|
}
|
|
1864
|
-
var e3, t3,
|
|
1894
|
+
var e3, t3, i2, r3, a3, s4, c, l, d, p, u2, m2, f2, g2, h2, b2, v2, S, y, w2, k, C2, x, P2, j, D3, E2, I2, O, J2, z2, L, $, q2, A, N, W, B2, U2, V, H, _, Z2, G2, K, Q2, X2, Y2, ee2, te2, ie2, ne2, oe2, re, ae, se2, ce2, le3, de3, pe3, ue3, me3, fe3, ge3, he3, be3, ve3, Se3, ye3, we2, ke3, Ce2, xe3, Pe3, je2, De3, Ee2, Ie3, Oe3, Je, Re3, Me3, Fe2, Te3, ze3, Le2, $e2, qe3, Ae3, Ne3, We3, Be2, Ue3, Ve2, He3, _e2, Ze3, Ge2, Ke3, Qe, Xe2, Ye, et2, tt2, it, nt2, ot, rt2, at2, st2, ct2, lt, dt, pt2, ut3, mt2, ft2, gt, ht, bt2, vt2, St, yt, wt2, kt2, Ct3, xt2, Pt2, jt2, Dt2, Et, It3, Ot2, Jt2, Rt2, Mt2, Ft2, Tt2, zt2, Lt2, $t, qt3, At2, Nt2, Wt2, Bt2, Ut2, Vt2, Ht2, _t, Zt2, Gt2, Kt2, Qt, Xt, Yt, ei, ti, ii, ni, oi, ri, ai, si, ci, li, di, pi, ui, mi, fi, gi, hi, bi, vi, Si, yi, wi, ki, Ci, xi, Pi, Di, Ei, Ii, Oi, Ji, Ri, Mi, Fi, Ti, zi, Li, $i, Bi, Ui, Vi, Hi, _i, Zi, Gi, Ki, Qi, Xi, Yi, tn, nn, on, rn, sn, cn, ln, dn, xn;
|
|
1865
1895
|
var init_dev = __esm({
|
|
1866
1896
|
"../core/dist/dev.mjs"() {
|
|
1867
1897
|
"use strict";
|
|
1868
1898
|
e3 = Object.defineProperty;
|
|
1869
|
-
t3 = (t4,
|
|
1870
|
-
for (var n4 in
|
|
1899
|
+
t3 = (t4, i3) => {
|
|
1900
|
+
for (var n4 in i3) e3(t4, n4, { get: i3[n4], enumerable: true });
|
|
1871
1901
|
};
|
|
1872
|
-
|
|
1873
|
-
t3(
|
|
1902
|
+
i2 = {};
|
|
1903
|
+
t3(i2, { BaseContextConfig: () => L, CacheRuleSchema: () => Xe2, CacheSchema: () => Ye, CacheSchemas: () => _e2, ClickIdEntrySchema: () => rn, CodeSchema: () => tn, CollectorSchemas: () => Et, ConsentSchema: () => Z2, ContractActionsSchema: () => Ri, ContractRuleSchema: () => Fi, ContractSchema: () => Ti, ContractSchemaEntry: () => Ji, Counter: () => d, DeepPartialEventSchema: () => te2, DestinationSchemas: () => Re3, DestinationsMapConfig: () => A, EntitiesSchema: () => X2, EntitySchema: () => Q2, EventCacheRuleSchema: () => Ze3, EventCacheSchema: () => Ge2, EventSchema: () => Y2, FlowBundlePackageSchema: () => bi, FlowBundleSchema: () => vi, FlowCodeSchema: () => Si, FlowConfigSchema: () => zi, FlowDestinationSchema: () => Ii, FlowJsonSchema: () => $i, FlowSchema: () => Li, FlowSchemas: () => mi, FlowSourceSchema: () => Di, FlowStoreSchema: () => Oi, FlowTransformerSchema: () => Ei, GenericEnvConfig: () => J2, GenericSettingsConfig: () => O, HandlersConfig: () => x, HintSchema: () => nn, HintsSchema: () => on, IdConfig: () => D3, Identifier: () => c, InitConfig: () => E2, LoggerConfigSchema: () => it, LoggerHandlerSchema: () => tt2, LoopSchema: () => me3, MapSchema: () => ge3, MappingResultSchema: () => ke3, MappingSchemas: () => de3, MatchExpressionSchema: () => ze3, MatcherSchemas: () => Me3, OptionalPrimitiveValue: () => u2, OrderedPropertiesSchema: () => H, PartialEventSchema: () => ee2, PolicySchema: () => be3, PrimaryConfig: () => I2, PrimitiveValue: () => p, ProcessingControlConfig: () => $, PropertiesSchema: () => V, PropertySchema: () => U2, PropertyTypeSchema: () => B2, QueueConfig: () => j, RequiredBoolean: () => s4, RequiredNumber: () => a3, RequiredString: () => r3, RouteSchema: () => We3, RouteWithoutManySchema: () => He3, RuleSchema: () => Se3, RulesSchema: () => ye3, RuntimeInstanceConfig: () => z2, SetSchema: () => fe3, SourceSchema: () => K, SourceSchemas: () => Bt2, SourceTypeSchema: () => _, SourcesMapConfig: () => q2, StateSchema: () => et2, StoreCacheRuleSchema: () => Ke3, StoreCacheSchema: () => Qe, StoreSchemas: () => ci, Timestamp: () => l, TransformerSchemas: () => ni, UserSchema: () => G2, UtilitySchemas: () => m2, ValidateEventsSchema: () => xi, ValidateSchema: () => Pi, ValueConfigSchema: () => he3, ValueSchema: () => pe3, ValuesSchema: () => ue3, VerboseConfig: () => P2, WalkerOSSchemas: () => N, configJsonSchema: () => Bi, consentJsonSchema: () => le3, contractJsonSchema: () => Qi, contractRuleJsonSchema: () => Ki, createArraySchema: () => vn, createConsentConfig: () => T2, createDataTransformationConfig: () => R2, createEnumSchema: () => Sn, createMappingRulesConfig: () => M2, createObjectSchema: () => hn, createPolicyConfig: () => F2, createTupleSchema: () => yn, destinationJsonSchema: () => _i, entityJsonSchema: () => se2, eventJsonSchema: () => ie2, flowConfigJsonSchema: () => Vi, flowJsonSchema: () => Ui, loopJsonSchema: () => Pe3, mapJsonSchema: () => De3, orderedPropertiesJsonSchema: () => ae, parseConfig: () => qi, parseFlow: () => Ni, partialEventJsonSchema: () => ne2, policyJsonSchema: () => Ee2, propertiesJsonSchema: () => re, ruleJsonSchema: () => Ie3, rulesJsonSchema: () => Oe3, safeParseConfig: () => Ai, safeParseFlow: () => Wi, setJsonSchema: () => je2, sourceJsonSchema: () => Hi, sourceTypeJsonSchema: () => ce2, storeJsonSchema: () => Gi, transformerJsonSchema: () => Zi, userJsonSchema: () => oe2, validateEventsJsonSchema: () => Yi, validateFlowConfig: () => an, validateJsonSchema: () => Xi, valueConfigJsonSchema: () => xe3, valueJsonSchema: () => Ce2, z: () => n3, zodToSchema: () => wn });
|
|
1874
1904
|
r3 = n3.string();
|
|
1875
1905
|
a3 = n3.number();
|
|
1876
1906
|
s4 = n3.boolean();
|
|
@@ -1878,15 +1908,15 @@ var init_dev = __esm({
|
|
|
1878
1908
|
l = n3.number().int().positive();
|
|
1879
1909
|
d = n3.number().int().nonnegative();
|
|
1880
1910
|
p = n3.union([n3.string(), n3.number(), n3.boolean()]);
|
|
1881
|
-
|
|
1911
|
+
u2 = p.optional();
|
|
1882
1912
|
m2 = {};
|
|
1883
|
-
t3(m2, { ErrorHandlerSchema: () => h2, HandlerSchema: () => v2, LogHandlerSchema: () => b2, StorageSchema: () => g2, StorageTypeSchema: () => f2, errorHandlerJsonSchema: () => w2, handlerJsonSchema: () => C2, logHandlerJsonSchema: () => k, storageJsonSchema: () => y, storageTypeJsonSchema: () =>
|
|
1913
|
+
t3(m2, { ErrorHandlerSchema: () => h2, HandlerSchema: () => v2, LogHandlerSchema: () => b2, StorageSchema: () => g2, StorageTypeSchema: () => f2, errorHandlerJsonSchema: () => w2, handlerJsonSchema: () => C2, logHandlerJsonSchema: () => k, storageJsonSchema: () => y, storageTypeJsonSchema: () => S });
|
|
1884
1914
|
f2 = n3.enum(["local", "session", "cookie"]).meta({ id: "StorageType", title: "Storage.Type", description: "Storage mechanism: local, session, or cookie." }).describe("Storage mechanism: local, session, or cookie");
|
|
1885
1915
|
g2 = n3.object({ Local: n3.literal("local"), Session: n3.literal("session"), Cookie: n3.literal("cookie") }).meta({ id: "StorageConstants", title: "Storage", description: "Storage type constants for type-safe references." }).describe("Storage type constants for type-safe references");
|
|
1886
1916
|
h2 = n3.unknown().meta({ id: "ErrorHandler", title: "Error.Handler", description: "Error handler function: (error, state?) => void." }).describe("Error handler function: (error, state?) => void");
|
|
1887
1917
|
b2 = n3.unknown().meta({ id: "LogHandler", title: "Log.Handler", description: "Log handler function: (message, verbose?) => void." }).describe("Log handler function: (message, verbose?) => void");
|
|
1888
1918
|
v2 = n3.object({ Error: h2.describe("Error handler function"), Log: b2.describe("Log handler function") }).meta({ id: "Handler", title: "Handler", description: "Handler interface with error and log functions." }).describe("Handler interface with error and log functions");
|
|
1889
|
-
|
|
1919
|
+
S = o2(f2);
|
|
1890
1920
|
y = o2(g2);
|
|
1891
1921
|
w2 = o2(h2);
|
|
1892
1922
|
k = o2(b2);
|
|
@@ -1894,8 +1924,8 @@ var init_dev = __esm({
|
|
|
1894
1924
|
x = n3.object({ onError: h2.optional().describe("Error handler function: (error, state?) => void"), onLog: b2.optional().describe("Log handler function: (message, verbose?) => void") }).partial();
|
|
1895
1925
|
P2 = n3.object({ verbose: n3.boolean().describe("Enable verbose logging for debugging").optional() }).partial();
|
|
1896
1926
|
j = n3.object({ queue: n3.boolean().describe("Whether to queue events when consent is not granted").optional() }).partial();
|
|
1897
|
-
|
|
1898
|
-
|
|
1927
|
+
D3 = n3.object({}).partial();
|
|
1928
|
+
E2 = n3.object({ init: n3.boolean().describe("Whether to initialize immediately").optional(), loadScript: n3.boolean().describe("Whether to load external script (for web destinations)").optional() }).partial();
|
|
1899
1929
|
I2 = n3.object({ primary: n3.boolean().describe("Mark as primary (only one can be primary)").optional() }).partial();
|
|
1900
1930
|
O = n3.object({ settings: n3.any().optional().describe("Implementation-specific configuration") }).partial();
|
|
1901
1931
|
J2 = n3.object({ env: n3.any().optional().describe("Environment dependencies (platform-specific)") }).partial();
|
|
@@ -1903,32 +1933,32 @@ var init_dev = __esm({
|
|
|
1903
1933
|
L = n3.object({ collector: n3.unknown().describe("Collector instance (runtime object)"), config: n3.unknown().describe("Configuration"), env: n3.unknown().describe("Environment dependencies") }).partial();
|
|
1904
1934
|
$ = n3.object({ ignore: n3.boolean().describe("Set to true to skip processing").optional(), condition: n3.string().optional().describe("Condition function: return true to process") }).partial();
|
|
1905
1935
|
q2 = n3.object({ sources: n3.record(n3.string(), n3.unknown()).describe("Map of source instances") }).partial();
|
|
1906
|
-
|
|
1907
|
-
|
|
1908
|
-
t3(
|
|
1936
|
+
A = n3.object({ destinations: n3.record(n3.string(), n3.unknown()).describe("Map of destination instances") }).partial();
|
|
1937
|
+
N = {};
|
|
1938
|
+
t3(N, { ConsentSchema: () => Z2, DeepPartialEventSchema: () => te2, EntitiesSchema: () => X2, EntitySchema: () => Q2, EventSchema: () => Y2, OrderedPropertiesSchema: () => H, PartialEventSchema: () => ee2, PropertiesSchema: () => V, PropertySchema: () => U2, PropertyTypeSchema: () => B2, SourceSchema: () => K, SourceTypeSchema: () => _, UserSchema: () => G2, consentJsonSchema: () => le3, entityJsonSchema: () => se2, eventJsonSchema: () => ie2, orderedPropertiesJsonSchema: () => ae, partialEventJsonSchema: () => ne2, propertiesJsonSchema: () => re, sourceTypeJsonSchema: () => ce2, userJsonSchema: () => oe2 });
|
|
1909
1939
|
B2 = n3.lazy(() => n3.union([n3.boolean(), n3.string(), n3.number(), n3.record(n3.string(), U2)])).meta({ id: "WalkerOSPropertyType", title: "WalkerOS.PropertyType", description: "Base property value types (boolean, string, number, or nested Property record)." });
|
|
1910
1940
|
U2 = n3.lazy(() => n3.union([B2, n3.array(B2)])).meta({ id: "WalkerOSProperty", title: "WalkerOS.Property", description: "PropertyType or an array of PropertyType. Recursive structure for nested objects and arrays." });
|
|
1911
|
-
|
|
1941
|
+
V = n3.record(n3.string(), U2.optional()).meta({ id: "WalkerOSProperties", title: "WalkerOS.Properties", description: "Flexible property collection with optional values." }).describe("Flexible property collection with optional values");
|
|
1912
1942
|
H = n3.record(n3.string(), n3.tuple([U2, n3.number()]).optional()).meta({ id: "WalkerOSOrderedProperties", title: "WalkerOS.OrderedProperties", description: "Ordered properties with [value, order] tuples for priority control." }).describe("Ordered properties with [value, order] tuples for priority control");
|
|
1913
1943
|
_ = n3.union([n3.enum(["web", "server", "app", "other"]), n3.string()]).meta({ id: "WalkerOSSourceType", title: "WalkerOS.SourceType", description: "Source type identifier. Standard: web, server, app, other. Extensible to custom strings." }).describe("Source type: web, server, app, other, or custom");
|
|
1914
1944
|
Z2 = n3.record(n3.string(), n3.boolean()).meta({ id: "WalkerOSConsent", title: "WalkerOS.Consent", description: "Consent state mapping. Keys are consent groups (e.g. marketing, functional), values are booleans for granted/denied." }).describe("Consent requirement mapping (group name to state)");
|
|
1915
|
-
G2 =
|
|
1916
|
-
|
|
1917
|
-
Q2 = n3.lazy(() => n3.object({ entity: n3.string().describe("Entity name"), data:
|
|
1945
|
+
G2 = V.and(n3.object({ id: n3.string().optional().describe("User identifier"), device: n3.string().optional().describe("Device identifier"), session: n3.string().optional().describe("Session identifier"), hash: n3.string().optional().describe("Hashed identifier"), address: n3.string().optional().describe("User address"), email: n3.string().email().optional().describe("User email address"), phone: n3.string().optional().describe("User phone number"), userAgent: n3.string().optional().describe("Browser user agent string"), browser: n3.string().optional().describe("Browser name"), browserVersion: n3.string().optional().describe("Browser version"), deviceType: n3.string().optional().describe("Device type (mobile, desktop, tablet)"), os: n3.string().optional().describe("Operating system"), osVersion: n3.string().optional().describe("Operating system version"), screenSize: n3.string().optional().describe("Screen dimensions"), language: n3.string().optional().describe("User language"), country: n3.string().optional().describe("User country"), region: n3.string().optional().describe("User region/state"), city: n3.string().optional().describe("User city"), zip: n3.string().optional().describe("User postal code"), timezone: n3.string().optional().describe("User timezone"), ip: n3.string().optional().describe("User IP address"), internal: n3.boolean().optional().describe("Internal user flag (employee, test user)") })).meta({ id: "WalkerOSUser", title: "WalkerOS.User", description: "User identification and attributes." }).describe("User identification and properties");
|
|
1946
|
+
K = V.and(n3.object({ type: n3.string().describe("Source kind (browser, dataLayer, gtag, ...)"), platform: n3.string().optional().describe("Runtime platform (web, server, app, ios, android, terminal, ...)"), version: n3.string().optional().describe("Deployment version of the source emitter"), schema: n3.string().optional().describe('Event model spec version (collector defaults to "4")'), count: n3.number().int().nonnegative().optional().describe("Emission sequence per run"), trace: n3.string().optional().describe("W3C traceparent full string"), url: n3.string().optional(), referrer: n3.string().optional(), tool: n3.string().optional(), command: n3.string().optional() })).meta({ id: "WalkerOSSource", title: "WalkerOS.Source", description: "Event source information (origin of the event)." }).describe("Event source information");
|
|
1947
|
+
Q2 = n3.lazy(() => n3.object({ entity: n3.string().describe("Entity name"), data: V.describe("Entity-specific properties"), nested: n3.array(Q2).optional().describe("Nested child entities"), context: H.optional().describe("Entity context data") })).meta({ id: "WalkerOSEntity", title: "WalkerOS.Entity", description: "Nested entity structure with recursive nesting support." }).describe("Nested entity structure with recursive nesting support");
|
|
1918
1948
|
X2 = n3.array(Q2).meta({ id: "WalkerOSEntities", title: "WalkerOS.Entities", description: "Array of nested entities." }).describe("Array of nested entities");
|
|
1919
|
-
Y2 = n3.object({ name: n3.string().describe('Event name in "entity action" format (e.g., "page view", "product add")'), data:
|
|
1949
|
+
Y2 = n3.object({ name: n3.string().describe('Event name in "entity action" format (e.g., "page view", "product add")'), data: V.describe("Event-specific properties"), context: H.describe("Ordered context properties with priorities"), globals: V.describe("Global properties shared across events"), custom: V.describe("Custom implementation-specific properties"), user: G2.describe("User identification and attributes"), nested: X2.describe("Related nested entities"), consent: Z2.describe("Consent states at event time"), id: c.describe("W3C span_id, 16 lowercase hex characters"), trigger: r3.describe("Event trigger identifier"), entity: r3.describe("Parsed entity from event name"), action: r3.describe("Parsed action from event name"), timestamp: l.describe("Unix timestamp in milliseconds since epoch"), timing: a3.describe("Event processing timing information"), source: K.describe("Event source information") }).meta({ id: "WalkerOSEvent", title: "WalkerOS.Event", description: "Complete walkerOS event structure." }).describe("Complete walkerOS event structure");
|
|
1920
1950
|
ee2 = Y2.partial().meta({ id: "WalkerOSPartialEvent", title: "WalkerOS.PartialEvent", description: "Partial event structure with all fields optional." }).describe("Partial event structure with all fields optional");
|
|
1921
|
-
|
|
1922
|
-
|
|
1923
|
-
|
|
1951
|
+
te2 = Y2.partial().meta({ id: "WalkerOSDeepPartialEvent", title: "WalkerOS.DeepPartialEvent", description: "Partial event structure with all top-level fields optional." }).describe("Partial event structure with all top-level fields optional");
|
|
1952
|
+
ie2 = o2(Y2);
|
|
1953
|
+
ne2 = o2(ee2);
|
|
1924
1954
|
oe2 = o2(G2);
|
|
1925
|
-
|
|
1926
|
-
|
|
1927
|
-
|
|
1928
|
-
|
|
1955
|
+
re = o2(V);
|
|
1956
|
+
ae = o2(H);
|
|
1957
|
+
se2 = o2(Q2);
|
|
1958
|
+
ce2 = o2(_);
|
|
1929
1959
|
le3 = o2(Z2);
|
|
1930
1960
|
de3 = {};
|
|
1931
|
-
t3(de3, { ConfigSchema: () => we2, LoopSchema: () => me3, MapSchema: () => ge3, PolicySchema: () => be3, ResultSchema: () =>
|
|
1961
|
+
t3(de3, { ConfigSchema: () => we2, LoopSchema: () => me3, MapSchema: () => ge3, PolicySchema: () => be3, ResultSchema: () => ke3, RulePatchSchema: () => ve3, RuleSchema: () => Se3, RulesSchema: () => ye3, SetSchema: () => fe3, ValueConfigSchema: () => he3, ValueSchema: () => pe3, ValuesSchema: () => ue3, configJsonSchema: () => Je, loopJsonSchema: () => Pe3, mapJsonSchema: () => De3, policyJsonSchema: () => Ee2, ruleJsonSchema: () => Ie3, rulesJsonSchema: () => Oe3, setJsonSchema: () => je2, valueConfigJsonSchema: () => xe3, valueJsonSchema: () => Ce2 });
|
|
1932
1962
|
pe3 = 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(() => W), n3.array(pe3).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." });
|
|
1933
1963
|
ue3 = n3.array(pe3).meta({ id: "MappingValues", title: "Mapping.Values", description: "Array of transformation values." }).describe("Array of transformation values");
|
|
1934
1964
|
me3 = n3.lazy(() => n3.tuple([pe3, pe3]).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." });
|
|
@@ -1936,161 +1966,171 @@ var init_dev = __esm({
|
|
|
1936
1966
|
ge3 = n3.lazy(() => n3.record(n3.string(), pe3).describe("Map: Object mapping keys to transformation values")).meta({ id: "MappingMap", title: "Mapping.Map", description: "Map: object mapping keys to transformation values." });
|
|
1937
1967
|
he3 = W = n3.object({ key: n3.string().optional().describe('Property path to extract from event (e.g., "data.id", "user.email")'), value: n3.union([n3.string(), n3.number(), n3.boolean()]).optional().describe("Static primitive value"), fn: n3.string().optional().describe("Custom transformation function as string (serialized)"), map: ge3.optional().describe("Object mapping: transform event data to structured output"), loop: me3.optional().describe("Loop transformation: [source, transform] for array processing"), set: fe3.optional().describe("Set of values: combine or select from multiple values"), consent: Z2.optional().describe("Required consent states to include this value"), condition: n3.string().optional().describe("Condition function as string: return true to include value"), validate: n3.string().optional().describe("Validation function as string: return true if value is valid") }).refine((e4) => Object.keys(e4).length > 0, { message: "ValueConfig must have at least one property" }).meta({ id: "MappingValueConfig", title: "Mapping.ValueConfig", description: "Object-form value transformation with map/loop/set/condition/consent etc." }).describe("Value transformation configuration with multiple strategies");
|
|
1938
1968
|
be3 = n3.record(n3.string(), pe3).meta({ id: "MappingPolicy", title: "Mapping.Policy", description: "Policy rules for event pre-processing (key \u2192 value transformation)." }).describe("Policy rules for event pre-processing (key \u2192 value mapping)");
|
|
1939
|
-
|
|
1940
|
-
|
|
1941
|
-
ye3 = n3.record(n3.string(), n3.record(n3.string(), n3.union([
|
|
1969
|
+
ve3 = n3.object({ name: n3.string().nullable().optional(), data: n3.union([pe3, ue3]).nullable().optional(), settings: n3.unknown().nullable().optional(), condition: n3.string().nullable().optional(), consent: Z2.nullable().optional(), policy: be3.nullable().optional(), batch: n3.union([n3.number(), n3.object({ wait: n3.number().optional(), size: n3.number().optional(), age: n3.number().optional() })]).nullable().optional(), include: n3.array(n3.string()).nullable().optional(), ignore: n3.boolean().nullable().optional(), silent: n3.boolean().nullable().optional() }).meta({ id: "MappingRulePatch", title: "Mapping.RulePatch", description: "Partial rule deep-merged onto a package-shipped default; a null value clears the inherited field." }).describe("Partial rule for `extend`; null clears an inherited field");
|
|
1970
|
+
Se3 = n3.object({ name: n3.string().optional().describe('Custom event name override (e.g., "view_item" for "product view")'), data: n3.union([pe3, ue3]).optional().describe("Data transformation rules for event"), settings: n3.unknown().optional().describe("Destination-specific settings for this event mapping"), condition: n3.string().optional().describe("Condition function as string: return true to process event"), consent: Z2.optional().describe("Required consent states to process this event"), policy: be3.optional().describe("Event-level policy overrides (applied after config-level policy)"), batch: n3.union([n3.number(), n3.object({ wait: n3.number().optional(), size: n3.number().optional(), age: n3.number().optional() })]).optional().describe("Batch scheduling: bare number is the debounce wait window (legacy); object form supports wait/size/age."), 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."), extend: ve3.optional().describe("Merge mode: a partial rule deep-merged onto the package-shipped default at this key (instead of replacing it). A null value clears an inherited field."), remove: n3.array(n3.string()).optional().describe("Dotted paths stripped from the produced data payload after evaluation (applied last).") }).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");
|
|
1971
|
+
ye3 = n3.record(n3.string(), n3.record(n3.string(), n3.union([Se3, n3.array(Se3)])).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*).');
|
|
1942
1972
|
we2 = n3.object({ consent: Z2.optional().describe("Required consent states to process any events"), data: n3.union([pe3, ue3]).optional().describe("Global data transformation applied to all events"), include: n3.array(n3.string()).optional().describe("Event sections to flatten into context.data"), mapping: ye3.optional().describe("Entity-action specific mapping rules"), policy: be3.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");
|
|
1943
|
-
|
|
1944
|
-
|
|
1973
|
+
ke3 = n3.object({ eventMapping: Se3.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");
|
|
1974
|
+
Ce2 = o2(pe3);
|
|
1945
1975
|
xe3 = o2(he3);
|
|
1946
1976
|
Pe3 = o2(me3);
|
|
1947
|
-
|
|
1948
|
-
|
|
1949
|
-
|
|
1950
|
-
Ie3 = o2(
|
|
1951
|
-
|
|
1977
|
+
je2 = o2(fe3);
|
|
1978
|
+
De3 = o2(ge3);
|
|
1979
|
+
Ee2 = o2(be3);
|
|
1980
|
+
Ie3 = o2(Se3);
|
|
1981
|
+
Oe3 = o2(ye3);
|
|
1952
1982
|
Je = o2(we2);
|
|
1953
|
-
|
|
1954
|
-
t3(
|
|
1983
|
+
Re3 = {};
|
|
1984
|
+
t3(Re3, { BatchSchema: () => pt2, ConfigSchema: () => nt2, ContextSchema: () => at2, DLQSchema: () => yt, DataSchema: () => ut3, DestinationPolicySchema: () => rt2, DestinationsSchema: () => ht, InitDestinationsSchema: () => gt, InitSchema: () => ft2, InstanceSchema: () => mt2, PartialConfigSchema: () => ot, PushBatchContextSchema: () => ct2, PushContextSchema: () => st2, PushEventSchema: () => lt, PushEventsSchema: () => dt, PushResultSchema: () => vt2, RefSchema: () => bt2, ResultSchema: () => St, batchJsonSchema: () => Pt2, configJsonSchema: () => wt2, contextJsonSchema: () => Ct3, instanceJsonSchema: () => jt2, partialConfigJsonSchema: () => kt2, pushContextJsonSchema: () => xt2, resultJsonSchema: () => Dt2 });
|
|
1955
1985
|
Me3 = {};
|
|
1956
|
-
t3(Me3, { MatchExpressionSchema: () => ze3, RouteSchema: () =>
|
|
1957
|
-
|
|
1958
|
-
|
|
1959
|
-
ze3 = n3.union([
|
|
1960
|
-
|
|
1961
|
-
$
|
|
1962
|
-
|
|
1963
|
-
|
|
1964
|
-
|
|
1965
|
-
|
|
1966
|
-
Be2 = n3.strictObject({ match: ze3.optional(), next: n3.lazy(() =>
|
|
1967
|
-
Ue3 = n3.strictObject({ match: ze3.optional(), one: n3.array(n3.lazy(() =>
|
|
1968
|
-
Ve2 = n3.union([Be2, Ue3,
|
|
1969
|
-
|
|
1970
|
-
|
|
1971
|
-
t3(
|
|
1972
|
-
|
|
1973
|
-
|
|
1974
|
-
|
|
1975
|
-
Qe = n3.strictObject({ store: n3.string().optional().describe("Store ID for persistent caching (references a configured store)"), namespace: n3.string().min(1).optional().describe("Optional key prefix. Omit to default to the host store id. Empty string is rejected."), rules: n3.array(
|
|
1976
|
-
|
|
1977
|
-
Ye =
|
|
1978
|
-
et2 = n3.
|
|
1979
|
-
|
|
1980
|
-
|
|
1981
|
-
|
|
1982
|
-
|
|
1983
|
-
|
|
1984
|
-
|
|
1985
|
-
|
|
1986
|
-
|
|
1987
|
-
|
|
1988
|
-
|
|
1989
|
-
|
|
1990
|
-
|
|
1991
|
-
|
|
1992
|
-
|
|
1993
|
-
|
|
1994
|
-
|
|
1995
|
-
|
|
1996
|
-
|
|
1997
|
-
|
|
1998
|
-
|
|
1999
|
-
|
|
2000
|
-
|
|
2001
|
-
|
|
2002
|
-
|
|
2003
|
-
|
|
2004
|
-
|
|
2005
|
-
|
|
2006
|
-
|
|
2007
|
-
|
|
2008
|
-
|
|
2009
|
-
|
|
2010
|
-
|
|
2011
|
-
|
|
2012
|
-
|
|
1986
|
+
t3(Me3, { MatchExpressionSchema: () => ze3, RouteSchema: () => We3, RouteWithoutManySchema: () => He3 });
|
|
1987
|
+
Fe2 = n3.enum(["eq", "contains", "prefix", "suffix", "regex", "gt", "lt", "exists"]).meta({ id: "MatcherOperator", title: "Matcher.Operator", description: "Supported operators for a match condition." });
|
|
1988
|
+
Te3 = n3.object({ key: n3.string(), operator: Fe2, value: n3.string(), not: n3.boolean().optional() }).meta({ id: "MatcherCondition", title: "Matcher.Condition", description: "Single match condition (key, operator, value, optional not)." });
|
|
1989
|
+
ze3 = n3.union([Te3, n3.object({ and: n3.array(n3.lazy(() => ze3)) }), n3.object({ or: n3.array(n3.lazy(() => ze3)) })]).meta({ id: "MatcherExpression", title: "Matcher.Expression", description: "Boolean expression tree of match conditions (leaf, and, or)." });
|
|
1990
|
+
Le2 = n3.strictObject({ match: ze3.optional(), next: n3.lazy(() => We3) });
|
|
1991
|
+
$e2 = n3.strictObject({ match: ze3.optional(), one: n3.array(n3.lazy(() => We3)) });
|
|
1992
|
+
qe3 = n3.strictObject({ match: ze3.optional(), many: n3.array(n3.lazy(() => We3)) });
|
|
1993
|
+
Ae3 = n3.strictObject({ match: ze3 });
|
|
1994
|
+
Ne3 = n3.union([Le2, $e2, qe3, Ae3]);
|
|
1995
|
+
We3 = n3.union([n3.string(), n3.array(n3.lazy(() => We3)), Ne3]).meta({ id: "Route", title: "Route", description: "Recursive route: string ID, sequence of routes, or a RouteConfig (next/one/many/gate)." });
|
|
1996
|
+
Be2 = n3.strictObject({ match: ze3.optional(), next: n3.lazy(() => He3) });
|
|
1997
|
+
Ue3 = n3.strictObject({ match: ze3.optional(), one: n3.array(n3.lazy(() => He3)) });
|
|
1998
|
+
Ve2 = n3.union([Be2, Ue3, Ae3]);
|
|
1999
|
+
He3 = n3.union([n3.string(), n3.array(n3.lazy(() => He3)), Ve2]).meta({ id: "RouteWithoutMany", title: "RouteWithoutMany", description: "Route variant for post-collector positions (destination.before). Excludes the many operator \u2014 post-collector fan-out uses the destinations map." });
|
|
2000
|
+
_e2 = {};
|
|
2001
|
+
t3(_e2, { CacheRuleSchema: () => Xe2, CacheSchema: () => Ye, EventCacheRuleSchema: () => Ze3, EventCacheSchema: () => Ge2, StoreCacheRuleSchema: () => Ke3, StoreCacheSchema: () => Qe });
|
|
2002
|
+
Ze3 = n3.object({ match: ze3.optional().describe("Optional match expression \u2014 omit for always-match."), 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"), update: n3.record(n3.string(), pe3).optional().describe("Response mutations applied on cache hit (key \u2192 Value mapping)") }).meta({ id: "EventCacheRule", title: "EventCache.Rule", description: "Single event-cache rule: when it applies (match), what event fields it keys off, TTL, and optional response mutations on hit." });
|
|
2003
|
+
Ge2 = n3.object({ stop: n3.boolean().optional().describe("Stop the chain 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)"), namespace: n3.string().optional().describe("Optional key prefix. Omit to write keys directly to the store. Same store + same key + same namespace = same cache entry."), rules: n3.array(Ze3).min(1).describe("Cache rules \u2014 at least one required") }).meta({ id: "EventCacheConfig", title: "EventCache.Config", description: "Top-level cache configuration for an event-context pipeline step (source / transformer / destination)." });
|
|
2004
|
+
Ke3 = n3.strictObject({ match: ze3.optional().describe("Optional match expression evaluated against `{ key, value? }`. Omit for always-match."), ttl: n3.number().positive().describe("Time-to-live in seconds") }).meta({ id: "StoreCacheRule", title: "StoreCache.Rule", description: "Single store-cache rule: optional match against `{ key, value? }` and a TTL. No `key` (caller provides it) and no `update` (no event to mutate)." });
|
|
2005
|
+
Qe = n3.strictObject({ store: n3.string().optional().describe("Store ID for persistent caching (references a configured store)"), namespace: n3.string().min(1).optional().describe("Optional key prefix. Omit to default to the host store id. Empty string is rejected."), rules: n3.array(Ke3).min(1).describe("Cache rules \u2014 at least one required") }).meta({ id: "StoreCacheConfig", title: "StoreCache.Config", description: "Top-level cache configuration for a store wrapper. No `stop` (always falls through on miss); namespace defaults to the host store id." });
|
|
2006
|
+
Xe2 = Ze3;
|
|
2007
|
+
Ye = Ge2;
|
|
2008
|
+
et2 = n3.object({ mode: n3.enum(["get", "set"]).describe("Direction: 'get' reads from the store, 'set' writes to it"), store: n3.string().optional().describe("Store id; defaults to the in-memory __cache store when omitted"), key: pe3.describe("Resolves against the event to the store key"), value: pe3.optional().describe("set: resolves to the payload to store. get: its key/bare-string path is the event write-target.") }).superRefine((e4, t4) => {
|
|
2009
|
+
if (void 0 !== e4.value) {
|
|
2010
|
+
if ("get" === e4.mode) {
|
|
2011
|
+
const i3 = e4.value;
|
|
2012
|
+
let n4;
|
|
2013
|
+
if ("string" == typeof i3 ? n4 = i3 : "object" == typeof i3 && null !== i3 && !Array.isArray(i3) && "key" in i3 && "string" == typeof i3.key && (n4 = i3.key), void 0 === n4) return void t4.addIssue({ code: "custom", message: 'For mode "get", `value` must be a bare string path or a ValueConfig with a `key` (no value/fn/map/loop/set).', path: ["value"] });
|
|
2014
|
+
n4.includes("*") && t4.addIssue({ code: "custom", message: 'For mode "get", the `value` path may not contain `*`.', path: ["value"] });
|
|
2015
|
+
}
|
|
2016
|
+
} else t4.addIssue({ code: "custom", message: `\`value\` is required for mode "${e4.mode}".`, path: ["value"] });
|
|
2017
|
+
}).meta({ id: "StateConfig", title: "State.Config", description: "Declarative store operation: stash (set) or fetch (get) a value against a store. key = store side, value = event side, mode = direction." });
|
|
2018
|
+
tt2 = n3.any().meta({ id: "LoggerHandler", title: "Logger.Handler", description: "Custom log handler function (level, ...args) => void" });
|
|
2019
|
+
it = n3.object({ level: n3.union([n3.number(), n3.enum(["ERROR", "WARN", "INFO", "DEBUG"])]).optional().describe("Minimum log level (default: ERROR)"), handler: tt2.optional().describe("Custom log handler function") }).meta({ id: "LoggerConfig", title: "Logger.Config", description: "Logger configuration (level, handler) to override the collector defaults" });
|
|
2020
|
+
nt2 = n3.object({ consent: Z2.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([pe3, ue3]).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: c.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: ye3.optional().describe("Entity-action specific mapping rules for this destination"), policy: be3.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: it.optional().describe("Logger configuration (level, handler) to override the collector defaults"), setup: n3.union([n3.boolean(), n3.record(n3.string(), n3.unknown())]).optional().describe("One-time setup options applied during destination registration (boolean enables defaults, object configures specifics)"), before: He3.optional().describe("Post-collector transformer chain applied before this destination receives the event. `many` is not valid here \u2014 use multiple destinations for post-collector fan-out."), next: He3.optional().describe("Post-push transformer chain. Runs after destination push completes; push response is available at ingest._response. `many` is not valid here \u2014 use multiple destinations for post-collector fan-out."), cache: Ge2.optional().describe("Cache configuration for deduplication; skip push on cache HIT"), state: n3.union([et2, n3.array(et2)]).optional().describe("Declarative store get/set operations applied around this destination"), 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."), queueMax: n3.number().optional().describe("Maximum consent-denied events retained in queuePush for this destination. FIFO drop on overflow. Default 1000."), dlqMax: n3.number().optional().describe("Maximum failed-push entries retained in dlq for this destination. FIFO drop on overflow. Default 100."), batch: n3.union([n3.number(), n3.object({ wait: n3.number().optional(), size: n3.number().optional(), age: n3.number().optional() })]).optional().describe("Batch scheduling: bare number is the debounce wait window (legacy); object form supports wait (debounce ms), size (count cap, default 1000), age (max ms since first entry, default 30000).") }).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");
|
|
2021
|
+
ot = nt2.partial().meta({ id: "DestinationPartialConfig", title: "Destination.PartialConfig", description: "Partial destination configuration with all fields optional." }).describe("Partial destination configuration with all fields optional");
|
|
2022
|
+
rt2 = be3.describe("Destination policy rules for event pre-processing");
|
|
2023
|
+
at2 = 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: nt2.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");
|
|
2024
|
+
st2 = at2.extend({ mapping: Se3.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");
|
|
2025
|
+
ct2 = st2.describe("Batch push context with event-specific mapping");
|
|
2026
|
+
lt = n3.object({ event: Y2.describe("The event to process"), mapping: Se3.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");
|
|
2027
|
+
dt = n3.array(lt).meta({ id: "DestinationPushEvents", title: "Destination.PushEvents", description: "Array of events with mappings (batch input)." }).describe("Array of events with mappings");
|
|
2028
|
+
pt2 = n3.object({ key: n3.string().describe('Batch key (usually mapping key like "product.view")'), events: n3.array(Y2).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: Se3.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");
|
|
2029
|
+
ut3 = 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)");
|
|
2030
|
+
mt2 = n3.object({ config: nt2.describe("Destination configuration"), queue: n3.array(Y2).optional().describe("Queued events awaiting consent"), dlq: n3.array(n3.tuple([Y2, 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)");
|
|
2031
|
+
ft2 = n3.object({ code: mt2.describe("Destination instance with implementation"), config: ot.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");
|
|
2032
|
+
gt = n3.record(n3.string(), ft2).meta({ id: "DestinationInitDestinations", title: "Destination.InitDestinations", description: "Map of destination IDs to initialization configurations." }).describe("Map of destination IDs to initialization configurations");
|
|
2033
|
+
ht = n3.record(n3.string(), mt2).meta({ id: "DestinationDestinations", title: "Destination.Destinations", description: "Map of destination IDs to runtime destination instances." }).describe("Map of destination IDs to runtime instances");
|
|
2034
|
+
bt2 = 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");
|
|
2035
|
+
vt2 = n3.object({ queue: n3.array(Y2).optional().describe("Events queued (awaiting consent)"), error: n3.unknown().optional().describe("Error if push failed") }).meta({ id: "DestinationPushResult", title: "Destination.PushResult", description: "Result of a single destination push (queued events, optional error)." }).describe("Push operation result");
|
|
2036
|
+
St = n3.object({ ok: n3.boolean().describe("True if nothing failed"), event: n3.unknown().optional().describe("The processed event"), done: n3.record(n3.string(), bt2).optional().describe("Destinations that processed successfully"), queued: n3.record(n3.string(), bt2).optional().describe("Destinations that queued events"), failed: n3.record(n3.string(), bt2).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");
|
|
2037
|
+
yt = n3.array(n3.tuple([Y2, n3.unknown()])).meta({ id: "DestinationDLQ", title: "Destination.DLQ", description: "Dead-letter queue: list of [event, error] tuples." }).describe("Dead letter queue: [(event, error), ...]");
|
|
2038
|
+
wt2 = o2(nt2);
|
|
2039
|
+
kt2 = o2(ot);
|
|
2040
|
+
Ct3 = o2(at2);
|
|
2041
|
+
xt2 = o2(st2);
|
|
2042
|
+
Pt2 = o2(pt2);
|
|
2043
|
+
jt2 = o2(mt2);
|
|
2044
|
+
Dt2 = o2(St);
|
|
2045
|
+
Et = {};
|
|
2046
|
+
t3(Et, { CommandTypeSchema: () => It3, ConfigSchema: () => Ot2, DestinationsSchema: () => Tt2, InitConfigSchema: () => Rt2, InstanceSchema: () => zt2, PushContextSchema: () => Mt2, SessionDataSchema: () => Jt2, SourcesSchema: () => Ft2, commandTypeJsonSchema: () => Lt2, configJsonSchema: () => $t, initConfigJsonSchema: () => At2, instanceJsonSchema: () => Wt2, pushContextJsonSchema: () => Nt2, sessionDataJsonSchema: () => qt3 });
|
|
2047
|
+
It3 = n3.union([n3.enum(["action", "config", "consent", "context", "destination", "elb", "globals", "hook", "init", "link", "run", "user", "walker"]), n3.string()]).meta({ id: "CollectorCommandType", title: "Collector.CommandType", description: "Collector command type identifier (standard or extension string)." }).describe("Collector command type: standard commands or custom string for extensions");
|
|
2048
|
+
Ot2 = n3.object({ run: n3.boolean().describe("Whether to run collector automatically on initialization").optional(), globalsStatic: V.describe("Static global properties that persist across collector runs"), sessionStatic: n3.record(n3.string(), n3.unknown()).meta({ id: "CollectorSessionStatic", title: "Collector.SessionStatic", description: "Static session data that persists across collector runs." }).describe("Static session data that persists across collector runs"), logger: it.optional().describe("Logger configuration (level, handler)"), queueMax: n3.number().optional().describe("Maximum events retained in collector.queue (late-registration replay). FIFO drop on overflow. Default 1000.") }).meta({ id: "CollectorConfig", title: "Collector.Config", description: "Core collector configuration (globals/session statics, logger, buffer bounds)." }).describe("Core collector configuration");
|
|
2049
|
+
Jt2 = V.and(n3.object({ isStart: n3.boolean().describe("Whether this is a new session start"), storage: n3.boolean().describe("Whether storage is available"), id: c.describe("Session identifier").optional(), start: l.describe("Session start timestamp").optional(), marketing: n3.literal(true).optional().describe("Marketing attribution flag"), updated: l.describe("Last update timestamp").optional(), isNew: n3.boolean().describe("Whether this is a new session").optional(), device: c.describe("Device identifier").optional(), count: d.describe("Event count in session").optional(), runs: d.describe("Number of runs").optional() })).meta({ id: "CollectorSessionData", title: "Collector.SessionData", description: "Session state and tracking data." }).describe("Session state and tracking data");
|
|
2050
|
+
Rt2 = Ot2.partial().extend({ consent: Z2.optional().describe("Initial consent state"), user: G2.optional().describe("Initial user data"), globals: V.optional().describe("Initial global properties"), sources: n3.unknown().meta({ id: "CollectorInitSources", title: "Source.InitSources", description: "Source configurations map (id \u2192 InitSource)." }).optional().describe("Source configurations"), destinations: n3.unknown().meta({ id: "CollectorInitDestinations", title: "Destination.InitDestinations", description: "Destination configurations map (id \u2192 Init)." }).optional().describe("Destination configurations"), transformers: n3.unknown().meta({ id: "CollectorInitTransformers", title: "Transformer.Configs", description: "Transformer configurations map (id \u2192 Config)." }).optional().describe("Transformer configurations"), stores: n3.unknown().meta({ id: "CollectorInitStores", title: "Store.Configs", description: "Store configurations map (id \u2192 Config)." }).optional().describe("Store configurations"), custom: V.optional().describe("Initial custom implementation-specific properties"), hooks: n3.unknown().meta({ id: "CollectorHooks", title: "Collector.Hooks", description: "Pipeline observation hooks." }).optional().describe("Pipeline observation hooks") }).meta({ id: "CollectorInitConfig", title: "Collector.InitConfig", description: "Collector initialization configuration with initial state (consent, user, globals, components, hooks)." }).describe("Collector initialization configuration with initial state");
|
|
2051
|
+
Mt2 = n3.object({ mapping: we2.optional().describe("Source-level mapping configuration") }).meta({ id: "CollectorPushContext", title: "Collector.PushContext", description: "Push context with optional source-level mapping." }).describe("Push context with optional source mapping");
|
|
2052
|
+
Ft2 = n3.record(n3.string(), n3.unknown()).meta({ id: "CollectorSources", title: "Collector.Sources", description: "Map of source IDs to runtime source instances." }).describe("Map of source IDs to source instances");
|
|
2013
2053
|
Tt2 = n3.record(n3.string(), n3.unknown()).meta({ id: "CollectorDestinations", title: "Collector.Destinations", description: "Map of destination IDs to runtime destination instances." }).describe("Map of destination IDs to destination instances");
|
|
2014
|
-
|
|
2015
|
-
|
|
2016
|
-
|
|
2017
|
-
|
|
2018
|
-
|
|
2019
|
-
Nt2 = o2(
|
|
2020
|
-
|
|
2021
|
-
|
|
2022
|
-
t3(
|
|
2023
|
-
|
|
2024
|
-
|
|
2025
|
-
|
|
2026
|
-
|
|
2027
|
-
|
|
2028
|
-
|
|
2029
|
-
|
|
2030
|
-
Kt2 = o2(Bt);
|
|
2054
|
+
zt2 = n3.object({ push: n3.unknown().describe("Push function for processing events"), command: n3.unknown().describe("Command function for walker commands"), allowed: n3.boolean().describe("Whether event processing is allowed"), config: Ot2.describe("Current collector configuration"), consent: Z2.describe("Current consent state"), custom: V.describe("Custom implementation-specific properties"), sources: Ft2.describe("Registered source instances"), destinations: Tt2.describe("Registered destination instances"), globals: V.describe("Current global properties"), hooks: n3.unknown().describe("Lifecycle hook functions"), on: n3.unknown().describe("Event lifecycle configuration"), queue: n3.array(Y2).describe("Queued events awaiting processing"), round: n3.number().describe("Collector run count (increments with each run)"), session: n3.union([Jt2]).describe("Current session state"), timing: n3.number().describe("Event processing timing information"), user: G2.describe("Current user data") }).meta({ id: "CollectorInstance", title: "Collector.Instance", description: "Collector instance (runtime object with push/command + full state and component maps)." }).describe("Collector instance with state and methods");
|
|
2055
|
+
Lt2 = o2(It3);
|
|
2056
|
+
$t = o2(Ot2);
|
|
2057
|
+
qt3 = o2(Jt2);
|
|
2058
|
+
At2 = o2(Rt2);
|
|
2059
|
+
Nt2 = o2(Mt2);
|
|
2060
|
+
Wt2 = o2(zt2);
|
|
2061
|
+
Bt2 = {};
|
|
2062
|
+
t3(Bt2, { BaseEnvSchema: () => Ut2, ConfigSchema: () => Vt2, InitSchema: () => Zt2, InitSourceSchema: () => Gt2, InitSourcesSchema: () => Kt2, InstanceSchema: () => _t, PartialConfigSchema: () => Ht2, baseEnvJsonSchema: () => Qt, configJsonSchema: () => Xt, initSourceJsonSchema: () => ti, initSourcesJsonSchema: () => ii, instanceJsonSchema: () => ei, partialConfigJsonSchema: () => Yt });
|
|
2063
|
+
Ut2 = n3.object({ push: n3.unknown().meta({ id: "SourcePushFn", title: "Source.PushFn", description: "Collector push function passed to the source via dependency injection." }).describe("Collector push function"), command: n3.unknown().meta({ id: "SourceCommandFn", title: "Source.CommandFn", description: "Collector command function passed to the source." }).describe("Collector command function"), sources: n3.unknown().optional().describe("Map of registered source instances"), elb: n3.unknown().meta({ id: "ElbFn", title: "Elb.Fn", description: "Public `elb(...)` API function alias for collector.push." }).describe("Public API function (alias for collector.push)") }).catchall(n3.unknown()).meta({ id: "SourceBaseEnv", title: "Source.BaseEnv", description: "Base environment for source dependency injection; platform-specific sources extend this." }).describe("Base environment for dependency injection - platform-specific sources extend this");
|
|
2064
|
+
Vt2 = we2.extend({ settings: n3.any().meta({ id: "SourceSettings", title: "Source.Settings", description: "Implementation-specific configuration (source-defined shape)." }).describe("Implementation-specific configuration").optional(), env: Ut2.optional().describe("Environment dependencies (platform-specific)"), id: c.describe("Source identifier (defaults to source key)").optional(), primary: n3.boolean().describe("Mark as primary (only one can be primary)").optional(), require: n3.array(n3.string()).optional().describe('Defer source initialization until these collector events fire (e.g., ["consent"])'), logger: it.optional().describe("Logger configuration (level, handler) to override the collector defaults"), setup: n3.union([n3.boolean(), n3.record(n3.string(), n3.unknown())]).optional().describe("One-time setup options applied during source registration (boolean enables defaults, object configures specifics)"), ingest: n3.union([pe3, ue3]).optional().describe("Ingest metadata extraction mapping. Extracts values from raw request objects (Express req, Lambda event) using mapping syntax."), disabled: n3.boolean().describe("Completely skip this source (no init, no event capture)").optional(), state: n3.union([et2, n3.array(et2)]).optional().describe("Declarative store get/set operations applied around this source"), init: n3.boolean().optional().describe("Init lifecycle flag set by collector to true after Instance.init() runs") }).meta({ id: "SourceConfig", title: "Source.Config", description: "Source configuration with mapping, environment, and lifecycle hooks." }).describe("Source configuration with mapping and environment");
|
|
2065
|
+
Ht2 = Vt2.partial().meta({ id: "SourcePartialConfig", title: "Source.PartialConfig", description: "Partial source configuration with all fields optional." }).describe("Partial source configuration with all fields optional");
|
|
2066
|
+
_t = n3.object({ type: n3.string().describe('Source type identifier (e.g., "browser", "dataLayer")'), config: Vt2.describe("Current source configuration"), push: n3.any().meta({ id: "SourceInstancePushFn", title: "Source.PushFn", description: "Push function \u2014 THE HANDLER (flexible signature for platform compatibility)." }).describe("Push function - THE HANDLER (flexible signature for platform compatibility)"), destroy: n3.any().meta({ id: "SourceDestroyFn", title: "Source.DestroyFn", description: "Cleanup function called when the source is removed." }).optional().describe("Cleanup function called when source is removed"), on: n3.unknown().optional().describe("Lifecycle hook function for event types") }).meta({ id: "SourceInstance", title: "Source.Instance", description: "Source instance (runtime object with push handler and lifecycle methods)." }).describe("Source instance with push handler and lifecycle methods");
|
|
2067
|
+
Zt2 = n3.any().meta({ id: "SourceInit", title: "Source.Init", description: "Source initialization function: (config, env) => Instance | Promise<Instance>." }).describe("Source initialization function: (config, env) => Instance | Promise<Instance>");
|
|
2068
|
+
Gt2 = n3.object({ code: Zt2.describe("Source initialization function"), config: Ht2.optional().describe("Partial configuration overrides"), env: Ut2.partial().optional().describe("Partial environment overrides"), primary: n3.boolean().optional().describe("Mark as primary source (only one can be primary)") }).meta({ id: "SourceInitSource", title: "Source.InitSource", description: "Source initialization bundle (init function + config + env + primary flag)." }).describe("Source initialization configuration");
|
|
2069
|
+
Kt2 = n3.record(n3.string(), Gt2).meta({ id: "SourceInitSources", title: "Source.InitSources", description: "Map of source IDs to initialization configurations." }).describe("Map of source IDs to initialization configurations");
|
|
2031
2070
|
Qt = o2(Ut2);
|
|
2032
|
-
Xt = o2(
|
|
2071
|
+
Xt = o2(Vt2);
|
|
2033
2072
|
Yt = o2(Ht2);
|
|
2034
|
-
ei = o2(
|
|
2035
|
-
ti = o2(
|
|
2036
|
-
ii =
|
|
2037
|
-
|
|
2038
|
-
ni
|
|
2039
|
-
oi =
|
|
2040
|
-
ri =
|
|
2073
|
+
ei = o2(_t);
|
|
2074
|
+
ti = o2(Gt2);
|
|
2075
|
+
ii = o2(Kt2);
|
|
2076
|
+
ni = {};
|
|
2077
|
+
t3(ni, { ConfigSchema: () => oi, PartialConfigSchema: () => ri, configJsonSchema: () => ai, partialConfigJsonSchema: () => si });
|
|
2078
|
+
oi = n3.object({ settings: n3.any().meta({ id: "TransformerSettings", title: "Transformer.Settings", description: "Implementation-specific configuration (transformer-defined shape)." }).describe("Implementation-specific configuration").optional(), env: n3.any().meta({ id: "TransformerEnv", title: "Transformer.Env", description: "Environment dependencies (transformer-defined shape)." }).describe("Environment dependencies (platform-specific)").optional(), id: c.describe("Transformer instance identifier (defaults to transformer key)").optional(), logger: it.optional().describe("Logger configuration (level, handler) to override the collector defaults"), before: We3.optional().describe("Pre-transformer chain that runs before this transformer pushes"), next: We3.optional().describe("Graph wiring to the next transformer in the chain"), cache: Ge2.optional().describe("Step-level cache configuration for this transformer"), state: n3.union([et2, n3.array(et2)]).optional().describe("Declarative store get/set operations applied around this transformer"), init: n3.boolean().describe("Whether to initialize immediately").optional(), disabled: n3.boolean().describe("Completely skip this transformer in chains").optional(), mock: n3.unknown().meta({ id: "TransformerMock", title: "Transformer.Mock", description: "Return this value instead of calling push(). Dev/testing only." }).optional().describe("Return this value instead of calling push(). Global mock for all chains. Dev/testing only."), chainMocks: n3.record(n3.string(), n3.unknown().meta({ id: "TransformerChainMock", title: "Transformer.ChainMock", description: "Chain-path-specific mock value. Dev/testing only." })).optional().describe("Path-specific mock values keyed by chain path. Takes precedence over global mock. Dev/testing only."), mapping: we2.optional().describe("Declarative event-to-event mapping applied when this transformer step has no code. At this position, only event-mutating fields apply (policy, mapping[].policy, mapping[].name, mapping[].ignore, mapping[].consent, include); vendor-payload fields are ignored.") }).strict().meta({ id: "TransformerConfig", title: "Transformer.Config", description: "Transformer configuration (settings, env, chain wiring, cache, mocks)." }).describe("Transformer configuration");
|
|
2079
|
+
ri = oi.partial().meta({ id: "TransformerPartialConfig", title: "Transformer.PartialConfig", description: "Partial transformer configuration with all fields optional." }).describe("Partial transformer configuration with all fields optional");
|
|
2041
2080
|
ai = o2(oi);
|
|
2042
|
-
si =
|
|
2043
|
-
|
|
2044
|
-
ci
|
|
2045
|
-
li =
|
|
2046
|
-
di =
|
|
2081
|
+
si = o2(ri);
|
|
2082
|
+
ci = {};
|
|
2083
|
+
t3(ci, { ConfigSchema: () => li, PartialConfigSchema: () => di, configJsonSchema: () => pi, partialConfigJsonSchema: () => ui });
|
|
2084
|
+
li = n3.object({ settings: n3.unknown().meta({ id: "StoreSettings", title: "Store.Settings", description: "Implementation-specific configuration (store-defined shape)." }).describe("Implementation-specific configuration").optional(), env: n3.unknown().meta({ id: "StoreEnv", title: "Store.Env", description: "Environment dependencies (store-defined shape)." }).describe("Environment dependencies (platform-specific)").optional(), id: c.describe("Store instance identifier (defaults to store key)").optional(), logger: it.optional().describe("Logger configuration (level, handler) to override the collector defaults"), setup: n3.union([n3.boolean(), n3.record(n3.string(), n3.unknown())]).optional().describe("One-time setup options applied during store registration (boolean enables defaults, object configures specifics)") }).meta({ id: "StoreConfig", title: "Store.Config", description: "Store configuration (settings, env, logger) \u2014 key-value infrastructure component." }).describe("Store configuration");
|
|
2085
|
+
di = li.partial().meta({ id: "StorePartialConfig", title: "Store.PartialConfig", description: "Partial store configuration with all fields optional." }).describe("Partial store configuration with all fields optional");
|
|
2047
2086
|
pi = o2(li);
|
|
2048
|
-
ui =
|
|
2049
|
-
|
|
2050
|
-
mi
|
|
2051
|
-
fi = n3.record(n3.string(), n3.unknown()).meta({ id: "
|
|
2052
|
-
gi =
|
|
2053
|
-
hi =
|
|
2054
|
-
bi = n3.object({
|
|
2055
|
-
vi = n3.object({
|
|
2056
|
-
Si = n3.object({
|
|
2057
|
-
yi = n3.object({
|
|
2058
|
-
wi = n3.
|
|
2059
|
-
ki = n3.record(n3.string(),
|
|
2060
|
-
Ci = n3.record(n3.string(), n3.
|
|
2061
|
-
xi = n3.
|
|
2062
|
-
|
|
2063
|
-
|
|
2064
|
-
|
|
2065
|
-
Ii = n3.object({ package: n3.string().min(1, "Package name cannot be empty").optional().describe(
|
|
2066
|
-
Oi = n3.record(n3.string(), n3.unknown()).meta({ id: "
|
|
2067
|
-
Ji = n3.record(n3.string(),
|
|
2068
|
-
Ri = n3.record(n3.string(), Ji).meta({ id: "
|
|
2069
|
-
Mi = n3.
|
|
2070
|
-
|
|
2071
|
-
|
|
2072
|
-
zi = n3.object({
|
|
2073
|
-
Li = n3.object({
|
|
2074
|
-
|
|
2075
|
-
Bi =
|
|
2076
|
-
Ui = o2(
|
|
2077
|
-
Vi = o2(
|
|
2087
|
+
ui = o2(di);
|
|
2088
|
+
mi = {};
|
|
2089
|
+
t3(mi, { BundlePackageSchema: () => bi, BundleSchema: () => vi, CodeSchema: () => Si, ConfigSchema: () => zi, ContractActionsSchema: () => Ri, ContractEventsSchema: () => Mi, ContractRuleSchema: () => Fi, ContractSchema: () => Ti, ContractSchemaEntry: () => Ji, DestinationSchema: () => Ii, FlowSchema: () => Li, JsonSchema: () => $i, JsonSchemaSchema: () => Ci, SettingsSchema: () => gi, SourceSchema: () => Di, StepExampleSchema: () => wi, StepExamplesSchema: () => ki, StoreSchema: () => Oi, TransformerSchema: () => Ei, TriggerDescriptorSchema: () => yi, ValidateEventsSchema: () => xi, ValidateSchema: () => Pi, VariablesSchema: () => fi, configJsonSchema: () => Bi, contractJsonSchema: () => Qi, contractRuleJsonSchema: () => Ki, destinationJsonSchema: () => _i, flowConfigJsonSchema: () => Vi, flowJsonSchema: () => Ui, parseConfig: () => qi, parseFlow: () => Ni, safeParseConfig: () => Ai, safeParseFlow: () => Wi, sourceJsonSchema: () => Hi, storeJsonSchema: () => Gi, transformerJsonSchema: () => Zi, validateEventsJsonSchema: () => Yi, validateJsonSchema: () => Xi });
|
|
2090
|
+
fi = n3.record(n3.string(), n3.unknown()).meta({ id: "FlowVariables", title: "Flow.Variables", description: "Reusable values referenced via $var.name (with optional deep paths). Whole-string refs preserve native type; inline interpolation requires scalars." });
|
|
2091
|
+
gi = n3.record(n3.string(), n3.unknown()).meta({ id: "FlowSettings", title: "Flow.Settings", description: "Free-form key-value settings consumed by the platform runtime." }).describe("Free-form platform settings bag");
|
|
2092
|
+
hi = /^(@[a-z0-9\-~][a-z0-9\-._~]*\/)?[a-z0-9\-~][a-z0-9\-._~]*$/;
|
|
2093
|
+
bi = 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)." });
|
|
2094
|
+
vi = n3.object({ packages: n3.record(n3.string().regex(hi, "Invalid npm package name"), bi).optional().describe("NPM packages to bundle, keyed by package name"), overrides: n3.record(n3.string().regex(hi, "Invalid npm package name"), n3.string().min(1, "Override version cannot be empty")).optional().describe("Transitive dependency version pins"), traceInclude: n3.array(n3.string()).optional().describe("Extra paths or globs the bundler must include in the trace output (server flows only)") }).strict().meta({ id: "FlowBundle", title: "Flow.Bundle", description: "Bundle configuration (packages + overrides + traceInclude)." }).describe("Bundle configuration (packages + overrides + traceInclude)");
|
|
2095
|
+
Si = 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 (object form) for custom sources / transformers / destinations / stores. Use `import` on the step to select a named export from a package." }).describe("Inline code for custom components (object form)");
|
|
2096
|
+
yi = 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." });
|
|
2097
|
+
wi = 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: yi.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");
|
|
2098
|
+
ki = n3.record(n3.string(), wi).meta({ id: "FlowStepExamples", title: "Flow.StepExamples", description: "Named step examples keyed by scenario name." }).describe("Named step examples for testing and documentation");
|
|
2099
|
+
Ci = n3.record(n3.string(), n3.unknown()).meta({ id: "JsonSchema", title: "JsonSchema", description: "Structural JSON Schema fragment (Record<string, unknown>)" });
|
|
2100
|
+
xi = n3.record(n3.string(), n3.record(n3.string(), Ci)).meta({ id: "ValidateEvents", title: "ValidateEvents", description: "Entity-action keyed JSON Schemas" }).describe("Entity-action keyed JSON Schemas");
|
|
2101
|
+
Pi = n3.object({ format: n3.boolean().optional().describe("Validate event structure against the standard event format"), events: xi.optional().describe("Per entity-action JSON Schemas to validate matching events against"), schema: Ci.optional().describe("A single JSON Schema applied to every event this step handles") }).meta({ id: "Validate", title: "Validate", description: "Step-level validation: { format?, events?, schema? }" });
|
|
2102
|
+
Di = 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: Si.optional().describe("Inline code definition (object form). For a named export from a package, use `import` instead."), import: n3.string().regex(/^[A-Za-z_$][A-Za-z0-9_$]*$/, "import must be a valid JavaScript identifier").optional().describe("Named export from `package` to import as this step's implementation. Top-level identifier only. Requires `package`. Mutually exclusive with `code`."), config: n3.looseObject({ setup: n3.union([n3.boolean(), n3.record(n3.string(), n3.unknown())]).optional().describe("One-time setup options applied during source registration (boolean enables defaults, object configures specifics)") }).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: fi.optional().describe("Source-level variables (highest priority in cascade)"), next: We3.optional().describe("Pre-collector transformer chain. String, string[], or Route[] for conditional routing based on ingest data."), before: We3.optional().describe("Pre-source transformer chain (consent-exempt). Handles transport-level preprocessing."), examples: ki.optional().describe("Named step examples for testing and documentation (stripped during bundling)"), cache: Ge2.optional().describe("Cache configuration for this source (match \u2192 key \u2192 ttl rules)"), validate: Pi.optional() }).meta({ id: "FlowSource", title: "Flow.Source", description: "Source package reference with configuration, env, chains, and examples." }).describe("Source package reference with configuration").superRefine(ji);
|
|
2103
|
+
Ei = 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: Si.optional().describe("Inline code definition (object form). For a named export from a package, use `import` instead."), import: n3.string().regex(/^[A-Za-z_$][A-Za-z0-9_$]*$/, "import must be a valid JavaScript identifier").optional().describe("Named export from `package` to import as this step's implementation. Top-level identifier only. Requires `package`. Mutually exclusive with `code`."), 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: We3.optional().describe("Pre-transformer chain. Runs before this transformer push function."), next: We3.optional().describe("Next transformer in chain. String, string[], or Route[] for conditional routing."), variables: fi.optional().describe("Transformer-level variables (highest priority in cascade)"), examples: ki.optional().describe("Named step examples for testing and documentation (stripped during bundling)"), cache: Ge2.optional().describe("Cache configuration for this transformer (match \u2192 key \u2192 ttl rules)"), validate: Pi.optional() }).meta({ id: "FlowTransformer", title: "Flow.Transformer", description: "Transformer package reference with configuration, env, chains, and cache." }).describe("Transformer package reference with configuration").superRefine(ji);
|
|
2104
|
+
Ii = 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: Si.optional().describe("Inline code definition (object form). For a named export from a package, use `import` instead."), import: n3.string().regex(/^[A-Za-z_$][A-Za-z0-9_$]*$/, "import must be a valid JavaScript identifier").optional().describe("Named export from `package` to import as this step's implementation. Top-level identifier only. Requires `package`. Mutually exclusive with `code`."), config: n3.looseObject({ setup: n3.union([n3.boolean(), n3.record(n3.string(), n3.unknown())]).optional().describe("One-time setup options applied during destination registration (boolean enables defaults, object configures specifics)") }).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: fi.optional().describe("Destination-level variables (highest priority in cascade)"), before: He3.optional().describe("Post-collector transformer chain. String, string[], or Route[] for conditional routing. `many` is not valid here \u2014 use multiple destinations for post-collector fan-out."), next: He3.optional().describe("Post-push transformer chain. Push response available at context.ingest._response. `many` is not valid here \u2014 use multiple destinations for post-collector fan-out."), examples: ki.optional().describe("Named step examples for testing and documentation (stripped during bundling)"), cache: Ge2.optional().describe("Cache configuration for this destination (match \u2192 key \u2192 ttl rules)"), validate: Pi.optional() }).meta({ id: "FlowDestination", title: "Flow.Destination", description: "Destination package reference with configuration, env, chains, and cache." }).describe("Destination package reference with configuration").superRefine(ji);
|
|
2105
|
+
Oi = n3.object({ package: n3.string().min(1, "Package name cannot be empty").optional().describe("Store package specifier with optional version"), code: Si.optional().describe("Inline code definition (object form). For a named export from a package, use `import` instead."), import: n3.string().regex(/^[A-Za-z_$][A-Za-z0-9_$]*$/, "import must be a valid JavaScript identifier").optional().describe("Named export from `package` to import as this step's implementation. Top-level identifier only. Requires `package`. Mutually exclusive with `code`."), config: n3.looseObject({ setup: n3.union([n3.boolean(), n3.record(n3.string(), n3.unknown())]).optional().describe("One-time setup options applied during store registration (boolean enables defaults, object configures specifics)") }).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"), cache: Qe.optional().describe("Cache configuration for this store (TTL-only rules, optional recursive `cache.store`)"), variables: fi.optional().describe("Store-level variables (highest priority in cascade)"), examples: ki.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, cache, and examples." }).describe("Store package reference with configuration").superRefine(ji);
|
|
2106
|
+
Ji = 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");
|
|
2107
|
+
Ri = n3.record(n3.string(), Ji).meta({ id: "FlowContractActions", title: "Flow.ContractActions", description: "Action-level contract entries keyed by action name." }).describe("Action-level contract entries");
|
|
2108
|
+
Mi = n3.record(n3.string(), Ri).meta({ id: "FlowContractEvents", title: "Flow.ContractEvents", description: "Entity-action event schemas (entity \u2192 action \u2192 schema)." }).describe("Entity-action event schemas");
|
|
2109
|
+
Fi = n3.object({ extend: n3.string().optional(), tagging: n3.number().optional(), description: n3.string().optional(), events: xi.optional(), schema: Ci.optional() }).meta({ id: "ContractRule", title: "Flow.ContractRule", description: "Named contract entry" });
|
|
2110
|
+
Ti = n3.record(n3.string(), Fi).meta({ id: "FlowContract", title: "Flow.Contract", description: "Named contracts map with optional extend inheritance." }).describe("Named contracts with optional extend inheritance");
|
|
2111
|
+
zi = 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: gi.optional().describe("Free-form key-value settings consumed by the platform runtime."), bundle: vi.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");
|
|
2112
|
+
Li = n3.object({ config: zi.optional().describe("Per-flow configuration: platform, url, settings, bundle."), sources: n3.record(n3.string(), Di).optional().describe("Source configurations (data capture) keyed by unique identifier"), destinations: n3.record(n3.string(), Ii).optional().describe("Destination configurations (data output) keyed by unique identifier"), transformers: n3.record(n3.string(), Ei).optional().describe("Transformer configurations (event transformation) keyed by unique identifier"), stores: n3.record(n3.string(), Oi).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: fi.optional().describe("Flow-level variables (override root variables, overridden by source/destination variables)") }).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");
|
|
2113
|
+
$i = 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: fi.optional().describe("Shared variables for interpolation across all flows (use $var.name syntax, deep paths supported)"), contract: Ti.optional().describe("Named contracts with extend inheritance and dot-path references"), flows: n3.record(n3.string(), Li).refine((e4) => Object.keys(e4).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, contract, named flows." }).describe("walkerOS root configuration (walkeros.config.json)");
|
|
2114
|
+
Bi = n3.toJSONSchema($i, { target: "draft-7" });
|
|
2115
|
+
Ui = o2(Li);
|
|
2116
|
+
Vi = o2(zi);
|
|
2078
2117
|
Hi = o2(Di);
|
|
2079
|
-
_i = o2(
|
|
2080
|
-
Zi = o2(
|
|
2081
|
-
Gi = o2(
|
|
2082
|
-
Ki = o2(
|
|
2083
|
-
Qi = o2(
|
|
2084
|
-
Xi = o2(
|
|
2085
|
-
|
|
2086
|
-
tn =
|
|
2087
|
-
nn =
|
|
2088
|
-
on =
|
|
2089
|
-
|
|
2090
|
-
sn = /\$
|
|
2091
|
-
cn = /\$
|
|
2092
|
-
ln = /\$
|
|
2093
|
-
|
|
2118
|
+
_i = o2(Ii);
|
|
2119
|
+
Zi = o2(Ei);
|
|
2120
|
+
Gi = o2(Oi);
|
|
2121
|
+
Ki = o2(Fi);
|
|
2122
|
+
Qi = o2(Ti);
|
|
2123
|
+
Xi = o2(Pi);
|
|
2124
|
+
Yi = o2(xi);
|
|
2125
|
+
tn = en.object({ lang: en.string().optional().describe("Language identifier (e.g. json, sql, bash, typescript)"), code: en.string().describe("Code snippet") });
|
|
2126
|
+
nn = en.object({ text: en.string().describe("Short actionable hint text focused on walkerOS usage"), code: en.array(tn).optional().describe("Optional code snippets") });
|
|
2127
|
+
on = en.record(en.string(), nn).describe("Keyed hints for AI consumption \u2014 lightweight context beyond schemas and examples");
|
|
2128
|
+
rn = n3.object({ param: n3.string().describe("Lowercase URL parameter name. Match is case-insensitive on lookup."), platform: n3.string().describe("Canonical platform identifier (lowercase, kebab-case).") });
|
|
2129
|
+
sn = /\$store\.([a-zA-Z_][a-zA-Z0-9_]*)/g;
|
|
2130
|
+
cn = /\$env\.([A-Za-z_]\w*)(=[^"}\s]*)?/g;
|
|
2131
|
+
ln = /\$flow\.([a-zA-Z_][a-zA-Z0-9_]*)(?:\.([a-zA-Z0-9_.]+))?/g;
|
|
2132
|
+
dn = /\$(var|store|flow|secret):([a-zA-Z_][a-zA-Z0-9_]*)/g;
|
|
2133
|
+
xn = { source: Bt2.configJsonSchema, destination: Re3.configJsonSchema };
|
|
2094
2134
|
}
|
|
2095
2135
|
});
|
|
2096
2136
|
|
|
@@ -2183,7 +2223,7 @@ var init_event_validation = __esm({
|
|
|
2183
2223
|
"src/core/event-validation.ts"() {
|
|
2184
2224
|
"use strict";
|
|
2185
2225
|
init_dev();
|
|
2186
|
-
({ PartialEventSchema } =
|
|
2226
|
+
({ PartialEventSchema } = i2);
|
|
2187
2227
|
}
|
|
2188
2228
|
});
|
|
2189
2229
|
|
|
@@ -2287,7 +2327,7 @@ var init_validators = __esm({
|
|
|
2287
2327
|
"use strict";
|
|
2288
2328
|
init_dist();
|
|
2289
2329
|
init_dev();
|
|
2290
|
-
({ safeParseConfig } =
|
|
2330
|
+
({ safeParseConfig } = i2);
|
|
2291
2331
|
}
|
|
2292
2332
|
});
|
|
2293
2333
|
|
|
@@ -2335,15 +2375,15 @@ function loadBundleConfig(rawConfig, options) {
|
|
|
2335
2375
|
const config = validateFlowConfig(sanitized);
|
|
2336
2376
|
const availableFlows = getAvailableFlows(config);
|
|
2337
2377
|
const flowName = resolveFlow(config, options.flowName, availableFlows);
|
|
2338
|
-
let flowSettings =
|
|
2339
|
-
const platform =
|
|
2378
|
+
let flowSettings = Q(config, flowName, { deferred: true });
|
|
2379
|
+
const platform = ee(flowSettings);
|
|
2340
2380
|
if (!platform) {
|
|
2341
2381
|
throw new Error(
|
|
2342
2382
|
`Invalid configuration: flow "${flowName}" must have config.platform set to "web" or "server".`
|
|
2343
2383
|
);
|
|
2344
2384
|
}
|
|
2345
2385
|
if (platform === "web") {
|
|
2346
|
-
flowSettings =
|
|
2386
|
+
flowSettings = Q(config, flowName);
|
|
2347
2387
|
}
|
|
2348
2388
|
const buildDefaults = getBuildDefaults(platform);
|
|
2349
2389
|
const bundle2 = flowSettings.config?.bundle;
|
|
@@ -2526,10 +2566,10 @@ async function getPackageCacheKey(packageName, version, date) {
|
|
|
2526
2566
|
if (isMutableVersion(version)) {
|
|
2527
2567
|
const dateStr = date ?? getTodayDate();
|
|
2528
2568
|
const input2 = `${safeName}@${version}:${dateStr}`;
|
|
2529
|
-
return
|
|
2569
|
+
return i(input2, HASH_LENGTH);
|
|
2530
2570
|
}
|
|
2531
2571
|
const input = `${safeName}@${version}`;
|
|
2532
|
-
return
|
|
2572
|
+
return i(input, HASH_LENGTH);
|
|
2533
2573
|
}
|
|
2534
2574
|
function normalizeJson(content) {
|
|
2535
2575
|
const parsed = JSON.parse(content);
|
|
@@ -2539,7 +2579,7 @@ async function getFlowSettingsCacheKey(content, date) {
|
|
|
2539
2579
|
const dateStr = date ?? getTodayDate();
|
|
2540
2580
|
const normalized = normalizeJson(content);
|
|
2541
2581
|
const input = `${normalized}:${dateStr}`;
|
|
2542
|
-
return
|
|
2582
|
+
return i(input, HASH_LENGTH);
|
|
2543
2583
|
}
|
|
2544
2584
|
var HASH_LENGTH;
|
|
2545
2585
|
var init_cache_utils = __esm({
|
|
@@ -2806,8 +2846,8 @@ async function resolveVersionConflicts(allSpecs, logger, npmConfig = {}) {
|
|
|
2806
2846
|
if (uniqueExact.length > 1) {
|
|
2807
2847
|
const sorted = [...uniqueExact].sort(semver2.rcompare);
|
|
2808
2848
|
chosenVersion = sorted[0];
|
|
2809
|
-
for (let
|
|
2810
|
-
const loserVersion = sorted[
|
|
2849
|
+
for (let i3 = 1; i3 < sorted.length; i3++) {
|
|
2850
|
+
const loserVersion = sorted[i3];
|
|
2811
2851
|
const consumers = activeSpecs.filter((s5) => s5.spec === loserVersion).map((s5) => s5.from);
|
|
2812
2852
|
nested.push({ name, version: loserVersion, consumers });
|
|
2813
2853
|
alreadyNested.add(loserVersion);
|
|
@@ -3278,7 +3318,7 @@ async function computeCodeCacheKey(codeContent, inputs) {
|
|
|
3278
3318
|
const keyMaterial = `${codeContent}
|
|
3279
3319
|
###
|
|
3280
3320
|
${serializeKeyInputs(inputs)}`;
|
|
3281
|
-
return
|
|
3321
|
+
return i(keyMaterial, 12);
|
|
3282
3322
|
}
|
|
3283
3323
|
async function getBuildCachePath(configContent, tmpDir) {
|
|
3284
3324
|
const cacheDir = getTmpPath(tmpDir, "cache", "builds");
|
|
@@ -3363,7 +3403,7 @@ function hasCodeReference(code) {
|
|
|
3363
3403
|
}
|
|
3364
3404
|
function validateReference(type, name, ref) {
|
|
3365
3405
|
if (type === "Transformer") {
|
|
3366
|
-
const r4 =
|
|
3406
|
+
const r4 = Jt({ ...ref }, "Transformer");
|
|
3367
3407
|
if (!r4.ok) {
|
|
3368
3408
|
throw new Error(`Transformer "${name}": ${r4.reason ?? "invalid entry."}`);
|
|
3369
3409
|
}
|
|
@@ -3473,7 +3513,7 @@ async function bundleCore(flowSettings, buildOptions, logger, showStats = false)
|
|
|
3473
3513
|
for (const pkg of stepPackages) {
|
|
3474
3514
|
const isLocalPath = pkg.startsWith(".") || pkg.startsWith("/");
|
|
3475
3515
|
if (isLocalPath) {
|
|
3476
|
-
const varName =
|
|
3516
|
+
const varName = Y(pkg);
|
|
3477
3517
|
if (!buildOptions.packages[varName]) {
|
|
3478
3518
|
buildOptions.packages[varName] = {
|
|
3479
3519
|
path: pkg
|
|
@@ -3555,7 +3595,7 @@ async function bundleCore(flowSettings, buildOptions, logger, showStats = false)
|
|
|
3555
3595
|
await assertConsumerDepsSatisfied(TEMP_DIR, logger);
|
|
3556
3596
|
}
|
|
3557
3597
|
const sortedVersions = [...resolutionResult.topLevel.entries()].sort(([a4], [b3]) => a4.localeCompare(b3)).map(([name, p2]) => `${name}@${p2.version}`);
|
|
3558
|
-
const versionsHash = await
|
|
3598
|
+
const versionsHash = await i(sortedVersions.join("\n"), 12);
|
|
3559
3599
|
const expectedTopLevelPackages = Object.keys(buildOptions.packages).filter(
|
|
3560
3600
|
(name) => !name.startsWith(".") && !name.startsWith("/")
|
|
3561
3601
|
);
|
|
@@ -3975,7 +4015,7 @@ async function generateImportStatements(packages, destinationPackages, sourcePac
|
|
|
3975
4015
|
const hasNamed = namedImports.has(packageName);
|
|
3976
4016
|
const namedImportsToGenerate = [];
|
|
3977
4017
|
if (isUsedByDestOrSource && !hasNamed) {
|
|
3978
|
-
const varName =
|
|
4018
|
+
const varName = Y(packageName);
|
|
3979
4019
|
importStatements.push(`import ${varName} from '${packageName}';`);
|
|
3980
4020
|
}
|
|
3981
4021
|
if (hasNamed) {
|
|
@@ -4017,7 +4057,7 @@ async function generateImportStatements(packages, destinationPackages, sourcePac
|
|
|
4017
4057
|
const pkgJson = await fs11.readJSON(pkgJsonPath);
|
|
4018
4058
|
const exports = pkgJson.exports;
|
|
4019
4059
|
if (exports && typeof exports === "object" && "./dev" in exports) {
|
|
4020
|
-
const varName = `__dev_${
|
|
4060
|
+
const varName = `__dev_${Y(packageName)}`;
|
|
4021
4061
|
importStatements.push(
|
|
4022
4062
|
`import * as ${varName} from '${packageName}/dev';`
|
|
4023
4063
|
);
|
|
@@ -4161,7 +4201,7 @@ function buildSplitConfigObject(flowSettings, namedImports) {
|
|
|
4161
4201
|
if (typeof step.import === "string" && step.package) {
|
|
4162
4202
|
return step.import;
|
|
4163
4203
|
}
|
|
4164
|
-
return
|
|
4204
|
+
return Y(step.package);
|
|
4165
4205
|
}
|
|
4166
4206
|
function getStepProps(step) {
|
|
4167
4207
|
const props = {};
|
|
@@ -4216,12 +4256,12 @@ function buildSplitConfigObject(flowSettings, namedImports) {
|
|
|
4216
4256
|
return buildSplitStepEntry("destinations", key, dest);
|
|
4217
4257
|
});
|
|
4218
4258
|
const transformersEntries = Object.entries(transformers).filter(
|
|
4219
|
-
([, transformer]) => transformer.package || hasCodeReference(transformer.code) ||
|
|
4259
|
+
([, transformer]) => transformer.package || hasCodeReference(transformer.code) || Gt({ ...transformer }, "Transformer")
|
|
4220
4260
|
).map(([key, transformer]) => {
|
|
4221
4261
|
if (isInlineCode(transformer.code)) {
|
|
4222
4262
|
return ` ${key}: ${generateInlineCode(transformer.code, transformer.config || {}, transformer.env, { before: transformer.before, next: transformer.next })}`;
|
|
4223
4263
|
}
|
|
4224
|
-
if (
|
|
4264
|
+
if (Gt({ ...transformer }, "Transformer")) {
|
|
4225
4265
|
const chainLines = [];
|
|
4226
4266
|
if (transformer.before !== void 0) {
|
|
4227
4267
|
chainLines.push(`before: ${JSON.stringify(transformer.before)}`);
|
|
@@ -4417,7 +4457,7 @@ function serializeWithCode(value, indent) {
|
|
|
4417
4457
|
if (value.startsWith("$code:")) {
|
|
4418
4458
|
return value.slice(6);
|
|
4419
4459
|
}
|
|
4420
|
-
const esc =
|
|
4460
|
+
const esc = B.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
4421
4461
|
const markerRe = new RegExp(
|
|
4422
4462
|
esc + "([a-zA-Z_][a-zA-Z0-9_]*)(?::((?:(?!" + esc + `)[^\\s"'])*))?`,
|
|
4423
4463
|
"g"
|
|
@@ -5304,9 +5344,9 @@ function formatPreviewCreated(preview, options) {
|
|
|
5304
5344
|
let stdoutLast;
|
|
5305
5345
|
let deactivationUrl = null;
|
|
5306
5346
|
if (options.url) {
|
|
5307
|
-
const
|
|
5308
|
-
|
|
5309
|
-
stdoutLast =
|
|
5347
|
+
const u3 = new URL(options.url);
|
|
5348
|
+
u3.searchParams.set("elbPreview", preview.token);
|
|
5349
|
+
stdoutLast = u3.toString();
|
|
5310
5350
|
const off = new URL(options.url);
|
|
5311
5351
|
off.searchParams.set("elbPreview", "off");
|
|
5312
5352
|
deactivationUrl = off.toString();
|
|
@@ -5398,16 +5438,19 @@ function s2(e4, t4) {
|
|
|
5398
5438
|
const n4 = {};
|
|
5399
5439
|
return Object.entries(t4).forEach(([e5, t5]) => {
|
|
5400
5440
|
n4[e5] = !!t5;
|
|
5401
|
-
}), e4.consent =
|
|
5441
|
+
}), e4.consent = ne(e4.consent, n4), { update: n4 };
|
|
5402
5442
|
}
|
|
5403
|
-
function
|
|
5443
|
+
function D2(e4, t4) {
|
|
5404
5444
|
const n4 = e4.status.startedAt;
|
|
5405
5445
|
return { flowId: "default", stepId: t4.stepId, stepType: t4.stepType, phase: t4.phase, eventId: t4.eventId, timestamp: new Date(t4.now).toISOString(), elapsedMs: t4.now - n4 };
|
|
5406
5446
|
}
|
|
5407
|
-
function
|
|
5447
|
+
function ce(e4, t4) {
|
|
5408
5448
|
return e4.storeId && t4.stores[e4.storeId] ? t4.stores[e4.storeId] : t4.stores.__cache;
|
|
5409
5449
|
}
|
|
5410
|
-
function
|
|
5450
|
+
function ue2(e4, t4) {
|
|
5451
|
+
return e4 ? t4.stores[e4] : t4.stores.__cache;
|
|
5452
|
+
}
|
|
5453
|
+
function de2(e4) {
|
|
5411
5454
|
const t4 = {};
|
|
5412
5455
|
for (const [n4, o3] of Object.entries(e4)) {
|
|
5413
5456
|
const e5 = o3.config?.next;
|
|
@@ -5415,11 +5458,11 @@ function oe(e4) {
|
|
|
5415
5458
|
}
|
|
5416
5459
|
return t4;
|
|
5417
5460
|
}
|
|
5418
|
-
function
|
|
5461
|
+
function le2(e4, t4) {
|
|
5419
5462
|
const n4 = e4.config || {}, o3 = e4[t4];
|
|
5420
5463
|
return void 0 !== o3 ? { config: { ...n4, [t4]: o3 }, chainValue: o3 } : { config: n4, chainValue: void 0 };
|
|
5421
5464
|
}
|
|
5422
|
-
function
|
|
5465
|
+
function fe2(e4, t4 = {}) {
|
|
5423
5466
|
if (!e4) return [];
|
|
5424
5467
|
if (Array.isArray(e4)) return e4;
|
|
5425
5468
|
const n4 = [], o3 = /* @__PURE__ */ new Set();
|
|
@@ -5435,35 +5478,35 @@ function re2(e4, t4 = {}) {
|
|
|
5435
5478
|
}
|
|
5436
5479
|
return n4;
|
|
5437
5480
|
}
|
|
5438
|
-
async function
|
|
5481
|
+
async function pe2(e4, t4, n4) {
|
|
5439
5482
|
if (t4.init && !t4.config.init) {
|
|
5440
|
-
const o3 = t4.type || "unknown", s5 = e4.logger.scope(`transformer:${o3}`), r4 = { collector: e4, logger: s5, id: n4, ingest: E(n4), config: t4.config, env:
|
|
5483
|
+
const o3 = t4.type || "unknown", s5 = e4.logger.scope(`transformer:${o3}`), r4 = { collector: e4, logger: s5, id: n4, ingest: E(n4), config: t4.config, env: ye2(t4.config.env) };
|
|
5441
5484
|
s5.debug("init");
|
|
5442
|
-
const a4 = await
|
|
5485
|
+
const a4 = await at(t4.init, "TransformerInit", e4.hooks, e4.logger)(r4);
|
|
5443
5486
|
if (false === a4) return false;
|
|
5444
5487
|
t4.config = { ...a4 || t4.config, env: a4?.env || t4.config.env, init: true }, s5.debug("init done");
|
|
5445
5488
|
}
|
|
5446
5489
|
return true;
|
|
5447
5490
|
}
|
|
5448
|
-
async function
|
|
5449
|
-
const a4 = t4.type || "unknown",
|
|
5450
|
-
|
|
5451
|
-
const
|
|
5452
|
-
|
|
5491
|
+
async function ge2(e4, t4, n4, o3, s5, r4) {
|
|
5492
|
+
const a4 = t4.type || "unknown", i3 = e4.logger.scope(`transformer:${a4}`), c2 = { collector: e4, logger: i3, id: n4, ingest: s5, config: t4.config, env: { ...ye2(t4.config.env), ...r4 ? { respond: r4 } : {} } };
|
|
5493
|
+
i3.debug("push", { event: o3.name });
|
|
5494
|
+
const u3 = "string" == typeof o3.id ? o3.id : "", d2 = Date.now(), l2 = D2(e4, { stepId: o("transformer", n4), stepType: "transformer", phase: "in", eventId: u3, now: d2 });
|
|
5495
|
+
ft(e4, l2);
|
|
5453
5496
|
try {
|
|
5454
|
-
const s6 = await
|
|
5455
|
-
return a5.durationMs = r5 - d2, a5.outEvent = s6,
|
|
5497
|
+
const s6 = await at(t4.push, "TransformerPush", e4.hooks, e4.logger)(o3, c2), r5 = Date.now(), a5 = D2(e4, { stepId: o("transformer", n4), stepType: "transformer", phase: "out", eventId: u3, now: r5 });
|
|
5498
|
+
return a5.durationMs = r5 - d2, a5.outEvent = s6, ft(e4, a5), i3.debug("push done"), s6;
|
|
5456
5499
|
} catch (t5) {
|
|
5457
|
-
const o4 = Date.now(), s6 =
|
|
5458
|
-
throw s6.durationMs = o4 - d2, s6.error = t5 instanceof Error ? { name: t5.name, message: t5.message } : { message: String(t5) },
|
|
5500
|
+
const o4 = Date.now(), s6 = D2(e4, { stepId: o("transformer", n4), stepType: "transformer", phase: "error", eventId: u3, now: o4 });
|
|
5501
|
+
throw s6.durationMs = o4 - d2, s6.error = t5 instanceof Error ? { name: t5.name, message: t5.message } : { message: String(t5) }, ft(e4, s6), t5;
|
|
5459
5502
|
}
|
|
5460
5503
|
}
|
|
5461
|
-
function
|
|
5504
|
+
function me2(e4, t4) {
|
|
5462
5505
|
return e4 ? { ...e4, _meta: { ...e4._meta, path: [...e4._meta.path] } } : E(t4);
|
|
5463
5506
|
}
|
|
5464
|
-
async function
|
|
5507
|
+
async function he2(e4, t4, n4, o3, s5, r4, a4) {
|
|
5465
5508
|
s5 || (s5 = E(n4[0] ?? "chain")), a4 && s5._meta && (s5._meta.chainPath = a4);
|
|
5466
|
-
let
|
|
5509
|
+
let i3 = o3, c2 = r4;
|
|
5467
5510
|
for (const o4 of n4) {
|
|
5468
5511
|
const r5 = t4[o4];
|
|
5469
5512
|
if (!r5) {
|
|
@@ -5472,183 +5515,185 @@ async function ue2(e4, t4, n4, o3, s5, r4, a4) {
|
|
|
5472
5515
|
}
|
|
5473
5516
|
if (s5 && s5._meta && s5._meta.path.length > 256) return e4.logger.error(`Max path length exceeded at ${o4}`), { event: null, respond: c2 };
|
|
5474
5517
|
s5 && s5._meta && (s5._meta.hops++, s5._meta.path.push(o4));
|
|
5475
|
-
if (!await
|
|
5476
|
-
if (t5 instanceof
|
|
5518
|
+
if (!await We(pe2, (t5) => {
|
|
5519
|
+
if (t5 instanceof He) throw t5;
|
|
5477
5520
|
return e4.status.failed++, e4.logger.scope(`transformer:${r5.type || "unknown"}`).error("transformer init failed", { transformer: o4, error: t5 }), false;
|
|
5478
5521
|
})(e4, r5, o4)) return { event: null, respond: c2 };
|
|
5479
5522
|
if (a4 && void 0 !== r5.config?.chainMocks?.[a4]) {
|
|
5480
5523
|
const t5 = r5.config.chainMocks[a4];
|
|
5481
|
-
e4.logger.scope(`transformer:${r5.type || "unknown"}`).debug("chainMock", { chain: a4 }),
|
|
5524
|
+
e4.logger.scope(`transformer:${r5.type || "unknown"}`).debug("chainMock", { chain: a4 }), i3 = t5;
|
|
5482
5525
|
continue;
|
|
5483
5526
|
}
|
|
5484
5527
|
if (void 0 !== r5.config?.mock) {
|
|
5485
|
-
e4.logger.scope(`transformer:${r5.type || "unknown"}`).debug("mock"),
|
|
5528
|
+
e4.logger.scope(`transformer:${r5.type || "unknown"}`).debug("mock"), i3 = r5.config.mock;
|
|
5486
5529
|
continue;
|
|
5487
5530
|
}
|
|
5488
5531
|
if (r5.config?.disabled) continue;
|
|
5489
|
-
const
|
|
5490
|
-
let
|
|
5532
|
+
const u3 = r5.config?.cache, d2 = u3 ? Ft(u3) : void 0, l2 = d2 ? ce(d2, e4) : void 0, f3 = r5.config?.state ? Ht(r5.config.state) : void 0, p2 = f3?.filter((e5) => "get" === e5.mode), g3 = f3?.filter((e5) => "set" === e5.mode);
|
|
5533
|
+
let m3;
|
|
5491
5534
|
if (d2 && l2) {
|
|
5492
|
-
const e5 =
|
|
5535
|
+
const e5 = Dt(s5, i3), t5 = await Ut(d2, l2, e5);
|
|
5493
5536
|
if ("HIT" === t5?.status && t5.value) {
|
|
5494
|
-
if (
|
|
5537
|
+
if (i3 = t5.value, d2.stop) return { event: i3, respond: c2, stopped: true };
|
|
5495
5538
|
continue;
|
|
5496
5539
|
}
|
|
5497
|
-
"MISS" === t5?.status && (
|
|
5540
|
+
"MISS" === t5?.status && (m3 = { key: t5.key, ttl: t5.rule.ttl });
|
|
5498
5541
|
}
|
|
5499
|
-
const
|
|
5500
|
-
if (
|
|
5501
|
-
const n5 =
|
|
5542
|
+
const h3 = r5.config.before;
|
|
5543
|
+
if (h3) {
|
|
5544
|
+
const n5 = Mt(h3, Dt(s5, i3));
|
|
5502
5545
|
if (1 === n5.length) {
|
|
5503
|
-
const o5 =
|
|
5546
|
+
const o5 = fe2(n5[0], de2(t4));
|
|
5504
5547
|
if (o5.length > 0) {
|
|
5505
|
-
const n6 = await
|
|
5548
|
+
const n6 = await he2(e4, t4, o5, i3, s5, c2, a4);
|
|
5506
5549
|
if (null === n6.event) return { event: null, respond: n6.respond ?? c2 };
|
|
5507
5550
|
if (n6.stopped) return { event: Array.isArray(n6.event) ? n6.event[0] : n6.event, respond: n6.respond ?? c2, stopped: true };
|
|
5508
|
-
n6.respond && (c2 = n6.respond),
|
|
5551
|
+
n6.respond && (c2 = n6.respond), i3 = Array.isArray(n6.event) ? n6.event[0] : n6.event;
|
|
5509
5552
|
}
|
|
5510
|
-
} else n5.length > 1 && await Promise.all(n5.map((n6) =>
|
|
5511
|
-
}
|
|
5512
|
-
|
|
5513
|
-
|
|
5514
|
-
if (
|
|
5515
|
-
|
|
5516
|
-
|
|
5553
|
+
} else n5.length > 1 && await Promise.all(n5.map((n6) => We(he2, (t5) => (e4.logger.scope("transformer:many").error(`many branch ${n6} failed`, { error: t5 }), { event: null, respond: void 0 }))(e4, t4, fe2(n6, de2(t4)), i3, me2(s5, n6), void 0, a4)));
|
|
5554
|
+
}
|
|
5555
|
+
p2 && p2.length > 0 && (i3 = await Lt(p2, (t5) => ue2(t5, e4), i3, e4));
|
|
5556
|
+
const y2 = await We(ge2, (t5) => (e4.logger.scope(`transformer:${r5.type || "unknown"}`).error("Push failed", { error: t5 }), false))(e4, r5, o4, i3, s5, c2);
|
|
5557
|
+
if (false === y2) return { event: null, respond: c2 };
|
|
5558
|
+
if (Array.isArray(y2)) {
|
|
5559
|
+
const r6 = n4.slice(n4.indexOf(o4) + 1), u4 = await Promise.all(y2.map(async (n5) => {
|
|
5560
|
+
const o5 = n5.event || i3, u5 = me2(s5, "unknown");
|
|
5517
5561
|
if (n5.next) {
|
|
5518
|
-
const s6 =
|
|
5562
|
+
const s6 = Mt(n5.next, Dt(u5, o5));
|
|
5519
5563
|
if (0 === s6.length) return { event: o5, respond: c2 };
|
|
5520
5564
|
if (1 === s6.length) {
|
|
5521
|
-
const n6 =
|
|
5522
|
-
return n6.length > 0 ?
|
|
5565
|
+
const n6 = fe2(s6[0], de2(t4));
|
|
5566
|
+
return n6.length > 0 ? he2(e4, t4, n6, o5, u5, c2, a4) : { event: o5, respond: c2 };
|
|
5523
5567
|
}
|
|
5524
|
-
return (await Promise.all(s6.map((n6) =>
|
|
5568
|
+
return (await Promise.all(s6.map((n6) => We(he2, (t5) => (e4.logger.scope("transformer:many").error(`many branch ${n6} failed`, { error: t5 }), { event: null, respond: void 0 }))(e4, t4, fe2(n6, de2(t4)), o5, me2(u5, n6), void 0, a4)))).map((e5) => ({ event: e5.event, respond: void 0 }));
|
|
5525
5569
|
}
|
|
5526
|
-
return r6.length > 0 ?
|
|
5570
|
+
return r6.length > 0 ? he2(e4, t4, r6, o5, u5, c2, a4) : { event: o5, respond: c2 };
|
|
5527
5571
|
}));
|
|
5528
5572
|
let d3 = c2;
|
|
5529
5573
|
const l3 = [];
|
|
5530
|
-
for (const e5 of
|
|
5574
|
+
for (const e5 of u4.flat()) if (null !== e5) if (e5 && "object" == typeof e5 && "event" in e5) {
|
|
5531
5575
|
const t5 = e5;
|
|
5532
5576
|
if (t5.respond && (d3 = t5.respond), null === t5.event) continue;
|
|
5533
5577
|
Array.isArray(t5.event) ? l3.push(...t5.event) : l3.push(t5.event);
|
|
5534
5578
|
} else l3.push(e5);
|
|
5535
5579
|
return 0 === l3.length ? { event: null, respond: d3 } : 1 === l3.length ? { event: l3[0], respond: d3 } : { event: l3, respond: d3 };
|
|
5536
5580
|
}
|
|
5537
|
-
if (
|
|
5538
|
-
const { event: n5, respond: o5, next: r6 } =
|
|
5581
|
+
if (y2 && "object" == typeof y2) {
|
|
5582
|
+
const { event: n5, respond: o5, next: r6 } = y2;
|
|
5539
5583
|
if (o5 && (c2 = o5), void 0 !== r6) {
|
|
5540
|
-
const o6 =
|
|
5584
|
+
const o6 = Mt(r6, Dt(s5, i3));
|
|
5541
5585
|
if (0 === o6.length) {
|
|
5542
|
-
n5 && (
|
|
5586
|
+
n5 && (i3 = n5);
|
|
5543
5587
|
continue;
|
|
5544
5588
|
}
|
|
5545
5589
|
if (1 === o6.length) {
|
|
5546
|
-
const
|
|
5547
|
-
return
|
|
5590
|
+
const u4 = fe2(o6[0], de2(t4));
|
|
5591
|
+
return u4.length > 0 ? he2(e4, t4, u4, n5 || i3, s5, c2, a4) : (e4.logger.warn(`Branch target not found: ${JSON.stringify(r6)}`), { event: null, respond: c2 });
|
|
5548
5592
|
}
|
|
5549
|
-
return await Promise.all(o6.map((o7) =>
|
|
5593
|
+
return await Promise.all(o6.map((o7) => We(he2, (t5) => (e4.logger.scope("transformer:many").error(`many branch ${o7} failed`, { error: t5 }), { event: null, respond: void 0 }))(e4, t4, fe2(o7, de2(t4)), n5 || i3, me2(s5, o7), void 0, a4))), { event: null, respond: void 0 };
|
|
5550
5594
|
}
|
|
5551
|
-
n5 && (
|
|
5595
|
+
n5 && (i3 = n5);
|
|
5552
5596
|
}
|
|
5553
|
-
|
|
5554
|
-
const
|
|
5555
|
-
if ((!
|
|
5556
|
-
const n5 =
|
|
5597
|
+
g3 && g3.length > 0 && (i3 = await Lt(g3, (t5) => ue2(t5, e4), i3, e4)), m3 && l2 && Zt(l2, m3.key, i3, m3.ttl);
|
|
5598
|
+
const w3 = r5.config.next, v3 = "string" == typeof w3 || Array.isArray(w3) && w3.every((e5) => "string" == typeof e5), b3 = void 0 !== w3 && !v3;
|
|
5599
|
+
if ((!y2 || "object" == typeof y2 && !y2.next) && b3) {
|
|
5600
|
+
const n5 = Mt(r5.config.next, Dt(s5, i3));
|
|
5557
5601
|
if (1 === n5.length) {
|
|
5558
|
-
const o5 =
|
|
5559
|
-
return o5.length > 0 ?
|
|
5602
|
+
const o5 = fe2(n5[0], de2(t4));
|
|
5603
|
+
return o5.length > 0 ? he2(e4, t4, o5, i3, s5, c2, a4) : { event: i3, respond: c2 };
|
|
5560
5604
|
}
|
|
5561
|
-
return n5.length > 1 ? (await Promise.all(n5.map((n6) =>
|
|
5605
|
+
return n5.length > 1 ? (await Promise.all(n5.map((n6) => We(he2, (t5) => (e4.logger.scope("transformer:many").error(`many branch ${n6} failed`, { error: t5 }), { event: null, respond: void 0 }))(e4, t4, fe2(n6, de2(t4)), i3, me2(s5, n6), void 0, a4))), { event: null, respond: void 0 }) : { event: i3, respond: c2 };
|
|
5562
5606
|
}
|
|
5563
5607
|
}
|
|
5564
|
-
return { event:
|
|
5608
|
+
return { event: i3, respond: c2 };
|
|
5565
5609
|
}
|
|
5566
|
-
function
|
|
5567
|
-
return e4 &&
|
|
5610
|
+
function ye2(e4) {
|
|
5611
|
+
return e4 && fe(e4) ? e4 : {};
|
|
5568
5612
|
}
|
|
5569
|
-
function
|
|
5613
|
+
function we(e4) {
|
|
5570
5614
|
return "string" == typeof e4 || !(!Array.isArray(e4) || !e4.every((e5) => "string" == typeof e5));
|
|
5571
5615
|
}
|
|
5572
|
-
async function
|
|
5616
|
+
async function ve2(e4, t4, n4) {
|
|
5573
5617
|
if (!t4.on || !t4.queueOn?.length) return;
|
|
5574
5618
|
const o3 = t4.queueOn;
|
|
5575
5619
|
t4.queueOn = [];
|
|
5576
5620
|
const s5 = n4 || t4.config?.id || "unknown";
|
|
5577
|
-
for (const { type: n5, data: r4 } of o3) await
|
|
5578
|
-
if (t5 instanceof
|
|
5621
|
+
for (const { type: n5, data: r4 } of o3) await We(t4.on, (t5) => {
|
|
5622
|
+
if (t5 instanceof He) throw t5;
|
|
5579
5623
|
e4.status.failed++, e4.logger.scope("source").error("source on flush failed", { sourceId: s5, type: n5, error: t5 });
|
|
5580
5624
|
})(n5, r4);
|
|
5581
5625
|
}
|
|
5582
|
-
function
|
|
5626
|
+
function be2(e4) {
|
|
5583
5627
|
return Boolean(e4.config.init) && !e4.config.require?.length;
|
|
5584
5628
|
}
|
|
5585
|
-
async function
|
|
5586
|
-
const { code: o3, config: s5 = {}, env: r4 = {}, primary: a4, next:
|
|
5629
|
+
async function ke2(e4, t4, n4) {
|
|
5630
|
+
const { code: o3, config: s5 = {}, env: r4 = {}, primary: a4, next: i3, before: c2, cache: u3 } = n4, d2 = s5.state ?? n4.state, l2 = d2 ? Ht(d2) : void 0, f3 = u3, p2 = f3 ? Ft({ ...f3, stop: f3.stop ?? true }) : void 0, g3 = we(i3) ? fe2(i3, de2(e4.transformers)) : void 0, m3 = we(c2) ? fe2(c2, de2(e4.transformers)) : void 0, h3 = r4.push, y2 = h3 ?? e4.push, w3 = Boolean(h3), v3 = async (n5, o4, r5) => {
|
|
5587
5631
|
let a5;
|
|
5588
|
-
const
|
|
5589
|
-
const t5 =
|
|
5632
|
+
const u4 = m3 ?? (void 0 !== c2 ? (() => {
|
|
5633
|
+
const t5 = Mt(c2, Dt(r5.ingest));
|
|
5590
5634
|
if (0 === t5.length) return [];
|
|
5591
|
-
return
|
|
5635
|
+
return fe2(1 === t5.length ? t5[0] : t5, de2(e4.transformers));
|
|
5592
5636
|
})() : []);
|
|
5593
5637
|
let d3 = [n5];
|
|
5594
|
-
if (
|
|
5595
|
-
const o5 = await
|
|
5638
|
+
if (u4.length > 0 && e4.transformers && Object.keys(e4.transformers).length > 0) {
|
|
5639
|
+
const o5 = await he2(e4, e4.transformers, u4, n5, r5.ingest, r5.respond, `source.${t4}.before`);
|
|
5596
5640
|
if (null === o5.event) return { ok: true };
|
|
5597
5641
|
if (o5.stopped) return o5.respond && (r5.respond = o5.respond), { ok: true };
|
|
5598
5642
|
o5.respond && (r5.respond = o5.respond), d3 = Array.isArray(o5.event) ? o5.event : [o5.event];
|
|
5599
5643
|
}
|
|
5600
|
-
if (
|
|
5601
|
-
const t5 =
|
|
5644
|
+
if (p2) {
|
|
5645
|
+
const t5 = ce(p2, e4);
|
|
5602
5646
|
if (t5) {
|
|
5603
|
-
const n6 =
|
|
5647
|
+
const n6 = Dt(r5.ingest), o5 = await Ut(p2, t5, n6);
|
|
5604
5648
|
if (o5) {
|
|
5605
|
-
if ("HIT" === o5.status && void 0 !== o5.value &&
|
|
5649
|
+
if ("HIT" === o5.status && void 0 !== o5.value && p2.stop) {
|
|
5606
5650
|
let t6 = o5.value;
|
|
5607
|
-
return o5.rule.update && (t6 = await
|
|
5651
|
+
return o5.rule.update && (t6 = await Wt(t6, o5.rule.update, { ...n6, cache: { status: "HIT" } }, e4)), r5.respond?.(t6), { ok: true };
|
|
5608
5652
|
}
|
|
5609
|
-
if ("MISS" === o5.status &&
|
|
5610
|
-
const s6 = r5.respond,
|
|
5611
|
-
|
|
5612
|
-
const t6 = await
|
|
5653
|
+
if ("MISS" === o5.status && p2.stop && r5.respond) {
|
|
5654
|
+
const s6 = r5.respond, i4 = o5.rule.update, c3 = { ...n6, cache: { status: "MISS" } }, u5 = o5.key, d4 = o5.rule.ttl, l3 = (n7) => {
|
|
5655
|
+
Zt(t5, u5, n7, d4), i4 ? a5 = (async () => {
|
|
5656
|
+
const t6 = await Wt(n7, i4, c3, e4);
|
|
5613
5657
|
s6(t6);
|
|
5614
5658
|
})() : s6(n7);
|
|
5615
5659
|
};
|
|
5616
5660
|
r5.respond = l3;
|
|
5617
5661
|
}
|
|
5618
|
-
"MISS" !== o5.status ||
|
|
5662
|
+
"MISS" !== o5.status || p2.stop || Zt(t5, o5.key, true, o5.rule.ttl);
|
|
5619
5663
|
}
|
|
5620
5664
|
}
|
|
5621
5665
|
}
|
|
5622
|
-
const
|
|
5623
|
-
const t5 =
|
|
5624
|
-
return 0 === t5.length ? { kind: "single", preChain: [] } : 1 === t5.length ? { kind: "single", preChain:
|
|
5666
|
+
const f4 = g3 ? { kind: "single", preChain: g3 } : void 0 !== i3 ? (() => {
|
|
5667
|
+
const t5 = Mt(i3, Dt(r5.ingest));
|
|
5668
|
+
return 0 === t5.length ? { kind: "single", preChain: [] } : 1 === t5.length ? { kind: "single", preChain: fe2(t5[0], de2(e4.transformers)) } : { kind: "many", branches: t5.map((t6) => fe2(t6, de2(e4.transformers))) };
|
|
5625
5669
|
})() : { kind: "single", preChain: [] };
|
|
5626
|
-
|
|
5627
|
-
|
|
5628
|
-
|
|
5629
|
-
|
|
5670
|
+
l2 && l2.length > 0 && (d3 = await Promise.all(d3.map((t5) => Lt(l2, (t6) => ue2(t6, e4), t5, e4))));
|
|
5671
|
+
let h4 = { ok: true };
|
|
5672
|
+
for (const n6 of d3) "many" === f4.kind ? (await Promise.all(f4.branches.map((a6, i4) => We(async () => w3 ? y2(n6) : y2(n6, { ...o4, id: t4, ingest: me2(r5.ingest, `${t4}.${i4}`), respond: void 0, mapping: s5, preChain: a6 }), (t5) => (e4.logger.scope("source:many").error(`many branch ${i4} failed`, { error: t5 }), { ok: true }))())), h4 = { ok: true }) : h4 = w3 ? await y2(n6) : await y2(n6, { ...o4, id: t4, ingest: r5.ingest, respond: r5.respond, mapping: s5, preChain: f4.preChain });
|
|
5673
|
+
return a5 && await a5, h4;
|
|
5674
|
+
}, b3 = async (n5) => {
|
|
5630
5675
|
const o4 = E(t4);
|
|
5631
5676
|
if (!s5.ingest || void 0 === n5) return o4;
|
|
5632
|
-
const r5 = await
|
|
5677
|
+
const r5 = await Ke(n5, s5.ingest, { collector: e4 });
|
|
5633
5678
|
return { ...o4, ...r5, _meta: o4._meta };
|
|
5634
|
-
},
|
|
5679
|
+
}, k2 = e4.logger.scope("source").scope(t4), C3 = { command: e4.command, sources: e4.sources, elb: e4.sources.elb.push, logger: k2, ...r4, push: async (e5, n5 = {}) => {
|
|
5635
5680
|
const o4 = { ingest: E(t4), respond: void 0 };
|
|
5636
|
-
return
|
|
5637
|
-
} },
|
|
5638
|
-
const o4 = { ingest: await
|
|
5639
|
-
return n5({ ...
|
|
5640
|
-
} },
|
|
5641
|
-
if (n5 instanceof
|
|
5681
|
+
return v3(e5, n5, o4);
|
|
5682
|
+
} }, I3 = { collector: e4, logger: k2, id: t4, config: s5, env: C3, withScope: async (e5, t5, n5) => {
|
|
5683
|
+
const o4 = { ingest: await b3(e5), respond: t5 };
|
|
5684
|
+
return n5({ ...C3, push: (e6, t6 = {}) => v3(e6, t6, o4), ingest: o4.ingest, respond: o4.respond });
|
|
5685
|
+
} }, q3 = await We(o3, (n5) => {
|
|
5686
|
+
if (n5 instanceof He) throw n5;
|
|
5642
5687
|
e4.status.failed++, e4.logger.scope("source").error("source factory failed", { sourceId: t4, error: n5 });
|
|
5643
|
-
})(
|
|
5644
|
-
if (!
|
|
5645
|
-
const
|
|
5646
|
-
return
|
|
5688
|
+
})(I3);
|
|
5689
|
+
if (!q3) return;
|
|
5690
|
+
const x2 = q3.type || "unknown", O2 = e4.logger.scope(x2).scope(t4);
|
|
5691
|
+
return C3.logger = O2, a4 && (q3.config = { ...q3.config, primary: a4 }), q3;
|
|
5647
5692
|
}
|
|
5648
|
-
async function
|
|
5693
|
+
async function Ce(e4, t4 = {}) {
|
|
5649
5694
|
const n4 = {};
|
|
5650
5695
|
for (const [o3, s5] of Object.entries(t4)) {
|
|
5651
|
-
const t5 = await
|
|
5696
|
+
const t5 = await ke2(e4, o3, s5);
|
|
5652
5697
|
if (!t5) continue;
|
|
5653
5698
|
const r4 = s5.config?.require;
|
|
5654
5699
|
t5.config = { ...t5.config, init: false, ...r4 ? { require: [...r4] } : {} }, n4[o3] = t5;
|
|
@@ -5657,32 +5702,32 @@ async function me2(e4, t4 = {}) {
|
|
|
5657
5702
|
for (const t5 of Object.keys(n4)) {
|
|
5658
5703
|
const n5 = e4.sources[t5];
|
|
5659
5704
|
let o3 = false;
|
|
5660
|
-
n5.init && await
|
|
5661
|
-
if (n6 instanceof
|
|
5705
|
+
n5.init && await We(n5.init.bind(n5), (n6) => {
|
|
5706
|
+
if (n6 instanceof He) throw n6;
|
|
5662
5707
|
o3 = true, e4.status.failed++, e4.logger.scope("source").error("source init failed", { sourceId: t5, error: n6 });
|
|
5663
|
-
})(), o3 || (n5.config.init = true,
|
|
5708
|
+
})(), o3 || (n5.config.init = true, be2(n5) && await ve2(e4, n5, t5));
|
|
5664
5709
|
}
|
|
5665
5710
|
return n4;
|
|
5666
5711
|
}
|
|
5667
|
-
function
|
|
5668
|
-
if (n4 instanceof
|
|
5712
|
+
function Ie2(e4, t4, n4, o3) {
|
|
5713
|
+
if (n4 instanceof He) throw n4;
|
|
5669
5714
|
e4.logger.scope("on").error("on callback failed", { kind: t4, ...o3, error: n4 });
|
|
5670
5715
|
}
|
|
5671
|
-
function
|
|
5716
|
+
function qe2(e4, t4) {
|
|
5672
5717
|
return { collector: e4, logger: e4.logger.scope("on").scope(String(t4)) };
|
|
5673
5718
|
}
|
|
5674
|
-
async function
|
|
5675
|
-
const o3 = e4.on, s5 = o3[t4] || [], r4 =
|
|
5719
|
+
async function xe2(e4, t4, n4) {
|
|
5720
|
+
const o3 = e4.on, s5 = o3[t4] || [], r4 = oe(n4) ? n4 : [n4];
|
|
5676
5721
|
r4.forEach((e5) => {
|
|
5677
5722
|
s5.push(e5);
|
|
5678
|
-
}), o3[t4] = s5,
|
|
5723
|
+
}), o3[t4] = s5, Se2(e4, t4, r4);
|
|
5679
5724
|
}
|
|
5680
|
-
function
|
|
5725
|
+
function Oe2(e4, t4, n4, o3, s5) {
|
|
5681
5726
|
if (!t4.on) return;
|
|
5682
|
-
const r4 = t4.type || "unknown", a4 = e4.logger.scope(r4).scope("on").scope(o3),
|
|
5683
|
-
|
|
5727
|
+
const r4 = t4.type || "unknown", a4 = e4.logger.scope(r4).scope("on").scope(o3), i3 = { collector: e4, logger: a4, id: n4, config: t4.config, data: s5, env: Ue2(t4.env, t4.config.env) };
|
|
5728
|
+
Ze(t4.on, (t5) => Ie2(e4, "destination", t5, { destId: n4, type: o3 }))(o3, i3);
|
|
5684
5729
|
}
|
|
5685
|
-
function
|
|
5730
|
+
function Se2(e4, t4, o3, s5) {
|
|
5686
5731
|
let r4;
|
|
5687
5732
|
switch (t4) {
|
|
5688
5733
|
case n.Commands.Consent:
|
|
@@ -5711,10 +5756,10 @@ function be2(e4, t4, o3, s5) {
|
|
|
5711
5756
|
if (o3.length) switch (t4) {
|
|
5712
5757
|
case n.Commands.Consent:
|
|
5713
5758
|
!(function(e5, t5, o4) {
|
|
5714
|
-
const s6 = o4 || e5.consent, r5 =
|
|
5759
|
+
const s6 = o4 || e5.consent, r5 = qe2(e5, n.Commands.Consent);
|
|
5715
5760
|
t5.forEach((t6) => {
|
|
5716
5761
|
Object.keys(s6).filter((e6) => e6 in t6).forEach((n4) => {
|
|
5717
|
-
|
|
5762
|
+
Ze(t6[n4], (t7) => Ie2(e5, "consent", t7, { key: n4 }))(s6, r5);
|
|
5718
5763
|
});
|
|
5719
5764
|
});
|
|
5720
5765
|
})(e4, o3, s5);
|
|
@@ -5722,40 +5767,40 @@ function be2(e4, t4, o3, s5) {
|
|
|
5722
5767
|
case n.Commands.Ready:
|
|
5723
5768
|
!(function(e5, t5) {
|
|
5724
5769
|
if (!e5.allowed) return;
|
|
5725
|
-
const o4 =
|
|
5770
|
+
const o4 = qe2(e5, n.Commands.Ready);
|
|
5726
5771
|
t5.forEach((t6) => {
|
|
5727
|
-
|
|
5772
|
+
Ze(t6, (t7) => Ie2(e5, "ready", t7))(void 0, o4);
|
|
5728
5773
|
});
|
|
5729
5774
|
})(e4, o3);
|
|
5730
5775
|
break;
|
|
5731
5776
|
case n.Commands.Run:
|
|
5732
5777
|
!(function(e5, t5) {
|
|
5733
5778
|
if (!e5.allowed) return;
|
|
5734
|
-
const o4 =
|
|
5779
|
+
const o4 = qe2(e5, n.Commands.Run);
|
|
5735
5780
|
t5.forEach((t6) => {
|
|
5736
|
-
|
|
5781
|
+
Ze(t6, (t7) => Ie2(e5, "run", t7))(void 0, o4);
|
|
5737
5782
|
});
|
|
5738
5783
|
})(e4, o3);
|
|
5739
5784
|
break;
|
|
5740
5785
|
case n.Commands.Session:
|
|
5741
5786
|
!(function(e5, t5) {
|
|
5742
5787
|
if (!e5.session) return;
|
|
5743
|
-
const o4 =
|
|
5788
|
+
const o4 = qe2(e5, n.Commands.Session);
|
|
5744
5789
|
t5.forEach((t6) => {
|
|
5745
|
-
|
|
5790
|
+
Ze(t6, (t7) => Ie2(e5, "session", t7))(e5.session, o4);
|
|
5746
5791
|
});
|
|
5747
5792
|
})(e4, o3);
|
|
5748
5793
|
break;
|
|
5749
5794
|
default: {
|
|
5750
|
-
const n4 =
|
|
5795
|
+
const n4 = qe2(e4, t4);
|
|
5751
5796
|
o3.forEach((o4) => {
|
|
5752
|
-
"function" == typeof o4 &&
|
|
5797
|
+
"function" == typeof o4 && Ze(o4, (n5) => Ie2(e4, "generic", n5, { type: t4 }))(r4, n4);
|
|
5753
5798
|
});
|
|
5754
5799
|
break;
|
|
5755
5800
|
}
|
|
5756
5801
|
}
|
|
5757
5802
|
}
|
|
5758
|
-
async function
|
|
5803
|
+
async function je(e4, t4, o3, s5) {
|
|
5759
5804
|
let r4, a4 = o3 || [];
|
|
5760
5805
|
switch (o3 || (a4 = e4.on[t4] || []), t4) {
|
|
5761
5806
|
case n.Commands.Consent:
|
|
@@ -5781,23 +5826,23 @@ async function ke(e4, t4, o3, s5) {
|
|
|
5781
5826
|
default:
|
|
5782
5827
|
r4 = void 0;
|
|
5783
5828
|
}
|
|
5784
|
-
let
|
|
5829
|
+
let i3 = false;
|
|
5785
5830
|
for (const [n4, o4] of Object.entries(e4.sources)) {
|
|
5786
5831
|
if (o4.config.require?.length) {
|
|
5787
5832
|
const e5 = o4.config.require.indexOf(t4);
|
|
5788
5833
|
-1 !== e5 && o4.config.require.splice(e5, 1);
|
|
5789
5834
|
}
|
|
5790
|
-
if (o4.on) if (
|
|
5791
|
-
false === await
|
|
5835
|
+
if (o4.on) if (be2(o4)) {
|
|
5836
|
+
false === await We(o4.on, (o5) => Ie2(e4, "source", o5, { sourceId: n4, type: t4 }))(t4, r4) && (i3 = true);
|
|
5792
5837
|
} else o4.queueOn = o4.queueOn || [], o4.queueOn.push({ type: t4, data: r4 });
|
|
5793
5838
|
}
|
|
5794
5839
|
Object.entries(e4.destinations).forEach(([n4, o4]) => {
|
|
5795
5840
|
if (o4.on) {
|
|
5796
5841
|
if (!o4.config.init) return o4.queueOn = o4.queueOn || [], void o4.queueOn.push({ type: t4, data: r4 });
|
|
5797
|
-
|
|
5842
|
+
Oe2(e4, o4, n4, t4, r4);
|
|
5798
5843
|
}
|
|
5799
5844
|
});
|
|
5800
|
-
for (const [t5, n4] of Object.entries(e4.sources))
|
|
5845
|
+
for (const [t5, n4] of Object.entries(e4.sources)) be2(n4) && n4.queueOn?.length && await ve2(e4, n4, t5);
|
|
5801
5846
|
return Object.keys(e4.pending.destinations).length > 0 && await (async function(e5, t5) {
|
|
5802
5847
|
for (const [n4, o4] of Object.entries(e5.pending.destinations)) {
|
|
5803
5848
|
if (!e5.pending.destinations[n4] || e5.destinations[n4]) continue;
|
|
@@ -5807,84 +5852,84 @@ async function ke(e4, t4, o3, s5) {
|
|
|
5807
5852
|
if (-1 === r5) continue;
|
|
5808
5853
|
if (s6.splice(r5, 1), s6.length > 0) continue;
|
|
5809
5854
|
delete e5.pending.destinations[n4];
|
|
5810
|
-
const a5 =
|
|
5855
|
+
const a5 = We2(o4);
|
|
5811
5856
|
false !== a5.config.queue && (a5.queuePush = [...e5.queue]), e5.destinations[n4] = a5;
|
|
5812
5857
|
}
|
|
5813
|
-
})(e4, t4),
|
|
5858
|
+
})(e4, t4), Se2(e4, t4, a4, s5), !i3;
|
|
5814
5859
|
}
|
|
5815
|
-
function
|
|
5860
|
+
function De2(e4, t4, n4, o3) {
|
|
5816
5861
|
if (!Number.isFinite(n4.max) || n4.max <= 0) throw new Error(`pushBounded: max must be > 0 (got ${n4.max})`);
|
|
5817
5862
|
if ("dropNewest" === (n4.onOverflow ?? "dropOldest")) return e4.length >= n4.max ? (o3 && o3([t4]), { appended: false, dropped: 1 }) : (e4.push(t4), { appended: true, dropped: 0 });
|
|
5818
5863
|
const s5 = [];
|
|
5819
5864
|
for (; e4.length >= n4.max; ) s5.push(e4.shift());
|
|
5820
5865
|
return e4.push(t4), s5.length > 0 && o3 && o3(s5), { appended: true, dropped: s5.length };
|
|
5821
5866
|
}
|
|
5822
|
-
var
|
|
5823
|
-
function
|
|
5824
|
-
|
|
5867
|
+
var Ae2 = /* @__PURE__ */ new WeakMap();
|
|
5868
|
+
function $e(e4, t4, n4, o3) {
|
|
5869
|
+
Ae2.get(e4) || (Ae2.set(e4, true), t4.warn(n4, o3));
|
|
5825
5870
|
}
|
|
5826
|
-
function
|
|
5827
|
-
|
|
5871
|
+
function Ee(e4) {
|
|
5872
|
+
Ae2.delete(e4);
|
|
5828
5873
|
}
|
|
5829
|
-
var
|
|
5830
|
-
function
|
|
5831
|
-
return e4 ===
|
|
5874
|
+
var Me2 = Object.freeze({ batched: true });
|
|
5875
|
+
function _e(e4) {
|
|
5876
|
+
return e4 === Me2;
|
|
5832
5877
|
}
|
|
5833
|
-
function
|
|
5878
|
+
function Te2(e4) {
|
|
5834
5879
|
return void 0 === e4 ? {} : "number" == typeof e4 ? { wait: e4 } : { wait: e4.wait, size: e4.size, age: e4.age };
|
|
5835
5880
|
}
|
|
5836
|
-
function
|
|
5881
|
+
function Pe2(e4, t4) {
|
|
5837
5882
|
return e4.status.destinations[t4] || (e4.status.destinations[t4] = { count: 0, failed: 0, duration: 0, queuePushSize: 0, dlqSize: 0 }), e4.status.destinations[t4];
|
|
5838
5883
|
}
|
|
5839
|
-
function
|
|
5884
|
+
function ze2(e4, t4, n4, o3) {
|
|
5840
5885
|
e4.dropped[t4] || (e4.dropped[t4] = {});
|
|
5841
5886
|
const s5 = e4.dropped[t4];
|
|
5842
5887
|
return s5[n4] = (s5[n4] ?? 0) + o3, s5[n4];
|
|
5843
5888
|
}
|
|
5844
|
-
function
|
|
5889
|
+
function Re2(e4, t4, n4) {
|
|
5845
5890
|
if (!e4) return [];
|
|
5846
|
-
if (Array.isArray(e4) && e4.every((e5) => "string" == typeof e5)) return
|
|
5847
|
-
if ("string" == typeof e4) return
|
|
5848
|
-
const o3 =
|
|
5849
|
-
return 0 === o3.length ? [] : 1 === o3.length ?
|
|
5850
|
-
}
|
|
5851
|
-
async function
|
|
5852
|
-
const { code: n4, config: o3 = {}, env: s5 = {}, before: r4, next: a4, cache:
|
|
5853
|
-
if (!
|
|
5854
|
-
const
|
|
5855
|
-
let
|
|
5856
|
-
a4 && (
|
|
5857
|
-
const
|
|
5858
|
-
let
|
|
5859
|
-
if (!
|
|
5860
|
-
|
|
5861
|
-
} while (e4.destinations[
|
|
5862
|
-
return e4.destinations[
|
|
5863
|
-
}
|
|
5864
|
-
async function
|
|
5891
|
+
if (Array.isArray(e4) && e4.every((e5) => "string" == typeof e5)) return fe2(e4, t4);
|
|
5892
|
+
if ("string" == typeof e4) return fe2(e4, t4);
|
|
5893
|
+
const o3 = Mt(e4, Dt(n4));
|
|
5894
|
+
return 0 === o3.length ? [] : 1 === o3.length ? fe2(o3[0], t4) : fe2(o3, t4);
|
|
5895
|
+
}
|
|
5896
|
+
async function Be(e4, t4) {
|
|
5897
|
+
const { code: n4, config: o3 = {}, env: s5 = {}, before: r4, next: a4, cache: i3, state: c2 } = t4;
|
|
5898
|
+
if (!le(n4.push)) return Ge({ ok: false, failed: { invalid: { type: "invalid", error: "Destination code must have a push method" } } });
|
|
5899
|
+
const u3 = o3 || { init: false };
|
|
5900
|
+
let d2 = r4 ? { ...u3, before: r4 } : { ...u3 };
|
|
5901
|
+
a4 && (d2 = { ...d2, next: a4 }), i3 && (d2 = { ...d2, cache: i3 }), void 0 !== c2 && void 0 === d2.state && (d2 = { ...d2, state: c2 });
|
|
5902
|
+
const l2 = { ...n4, config: d2, env: Ue2(n4.env, s5) };
|
|
5903
|
+
let f3 = l2.config.id;
|
|
5904
|
+
if (!f3) do {
|
|
5905
|
+
f3 = Se(5, "abcdefghijklmnopqrstuvwxyz");
|
|
5906
|
+
} while (e4.destinations[f3]);
|
|
5907
|
+
return e4.destinations[f3] = l2, false !== l2.config.queue && (l2.queuePush = [...e4.queue]), He2(e4, void 0, {}, { [f3]: l2 });
|
|
5908
|
+
}
|
|
5909
|
+
async function He2(e4, t4, n4 = {}, o3) {
|
|
5865
5910
|
const { allowed: s5, consent: r4, globals: a4, user: g3 } = e4;
|
|
5866
|
-
if (!s5) return
|
|
5911
|
+
if (!s5) return Ge({ ok: false });
|
|
5867
5912
|
if (t4) {
|
|
5868
5913
|
const n5 = e4.config.queueMax;
|
|
5869
5914
|
if (void 0 === n5) throw new Error("Collector.Config.queueMax is undefined; defaults must be seeded by collector()");
|
|
5870
|
-
const o4 =
|
|
5915
|
+
const o4 = De2(e4.queue, t4, { max: n5 });
|
|
5871
5916
|
if (o4.dropped > 0) {
|
|
5872
|
-
const t5 =
|
|
5873
|
-
|
|
5874
|
-
} else e4.queue.length < n5 &&
|
|
5917
|
+
const t5 = ze2(e4.status, o("collector"), "queue", o4.dropped);
|
|
5918
|
+
$e(e4.queue, e4.logger, "collector.queue overflow; oldest events dropped", { buffer: "queue", cap: n5, droppedCount: t5 });
|
|
5919
|
+
} else e4.queue.length < n5 && Ee(e4.queue);
|
|
5875
5920
|
e4.status.in++;
|
|
5876
5921
|
}
|
|
5877
5922
|
o3 || (o3 = e4.destinations);
|
|
5878
|
-
const h3 = e4.transformers ?
|
|
5923
|
+
const h3 = e4.transformers ? de2(e4.transformers) : {}, w3 = await Promise.all(Object.entries(o3 || {}).map(async ([o4, s6]) => {
|
|
5879
5924
|
if (s6.config.disabled) return { id: o4, destination: s6, skipped: true };
|
|
5880
5925
|
let w4 = (s6.queuePush || []).map((e5) => ({ ...e5, consent: r4 }));
|
|
5881
|
-
s6.queuePush = [], t4 && w4.push(
|
|
5926
|
+
s6.queuePush = [], t4 && w4.push(me(t4));
|
|
5882
5927
|
const v4 = n4.ingest ? { ...n4.ingest, _meta: { ...n4.ingest._meta, path: [...n4.ingest._meta.path] } } : E("unknown");
|
|
5883
5928
|
if (!w4.length && !s6.queueOn?.length) return { id: o4, destination: s6, skipped: true };
|
|
5884
5929
|
if (!w4.length && s6.queueOn?.length) {
|
|
5885
5930
|
let t5 = false;
|
|
5886
5931
|
try {
|
|
5887
|
-
t5 = await
|
|
5932
|
+
t5 = await Fe(e4, s6, o4);
|
|
5888
5933
|
} catch (t6) {
|
|
5889
5934
|
e4.status.failed++;
|
|
5890
5935
|
const n5 = s6.type || "unknown";
|
|
@@ -5893,81 +5938,82 @@ async function Me2(e4, t4, n4 = {}, o3) {
|
|
|
5893
5938
|
return { id: o4, destination: s6, skipped: !t5 };
|
|
5894
5939
|
}
|
|
5895
5940
|
const b4 = [], k3 = w4.filter((t5) => {
|
|
5896
|
-
const n5 =
|
|
5941
|
+
const n5 = ke(s6.config.consent, r4, t5.consent);
|
|
5897
5942
|
if (n5) return t5.consent = n5, b4.push(t5), false;
|
|
5898
|
-
const a5 =
|
|
5899
|
-
return a5.skipReason = "consent", r4 && (a5.consent = { ...r4 }), s6.config.consent && (a5.meta = { required: { ...s6.config.consent } }),
|
|
5943
|
+
const a5 = D2(e4, { stepId: o("destination", o4), stepType: "destination", phase: "skip", eventId: "string" == typeof t5.id ? t5.id : "", now: Date.now() });
|
|
5944
|
+
return a5.skipReason = "consent", r4 && (a5.consent = { ...r4 }), s6.config.consent && (a5.meta = { required: { ...s6.config.consent } }), ft(e4, a5), true;
|
|
5900
5945
|
});
|
|
5901
5946
|
if (k3.length > 0) {
|
|
5902
5947
|
const t5 = s6.queuePush, n5 = s6.config.id || o4, r5 = { max: s6.config.queueMax ?? 1e3 };
|
|
5903
5948
|
let a5 = 0;
|
|
5904
5949
|
for (const e5 of k3) {
|
|
5905
|
-
a5 +=
|
|
5950
|
+
a5 += De2(t5, e5, r5).dropped;
|
|
5906
5951
|
}
|
|
5907
5952
|
if (a5 > 0) {
|
|
5908
|
-
|
|
5909
|
-
const o5 =
|
|
5910
|
-
|
|
5911
|
-
} else t5.length < r5.max &&
|
|
5953
|
+
Pe2(e4, n5);
|
|
5954
|
+
const o5 = ze2(e4.status, o("destination", n5), "queue", a5);
|
|
5955
|
+
$e(t5, e4.logger.scope(s6.type || "unknown"), "destination.queuePush overflow; oldest events dropped", { buffer: "queuePush", destination: n5, cap: r5.max, droppedCount: o5 });
|
|
5956
|
+
} else t5.length < r5.max && Ee(t5);
|
|
5912
5957
|
}
|
|
5913
5958
|
if (!b4.length) return { id: o4, destination: s6, queue: w4 };
|
|
5914
|
-
let C3, x2,
|
|
5959
|
+
let C3, x2, j2 = false;
|
|
5915
5960
|
try {
|
|
5916
|
-
|
|
5961
|
+
j2 = await Fe(e4, s6, o4);
|
|
5917
5962
|
} catch (t5) {
|
|
5918
5963
|
e4.status.failed++;
|
|
5919
5964
|
const n5 = s6.type || "unknown";
|
|
5920
5965
|
e4.logger.scope(n5).error("destination init failed", { error: t5 instanceof Error ? t5.message : String(t5) });
|
|
5921
5966
|
}
|
|
5922
|
-
if (!
|
|
5967
|
+
if (!j2) return { id: o4, destination: s6, queue: w4 };
|
|
5923
5968
|
s6.dlq || (s6.dlq = []);
|
|
5924
|
-
const
|
|
5925
|
-
let
|
|
5969
|
+
const A2 = Re2(s6.config.before, h3, v4), $2 = s6.config.next, E3 = s6.config?.cache, M3 = E3 ? Ft(E3) : void 0, _2 = M3 ? ce(M3, e4) : void 0, T3 = s6.config?.state ? Ht(s6.config.state) : void 0, P3 = T3?.filter((e5) => "get" === e5.mode), z4 = T3?.filter((e5) => "set" === e5.mode);
|
|
5970
|
+
let R3 = 0, B3 = 0;
|
|
5926
5971
|
return await Promise.all(b4.map(async (t5) => {
|
|
5927
5972
|
let r5;
|
|
5928
|
-
if (t5.globals =
|
|
5929
|
-
const e5 =
|
|
5973
|
+
if (t5.globals = ne(a4, t5.globals), t5.user = ne(g3, t5.user), M3?.stop && _2) {
|
|
5974
|
+
const e5 = Dt(v4, t5), n5 = await Ut(M3, _2, e5);
|
|
5930
5975
|
if ("HIT" === n5?.status) return t5;
|
|
5931
5976
|
"MISS" === n5?.status && (r5 = { key: n5.key, ttl: n5.rule.ttl });
|
|
5932
5977
|
}
|
|
5933
|
-
let
|
|
5934
|
-
if (
|
|
5935
|
-
const s7 = await
|
|
5978
|
+
let u3 = t5, d2 = n4.respond;
|
|
5979
|
+
if (A2.length > 0 && e4.transformers && Object.keys(e4.transformers).length > 0) {
|
|
5980
|
+
const s7 = await he2(e4, e4.transformers, A2, t5, v4, n4.respond, `destination.${o4}.before`);
|
|
5936
5981
|
if (null === s7.event) return t5;
|
|
5937
|
-
s7.respond && (d2 = s7.respond),
|
|
5982
|
+
s7.respond && (d2 = s7.respond), u3 = Array.isArray(s7.event) ? s7.event[0] : s7.event;
|
|
5938
5983
|
}
|
|
5939
|
-
if (
|
|
5940
|
-
const e5 =
|
|
5984
|
+
if (M3 && !M3.stop && _2) {
|
|
5985
|
+
const e5 = Dt(v4, u3), n5 = await Ut(M3, _2, e5);
|
|
5941
5986
|
if ("HIT" === n5?.status) return t5;
|
|
5942
5987
|
"MISS" === n5?.status && (r5 = { key: n5.key, ttl: n5.rule.ttl });
|
|
5943
5988
|
}
|
|
5989
|
+
P3 && P3.length > 0 && u3 && (u3 = await Lt(P3, (t6) => ue2(t6, e4), u3, e4));
|
|
5944
5990
|
const p2 = Date.now();
|
|
5945
5991
|
let m3 = false;
|
|
5946
|
-
const y2 = await
|
|
5992
|
+
const y2 = await We(Ke2, (t6) => {
|
|
5947
5993
|
const n5 = s6.type || "unknown";
|
|
5948
|
-
e4.logger.scope(n5).error("Push failed", { error: t6, event:
|
|
5949
|
-
const r6 = s6.dlq, a5 = s6.config.id || o4,
|
|
5994
|
+
e4.logger.scope(n5).error("Push failed", { error: t6, event: u3.name }), C3 = t6, m3 = true;
|
|
5995
|
+
const r6 = s6.dlq, a5 = s6.config.id || o4, i3 = { max: s6.config.dlqMax ?? 100 }, c2 = De2(r6, [u3, t6], i3);
|
|
5950
5996
|
if (c2.dropped > 0) {
|
|
5951
|
-
|
|
5952
|
-
const t7 =
|
|
5953
|
-
|
|
5954
|
-
} else r6.length <
|
|
5955
|
-
})(e4, s6, o4,
|
|
5956
|
-
if (
|
|
5997
|
+
Pe2(e4, a5);
|
|
5998
|
+
const t7 = ze2(e4.status, o("destination", a5), "dlq", c2.dropped);
|
|
5999
|
+
$e(r6, e4.logger.scope(s6.type || "unknown"), "destination.dlq overflow; oldest entries dropped", { buffer: "dlq", destination: a5, cap: i3.max, droppedCount: t7 });
|
|
6000
|
+
} else r6.length < i3.max && Ee(r6);
|
|
6001
|
+
})(e4, s6, o4, u3, v4, d2);
|
|
6002
|
+
if (R3 += Date.now() - p2, r5 && _2 && void 0 === s6.config.mock && Zt(_2, r5.key, y2 ?? true, r5.ttl), !m3 && z4 && z4.length > 0 && u3 && (u3 = await Lt(z4, (t6) => ue2(t6, e4), u3, e4)), void 0 === y2 || _e(y2) || (x2 = y2), _e(y2) && B3++, !m3 && $2) {
|
|
5957
6003
|
void 0 !== y2 && (v4._response = y2);
|
|
5958
|
-
const t6 = $
|
|
6004
|
+
const t6 = Re2($2, h3, v4);
|
|
5959
6005
|
if (t6.length > 0 && e4.transformers && Object.keys(e4.transformers).length > 0) {
|
|
5960
|
-
const n5 = await
|
|
6006
|
+
const n5 = await he2(e4, e4.transformers, t6, u3, v4, d2, `destination.${o4}.next`);
|
|
5961
6007
|
n5.respond && (d2 = n5.respond);
|
|
5962
6008
|
}
|
|
5963
6009
|
}
|
|
5964
6010
|
return t5;
|
|
5965
|
-
})), { id: o4, destination: s6, error: C3, response: x2, totalDuration:
|
|
6011
|
+
})), { id: o4, destination: s6, error: C3, response: x2, totalDuration: R3, batchedCount: B3, allowedCount: b4.length };
|
|
5966
6012
|
})), v3 = {}, b3 = {}, k2 = {};
|
|
5967
6013
|
for (const t5 of w3) {
|
|
5968
6014
|
if (t5.skipped) continue;
|
|
5969
6015
|
const n5 = t5.destination, o4 = { type: n5.type || "unknown", data: t5.response };
|
|
5970
|
-
|
|
6016
|
+
Pe2(e4, t5.id);
|
|
5971
6017
|
const s6 = e4.status.destinations[t5.id], r5 = Date.now();
|
|
5972
6018
|
if (s6.queuePushSize = n5.queuePush?.length ?? 0, s6.dlqSize = n5.dlq?.length ?? 0, t5.error) o4.error = t5.error, k2[t5.id] = o4, s6.failed++, s6.lastAt = r5, s6.duration += t5.totalDuration || 0, e4.status.failed++;
|
|
5973
6019
|
else if (t5.queue && t5.queue.length) b3[t5.id] = o4;
|
|
@@ -5976,65 +6022,65 @@ async function Me2(e4, t4, n4 = {}, o3) {
|
|
|
5976
6022
|
(Math.max(0, a5 - n6) > 0 || 0 === a5) && (v3[t5.id] = o4, s6.count++, s6.lastAt = r5, s6.duration += t5.totalDuration || 0, e4.status.out++);
|
|
5977
6023
|
}
|
|
5978
6024
|
}
|
|
5979
|
-
return
|
|
6025
|
+
return Ge({ event: t4, ...Object.keys(v3).length && { done: v3 }, ...Object.keys(b3).length && { queued: b3 }, ...Object.keys(k2).length && { failed: k2 } });
|
|
5980
6026
|
}
|
|
5981
|
-
async function
|
|
6027
|
+
async function Fe(e4, t4, n4) {
|
|
5982
6028
|
if (t4.init && !t4.config.init) {
|
|
5983
|
-
const o3 = t4.type || "unknown", s5 = e4.logger.scope(o3), r4 = { collector: e4, logger: s5, id: n4, config: t4.config, env:
|
|
6029
|
+
const o3 = t4.type || "unknown", s5 = e4.logger.scope(o3), r4 = { collector: e4, logger: s5, id: n4, config: t4.config, env: Ue2(t4.env, t4.config.env) };
|
|
5984
6030
|
s5.debug("init");
|
|
5985
6031
|
const a4 = Date.now();
|
|
5986
|
-
let
|
|
5987
|
-
|
|
6032
|
+
let i3;
|
|
6033
|
+
ft(e4, D2(e4, { stepId: o("destination", n4), stepType: "destination", phase: "init", eventId: "", now: a4 }));
|
|
5988
6034
|
try {
|
|
5989
|
-
|
|
6035
|
+
i3 = await at(t4.init, "DestinationInit", e4.hooks, e4.logger)(r4);
|
|
5990
6036
|
} catch (t5) {
|
|
5991
|
-
const o4 = Date.now(), s6 =
|
|
5992
|
-
throw s6.durationMs = o4 - a4, s6.error = t5 instanceof Error ? { name: t5.name, message: t5.message } : { message: String(t5) },
|
|
6037
|
+
const o4 = Date.now(), s6 = D2(e4, { stepId: o("destination", n4), stepType: "destination", phase: "error", eventId: "", now: o4 });
|
|
6038
|
+
throw s6.durationMs = o4 - a4, s6.error = t5 instanceof Error ? { name: t5.name, message: t5.message } : { message: String(t5) }, ft(e4, s6), t5;
|
|
5993
6039
|
}
|
|
5994
|
-
if (false ===
|
|
5995
|
-
if (t4.config = { ...
|
|
6040
|
+
if (false === i3) return i3;
|
|
6041
|
+
if (t4.config = { ...i3 || t4.config, init: true }, t4.queueOn?.length) {
|
|
5996
6042
|
const o4 = t4.queueOn;
|
|
5997
6043
|
t4.queueOn = [];
|
|
5998
|
-
for (const { type: s6, data: r5 } of o4)
|
|
6044
|
+
for (const { type: s6, data: r5 } of o4) Oe2(e4, t4, n4, s6, r5);
|
|
5999
6045
|
}
|
|
6000
6046
|
s5.debug("init done");
|
|
6001
6047
|
}
|
|
6002
6048
|
return true;
|
|
6003
6049
|
}
|
|
6004
|
-
async function
|
|
6005
|
-
const { config: a4 } = t4,
|
|
6006
|
-
if (
|
|
6007
|
-
const c2 = t4.type || "unknown",
|
|
6008
|
-
if (void 0 !== a4.mock) return
|
|
6009
|
-
const l2 =
|
|
6050
|
+
async function Ke2(e4, t4, n4, o3, s5, r4) {
|
|
6051
|
+
const { config: a4 } = t4, i3 = await qe(o3, a4, e4);
|
|
6052
|
+
if (i3.ignore) return false;
|
|
6053
|
+
const c2 = t4.type || "unknown", u3 = e4.logger.scope(c2), d2 = { collector: e4, logger: u3, id: n4, config: a4, data: i3.data, rule: i3.mapping, ingest: s5, env: { ...Ue2(t4.env, a4.env), ...r4 ? { respond: r4 } : {} } };
|
|
6054
|
+
if (void 0 !== a4.mock) return u3.debug("mock", { event: i3.event.name }), a4.mock;
|
|
6055
|
+
const l2 = i3.mapping, f3 = i3.mappingKey || "* *";
|
|
6010
6056
|
if (l2?.batch && t4.pushBatch && void 0 === a4.mock) {
|
|
6011
6057
|
if (t4.batches = t4.batches || {}, !t4.batches[f3]) {
|
|
6012
|
-
const o5 = { key: f3, entries: [], events: [], data: [] }, s6 =
|
|
6058
|
+
const o5 = { key: f3, entries: [], events: [], data: [] }, s6 = Te2(l2.batch), r5 = Te2(a4.batch), i4 = s6.wait ?? r5.wait ?? 3e4, c4 = s6.size ?? r5.size ?? 1e3, d4 = s6.age ?? r5.age ?? 3e4, p2 = Ue2(t4.env, a4.env), h3 = Te(async () => {
|
|
6013
6059
|
const o6 = t4.batches[f3].batched;
|
|
6014
6060
|
if (0 === o6.entries.length) return;
|
|
6015
6061
|
const s7 = { key: o6.key, entries: o6.entries, events: o6.events, data: o6.data };
|
|
6016
6062
|
o6.entries = [], o6.events = [], o6.data = [];
|
|
6017
|
-
const r6 = s7.entries[0],
|
|
6018
|
-
|
|
6019
|
-
const c5 = t4.config.id || n4, d5 =
|
|
6020
|
-
g3.batch = { size: s7.entries.length, index: 0 },
|
|
6063
|
+
const r6 = s7.entries[0], i5 = { collector: e4, logger: u3, id: n4, config: a4, data: void 0, rule: r6.rule, ingest: r6.ingest, env: { ...p2, ...r6.respond ? { respond: r6.respond } : {} } };
|
|
6064
|
+
u3.debug("push batch", { events: s7.entries.length });
|
|
6065
|
+
const c5 = t4.config.id || n4, d5 = Pe2(e4, c5), l3 = Date.now(), g3 = D2(e4, { stepId: o("destination", n4), stepType: "destination", phase: "flush", eventId: "", now: l3 });
|
|
6066
|
+
g3.batch = { size: s7.entries.length, index: 0 }, ft(e4, g3);
|
|
6021
6067
|
let h4 = true;
|
|
6022
|
-
await
|
|
6068
|
+
await We(at(t4.pushBatch, "DestinationPushBatch", e4.hooks, e4.logger), (o7) => {
|
|
6023
6069
|
h4 = false;
|
|
6024
|
-
const r7 = Date.now(), a5 =
|
|
6025
|
-
a5.durationMs = r7 - l3, a5.error = o7 instanceof Error ? { name: o7.name, message: o7.message } : { message: String(o7) }, a5.batch = { size: s7.entries.length, index: 0 },
|
|
6026
|
-
const
|
|
6070
|
+
const r7 = Date.now(), a5 = D2(e4, { stepId: o("destination", n4), stepType: "destination", phase: "error", eventId: "", now: r7 });
|
|
6071
|
+
a5.durationMs = r7 - l3, a5.error = o7 instanceof Error ? { name: o7.name, message: o7.message } : { message: String(o7) }, a5.batch = { size: s7.entries.length, index: 0 }, ft(e4, a5);
|
|
6072
|
+
const i6 = t4.dlq = t4.dlq || [], f4 = { max: t4.config.dlqMax ?? 100 };
|
|
6027
6073
|
let p3 = 0;
|
|
6028
6074
|
for (const e5 of s7.entries) {
|
|
6029
|
-
p3 +=
|
|
6075
|
+
p3 += De2(i6, [e5.event, o7], f4).dropped;
|
|
6030
6076
|
}
|
|
6031
6077
|
if (p3 > 0) {
|
|
6032
|
-
const t5 =
|
|
6033
|
-
|
|
6034
|
-
} else
|
|
6035
|
-
d5.failed += s7.entries.length, d5.dlqSize =
|
|
6036
|
-
})(s7,
|
|
6037
|
-
}, { wait:
|
|
6078
|
+
const t5 = ze2(e4.status, o("destination", c5), "dlq", p3);
|
|
6079
|
+
$e(i6, u3, "destination.dlq overflow; oldest entries dropped", { buffer: "dlq", destination: c5, cap: f4.max, droppedCount: t5 });
|
|
6080
|
+
} else i6.length < f4.max && Ee(i6);
|
|
6081
|
+
d5.failed += s7.entries.length, d5.dlqSize = i6.length, e4.status.failed += s7.entries.length, u3.error("Push batch failed", { error: o7 instanceof Error ? o7.message : String(o7), entries: s7.entries.length });
|
|
6082
|
+
})(s7, i5), u3.debug("push batch done"), d5.inFlightBatch = Math.max(0, (d5.inFlightBatch ?? 0) - s7.entries.length), h4 && (d5.count += s7.entries.length, d5.lastAt = Date.now(), e4.status.out += s7.entries.length);
|
|
6083
|
+
}, { wait: i4, size: c4, age: d4 });
|
|
6038
6084
|
t4.batches[f3] = { batched: o5, batchFn: () => {
|
|
6039
6085
|
h3();
|
|
6040
6086
|
}, flush: async () => {
|
|
@@ -6042,154 +6088,154 @@ async function _e2(e4, t4, n4, o3, s5, r4) {
|
|
|
6042
6088
|
} };
|
|
6043
6089
|
}
|
|
6044
6090
|
const o4 = t4.batches[f3];
|
|
6045
|
-
o4.batched.entries.push({ event:
|
|
6046
|
-
const c3 = t4.config.id || n4, d3 =
|
|
6047
|
-
return d3.inFlightBatch = (d3.inFlightBatch ?? 0) + 1, o4.batchFn(),
|
|
6091
|
+
o4.batched.entries.push({ event: i3.event, ingest: s5, respond: r4, rule: l2, data: i3.data }), o4.batched.events.push(i3.event), se(i3.data) && o4.batched.data.push(i3.data);
|
|
6092
|
+
const c3 = t4.config.id || n4, d3 = Pe2(e4, c3);
|
|
6093
|
+
return d3.inFlightBatch = (d3.inFlightBatch ?? 0) + 1, o4.batchFn(), Me2;
|
|
6048
6094
|
}
|
|
6049
6095
|
{
|
|
6050
|
-
|
|
6051
|
-
const o4 = "string" == typeof
|
|
6052
|
-
|
|
6096
|
+
u3.debug("push", { event: i3.event.name });
|
|
6097
|
+
const o4 = "string" == typeof i3.event.id ? i3.event.id : "", s6 = Date.now(), r5 = D2(e4, { stepId: o("destination", n4), stepType: "destination", phase: "in", eventId: o4, now: s6 });
|
|
6098
|
+
i3.mappingKey && (r5.mappingKey = i3.mappingKey), i3.event.consent && (r5.consent = { ...i3.event.consent }), ft(e4, r5);
|
|
6053
6099
|
try {
|
|
6054
|
-
const r6 = await
|
|
6055
|
-
return c3.durationMs = a5 - s6, c3.outEvent = r6,
|
|
6100
|
+
const r6 = await at(t4.push, "DestinationPush", e4.hooks, e4.logger)(i3.event, d2), a5 = Date.now(), c3 = D2(e4, { stepId: o("destination", n4), stepType: "destination", phase: "out", eventId: o4, now: a5 });
|
|
6101
|
+
return c3.durationMs = a5 - s6, c3.outEvent = r6, i3.mappingKey && (c3.mappingKey = i3.mappingKey), ft(e4, c3), u3.debug("push done"), r6;
|
|
6056
6102
|
} catch (t5) {
|
|
6057
|
-
const r6 = Date.now(), a5 =
|
|
6058
|
-
throw a5.durationMs = r6 - s6, a5.error = t5 instanceof Error ? { name: t5.name, message: t5.message } : { message: String(t5) },
|
|
6103
|
+
const r6 = Date.now(), a5 = D2(e4, { stepId: o("destination", n4), stepType: "destination", phase: "error", eventId: o4, now: r6 });
|
|
6104
|
+
throw a5.durationMs = r6 - s6, a5.error = t5 instanceof Error ? { name: t5.name, message: t5.message } : { message: String(t5) }, i3.mappingKey && (a5.mappingKey = i3.mappingKey), ft(e4, a5), t5;
|
|
6059
6105
|
}
|
|
6060
6106
|
}
|
|
6061
6107
|
}
|
|
6062
|
-
function
|
|
6108
|
+
function Ge(e4) {
|
|
6063
6109
|
return { ok: !e4?.failed, ...e4 };
|
|
6064
6110
|
}
|
|
6065
|
-
function
|
|
6066
|
-
const { code: t4, config: n4 = {}, env: o3 = {}, cache: s5 } = e4, { config:
|
|
6067
|
-
s5 && (
|
|
6068
|
-
const
|
|
6069
|
-
return { ...t4, config:
|
|
6111
|
+
function We2(e4) {
|
|
6112
|
+
const { code: t4, config: n4 = {}, env: o3 = {}, cache: s5, state: r4 } = e4, { config: a4 } = le2(e4, "before"), { config: i3 } = le2({ ...e4, config: a4 }, "next"), c2 = { ...t4.config, ...n4, ...i3 };
|
|
6113
|
+
s5 && (c2.cache = s5), void 0 !== r4 && void 0 === c2.state && (c2.state = r4);
|
|
6114
|
+
const u3 = Ue2(t4.env, o3);
|
|
6115
|
+
return { ...t4, config: c2, env: u3 };
|
|
6070
6116
|
}
|
|
6071
|
-
async function
|
|
6117
|
+
async function Ne2(e4, t4 = {}) {
|
|
6072
6118
|
const n4 = {};
|
|
6073
|
-
for (const [o3, s5] of Object.entries(t4)) s5.config?.require?.length ? e4.pending.destinations[o3] = s5 : n4[o3] =
|
|
6119
|
+
for (const [o3, s5] of Object.entries(t4)) s5.config?.require?.length ? e4.pending.destinations[o3] = s5 : n4[o3] = We2(s5);
|
|
6074
6120
|
return n4;
|
|
6075
6121
|
}
|
|
6076
|
-
function
|
|
6077
|
-
return e4 || t4 ? t4 ? e4 &&
|
|
6122
|
+
function Ue2(e4, t4) {
|
|
6123
|
+
return e4 || t4 ? t4 ? e4 && fe(e4) && fe(t4) ? { ...e4, ...t4 } : t4 : e4 : {};
|
|
6078
6124
|
}
|
|
6079
|
-
async function
|
|
6125
|
+
async function Xe(e4, t4, n4) {
|
|
6080
6126
|
const o3 = Object.entries(e4).map(async ([e5, o4]) => {
|
|
6081
6127
|
const s5 = o4.destroy;
|
|
6082
6128
|
if (!s5) return;
|
|
6083
|
-
const r4 = o4.type || "unknown", a4 = n4.scope(r4),
|
|
6129
|
+
const r4 = o4.type || "unknown", a4 = n4.scope(r4), i3 = { id: e5, config: o4.config, env: o4.env ?? {}, logger: a4 };
|
|
6084
6130
|
try {
|
|
6085
|
-
await Promise.race([s5(
|
|
6131
|
+
await Promise.race([s5(i3), new Promise((n5, o5) => setTimeout(() => o5(new Error(`${t4} '${e5}' destroy timed out`)), 5e3))]);
|
|
6086
6132
|
} catch (n5) {
|
|
6087
6133
|
a4.error(`${t4} '${e5}' destroy failed: ${n5}`);
|
|
6088
6134
|
}
|
|
6089
6135
|
});
|
|
6090
6136
|
await Promise.allSettled(o3);
|
|
6091
6137
|
}
|
|
6092
|
-
async function
|
|
6093
|
-
let r4, a4,
|
|
6138
|
+
async function Ze2(e4, t4, o3) {
|
|
6139
|
+
let r4, a4, i3 = false;
|
|
6094
6140
|
switch (t4) {
|
|
6095
6141
|
case n.Commands.Config:
|
|
6096
|
-
|
|
6142
|
+
fe(o3) && (ne(e4.config, o3, { shallow: false }), a4 = o3, i3 = true);
|
|
6097
6143
|
break;
|
|
6098
6144
|
case n.Commands.Consent:
|
|
6099
|
-
if (
|
|
6145
|
+
if (fe(o3)) {
|
|
6100
6146
|
const { update: t5 } = s2(e4, o3);
|
|
6101
|
-
a4 = t5,
|
|
6147
|
+
a4 = t5, i3 = true;
|
|
6102
6148
|
}
|
|
6103
6149
|
break;
|
|
6104
6150
|
case n.Commands.Custom:
|
|
6105
|
-
|
|
6151
|
+
fe(o3) && (e4.custom = ne(e4.custom, o3), a4 = o3, i3 = true);
|
|
6106
6152
|
break;
|
|
6107
6153
|
case n.Commands.Destination:
|
|
6108
|
-
|
|
6154
|
+
fe(o3) && "code" in o3 && fe(o3.code) && (r4 = await Be(e4, o3));
|
|
6109
6155
|
break;
|
|
6110
6156
|
case n.Commands.Globals:
|
|
6111
|
-
|
|
6157
|
+
fe(o3) && (e4.globals = ne(e4.globals, o3), a4 = o3, i3 = true);
|
|
6112
6158
|
break;
|
|
6113
6159
|
case n.Commands.Hook:
|
|
6114
|
-
if (
|
|
6160
|
+
if (fe(o3) && de(o3.name) && le(o3.fn)) {
|
|
6115
6161
|
const { name: t5, fn: n4 } = o3;
|
|
6116
|
-
e4.hooks[t5] = n4, a4 = o3,
|
|
6162
|
+
e4.hooks[t5] = n4, a4 = o3, i3 = true;
|
|
6117
6163
|
}
|
|
6118
6164
|
break;
|
|
6119
6165
|
case n.Commands.On:
|
|
6120
|
-
if (
|
|
6166
|
+
if (fe(o3) && de(o3.type)) {
|
|
6121
6167
|
const { type: t5, rules: n4 } = o3;
|
|
6122
|
-
await
|
|
6168
|
+
await xe2(e4, t5, n4);
|
|
6123
6169
|
}
|
|
6124
6170
|
break;
|
|
6125
6171
|
case n.Commands.Ready:
|
|
6126
|
-
|
|
6172
|
+
i3 = true;
|
|
6127
6173
|
break;
|
|
6128
6174
|
case n.Commands.Run:
|
|
6129
|
-
r4 = await
|
|
6175
|
+
r4 = await tt(e4, o3), i3 = true;
|
|
6130
6176
|
break;
|
|
6131
6177
|
case n.Commands.Session:
|
|
6132
|
-
|
|
6178
|
+
i3 = true;
|
|
6133
6179
|
break;
|
|
6134
6180
|
case n.Commands.Shutdown:
|
|
6135
6181
|
await (async function(e5) {
|
|
6136
6182
|
const t5 = e5.logger;
|
|
6137
|
-
await
|
|
6183
|
+
await Xe(e5.sources, "source", t5), await Xe(e5.destinations, "destination", t5), await Xe(e5.transformers, "transformer", t5), await Xe(e5.stores, "store", t5);
|
|
6138
6184
|
})(e4);
|
|
6139
6185
|
break;
|
|
6140
6186
|
case n.Commands.User:
|
|
6141
|
-
|
|
6187
|
+
fe(o3) && (ne(e4.user, o3, { shallow: false }), a4 = o3, i3 = true);
|
|
6142
6188
|
}
|
|
6143
|
-
return
|
|
6189
|
+
return i3 && (await je(e4, t4, void 0, a4), r4 = await He2(e4)), r4 || Ge({ ok: true });
|
|
6144
6190
|
}
|
|
6145
|
-
function
|
|
6191
|
+
function et(e4, t4) {
|
|
6146
6192
|
if (!t4.name) throw new Error("Event name is required");
|
|
6147
6193
|
const [n4, o3] = t4.name.split(" ");
|
|
6148
6194
|
if (!n4 || !o3) throw new Error("Event name is invalid");
|
|
6149
|
-
const { timestamp: s5 = Date.now(), name: r4 = `${n4} ${o3}`, data: a4 = {}, context:
|
|
6150
|
-
return { name: r4, data: a4, context:
|
|
6195
|
+
const { timestamp: s5 = Date.now(), name: r4 = `${n4} ${o3}`, data: a4 = {}, context: i3 = {}, globals: c2 = e4.globals, custom: u3 = {}, user: d2 = e4.user, nested: l2 = [], consent: f3 = e4.consent, id: p2 = xe(), trigger: g3 = "", entity: m3 = n4, action: h3 = o3, timing: y2 = 0, source: w3 = { type: "collector", schema: "4" } } = t4;
|
|
6196
|
+
return { name: r4, data: a4, context: i3, globals: c2, custom: u3, user: d2, nested: l2, consent: f3, id: p2, trigger: g3, entity: m3, action: h3, timestamp: s5, timing: y2, source: w3 };
|
|
6151
6197
|
}
|
|
6152
|
-
async function
|
|
6153
|
-
e4.allowed = true, e4.timing = Date.now(), t4 && (t4.consent && (e4.consent =
|
|
6198
|
+
async function tt(e4, t4) {
|
|
6199
|
+
e4.allowed = true, e4.timing = Date.now(), t4 && (t4.consent && (e4.consent = ne(e4.consent, t4.consent)), t4.user && (e4.user = ne(e4.user, t4.user)), t4.globals && (e4.globals = ne(e4.config.globalsStatic || {}, t4.globals)), t4.custom && (e4.custom = ne(e4.custom, t4.custom))), Object.values(e4.destinations).forEach((e5) => {
|
|
6154
6200
|
e5.queuePush = [];
|
|
6155
6201
|
}), e4.queue = [], e4.round++;
|
|
6156
|
-
return await
|
|
6202
|
+
return await He2(e4);
|
|
6157
6203
|
}
|
|
6158
|
-
function
|
|
6159
|
-
const n4 =
|
|
6160
|
-
const s5 = Date.now(), { id: r4, ingest: a4, respond:
|
|
6161
|
-
let f3 =
|
|
6204
|
+
function ut2(e4, t4) {
|
|
6205
|
+
const n4 = at(async (n5, o3 = {}) => await We(async () => {
|
|
6206
|
+
const s5 = Date.now(), { id: r4, ingest: a4, respond: i3, mapping: c2, preChain: u3, include: d2, exclude: l2 } = o3;
|
|
6207
|
+
let f3 = i3, p2 = n5;
|
|
6162
6208
|
const g3 = d2 || l2 ? (function(e5, t5, n6) {
|
|
6163
6209
|
let o4 = e5;
|
|
6164
6210
|
return t5 && (o4 = Object.fromEntries(Object.entries(o4).filter(([e6]) => t5.includes(e6)))), n6 && (o4 = Object.fromEntries(Object.entries(o4).filter(([e6]) => !n6.includes(e6)))), o4;
|
|
6165
6211
|
})(e4.destinations, d2, l2) : void 0, m3 = a4 ?? E(r4 || "unknown");
|
|
6166
6212
|
if (c2) {
|
|
6167
|
-
const t5 = await
|
|
6168
|
-
if (t5.ignore) return
|
|
6213
|
+
const t5 = await qe(p2, c2, e4);
|
|
6214
|
+
if (t5.ignore) return Ge({ ok: true });
|
|
6169
6215
|
if (c2.consent) {
|
|
6170
|
-
if (!
|
|
6216
|
+
if (!ke(c2.consent, e4.consent, t5.event.consent)) return Ge({ ok: true });
|
|
6171
6217
|
}
|
|
6172
6218
|
p2 = t5.event;
|
|
6173
6219
|
}
|
|
6174
|
-
if (
|
|
6175
|
-
const n6 = await
|
|
6176
|
-
if (null === n6.event) return
|
|
6177
|
-
if (n6.stopped) return n6.respond && (f3 = n6.respond),
|
|
6220
|
+
if (u3?.length && e4.transformers && Object.keys(e4.transformers).length > 0) {
|
|
6221
|
+
const n6 = await he2(e4, e4.transformers, u3, p2, m3, f3, r4 ? `source.${r4}.next` : void 0);
|
|
6222
|
+
if (null === n6.event) return Ge({ ok: true });
|
|
6223
|
+
if (n6.stopped) return n6.respond && (f3 = n6.respond), Ge({ ok: true });
|
|
6178
6224
|
if (n6.respond && (f3 = n6.respond), Array.isArray(n6.event)) {
|
|
6179
6225
|
const o4 = await Promise.all(n6.event.map(async (n7) => {
|
|
6180
|
-
const o5 = t4(n7), s6 =
|
|
6181
|
-
return
|
|
6226
|
+
const o5 = t4(n7), s6 = et(e4, o5);
|
|
6227
|
+
return He2(e4, s6, { id: r4, ingest: m3, respond: f3 }, g3);
|
|
6182
6228
|
}));
|
|
6183
6229
|
if (r4) {
|
|
6184
6230
|
e4.status.sources[r4] || (e4.status.sources[r4] = { count: 0, duration: 0 });
|
|
6185
6231
|
const t5 = e4.status.sources[r4];
|
|
6186
6232
|
t5.count += n6.event.length, t5.lastAt = Date.now(), t5.duration += Date.now() - s5;
|
|
6187
6233
|
}
|
|
6188
|
-
return o4[0] ??
|
|
6234
|
+
return o4[0] ?? Ge({ ok: true });
|
|
6189
6235
|
}
|
|
6190
6236
|
p2 = n6.event;
|
|
6191
6237
|
}
|
|
6192
|
-
const h3 = t4(p2), y2 =
|
|
6238
|
+
const h3 = t4(p2), y2 = et(e4, h3), w3 = await He2(e4, y2, { id: r4, ingest: m3, respond: f3 }, g3);
|
|
6193
6239
|
if (r4) {
|
|
6194
6240
|
e4.status.sources[r4] || (e4.status.sources[r4] = { count: 0, duration: 0 });
|
|
6195
6241
|
const t5 = e4.status.sources[r4];
|
|
@@ -6197,37 +6243,37 @@ function nt(e4, t4) {
|
|
|
6197
6243
|
}
|
|
6198
6244
|
return w3;
|
|
6199
6245
|
}, (t5) => {
|
|
6200
|
-
if (t5 instanceof
|
|
6201
|
-
return e4.status.failed++, e4.logger.error("push failed", { event: n5, ingest: o3.ingest, error: t5 }),
|
|
6246
|
+
if (t5 instanceof He) throw t5;
|
|
6247
|
+
return e4.status.failed++, e4.logger.error("push failed", { event: n5, ingest: o3.ingest, error: t5 }), Ge({ ok: false });
|
|
6202
6248
|
})(), "Push", e4.hooks, e4.logger);
|
|
6203
6249
|
return async (t5, o3) => {
|
|
6204
6250
|
const s5 = "string" == typeof t5.id ? t5.id : "", r4 = Date.now();
|
|
6205
|
-
|
|
6251
|
+
ft(e4, D2(e4, { stepId: "collector.push", stepType: "collector", phase: "in", eventId: s5, now: r4 }));
|
|
6206
6252
|
try {
|
|
6207
|
-
const a4 = await n4(t5, o3),
|
|
6208
|
-
return c2.durationMs =
|
|
6253
|
+
const a4 = await n4(t5, o3), i3 = Date.now(), c2 = D2(e4, { stepId: "collector.push", stepType: "collector", phase: "out", eventId: s5, now: i3 });
|
|
6254
|
+
return c2.durationMs = i3 - r4, c2.outEvent = a4, ft(e4, c2), a4;
|
|
6209
6255
|
} catch (t6) {
|
|
6210
|
-
const n5 = Date.now(), o4 =
|
|
6211
|
-
throw o4.durationMs = n5 - r4, o4.error = t6 instanceof Error ? { name: t6.name, message: t6.message } : { message: String(t6) },
|
|
6256
|
+
const n5 = Date.now(), o4 = D2(e4, { stepId: "collector.push", stepType: "collector", phase: "error", eventId: s5, now: n5 });
|
|
6257
|
+
throw o4.durationMs = n5 - r4, o4.error = t6 instanceof Error ? { name: t6.name, message: t6.message } : { message: String(t6) }, ft(e4, o4), t6;
|
|
6212
6258
|
}
|
|
6213
6259
|
};
|
|
6214
6260
|
}
|
|
6215
|
-
function
|
|
6261
|
+
function mt(e4 = {}) {
|
|
6216
6262
|
const t4 = e4.maxEntries ?? 1e4, n4 = e4.lowWaterMark ?? 0.8, o3 = e4.sweepIntervalMs ?? 6e4, s5 = Math.floor(t4 * n4), r4 = /* @__PURE__ */ new Map(), a4 = { hits: 0, misses: 0, populates: 0, writes: 0, deletes: 0, evictions_entries: 0, evictions_ttl: 0 };
|
|
6217
|
-
let
|
|
6218
|
-
o3 > 0 && (
|
|
6263
|
+
let i3;
|
|
6264
|
+
o3 > 0 && (i3 = setInterval(function() {
|
|
6219
6265
|
const e5 = Date.now();
|
|
6220
6266
|
let t5 = 0;
|
|
6221
6267
|
for (const [n5, o4] of r4) void 0 !== o4.expires && o4.expires <= e5 && (r4.delete(n5), t5++);
|
|
6222
6268
|
a4.evictions_ttl += t5;
|
|
6223
|
-
}, o3),
|
|
6269
|
+
}, o3), i3 && "function" == typeof i3.unref && i3.unref());
|
|
6224
6270
|
return { type: "memory", config: {}, get(e5) {
|
|
6225
6271
|
const t5 = r4.get(e5);
|
|
6226
6272
|
if (t5) return void 0 !== t5.expires && t5.expires <= Date.now() ? (r4.delete(e5), a4.evictions_ttl++, void a4.misses++) : (r4.delete(e5), r4.set(e5, t5), a4.hits++, t5.value);
|
|
6227
6273
|
a4.misses++;
|
|
6228
6274
|
}, set(e5, n5, o4) {
|
|
6229
|
-
const
|
|
6230
|
-
|
|
6275
|
+
const i4 = !r4.has(e5);
|
|
6276
|
+
i4 || r4.delete(e5), r4.set(e5, { value: n5, expires: void 0 !== o4 ? Date.now() + o4 : void 0 }), a4.writes++, i4 && a4.populates++, r4.size > t4 && (function() {
|
|
6231
6277
|
if (r4.size <= t4) return;
|
|
6232
6278
|
const e6 = r4.size - s5;
|
|
6233
6279
|
let n6 = 0;
|
|
@@ -6242,35 +6288,35 @@ function ct2(e4 = {}) {
|
|
|
6242
6288
|
}, get counters() {
|
|
6243
6289
|
return { ...a4 };
|
|
6244
6290
|
}, destroy() {
|
|
6245
|
-
void 0 !==
|
|
6291
|
+
void 0 !== i3 && (clearInterval(i3), i3 = void 0), r4.clear();
|
|
6246
6292
|
} };
|
|
6247
6293
|
}
|
|
6248
|
-
function
|
|
6249
|
-
const { cacheConfig: n4, cacheStore: o3, namespace: s5, logger: r4, storeId: a4, collector:
|
|
6250
|
-
if (!
|
|
6251
|
-
const n5 =
|
|
6252
|
-
n5.meta = { op: "cache", cached: "hit" === t5, status: t5, key: e5 },
|
|
6253
|
-
},
|
|
6294
|
+
function wt(e4, t4) {
|
|
6295
|
+
const { cacheConfig: n4, cacheStore: o3, namespace: s5, logger: r4, storeId: a4, collector: i3 } = t4, c2 = (e5, t5) => {
|
|
6296
|
+
if (!i3) return;
|
|
6297
|
+
const n5 = D2(i3, { stepId: `store.${a4}`, stepType: "store", phase: "in", eventId: "", now: Date.now() });
|
|
6298
|
+
n5.meta = { op: "cache", cached: "hit" === t5, status: t5, key: e5 }, ft(i3, n5);
|
|
6299
|
+
}, u3 = { hits: 0, misses: 0, populates: 0, writes: 0, deletes: 0, inflight_dedups: 0 }, d2 = n4.rules.map((e5) => ({ match: e5.match ? Nt(e5.match) : () => true, ttl: e5.ttl })), l2 = (e5) => `${s5}:${e5}`;
|
|
6254
6300
|
function f3(e5, t5) {
|
|
6255
6301
|
const n5 = void 0 === t5 ? { key: e5 } : { key: e5, value: t5 };
|
|
6256
6302
|
return d2.find((e6) => e6.match(n5));
|
|
6257
6303
|
}
|
|
6258
6304
|
const p2 = /* @__PURE__ */ new Map();
|
|
6259
6305
|
return { type: e4.type, config: e4.config, setup: e4.setup, get counters() {
|
|
6260
|
-
return { ...
|
|
6306
|
+
return { ...u3 };
|
|
6261
6307
|
}, async get(t5) {
|
|
6262
6308
|
const n5 = l2(t5), s6 = await o3.get(n5);
|
|
6263
|
-
if (void 0 !== s6) return
|
|
6309
|
+
if (void 0 !== s6) return u3.hits++, c2(t5, "hit"), s6;
|
|
6264
6310
|
const r5 = p2.get(n5);
|
|
6265
|
-
if (r5) return
|
|
6266
|
-
|
|
6311
|
+
if (r5) return u3.inflight_dedups++, c2(t5, "hit"), r5;
|
|
6312
|
+
u3.misses++, c2(t5, "miss");
|
|
6267
6313
|
const a5 = (async () => {
|
|
6268
6314
|
try {
|
|
6269
6315
|
const s7 = await e4.get(t5);
|
|
6270
6316
|
if (void 0 === s7) return;
|
|
6271
6317
|
const r6 = f3(t5, s7);
|
|
6272
6318
|
if (r6) try {
|
|
6273
|
-
await o3.set(n5, s7, 1e3 * r6.ttl),
|
|
6319
|
+
await o3.set(n5, s7, 1e3 * r6.ttl), u3.populates++;
|
|
6274
6320
|
} catch (e5) {
|
|
6275
6321
|
g3("set", t5, e5);
|
|
6276
6322
|
}
|
|
@@ -6281,7 +6327,7 @@ function lt2(e4, t4) {
|
|
|
6281
6327
|
})();
|
|
6282
6328
|
return p2.set(n5, a5), a5;
|
|
6283
6329
|
}, async set(t5, n5, s6) {
|
|
6284
|
-
|
|
6330
|
+
u3.writes++, await e4.set(t5, n5, s6);
|
|
6285
6331
|
const r5 = f3(t5, n5);
|
|
6286
6332
|
if (r5) try {
|
|
6287
6333
|
await o3.set(l2(t5), n5, 1e3 * r5.ttl);
|
|
@@ -6289,7 +6335,7 @@ function lt2(e4, t4) {
|
|
|
6289
6335
|
g3("set", t5, e5);
|
|
6290
6336
|
}
|
|
6291
6337
|
}, async delete(t5) {
|
|
6292
|
-
|
|
6338
|
+
u3.deletes++, await e4.delete(t5);
|
|
6293
6339
|
try {
|
|
6294
6340
|
await o3.delete(l2(t5));
|
|
6295
6341
|
} catch (e5) {
|
|
@@ -6301,47 +6347,47 @@ function lt2(e4, t4) {
|
|
|
6301
6347
|
r4 ? r4.warn(o4, { error: n5 }) : console.warn(o4, n5);
|
|
6302
6348
|
}
|
|
6303
6349
|
}
|
|
6304
|
-
function
|
|
6305
|
-
const o3 = `store.${n4}`, s5 =
|
|
6350
|
+
function vt(e4, t4, n4) {
|
|
6351
|
+
const o3 = `store.${n4}`, s5 = at(t4.get, "StoreGet", e4.hooks, e4.logger), r4 = at(t4.set, "StoreSet", e4.hooks, e4.logger), a4 = at(t4.delete, "StoreDelete", e4.hooks, e4.logger);
|
|
6306
6352
|
t4.get = async (t5) => {
|
|
6307
|
-
const n5 = Date.now(), r5 =
|
|
6308
|
-
r5.meta = { op: "get", key: t5 },
|
|
6353
|
+
const n5 = Date.now(), r5 = D2(e4, { stepId: o3, stepType: "store", phase: "in", eventId: "", now: n5 });
|
|
6354
|
+
r5.meta = { op: "get", key: t5 }, ft(e4, r5);
|
|
6309
6355
|
try {
|
|
6310
|
-
const r6 = await s5(t5), a5 = Date.now(),
|
|
6311
|
-
return
|
|
6356
|
+
const r6 = await s5(t5), a5 = Date.now(), i3 = D2(e4, { stepId: o3, stepType: "store", phase: "out", eventId: "", now: a5 });
|
|
6357
|
+
return i3.durationMs = a5 - n5, i3.meta = { op: "get", key: t5 }, ft(e4, i3), r6;
|
|
6312
6358
|
} catch (s6) {
|
|
6313
|
-
const r6 = Date.now(), a5 =
|
|
6314
|
-
throw a5.durationMs = r6 - n5, a5.meta = { op: "get", key: t5 }, a5.error = s6 instanceof Error ? { name: s6.name, message: s6.message } : { message: String(s6) },
|
|
6359
|
+
const r6 = Date.now(), a5 = D2(e4, { stepId: o3, stepType: "store", phase: "error", eventId: "", now: r6 });
|
|
6360
|
+
throw a5.durationMs = r6 - n5, a5.meta = { op: "get", key: t5 }, a5.error = s6 instanceof Error ? { name: s6.name, message: s6.message } : { message: String(s6) }, ft(e4, a5), s6;
|
|
6315
6361
|
}
|
|
6316
6362
|
}, t4.set = async (t5, n5, s6) => {
|
|
6317
|
-
const a5 = Date.now(),
|
|
6318
|
-
|
|
6363
|
+
const a5 = Date.now(), i3 = D2(e4, { stepId: o3, stepType: "store", phase: "in", eventId: "", now: a5 });
|
|
6364
|
+
i3.meta = { op: "set", key: t5 }, ft(e4, i3);
|
|
6319
6365
|
try {
|
|
6320
6366
|
await r4(t5, n5, s6);
|
|
6321
|
-
const
|
|
6322
|
-
c2.durationMs =
|
|
6367
|
+
const i4 = Date.now(), c2 = D2(e4, { stepId: o3, stepType: "store", phase: "out", eventId: "", now: i4 });
|
|
6368
|
+
c2.durationMs = i4 - a5, c2.meta = { op: "set", key: t5 }, ft(e4, c2);
|
|
6323
6369
|
} catch (n6) {
|
|
6324
|
-
const s7 = Date.now(), r5 =
|
|
6325
|
-
throw r5.durationMs = s7 - a5, r5.meta = { op: "set", key: t5 }, r5.error = n6 instanceof Error ? { name: n6.name, message: n6.message } : { message: String(n6) },
|
|
6370
|
+
const s7 = Date.now(), r5 = D2(e4, { stepId: o3, stepType: "store", phase: "error", eventId: "", now: s7 });
|
|
6371
|
+
throw r5.durationMs = s7 - a5, r5.meta = { op: "set", key: t5 }, r5.error = n6 instanceof Error ? { name: n6.name, message: n6.message } : { message: String(n6) }, ft(e4, r5), n6;
|
|
6326
6372
|
}
|
|
6327
6373
|
}, t4.delete = async (t5) => {
|
|
6328
|
-
const n5 = Date.now(), s6 =
|
|
6329
|
-
s6.meta = { op: "delete", key: t5 },
|
|
6374
|
+
const n5 = Date.now(), s6 = D2(e4, { stepId: o3, stepType: "store", phase: "in", eventId: "", now: n5 });
|
|
6375
|
+
s6.meta = { op: "delete", key: t5 }, ft(e4, s6);
|
|
6330
6376
|
try {
|
|
6331
6377
|
await a4(t5);
|
|
6332
|
-
const s7 = Date.now(), r5 =
|
|
6333
|
-
r5.durationMs = s7 - n5, r5.meta = { op: "delete", key: t5 },
|
|
6378
|
+
const s7 = Date.now(), r5 = D2(e4, { stepId: o3, stepType: "store", phase: "out", eventId: "", now: s7 });
|
|
6379
|
+
r5.durationMs = s7 - n5, r5.meta = { op: "delete", key: t5 }, ft(e4, r5);
|
|
6334
6380
|
} catch (s7) {
|
|
6335
|
-
const r5 = Date.now(), a5 =
|
|
6336
|
-
throw a5.durationMs = r5 - n5, a5.meta = { op: "delete", key: t5 }, a5.error = s7 instanceof Error ? { name: s7.name, message: s7.message } : { message: String(s7) },
|
|
6381
|
+
const r5 = Date.now(), a5 = D2(e4, { stepId: o3, stepType: "store", phase: "error", eventId: "", now: r5 });
|
|
6382
|
+
throw a5.durationMs = r5 - n5, a5.meta = { op: "delete", key: t5 }, a5.error = s7 instanceof Error ? { name: s7.name, message: s7.message } : { message: String(s7) }, ft(e4, a5), s7;
|
|
6337
6383
|
}
|
|
6338
6384
|
};
|
|
6339
6385
|
}
|
|
6340
|
-
async function
|
|
6386
|
+
async function bt(e4, t4 = {}) {
|
|
6341
6387
|
const n4 = {};
|
|
6342
6388
|
for (const [o4, s6] of Object.entries(t4)) {
|
|
6343
|
-
const { code: t5, config: r4 = {}, env: a4 = {} } = s6,
|
|
6344
|
-
n4[o4] =
|
|
6389
|
+
const { code: t5, config: r4 = {}, env: a4 = {} } = s6, i3 = e4.logger.scope("store").scope(o4), c2 = { collector: e4, logger: i3, id: o4, config: r4, env: a4 }, u3 = await t5(c2);
|
|
6390
|
+
n4[o4] = u3;
|
|
6345
6391
|
}
|
|
6346
6392
|
const o3 = t4, s5 = (function(e5) {
|
|
6347
6393
|
const t5 = {};
|
|
@@ -6355,10 +6401,10 @@ async function pt(e4, t4 = {}) {
|
|
|
6355
6401
|
throw new Error(`Cycle in cache.store chain: ${t6}`);
|
|
6356
6402
|
}
|
|
6357
6403
|
t5[r4] = "GRAY", o4.push(r4);
|
|
6358
|
-
const
|
|
6359
|
-
if (void 0 !==
|
|
6360
|
-
if (!(
|
|
6361
|
-
s6(
|
|
6404
|
+
const i3 = e5[r4].cache?.store;
|
|
6405
|
+
if (void 0 !== i3) {
|
|
6406
|
+
if (!(i3 in e5)) throw new Error(`Store "${r4}" cache.store references "${i3}", which is not declared in flow.stores`);
|
|
6407
|
+
s6(i3);
|
|
6362
6408
|
}
|
|
6363
6409
|
o4.pop(), t5[r4] = "BLACK", n5.push(r4);
|
|
6364
6410
|
}
|
|
@@ -6369,23 +6415,23 @@ async function pt(e4, t4 = {}) {
|
|
|
6369
6415
|
const s6 = o3[t5].cache;
|
|
6370
6416
|
if (!s6) continue;
|
|
6371
6417
|
let r4, a4;
|
|
6372
|
-
void 0 !== s6.store ? (r4 = n4[s6.store], a4 = s6.store) : (n4.__cache || (n4.__cache =
|
|
6373
|
-
const
|
|
6374
|
-
e4.logger.scope("store-cache").scope(t5).info(`store "${t5}" caches with namespace "${
|
|
6418
|
+
void 0 !== s6.store ? (r4 = n4[s6.store], a4 = s6.store) : (n4.__cache || (n4.__cache = mt()), r4 = n4.__cache, a4 = "__cache");
|
|
6419
|
+
const i3 = s6.namespace ?? t5;
|
|
6420
|
+
e4.logger.scope("store-cache").scope(t5).info(`store "${t5}" caches with namespace "${i3}:" via ${a4}`), n4[t5] = wt(n4[t5], { storeId: t5, cacheConfig: s6, cacheStore: r4, namespace: i3, logger: e4.logger.scope("store-cache").scope(t5), collector: e4 });
|
|
6375
6421
|
}
|
|
6376
|
-
for (const [t5, o4] of Object.entries(n4)) "__cache" !== t5 &&
|
|
6422
|
+
for (const [t5, o4] of Object.entries(n4)) "__cache" !== t5 && vt(e4, o4, t5);
|
|
6377
6423
|
return n4;
|
|
6378
6424
|
}
|
|
6379
|
-
async function
|
|
6380
|
-
const t4 =
|
|
6381
|
-
|
|
6382
|
-
return
|
|
6383
|
-
if (t6 instanceof
|
|
6384
|
-
return e5.status.failed++, e5.logger.error("command failed", { command: n5, data: o4, error: t6 }),
|
|
6425
|
+
async function kt(e4) {
|
|
6426
|
+
const t4 = ne({ globalsStatic: {}, sessionStatic: {}, run: true, queueMax: 1e3 }, e4, { merge: false, extend: false }), n4 = { level: e4.logger?.level, handler: e4.logger?.handler }, o3 = Me(n4), s5 = { ...t4.globalsStatic, ...e4.globals }, i3 = { allowed: false, config: t4, consent: e4.consent || {}, custom: e4.custom || {}, destinations: {}, transformers: {}, stores: {}, globals: s5, hooks: e4.hooks || {}, observers: /* @__PURE__ */ new Set(), logger: o3, on: {}, queue: [], round: 0, session: void 0, status: { startedAt: Date.now(), in: 0, out: 0, failed: 0, sources: {}, destinations: {}, dropped: {} }, timing: Date.now(), user: e4.user || {}, sources: {}, pending: { destinations: {} }, push: void 0, command: void 0 };
|
|
6427
|
+
i3.push = ut2(i3, (e5) => ({ timing: Math.round((Date.now() - i3.timing) / 10) / 100, source: { type: "collector", schema: "4", version: "4.1.3-next-1780071196115" }, ...e5 })), i3.command = (function(e5, t5) {
|
|
6428
|
+
return at(async (n5, o4, s6) => await We(async () => await t5(e5, n5, o4, s6), (t6) => {
|
|
6429
|
+
if (t6 instanceof He) throw t6;
|
|
6430
|
+
return e5.status.failed++, e5.logger.error("command failed", { command: n5, data: o4, error: t6 }), Ge({ ok: false });
|
|
6385
6431
|
})(), "Command", e5.hooks, e5.logger);
|
|
6386
|
-
})(
|
|
6432
|
+
})(i3, Ze2);
|
|
6387
6433
|
const c2 = e4.stores || {};
|
|
6388
|
-
return
|
|
6434
|
+
return i3.stores = await bt(i3, c2), (function(e5, t5, n5) {
|
|
6389
6435
|
const o4 = /* @__PURE__ */ new Map();
|
|
6390
6436
|
for (const [n6, s7] of Object.entries(e5)) t5[n6] && o4.set(s7, t5[n6]);
|
|
6391
6437
|
if (0 !== o4.size) {
|
|
@@ -6399,15 +6445,15 @@ async function gt(e4) {
|
|
|
6399
6445
|
}
|
|
6400
6446
|
}
|
|
6401
6447
|
}
|
|
6402
|
-
})(c2,
|
|
6448
|
+
})(c2, i3.stores, e4), i3.stores.__cache || (i3.stores.__cache = mt()), i3.destinations = await Ne2(i3, e4.destinations || {}), i3.transformers = await (async function(e5, t5 = {}) {
|
|
6403
6449
|
const n5 = {};
|
|
6404
6450
|
for (const [o4, s6] of Object.entries(t5)) {
|
|
6405
|
-
const { code: t6, env: r4 = {} } = s6, a4 =
|
|
6451
|
+
const { code: t6, env: r4 = {} } = s6, a4 = Jt(s6, "Transformer");
|
|
6406
6452
|
if (!a4.ok) {
|
|
6407
6453
|
e5.logger.warn(`Transformer ${o4} invalid (${a4.code}): ${a4.reason}. Skipping.`);
|
|
6408
6454
|
continue;
|
|
6409
6455
|
}
|
|
6410
|
-
const { config:
|
|
6456
|
+
const { config: i4 } = le2(s6, "before"), { config: c3 } = le2({ ...s6, config: i4 }, "next"), u3 = Object.keys(r4).length > 0 ? { ...c3, env: r4 } : c3, { cache: d2 } = s6, l2 = d2 ? { ...u3, cache: d2 } : u3, { state: f3 } = s6, p2 = void 0 !== f3 && void 0 === l2.state ? { ...l2, state: f3 } : l2, g3 = e5.logger.scope("transformer").scope(o4), m3 = { collector: e5, logger: g3, id: o4, ingest: E(o4), config: p2, env: r4 }, h3 = t6 ?? ((e6) => {
|
|
6411
6457
|
const t7 = s6.mapping;
|
|
6412
6458
|
if (t7) {
|
|
6413
6459
|
const n6 = [];
|
|
@@ -6419,20 +6465,20 @@ async function gt(e4) {
|
|
|
6419
6465
|
}
|
|
6420
6466
|
}
|
|
6421
6467
|
return n6.length > 0 && e6.collector.logger.warn(`Transformer ${o4}: \`${n6.join(", ")}\` ignored at transformer position (only event-mutating fields apply).`), { type: "pass", config: e6.config, push: async (n7) => {
|
|
6422
|
-
const o5 = await
|
|
6468
|
+
const o5 = await qe(n7, t7, e6.collector);
|
|
6423
6469
|
return !o5.ignore && { event: o5.event };
|
|
6424
6470
|
} };
|
|
6425
6471
|
}
|
|
6426
6472
|
return { type: "pass", config: e6.config, push: (e7) => ({ event: e7 }) };
|
|
6427
|
-
}),
|
|
6428
|
-
void 0 !== s6.before && void 0 ===
|
|
6473
|
+
}), y2 = await h3(m3);
|
|
6474
|
+
void 0 !== s6.before && void 0 === y2.config?.before && (y2.config = { ...y2.config ?? {}, before: s6.before }), void 0 !== s6.next && void 0 === y2.config?.next && (y2.config = { ...y2.config ?? {}, next: s6.next }), n5[o4] = y2;
|
|
6429
6475
|
}
|
|
6430
6476
|
return n5;
|
|
6431
|
-
})(
|
|
6477
|
+
})(i3, e4.transformers || {}), i3;
|
|
6432
6478
|
}
|
|
6433
|
-
async function
|
|
6479
|
+
async function Ct2(e4) {
|
|
6434
6480
|
e4 = e4 || {};
|
|
6435
|
-
const t4 = await
|
|
6481
|
+
const t4 = await kt(e4), n4 = (o3 = t4, { type: "elb", config: {}, push: async (e5, t5, n5, s6, r5) => {
|
|
6436
6482
|
if ("string" == typeof e5 && e5.startsWith("walker ")) {
|
|
6437
6483
|
const n6 = e5.replace("walker ", "");
|
|
6438
6484
|
return o3.command(n6, t5);
|
|
@@ -6440,37 +6486,37 @@ async function mt(e4) {
|
|
|
6440
6486
|
let a5;
|
|
6441
6487
|
if ("string" == typeof e5) a5 = { name: e5 }, t5 && "object" == typeof t5 && !Array.isArray(t5) && (a5.data = t5);
|
|
6442
6488
|
else {
|
|
6443
|
-
if (!e5 || "object" != typeof e5) return
|
|
6489
|
+
if (!e5 || "object" != typeof e5) return Ge({ ok: false });
|
|
6444
6490
|
a5 = e5, t5 && "object" == typeof t5 && !Array.isArray(t5) && (a5.data = { ...a5.data || {}, ...t5 });
|
|
6445
6491
|
}
|
|
6446
6492
|
return n5 && "object" == typeof n5 && (a5.context = n5), s6 && Array.isArray(s6) && (a5.nested = s6), r5 && "object" == typeof r5 && (a5.custom = r5), o3.push(a5);
|
|
6447
6493
|
} });
|
|
6448
6494
|
var o3;
|
|
6449
|
-
t4.sources.elb = n4, await
|
|
6450
|
-
const { consent: s5, user: r4, globals: a4, custom:
|
|
6451
|
-
s5 && await t4.command("consent", s5), r4 && await t4.command("user", r4), a4 && Object.assign(t4.globals, a4),
|
|
6495
|
+
t4.sources.elb = n4, await Ce(t4, e4.sources || {});
|
|
6496
|
+
const { consent: s5, user: r4, globals: a4, custom: i3 } = e4;
|
|
6497
|
+
s5 && await t4.command("consent", s5), r4 && await t4.command("user", r4), a4 && Object.assign(t4.globals, a4), i3 && Object.assign(t4.custom, i3), t4.config.run && await t4.command("run");
|
|
6452
6498
|
let c2 = n4.push;
|
|
6453
|
-
const
|
|
6454
|
-
return d2 ? c2 = d2.push :
|
|
6499
|
+
const u3 = Object.values(t4.sources).filter((e5) => "elb" !== e5.type), d2 = u3.find((e5) => e5.config.primary);
|
|
6500
|
+
return d2 ? c2 = d2.push : u3.length > 0 && (c2 = u3[0].push), { collector: t4, elb: c2 };
|
|
6455
6501
|
}
|
|
6456
|
-
function
|
|
6502
|
+
function It2(e4) {
|
|
6457
6503
|
if (null === e4 || "object" != typeof e4) return e4;
|
|
6458
|
-
if (Array.isArray(e4)) return e4.map(
|
|
6504
|
+
if (Array.isArray(e4)) return e4.map(It2);
|
|
6459
6505
|
const t4 = {};
|
|
6460
|
-
for (const [n4, o3] of Object.entries(e4)) t4[n4] = "function" == typeof o3 ? o3 :
|
|
6506
|
+
for (const [n4, o3] of Object.entries(e4)) t4[n4] = "function" == typeof o3 ? o3 : It2(o3);
|
|
6461
6507
|
return t4;
|
|
6462
6508
|
}
|
|
6463
|
-
function
|
|
6464
|
-
const t4 = [], { simulation: n4, ...o3 } = e4, s5 =
|
|
6509
|
+
function qt2(e4) {
|
|
6510
|
+
const t4 = [], { simulation: n4, ...o3 } = e4, s5 = It2(o3);
|
|
6465
6511
|
for (const e5 of n4) {
|
|
6466
6512
|
const n5 = e5.startsWith("call:") ? e5.slice(5) : e5, o4 = n5.split(".");
|
|
6467
6513
|
let r4 = s5;
|
|
6468
6514
|
for (let e6 = 0; e6 < o4.length - 1 && null != r4[o4[e6]]; e6++) r4 = r4[o4[e6]];
|
|
6469
6515
|
const a4 = o4[o4.length - 1];
|
|
6470
6516
|
if (null == r4 || !(a4 in r4)) continue;
|
|
6471
|
-
const
|
|
6472
|
-
"function" == typeof
|
|
6473
|
-
return t4.push({ fn: n5, args: e6, ts: Date.now() }),
|
|
6517
|
+
const i3 = r4[a4];
|
|
6518
|
+
"function" == typeof i3 && (r4[a4] = function(...e6) {
|
|
6519
|
+
return t4.push({ fn: n5, args: e6, ts: Date.now() }), i3.apply(this, e6);
|
|
6474
6520
|
});
|
|
6475
6521
|
}
|
|
6476
6522
|
return { wrappedEnv: s5, calls: t4 };
|
|
@@ -6494,13 +6540,13 @@ var simulation = ["sendServer"];
|
|
|
6494
6540
|
var step_exports = {};
|
|
6495
6541
|
__export2(step_exports, { customHeaders: () => customHeaders, customTransform: () => customTransform, fullEvent: () => fullEvent });
|
|
6496
6542
|
var URL2 = "https://api.example.com/events";
|
|
6497
|
-
var fullEvent = { title: "Forward event data", description: "A page view is POSTed to the configured endpoint with the event data serialized as the JSON body.", in:
|
|
6498
|
-
var customHeaders = { title: "Custom headers", description: "A form submission is sent to the API with custom request headers such as an API key for authentication.", in:
|
|
6499
|
-
var customTransform = { title: "Custom payload", description: "An order event is reshaped via a data mapping into a custom JSON payload with renamed fields for the API.", in:
|
|
6543
|
+
var fullEvent = { title: "Forward event data", description: "A page view is POSTed to the configured endpoint with the event data serialized as the JSON body.", in: Oe("page view", { timestamp: 1700000800, data: { title: "Docs", url: "https://example.com/docs" }, source: { type: "express", platform: "server" } }), mapping: { data: "data" }, out: [["sendServer", URL2, JSON.stringify({ title: "Docs", url: "https://example.com/docs" }), { headers: void 0, method: void 0, timeout: void 0 }]] };
|
|
6544
|
+
var customHeaders = { title: "Custom headers", description: "A form submission is sent to the API with custom request headers such as an API key for authentication.", in: Oe("form submit", { timestamp: 1700000801, data: { type: "contact", email: "user@example.com" }, source: { type: "express", platform: "server" } }), mapping: { data: "data" }, out: [["sendServer", URL2, JSON.stringify({ type: "contact", email: "user@example.com" }), { headers: { "X-API-Key": "YOUR_API_KEY" }, method: void 0, timeout: void 0 }]] };
|
|
6545
|
+
var customTransform = { title: "Custom payload", description: "An order event is reshaped via a data mapping into a custom JSON payload with renamed fields for the API.", in: Oe("order complete", { timestamp: 1700000802, data: { id: "ORD-500", total: 199.99, currency: "USD" }, user: { id: "buyer-42" }, source: { type: "express", platform: "server" } }), mapping: { data: { map: { order_id: "data.id", amount: "data.total", currency: "data.currency", customer_id: "user.id", event_type: "name" } } }, out: [["sendServer", URL2, JSON.stringify({ order_id: "ORD-500", amount: 199.99, currency: "USD", customer_id: "buyer-42", event_type: "order complete" }), { headers: void 0, method: void 0, timeout: void 0 }]] };
|
|
6500
6546
|
var destinationAPI = { type: "api", config: {}, env: { sendServer: a2 }, async push(event, { config, rule, data, env, logger }) {
|
|
6501
6547
|
const { settings } = config, { url, headers, method, transform, timeout } = settings || {};
|
|
6502
6548
|
if (!url) return;
|
|
6503
|
-
const eventData =
|
|
6549
|
+
const eventData = se(data) ? data : event, body = transform ? transform(eventData, config, rule) : JSON.stringify(eventData);
|
|
6504
6550
|
logger?.debug("API destination sending request", { url, method: method || "POST", eventName: event.name });
|
|
6505
6551
|
const sendServerFn = env?.sendServer || a2, response = await sendServerFn(url, body, { headers, method, timeout });
|
|
6506
6552
|
logger?.debug("API destination response", { ok: response?.ok });
|
|
@@ -6632,7 +6678,7 @@ async function createEmitter(opts) {
|
|
|
6632
6678
|
}
|
|
6633
6679
|
}
|
|
6634
6680
|
};
|
|
6635
|
-
const { elb } = await
|
|
6681
|
+
const { elb } = await Ct2(collectorConfig);
|
|
6636
6682
|
elbFn = elb;
|
|
6637
6683
|
return elbFn;
|
|
6638
6684
|
}
|
|
@@ -7225,7 +7271,7 @@ async function prepareFlow(input) {
|
|
|
7225
7271
|
configPath: process.cwd(),
|
|
7226
7272
|
flowName: input.flow
|
|
7227
7273
|
});
|
|
7228
|
-
const platform =
|
|
7274
|
+
const platform = ee(flowSettings);
|
|
7229
7275
|
const overrides = buildOverrides(
|
|
7230
7276
|
{ simulate: input.simulate, mock: input.mock },
|
|
7231
7277
|
flowSettings
|
|
@@ -7449,7 +7495,7 @@ function resolveBeforeChain(before, transformers, ingest, event) {
|
|
|
7449
7495
|
if (Array.isArray(before) && before.every(isString)) {
|
|
7450
7496
|
return before;
|
|
7451
7497
|
}
|
|
7452
|
-
const ids =
|
|
7498
|
+
const ids = Mt(before, Dt(ingest, event));
|
|
7453
7499
|
if (ids.length === 0) return [];
|
|
7454
7500
|
if (ids.length === 1) return walkStaticChain(ids[0], transformers);
|
|
7455
7501
|
return ids;
|
|
@@ -7551,12 +7597,12 @@ async function push(configOrPath, event, options = {}) {
|
|
|
7551
7597
|
"push() currently only supports config file paths. Config object support will be added in a future version. Please provide a path to a configuration file."
|
|
7552
7598
|
);
|
|
7553
7599
|
}
|
|
7554
|
-
const parsed =
|
|
7600
|
+
const parsed = i2.PartialEventSchema.safeParse(event);
|
|
7555
7601
|
if (!parsed.success) {
|
|
7556
7602
|
return {
|
|
7557
7603
|
success: false,
|
|
7558
7604
|
duration: 0,
|
|
7559
|
-
error: `Invalid event: ${parsed.error.issues.map((
|
|
7605
|
+
error: `Invalid event: ${parsed.error.issues.map((i3) => `${i3.path.join(".")}: ${i3.message}`).join(", ")}`
|
|
7560
7606
|
};
|
|
7561
7607
|
}
|
|
7562
7608
|
return pushCore(configOrPath, event, {
|
|
@@ -7575,7 +7621,7 @@ async function executeConfigPush(options, validatedEvent, logger, setTempDir, sn
|
|
|
7575
7621
|
flowName: options.flow,
|
|
7576
7622
|
logger
|
|
7577
7623
|
});
|
|
7578
|
-
const platform =
|
|
7624
|
+
const platform = ee(flowSettings);
|
|
7579
7625
|
const overrides = buildOverrides({ mock: options.mock }, flowSettings);
|
|
7580
7626
|
logger.debug("Bundling flow configuration");
|
|
7581
7627
|
const tempDir = getTmpPath(
|
|
@@ -7803,7 +7849,7 @@ async function simulateSource(configOrPath, input, options) {
|
|
|
7803
7849
|
}
|
|
7804
7850
|
async function simulateTransformer(configOrPath, event, options) {
|
|
7805
7851
|
const startTime = Date.now();
|
|
7806
|
-
const parsed =
|
|
7852
|
+
const parsed = i2.PartialEventSchema.safeParse(event);
|
|
7807
7853
|
if (!parsed.success) {
|
|
7808
7854
|
return buildSimulationResult({
|
|
7809
7855
|
step: "transformer",
|
|
@@ -7873,7 +7919,7 @@ async function simulateTransformer(configOrPath, event, options) {
|
|
|
7873
7919
|
`Transformer "${options.transformerId}" not found in collector. Available: ${Object.keys(collector.transformers || {}).join(", ") || "none"}`
|
|
7874
7920
|
);
|
|
7875
7921
|
}
|
|
7876
|
-
const initialized = await
|
|
7922
|
+
const initialized = await pe2(
|
|
7877
7923
|
collector,
|
|
7878
7924
|
transformer,
|
|
7879
7925
|
options.transformerId
|
|
@@ -7897,7 +7943,7 @@ async function simulateTransformer(configOrPath, event, options) {
|
|
|
7897
7943
|
processedEvent
|
|
7898
7944
|
);
|
|
7899
7945
|
if (beforeChainIds.length > 0) {
|
|
7900
|
-
const beforeResult = await
|
|
7946
|
+
const beforeResult = await he2(
|
|
7901
7947
|
collector,
|
|
7902
7948
|
collector.transformers,
|
|
7903
7949
|
beforeChainIds,
|
|
@@ -7919,7 +7965,7 @@ async function simulateTransformer(configOrPath, event, options) {
|
|
|
7919
7965
|
processedEvent = Array.isArray(beforeResult) ? beforeResult[0] : beforeResult;
|
|
7920
7966
|
}
|
|
7921
7967
|
}
|
|
7922
|
-
const pushResult = await
|
|
7968
|
+
const pushResult = await ge2(
|
|
7923
7969
|
collector,
|
|
7924
7970
|
transformer,
|
|
7925
7971
|
options.transformerId,
|
|
@@ -7968,7 +8014,7 @@ async function simulateTransformer(configOrPath, event, options) {
|
|
|
7968
8014
|
}
|
|
7969
8015
|
async function simulateDestination(configOrPath, event, options) {
|
|
7970
8016
|
const startTime = Date.now();
|
|
7971
|
-
const parsed =
|
|
8017
|
+
const parsed = i2.PartialEventSchema.safeParse(event);
|
|
7972
8018
|
if (!parsed.success) {
|
|
7973
8019
|
return buildSimulationResult({
|
|
7974
8020
|
step: "destination",
|
|
@@ -8041,7 +8087,7 @@ async function simulateDestination(configOrPath, event, options) {
|
|
|
8041
8087
|
...devEnv.push,
|
|
8042
8088
|
simulation: devEnv.simulation
|
|
8043
8089
|
};
|
|
8044
|
-
const { wrappedEnv, calls } =
|
|
8090
|
+
const { wrappedEnv, calls } = qt2(combined);
|
|
8045
8091
|
if (destConfig) destConfig.env = wrappedEnv;
|
|
8046
8092
|
trackedCalls = calls;
|
|
8047
8093
|
}
|
|
@@ -8813,9 +8859,9 @@ function buildTelemetryObservers(flowId) {
|
|
|
8813
8859
|
const url = process.env.WALKEROS_OBSERVER_URL;
|
|
8814
8860
|
const token = process.env.WALKEROS_INGEST_TOKEN;
|
|
8815
8861
|
if (!url || !token) return void 0;
|
|
8816
|
-
const emit =
|
|
8862
|
+
const emit = pt({ url, token });
|
|
8817
8863
|
return [
|
|
8818
|
-
|
|
8864
|
+
ct(emit, () => ut({ flowId }))
|
|
8819
8865
|
];
|
|
8820
8866
|
}
|
|
8821
8867
|
async function injectSecrets(api, logger) {
|
|
@@ -9141,13 +9187,13 @@ function resolveEnvMarkers(value) {
|
|
|
9141
9187
|
return value;
|
|
9142
9188
|
}
|
|
9143
9189
|
function resolveEnvMarkersInString(input) {
|
|
9144
|
-
if (!input.includes(
|
|
9145
|
-
const esc =
|
|
9146
|
-
const
|
|
9190
|
+
if (!input.includes(B)) return input;
|
|
9191
|
+
const esc = B.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
9192
|
+
const re2 = new RegExp(
|
|
9147
9193
|
esc + "([a-zA-Z_][a-zA-Z0-9_]*)(?::((?:(?!" + esc + `)[^\\s"'])*))?`,
|
|
9148
9194
|
"g"
|
|
9149
9195
|
);
|
|
9150
|
-
return input.replace(
|
|
9196
|
+
return input.replace(re2, (match, name, defaultValue) => {
|
|
9151
9197
|
if (typeof process !== "undefined" && process.env?.[name] !== void 0) {
|
|
9152
9198
|
return process.env[name];
|
|
9153
9199
|
}
|
|
@@ -9444,11 +9490,11 @@ function validateEvent2(input) {
|
|
|
9444
9490
|
// src/commands/validate/validators/flow.ts
|
|
9445
9491
|
init_dist();
|
|
9446
9492
|
init_dev();
|
|
9447
|
-
var { validateFlowConfig: validateFlowConfig2 } =
|
|
9493
|
+
var { validateFlowConfig: validateFlowConfig2 } = i2;
|
|
9448
9494
|
function isFlowJson(value) {
|
|
9449
|
-
if (!
|
|
9495
|
+
if (!fe(value)) return false;
|
|
9450
9496
|
if (!("version" in value) || !("flows" in value)) return false;
|
|
9451
|
-
return
|
|
9497
|
+
return fe(value.flows);
|
|
9452
9498
|
}
|
|
9453
9499
|
function validateFlow(input, options = {}) {
|
|
9454
9500
|
const errors = [];
|
|
@@ -9479,9 +9525,9 @@ function validateFlow(input, options = {}) {
|
|
|
9479
9525
|
message: issue.message
|
|
9480
9526
|
});
|
|
9481
9527
|
}
|
|
9482
|
-
const config =
|
|
9528
|
+
const config = fe(input) ? input : {};
|
|
9483
9529
|
const flowsValue = config.flows;
|
|
9484
|
-
const flows =
|
|
9530
|
+
const flows = fe(flowsValue) ? flowsValue : void 0;
|
|
9485
9531
|
if (flows && Object.keys(flows).length === 0) {
|
|
9486
9532
|
errors.push({
|
|
9487
9533
|
path: "flows",
|
|
@@ -9491,14 +9537,14 @@ function validateFlow(input, options = {}) {
|
|
|
9491
9537
|
}
|
|
9492
9538
|
if (flows) {
|
|
9493
9539
|
for (const [flowName, flowValue] of Object.entries(flows)) {
|
|
9494
|
-
if (!
|
|
9540
|
+
if (!fe(flowValue)) continue;
|
|
9495
9541
|
const transformersValue = flowValue.transformers;
|
|
9496
|
-
if (!
|
|
9542
|
+
if (!fe(transformersValue)) continue;
|
|
9497
9543
|
for (const [name, transformerValue] of Object.entries(
|
|
9498
9544
|
transformersValue
|
|
9499
9545
|
)) {
|
|
9500
|
-
if (!
|
|
9501
|
-
const result =
|
|
9546
|
+
if (!fe(transformerValue)) continue;
|
|
9547
|
+
const result = Jt(transformerValue, "Transformer");
|
|
9502
9548
|
if (!result.ok) {
|
|
9503
9549
|
errors.push({
|
|
9504
9550
|
path: `flows.${flowName}.transformers.${name}`,
|
|
@@ -9528,15 +9574,15 @@ function validateFlow(input, options = {}) {
|
|
|
9528
9574
|
let totalPackageCount = 0;
|
|
9529
9575
|
if (flows) {
|
|
9530
9576
|
for (const [flowName, flowValue] of Object.entries(flows)) {
|
|
9531
|
-
if (!
|
|
9577
|
+
if (!fe(flowValue)) continue;
|
|
9532
9578
|
const flowConfig = flowValue.config;
|
|
9533
|
-
if (!
|
|
9579
|
+
if (!fe(flowConfig)) continue;
|
|
9534
9580
|
const bundle2 = flowConfig.bundle;
|
|
9535
|
-
if (!
|
|
9581
|
+
if (!fe(bundle2)) continue;
|
|
9536
9582
|
const packages = bundle2.packages;
|
|
9537
|
-
if (!
|
|
9583
|
+
if (!fe(packages)) continue;
|
|
9538
9584
|
for (const [pkgName, pkgConfigValue] of Object.entries(packages)) {
|
|
9539
|
-
if (!
|
|
9585
|
+
if (!fe(pkgConfigValue)) continue;
|
|
9540
9586
|
if (!pkgConfigValue.version && !pkgConfigValue.path) {
|
|
9541
9587
|
warnings.push({
|
|
9542
9588
|
path: `flows.${flowName}.config.bundle.packages.${pkgName}`,
|
|
@@ -9579,9 +9625,9 @@ function validateFlow(input, options = {}) {
|
|
|
9579
9625
|
for (const [destName, dest] of Object.entries(
|
|
9580
9626
|
flowSettings.destinations || {}
|
|
9581
9627
|
)) {
|
|
9582
|
-
if (!
|
|
9628
|
+
if (!fe(dest.config)) continue;
|
|
9583
9629
|
const mapping = dest.config.mapping;
|
|
9584
|
-
if (!
|
|
9630
|
+
if (!fe(mapping)) continue;
|
|
9585
9631
|
for (const key of Object.keys(mapping)) {
|
|
9586
9632
|
if (key.includes(".") && !key.includes(" ")) {
|
|
9587
9633
|
const parts = key.split(".");
|
|
@@ -9609,7 +9655,7 @@ function validateFlow(input, options = {}) {
|
|
|
9609
9655
|
const flowsToResolve = options.flow ? options.flow in flowsMap ? [options.flow] : [] : Object.keys(flowsMap);
|
|
9610
9656
|
for (const name of flowsToResolve) {
|
|
9611
9657
|
try {
|
|
9612
|
-
|
|
9658
|
+
Q(input, name, {
|
|
9613
9659
|
deferred: true,
|
|
9614
9660
|
// don't fail on missing $env when validating
|
|
9615
9661
|
strictFlowRefs: false,
|
|
@@ -9813,16 +9859,16 @@ function lintRoute(spec, position, warnings) {
|
|
|
9813
9859
|
if (!spec) return;
|
|
9814
9860
|
if (typeof spec === "string") return;
|
|
9815
9861
|
if (Array.isArray(spec)) {
|
|
9816
|
-
for (let
|
|
9817
|
-
const entry = spec[
|
|
9818
|
-
if (
|
|
9862
|
+
for (let i3 = 0; i3 < spec.length; i3++) {
|
|
9863
|
+
const entry = spec[i3];
|
|
9864
|
+
if (i3 < spec.length - 1 && typeof entry === "object" && entry !== null && !Array.isArray(entry) && isRouteMany(entry)) {
|
|
9819
9865
|
warnings.push({
|
|
9820
9866
|
path: position,
|
|
9821
9867
|
message: `dead code after many at ${position}: main chain terminates at the many operator`,
|
|
9822
9868
|
suggestion: "Remove entries after the many operator; move them into each many branch if they should still run."
|
|
9823
9869
|
});
|
|
9824
9870
|
}
|
|
9825
|
-
lintRoute(entry, `${position}[${
|
|
9871
|
+
lintRoute(entry, `${position}[${i3}]`, warnings);
|
|
9826
9872
|
}
|
|
9827
9873
|
return;
|
|
9828
9874
|
}
|
|
@@ -9831,8 +9877,8 @@ function lintRoute(spec, position, warnings) {
|
|
|
9831
9877
|
return;
|
|
9832
9878
|
}
|
|
9833
9879
|
if (isRouteOne(spec)) {
|
|
9834
|
-
for (let
|
|
9835
|
-
lintRoute(spec.one[
|
|
9880
|
+
for (let i3 = 0; i3 < spec.one.length; i3++) {
|
|
9881
|
+
lintRoute(spec.one[i3], `${position}.one[${i3}]`, warnings);
|
|
9836
9882
|
}
|
|
9837
9883
|
return;
|
|
9838
9884
|
}
|
|
@@ -9852,8 +9898,8 @@ function lintRoute(spec, position, warnings) {
|
|
|
9852
9898
|
suggestion: "Replace many with next when only one branch exists."
|
|
9853
9899
|
});
|
|
9854
9900
|
}
|
|
9855
|
-
for (let
|
|
9856
|
-
lintRoute(spec.many[
|
|
9901
|
+
for (let i3 = 0; i3 < spec.many.length; i3++) {
|
|
9902
|
+
lintRoute(spec.many[i3], `${position}.many[${i3}]`, warnings);
|
|
9857
9903
|
}
|
|
9858
9904
|
return;
|
|
9859
9905
|
}
|
|
@@ -9944,7 +9990,7 @@ function validateMapping(input) {
|
|
|
9944
9990
|
// src/commands/validate/validators/entry.ts
|
|
9945
9991
|
init_dist();
|
|
9946
9992
|
import Ajv from "ajv";
|
|
9947
|
-
var CLIENT_HEADER = "walkeros-cli/4.1.
|
|
9993
|
+
var CLIENT_HEADER = "walkeros-cli/4.1.3-next-1780071196115";
|
|
9948
9994
|
var SECTIONS = ["destinations", "sources", "transformers"];
|
|
9949
9995
|
function resolveEntry(path19, flowConfig) {
|
|
9950
9996
|
const flows = flowConfig.flows;
|
|
@@ -10020,7 +10066,7 @@ async function validateEntry(path19, flowConfig) {
|
|
|
10020
10066
|
}
|
|
10021
10067
|
let schemas;
|
|
10022
10068
|
try {
|
|
10023
|
-
const info = await
|
|
10069
|
+
const info = await Ot(packageName, {
|
|
10024
10070
|
client: CLIENT_HEADER
|
|
10025
10071
|
});
|
|
10026
10072
|
schemas = info.schemas;
|
|
@@ -10887,7 +10933,7 @@ async function createDeployCommand(config, options) {
|
|
|
10887
10933
|
const result2 = await loadFlowConfig(config, {
|
|
10888
10934
|
flowName: options.flow
|
|
10889
10935
|
});
|
|
10890
|
-
type =
|
|
10936
|
+
type = ee(result2.flowSettings);
|
|
10891
10937
|
}
|
|
10892
10938
|
const deployment = await createDeployment({
|
|
10893
10939
|
type,
|