@walkeros/cli 2.1.0 → 2.2.0-next-1772811722420
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 +31 -0
- package/dist/cli.js +1301 -1149
- package/dist/examples/flow-complete.json +47 -5
- package/dist/index.d.ts +2211 -400
- package/dist/index.js +420 -359
- package/dist/index.js.map +1 -1
- package/dist/runtime/main.js +507 -367
- package/examples/flow-complete.json +47 -5
- package/package.json +5 -5
package/dist/cli.js
CHANGED
|
@@ -1,12 +1,6 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
var __defProp = Object.defineProperty;
|
|
3
3
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
-
var __require = /* @__PURE__ */ ((x4) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x4, {
|
|
5
|
-
get: (a3, b2) => (typeof require !== "undefined" ? require : a3)[b2]
|
|
6
|
-
}) : x4)(function(x4) {
|
|
7
|
-
if (typeof require !== "undefined") return require.apply(this, arguments);
|
|
8
|
-
throw Error('Dynamic require of "' + x4 + '" is not supported');
|
|
9
|
-
});
|
|
10
4
|
var __esm = (fn3, res) => function __init() {
|
|
11
5
|
return fn3 && (res = (0, fn3[__getOwnPropNames(fn3)[0]])(fn3 = 0)), res;
|
|
12
6
|
};
|
|
@@ -45,395 +39,399 @@ var init_version = __esm({
|
|
|
45
39
|
});
|
|
46
40
|
|
|
47
41
|
// ../core/dist/index.mjs
|
|
48
|
-
function
|
|
49
|
-
const n3 = { ...
|
|
50
|
-
for (const o2 of Object.keys(
|
|
51
|
-
const r2 =
|
|
52
|
-
"required" === o2 && Array.isArray(r2) && Array.isArray(i2) ? n3[o2] = [.../* @__PURE__ */ new Set([...r2, ...i2])] :
|
|
42
|
+
function O(e4, t2) {
|
|
43
|
+
const n3 = { ...e4 };
|
|
44
|
+
for (const o2 of Object.keys(t2)) {
|
|
45
|
+
const r2 = e4[o2], i2 = t2[o2];
|
|
46
|
+
"required" === o2 && Array.isArray(r2) && Array.isArray(i2) ? n3[o2] = [.../* @__PURE__ */ new Set([...r2, ...i2])] : S(r2) && S(i2) ? n3[o2] = O(r2, i2) : n3[o2] = i2;
|
|
53
47
|
}
|
|
54
48
|
return n3;
|
|
55
49
|
}
|
|
56
|
-
function
|
|
50
|
+
function $(e4, t2, n3, o2) {
|
|
57
51
|
let r2 = {};
|
|
58
|
-
for (const i2 of [
|
|
52
|
+
for (const i2 of [e4, o2]) {
|
|
59
53
|
if (!i2) continue;
|
|
60
|
-
const
|
|
61
|
-
for (const
|
|
54
|
+
const e5 = [x(i2, "*", "*"), x(i2, "*", n3), x(i2, t2, "*"), x(i2, t2, n3)];
|
|
55
|
+
for (const t3 of e5) t3 && (r2 = O(r2, t3));
|
|
62
56
|
}
|
|
63
57
|
return r2;
|
|
64
58
|
}
|
|
65
|
-
function
|
|
66
|
-
const o2 =
|
|
59
|
+
function x(e4, t2, n3) {
|
|
60
|
+
const o2 = e4[t2];
|
|
67
61
|
if (!o2 || "object" != typeof o2) return;
|
|
68
62
|
const r2 = o2[n3];
|
|
69
63
|
return r2 && "object" == typeof r2 ? r2 : void 0;
|
|
70
64
|
}
|
|
71
|
-
function
|
|
72
|
-
return "object" == typeof
|
|
65
|
+
function S(e4) {
|
|
66
|
+
return "object" == typeof e4 && null !== e4 && !Array.isArray(e4);
|
|
73
67
|
}
|
|
74
|
-
function
|
|
75
|
-
throw new Error(String(
|
|
68
|
+
function E(e4) {
|
|
69
|
+
throw new Error(String(e4));
|
|
76
70
|
}
|
|
77
|
-
function
|
|
78
|
-
const
|
|
79
|
-
for (const n3 of
|
|
80
|
-
return
|
|
71
|
+
function A(...e4) {
|
|
72
|
+
const t2 = {};
|
|
73
|
+
for (const n3 of e4) n3 && Object.assign(t2, n3);
|
|
74
|
+
return t2;
|
|
81
75
|
}
|
|
82
|
-
function
|
|
83
|
-
const
|
|
84
|
-
for (const n3 of
|
|
85
|
-
return
|
|
76
|
+
function N(...e4) {
|
|
77
|
+
const t2 = {};
|
|
78
|
+
for (const n3 of e4) n3 && Object.assign(t2, n3);
|
|
79
|
+
return t2;
|
|
86
80
|
}
|
|
87
|
-
function
|
|
88
|
-
if ("string" == typeof
|
|
89
|
-
const r2 =
|
|
81
|
+
function P(e4, t2, n3, o2) {
|
|
82
|
+
if ("string" == typeof e4) {
|
|
83
|
+
const r2 = e4.match(/^\$def\.([a-zA-Z_][a-zA-Z0-9_]*)$/);
|
|
90
84
|
if (r2) {
|
|
91
|
-
const
|
|
92
|
-
return void 0 === n3[
|
|
85
|
+
const e5 = r2[1];
|
|
86
|
+
return void 0 === n3[e5] && E(`Definition "${e5}" not found`), P(n3[e5], t2, n3, o2);
|
|
93
87
|
}
|
|
94
|
-
let i2 =
|
|
95
|
-
if (void 0 !==
|
|
96
|
-
|
|
88
|
+
let i2 = e4.replace(/\$var\.([a-zA-Z_][a-zA-Z0-9_]*)/g, (e5, n4) => {
|
|
89
|
+
if (void 0 !== t2[n4]) return String(t2[n4]);
|
|
90
|
+
E(`Variable "${n4}" not found`);
|
|
97
91
|
});
|
|
98
|
-
return i2 = i2.replace(/\$env\.([a-zA-Z_][a-zA-Z0-9_]*)(?::([^"}\s]*))?/g, (
|
|
92
|
+
return i2 = i2.replace(/\$env\.([a-zA-Z_][a-zA-Z0-9_]*)(?::([^"}\s]*))?/g, (e5, t3, n4) => o2?.deferred ? void 0 !== n4 ? `${T}${t3}:${n4}` : `${T}${t3}` : "undefined" != typeof process && void 0 !== process.env?.[t3] ? process.env[t3] : void 0 !== n4 ? n4 : void E(`Environment variable "${t3}" not found and no default provided`)), i2;
|
|
99
93
|
}
|
|
100
|
-
if (Array.isArray(
|
|
101
|
-
if (null !==
|
|
94
|
+
if (Array.isArray(e4)) return e4.map((e5) => P(e5, t2, n3, o2));
|
|
95
|
+
if (null !== e4 && "object" == typeof e4) {
|
|
102
96
|
const r2 = {};
|
|
103
|
-
for (const [i2, s3] of Object.entries(
|
|
97
|
+
for (const [i2, s3] of Object.entries(e4)) r2[i2] = P(s3, t2, n3, o2);
|
|
104
98
|
return r2;
|
|
105
99
|
}
|
|
106
|
-
return
|
|
100
|
+
return e4;
|
|
107
101
|
}
|
|
108
|
-
function
|
|
109
|
-
const
|
|
110
|
-
return
|
|
102
|
+
function _(e4) {
|
|
103
|
+
const t2 = e4.startsWith("@"), n3 = e4.replace("@", "").replace(/[/-]/g, "_").split("_").filter((e5) => e5.length > 0).map((e5, t3) => 0 === t3 ? e5 : e5.charAt(0).toUpperCase() + e5.slice(1)).join("");
|
|
104
|
+
return t2 ? "_" + n3 : n3;
|
|
111
105
|
}
|
|
112
|
-
function
|
|
113
|
-
if (
|
|
114
|
-
if (!
|
|
115
|
-
return n3[
|
|
106
|
+
function R(e4, t2, n3) {
|
|
107
|
+
if (t2) return t2;
|
|
108
|
+
if (!e4 || !n3) return;
|
|
109
|
+
return n3[e4] ? _(e4) : void 0;
|
|
116
110
|
}
|
|
117
|
-
function
|
|
118
|
-
const o2 = Object.keys(
|
|
119
|
-
|
|
120
|
-
const r2 =
|
|
121
|
-
r2 ||
|
|
111
|
+
function C(e4, t2, n3) {
|
|
112
|
+
const o2 = Object.keys(e4.flows);
|
|
113
|
+
t2 || (1 === o2.length ? t2 = o2[0] : E(`Multiple flows found (${o2.join(", ")}). Please specify a flow.`));
|
|
114
|
+
const r2 = e4.flows[t2];
|
|
115
|
+
r2 || E(`Flow "${t2}" not found. Available: ${o2.join(", ")}`);
|
|
122
116
|
const i2 = JSON.parse(JSON.stringify(r2));
|
|
123
|
-
if (i2.sources) for (const [
|
|
124
|
-
const s4 =
|
|
125
|
-
i2.sources[
|
|
117
|
+
if (i2.sources) for (const [t3, o3] of Object.entries(i2.sources)) {
|
|
118
|
+
const s4 = A(e4.variables, r2.variables, o3.variables), c3 = N(e4.definitions, r2.definitions, o3.definitions), a3 = P(o3.config, s4, c3, n3), u4 = R(o3.package, o3.code, i2.packages), f2 = "string" == typeof o3.code || "object" == typeof o3.code ? o3.code : void 0, l2 = u4 || f2;
|
|
119
|
+
i2.sources[t3] = { package: o3.package, config: a3, env: o3.env, primary: o3.primary, variables: o3.variables, definitions: o3.definitions, next: o3.next, code: l2 };
|
|
120
|
+
}
|
|
121
|
+
if (i2.destinations) for (const [t3, o3] of Object.entries(i2.destinations)) {
|
|
122
|
+
const s4 = A(e4.variables, r2.variables, o3.variables), c3 = N(e4.definitions, r2.definitions, o3.definitions), a3 = P(o3.config, s4, c3, n3), u4 = R(o3.package, o3.code, i2.packages), f2 = "string" == typeof o3.code || "object" == typeof o3.code ? o3.code : void 0, l2 = u4 || f2;
|
|
123
|
+
i2.destinations[t3] = { package: o3.package, config: a3, env: o3.env, variables: o3.variables, definitions: o3.definitions, before: o3.before, code: l2 };
|
|
126
124
|
}
|
|
127
|
-
if (i2.
|
|
128
|
-
const s4 =
|
|
129
|
-
i2.
|
|
125
|
+
if (i2.stores) for (const [t3, o3] of Object.entries(i2.stores)) {
|
|
126
|
+
const s4 = A(e4.variables, r2.variables, o3.variables), c3 = N(e4.definitions, r2.definitions, o3.definitions), a3 = P(o3.config, s4, c3, n3), u4 = R(o3.package, o3.code, i2.packages), f2 = "string" == typeof o3.code || "object" == typeof o3.code ? o3.code : void 0, l2 = u4 || f2;
|
|
127
|
+
i2.stores[t3] = { package: o3.package, config: a3, env: o3.env, variables: o3.variables, definitions: o3.definitions, code: l2 };
|
|
130
128
|
}
|
|
131
129
|
if (i2.collector) {
|
|
132
|
-
const
|
|
130
|
+
const t3 = A(e4.variables, r2.variables), o3 = N(e4.definitions, r2.definitions), s4 = P(i2.collector, t3, o3, n3);
|
|
133
131
|
i2.collector = s4;
|
|
134
132
|
}
|
|
135
|
-
const s3 =
|
|
133
|
+
const s3 = e4.contract, c2 = r2.contract;
|
|
136
134
|
if (s3 || c2) {
|
|
137
|
-
const
|
|
138
|
-
const
|
|
139
|
-
for (const n6 of
|
|
140
|
-
if (
|
|
141
|
-
const o4 = n6[
|
|
142
|
-
if (o4 && "object" == typeof o4) for (const n7 of Object.keys(o4)) "*" !== n7 &&
|
|
135
|
+
const e5 = (function(...e6) {
|
|
136
|
+
const t4 = /* @__PURE__ */ new Set();
|
|
137
|
+
for (const n6 of e6) if (n6) for (const e7 of Object.keys(n6)) {
|
|
138
|
+
if (e7.startsWith("$")) continue;
|
|
139
|
+
const o4 = n6[e7];
|
|
140
|
+
if (o4 && "object" == typeof o4) for (const n7 of Object.keys(o4)) "*" !== n7 && t4.add(`${e7}\0${n7}`);
|
|
143
141
|
}
|
|
144
142
|
const n5 = /* @__PURE__ */ new Set(), o3 = /* @__PURE__ */ new Set();
|
|
145
|
-
for (const
|
|
146
|
-
if (
|
|
147
|
-
n5.add(
|
|
148
|
-
const r3 =
|
|
149
|
-
if (r3 && "object" == typeof r3) for (const
|
|
150
|
-
}
|
|
151
|
-
for (const
|
|
152
|
-
return [...
|
|
153
|
-
})(s3, c2),
|
|
154
|
-
for (const [n5, o3] of
|
|
155
|
-
const
|
|
156
|
-
Object.keys(
|
|
157
|
-
}
|
|
158
|
-
if (i2.transformers) for (const [,
|
|
143
|
+
for (const t5 of e6) if (t5) for (const e7 of Object.keys(t5)) {
|
|
144
|
+
if (e7.startsWith("$") || "*" === e7) continue;
|
|
145
|
+
n5.add(e7);
|
|
146
|
+
const r3 = t5[e7];
|
|
147
|
+
if (r3 && "object" == typeof r3) for (const e8 of Object.keys(r3)) "*" !== e8 && o3.add(e8);
|
|
148
|
+
}
|
|
149
|
+
for (const e7 of n5) for (const n6 of o3) t4.add(`${e7}\0${n6}`);
|
|
150
|
+
return [...t4].map((e7) => e7.split("\0"));
|
|
151
|
+
})(s3, c2), t3 = {};
|
|
152
|
+
for (const [n5, o3] of e5) {
|
|
153
|
+
const e6 = $(s3 || {}, n5, o3, c2);
|
|
154
|
+
Object.keys(e6).length > 0 && (t3[n5] || (t3[n5] = {}), t3[n5][o3] = { schema: W(e6) });
|
|
155
|
+
}
|
|
156
|
+
if (i2.transformers) for (const [, e6] of Object.entries(i2.transformers)) z(e6.config, t3);
|
|
159
157
|
const n4 = s3?.$tagging ?? c2?.$tagging;
|
|
160
158
|
if ("number" == typeof n4) {
|
|
161
|
-
const
|
|
162
|
-
void 0 ===
|
|
159
|
+
const e6 = i2.collector || {};
|
|
160
|
+
void 0 === e6.tagging && (e6.tagging = n4), i2.collector = e6;
|
|
163
161
|
}
|
|
164
162
|
}
|
|
165
163
|
return i2;
|
|
166
164
|
}
|
|
167
|
-
function
|
|
168
|
-
const
|
|
169
|
-
for (const [n3, o2] of Object.entries(
|
|
170
|
-
return
|
|
165
|
+
function W(e4) {
|
|
166
|
+
const t2 = {};
|
|
167
|
+
for (const [n3, o2] of Object.entries(e4)) M.has(n3) || (null === o2 || "object" != typeof o2 || Array.isArray(o2) ? t2[n3] = o2 : t2[n3] = W(o2));
|
|
168
|
+
return t2;
|
|
171
169
|
}
|
|
172
|
-
function
|
|
173
|
-
if (!
|
|
174
|
-
const n3 =
|
|
175
|
-
for (const
|
|
170
|
+
function z(e4, t2) {
|
|
171
|
+
if (!e4 || "object" != typeof e4) return;
|
|
172
|
+
const n3 = e4;
|
|
173
|
+
for (const e5 of Object.keys(n3)) "$contract" === n3[e5] ? n3[e5] = t2 : "object" == typeof n3[e5] && null !== n3[e5] && z(n3[e5], t2);
|
|
176
174
|
}
|
|
177
|
-
function
|
|
178
|
-
return void 0 !==
|
|
175
|
+
function D(e4) {
|
|
176
|
+
return void 0 !== e4.web ? "web" : void 0 !== e4.server ? "server" : void E("Config must have web or server key");
|
|
179
177
|
}
|
|
180
|
-
function
|
|
181
|
-
n3 = { ...
|
|
182
|
-
const o2 = Object.entries(
|
|
183
|
-
const i2 =
|
|
184
|
-
return n3.merge && Array.isArray(i2) && Array.isArray(r2) ?
|
|
178
|
+
function I(e4, t2 = {}, n3 = {}) {
|
|
179
|
+
n3 = { ...H, ...n3 };
|
|
180
|
+
const o2 = Object.entries(t2).reduce((t3, [o3, r2]) => {
|
|
181
|
+
const i2 = e4[o3];
|
|
182
|
+
return n3.merge && Array.isArray(i2) && Array.isArray(r2) ? t3[o3] = r2.reduce((e5, t4) => e5.includes(t4) ? e5 : [...e5, t4], [...i2]) : (n3.extend || o3 in e4) && (t3[o3] = r2), t3;
|
|
185
183
|
}, {});
|
|
186
|
-
return n3.shallow ? { ...
|
|
184
|
+
return n3.shallow ? { ...e4, ...o2 } : (Object.assign(e4, o2), e4);
|
|
187
185
|
}
|
|
188
|
-
function
|
|
189
|
-
return Array.isArray(
|
|
186
|
+
function U(e4) {
|
|
187
|
+
return Array.isArray(e4);
|
|
190
188
|
}
|
|
191
|
-
function
|
|
192
|
-
return "boolean" == typeof
|
|
189
|
+
function L(e4) {
|
|
190
|
+
return "boolean" == typeof e4;
|
|
193
191
|
}
|
|
194
|
-
function
|
|
195
|
-
return void 0 !==
|
|
192
|
+
function B(e4) {
|
|
193
|
+
return void 0 !== e4;
|
|
196
194
|
}
|
|
197
|
-
function
|
|
198
|
-
return "function" == typeof
|
|
195
|
+
function Z(e4) {
|
|
196
|
+
return "function" == typeof e4;
|
|
199
197
|
}
|
|
200
|
-
function
|
|
201
|
-
return "number" == typeof
|
|
198
|
+
function K(e4) {
|
|
199
|
+
return "number" == typeof e4 && !Number.isNaN(e4);
|
|
202
200
|
}
|
|
203
|
-
function
|
|
204
|
-
return "object" == typeof
|
|
201
|
+
function q(e4) {
|
|
202
|
+
return "object" == typeof e4 && null !== e4 && !U(e4) && "[object Object]" === Object.prototype.toString.call(e4);
|
|
205
203
|
}
|
|
206
|
-
function
|
|
207
|
-
return "string" == typeof
|
|
204
|
+
function X(e4) {
|
|
205
|
+
return "string" == typeof e4;
|
|
208
206
|
}
|
|
209
|
-
function
|
|
210
|
-
if ("object" != typeof
|
|
211
|
-
if (
|
|
212
|
-
const n3 = Object.prototype.toString.call(
|
|
207
|
+
function Q(e4, t2 = /* @__PURE__ */ new WeakMap()) {
|
|
208
|
+
if ("object" != typeof e4 || null === e4) return e4;
|
|
209
|
+
if (t2.has(e4)) return t2.get(e4);
|
|
210
|
+
const n3 = Object.prototype.toString.call(e4);
|
|
213
211
|
if ("[object Object]" === n3) {
|
|
214
212
|
const n4 = {};
|
|
215
|
-
|
|
216
|
-
for (const o2 in
|
|
213
|
+
t2.set(e4, n4);
|
|
214
|
+
for (const o2 in e4) Object.prototype.hasOwnProperty.call(e4, o2) && (n4[o2] = Q(e4[o2], t2));
|
|
217
215
|
return n4;
|
|
218
216
|
}
|
|
219
217
|
if ("[object Array]" === n3) {
|
|
220
218
|
const n4 = [];
|
|
221
|
-
return
|
|
222
|
-
n4.push(
|
|
219
|
+
return t2.set(e4, n4), e4.forEach((e5) => {
|
|
220
|
+
n4.push(Q(e5, t2));
|
|
223
221
|
}), n4;
|
|
224
222
|
}
|
|
225
|
-
if ("[object Date]" === n3) return new Date(
|
|
223
|
+
if ("[object Date]" === n3) return new Date(e4.getTime());
|
|
226
224
|
if ("[object RegExp]" === n3) {
|
|
227
|
-
const
|
|
228
|
-
return new RegExp(
|
|
229
|
-
}
|
|
230
|
-
return
|
|
231
|
-
}
|
|
232
|
-
function
|
|
233
|
-
const o2 =
|
|
234
|
-
let r2 =
|
|
235
|
-
for (let
|
|
236
|
-
const
|
|
237
|
-
if ("*" ===
|
|
238
|
-
const
|
|
239
|
-
for (const
|
|
240
|
-
const o3 =
|
|
225
|
+
const t3 = e4;
|
|
226
|
+
return new RegExp(t3.source, t3.flags);
|
|
227
|
+
}
|
|
228
|
+
return e4;
|
|
229
|
+
}
|
|
230
|
+
function Y(e4, t2 = "", n3) {
|
|
231
|
+
const o2 = t2.split(".");
|
|
232
|
+
let r2 = e4;
|
|
233
|
+
for (let e5 = 0; e5 < o2.length; e5++) {
|
|
234
|
+
const t3 = o2[e5];
|
|
235
|
+
if ("*" === t3 && U(r2)) {
|
|
236
|
+
const t4 = o2.slice(e5 + 1).join("."), i2 = [];
|
|
237
|
+
for (const e6 of r2) {
|
|
238
|
+
const o3 = Y(e6, t4, n3);
|
|
241
239
|
i2.push(o3);
|
|
242
240
|
}
|
|
243
241
|
return i2;
|
|
244
242
|
}
|
|
245
|
-
if (r2 = r2 instanceof Object ? r2[
|
|
243
|
+
if (r2 = r2 instanceof Object ? r2[t3] : void 0, !r2) break;
|
|
246
244
|
}
|
|
247
|
-
return
|
|
245
|
+
return B(r2) ? r2 : n3;
|
|
248
246
|
}
|
|
249
|
-
function
|
|
250
|
-
if (!
|
|
251
|
-
const o2 =
|
|
247
|
+
function ee(e4, t2, n3) {
|
|
248
|
+
if (!q(e4)) return e4;
|
|
249
|
+
const o2 = Q(e4), r2 = t2.split(".");
|
|
252
250
|
let i2 = o2;
|
|
253
|
-
for (let
|
|
254
|
-
const
|
|
255
|
-
|
|
251
|
+
for (let e5 = 0; e5 < r2.length; e5++) {
|
|
252
|
+
const t3 = r2[e5];
|
|
253
|
+
e5 === r2.length - 1 ? i2[t3] = n3 : (t3 in i2 && "object" == typeof i2[t3] && null !== i2[t3] || (i2[t3] = {}), i2 = i2[t3]);
|
|
256
254
|
}
|
|
257
255
|
return o2;
|
|
258
256
|
}
|
|
259
|
-
function
|
|
260
|
-
const o2 = { ...
|
|
261
|
-
let i2 = void 0 ===
|
|
262
|
-
return Object.keys(o2).forEach((
|
|
263
|
-
o2[
|
|
257
|
+
function ne(e4, t2 = {}, n3 = {}) {
|
|
258
|
+
const o2 = { ...t2, ...n3 }, r2 = {};
|
|
259
|
+
let i2 = void 0 === e4;
|
|
260
|
+
return Object.keys(o2).forEach((t3) => {
|
|
261
|
+
o2[t3] && (r2[t3] = true, e4 && e4[t3] && (i2 = true));
|
|
264
262
|
}), !!i2 && r2;
|
|
265
263
|
}
|
|
266
|
-
function
|
|
267
|
-
let
|
|
268
|
-
for (let n3 = 36;
|
|
269
|
-
return
|
|
264
|
+
function se(e4 = 6) {
|
|
265
|
+
let t2 = "";
|
|
266
|
+
for (let n3 = 36; t2.length < e4; ) t2 += (Math.random() * n3 | 0).toString(n3);
|
|
267
|
+
return t2;
|
|
270
268
|
}
|
|
271
|
-
function
|
|
269
|
+
function ae(e4, t2 = 1e3, n3 = false) {
|
|
272
270
|
let o2, r2 = null, i2 = false;
|
|
273
271
|
return (...s3) => new Promise((c2) => {
|
|
274
272
|
const a3 = n3 && !i2;
|
|
275
273
|
r2 && clearTimeout(r2), r2 = setTimeout(() => {
|
|
276
|
-
r2 = null, n3 && !i2 || (o2 =
|
|
277
|
-
},
|
|
274
|
+
r2 = null, n3 && !i2 || (o2 = e4(...s3), c2(o2));
|
|
275
|
+
}, t2), a3 && (i2 = true, o2 = e4(...s3), c2(o2));
|
|
278
276
|
});
|
|
279
277
|
}
|
|
280
|
-
function
|
|
281
|
-
return { message:
|
|
278
|
+
function fe(e4) {
|
|
279
|
+
return { message: e4.message, name: e4.name, stack: e4.stack, cause: e4.cause };
|
|
282
280
|
}
|
|
283
|
-
function
|
|
281
|
+
function le(e4, t2) {
|
|
284
282
|
let n3, o2 = {};
|
|
285
|
-
return
|
|
283
|
+
return e4 instanceof Error ? (n3 = e4.message, o2.error = fe(e4)) : n3 = e4, void 0 !== t2 && (t2 instanceof Error ? o2.error = fe(t2) : "object" == typeof t2 && null !== t2 ? (o2 = { ...o2, ...t2 }, "error" in o2 && o2.error instanceof Error && (o2.error = fe(o2.error))) : o2.value = t2), { message: n3, context: o2 };
|
|
286
284
|
}
|
|
287
|
-
function
|
|
288
|
-
return
|
|
289
|
-
return "string" == typeof
|
|
290
|
-
})(
|
|
285
|
+
function de(e4 = {}) {
|
|
286
|
+
return ge({ level: void 0 !== e4.level ? (function(e5) {
|
|
287
|
+
return "string" == typeof e5 ? u[e5] : e5;
|
|
288
|
+
})(e4.level) : 0, handler: e4.handler, jsonHandler: e4.jsonHandler, scope: [] });
|
|
291
289
|
}
|
|
292
|
-
function
|
|
293
|
-
const { level:
|
|
294
|
-
if (
|
|
295
|
-
const
|
|
296
|
-
n3 ? n3(
|
|
290
|
+
function ge(e4) {
|
|
291
|
+
const { level: t2, handler: n3, jsonHandler: o2, scope: r2 } = e4, i2 = (e5, o3, i3) => {
|
|
292
|
+
if (e5 <= t2) {
|
|
293
|
+
const t3 = le(o3, i3);
|
|
294
|
+
n3 ? n3(e5, t3.message, t3.context, r2, pe) : pe(e5, t3.message, t3.context, r2);
|
|
297
295
|
}
|
|
298
296
|
};
|
|
299
|
-
return { error: (
|
|
300
|
-
const o3 =
|
|
301
|
-
throw n3 ? n3(0, o3.message, o3.context, r2,
|
|
302
|
-
}, json: (
|
|
303
|
-
o2 ? o2(
|
|
304
|
-
}, scope: (
|
|
297
|
+
return { error: (e5, t3) => i2(0, e5, t3), warn: (e5, t3) => i2(1, e5, t3), info: (e5, t3) => i2(2, e5, t3), debug: (e5, t3) => i2(3, e5, t3), throw: (e5, t3) => {
|
|
298
|
+
const o3 = le(e5, t3);
|
|
299
|
+
throw n3 ? n3(0, o3.message, o3.context, r2, pe) : pe(0, o3.message, o3.context, r2), new Error(o3.message);
|
|
300
|
+
}, json: (e5) => {
|
|
301
|
+
o2 ? o2(e5) : console.log(JSON.stringify(e5, null, 2));
|
|
302
|
+
}, scope: (e5) => ge({ level: t2, handler: n3, jsonHandler: o2, scope: [...r2, e5] }) };
|
|
305
303
|
}
|
|
306
|
-
function
|
|
307
|
-
return
|
|
304
|
+
function me(e4) {
|
|
305
|
+
return L(e4) || X(e4) || K(e4) || !B(e4) || U(e4) && e4.every(me) || q(e4) && Object.values(e4).every(me);
|
|
308
306
|
}
|
|
309
|
-
function
|
|
310
|
-
return
|
|
307
|
+
function be(e4) {
|
|
308
|
+
return me(e4) ? e4 : void 0;
|
|
311
309
|
}
|
|
312
|
-
function
|
|
310
|
+
function ve(e4, t2, n3) {
|
|
313
311
|
return function(...o2) {
|
|
314
312
|
try {
|
|
315
|
-
return
|
|
316
|
-
} catch (
|
|
317
|
-
if (!
|
|
318
|
-
return
|
|
313
|
+
return e4(...o2);
|
|
314
|
+
} catch (e5) {
|
|
315
|
+
if (!t2) return;
|
|
316
|
+
return t2(e5);
|
|
319
317
|
} finally {
|
|
320
318
|
n3?.();
|
|
321
319
|
}
|
|
322
320
|
};
|
|
323
321
|
}
|
|
324
|
-
function
|
|
322
|
+
function he(e4, t2, n3) {
|
|
325
323
|
return async function(...o2) {
|
|
326
324
|
try {
|
|
327
|
-
return await
|
|
328
|
-
} catch (
|
|
329
|
-
if (!
|
|
330
|
-
return await
|
|
325
|
+
return await e4(...o2);
|
|
326
|
+
} catch (e5) {
|
|
327
|
+
if (!t2) return;
|
|
328
|
+
return await t2(e5);
|
|
331
329
|
} finally {
|
|
332
330
|
await n3?.();
|
|
333
331
|
}
|
|
334
332
|
};
|
|
335
333
|
}
|
|
336
|
-
async function
|
|
337
|
-
const [n3, o2] = (
|
|
338
|
-
if (!
|
|
334
|
+
async function we(e4, t2) {
|
|
335
|
+
const [n3, o2] = (e4.name || "").split(" ");
|
|
336
|
+
if (!t2 || !n3 || !o2) return {};
|
|
339
337
|
let r2, i2 = "", s3 = n3, c2 = o2;
|
|
340
|
-
const a3 = (
|
|
341
|
-
if (
|
|
338
|
+
const a3 = (t3) => {
|
|
339
|
+
if (t3) return (t3 = U(t3) ? t3 : [t3]).find((t4) => !t4.condition || t4.condition(e4));
|
|
342
340
|
};
|
|
343
|
-
|
|
344
|
-
const u4 =
|
|
345
|
-
return u4 && (u4[c2] || (c2 = "*"), r2 = a3(u4[c2])), r2 || (s3 = "*", c2 = "*", r2 = a3(
|
|
341
|
+
t2[s3] || (s3 = "*");
|
|
342
|
+
const u4 = t2[s3];
|
|
343
|
+
return u4 && (u4[c2] || (c2 = "*"), r2 = a3(u4[c2])), r2 || (s3 = "*", c2 = "*", r2 = a3(t2[s3]?.[c2])), r2 && (i2 = `${s3} ${c2}`), { eventMapping: r2, mappingKey: i2 };
|
|
346
344
|
}
|
|
347
|
-
async function
|
|
348
|
-
if (!
|
|
349
|
-
const o2 =
|
|
350
|
-
for (const
|
|
351
|
-
const r3 = await
|
|
352
|
-
if (
|
|
345
|
+
async function je(e4, t2 = {}, n3 = {}) {
|
|
346
|
+
if (!B(e4)) return;
|
|
347
|
+
const o2 = q(e4) && e4.consent || n3.consent || n3.collector?.consent, r2 = U(t2) ? t2 : [t2];
|
|
348
|
+
for (const t3 of r2) {
|
|
349
|
+
const r3 = await he(ke)(e4, t3, { ...n3, consent: o2 });
|
|
350
|
+
if (B(r3)) return r3;
|
|
353
351
|
}
|
|
354
352
|
}
|
|
355
|
-
async function
|
|
353
|
+
async function ke(e4, t2, n3 = {}) {
|
|
356
354
|
const { collector: o2, consent: r2 } = n3;
|
|
357
|
-
return (
|
|
358
|
-
const s3 = await
|
|
355
|
+
return (U(t2) ? t2 : [t2]).reduce(async (t3, i2) => {
|
|
356
|
+
const s3 = await t3;
|
|
359
357
|
if (s3) return s3;
|
|
360
|
-
const c2 =
|
|
358
|
+
const c2 = X(i2) ? { key: i2 } : i2;
|
|
361
359
|
if (!Object.keys(c2).length) return;
|
|
362
360
|
const { condition: a3, consent: u4, fn: f2, key: l2, loop: p2, map: d2, set: g2, validate: m2, value: y2 } = c2;
|
|
363
|
-
if (a3 && !await
|
|
364
|
-
if (u4 && !
|
|
365
|
-
let b2 =
|
|
366
|
-
if (f2 && (b2 = await
|
|
367
|
-
const [
|
|
368
|
-
|
|
369
|
-
} else d2 ? b2 = await Object.entries(d2).reduce(async (
|
|
370
|
-
const i3 = await
|
|
371
|
-
return
|
|
372
|
-
}, Promise.resolve({})) : g2 && (b2 = await Promise.all(g2.map((
|
|
373
|
-
m2 && !await
|
|
374
|
-
const
|
|
375
|
-
return
|
|
361
|
+
if (a3 && !await he(a3)(e4, i2, o2)) return;
|
|
362
|
+
if (u4 && !ne(u4, r2)) return y2;
|
|
363
|
+
let b2 = B(y2) ? y2 : e4;
|
|
364
|
+
if (f2 && (b2 = await he(f2)(e4, i2, n3)), l2 && (b2 = Y(e4, l2, y2)), p2) {
|
|
365
|
+
const [t4, o3] = p2, r3 = "this" === t4 ? [e4] : await je(e4, t4, n3);
|
|
366
|
+
U(r3) && (b2 = (await Promise.all(r3.map((e5) => je(e5, o3, n3)))).filter(B));
|
|
367
|
+
} else d2 ? b2 = await Object.entries(d2).reduce(async (t4, [o3, r3]) => {
|
|
368
|
+
const i3 = await t4, s4 = await je(e4, r3, n3);
|
|
369
|
+
return B(s4) && (i3[o3] = s4), i3;
|
|
370
|
+
}, Promise.resolve({})) : g2 && (b2 = await Promise.all(g2.map((t4) => ke(e4, t4, n3))));
|
|
371
|
+
m2 && !await he(m2)(b2) && (b2 = void 0);
|
|
372
|
+
const v2 = be(b2);
|
|
373
|
+
return B(v2) ? v2 : be(y2);
|
|
376
374
|
}, Promise.resolve(void 0));
|
|
377
375
|
}
|
|
378
|
-
async function
|
|
379
|
-
|
|
380
|
-
const r3 = await
|
|
381
|
-
|
|
376
|
+
async function Oe(e4, t2, n3) {
|
|
377
|
+
t2.policy && await Promise.all(Object.entries(t2.policy).map(async ([t3, o3]) => {
|
|
378
|
+
const r3 = await je(e4, o3, { collector: n3 });
|
|
379
|
+
e4 = ee(e4, t3, r3);
|
|
382
380
|
}));
|
|
383
|
-
const { eventMapping: o2, mappingKey: r2 } = await
|
|
384
|
-
o2?.policy && await Promise.all(Object.entries(o2.policy).map(async ([
|
|
385
|
-
const r3 = await
|
|
386
|
-
|
|
381
|
+
const { eventMapping: o2, mappingKey: r2 } = await we(e4, t2.mapping);
|
|
382
|
+
o2?.policy && await Promise.all(Object.entries(o2.policy).map(async ([t3, o3]) => {
|
|
383
|
+
const r3 = await je(e4, o3, { collector: n3 });
|
|
384
|
+
e4 = ee(e4, t3, r3);
|
|
387
385
|
}));
|
|
388
|
-
let i2 =
|
|
386
|
+
let i2 = t2.data && await je(e4, t2.data, { collector: n3 });
|
|
389
387
|
if (o2) {
|
|
390
|
-
if (o2.ignore) return { event:
|
|
391
|
-
if (o2.name && (
|
|
392
|
-
const
|
|
393
|
-
i2 =
|
|
388
|
+
if (o2.ignore) return { event: e4, data: i2, mapping: o2, mappingKey: r2, ignore: true };
|
|
389
|
+
if (o2.name && (e4.name = o2.name), o2.data) {
|
|
390
|
+
const t3 = o2.data && await je(e4, o2.data, { collector: n3 });
|
|
391
|
+
i2 = q(i2) && q(t3) ? I(i2, t3) : t3;
|
|
394
392
|
}
|
|
395
393
|
}
|
|
396
|
-
return { event:
|
|
394
|
+
return { event: e4, data: i2, mapping: o2, mappingKey: r2, ignore: false };
|
|
397
395
|
}
|
|
398
|
-
function
|
|
396
|
+
function _e(e4, t2, n3) {
|
|
399
397
|
return function(...o2) {
|
|
400
398
|
let r2;
|
|
401
|
-
const i2 = "post" +
|
|
402
|
-
return r2 = s3 ? s3({ fn:
|
|
399
|
+
const i2 = "post" + t2, s3 = n3["pre" + t2], c2 = n3[i2];
|
|
400
|
+
return r2 = s3 ? s3({ fn: e4 }, ...o2) : e4(...o2), c2 && (r2 = c2({ fn: e4, result: r2 }, ...o2)), r2;
|
|
403
401
|
};
|
|
404
402
|
}
|
|
405
|
-
async function
|
|
406
|
-
const n3 =
|
|
403
|
+
async function Be(e4, t2) {
|
|
404
|
+
const n3 = t2?.version || "latest", o2 = `${Le}/${e4}@${n3}`, r2 = new AbortController(), i2 = setTimeout(() => r2.abort(), t2?.timeout || 1e4);
|
|
407
405
|
try {
|
|
408
|
-
const
|
|
409
|
-
if (!
|
|
410
|
-
const i3 = await
|
|
411
|
-
if (!s3.ok) throw new Error(`walkerOS.json not found at ${
|
|
406
|
+
const t3 = await fetch(`${o2}/package.json`, { signal: r2.signal });
|
|
407
|
+
if (!t3.ok) throw new Error(`Package "${e4}" not found on npm (HTTP ${t3.status})`);
|
|
408
|
+
const i3 = await t3.json(), s3 = await fetch(`${o2}/${Ve}`, { signal: r2.signal });
|
|
409
|
+
if (!s3.ok) throw new Error(`walkerOS.json not found at ${Ve} (HTTP ${s3.status}). This package may not support the walkerOS.json convention yet.`);
|
|
412
410
|
const c2 = await s3.json(), a3 = c2.$meta || {};
|
|
413
|
-
return { packageName:
|
|
411
|
+
return { packageName: e4, version: i3.version || n3, type: a3.type, platform: a3.platform, schemas: c2.schemas || {}, examples: c2.examples || {} };
|
|
414
412
|
} finally {
|
|
415
413
|
clearTimeout(i2);
|
|
416
414
|
}
|
|
417
415
|
}
|
|
418
|
-
var
|
|
416
|
+
var e, a, u, T, M, H, pe, Le, Ve;
|
|
419
417
|
var init_dist = __esm({
|
|
420
418
|
"../core/dist/index.mjs"() {
|
|
421
419
|
"use strict";
|
|
422
|
-
|
|
420
|
+
e = Object.defineProperty;
|
|
423
421
|
a = {};
|
|
424
|
-
((
|
|
425
|
-
for (var o2 in n3)
|
|
422
|
+
((t2, n3) => {
|
|
423
|
+
for (var o2 in n3) e(t2, o2, { get: n3[o2], enumerable: true });
|
|
426
424
|
})(a, { Level: () => u });
|
|
427
|
-
u = ((
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
const r2 = `${u[
|
|
433
|
-
i2 ? s3(r2,
|
|
425
|
+
u = ((e4) => (e4[e4.ERROR = 0] = "ERROR", e4[e4.WARN = 1] = "WARN", e4[e4.INFO = 2] = "INFO", e4[e4.DEBUG = 3] = "DEBUG", e4))(u || {});
|
|
426
|
+
T = "__WALKEROS_ENV:";
|
|
427
|
+
M = /* @__PURE__ */ new Set(["description", "examples", "title", "$comment"]);
|
|
428
|
+
H = { merge: true, shallow: true, extend: true };
|
|
429
|
+
pe = (e4, t2, n3, o2) => {
|
|
430
|
+
const r2 = `${u[e4]}${o2.length > 0 ? ` [${o2.join(":")}]` : ""}`, i2 = Object.keys(n3).length > 0, s3 = 0 === e4 ? console.error : 1 === e4 ? console.warn : console.log;
|
|
431
|
+
i2 ? s3(r2, t2, n3) : s3(r2, t2);
|
|
434
432
|
};
|
|
435
|
-
|
|
436
|
-
|
|
433
|
+
Le = "https://cdn.jsdelivr.net/npm";
|
|
434
|
+
Ve = "dist/walkerOS.json";
|
|
437
435
|
}
|
|
438
436
|
});
|
|
439
437
|
|
|
@@ -447,7 +445,7 @@ function createCLILogger(options = {}) {
|
|
|
447
445
|
stderr = false
|
|
448
446
|
} = options;
|
|
449
447
|
const out = stderr ? console.error : console.log;
|
|
450
|
-
return
|
|
448
|
+
return de({
|
|
451
449
|
// Let handler control visibility — pass everything through
|
|
452
450
|
level: u.DEBUG,
|
|
453
451
|
handler: (level, message, _context, scope) => {
|
|
@@ -707,8 +705,8 @@ function printBanner(version2) {
|
|
|
707
705
|
// src/commands/bundle/index.ts
|
|
708
706
|
init_dist();
|
|
709
707
|
init_cli_logger();
|
|
710
|
-
import
|
|
711
|
-
import
|
|
708
|
+
import path11 from "path";
|
|
709
|
+
import fs11 from "fs-extra";
|
|
712
710
|
|
|
713
711
|
// src/core/index.ts
|
|
714
712
|
init_cli_logger();
|
|
@@ -1590,7 +1588,7 @@ function $constructor(name, initializer3, params) {
|
|
|
1590
1588
|
Object.defineProperty(inst, "_zod", {
|
|
1591
1589
|
value: {
|
|
1592
1590
|
def,
|
|
1593
|
-
constr:
|
|
1591
|
+
constr: _3,
|
|
1594
1592
|
traits: /* @__PURE__ */ new Set()
|
|
1595
1593
|
},
|
|
1596
1594
|
enumerable: false
|
|
@@ -1601,12 +1599,12 @@ function $constructor(name, initializer3, params) {
|
|
|
1601
1599
|
}
|
|
1602
1600
|
inst._zod.traits.add(name);
|
|
1603
1601
|
initializer3(inst, def);
|
|
1604
|
-
const proto =
|
|
1602
|
+
const proto = _3.prototype;
|
|
1605
1603
|
const keys = Object.keys(proto);
|
|
1606
1604
|
for (let i2 = 0; i2 < keys.length; i2++) {
|
|
1607
|
-
const
|
|
1608
|
-
if (!(
|
|
1609
|
-
inst[
|
|
1605
|
+
const k2 = keys[i2];
|
|
1606
|
+
if (!(k2 in inst)) {
|
|
1607
|
+
inst[k2] = proto[k2].bind(inst);
|
|
1610
1608
|
}
|
|
1611
1609
|
}
|
|
1612
1610
|
}
|
|
@@ -1614,7 +1612,7 @@ function $constructor(name, initializer3, params) {
|
|
|
1614
1612
|
class Definition extends Parent {
|
|
1615
1613
|
}
|
|
1616
1614
|
Object.defineProperty(Definition, "name", { value: name });
|
|
1617
|
-
function
|
|
1615
|
+
function _3(def) {
|
|
1618
1616
|
var _a2;
|
|
1619
1617
|
const inst = params?.Parent ? new Definition() : this;
|
|
1620
1618
|
init(inst, def);
|
|
@@ -1624,16 +1622,16 @@ function $constructor(name, initializer3, params) {
|
|
|
1624
1622
|
}
|
|
1625
1623
|
return inst;
|
|
1626
1624
|
}
|
|
1627
|
-
Object.defineProperty(
|
|
1628
|
-
Object.defineProperty(
|
|
1625
|
+
Object.defineProperty(_3, "init", { value: init });
|
|
1626
|
+
Object.defineProperty(_3, Symbol.hasInstance, {
|
|
1629
1627
|
value: (inst) => {
|
|
1630
1628
|
if (params?.Parent && inst instanceof params.Parent)
|
|
1631
1629
|
return true;
|
|
1632
1630
|
return inst?._zod?.traits?.has(name);
|
|
1633
1631
|
}
|
|
1634
1632
|
});
|
|
1635
|
-
Object.defineProperty(
|
|
1636
|
-
return
|
|
1633
|
+
Object.defineProperty(_3, "name", { value: name });
|
|
1634
|
+
return _3;
|
|
1637
1635
|
}
|
|
1638
1636
|
var $brand = /* @__PURE__ */ Symbol("zod_brand");
|
|
1639
1637
|
var $ZodAsyncError = class extends Error {
|
|
@@ -1731,17 +1729,17 @@ function assertIs(_arg) {
|
|
|
1731
1729
|
function assertNever(_x) {
|
|
1732
1730
|
throw new Error("Unexpected value in exhaustive check");
|
|
1733
1731
|
}
|
|
1734
|
-
function assert(
|
|
1732
|
+
function assert(_3) {
|
|
1735
1733
|
}
|
|
1736
1734
|
function getEnumValues(entries) {
|
|
1737
1735
|
const numericValues = Object.values(entries).filter((v2) => typeof v2 === "number");
|
|
1738
|
-
const values = Object.entries(entries).filter(([
|
|
1736
|
+
const values = Object.entries(entries).filter(([k2, _3]) => numericValues.indexOf(+k2) === -1).map(([_3, v2]) => v2);
|
|
1739
1737
|
return values;
|
|
1740
1738
|
}
|
|
1741
1739
|
function joinValues(array2, separator = "|") {
|
|
1742
1740
|
return array2.map((val) => stringifyPrimitive(val)).join(separator);
|
|
1743
1741
|
}
|
|
1744
|
-
function jsonStringifyReplacer(
|
|
1742
|
+
function jsonStringifyReplacer(_3, value) {
|
|
1745
1743
|
if (typeof value === "bigint")
|
|
1746
1744
|
return value.toString();
|
|
1747
1745
|
return value;
|
|
@@ -1827,10 +1825,10 @@ function mergeDefs(...defs) {
|
|
|
1827
1825
|
function cloneDef(schema) {
|
|
1828
1826
|
return mergeDefs(schema._zod.def);
|
|
1829
1827
|
}
|
|
1830
|
-
function getElementAtPath(obj,
|
|
1831
|
-
if (!
|
|
1828
|
+
function getElementAtPath(obj, path15) {
|
|
1829
|
+
if (!path15)
|
|
1832
1830
|
return obj;
|
|
1833
|
-
return
|
|
1831
|
+
return path15.reduce((acc, key) => acc?.[key], obj);
|
|
1834
1832
|
}
|
|
1835
1833
|
function promiseAllObject(promisesObj) {
|
|
1836
1834
|
const keys = Object.keys(promisesObj);
|
|
@@ -1867,10 +1865,10 @@ var allowsEval = cached(() => {
|
|
|
1867
1865
|
return false;
|
|
1868
1866
|
}
|
|
1869
1867
|
try {
|
|
1870
|
-
const
|
|
1871
|
-
new
|
|
1868
|
+
const F3 = Function;
|
|
1869
|
+
new F3("");
|
|
1872
1870
|
return true;
|
|
1873
|
-
} catch (
|
|
1871
|
+
} catch (_3) {
|
|
1874
1872
|
return false;
|
|
1875
1873
|
}
|
|
1876
1874
|
});
|
|
@@ -1907,8 +1905,8 @@ function numKeys(data) {
|
|
|
1907
1905
|
return keyCount;
|
|
1908
1906
|
}
|
|
1909
1907
|
var getParsedType = (data) => {
|
|
1910
|
-
const
|
|
1911
|
-
switch (
|
|
1908
|
+
const t2 = typeof data;
|
|
1909
|
+
switch (t2) {
|
|
1912
1910
|
case "undefined":
|
|
1913
1911
|
return "undefined";
|
|
1914
1912
|
case "string":
|
|
@@ -1947,7 +1945,7 @@ var getParsedType = (data) => {
|
|
|
1947
1945
|
}
|
|
1948
1946
|
return "object";
|
|
1949
1947
|
default:
|
|
1950
|
-
throw new Error(`Unknown data type: ${
|
|
1948
|
+
throw new Error(`Unknown data type: ${t2}`);
|
|
1951
1949
|
}
|
|
1952
1950
|
};
|
|
1953
1951
|
var propertyKeyTypes = /* @__PURE__ */ new Set(["string", "number", "symbol"]);
|
|
@@ -1980,31 +1978,31 @@ function normalizeParams(_params) {
|
|
|
1980
1978
|
function createTransparentProxy(getter) {
|
|
1981
1979
|
let target;
|
|
1982
1980
|
return new Proxy({}, {
|
|
1983
|
-
get(
|
|
1981
|
+
get(_3, prop, receiver) {
|
|
1984
1982
|
target ?? (target = getter());
|
|
1985
1983
|
return Reflect.get(target, prop, receiver);
|
|
1986
1984
|
},
|
|
1987
|
-
set(
|
|
1985
|
+
set(_3, prop, value, receiver) {
|
|
1988
1986
|
target ?? (target = getter());
|
|
1989
1987
|
return Reflect.set(target, prop, value, receiver);
|
|
1990
1988
|
},
|
|
1991
|
-
has(
|
|
1989
|
+
has(_3, prop) {
|
|
1992
1990
|
target ?? (target = getter());
|
|
1993
1991
|
return Reflect.has(target, prop);
|
|
1994
1992
|
},
|
|
1995
|
-
deleteProperty(
|
|
1993
|
+
deleteProperty(_3, prop) {
|
|
1996
1994
|
target ?? (target = getter());
|
|
1997
1995
|
return Reflect.deleteProperty(target, prop);
|
|
1998
1996
|
},
|
|
1999
|
-
ownKeys(
|
|
1997
|
+
ownKeys(_3) {
|
|
2000
1998
|
target ?? (target = getter());
|
|
2001
1999
|
return Reflect.ownKeys(target);
|
|
2002
2000
|
},
|
|
2003
|
-
getOwnPropertyDescriptor(
|
|
2001
|
+
getOwnPropertyDescriptor(_3, prop) {
|
|
2004
2002
|
target ?? (target = getter());
|
|
2005
2003
|
return Reflect.getOwnPropertyDescriptor(target, prop);
|
|
2006
2004
|
},
|
|
2007
|
-
defineProperty(
|
|
2005
|
+
defineProperty(_3, prop, descriptor) {
|
|
2008
2006
|
target ?? (target = getter());
|
|
2009
2007
|
return Reflect.defineProperty(target, prop, descriptor);
|
|
2010
2008
|
}
|
|
@@ -2018,8 +2016,8 @@ function stringifyPrimitive(value) {
|
|
|
2018
2016
|
return `${value}`;
|
|
2019
2017
|
}
|
|
2020
2018
|
function optionalKeys(shape) {
|
|
2021
|
-
return Object.keys(shape).filter((
|
|
2022
|
-
return shape[
|
|
2019
|
+
return Object.keys(shape).filter((k2) => {
|
|
2020
|
+
return shape[k2]._zod.optin === "optional" && shape[k2]._zod.optout === "optional";
|
|
2023
2021
|
});
|
|
2024
2022
|
}
|
|
2025
2023
|
var NUMBER_FORMAT_RANGES = {
|
|
@@ -2213,11 +2211,11 @@ function aborted(x4, startIndex = 0) {
|
|
|
2213
2211
|
}
|
|
2214
2212
|
return false;
|
|
2215
2213
|
}
|
|
2216
|
-
function prefixIssues(
|
|
2214
|
+
function prefixIssues(path15, issues) {
|
|
2217
2215
|
return issues.map((iss) => {
|
|
2218
2216
|
var _a2;
|
|
2219
2217
|
(_a2 = iss).path ?? (_a2.path = []);
|
|
2220
|
-
iss.path.unshift(
|
|
2218
|
+
iss.path.unshift(path15);
|
|
2221
2219
|
return iss;
|
|
2222
2220
|
});
|
|
2223
2221
|
}
|
|
@@ -2254,8 +2252,8 @@ function getLengthableOrigin(input) {
|
|
|
2254
2252
|
return "unknown";
|
|
2255
2253
|
}
|
|
2256
2254
|
function parsedType(data) {
|
|
2257
|
-
const
|
|
2258
|
-
switch (
|
|
2255
|
+
const t2 = typeof data;
|
|
2256
|
+
switch (t2) {
|
|
2259
2257
|
case "number": {
|
|
2260
2258
|
return Number.isNaN(data) ? "nan" : "number";
|
|
2261
2259
|
}
|
|
@@ -2272,7 +2270,7 @@ function parsedType(data) {
|
|
|
2272
2270
|
}
|
|
2273
2271
|
}
|
|
2274
2272
|
}
|
|
2275
|
-
return
|
|
2273
|
+
return t2;
|
|
2276
2274
|
}
|
|
2277
2275
|
function issue(...args) {
|
|
2278
2276
|
const [iss, input, inst] = args;
|
|
@@ -2287,8 +2285,8 @@ function issue(...args) {
|
|
|
2287
2285
|
return { ...iss };
|
|
2288
2286
|
}
|
|
2289
2287
|
function cleanEnum(obj) {
|
|
2290
|
-
return Object.entries(obj).filter(([
|
|
2291
|
-
return Number.isNaN(Number.parseInt(
|
|
2288
|
+
return Object.entries(obj).filter(([k2, _3]) => {
|
|
2289
|
+
return Number.isNaN(Number.parseInt(k2, 10));
|
|
2292
2290
|
}).map((el) => el[1]);
|
|
2293
2291
|
}
|
|
2294
2292
|
function base64ToUint8Array(base643) {
|
|
@@ -2400,7 +2398,7 @@ function formatError(error48, mapper = (issue2) => issue2.message) {
|
|
|
2400
2398
|
}
|
|
2401
2399
|
function treeifyError(error48, mapper = (issue2) => issue2.message) {
|
|
2402
2400
|
const result = { errors: [] };
|
|
2403
|
-
const processError = (error49,
|
|
2401
|
+
const processError = (error49, path15 = []) => {
|
|
2404
2402
|
var _a2, _b;
|
|
2405
2403
|
for (const issue2 of error49.issues) {
|
|
2406
2404
|
if (issue2.code === "invalid_union" && issue2.errors.length) {
|
|
@@ -2410,7 +2408,7 @@ function treeifyError(error48, mapper = (issue2) => issue2.message) {
|
|
|
2410
2408
|
} else if (issue2.code === "invalid_element") {
|
|
2411
2409
|
processError({ issues: issue2.issues }, issue2.path);
|
|
2412
2410
|
} else {
|
|
2413
|
-
const fullpath = [...
|
|
2411
|
+
const fullpath = [...path15, ...issue2.path];
|
|
2414
2412
|
if (fullpath.length === 0) {
|
|
2415
2413
|
result.errors.push(mapper(issue2));
|
|
2416
2414
|
continue;
|
|
@@ -2442,8 +2440,8 @@ function treeifyError(error48, mapper = (issue2) => issue2.message) {
|
|
|
2442
2440
|
}
|
|
2443
2441
|
function toDotPath(_path) {
|
|
2444
2442
|
const segs = [];
|
|
2445
|
-
const
|
|
2446
|
-
for (const seg of
|
|
2443
|
+
const path15 = _path.map((seg) => typeof seg === "object" ? seg.key : seg);
|
|
2444
|
+
for (const seg of path15) {
|
|
2447
2445
|
if (typeof seg === "number")
|
|
2448
2446
|
segs.push(`[${seg}]`);
|
|
2449
2447
|
else if (typeof seg === "symbol")
|
|
@@ -2477,9 +2475,9 @@ var _parse = (_Err) => (schema, value, _ctx, _params) => {
|
|
|
2477
2475
|
throw new $ZodAsyncError();
|
|
2478
2476
|
}
|
|
2479
2477
|
if (result.issues.length) {
|
|
2480
|
-
const
|
|
2481
|
-
captureStackTrace(
|
|
2482
|
-
throw
|
|
2478
|
+
const e4 = new (_params?.Err ?? _Err)(result.issues.map((iss) => finalizeIssue(iss, ctx, config())));
|
|
2479
|
+
captureStackTrace(e4, _params?.callee);
|
|
2480
|
+
throw e4;
|
|
2483
2481
|
}
|
|
2484
2482
|
return result.value;
|
|
2485
2483
|
};
|
|
@@ -2490,9 +2488,9 @@ var _parseAsync = (_Err) => async (schema, value, _ctx, params) => {
|
|
|
2490
2488
|
if (result instanceof Promise)
|
|
2491
2489
|
result = await result;
|
|
2492
2490
|
if (result.issues.length) {
|
|
2493
|
-
const
|
|
2494
|
-
captureStackTrace(
|
|
2495
|
-
throw
|
|
2491
|
+
const e4 = new (params?.Err ?? _Err)(result.issues.map((iss) => finalizeIssue(iss, ctx, config())));
|
|
2492
|
+
captureStackTrace(e4, params?.callee);
|
|
2493
|
+
throw e4;
|
|
2496
2494
|
}
|
|
2497
2495
|
return result.value;
|
|
2498
2496
|
};
|
|
@@ -3290,11 +3288,11 @@ var Doc = class {
|
|
|
3290
3288
|
}
|
|
3291
3289
|
}
|
|
3292
3290
|
compile() {
|
|
3293
|
-
const
|
|
3291
|
+
const F3 = Function;
|
|
3294
3292
|
const args = this?.args;
|
|
3295
3293
|
const content = this?.content ?? [``];
|
|
3296
3294
|
const lines = [...content.map((x4) => ` ${x4}`)];
|
|
3297
|
-
return new
|
|
3295
|
+
return new F3(...args, lines.join("\n"));
|
|
3298
3296
|
}
|
|
3299
3297
|
};
|
|
3300
3298
|
|
|
@@ -3339,13 +3337,13 @@ var $ZodType = /* @__PURE__ */ $constructor("$ZodType", (inst, def) => {
|
|
|
3339
3337
|
continue;
|
|
3340
3338
|
}
|
|
3341
3339
|
const currLen = payload.issues.length;
|
|
3342
|
-
const
|
|
3343
|
-
if (
|
|
3340
|
+
const _3 = ch._zod.check(payload);
|
|
3341
|
+
if (_3 instanceof Promise && ctx?.async === false) {
|
|
3344
3342
|
throw new $ZodAsyncError();
|
|
3345
3343
|
}
|
|
3346
|
-
if (asyncResult ||
|
|
3344
|
+
if (asyncResult || _3 instanceof Promise) {
|
|
3347
3345
|
asyncResult = (asyncResult ?? Promise.resolve()).then(async () => {
|
|
3348
|
-
await
|
|
3346
|
+
await _3;
|
|
3349
3347
|
const nextLen = payload.issues.length;
|
|
3350
3348
|
if (nextLen === currLen)
|
|
3351
3349
|
return;
|
|
@@ -3407,7 +3405,7 @@ var $ZodType = /* @__PURE__ */ $constructor("$ZodType", (inst, def) => {
|
|
|
3407
3405
|
try {
|
|
3408
3406
|
const r2 = safeParse(inst, value);
|
|
3409
3407
|
return r2.success ? { value: r2.data } : { issues: r2.error?.issues };
|
|
3410
|
-
} catch (
|
|
3408
|
+
} catch (_3) {
|
|
3411
3409
|
return safeParseAsync(inst, value).then((r2) => r2.success ? { value: r2.data } : { issues: r2.error?.issues });
|
|
3412
3410
|
}
|
|
3413
3411
|
},
|
|
@@ -3418,11 +3416,11 @@ var $ZodType = /* @__PURE__ */ $constructor("$ZodType", (inst, def) => {
|
|
|
3418
3416
|
var $ZodString = /* @__PURE__ */ $constructor("$ZodString", (inst, def) => {
|
|
3419
3417
|
$ZodType.init(inst, def);
|
|
3420
3418
|
inst._zod.pattern = [...inst?._zod.bag?.patterns ?? []].pop() ?? string(inst._zod.bag);
|
|
3421
|
-
inst._zod.parse = (payload,
|
|
3419
|
+
inst._zod.parse = (payload, _3) => {
|
|
3422
3420
|
if (def.coerce)
|
|
3423
3421
|
try {
|
|
3424
3422
|
payload.value = String(payload.value);
|
|
3425
|
-
} catch (
|
|
3423
|
+
} catch (_4) {
|
|
3426
3424
|
}
|
|
3427
3425
|
if (typeof payload.value === "string")
|
|
3428
3426
|
return payload;
|
|
@@ -3507,7 +3505,7 @@ var $ZodURL = /* @__PURE__ */ $constructor("$ZodURL", (inst, def) => {
|
|
|
3507
3505
|
payload.value = trimmed;
|
|
3508
3506
|
}
|
|
3509
3507
|
return;
|
|
3510
|
-
} catch (
|
|
3508
|
+
} catch (_3) {
|
|
3511
3509
|
payload.issues.push({
|
|
3512
3510
|
code: "invalid_format",
|
|
3513
3511
|
format: "url",
|
|
@@ -3732,7 +3730,7 @@ var $ZodNumber = /* @__PURE__ */ $constructor("$ZodNumber", (inst, def) => {
|
|
|
3732
3730
|
if (def.coerce)
|
|
3733
3731
|
try {
|
|
3734
3732
|
payload.value = Number(payload.value);
|
|
3735
|
-
} catch (
|
|
3733
|
+
} catch (_3) {
|
|
3736
3734
|
}
|
|
3737
3735
|
const input = payload.value;
|
|
3738
3736
|
if (typeof input === "number" && !Number.isNaN(input) && Number.isFinite(input)) {
|
|
@@ -3760,7 +3758,7 @@ var $ZodBoolean = /* @__PURE__ */ $constructor("$ZodBoolean", (inst, def) => {
|
|
|
3760
3758
|
if (def.coerce)
|
|
3761
3759
|
try {
|
|
3762
3760
|
payload.value = Boolean(payload.value);
|
|
3763
|
-
} catch (
|
|
3761
|
+
} catch (_3) {
|
|
3764
3762
|
}
|
|
3765
3763
|
const input = payload.value;
|
|
3766
3764
|
if (typeof input === "boolean")
|
|
@@ -3781,7 +3779,7 @@ var $ZodBigInt = /* @__PURE__ */ $constructor("$ZodBigInt", (inst, def) => {
|
|
|
3781
3779
|
if (def.coerce)
|
|
3782
3780
|
try {
|
|
3783
3781
|
payload.value = BigInt(payload.value);
|
|
3784
|
-
} catch (
|
|
3782
|
+
} catch (_3) {
|
|
3785
3783
|
}
|
|
3786
3784
|
if (typeof payload.value === "bigint")
|
|
3787
3785
|
return payload;
|
|
@@ -3964,9 +3962,9 @@ function handlePropertyResult(result, final, key, input, isOptionalOut) {
|
|
|
3964
3962
|
}
|
|
3965
3963
|
function normalizeDef(def) {
|
|
3966
3964
|
const keys = Object.keys(def.shape);
|
|
3967
|
-
for (const
|
|
3968
|
-
if (!def.shape?.[
|
|
3969
|
-
throw new Error(`Invalid element at key "${
|
|
3965
|
+
for (const k2 of keys) {
|
|
3966
|
+
if (!def.shape?.[k2]?._zod?.traits?.has("$ZodType")) {
|
|
3967
|
+
throw new Error(`Invalid element at key "${k2}": expected a Zod schema`);
|
|
3970
3968
|
}
|
|
3971
3969
|
}
|
|
3972
3970
|
const okeys = optionalKeys(def.shape);
|
|
@@ -3982,12 +3980,12 @@ function handleCatchall(proms, input, payload, ctx, def, inst) {
|
|
|
3982
3980
|
const unrecognized = [];
|
|
3983
3981
|
const keySet = def.keySet;
|
|
3984
3982
|
const _catchall = def.catchall._zod;
|
|
3985
|
-
const
|
|
3983
|
+
const t2 = _catchall.def.type;
|
|
3986
3984
|
const isOptionalOut = _catchall.optout === "optional";
|
|
3987
3985
|
for (const key in input) {
|
|
3988
3986
|
if (keySet.has(key))
|
|
3989
3987
|
continue;
|
|
3990
|
-
if (
|
|
3988
|
+
if (t2 === "never") {
|
|
3991
3989
|
unrecognized.push(key);
|
|
3992
3990
|
continue;
|
|
3993
3991
|
}
|
|
@@ -4083,8 +4081,8 @@ var $ZodObjectJIT = /* @__PURE__ */ $constructor("$ZodObjectJIT", (inst, def) =>
|
|
|
4083
4081
|
const doc = new Doc(["shape", "payload", "ctx"]);
|
|
4084
4082
|
const normalized = _normalized.value;
|
|
4085
4083
|
const parseStr = (key) => {
|
|
4086
|
-
const
|
|
4087
|
-
return `shape[${
|
|
4084
|
+
const k2 = esc(key);
|
|
4085
|
+
return `shape[${k2}]._zod.run({ value: input[${k2}], issues: [] }, ctx)`;
|
|
4088
4086
|
};
|
|
4089
4087
|
doc.write(`const input = payload.value;`);
|
|
4090
4088
|
const ids = /* @__PURE__ */ Object.create(null);
|
|
@@ -4095,27 +4093,27 @@ var $ZodObjectJIT = /* @__PURE__ */ $constructor("$ZodObjectJIT", (inst, def) =>
|
|
|
4095
4093
|
doc.write(`const newResult = {};`);
|
|
4096
4094
|
for (const key of normalized.keys) {
|
|
4097
4095
|
const id = ids[key];
|
|
4098
|
-
const
|
|
4096
|
+
const k2 = esc(key);
|
|
4099
4097
|
const schema = shape[key];
|
|
4100
4098
|
const isOptionalOut = schema?._zod?.optout === "optional";
|
|
4101
4099
|
doc.write(`const ${id} = ${parseStr(key)};`);
|
|
4102
4100
|
if (isOptionalOut) {
|
|
4103
4101
|
doc.write(`
|
|
4104
4102
|
if (${id}.issues.length) {
|
|
4105
|
-
if (${
|
|
4103
|
+
if (${k2} in input) {
|
|
4106
4104
|
payload.issues = payload.issues.concat(${id}.issues.map(iss => ({
|
|
4107
4105
|
...iss,
|
|
4108
|
-
path: iss.path ? [${
|
|
4106
|
+
path: iss.path ? [${k2}, ...iss.path] : [${k2}]
|
|
4109
4107
|
})));
|
|
4110
4108
|
}
|
|
4111
4109
|
}
|
|
4112
4110
|
|
|
4113
4111
|
if (${id}.value === undefined) {
|
|
4114
|
-
if (${
|
|
4115
|
-
newResult[${
|
|
4112
|
+
if (${k2} in input) {
|
|
4113
|
+
newResult[${k2}] = undefined;
|
|
4116
4114
|
}
|
|
4117
4115
|
} else {
|
|
4118
|
-
newResult[${
|
|
4116
|
+
newResult[${k2}] = ${id}.value;
|
|
4119
4117
|
}
|
|
4120
4118
|
|
|
4121
4119
|
`);
|
|
@@ -4124,16 +4122,16 @@ var $ZodObjectJIT = /* @__PURE__ */ $constructor("$ZodObjectJIT", (inst, def) =>
|
|
|
4124
4122
|
if (${id}.issues.length) {
|
|
4125
4123
|
payload.issues = payload.issues.concat(${id}.issues.map(iss => ({
|
|
4126
4124
|
...iss,
|
|
4127
|
-
path: iss.path ? [${
|
|
4125
|
+
path: iss.path ? [${k2}, ...iss.path] : [${k2}]
|
|
4128
4126
|
})));
|
|
4129
4127
|
}
|
|
4130
4128
|
|
|
4131
4129
|
if (${id}.value === undefined) {
|
|
4132
|
-
if (${
|
|
4133
|
-
newResult[${
|
|
4130
|
+
if (${k2} in input) {
|
|
4131
|
+
newResult[${k2}] = undefined;
|
|
4134
4132
|
}
|
|
4135
4133
|
} else {
|
|
4136
|
-
newResult[${
|
|
4134
|
+
newResult[${k2}] = ${id}.value;
|
|
4137
4135
|
}
|
|
4138
4136
|
|
|
4139
4137
|
`);
|
|
@@ -4304,11 +4302,11 @@ var $ZodDiscriminatedUnion = /* @__PURE__ */ $constructor("$ZodDiscriminatedUnio
|
|
|
4304
4302
|
const pv = option._zod.propValues;
|
|
4305
4303
|
if (!pv || Object.keys(pv).length === 0)
|
|
4306
4304
|
throw new Error(`Invalid discriminated union option at index "${def.options.indexOf(option)}"`);
|
|
4307
|
-
for (const [
|
|
4308
|
-
if (!propValues[
|
|
4309
|
-
propValues[
|
|
4305
|
+
for (const [k2, v2] of Object.entries(pv)) {
|
|
4306
|
+
if (!propValues[k2])
|
|
4307
|
+
propValues[k2] = /* @__PURE__ */ new Set();
|
|
4310
4308
|
for (const val of v2) {
|
|
4311
|
-
propValues[
|
|
4309
|
+
propValues[k2].add(val);
|
|
4312
4310
|
}
|
|
4313
4311
|
}
|
|
4314
4312
|
}
|
|
@@ -4425,10 +4423,10 @@ function handleIntersectionResults(result, left, right) {
|
|
|
4425
4423
|
for (const iss of left.issues) {
|
|
4426
4424
|
if (iss.code === "unrecognized_keys") {
|
|
4427
4425
|
unrecIssue ?? (unrecIssue = iss);
|
|
4428
|
-
for (const
|
|
4429
|
-
if (!unrecKeys.has(
|
|
4430
|
-
unrecKeys.set(
|
|
4431
|
-
unrecKeys.get(
|
|
4426
|
+
for (const k2 of iss.keys) {
|
|
4427
|
+
if (!unrecKeys.has(k2))
|
|
4428
|
+
unrecKeys.set(k2, {});
|
|
4429
|
+
unrecKeys.get(k2).l = true;
|
|
4432
4430
|
}
|
|
4433
4431
|
} else {
|
|
4434
4432
|
result.issues.push(iss);
|
|
@@ -4436,16 +4434,16 @@ function handleIntersectionResults(result, left, right) {
|
|
|
4436
4434
|
}
|
|
4437
4435
|
for (const iss of right.issues) {
|
|
4438
4436
|
if (iss.code === "unrecognized_keys") {
|
|
4439
|
-
for (const
|
|
4440
|
-
if (!unrecKeys.has(
|
|
4441
|
-
unrecKeys.set(
|
|
4442
|
-
unrecKeys.get(
|
|
4437
|
+
for (const k2 of iss.keys) {
|
|
4438
|
+
if (!unrecKeys.has(k2))
|
|
4439
|
+
unrecKeys.set(k2, {});
|
|
4440
|
+
unrecKeys.get(k2).r = true;
|
|
4443
4441
|
}
|
|
4444
4442
|
} else {
|
|
4445
4443
|
result.issues.push(iss);
|
|
4446
4444
|
}
|
|
4447
4445
|
}
|
|
4448
|
-
const bothKeys = [...unrecKeys].filter(([, f2]) => f2.l && f2.r).map(([
|
|
4446
|
+
const bothKeys = [...unrecKeys].filter(([, f2]) => f2.l && f2.r).map(([k2]) => k2);
|
|
4449
4447
|
if (bothKeys.length && unrecIssue) {
|
|
4450
4448
|
result.issues.push({ ...unrecIssue, keys: bothKeys });
|
|
4451
4449
|
}
|
|
@@ -4739,7 +4737,7 @@ var $ZodEnum = /* @__PURE__ */ $constructor("$ZodEnum", (inst, def) => {
|
|
|
4739
4737
|
const values = getEnumValues(def.entries);
|
|
4740
4738
|
const valuesSet = new Set(values);
|
|
4741
4739
|
inst._zod.values = valuesSet;
|
|
4742
|
-
inst._zod.pattern = new RegExp(`^(${values.filter((
|
|
4740
|
+
inst._zod.pattern = new RegExp(`^(${values.filter((k2) => propertyKeyTypes.has(typeof k2)).map((o2) => typeof o2 === "string" ? escapeRegex(o2) : o2.toString()).join("|")})$`);
|
|
4743
4741
|
inst._zod.parse = (payload, _ctx) => {
|
|
4744
4742
|
const input = payload.value;
|
|
4745
4743
|
if (valuesSet.has(input)) {
|
|
@@ -5196,9 +5194,9 @@ var $ZodFunction = /* @__PURE__ */ $constructor("$ZodFunction", (inst, def) => {
|
|
|
5196
5194
|
return payload;
|
|
5197
5195
|
};
|
|
5198
5196
|
inst.input = (...args) => {
|
|
5199
|
-
const
|
|
5197
|
+
const F3 = inst.constructor;
|
|
5200
5198
|
if (Array.isArray(args[0])) {
|
|
5201
|
-
return new
|
|
5199
|
+
return new F3({
|
|
5202
5200
|
type: "function",
|
|
5203
5201
|
input: new $ZodTuple({
|
|
5204
5202
|
type: "tuple",
|
|
@@ -5208,15 +5206,15 @@ var $ZodFunction = /* @__PURE__ */ $constructor("$ZodFunction", (inst, def) => {
|
|
|
5208
5206
|
output: inst._def.output
|
|
5209
5207
|
});
|
|
5210
5208
|
}
|
|
5211
|
-
return new
|
|
5209
|
+
return new F3({
|
|
5212
5210
|
type: "function",
|
|
5213
5211
|
input: args[0],
|
|
5214
5212
|
output: inst._def.output
|
|
5215
5213
|
});
|
|
5216
5214
|
};
|
|
5217
5215
|
inst.output = (output) => {
|
|
5218
|
-
const
|
|
5219
|
-
return new
|
|
5216
|
+
const F3 = inst.constructor;
|
|
5217
|
+
return new F3({
|
|
5220
5218
|
type: "function",
|
|
5221
5219
|
input: inst._def.input,
|
|
5222
5220
|
output
|
|
@@ -5245,7 +5243,7 @@ var $ZodLazy = /* @__PURE__ */ $constructor("$ZodLazy", (inst, def) => {
|
|
|
5245
5243
|
var $ZodCustom = /* @__PURE__ */ $constructor("$ZodCustom", (inst, def) => {
|
|
5246
5244
|
$ZodCheck.init(inst, def);
|
|
5247
5245
|
$ZodType.init(inst, def);
|
|
5248
|
-
inst._zod.parse = (payload,
|
|
5246
|
+
inst._zod.parse = (payload, _3) => {
|
|
5249
5247
|
return payload;
|
|
5250
5248
|
};
|
|
5251
5249
|
inst._zod.check = (payload) => {
|
|
@@ -7094,17 +7092,17 @@ var error16 = () => {
|
|
|
7094
7092
|
number: { unit: "", shortLabel: "\u05E7\u05D8\u05DF", longLabel: "\u05D2\u05D3\u05D5\u05DC" }
|
|
7095
7093
|
// no unit
|
|
7096
7094
|
};
|
|
7097
|
-
const typeEntry = (
|
|
7098
|
-
const typeLabel = (
|
|
7099
|
-
const
|
|
7100
|
-
if (
|
|
7101
|
-
return
|
|
7102
|
-
return
|
|
7103
|
-
};
|
|
7104
|
-
const withDefinite = (
|
|
7105
|
-
const verbFor = (
|
|
7106
|
-
const
|
|
7107
|
-
const gender =
|
|
7095
|
+
const typeEntry = (t2) => t2 ? TypeNames[t2] : void 0;
|
|
7096
|
+
const typeLabel = (t2) => {
|
|
7097
|
+
const e4 = typeEntry(t2);
|
|
7098
|
+
if (e4)
|
|
7099
|
+
return e4.label;
|
|
7100
|
+
return t2 ?? TypeNames.unknown.label;
|
|
7101
|
+
};
|
|
7102
|
+
const withDefinite = (t2) => `\u05D4${typeLabel(t2)}`;
|
|
7103
|
+
const verbFor = (t2) => {
|
|
7104
|
+
const e4 = typeEntry(t2);
|
|
7105
|
+
const gender = e4?.gender ?? "m";
|
|
7108
7106
|
return gender === "f" ? "\u05E6\u05E8\u05D9\u05DB\u05D4 \u05DC\u05D4\u05D9\u05D5\u05EA" : "\u05E6\u05E8\u05D9\u05DA \u05DC\u05D4\u05D9\u05D5\u05EA";
|
|
7109
7107
|
};
|
|
7110
7108
|
const getSizing = (origin) => {
|
|
@@ -7187,11 +7185,11 @@ var error16 = () => {
|
|
|
7187
7185
|
return `\u05D2\u05D3\u05D5\u05DC \u05DE\u05D3\u05D9: ${subject} ${verb} \u05DC\u05D4\u05DB\u05D9\u05DC ${comparison}`.trim();
|
|
7188
7186
|
}
|
|
7189
7187
|
const adj = issue2.inclusive ? "<=" : "<";
|
|
7190
|
-
const
|
|
7188
|
+
const be3 = verbFor(issue2.origin ?? "value");
|
|
7191
7189
|
if (sizing?.unit) {
|
|
7192
|
-
return `${sizing.longLabel} \u05DE\u05D3\u05D9: ${subject} ${
|
|
7190
|
+
return `${sizing.longLabel} \u05DE\u05D3\u05D9: ${subject} ${be3} ${adj}${issue2.maximum.toString()} ${sizing.unit}`;
|
|
7193
7191
|
}
|
|
7194
|
-
return `${sizing?.longLabel ?? "\u05D2\u05D3\u05D5\u05DC"} \u05DE\u05D3\u05D9: ${subject} ${
|
|
7192
|
+
return `${sizing?.longLabel ?? "\u05D2\u05D3\u05D5\u05DC"} \u05DE\u05D3\u05D9: ${subject} ${be3} ${adj}${issue2.maximum.toString()}`;
|
|
7195
7193
|
}
|
|
7196
7194
|
case "too_small": {
|
|
7197
7195
|
const sizing = getSizing(issue2.origin);
|
|
@@ -7213,11 +7211,11 @@ var error16 = () => {
|
|
|
7213
7211
|
return `\u05E7\u05D8\u05DF \u05DE\u05D3\u05D9: ${subject} ${verb} \u05DC\u05D4\u05DB\u05D9\u05DC ${comparison}`.trim();
|
|
7214
7212
|
}
|
|
7215
7213
|
const adj = issue2.inclusive ? ">=" : ">";
|
|
7216
|
-
const
|
|
7214
|
+
const be3 = verbFor(issue2.origin ?? "value");
|
|
7217
7215
|
if (sizing?.unit) {
|
|
7218
|
-
return `${sizing.shortLabel} \u05DE\u05D3\u05D9: ${subject} ${
|
|
7216
|
+
return `${sizing.shortLabel} \u05DE\u05D3\u05D9: ${subject} ${be3} ${adj}${issue2.minimum.toString()} ${sizing.unit}`;
|
|
7219
7217
|
}
|
|
7220
|
-
return `${sizing?.shortLabel ?? "\u05E7\u05D8\u05DF"} \u05DE\u05D3\u05D9: ${subject} ${
|
|
7218
|
+
return `${sizing?.shortLabel ?? "\u05E7\u05D8\u05DF"} \u05DE\u05D3\u05D9: ${subject} ${be3} ${adj}${issue2.minimum.toString()}`;
|
|
7221
7219
|
}
|
|
7222
7220
|
case "invalid_format": {
|
|
7223
7221
|
const _issue = issue2;
|
|
@@ -12816,7 +12814,7 @@ function toJSONSchema(input, params) {
|
|
|
12816
12814
|
const ctx2 = initializeContext({ ...params, processors: allProcessors });
|
|
12817
12815
|
const defs = {};
|
|
12818
12816
|
for (const entry of registry2._idmap.entries()) {
|
|
12819
|
-
const [
|
|
12817
|
+
const [_3, schema] = entry;
|
|
12820
12818
|
process2(schema, ctx2);
|
|
12821
12819
|
}
|
|
12822
12820
|
const schemas = {};
|
|
@@ -12915,7 +12913,7 @@ var JSONSchemaGenerator = class {
|
|
|
12915
12913
|
}
|
|
12916
12914
|
extractDefs(this.ctx, schema);
|
|
12917
12915
|
const result = finalize(this.ctx, schema);
|
|
12918
|
-
const { "~standard":
|
|
12916
|
+
const { "~standard": _3, ...plainResult } = result;
|
|
12919
12917
|
return plainResult;
|
|
12920
12918
|
}
|
|
12921
12919
|
};
|
|
@@ -13858,11 +13856,11 @@ function record(keyType, valueType, params) {
|
|
|
13858
13856
|
});
|
|
13859
13857
|
}
|
|
13860
13858
|
function partialRecord(keyType, valueType, params) {
|
|
13861
|
-
const
|
|
13862
|
-
|
|
13859
|
+
const k2 = clone(keyType);
|
|
13860
|
+
k2._zod.values = void 0;
|
|
13863
13861
|
return new ZodRecord({
|
|
13864
13862
|
type: "record",
|
|
13865
|
-
keyType:
|
|
13863
|
+
keyType: k2,
|
|
13866
13864
|
valueType,
|
|
13867
13865
|
...util_exports.normalizeParams(params)
|
|
13868
13866
|
});
|
|
@@ -14420,13 +14418,13 @@ function resolveRef(ref, ctx) {
|
|
|
14420
14418
|
if (!ref.startsWith("#")) {
|
|
14421
14419
|
throw new Error("External $ref is not supported, only local refs (#/...) are allowed");
|
|
14422
14420
|
}
|
|
14423
|
-
const
|
|
14424
|
-
if (
|
|
14421
|
+
const path15 = ref.slice(1).split("/").filter(Boolean);
|
|
14422
|
+
if (path15.length === 0) {
|
|
14425
14423
|
return ctx.rootSchema;
|
|
14426
14424
|
}
|
|
14427
14425
|
const defsKey = ctx.version === "draft-2020-12" ? "$defs" : "definitions";
|
|
14428
|
-
if (
|
|
14429
|
-
const key =
|
|
14426
|
+
if (path15[0] === defsKey) {
|
|
14427
|
+
const key = path15[1];
|
|
14430
14428
|
if (!key || !ctx.defs[key]) {
|
|
14431
14429
|
throw new Error(`Reference not found: ${ref}`);
|
|
14432
14430
|
}
|
|
@@ -14498,8 +14496,8 @@ function convertBaseSchema(schema, ctx) {
|
|
|
14498
14496
|
}
|
|
14499
14497
|
const type = schema.type;
|
|
14500
14498
|
if (Array.isArray(type)) {
|
|
14501
|
-
const typeSchemas = type.map((
|
|
14502
|
-
const typeSchema = { ...schema, type:
|
|
14499
|
+
const typeSchemas = type.map((t2) => {
|
|
14500
|
+
const typeSchema = { ...schema, type: t2 };
|
|
14503
14501
|
return convertBaseSchema(typeSchema, ctx);
|
|
14504
14502
|
});
|
|
14505
14503
|
if (typeSchemas.length === 0) {
|
|
@@ -14829,14 +14827,14 @@ function date4(params) {
|
|
|
14829
14827
|
config(en_default());
|
|
14830
14828
|
|
|
14831
14829
|
// ../core/dist/dev.mjs
|
|
14832
|
-
var
|
|
14830
|
+
var e2 = Object.defineProperty;
|
|
14833
14831
|
var n = (n3, i2) => {
|
|
14834
|
-
for (var
|
|
14832
|
+
for (var t2 in i2) e2(n3, t2, { get: i2[t2], enumerable: true });
|
|
14835
14833
|
};
|
|
14836
14834
|
var i = {};
|
|
14837
|
-
n(i, { BaseContextConfig: () => z3, BatchConfig: () =>
|
|
14838
|
-
function o(
|
|
14839
|
-
return external_exports.toJSONSchema(
|
|
14835
|
+
n(i, { BaseContextConfig: () => z3, BatchConfig: () => U2, CollectorSchemas: () => sn, ConsentSchema: () => K2, ContractActionsSchema: () => Xn, ContractSchema: () => Yn, ContractSchemaEntry: () => Kn, Counter: () => d, DeepPartialEventSchema: () => oe, DestinationReferenceSchema: () => Qn, DestinationSchemas: () => Ne, DestinationsMapConfig: () => $2, EntitiesSchema: () => ne2, EntitySchema: () => ee2, EventSchema: () => ie, FlowConfigSchema: () => Zn, FlowSchemas: () => Tn, GenericEnvConfig: () => O2, GenericSettingsConfig: () => R2, HandlersConfig: () => x2, IdConfig: () => E2, Identifier: () => c, InitConfig: () => D2, LoopSchema: () => ge2, MapSchema: () => ve2, MappingResultSchema: () => je2, MappingSchemas: () => me2, OptionalPrimitiveValue: () => m, OrderedPropertiesSchema: () => Q2, PartialEventSchema: () => te, PolicySchema: () => ye, PrimaryConfig: () => I2, PrimitiveSchema: () => Mn, PrimitiveValue: () => u2, ProcessingControlConfig: () => V, PropertiesSchema: () => G, PropertySchema: () => H2, PropertyTypeSchema: () => F, QueueConfig: () => P2, RequiredBoolean: () => s, RequiredNumber: () => a2, RequiredString: () => r, RuleSchema: () => we2, RulesSchema: () => ke2, RuntimeInstanceConfig: () => M2, SetSchema: () => he2, SetupSchema: () => ti, SetupV2Schema: () => ii, SourceReferenceSchema: () => Hn, SourceSchema: () => Z2, SourceSchemas: () => kn, SourceTypeSchema: () => _2, SourcesMapConfig: () => W2, StoreReferenceSchema: () => _n, TaggingVersion: () => p, Timestamp: () => l, UserSchema: () => X2, UtilitySchemas: () => b, ValueConfigSchema: () => Se, ValueSchema: () => be2, ValuesSchema: () => fe2, VerboseConfig: () => J, VersionSchema: () => Y2, WalkerOSSchemas: () => B2, configJsonSchema: () => di, consentJsonSchema: () => ue, createArraySchema: () => Ji, createConsentConfig: () => T2, createDataTransformationConfig: () => L2, createEnumSchema: () => Pi, createMappingRulesConfig: () => N2, createObjectSchema: () => ji, createPolicyConfig: () => q2, createTupleSchema: () => Ei, destinationReferenceJsonSchema: () => ui, entityJsonSchema: () => de2, eventJsonSchema: () => re, loopJsonSchema: () => Pe, mapJsonSchema: () => De, orderedPropertiesJsonSchema: () => le2, parseConfig: () => ai, parseSetup: () => oi, partialEventJsonSchema: () => ae2, policyJsonSchema: () => Ie, propertiesJsonSchema: () => ce, ruleJsonSchema: () => Re, rulesJsonSchema: () => Oe2, safeParseConfig: () => si, safeParseSetup: () => ri, setJsonSchema: () => Ee, setupJsonSchema: () => ci, setupV2JsonSchema: () => li, sourceReferenceJsonSchema: () => pi, sourceTypeJsonSchema: () => pe2, storeReferenceJsonSchema: () => bi, userJsonSchema: () => se2, validateFlowSetup: () => fi, valueConfigJsonSchema: () => Je, valueJsonSchema: () => xe, z: () => external_exports, zodToSchema: () => Di });
|
|
14836
|
+
function o(e4, n3, i2 = "draft-7") {
|
|
14837
|
+
return external_exports.toJSONSchema(e4, { target: i2 });
|
|
14840
14838
|
}
|
|
14841
14839
|
var r = external_exports.string();
|
|
14842
14840
|
var a2 = external_exports.number();
|
|
@@ -14848,7 +14846,7 @@ var p = external_exports.number().describe("Tagging version number");
|
|
|
14848
14846
|
var u2 = external_exports.union([external_exports.string(), external_exports.number(), external_exports.boolean()]);
|
|
14849
14847
|
var m = u2.optional();
|
|
14850
14848
|
var b = {};
|
|
14851
|
-
n(b, { ErrorHandlerSchema: () => h, HandlerSchema: () => S2, LogHandlerSchema: () => v, StorageSchema: () => g, StorageTypeSchema: () => f, errorHandlerJsonSchema: () =>
|
|
14849
|
+
n(b, { ErrorHandlerSchema: () => h, HandlerSchema: () => S2, LogHandlerSchema: () => v, StorageSchema: () => g, StorageTypeSchema: () => f, errorHandlerJsonSchema: () => k, handlerJsonSchema: () => j, logHandlerJsonSchema: () => C2, storageJsonSchema: () => w, storageTypeJsonSchema: () => y });
|
|
14852
14850
|
var f = external_exports.enum(["local", "session", "cookie"]).describe("Storage mechanism: local, session, or cookie");
|
|
14853
14851
|
var g = external_exports.object({ Local: external_exports.literal("local"), Session: external_exports.literal("session"), Cookie: external_exports.literal("cookie") }).describe("Storage type constants for type-safe references");
|
|
14854
14852
|
var h = external_exports.any().describe("Error handler function: (error, state?) => void");
|
|
@@ -14856,119 +14854,119 @@ var v = external_exports.any().describe("Log handler function: (message, verbose
|
|
|
14856
14854
|
var S2 = external_exports.object({ Error: h.describe("Error handler function"), Log: v.describe("Log handler function") }).describe("Handler interface with error and log functions");
|
|
14857
14855
|
var y = o(f);
|
|
14858
14856
|
var w = o(g);
|
|
14859
|
-
var
|
|
14857
|
+
var k = o(h);
|
|
14860
14858
|
var C2 = o(v);
|
|
14861
|
-
var
|
|
14859
|
+
var j = o(S2);
|
|
14862
14860
|
var x2 = external_exports.object({ onError: h.optional().describe("Error handler function: (error, state?) => void"), onLog: v.optional().describe("Log handler function: (message, verbose?) => void") }).partial();
|
|
14863
|
-
var
|
|
14864
|
-
var
|
|
14865
|
-
var
|
|
14861
|
+
var J = external_exports.object({ verbose: external_exports.boolean().describe("Enable verbose logging for debugging").optional() }).partial();
|
|
14862
|
+
var P2 = external_exports.object({ queue: external_exports.boolean().describe("Whether to queue events when consent is not granted").optional() }).partial();
|
|
14863
|
+
var E2 = external_exports.object({}).partial();
|
|
14866
14864
|
var D2 = external_exports.object({ init: external_exports.boolean().describe("Whether to initialize immediately").optional(), loadScript: external_exports.boolean().describe("Whether to load external script (for web destinations)").optional() }).partial();
|
|
14867
|
-
var
|
|
14868
|
-
var
|
|
14869
|
-
var
|
|
14870
|
-
function L2(
|
|
14871
|
-
return external_exports.object({ data: external_exports.union([
|
|
14865
|
+
var I2 = external_exports.object({ primary: external_exports.boolean().describe("Mark as primary (only one can be primary)").optional() }).partial();
|
|
14866
|
+
var R2 = external_exports.object({ settings: external_exports.any().optional().describe("Implementation-specific configuration") }).partial();
|
|
14867
|
+
var O2 = external_exports.object({ env: external_exports.any().optional().describe("Environment dependencies (platform-specific)") }).partial();
|
|
14868
|
+
function L2(e4, n3) {
|
|
14869
|
+
return external_exports.object({ data: external_exports.union([e4, n3]).optional().describe("Data transformation rules") }).partial();
|
|
14872
14870
|
}
|
|
14873
|
-
function N2(
|
|
14874
|
-
return external_exports.object({ mapping:
|
|
14871
|
+
function N2(e4) {
|
|
14872
|
+
return external_exports.object({ mapping: e4.optional().describe("Event mapping rules") }).partial();
|
|
14875
14873
|
}
|
|
14876
|
-
function
|
|
14877
|
-
return external_exports.object({ policy:
|
|
14874
|
+
function q2(e4) {
|
|
14875
|
+
return external_exports.object({ policy: e4.optional().describe("Pre-processing policy rules") }).partial();
|
|
14878
14876
|
}
|
|
14879
|
-
function
|
|
14880
|
-
return external_exports.object({ consent:
|
|
14877
|
+
function T2(e4) {
|
|
14878
|
+
return external_exports.object({ consent: e4.optional().describe("Required consent states") }).partial();
|
|
14881
14879
|
}
|
|
14882
14880
|
var M2 = external_exports.object({ type: external_exports.string().optional().describe("Instance type identifier"), config: external_exports.unknown().describe("Instance configuration") }).partial();
|
|
14883
14881
|
var z3 = external_exports.object({ collector: external_exports.unknown().describe("Collector instance (runtime object)"), config: external_exports.unknown().describe("Configuration"), env: external_exports.unknown().describe("Environment dependencies") }).partial();
|
|
14884
|
-
var
|
|
14882
|
+
var U2 = external_exports.object({ batch: external_exports.number().optional().describe("Batch size: bundle N events for batch processing"), batched: external_exports.unknown().optional().describe("Batch of events to be processed") }).partial();
|
|
14885
14883
|
var V = external_exports.object({ ignore: external_exports.boolean().describe("Set to true to skip processing").optional(), condition: external_exports.string().optional().describe("Condition function: return true to process") }).partial();
|
|
14886
14884
|
var W2 = external_exports.object({ sources: external_exports.record(external_exports.string(), external_exports.unknown()).describe("Map of source instances") }).partial();
|
|
14887
14885
|
var $2 = external_exports.object({ destinations: external_exports.record(external_exports.string(), external_exports.unknown()).describe("Map of destination instances") }).partial();
|
|
14888
14886
|
var B2 = {};
|
|
14889
|
-
n(B2, { ConsentSchema: () =>
|
|
14887
|
+
n(B2, { ConsentSchema: () => K2, DeepPartialEventSchema: () => oe, EntitiesSchema: () => ne2, EntitySchema: () => ee2, EventSchema: () => ie, OrderedPropertiesSchema: () => Q2, PartialEventSchema: () => te, PropertiesSchema: () => G, PropertySchema: () => H2, PropertyTypeSchema: () => F, SourceSchema: () => Z2, SourceTypeSchema: () => _2, UserSchema: () => X2, VersionSchema: () => Y2, consentJsonSchema: () => ue, entityJsonSchema: () => de2, eventJsonSchema: () => re, orderedPropertiesJsonSchema: () => le2, partialEventJsonSchema: () => ae2, propertiesJsonSchema: () => ce, sourceTypeJsonSchema: () => pe2, userJsonSchema: () => se2 });
|
|
14890
14888
|
var A2;
|
|
14891
|
-
var
|
|
14892
|
-
var H2 = external_exports.lazy(() => external_exports.union([
|
|
14893
|
-
var
|
|
14889
|
+
var F = external_exports.lazy(() => external_exports.union([external_exports.boolean(), external_exports.string(), external_exports.number(), external_exports.record(external_exports.string(), H2)]));
|
|
14890
|
+
var H2 = external_exports.lazy(() => external_exports.union([F, external_exports.array(F)]));
|
|
14891
|
+
var G = external_exports.record(external_exports.string(), H2.optional()).describe("Flexible property collection with optional values");
|
|
14894
14892
|
var Q2 = external_exports.record(external_exports.string(), external_exports.tuple([H2, external_exports.number()]).optional()).describe("Ordered properties with [value, order] tuples for priority control");
|
|
14895
14893
|
var _2 = external_exports.union([external_exports.enum(["web", "server", "app", "other"]), external_exports.string()]).describe("Source type: web, server, app, other, or custom");
|
|
14896
|
-
var
|
|
14897
|
-
var X2 =
|
|
14898
|
-
var
|
|
14899
|
-
var Z2 =
|
|
14900
|
-
var
|
|
14901
|
-
var
|
|
14902
|
-
var ie = external_exports.object({ name: external_exports.string().describe('Event name in "entity action" format (e.g., "page view", "product add")'), data:
|
|
14894
|
+
var K2 = external_exports.record(external_exports.string(), external_exports.boolean()).describe("Consent requirement mapping (group name \u2192 state)");
|
|
14895
|
+
var X2 = G.and(external_exports.object({ id: external_exports.string().optional().describe("User identifier"), device: external_exports.string().optional().describe("Device identifier"), session: external_exports.string().optional().describe("Session identifier"), hash: external_exports.string().optional().describe("Hashed identifier"), address: external_exports.string().optional().describe("User address"), email: external_exports.string().email().optional().describe("User email address"), phone: external_exports.string().optional().describe("User phone number"), userAgent: external_exports.string().optional().describe("Browser user agent string"), browser: external_exports.string().optional().describe("Browser name"), browserVersion: external_exports.string().optional().describe("Browser version"), deviceType: external_exports.string().optional().describe("Device type (mobile, desktop, tablet)"), os: external_exports.string().optional().describe("Operating system"), osVersion: external_exports.string().optional().describe("Operating system version"), screenSize: external_exports.string().optional().describe("Screen dimensions"), language: external_exports.string().optional().describe("User language"), country: external_exports.string().optional().describe("User country"), region: external_exports.string().optional().describe("User region/state"), city: external_exports.string().optional().describe("User city"), zip: external_exports.string().optional().describe("User postal code"), timezone: external_exports.string().optional().describe("User timezone"), ip: external_exports.string().optional().describe("User IP address"), internal: external_exports.boolean().optional().describe("Internal user flag (employee, test user)") })).describe("User identification and properties");
|
|
14896
|
+
var Y2 = G.and(external_exports.object({ source: r.describe('Walker implementation version (e.g., "2.0.0")'), tagging: p })).describe("Walker version information");
|
|
14897
|
+
var Z2 = G.and(external_exports.object({ type: _2.describe("Source type identifier"), id: r.describe("Source identifier (typically URL on web)"), previous_id: r.describe("Previous source identifier (typically referrer on web)") })).describe("Event source information");
|
|
14898
|
+
var ee2 = external_exports.lazy(() => external_exports.object({ entity: external_exports.string().describe("Entity name"), data: G.describe("Entity-specific properties"), nested: external_exports.array(ee2).describe("Nested child entities"), context: Q2.describe("Entity context data") })).describe("Nested entity structure with recursive nesting support");
|
|
14899
|
+
var ne2 = external_exports.array(ee2).describe("Array of nested entities");
|
|
14900
|
+
var ie = external_exports.object({ name: external_exports.string().describe('Event name in "entity action" format (e.g., "page view", "product add")'), data: G.describe("Event-specific properties"), context: Q2.describe("Ordered context properties with priorities"), globals: G.describe("Global properties shared across events"), custom: G.describe("Custom implementation-specific properties"), user: X2.describe("User identification and attributes"), nested: ne2.describe("Related nested entities"), consent: K2.describe("Consent states at event time"), id: c.describe("Unique event identifier (timestamp-based)"), trigger: r.describe("Event trigger identifier"), entity: r.describe("Parsed entity from event name"), action: r.describe("Parsed action from event name"), timestamp: l.describe("Unix timestamp in milliseconds since epoch"), timing: a2.describe("Event processing timing information"), group: r.describe("Event grouping identifier"), count: d.describe("Event count in session"), version: Y2.describe("Walker version information"), source: Z2.describe("Event source information") }).describe("Complete walkerOS event structure");
|
|
14903
14901
|
var te = ie.partial().describe("Partial event structure with all fields optional");
|
|
14904
14902
|
var oe = ie.partial().describe("Partial event structure with all top-level fields optional");
|
|
14905
14903
|
var re = o(ie);
|
|
14906
|
-
var
|
|
14907
|
-
var
|
|
14908
|
-
var ce = o(
|
|
14909
|
-
var
|
|
14910
|
-
var
|
|
14911
|
-
var
|
|
14912
|
-
var ue = o(
|
|
14913
|
-
var
|
|
14914
|
-
n(
|
|
14915
|
-
var
|
|
14916
|
-
var
|
|
14917
|
-
var
|
|
14918
|
-
var
|
|
14919
|
-
var
|
|
14920
|
-
var Se = A2 = external_exports.object({ key: external_exports.string().optional().describe('Property path to extract from event (e.g., "data.id", "user.email")'), value: external_exports.union([external_exports.string(), external_exports.number(), external_exports.boolean()]).optional().describe("Static primitive value"), fn: external_exports.string().optional().describe("Custom transformation function as string (serialized)"), map:
|
|
14921
|
-
var ye = external_exports.record(external_exports.string(),
|
|
14922
|
-
var
|
|
14923
|
-
var
|
|
14924
|
-
var Ce = external_exports.object({ consent:
|
|
14925
|
-
var
|
|
14926
|
-
var xe = o(
|
|
14904
|
+
var ae2 = o(te);
|
|
14905
|
+
var se2 = o(X2);
|
|
14906
|
+
var ce = o(G);
|
|
14907
|
+
var le2 = o(Q2);
|
|
14908
|
+
var de2 = o(ee2);
|
|
14909
|
+
var pe2 = o(_2);
|
|
14910
|
+
var ue = o(K2);
|
|
14911
|
+
var me2 = {};
|
|
14912
|
+
n(me2, { ConfigSchema: () => Ce, LoopSchema: () => ge2, MapSchema: () => ve2, PolicySchema: () => ye, ResultSchema: () => je2, RuleSchema: () => we2, RulesSchema: () => ke2, SetSchema: () => he2, ValueConfigSchema: () => Se, ValueSchema: () => be2, ValuesSchema: () => fe2, configJsonSchema: () => Le2, loopJsonSchema: () => Pe, mapJsonSchema: () => De, policyJsonSchema: () => Ie, ruleJsonSchema: () => Re, rulesJsonSchema: () => Oe2, setJsonSchema: () => Ee, valueConfigJsonSchema: () => Je, valueJsonSchema: () => xe });
|
|
14913
|
+
var be2 = external_exports.lazy(() => external_exports.union([external_exports.string().describe('String value or property path (e.g., "data.id")'), external_exports.number().describe("Numeric value"), external_exports.boolean().describe("Boolean value"), external_exports.lazy(() => A2), external_exports.array(be2).describe("Array of values")]));
|
|
14914
|
+
var fe2 = external_exports.array(be2).describe("Array of transformation values");
|
|
14915
|
+
var ge2 = external_exports.lazy(() => external_exports.tuple([be2, be2]).describe("Loop transformation: [source, transform] tuple for array processing"));
|
|
14916
|
+
var he2 = external_exports.lazy(() => external_exports.array(be2).describe("Set: Array of values for selection or combination"));
|
|
14917
|
+
var ve2 = external_exports.lazy(() => external_exports.record(external_exports.string(), be2).describe("Map: Object mapping keys to transformation values"));
|
|
14918
|
+
var Se = A2 = external_exports.object({ key: external_exports.string().optional().describe('Property path to extract from event (e.g., "data.id", "user.email")'), value: external_exports.union([external_exports.string(), external_exports.number(), external_exports.boolean()]).optional().describe("Static primitive value"), fn: external_exports.string().optional().describe("Custom transformation function as string (serialized)"), map: ve2.optional().describe("Object mapping: transform event data to structured output"), loop: ge2.optional().describe("Loop transformation: [source, transform] for array processing"), set: he2.optional().describe("Set of values: combine or select from multiple values"), consent: K2.optional().describe("Required consent states to include this value"), condition: external_exports.string().optional().describe("Condition function as string: return true to include value"), validate: external_exports.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" }).describe("Value transformation configuration with multiple strategies");
|
|
14919
|
+
var ye = external_exports.record(external_exports.string(), be2).describe("Policy rules for event pre-processing (key \u2192 value mapping)");
|
|
14920
|
+
var we2 = external_exports.object({ batch: external_exports.number().optional().describe("Batch size: bundle N events for batch processing"), condition: external_exports.string().optional().describe("Condition function as string: return true to process event"), consent: K2.optional().describe("Required consent states to process this event"), settings: external_exports.any().optional().describe("Destination-specific settings for this event mapping"), data: external_exports.union([be2, fe2]).optional().describe("Data transformation rules for event"), ignore: external_exports.boolean().optional().describe("Set to true to skip processing this event"), name: external_exports.string().optional().describe('Custom event name override (e.g., "view_item" for "product view")'), policy: ye.optional().describe("Event-level policy overrides (applied after config-level policy)") }).describe("Mapping rule for specific entity-action combination");
|
|
14921
|
+
var ke2 = external_exports.record(external_exports.string(), external_exports.record(external_exports.string(), external_exports.union([we2, external_exports.array(we2)])).optional()).describe("Nested mapping rules: { entity: { action: Rule | Rule[] } } with wildcard support");
|
|
14922
|
+
var Ce = external_exports.object({ consent: K2.optional().describe("Required consent states to process any events"), data: external_exports.union([be2, fe2]).optional().describe("Global data transformation applied to all events"), mapping: ke2.optional().describe("Entity-action specific mapping rules"), policy: ye.optional().describe("Pre-processing policy rules applied before mapping") }).describe("Shared mapping configuration for sources and destinations");
|
|
14923
|
+
var je2 = external_exports.object({ eventMapping: we2.optional().describe("Resolved mapping rule for event"), mappingKey: external_exports.string().optional().describe('Mapping key used (e.g., "product.view")') }).describe("Mapping resolution result");
|
|
14924
|
+
var xe = o(be2);
|
|
14927
14925
|
var Je = o(Se);
|
|
14928
|
-
var
|
|
14929
|
-
var
|
|
14930
|
-
var De = o(
|
|
14926
|
+
var Pe = o(ge2);
|
|
14927
|
+
var Ee = o(he2);
|
|
14928
|
+
var De = o(ve2);
|
|
14931
14929
|
var Ie = o(ye);
|
|
14932
|
-
var
|
|
14933
|
-
var
|
|
14934
|
-
var
|
|
14930
|
+
var Re = o(we2);
|
|
14931
|
+
var Oe2 = o(ke2);
|
|
14932
|
+
var Le2 = o(Ce);
|
|
14935
14933
|
var Ne = {};
|
|
14936
|
-
n(Ne, { BatchSchema: () =>
|
|
14937
|
-
var
|
|
14938
|
-
var
|
|
14934
|
+
n(Ne, { BatchSchema: () => Be2, ConfigSchema: () => qe, ContextSchema: () => ze, DLQSchema: () => Ye, DataSchema: () => Ae, DestinationPolicySchema: () => Me, DestinationsSchema: () => Qe, InitDestinationsSchema: () => Ge, InitSchema: () => He, InstanceSchema: () => Fe, PartialConfigSchema: () => Te, PushBatchContextSchema: () => Ve2, PushContextSchema: () => Ue, PushEventSchema: () => We, PushEventsSchema: () => $e, PushResultSchema: () => Ke, RefSchema: () => _e2, ResultSchema: () => Xe, batchJsonSchema: () => on, configJsonSchema: () => Ze, contextJsonSchema: () => nn, instanceJsonSchema: () => rn, partialConfigJsonSchema: () => en, pushContextJsonSchema: () => tn, resultJsonSchema: () => an });
|
|
14935
|
+
var qe = external_exports.object({ consent: K2.optional().describe("Required consent states to send events to this destination"), settings: external_exports.any().describe("Implementation-specific configuration").optional(), data: external_exports.union([be2, fe2]).optional().describe("Global data transformation applied to all events for this destination"), env: external_exports.any().describe("Environment dependencies (platform-specific)").optional(), id: c.describe("Destination instance identifier (defaults to destination key)").optional(), init: external_exports.boolean().describe("Whether to initialize immediately").optional(), loadScript: external_exports.boolean().describe("Whether to load external script (for web destinations)").optional(), mapping: ke2.optional().describe("Entity-action specific mapping rules for this destination"), policy: ye.optional().describe("Pre-processing policy rules applied before event mapping"), queue: external_exports.boolean().describe("Whether to queue events when consent is not granted").optional(), verbose: external_exports.boolean().describe("Enable verbose logging for debugging").optional(), onError: h.optional(), onLog: v.optional() }).describe("Destination configuration");
|
|
14936
|
+
var Te = qe.partial().describe("Partial destination configuration with all fields optional");
|
|
14939
14937
|
var Me = ye.describe("Destination policy rules for event pre-processing");
|
|
14940
|
-
var ze = external_exports.object({ collector: external_exports.unknown().describe("Collector instance (runtime object)"), config:
|
|
14941
|
-
var Ue = ze.extend({ mapping:
|
|
14942
|
-
var
|
|
14943
|
-
var We = external_exports.object({ event: ie.describe("The event to process"), mapping:
|
|
14938
|
+
var ze = external_exports.object({ collector: external_exports.unknown().describe("Collector instance (runtime object)"), config: qe.describe("Destination configuration"), data: external_exports.union([external_exports.unknown(), external_exports.array(external_exports.unknown())]).optional().describe("Transformed event data"), env: external_exports.unknown().describe("Environment dependencies") }).describe("Destination context for init and push functions");
|
|
14939
|
+
var Ue = ze.extend({ mapping: we2.optional().describe("Resolved mapping rule for this specific event") }).describe("Push context with event-specific mapping");
|
|
14940
|
+
var Ve2 = Ue.describe("Batch push context with event-specific mapping");
|
|
14941
|
+
var We = external_exports.object({ event: ie.describe("The event to process"), mapping: we2.optional().describe("Mapping rule for this event") }).describe("Event with optional mapping for batch processing");
|
|
14944
14942
|
var $e = external_exports.array(We).describe("Array of events with mappings");
|
|
14945
|
-
var
|
|
14943
|
+
var Be2 = external_exports.object({ key: external_exports.string().describe('Batch key (usually mapping key like "product.view")'), events: external_exports.array(ie).describe("Array of events in batch"), data: external_exports.array(external_exports.union([external_exports.unknown(), external_exports.array(external_exports.unknown())]).optional()).describe("Transformed data for each event"), mapping: we2.optional().describe("Shared mapping rule for batch") }).describe("Batch of events grouped by mapping key");
|
|
14946
14944
|
var Ae = external_exports.union([external_exports.unknown(), external_exports.array(external_exports.unknown())]).optional().describe("Transformed event data (Property, undefined, or array)");
|
|
14947
|
-
var Fe = external_exports.object({ config:
|
|
14948
|
-
var He = external_exports.object({ code: Fe.describe("Destination instance with implementation"), config:
|
|
14945
|
+
var Fe = external_exports.object({ config: qe.describe("Destination configuration"), queue: external_exports.array(ie).optional().describe("Queued events awaiting consent"), dlq: external_exports.array(external_exports.tuple([ie, external_exports.unknown()])).optional().describe("Dead letter queue (failed events with errors)"), type: external_exports.string().optional().describe("Destination type identifier"), env: external_exports.unknown().optional().describe("Environment dependencies"), init: external_exports.unknown().optional().describe("Initialization function"), push: external_exports.unknown().describe("Push function for single events"), pushBatch: external_exports.unknown().optional().describe("Batch push function"), on: external_exports.unknown().optional().describe("Event lifecycle hook function") }).describe("Destination instance (runtime object with functions)");
|
|
14946
|
+
var He = external_exports.object({ code: Fe.describe("Destination instance with implementation"), config: Te.optional().describe("Partial configuration overrides"), env: external_exports.unknown().optional().describe("Partial environment overrides") }).describe("Destination initialization configuration");
|
|
14949
14947
|
var Ge = external_exports.record(external_exports.string(), He).describe("Map of destination IDs to initialization configurations");
|
|
14950
14948
|
var Qe = external_exports.record(external_exports.string(), Fe).describe("Map of destination IDs to runtime instances");
|
|
14951
|
-
var
|
|
14949
|
+
var _e2 = external_exports.object({ type: external_exports.string().describe('Destination type ("gtag", "meta", "bigquery")'), data: external_exports.unknown().optional().describe("Response from push()"), error: external_exports.unknown().optional().describe("Error if failed") }).describe("Destination reference with type and response data");
|
|
14952
14950
|
var Ke = external_exports.object({ queue: external_exports.array(ie).optional().describe("Events queued (awaiting consent)"), error: external_exports.unknown().optional().describe("Error if push failed") }).describe("Push operation result");
|
|
14953
|
-
var Xe = external_exports.object({ ok: external_exports.boolean().describe("True if nothing failed"), event: external_exports.unknown().optional().describe("The processed event"), done: external_exports.record(external_exports.string(),
|
|
14951
|
+
var Xe = external_exports.object({ ok: external_exports.boolean().describe("True if nothing failed"), event: external_exports.unknown().optional().describe("The processed event"), done: external_exports.record(external_exports.string(), _e2).optional().describe("Destinations that processed successfully"), queued: external_exports.record(external_exports.string(), _e2).optional().describe("Destinations that queued events"), failed: external_exports.record(external_exports.string(), _e2).optional().describe("Destinations that failed to process") }).describe("Push result with destination outcomes");
|
|
14954
14952
|
var Ye = external_exports.array(external_exports.tuple([ie, external_exports.unknown()])).describe("Dead letter queue: [(event, error), ...]");
|
|
14955
|
-
var Ze = o(
|
|
14956
|
-
var en = o(
|
|
14953
|
+
var Ze = o(qe);
|
|
14954
|
+
var en = o(Te);
|
|
14957
14955
|
var nn = o(ze);
|
|
14958
14956
|
var tn = o(Ue);
|
|
14959
|
-
var on = o(
|
|
14957
|
+
var on = o(Be2);
|
|
14960
14958
|
var rn = o(Fe);
|
|
14961
14959
|
var an = o(Xe);
|
|
14962
14960
|
var sn = {};
|
|
14963
14961
|
n(sn, { CommandTypeSchema: () => cn, ConfigSchema: () => ln, DestinationsSchema: () => bn, InitConfigSchema: () => pn, InstanceSchema: () => fn, PushContextSchema: () => un, SessionDataSchema: () => dn, SourcesSchema: () => mn, commandTypeJsonSchema: () => gn, configJsonSchema: () => hn, initConfigJsonSchema: () => Sn, instanceJsonSchema: () => wn, pushContextJsonSchema: () => yn, sessionDataJsonSchema: () => vn });
|
|
14964
14962
|
var cn = external_exports.union([external_exports.enum(["action", "config", "consent", "context", "destination", "elb", "globals", "hook", "init", "link", "run", "user", "walker"]), external_exports.string()]).describe("Collector command type: standard commands or custom string for extensions");
|
|
14965
|
-
var ln = external_exports.object({ run: external_exports.boolean().describe("Whether to run collector automatically on initialization").optional(), tagging: p, globalsStatic:
|
|
14966
|
-
var dn =
|
|
14967
|
-
var pn = ln.partial().extend({ consent:
|
|
14963
|
+
var ln = external_exports.object({ run: external_exports.boolean().describe("Whether to run collector automatically on initialization").optional(), tagging: p, globalsStatic: G.describe("Static global properties that persist across collector runs"), sessionStatic: external_exports.record(external_exports.string(), external_exports.unknown()).describe("Static session data that persists across collector runs"), verbose: external_exports.boolean().describe("Enable verbose logging for debugging"), onError: h.optional(), onLog: v.optional() }).describe("Core collector configuration");
|
|
14964
|
+
var dn = G.and(external_exports.object({ isStart: external_exports.boolean().describe("Whether this is a new session start"), storage: external_exports.boolean().describe("Whether storage is available"), id: c.describe("Session identifier").optional(), start: l.describe("Session start timestamp").optional(), marketing: external_exports.literal(true).optional().describe("Marketing attribution flag"), updated: l.describe("Last update timestamp").optional(), isNew: external_exports.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() })).describe("Session state and tracking data");
|
|
14965
|
+
var pn = ln.partial().extend({ consent: K2.optional().describe("Initial consent state"), user: X2.optional().describe("Initial user data"), globals: G.optional().describe("Initial global properties"), sources: external_exports.unknown().optional().describe("Source configurations"), destinations: external_exports.unknown().optional().describe("Destination configurations"), custom: G.optional().describe("Initial custom implementation-specific properties") }).describe("Collector initialization configuration with initial state");
|
|
14968
14966
|
var un = external_exports.object({ mapping: Ce.optional().describe("Source-level mapping configuration") }).describe("Push context with optional source mapping");
|
|
14969
14967
|
var mn = external_exports.record(external_exports.string(), external_exports.unknown()).describe("Map of source IDs to source instances");
|
|
14970
14968
|
var bn = external_exports.record(external_exports.string(), external_exports.unknown()).describe("Map of destination IDs to destination instances");
|
|
14971
|
-
var fn = external_exports.object({ push: external_exports.unknown().describe("Push function for processing events"), command: external_exports.unknown().describe("Command function for walker commands"), allowed: external_exports.boolean().describe("Whether event processing is allowed"), config: ln.describe("Current collector configuration"), consent:
|
|
14969
|
+
var fn = external_exports.object({ push: external_exports.unknown().describe("Push function for processing events"), command: external_exports.unknown().describe("Command function for walker commands"), allowed: external_exports.boolean().describe("Whether event processing is allowed"), config: ln.describe("Current collector configuration"), consent: K2.describe("Current consent state"), count: external_exports.number().describe("Event count (increments with each event)"), custom: G.describe("Custom implementation-specific properties"), sources: mn.describe("Registered source instances"), destinations: bn.describe("Registered destination instances"), globals: G.describe("Current global properties"), group: external_exports.string().describe("Event grouping identifier"), hooks: external_exports.unknown().describe("Lifecycle hook functions"), on: external_exports.unknown().describe("Event lifecycle configuration"), queue: external_exports.array(ie).describe("Queued events awaiting processing"), round: external_exports.number().describe("Collector run count (increments with each run)"), session: external_exports.union([dn]).describe("Current session state"), timing: external_exports.number().describe("Event processing timing information"), user: X2.describe("Current user data"), version: external_exports.string().describe("Walker implementation version") }).describe("Collector instance with state and methods");
|
|
14972
14970
|
var gn = o(cn);
|
|
14973
14971
|
var hn = o(ln);
|
|
14974
14972
|
var vn = o(dn);
|
|
@@ -14976,22 +14974,22 @@ var Sn = o(pn);
|
|
|
14976
14974
|
var yn = o(un);
|
|
14977
14975
|
var wn = o(fn);
|
|
14978
14976
|
var kn = {};
|
|
14979
|
-
n(kn, { BaseEnvSchema: () => Cn, ConfigSchema: () => jn, InitSchema: () =>
|
|
14977
|
+
n(kn, { BaseEnvSchema: () => Cn, ConfigSchema: () => jn, InitSchema: () => Pn, InitSourceSchema: () => En, InitSourcesSchema: () => Dn, InstanceSchema: () => Jn, PartialConfigSchema: () => xn, baseEnvJsonSchema: () => In, configJsonSchema: () => Rn, initSourceJsonSchema: () => Nn, initSourcesJsonSchema: () => qn, instanceJsonSchema: () => Ln, partialConfigJsonSchema: () => On });
|
|
14980
14978
|
var Cn = external_exports.object({ push: external_exports.unknown().describe("Collector push function"), command: external_exports.unknown().describe("Collector command function"), sources: external_exports.unknown().optional().describe("Map of registered source instances"), elb: external_exports.unknown().describe("Public API function (alias for collector.push)") }).catchall(external_exports.unknown()).describe("Base environment for dependency injection - platform-specific sources extend this");
|
|
14981
14979
|
var jn = Ce.extend({ settings: external_exports.any().describe("Implementation-specific configuration").optional(), env: Cn.optional().describe("Environment dependencies (platform-specific)"), id: c.describe("Source identifier (defaults to source key)").optional(), onError: h.optional(), primary: external_exports.boolean().describe("Mark as primary (only one can be primary)").optional() }).describe("Source configuration with mapping and environment");
|
|
14982
14980
|
var xn = jn.partial().describe("Partial source configuration with all fields optional");
|
|
14983
14981
|
var Jn = external_exports.object({ type: external_exports.string().describe('Source type identifier (e.g., "browser", "dataLayer")'), config: jn.describe("Current source configuration"), push: external_exports.any().describe("Push function - THE HANDLER (flexible signature for platform compatibility)"), destroy: external_exports.any().optional().describe("Cleanup function called when source is removed"), on: external_exports.unknown().optional().describe("Lifecycle hook function for event types") }).describe("Source instance with push handler and lifecycle methods");
|
|
14984
|
-
var
|
|
14985
|
-
var
|
|
14986
|
-
var Dn = external_exports.record(external_exports.string(),
|
|
14982
|
+
var Pn = external_exports.any().describe("Source initialization function: (config, env) => Instance | Promise<Instance>");
|
|
14983
|
+
var En = external_exports.object({ code: Pn.describe("Source initialization function"), config: xn.optional().describe("Partial configuration overrides"), env: Cn.partial().optional().describe("Partial environment overrides"), primary: external_exports.boolean().optional().describe("Mark as primary source (only one can be primary)") }).describe("Source initialization configuration");
|
|
14984
|
+
var Dn = external_exports.record(external_exports.string(), En).describe("Map of source IDs to initialization configurations");
|
|
14987
14985
|
var In = o(Cn);
|
|
14988
|
-
var
|
|
14989
|
-
var
|
|
14986
|
+
var Rn = o(jn);
|
|
14987
|
+
var On = o(xn);
|
|
14990
14988
|
var Ln = o(Jn);
|
|
14991
|
-
var Nn = o(
|
|
14992
|
-
var
|
|
14993
|
-
var
|
|
14994
|
-
n(
|
|
14989
|
+
var Nn = o(En);
|
|
14990
|
+
var qn = o(Dn);
|
|
14991
|
+
var Tn = {};
|
|
14992
|
+
n(Tn, { ConfigSchema: () => Zn, ContractActionsSchema: () => Xn, ContractSchema: () => Yn, ContractSchemaEntry: () => Kn, DefinitionsSchema: () => Un, DestinationReferenceSchema: () => Qn, InlineCodeSchema: () => Bn, PackagesSchema: () => Vn, PrimitiveSchema: () => Mn, ServerSchema: () => $n, SetupSchema: () => ti, SetupV2Schema: () => ii, SourceReferenceSchema: () => Hn, StepExampleSchema: () => An, StepExamplesSchema: () => Fn, StoreReferenceSchema: () => _n, TransformerReferenceSchema: () => Gn, VariablesSchema: () => zn, WebSchema: () => Wn, configJsonSchema: () => di, destinationReferenceJsonSchema: () => ui, parseConfig: () => ai, parseSetup: () => oi, safeParseConfig: () => si, safeParseSetup: () => ri, setupJsonSchema: () => ci, setupV2JsonSchema: () => li, sourceReferenceJsonSchema: () => pi, storeReferenceJsonSchema: () => bi, transformerReferenceJsonSchema: () => mi });
|
|
14995
14993
|
var Mn = external_exports.union([external_exports.string(), external_exports.number(), external_exports.boolean()]).describe("Primitive value: string, number, or boolean");
|
|
14996
14994
|
var zn = external_exports.record(external_exports.string(), Mn).describe("Variables for interpolation");
|
|
14997
14995
|
var Un = external_exports.record(external_exports.string(), external_exports.unknown()).describe("Reusable configuration definitions");
|
|
@@ -15004,176 +15002,178 @@ var Fn = external_exports.record(external_exports.string(), An).describe("Named
|
|
|
15004
15002
|
var Hn = external_exports.object({ package: external_exports.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: external_exports.union([external_exports.string(), Bn]).optional().describe('Either a named export string (e.g., "sourceExpress") or an inline code object with push function'), config: external_exports.unknown().optional().describe("Source-specific configuration object"), env: external_exports.unknown().optional().describe("Source environment configuration"), primary: external_exports.boolean().optional().describe("Mark as primary source (provides main elb). Only one source should be primary."), variables: zn.optional().describe("Source-level variables (highest priority in cascade)"), definitions: Un.optional().describe("Source-level definitions (highest priority in cascade)"), next: external_exports.union([external_exports.string(), external_exports.array(external_exports.string())]).optional().describe("First transformer in post-source chain. If omitted, events route directly to collector."), examples: Fn.optional().describe("Named step examples for testing and documentation (stripped during bundling)") }).describe("Source package reference with configuration");
|
|
15005
15003
|
var Gn = external_exports.object({ package: external_exports.string().min(1, "Package name cannot be empty").optional().describe('Package specifier with optional version (e.g., "@walkeros/transformer-enricher@1.0.0")'), code: external_exports.union([external_exports.string(), Bn]).optional().describe('Either a named export string (e.g., "transformerEnricher") or an inline code object with push function'), config: external_exports.unknown().optional().describe("Transformer-specific configuration object"), env: external_exports.unknown().optional().describe("Transformer environment configuration"), next: external_exports.union([external_exports.string(), external_exports.array(external_exports.string())]).optional().describe("Next transformer in chain. If omitted: pre-collector routes to collector, post-collector routes to destination."), variables: zn.optional().describe("Transformer-level variables (highest priority in cascade)"), definitions: Un.optional().describe("Transformer-level definitions (highest priority in cascade)"), examples: Fn.optional().describe("Named step examples for testing and documentation (stripped during bundling)") }).describe("Transformer package reference with configuration");
|
|
15006
15004
|
var Qn = external_exports.object({ package: external_exports.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: external_exports.union([external_exports.string(), Bn]).optional().describe('Either a named export string (e.g., "destinationAnalytics") or an inline code object with push function'), config: external_exports.unknown().optional().describe("Destination-specific configuration object"), env: external_exports.unknown().optional().describe("Destination environment configuration"), variables: zn.optional().describe("Destination-level variables (highest priority in cascade)"), definitions: Un.optional().describe("Destination-level definitions (highest priority in cascade)"), before: external_exports.union([external_exports.string(), external_exports.array(external_exports.string())]).optional().describe("First transformer in pre-destination chain. If omitted, events are sent directly from collector."), examples: Fn.optional().describe("Named step examples for testing and documentation (stripped during bundling)") }).describe("Destination package reference with configuration");
|
|
15007
|
-
var _n = external_exports.
|
|
15008
|
-
var Kn = external_exports.record(external_exports.string(),
|
|
15009
|
-
var Xn = external_exports.record(external_exports.string(),
|
|
15010
|
-
var Yn = external_exports.
|
|
15011
|
-
|
|
15005
|
+
var _n = external_exports.object({ package: external_exports.string().min(1, "Package name cannot be empty").optional().describe("Store package specifier with optional version"), code: external_exports.union([external_exports.string(), Bn]).optional().describe("Named export string or inline code definition"), config: external_exports.unknown().optional().describe("Store-specific configuration object"), env: external_exports.unknown().optional().describe("Store environment configuration"), variables: zn.optional().describe("Store-level variables (highest priority in cascade)"), definitions: Un.optional().describe("Store-level definitions (highest priority in cascade)"), examples: Fn.optional().describe("Named step examples for testing and documentation (stripped during bundling)") }).describe("Store package reference with configuration");
|
|
15006
|
+
var Kn = external_exports.record(external_exports.string(), external_exports.unknown()).describe("JSON Schema object for event validation with description/examples annotations");
|
|
15007
|
+
var Xn = external_exports.record(external_exports.string(), Kn).describe("Action-level contract entries");
|
|
15008
|
+
var Yn = external_exports.record(external_exports.string(), external_exports.union([Xn, external_exports.number()])).describe("Data contract: entity-action keyed JSON Schema with additive inheritance");
|
|
15009
|
+
var Zn = external_exports.object({ web: Wn.optional().describe("Web platform configuration (browser-based tracking). Mutually exclusive with server."), server: $n.optional().describe("Server platform configuration (Node.js). Mutually exclusive with web."), contract: Yn.optional().describe("Flow-level data contract (merges on top of Setup-level contract)"), sources: external_exports.record(external_exports.string(), Hn).optional().describe("Source configurations (data capture) keyed by unique identifier"), destinations: external_exports.record(external_exports.string(), Qn).optional().describe("Destination configurations (data output) keyed by unique identifier"), transformers: external_exports.record(external_exports.string(), Gn).optional().describe("Transformer configurations (event transformation) keyed by unique identifier"), stores: external_exports.record(external_exports.string(), _n).optional().describe("Store configurations (key-value storage) keyed by unique identifier"), collector: external_exports.unknown().optional().describe("Collector configuration for event processing (uses Collector.InitConfig)"), packages: Vn.optional().describe("NPM packages to bundle"), variables: zn.optional().describe("Flow-level variables (override Setup.variables, overridden by source/destination variables)"), definitions: Un.optional().describe("Flow-level definitions (extend Setup.definitions, overridden by source/destination definitions)") }).refine((e4) => {
|
|
15010
|
+
const n3 = void 0 !== e4.web, i2 = void 0 !== e4.server;
|
|
15012
15011
|
return (n3 || i2) && !(n3 && i2);
|
|
15013
15012
|
}, { message: 'Exactly one of "web" or "server" must be present' }).describe("Single flow configuration for one deployment target");
|
|
15014
|
-
var
|
|
15015
|
-
var
|
|
15016
|
-
var
|
|
15017
|
-
var
|
|
15018
|
-
function
|
|
15019
|
-
return
|
|
15020
|
-
}
|
|
15021
|
-
function
|
|
15022
|
-
return
|
|
15023
|
-
}
|
|
15024
|
-
function
|
|
15025
|
-
return
|
|
15026
|
-
}
|
|
15027
|
-
function
|
|
15028
|
-
return
|
|
15029
|
-
}
|
|
15030
|
-
var
|
|
15031
|
-
var
|
|
15032
|
-
var
|
|
15033
|
-
var
|
|
15034
|
-
var
|
|
15035
|
-
var
|
|
15036
|
-
|
|
15013
|
+
var ei = external_exports.object({ $schema: external_exports.string().url("Schema URL must be a valid URL").optional().describe('JSON Schema reference for IDE validation (e.g., "https://walkeros.io/schema/flow/v2.json")'), include: external_exports.array(external_exports.string()).optional().describe("Folders to include in the bundle output"), variables: zn.optional().describe("Shared variables for interpolation across all flows (use $var.name syntax)"), definitions: Un.optional().describe("Reusable configuration definitions (use $def.name syntax)"), flows: external_exports.record(external_exports.string(), Zn).refine((e4) => Object.keys(e4).length > 0, { message: "At least one flow is required" }).describe("Named flow configurations (e.g., production, staging, development)") });
|
|
15014
|
+
var ni = ei.extend({ version: external_exports.literal(1).describe("Configuration schema version 1") }).describe("walkerOS v1 configuration");
|
|
15015
|
+
var ii = ei.extend({ version: external_exports.literal(2).describe("Configuration schema version 2"), contract: Yn.optional().describe("Data contract: entity-action keyed JSON Schema with additive inheritance") }).describe("walkerOS v2 configuration with data contracts");
|
|
15016
|
+
var ti = external_exports.union([ni, ii]).describe("Complete multi-flow walkerOS configuration (walkeros.config.json)");
|
|
15017
|
+
function oi(e4) {
|
|
15018
|
+
return ti.parse(e4);
|
|
15019
|
+
}
|
|
15020
|
+
function ri(e4) {
|
|
15021
|
+
return ti.safeParse(e4);
|
|
15022
|
+
}
|
|
15023
|
+
function ai(e4) {
|
|
15024
|
+
return Zn.parse(e4);
|
|
15025
|
+
}
|
|
15026
|
+
function si(e4) {
|
|
15027
|
+
return Zn.safeParse(e4);
|
|
15028
|
+
}
|
|
15029
|
+
var ci = external_exports.toJSONSchema(ti, { target: "draft-7" });
|
|
15030
|
+
var li = external_exports.toJSONSchema(ii, { target: "draft-7" });
|
|
15031
|
+
var di = o(Zn);
|
|
15032
|
+
var pi = o(Hn);
|
|
15033
|
+
var ui = o(Qn);
|
|
15034
|
+
var mi = o(Gn);
|
|
15035
|
+
var bi = o(_n);
|
|
15036
|
+
function fi(e4) {
|
|
15037
15037
|
let n3;
|
|
15038
15038
|
try {
|
|
15039
|
-
n3 = JSON.parse(
|
|
15039
|
+
n3 = JSON.parse(e4);
|
|
15040
15040
|
} catch (n4) {
|
|
15041
|
-
const { line: i3, column:
|
|
15042
|
-
if (
|
|
15043
|
-
const i4 =
|
|
15041
|
+
const { line: i3, column: t3 } = (function(e5, n5) {
|
|
15042
|
+
if (e5 instanceof SyntaxError) {
|
|
15043
|
+
const i4 = e5.message.match(/position\s+(\d+)/);
|
|
15044
15044
|
if (i4) {
|
|
15045
|
-
return
|
|
15045
|
+
return gi(n5, parseInt(i4[1], 10));
|
|
15046
15046
|
}
|
|
15047
|
-
const
|
|
15048
|
-
if (
|
|
15047
|
+
const t4 = e5.message.match(/line\s+(\d+)\s+column\s+(\d+)/);
|
|
15048
|
+
if (t4) return { line: parseInt(t4[1], 10), column: parseInt(t4[2], 10) };
|
|
15049
15049
|
}
|
|
15050
15050
|
return { line: 1, column: 1 };
|
|
15051
|
-
})(n4,
|
|
15052
|
-
return { valid: false, errors: [{ message: n4 instanceof Error ? n4.message : "Invalid JSON", severity: "error", line: i3, column:
|
|
15051
|
+
})(n4, e4);
|
|
15052
|
+
return { valid: false, errors: [{ message: n4 instanceof Error ? n4.message : "Invalid JSON", severity: "error", line: i3, column: t3 }], warnings: [] };
|
|
15053
15053
|
}
|
|
15054
|
-
const i2 = [],
|
|
15054
|
+
const i2 = [], t2 = [], o2 = ti.safeParse(n3);
|
|
15055
15055
|
if (!o2.success) for (const n4 of o2.error.issues) {
|
|
15056
|
-
const
|
|
15057
|
-
i2.push({ message: n4.message, severity: "error", path:
|
|
15056
|
+
const t3 = n4.path.join("."), o3 = vi(e4, n4.path);
|
|
15057
|
+
i2.push({ message: n4.message, severity: "error", path: t3 || "root", ...o3 });
|
|
15058
15058
|
}
|
|
15059
|
-
const r2 = (function(
|
|
15060
|
-
if (!(
|
|
15061
|
-
const n4 = {}, i3 = {},
|
|
15059
|
+
const r2 = (function(e5) {
|
|
15060
|
+
if (!(Si(e5) && "version" in e5 && "flows" in e5 && Si(e5.flows))) return;
|
|
15061
|
+
const n4 = {}, i3 = {}, t3 = [], o3 = [], r3 = [], a3 = [], s3 = [];
|
|
15062
15062
|
let c2;
|
|
15063
|
-
|
|
15064
|
-
for (const l3 of Object.values(
|
|
15065
|
-
c2 || ("web" in l3 ? c2 = "web" : "server" in l3 && (c2 = "server")),
|
|
15066
|
-
for (const
|
|
15067
|
-
const s4 = "sources" ===
|
|
15068
|
-
if (
|
|
15063
|
+
wi(n4, e5.variables), ki(i3, e5.definitions), Ci(s3, e5.contract);
|
|
15064
|
+
for (const l3 of Object.values(e5.flows)) if (Si(l3)) {
|
|
15065
|
+
c2 || ("web" in l3 ? c2 = "web" : "server" in l3 && (c2 = "server")), wi(n4, l3.variables), ki(i3, l3.definitions), Ci(s3, l3.contract);
|
|
15066
|
+
for (const e6 of ["sources", "destinations", "transformers"]) {
|
|
15067
|
+
const s4 = "sources" === e6 ? "source" : "destinations" === e6 ? "destination" : "transformer", d2 = "sources" === e6 ? t3 : "destinations" === e6 ? o3 : r3;
|
|
15068
|
+
if (Si(l3[e6])) for (const [t4, o4] of Object.entries(l3[e6])) d2.push(t4), Si(o4) && (wi(n4, o4.variables), ki(i3, o4.definitions), "string" == typeof o4.package && a3.push({ package: o4.package, shortName: t4, type: s4, platform: c2 || "web" }));
|
|
15069
15069
|
}
|
|
15070
15070
|
}
|
|
15071
|
-
const l2 = { variables: n4, definitions: i3, stepNames: { sources:
|
|
15071
|
+
const l2 = { variables: n4, definitions: i3, stepNames: { sources: t3, destinations: o3, transformers: r3 } };
|
|
15072
15072
|
c2 && (l2.platform = c2);
|
|
15073
15073
|
a3.length > 0 && (l2.packages = a3);
|
|
15074
15074
|
s3.length > 0 && (l2.contract = s3);
|
|
15075
15075
|
return l2;
|
|
15076
15076
|
})(n3);
|
|
15077
15077
|
if (r2) {
|
|
15078
|
-
const n4 = (function(
|
|
15078
|
+
const n4 = (function(e5, n5) {
|
|
15079
15079
|
const i3 = [];
|
|
15080
15080
|
if (n5.variables) {
|
|
15081
|
-
const
|
|
15081
|
+
const t3 = /\$var\.(\w+)/g;
|
|
15082
15082
|
let o3;
|
|
15083
|
-
for (; null !== (o3 =
|
|
15084
|
-
const
|
|
15085
|
-
i3.push({ message: `Unknown variable "$var.${o3[1]}". Defined: ${Object.keys(n5.variables).join(", ") || "none"}`, severity: "warning", path: `$var.${o3[1]}`, ...
|
|
15083
|
+
for (; null !== (o3 = t3.exec(e5)); ) if (!(o3[1] in n5.variables)) {
|
|
15084
|
+
const t4 = hi(e5, o3.index, o3[0].length);
|
|
15085
|
+
i3.push({ message: `Unknown variable "$var.${o3[1]}". Defined: ${Object.keys(n5.variables).join(", ") || "none"}`, severity: "warning", path: `$var.${o3[1]}`, ...t4 });
|
|
15086
15086
|
}
|
|
15087
15087
|
}
|
|
15088
15088
|
if (n5.definitions) {
|
|
15089
|
-
const
|
|
15089
|
+
const t3 = /\$def\.(\w+)/g;
|
|
15090
15090
|
let o3;
|
|
15091
|
-
for (; null !== (o3 =
|
|
15092
|
-
const
|
|
15093
|
-
i3.push({ message: `Unknown definition "$def.${o3[1]}". Defined: ${Object.keys(n5.definitions).join(", ") || "none"}`, severity: "warning", path: `$def.${o3[1]}`, ...
|
|
15091
|
+
for (; null !== (o3 = t3.exec(e5)); ) if (!(o3[1] in n5.definitions)) {
|
|
15092
|
+
const t4 = hi(e5, o3.index, o3[0].length);
|
|
15093
|
+
i3.push({ message: `Unknown definition "$def.${o3[1]}". Defined: ${Object.keys(n5.definitions).join(", ") || "none"}`, severity: "warning", path: `$def.${o3[1]}`, ...t4 });
|
|
15094
15094
|
}
|
|
15095
15095
|
}
|
|
15096
15096
|
return i3;
|
|
15097
|
-
})(
|
|
15098
|
-
|
|
15097
|
+
})(e4, r2);
|
|
15098
|
+
t2.push(...n4);
|
|
15099
15099
|
}
|
|
15100
|
-
return { valid: 0 === i2.length, errors: i2, warnings:
|
|
15100
|
+
return { valid: 0 === i2.length, errors: i2, warnings: t2, context: r2 };
|
|
15101
15101
|
}
|
|
15102
|
-
function
|
|
15103
|
-
let i2 = 1,
|
|
15104
|
-
for (let o2 = 0; o2 < n3 && o2 <
|
|
15105
|
-
return { line: i2, column:
|
|
15102
|
+
function gi(e4, n3) {
|
|
15103
|
+
let i2 = 1, t2 = 1;
|
|
15104
|
+
for (let o2 = 0; o2 < n3 && o2 < e4.length; o2++) "\n" === e4[o2] ? (i2++, t2 = 1) : t2++;
|
|
15105
|
+
return { line: i2, column: t2 };
|
|
15106
15106
|
}
|
|
15107
|
-
function
|
|
15108
|
-
const
|
|
15109
|
-
return { line:
|
|
15107
|
+
function hi(e4, n3, i2) {
|
|
15108
|
+
const t2 = gi(e4, n3), o2 = gi(e4, n3 + i2);
|
|
15109
|
+
return { line: t2.line, column: t2.column, endLine: o2.line, endColumn: o2.column };
|
|
15110
15110
|
}
|
|
15111
|
-
function
|
|
15111
|
+
function vi(e4, n3) {
|
|
15112
15112
|
if (0 === n3.length) return { line: 1, column: 1 };
|
|
15113
15113
|
const i2 = n3[n3.length - 1];
|
|
15114
15114
|
if ("string" == typeof i2) {
|
|
15115
|
-
const n4 = `"${i2}"`,
|
|
15116
|
-
if (-1 !==
|
|
15115
|
+
const n4 = `"${i2}"`, t2 = e4.lastIndexOf(n4);
|
|
15116
|
+
if (-1 !== t2) return gi(e4, t2);
|
|
15117
15117
|
}
|
|
15118
15118
|
return { line: 1, column: 1 };
|
|
15119
15119
|
}
|
|
15120
|
-
function
|
|
15121
|
-
return "object" == typeof
|
|
15120
|
+
function Si(e4) {
|
|
15121
|
+
return "object" == typeof e4 && null !== e4 && !Array.isArray(e4);
|
|
15122
15122
|
}
|
|
15123
|
-
function
|
|
15124
|
-
return "string" == typeof
|
|
15123
|
+
function yi(e4) {
|
|
15124
|
+
return "string" == typeof e4 || "number" == typeof e4 || "boolean" == typeof e4;
|
|
15125
15125
|
}
|
|
15126
|
-
function
|
|
15127
|
-
if (
|
|
15126
|
+
function wi(e4, n3) {
|
|
15127
|
+
if (Si(n3)) for (const [i2, t2] of Object.entries(n3)) yi(t2) && (e4[i2] = t2);
|
|
15128
15128
|
}
|
|
15129
|
-
function
|
|
15130
|
-
if (
|
|
15129
|
+
function ki(e4, n3) {
|
|
15130
|
+
if (Si(n3)) for (const [i2, t2] of Object.entries(n3)) e4[i2] = t2;
|
|
15131
15131
|
}
|
|
15132
|
-
function
|
|
15133
|
-
if (
|
|
15134
|
-
if (i2.startsWith("$") || !
|
|
15135
|
-
const n4 =
|
|
15136
|
-
if (n4) for (const
|
|
15137
|
-
else
|
|
15132
|
+
function Ci(e4, n3) {
|
|
15133
|
+
if (Si(n3)) for (const [i2, t2] of Object.entries(n3)) {
|
|
15134
|
+
if (i2.startsWith("$") || !Si(t2)) continue;
|
|
15135
|
+
const n4 = e4.find((e5) => e5.entity === i2), o2 = Object.keys(t2);
|
|
15136
|
+
if (n4) for (const e5 of o2) n4.actions.includes(e5) || n4.actions.push(e5);
|
|
15137
|
+
else e4.push({ entity: i2, actions: o2 });
|
|
15138
15138
|
}
|
|
15139
15139
|
}
|
|
15140
|
-
function
|
|
15141
|
-
const i2 = [],
|
|
15142
|
-
for (const [n4, o3] of Object.entries(
|
|
15140
|
+
function ji(e4, n3) {
|
|
15141
|
+
const i2 = [], t2 = {};
|
|
15142
|
+
for (const [n4, o3] of Object.entries(e4)) {
|
|
15143
15143
|
o3.required && i2.push(n4);
|
|
15144
|
-
const
|
|
15145
|
-
if (o3.description && (
|
|
15144
|
+
const e5 = { type: o3.type };
|
|
15145
|
+
if (o3.description && (e5.description = o3.description), o3.pattern && (e5.pattern = o3.pattern), void 0 !== o3.minLength && (e5.minLength = o3.minLength), void 0 !== o3.maxLength && (e5.maxLength = o3.maxLength), void 0 !== o3.minimum && (e5.minimum = o3.minimum), void 0 !== o3.maximum && (e5.maximum = o3.maximum), o3.enum && (e5.enum = [...o3.enum]), void 0 !== o3.default && (e5.default = o3.default), "object" === o3.type && o3.properties) {
|
|
15146
15146
|
const n5 = {};
|
|
15147
|
-
for (const [
|
|
15148
|
-
|
|
15147
|
+
for (const [e6, i3] of Object.entries(o3.properties)) n5[e6] = xi(i3);
|
|
15148
|
+
e5.properties = n5;
|
|
15149
15149
|
}
|
|
15150
|
-
"array" === o3.type && o3.items && (
|
|
15150
|
+
"array" === o3.type && o3.items && (e5.items = xi(o3.items)), t2[n4] = e5;
|
|
15151
15151
|
}
|
|
15152
|
-
const o2 = { type: "object", properties:
|
|
15152
|
+
const o2 = { type: "object", properties: t2 };
|
|
15153
15153
|
return n3 && (o2.title = n3), i2.length > 0 && (o2.required = i2), o2;
|
|
15154
15154
|
}
|
|
15155
|
-
function
|
|
15156
|
-
const n3 = { type:
|
|
15157
|
-
if (
|
|
15155
|
+
function xi(e4) {
|
|
15156
|
+
const n3 = { type: e4.type };
|
|
15157
|
+
if (e4.description && (n3.description = e4.description), e4.pattern && (n3.pattern = e4.pattern), void 0 !== e4.minLength && (n3.minLength = e4.minLength), void 0 !== e4.maxLength && (n3.maxLength = e4.maxLength), void 0 !== e4.minimum && (n3.minimum = e4.minimum), void 0 !== e4.maximum && (n3.maximum = e4.maximum), e4.enum && (n3.enum = [...e4.enum]), void 0 !== e4.default && (n3.default = e4.default), "object" === e4.type && e4.properties) {
|
|
15158
15158
|
const i2 = {};
|
|
15159
|
-
for (const [n4,
|
|
15159
|
+
for (const [n4, t2] of Object.entries(e4.properties)) i2[n4] = xi(t2);
|
|
15160
15160
|
n3.properties = i2;
|
|
15161
15161
|
}
|
|
15162
|
-
return "array" ===
|
|
15162
|
+
return "array" === e4.type && e4.items && (n3.items = xi(e4.items)), n3;
|
|
15163
15163
|
}
|
|
15164
|
-
function
|
|
15165
|
-
const i2 = { type: "array", items:
|
|
15164
|
+
function Ji(e4, n3) {
|
|
15165
|
+
const i2 = { type: "array", items: xi(e4) };
|
|
15166
15166
|
return void 0 !== n3?.minItems && (i2.minItems = n3.minItems), void 0 !== n3?.maxItems && (i2.maxItems = n3.maxItems), n3?.description && (i2.description = n3.description), n3?.title && (i2.title = n3.title), i2;
|
|
15167
15167
|
}
|
|
15168
|
-
function
|
|
15169
|
-
const
|
|
15170
|
-
return i2?.description && (
|
|
15168
|
+
function Pi(e4, n3 = "string", i2) {
|
|
15169
|
+
const t2 = { type: n3, enum: [...e4] };
|
|
15170
|
+
return i2?.description && (t2.description = i2.description), i2?.title && (t2.title = i2.title), t2;
|
|
15171
15171
|
}
|
|
15172
|
-
function
|
|
15173
|
-
return
|
|
15172
|
+
function Ei(e4, n3, i2) {
|
|
15173
|
+
return Ji({ type: "object" }, { minItems: 2, maxItems: 2, description: i2 || "Tuple with exactly 2 elements [source, transform]" });
|
|
15174
15174
|
}
|
|
15175
|
-
function
|
|
15176
|
-
return external_exports.toJSONSchema(
|
|
15175
|
+
function Di(e4) {
|
|
15176
|
+
return external_exports.toJSONSchema(e4, { target: "draft-7" });
|
|
15177
15177
|
}
|
|
15178
15178
|
|
|
15179
15179
|
// src/config/validators.ts
|
|
@@ -15185,8 +15185,8 @@ function validateFlowSetup(data) {
|
|
|
15185
15185
|
const result = safeParseSetup(data);
|
|
15186
15186
|
if (!result.success) {
|
|
15187
15187
|
const errors = result.error.issues.map((issue2) => {
|
|
15188
|
-
const
|
|
15189
|
-
return ` - ${
|
|
15188
|
+
const path15 = issue2.path.length > 0 ? issue2.path.map(String).join(".") : "root";
|
|
15189
|
+
return ` - ${path15}: ${issue2.message}`;
|
|
15190
15190
|
}).join("\n");
|
|
15191
15191
|
throw new Error(`Invalid configuration:
|
|
15192
15192
|
${errors}`);
|
|
@@ -15236,15 +15236,15 @@ function loadBundleConfig(rawConfig, options) {
|
|
|
15236
15236
|
const setup = validateFlowSetup(rawConfig);
|
|
15237
15237
|
const availableFlows = getAvailableFlows(setup);
|
|
15238
15238
|
const flowName = resolveFlow(setup, options.flowName, availableFlows);
|
|
15239
|
-
let flowConfig =
|
|
15240
|
-
const platform =
|
|
15239
|
+
let flowConfig = C(setup, flowName, { deferred: true });
|
|
15240
|
+
const platform = D(flowConfig);
|
|
15241
15241
|
if (!platform) {
|
|
15242
15242
|
throw new Error(
|
|
15243
15243
|
`Invalid configuration: flow "${flowName}" must have a "web" or "server" key.`
|
|
15244
15244
|
);
|
|
15245
15245
|
}
|
|
15246
15246
|
if (platform === "web") {
|
|
15247
|
-
flowConfig =
|
|
15247
|
+
flowConfig = C(setup, flowName);
|
|
15248
15248
|
}
|
|
15249
15249
|
const buildDefaults = getBuildDefaults(platform);
|
|
15250
15250
|
const packages = flowConfig.packages || {};
|
|
@@ -15331,11 +15331,11 @@ import fs6 from "fs-extra";
|
|
|
15331
15331
|
// ../server/core/dist/index.mjs
|
|
15332
15332
|
init_dist();
|
|
15333
15333
|
import { createHash as n2 } from "crypto";
|
|
15334
|
-
async function u3(
|
|
15335
|
-
return (await (async function(
|
|
15336
|
-
const
|
|
15337
|
-
return
|
|
15338
|
-
})(
|
|
15334
|
+
async function u3(t2, e4) {
|
|
15335
|
+
return (await (async function(t3) {
|
|
15336
|
+
const e5 = n2("sha256");
|
|
15337
|
+
return e5.update(t3), e5.digest("hex");
|
|
15338
|
+
})(t2)).slice(0, e4);
|
|
15339
15339
|
}
|
|
15340
15340
|
|
|
15341
15341
|
// src/core/cache-utils.ts
|
|
@@ -15371,7 +15371,7 @@ async function getFlowConfigCacheKey(content, date5) {
|
|
|
15371
15371
|
var PACKAGE_DOWNLOAD_TIMEOUT_MS = 6e4;
|
|
15372
15372
|
async function withTimeout(promise2, ms, errorMessage) {
|
|
15373
15373
|
let timer;
|
|
15374
|
-
const timeout = new Promise((
|
|
15374
|
+
const timeout = new Promise((_3, reject) => {
|
|
15375
15375
|
timer = setTimeout(() => reject(new Error(errorMessage)), ms);
|
|
15376
15376
|
});
|
|
15377
15377
|
try {
|
|
@@ -15629,11 +15629,18 @@ async function copyIncludes(includes, sourceDir, outputDir, logger2) {
|
|
|
15629
15629
|
const sourcePath = path9.resolve(sourceDir, include);
|
|
15630
15630
|
const folderName = path9.basename(include);
|
|
15631
15631
|
const destPath = path9.join(outputDir, folderName);
|
|
15632
|
+
const resolvedOutput = path9.resolve(outputDir);
|
|
15633
|
+
const resolvedSource = path9.resolve(sourcePath);
|
|
15634
|
+
if (resolvedSource === resolvedOutput || resolvedOutput.startsWith(resolvedSource + path9.sep) || resolvedSource.startsWith(resolvedOutput + path9.sep)) {
|
|
15635
|
+
throw new Error(
|
|
15636
|
+
`Circular include detected: "${include}" resolves to "${resolvedSource}" which overlaps with output directory "${resolvedOutput}"`
|
|
15637
|
+
);
|
|
15638
|
+
}
|
|
15632
15639
|
if (await fs8.pathExists(sourcePath)) {
|
|
15633
15640
|
await fs8.copy(sourcePath, destPath);
|
|
15634
15641
|
logger2.debug(`Copied ${include} to output`);
|
|
15635
15642
|
} else {
|
|
15636
|
-
logger2.
|
|
15643
|
+
logger2.warn(`Include folder not found: ${include}`);
|
|
15637
15644
|
}
|
|
15638
15645
|
}
|
|
15639
15646
|
}
|
|
@@ -15982,6 +15989,18 @@ function detectTransformerPackages(flowConfig) {
|
|
|
15982
15989
|
}
|
|
15983
15990
|
return transformerPackages;
|
|
15984
15991
|
}
|
|
15992
|
+
function detectStorePackages(flowConfig) {
|
|
15993
|
+
const storePackages = /* @__PURE__ */ new Set();
|
|
15994
|
+
const stores = flowConfig.stores;
|
|
15995
|
+
if (stores) {
|
|
15996
|
+
for (const [, storeConfig] of Object.entries(stores)) {
|
|
15997
|
+
if (typeof storeConfig === "object" && storeConfig !== null && "package" in storeConfig && typeof storeConfig.package === "string") {
|
|
15998
|
+
storePackages.add(storeConfig.package);
|
|
15999
|
+
}
|
|
16000
|
+
}
|
|
16001
|
+
}
|
|
16002
|
+
return storePackages;
|
|
16003
|
+
}
|
|
15985
16004
|
function detectExplicitCodeImports(flowConfig) {
|
|
15986
16005
|
const explicitCodeImports = /* @__PURE__ */ new Map();
|
|
15987
16006
|
const destinations = flowConfig.destinations;
|
|
@@ -16037,22 +16056,37 @@ function detectExplicitCodeImports(flowConfig) {
|
|
|
16037
16056
|
}
|
|
16038
16057
|
}
|
|
16039
16058
|
}
|
|
16059
|
+
const stores = flowConfig.stores;
|
|
16060
|
+
if (stores) {
|
|
16061
|
+
for (const [, storeConfig] of Object.entries(stores)) {
|
|
16062
|
+
if (typeof storeConfig === "object" && storeConfig !== null && "package" in storeConfig && typeof storeConfig.package === "string" && "code" in storeConfig && typeof storeConfig.code === "string") {
|
|
16063
|
+
const isAutoGenerated = storeConfig.code.startsWith("_");
|
|
16064
|
+
if (!isAutoGenerated) {
|
|
16065
|
+
if (!explicitCodeImports.has(storeConfig.package)) {
|
|
16066
|
+
explicitCodeImports.set(storeConfig.package, /* @__PURE__ */ new Set());
|
|
16067
|
+
}
|
|
16068
|
+
explicitCodeImports.get(storeConfig.package).add(storeConfig.code);
|
|
16069
|
+
}
|
|
16070
|
+
}
|
|
16071
|
+
}
|
|
16072
|
+
}
|
|
16040
16073
|
return explicitCodeImports;
|
|
16041
16074
|
}
|
|
16042
|
-
function generateImportStatements(packages, destinationPackages, sourcePackages, transformerPackages, explicitCodeImports) {
|
|
16075
|
+
function generateImportStatements(packages, destinationPackages, sourcePackages, transformerPackages, storePackages, explicitCodeImports) {
|
|
16043
16076
|
const importStatements = [];
|
|
16044
16077
|
const examplesMappings = [];
|
|
16045
16078
|
const usedPackages = /* @__PURE__ */ new Set([
|
|
16046
16079
|
...destinationPackages,
|
|
16047
16080
|
...sourcePackages,
|
|
16048
|
-
...transformerPackages
|
|
16081
|
+
...transformerPackages,
|
|
16082
|
+
...storePackages
|
|
16049
16083
|
]);
|
|
16050
16084
|
for (const [packageName, packageConfig] of Object.entries(packages)) {
|
|
16051
16085
|
const isUsedByDestOrSource = usedPackages.has(packageName);
|
|
16052
16086
|
const hasExplicitCode = explicitCodeImports.has(packageName);
|
|
16053
16087
|
const namedImportsToGenerate = [];
|
|
16054
16088
|
if (isUsedByDestOrSource && !hasExplicitCode) {
|
|
16055
|
-
const varName =
|
|
16089
|
+
const varName = _(packageName);
|
|
16056
16090
|
importStatements.push(`import ${varName} from '${packageName}';`);
|
|
16057
16091
|
}
|
|
16058
16092
|
if (hasExplicitCode) {
|
|
@@ -16101,16 +16135,74 @@ function generateImportStatements(packages, destinationPackages, sourcePackages,
|
|
|
16101
16135
|
}
|
|
16102
16136
|
return { importStatements, examplesMappings };
|
|
16103
16137
|
}
|
|
16138
|
+
var VALID_JS_IDENTIFIER = /^[a-zA-Z_$][a-zA-Z0-9_$]*$/;
|
|
16139
|
+
function validateComponentNames(components, section) {
|
|
16140
|
+
for (const name of Object.keys(components)) {
|
|
16141
|
+
if (!VALID_JS_IDENTIFIER.test(name)) {
|
|
16142
|
+
throw new Error(
|
|
16143
|
+
`Invalid ${section} name "${name}": must be a valid JavaScript identifier (use camelCase, e.g., "${name.replace(/-([a-z])/g, (_3, c2) => c2.toUpperCase())}")`
|
|
16144
|
+
);
|
|
16145
|
+
}
|
|
16146
|
+
}
|
|
16147
|
+
}
|
|
16148
|
+
function validateStoreReferences(flowConfig, storeIds) {
|
|
16149
|
+
const refs = [];
|
|
16150
|
+
function collectRefs(obj, path15) {
|
|
16151
|
+
if (typeof obj === "string" && obj.startsWith("$store:")) {
|
|
16152
|
+
refs.push({ ref: obj.slice(7), location: path15 });
|
|
16153
|
+
} else if (obj && typeof obj === "object") {
|
|
16154
|
+
for (const [key, val] of Object.entries(obj)) {
|
|
16155
|
+
collectRefs(val, `${path15}.${key}`);
|
|
16156
|
+
}
|
|
16157
|
+
}
|
|
16158
|
+
}
|
|
16159
|
+
for (const [section, components] of Object.entries({
|
|
16160
|
+
sources: flowConfig.sources || {},
|
|
16161
|
+
destinations: flowConfig.destinations || {},
|
|
16162
|
+
transformers: flowConfig.transformers || {}
|
|
16163
|
+
})) {
|
|
16164
|
+
for (const [id, component] of Object.entries(
|
|
16165
|
+
components
|
|
16166
|
+
)) {
|
|
16167
|
+
collectRefs(component, `${section}.${id}`);
|
|
16168
|
+
}
|
|
16169
|
+
}
|
|
16170
|
+
for (const { ref, location } of refs) {
|
|
16171
|
+
if (!storeIds.has(ref)) {
|
|
16172
|
+
const available = storeIds.size > 0 ? `Available stores: ${Array.from(storeIds).join(", ")}` : "No stores defined";
|
|
16173
|
+
throw new Error(
|
|
16174
|
+
`Store reference "$store:${ref}" in ${location} \u2014 store "${ref}" not found. ${available}`
|
|
16175
|
+
);
|
|
16176
|
+
}
|
|
16177
|
+
}
|
|
16178
|
+
}
|
|
16104
16179
|
async function createEntryPoint(flowConfig, buildOptions, packagePaths) {
|
|
16105
16180
|
const destinationPackages = detectDestinationPackages(flowConfig);
|
|
16106
16181
|
const sourcePackages = detectSourcePackages(flowConfig);
|
|
16107
16182
|
const transformerPackages = detectTransformerPackages(flowConfig);
|
|
16183
|
+
const storePackages = detectStorePackages(flowConfig);
|
|
16108
16184
|
const explicitCodeImports = detectExplicitCodeImports(flowConfig);
|
|
16185
|
+
const storeIds = new Set(
|
|
16186
|
+
Object.keys(
|
|
16187
|
+
flowConfig.stores || {}
|
|
16188
|
+
)
|
|
16189
|
+
);
|
|
16190
|
+
validateStoreReferences(flowConfig, storeIds);
|
|
16191
|
+
const flowWithSections = flowConfig;
|
|
16192
|
+
if (flowWithSections.sources)
|
|
16193
|
+
validateComponentNames(flowWithSections.sources, "sources");
|
|
16194
|
+
if (flowWithSections.destinations)
|
|
16195
|
+
validateComponentNames(flowWithSections.destinations, "destinations");
|
|
16196
|
+
if (flowWithSections.transformers)
|
|
16197
|
+
validateComponentNames(flowWithSections.transformers, "transformers");
|
|
16198
|
+
if (flowWithSections.stores)
|
|
16199
|
+
validateComponentNames(flowWithSections.stores, "stores");
|
|
16109
16200
|
const { importStatements } = generateImportStatements(
|
|
16110
16201
|
buildOptions.packages,
|
|
16111
16202
|
destinationPackages,
|
|
16112
16203
|
sourcePackages,
|
|
16113
16204
|
transformerPackages,
|
|
16205
|
+
storePackages,
|
|
16114
16206
|
explicitCodeImports
|
|
16115
16207
|
);
|
|
16116
16208
|
const importsCode = importStatements.join("\n");
|
|
@@ -16163,6 +16255,7 @@ function buildConfigObject(flowConfig, explicitCodeImports) {
|
|
|
16163
16255
|
const sources = flowWithProps.sources || {};
|
|
16164
16256
|
const destinations = flowWithProps.destinations || {};
|
|
16165
16257
|
const transformers = flowWithProps.transformers || {};
|
|
16258
|
+
const stores = flowWithProps.stores || {};
|
|
16166
16259
|
Object.entries(sources).forEach(([name, source]) => {
|
|
16167
16260
|
if (source.code !== true) {
|
|
16168
16261
|
validateReference("Source", name, source);
|
|
@@ -16188,7 +16281,7 @@ function buildConfigObject(flowConfig, explicitCodeImports) {
|
|
|
16188
16281
|
if (source.code && typeof source.code === "string" && explicitCodeImports.has(source.package)) {
|
|
16189
16282
|
codeVar = source.code;
|
|
16190
16283
|
} else {
|
|
16191
|
-
codeVar =
|
|
16284
|
+
codeVar = _(source.package);
|
|
16192
16285
|
}
|
|
16193
16286
|
const configStr = source.config ? processConfigValue(source.config) : "{}";
|
|
16194
16287
|
const envStr = source.env ? `,
|
|
@@ -16210,7 +16303,7 @@ function buildConfigObject(flowConfig, explicitCodeImports) {
|
|
|
16210
16303
|
if (dest.code && typeof dest.code === "string" && explicitCodeImports.has(dest.package)) {
|
|
16211
16304
|
codeVar = dest.code;
|
|
16212
16305
|
} else {
|
|
16213
|
-
codeVar =
|
|
16306
|
+
codeVar = _(dest.package);
|
|
16214
16307
|
}
|
|
16215
16308
|
const configStr = dest.config ? processConfigValue(dest.config) : "{}";
|
|
16216
16309
|
const envStr = dest.env ? `,
|
|
@@ -16232,7 +16325,7 @@ function buildConfigObject(flowConfig, explicitCodeImports) {
|
|
|
16232
16325
|
if (transformer.code && typeof transformer.code === "string" && explicitCodeImports.has(transformer.package)) {
|
|
16233
16326
|
codeVar = transformer.code;
|
|
16234
16327
|
} else {
|
|
16235
|
-
codeVar =
|
|
16328
|
+
codeVar = _(transformer.package);
|
|
16236
16329
|
}
|
|
16237
16330
|
const configStr = transformer.config ? processConfigValue(transformer.config) : "{}";
|
|
16238
16331
|
const envStr = transformer.env ? `,
|
|
@@ -16244,11 +16337,38 @@ function buildConfigObject(flowConfig, explicitCodeImports) {
|
|
|
16244
16337
|
config: ${configStr}${envStr}${nextStr}
|
|
16245
16338
|
}`;
|
|
16246
16339
|
});
|
|
16340
|
+
Object.entries(stores).forEach(([name, store]) => {
|
|
16341
|
+
if (store.package || isInlineCode(store.code)) {
|
|
16342
|
+
validateReference("Store", name, store);
|
|
16343
|
+
}
|
|
16344
|
+
});
|
|
16345
|
+
const storesEntries = Object.entries(stores).filter(([, store]) => store.package || isInlineCode(store.code)).map(([key, store]) => {
|
|
16346
|
+
if (isInlineCode(store.code)) {
|
|
16347
|
+
return ` ${key}: ${generateInlineCode(store.code, store.config || {}, store.env)}`;
|
|
16348
|
+
}
|
|
16349
|
+
let codeVar;
|
|
16350
|
+
if (store.code && typeof store.code === "string" && explicitCodeImports.has(store.package)) {
|
|
16351
|
+
codeVar = store.code;
|
|
16352
|
+
} else {
|
|
16353
|
+
codeVar = _(store.package);
|
|
16354
|
+
}
|
|
16355
|
+
const configStr = store.config ? processConfigValue(store.config) : "{}";
|
|
16356
|
+
const envStr = store.env ? `,
|
|
16357
|
+
env: ${processConfigValue(store.env)}` : "";
|
|
16358
|
+
return ` ${key}: {
|
|
16359
|
+
code: ${codeVar},
|
|
16360
|
+
config: ${configStr}${envStr}
|
|
16361
|
+
}`;
|
|
16362
|
+
});
|
|
16247
16363
|
const collectorStr = flowWithProps.collector ? `,
|
|
16248
16364
|
...${processConfigValue(flowWithProps.collector)}` : "";
|
|
16249
16365
|
const transformersStr = transformersEntries.length > 0 ? `,
|
|
16250
16366
|
transformers: {
|
|
16251
16367
|
${transformersEntries.join(",\n")}
|
|
16368
|
+
}` : "";
|
|
16369
|
+
const storesStr = storesEntries.length > 0 ? `,
|
|
16370
|
+
stores: {
|
|
16371
|
+
${storesEntries.join(",\n")}
|
|
16252
16372
|
}` : "";
|
|
16253
16373
|
return `{
|
|
16254
16374
|
sources: {
|
|
@@ -16256,7 +16376,7 @@ ${sourcesEntries.join(",\n")}
|
|
|
16256
16376
|
},
|
|
16257
16377
|
destinations: {
|
|
16258
16378
|
${destinationsEntries.join(",\n")}
|
|
16259
|
-
}${transformersStr}${collectorStr}
|
|
16379
|
+
}${transformersStr}${storesStr}${collectorStr}
|
|
16260
16380
|
}`;
|
|
16261
16381
|
}
|
|
16262
16382
|
function processConfigValue(value) {
|
|
@@ -16266,10 +16386,14 @@ function serializeWithCode(value, indent) {
|
|
|
16266
16386
|
const spaces = " ".repeat(indent);
|
|
16267
16387
|
const nextSpaces = " ".repeat(indent + 1);
|
|
16268
16388
|
if (typeof value === "string") {
|
|
16389
|
+
if (value.startsWith("$store:")) {
|
|
16390
|
+
const storeId = value.slice(7);
|
|
16391
|
+
return `stores.${storeId}`;
|
|
16392
|
+
}
|
|
16269
16393
|
if (value.startsWith("$code:")) {
|
|
16270
16394
|
return value.slice(6);
|
|
16271
16395
|
}
|
|
16272
|
-
const esc2 =
|
|
16396
|
+
const esc2 = T.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
16273
16397
|
const markerRe = new RegExp(
|
|
16274
16398
|
esc2 + "([a-zA-Z_][a-zA-Z0-9_]*)(?::((?:(?!" + esc2 + `)[^\\s"'])*))?`,
|
|
16275
16399
|
"g"
|
|
@@ -16314,7 +16438,7 @@ ${spaces}]`;
|
|
|
16314
16438
|
const entries = Object.entries(value);
|
|
16315
16439
|
if (entries.length === 0) return "{}";
|
|
16316
16440
|
const props = entries.map(
|
|
16317
|
-
([
|
|
16441
|
+
([k2, v2]) => `${nextSpaces}${JSON.stringify(k2)}: ${serializeWithCode(v2, indent + 1)}`
|
|
16318
16442
|
);
|
|
16319
16443
|
return `{
|
|
16320
16444
|
${props.join(",\n")}
|
|
@@ -16442,13 +16566,43 @@ function createApiClient() {
|
|
|
16442
16566
|
});
|
|
16443
16567
|
}
|
|
16444
16568
|
|
|
16569
|
+
// src/commands/bundle/dockerfile.ts
|
|
16570
|
+
import path10 from "path";
|
|
16571
|
+
import fs10 from "fs-extra";
|
|
16572
|
+
function buildDockerfileContent(platform, includedFolders) {
|
|
16573
|
+
const bundleFile = platform === "web" ? "walker.js" : "bundle.mjs";
|
|
16574
|
+
const lines = [
|
|
16575
|
+
"# Generated by walkeros CLI",
|
|
16576
|
+
"FROM walkeros/flow:latest",
|
|
16577
|
+
"",
|
|
16578
|
+
`COPY ${bundleFile} /app/flow/${bundleFile}`
|
|
16579
|
+
];
|
|
16580
|
+
for (const folder of includedFolders) {
|
|
16581
|
+
const name = path10.basename(folder);
|
|
16582
|
+
lines.push(`COPY ${name}/ /app/flow/${name}/`);
|
|
16583
|
+
}
|
|
16584
|
+
lines.push("", `ENV BUNDLE=/app/flow/${bundleFile}`, "", "EXPOSE 8080", "");
|
|
16585
|
+
return lines.join("\n");
|
|
16586
|
+
}
|
|
16587
|
+
async function generateDockerfile(outputDir, platform, logger2, customFile, includedFolders) {
|
|
16588
|
+
const destPath = path10.join(outputDir, "Dockerfile");
|
|
16589
|
+
if (customFile && await fs10.pathExists(customFile)) {
|
|
16590
|
+
await fs10.copy(customFile, destPath);
|
|
16591
|
+
logger2.info(`Dockerfile: ${destPath} (copied from ${customFile})`);
|
|
16592
|
+
return;
|
|
16593
|
+
}
|
|
16594
|
+
const dockerfile = buildDockerfileContent(platform, includedFolders || []);
|
|
16595
|
+
await fs10.writeFile(destPath, dockerfile);
|
|
16596
|
+
logger2.info(`Dockerfile: ${destPath}`);
|
|
16597
|
+
}
|
|
16598
|
+
|
|
16445
16599
|
// src/commands/bundle/index.ts
|
|
16446
16600
|
function resolveOutputPath(output, buildOptions) {
|
|
16447
|
-
const resolved =
|
|
16448
|
-
const ext =
|
|
16449
|
-
if (output.endsWith("/") || output.endsWith(
|
|
16601
|
+
const resolved = path11.resolve(output);
|
|
16602
|
+
const ext = path11.extname(resolved);
|
|
16603
|
+
if (output.endsWith("/") || output.endsWith(path11.sep) || !ext) {
|
|
16450
16604
|
const filename = buildOptions.platform === "browser" ? "walker.js" : "bundle.mjs";
|
|
16451
|
-
return
|
|
16605
|
+
return path11.join(resolved, filename);
|
|
16452
16606
|
}
|
|
16453
16607
|
return resolved;
|
|
16454
16608
|
}
|
|
@@ -16478,7 +16632,7 @@ async function bundleCommand(options) {
|
|
|
16478
16632
|
} catch {
|
|
16479
16633
|
throw new Error("Invalid JSON received on stdin");
|
|
16480
16634
|
}
|
|
16481
|
-
configPath =
|
|
16635
|
+
configPath = path11.resolve(process.cwd(), "stdin.config.json");
|
|
16482
16636
|
} else {
|
|
16483
16637
|
const file2 = options.config || "bundle.config.json";
|
|
16484
16638
|
configPath = resolveAsset(file2, "config");
|
|
@@ -16532,21 +16686,27 @@ async function bundleCommand(options) {
|
|
|
16532
16686
|
if (uploadUrl) {
|
|
16533
16687
|
await uploadBundleToUrl(buildOptions.output, uploadUrl);
|
|
16534
16688
|
logger2.info(`Uploaded to: ${sanitizeUrl(uploadUrl)}`);
|
|
16535
|
-
await
|
|
16689
|
+
await fs11.remove(buildOptions.output);
|
|
16536
16690
|
}
|
|
16537
16691
|
if (!options.json && !options.all && options.stats && stats) {
|
|
16538
16692
|
displayStats(stats, logger2);
|
|
16539
16693
|
}
|
|
16540
16694
|
if (writingToStdout && !options.json) {
|
|
16541
|
-
const bundleContent = await
|
|
16695
|
+
const bundleContent = await fs11.readFile(buildOptions.output);
|
|
16542
16696
|
await writeResult(bundleContent, {});
|
|
16543
16697
|
}
|
|
16544
16698
|
if (options.dockerfile && options.output) {
|
|
16545
|
-
const platform =
|
|
16699
|
+
const platform = D(flowConfig);
|
|
16546
16700
|
if (platform) {
|
|
16547
|
-
const outputDir =
|
|
16701
|
+
const outputDir = path11.dirname(buildOptions.output);
|
|
16548
16702
|
const customFile = typeof options.dockerfile === "string" ? options.dockerfile : void 0;
|
|
16549
|
-
await generateDockerfile(
|
|
16703
|
+
await generateDockerfile(
|
|
16704
|
+
outputDir,
|
|
16705
|
+
platform,
|
|
16706
|
+
logger2,
|
|
16707
|
+
customFile,
|
|
16708
|
+
buildOptions.include
|
|
16709
|
+
);
|
|
16550
16710
|
}
|
|
16551
16711
|
}
|
|
16552
16712
|
} catch (error48) {
|
|
@@ -16609,7 +16769,7 @@ Build Summary: ${successCount}/${results.length} succeeded`
|
|
|
16609
16769
|
}
|
|
16610
16770
|
async function bundle(configOrPath, options = {}) {
|
|
16611
16771
|
let rawConfig;
|
|
16612
|
-
let configPath =
|
|
16772
|
+
let configPath = path11.resolve(process.cwd(), "walkeros.config.json");
|
|
16613
16773
|
if (typeof configOrPath === "string") {
|
|
16614
16774
|
configPath = resolveAsset(configOrPath, "config");
|
|
16615
16775
|
rawConfig = await loadJsonConfig(configPath);
|
|
@@ -16632,31 +16792,9 @@ async function bundle(configOrPath, options = {}) {
|
|
|
16632
16792
|
options.stats ?? false
|
|
16633
16793
|
);
|
|
16634
16794
|
}
|
|
16635
|
-
async function generateDockerfile(outputDir, platform, logger2, customFile) {
|
|
16636
|
-
const destPath = path10.join(outputDir, "Dockerfile");
|
|
16637
|
-
if (customFile && await fs10.pathExists(customFile)) {
|
|
16638
|
-
await fs10.copy(customFile, destPath);
|
|
16639
|
-
logger2.info(`Dockerfile: ${destPath} (copied from ${customFile})`);
|
|
16640
|
-
return;
|
|
16641
|
-
}
|
|
16642
|
-
const isWeb = platform === "web";
|
|
16643
|
-
const bundleFile = isWeb ? "walker.js" : "bundle.mjs";
|
|
16644
|
-
const dockerfile = `# Generated by walkeros CLI
|
|
16645
|
-
FROM walkeros/flow:latest
|
|
16646
|
-
|
|
16647
|
-
COPY ${bundleFile} /app/flow/${bundleFile}
|
|
16648
|
-
|
|
16649
|
-
ENV BUNDLE=/app/flow/${bundleFile}
|
|
16650
|
-
|
|
16651
|
-
EXPOSE 8080
|
|
16652
|
-
`;
|
|
16653
|
-
await fs10.writeFile(destPath, dockerfile);
|
|
16654
|
-
logger2.info(`Dockerfile: ${destPath}`);
|
|
16655
|
-
}
|
|
16656
16795
|
|
|
16657
16796
|
// src/commands/simulate/simulator.ts
|
|
16658
|
-
|
|
16659
|
-
import fs11 from "fs-extra";
|
|
16797
|
+
import fs12 from "fs-extra";
|
|
16660
16798
|
|
|
16661
16799
|
// ../collector/dist/index.mjs
|
|
16662
16800
|
init_dist();
|
|
@@ -16670,307 +16808,307 @@ init_dist();
|
|
|
16670
16808
|
init_dist();
|
|
16671
16809
|
init_dist();
|
|
16672
16810
|
init_dist();
|
|
16673
|
-
var
|
|
16674
|
-
var
|
|
16675
|
-
function s2(n3,
|
|
16676
|
-
let
|
|
16811
|
+
var e3 = { Action: "action", Actions: "actions", Config: "config", Consent: "consent", Context: "context", Custom: "custom", Destination: "destination", Elb: "elb", Globals: "globals", Hook: "hook", Init: "init", Link: "link", On: "on", Prefix: "data-elb", Ready: "ready", Run: "run", Session: "session", Shutdown: "shutdown", User: "user", Walker: "walker" };
|
|
16812
|
+
var t = { Commands: e3, Utils: { Storage: { Cookie: "cookie", Local: "local", Session: "session" } } };
|
|
16813
|
+
function s2(n3, e4) {
|
|
16814
|
+
let t2 = false;
|
|
16677
16815
|
const s3 = {};
|
|
16678
|
-
return Object.entries(
|
|
16679
|
-
const o2 = !!
|
|
16680
|
-
s3[n4] = o2,
|
|
16681
|
-
}), n3.consent =
|
|
16816
|
+
return Object.entries(e4).forEach(([n4, e5]) => {
|
|
16817
|
+
const o2 = !!e5;
|
|
16818
|
+
s3[n4] = o2, t2 = t2 || o2;
|
|
16819
|
+
}), n3.consent = I(n3.consent, s3), { update: s3, runQueue: t2 };
|
|
16682
16820
|
}
|
|
16683
16821
|
function D3(n3) {
|
|
16684
|
-
|
|
16685
|
-
}
|
|
16686
|
-
|
|
16687
|
-
const e3 = {};
|
|
16688
|
-
for (const [t3, o2] of Object.entries(n3)) o2.config?.next ? e3[t3] = { next: o2.config.next } : e3[t3] = {};
|
|
16689
|
-
return e3;
|
|
16822
|
+
const e4 = {};
|
|
16823
|
+
for (const [t2, o2] of Object.entries(n3)) o2.config?.next ? e4[t2] = { next: o2.config.next } : e4[t2] = {};
|
|
16824
|
+
return e4;
|
|
16690
16825
|
}
|
|
16691
|
-
function
|
|
16692
|
-
const
|
|
16693
|
-
return void 0 !== o2 ? { config: { ...
|
|
16826
|
+
function A3(n3, e4) {
|
|
16827
|
+
const t2 = n3.config || {}, o2 = n3[e4];
|
|
16828
|
+
return void 0 !== o2 ? { config: { ...t2, [e4]: o2 }, chainValue: o2 } : { config: t2, chainValue: void 0 };
|
|
16694
16829
|
}
|
|
16695
|
-
function
|
|
16830
|
+
function E3(n3, e4 = {}) {
|
|
16696
16831
|
if (!n3) return [];
|
|
16697
16832
|
if (Array.isArray(n3)) return n3;
|
|
16698
|
-
const
|
|
16833
|
+
const t2 = [], o2 = /* @__PURE__ */ new Set();
|
|
16699
16834
|
let s3 = n3;
|
|
16700
|
-
for (; s3 &&
|
|
16701
|
-
o2.add(s3),
|
|
16702
|
-
const n4 =
|
|
16835
|
+
for (; s3 && e4[s3] && !o2.has(s3); ) {
|
|
16836
|
+
o2.add(s3), t2.push(s3);
|
|
16837
|
+
const n4 = e4[s3].next;
|
|
16703
16838
|
if (Array.isArray(n4)) {
|
|
16704
|
-
|
|
16839
|
+
t2.push(...n4);
|
|
16705
16840
|
break;
|
|
16706
16841
|
}
|
|
16707
16842
|
s3 = n4;
|
|
16708
16843
|
}
|
|
16709
|
-
return
|
|
16844
|
+
return t2;
|
|
16710
16845
|
}
|
|
16711
|
-
async function
|
|
16712
|
-
if (
|
|
16713
|
-
const o2 =
|
|
16846
|
+
async function P3(n3, e4, t2) {
|
|
16847
|
+
if (e4.init && !e4.config.init) {
|
|
16848
|
+
const o2 = e4.type || "unknown", s3 = n3.logger.scope(`transformer:${o2}`), r2 = { collector: n3, logger: s3, id: t2, config: e4.config, env: $3(e4.config.env) };
|
|
16714
16849
|
s3.debug("init");
|
|
16715
|
-
const i2 = await
|
|
16850
|
+
const i2 = await _e(e4.init, "TransformerInit", n3.hooks)(r2);
|
|
16716
16851
|
if (false === i2) return false;
|
|
16717
|
-
|
|
16852
|
+
e4.config = { ...i2 || e4.config, init: true }, s3.debug("init done");
|
|
16718
16853
|
}
|
|
16719
16854
|
return true;
|
|
16720
16855
|
}
|
|
16721
|
-
async function
|
|
16722
|
-
const i2 =
|
|
16856
|
+
async function x3(n3, e4, t2, o2, s3, r2) {
|
|
16857
|
+
const i2 = e4.type || "unknown", a3 = n3.logger.scope(`transformer:${i2}`), c2 = { collector: n3, logger: a3, id: t2, ingest: s3, config: e4.config, env: { ...$3(e4.config.env), ...r2 ? { respond: r2 } : {} } };
|
|
16723
16858
|
a3.debug("push", { event: o2.name });
|
|
16724
|
-
const u4 = await
|
|
16859
|
+
const u4 = await _e(e4.push, "TransformerPush", n3.hooks)(o2, c2);
|
|
16725
16860
|
return a3.debug("push done"), u4;
|
|
16726
16861
|
}
|
|
16727
|
-
async function
|
|
16728
|
-
let i2 = o2;
|
|
16729
|
-
for (const o3 of
|
|
16730
|
-
const
|
|
16731
|
-
if (!
|
|
16862
|
+
async function S3(n3, e4, t2, o2, s3, r2) {
|
|
16863
|
+
let i2 = o2, a3 = r2;
|
|
16864
|
+
for (const o3 of t2) {
|
|
16865
|
+
const t3 = e4[o3];
|
|
16866
|
+
if (!t3) {
|
|
16732
16867
|
n3.logger.warn(`Transformer not found: ${o3}`);
|
|
16733
16868
|
continue;
|
|
16734
16869
|
}
|
|
16735
|
-
if (!await
|
|
16736
|
-
const
|
|
16737
|
-
if (false ===
|
|
16738
|
-
if (
|
|
16739
|
-
const
|
|
16740
|
-
|
|
16870
|
+
if (!await he(P3)(n3, t3, o3)) return n3.logger.error(`Transformer init failed: ${o3}`), null;
|
|
16871
|
+
const r3 = await he(x3, (e5) => (n3.logger.scope(`transformer:${t3.type || "unknown"}`).error("Push failed", { error: e5 }), false))(n3, t3, o3, i2, s3, a3);
|
|
16872
|
+
if (false === r3) return null;
|
|
16873
|
+
if (r3 && "object" == typeof r3) {
|
|
16874
|
+
const { event: t4, respond: o4, next: c2 } = r3;
|
|
16875
|
+
if (o4 && (a3 = o4), c2) {
|
|
16876
|
+
const o5 = E3(c2, D3(e4));
|
|
16877
|
+
return o5.length > 0 ? S3(n3, e4, o5, t4 || i2, s3, a3) : (n3.logger.warn(`Branch target not found: ${JSON.stringify(c2)}`), null);
|
|
16878
|
+
}
|
|
16879
|
+
t4 && (i2 = t4);
|
|
16741
16880
|
}
|
|
16742
|
-
void 0 !== a3 && (i2 = a3);
|
|
16743
16881
|
}
|
|
16744
16882
|
return i2;
|
|
16745
16883
|
}
|
|
16746
|
-
function
|
|
16747
|
-
return n3 &&
|
|
16884
|
+
function $3(n3) {
|
|
16885
|
+
return n3 && q(n3) ? n3 : {};
|
|
16748
16886
|
}
|
|
16749
|
-
async function
|
|
16750
|
-
const { code: o2, config: s3 = {}, env: r2 = {}, primary: i2, next: a3 } =
|
|
16887
|
+
async function R3(n3, e4, t2) {
|
|
16888
|
+
const { code: o2, config: s3 = {}, env: r2 = {}, primary: i2, next: a3 } = t2;
|
|
16751
16889
|
let c2, u4;
|
|
16752
|
-
const f2 =
|
|
16753
|
-
c2 = s3.ingest ? await
|
|
16890
|
+
const f2 = E3(a3, D3(n3.transformers)), l2 = n3.logger.scope("source").scope(e4), g2 = { push: (t3, o3 = {}) => n3.push(t3, { ...o3, id: e4, ingest: c2, respond: u4, mapping: s3, preChain: f2 }), command: n3.command, sources: n3.sources, elb: n3.sources.elb.push, logger: l2, ...r2 }, d2 = { collector: n3, logger: l2, id: e4, config: s3, env: g2, setIngest: async (e5) => {
|
|
16891
|
+
c2 = s3.ingest ? await je(e5, s3.ingest, { collector: n3 }) : void 0;
|
|
16754
16892
|
}, setRespond: (n4) => {
|
|
16755
16893
|
u4 = n4;
|
|
16756
|
-
} }, m2 = await
|
|
16894
|
+
} }, m2 = await he(o2)(d2);
|
|
16757
16895
|
if (!m2) return;
|
|
16758
|
-
const p2 = m2.type || "unknown", h2 = n3.logger.scope(p2).scope(
|
|
16759
|
-
return
|
|
16760
|
-
}
|
|
16761
|
-
async function
|
|
16762
|
-
const
|
|
16763
|
-
for (const [o2, s3] of Object.entries(
|
|
16764
|
-
const { config:
|
|
16765
|
-
if (
|
|
16896
|
+
const p2 = m2.type || "unknown", h2 = n3.logger.scope(p2).scope(e4);
|
|
16897
|
+
return g2.logger = h2, i2 && (m2.config = { ...m2.config, primary: i2 }), m2;
|
|
16898
|
+
}
|
|
16899
|
+
async function T3(n3, e4 = {}) {
|
|
16900
|
+
const t2 = {};
|
|
16901
|
+
for (const [o2, s3] of Object.entries(e4)) {
|
|
16902
|
+
const { config: e5 = {} } = s3;
|
|
16903
|
+
if (e5.require && e5.require.length > 0) {
|
|
16766
16904
|
n3.pending.sources[o2] = s3;
|
|
16767
16905
|
continue;
|
|
16768
16906
|
}
|
|
16769
|
-
const r2 = await
|
|
16770
|
-
r2 && (
|
|
16907
|
+
const r2 = await R3(n3, o2, s3);
|
|
16908
|
+
r2 && (t2[o2] = r2);
|
|
16771
16909
|
}
|
|
16772
|
-
return
|
|
16910
|
+
return t2;
|
|
16773
16911
|
}
|
|
16774
|
-
async function
|
|
16775
|
-
const o2 = n3.on, s3 = o2[
|
|
16912
|
+
async function I3(n3, e4, t2) {
|
|
16913
|
+
const o2 = n3.on, s3 = o2[e4] || [], r2 = U(t2) ? t2 : [t2];
|
|
16776
16914
|
r2.forEach((n4) => {
|
|
16777
16915
|
s3.push(n4);
|
|
16778
|
-
}), o2[
|
|
16916
|
+
}), o2[e4] = s3, await G2(n3, e4, r2);
|
|
16779
16917
|
}
|
|
16780
|
-
function
|
|
16781
|
-
if (!
|
|
16782
|
-
const r2 =
|
|
16783
|
-
|
|
16918
|
+
function B3(n3, e4, t2, o2, s3) {
|
|
16919
|
+
if (!e4.on) return;
|
|
16920
|
+
const r2 = e4.type || "unknown", i2 = n3.logger.scope(r2).scope("on").scope(o2), a3 = { collector: n3, logger: i2, id: t2, config: e4.config, data: s3, env: L3(e4.env, e4.config.env) };
|
|
16921
|
+
ve(e4.on)(o2, a3);
|
|
16784
16922
|
}
|
|
16785
|
-
async function
|
|
16923
|
+
async function G2(n3, e4, o2, s3) {
|
|
16786
16924
|
let r2, i2 = o2 || [];
|
|
16787
|
-
switch (o2 || (i2 = n3.on[
|
|
16788
|
-
case
|
|
16925
|
+
switch (o2 || (i2 = n3.on[e4] || []), e4) {
|
|
16926
|
+
case t.Commands.Consent:
|
|
16789
16927
|
r2 = s3 || n3.consent;
|
|
16790
16928
|
break;
|
|
16791
|
-
case
|
|
16929
|
+
case t.Commands.Session:
|
|
16792
16930
|
r2 = n3.session;
|
|
16793
16931
|
break;
|
|
16794
|
-
case
|
|
16932
|
+
case t.Commands.User:
|
|
16795
16933
|
r2 = s3 || n3.user;
|
|
16796
16934
|
break;
|
|
16797
|
-
case
|
|
16935
|
+
case t.Commands.Custom:
|
|
16798
16936
|
r2 = s3 || n3.custom;
|
|
16799
16937
|
break;
|
|
16800
|
-
case
|
|
16938
|
+
case t.Commands.Globals:
|
|
16801
16939
|
r2 = s3 || n3.globals;
|
|
16802
16940
|
break;
|
|
16803
|
-
case
|
|
16941
|
+
case t.Commands.Config:
|
|
16804
16942
|
r2 = s3 || n3.config;
|
|
16805
16943
|
break;
|
|
16806
|
-
case
|
|
16807
|
-
case
|
|
16944
|
+
case t.Commands.Ready:
|
|
16945
|
+
case t.Commands.Run:
|
|
16808
16946
|
default:
|
|
16809
16947
|
r2 = void 0;
|
|
16810
16948
|
}
|
|
16811
16949
|
let a3 = false;
|
|
16812
|
-
for (const
|
|
16813
|
-
false === await
|
|
16950
|
+
for (const t2 of Object.values(n3.sources)) if (t2.on) {
|
|
16951
|
+
false === await he(t2.on)(e4, r2) && (a3 = true);
|
|
16814
16952
|
}
|
|
16815
|
-
if (Object.entries(n3.destinations).forEach(([
|
|
16953
|
+
if (Object.entries(n3.destinations).forEach(([t2, o3]) => {
|
|
16816
16954
|
if (o3.on) {
|
|
16817
|
-
if (!o3.config.init) return o3.queueOn = o3.queueOn || [], void o3.queueOn.push({ type:
|
|
16818
|
-
|
|
16955
|
+
if (!o3.config.init) return o3.queueOn = o3.queueOn || [], void o3.queueOn.push({ type: e4, data: r2 });
|
|
16956
|
+
B3(n3, o3, t2, e4, r2);
|
|
16819
16957
|
}
|
|
16820
|
-
}), (Object.keys(n3.pending.sources).length > 0 || Object.keys(n3.pending.destinations).length > 0) && await (async function(n4,
|
|
16821
|
-
for (const [
|
|
16822
|
-
if (!n4.pending.sources[
|
|
16958
|
+
}), (Object.keys(n3.pending.sources).length > 0 || Object.keys(n3.pending.destinations).length > 0) && await (async function(n4, e5) {
|
|
16959
|
+
for (const [t2, o3] of Object.entries(n4.pending.sources)) {
|
|
16960
|
+
if (!n4.pending.sources[t2] || n4.sources[t2]) continue;
|
|
16823
16961
|
const s4 = o3.config?.require;
|
|
16824
16962
|
if (!s4) continue;
|
|
16825
|
-
const r3 = s4.indexOf(
|
|
16963
|
+
const r3 = s4.indexOf(e5);
|
|
16826
16964
|
if (-1 === r3) continue;
|
|
16827
16965
|
if (s4.splice(r3, 1), s4.length > 0) continue;
|
|
16828
|
-
delete n4.pending.sources[
|
|
16829
|
-
const i3 = await
|
|
16830
|
-
i3 && (n4.sources[
|
|
16966
|
+
delete n4.pending.sources[t2];
|
|
16967
|
+
const i3 = await R3(n4, t2, o3);
|
|
16968
|
+
i3 && (n4.sources[t2] = i3);
|
|
16831
16969
|
}
|
|
16832
|
-
for (const [
|
|
16833
|
-
if (!n4.pending.destinations[
|
|
16970
|
+
for (const [t2, o3] of Object.entries(n4.pending.destinations)) {
|
|
16971
|
+
if (!n4.pending.destinations[t2] || n4.destinations[t2]) continue;
|
|
16834
16972
|
const s4 = o3.config?.require;
|
|
16835
16973
|
if (!s4) continue;
|
|
16836
|
-
const r3 = s4.indexOf(
|
|
16974
|
+
const r3 = s4.indexOf(e5);
|
|
16837
16975
|
if (-1 === r3) continue;
|
|
16838
16976
|
if (s4.splice(r3, 1), s4.length > 0) continue;
|
|
16839
|
-
delete n4.pending.destinations[
|
|
16977
|
+
delete n4.pending.destinations[t2];
|
|
16840
16978
|
const i3 = W3(o3);
|
|
16841
|
-
false !== i3.config.queue && (i3.queuePush = [...n4.queue]), n4.destinations[
|
|
16842
|
-
}
|
|
16843
|
-
})(n3,
|
|
16844
|
-
switch (
|
|
16845
|
-
case
|
|
16846
|
-
!(function(n4,
|
|
16847
|
-
const o3 =
|
|
16848
|
-
|
|
16849
|
-
Object.keys(o3).filter((n5) => n5 in
|
|
16850
|
-
|
|
16979
|
+
false !== i3.config.queue && (i3.queuePush = [...n4.queue]), n4.destinations[t2] = i3;
|
|
16980
|
+
}
|
|
16981
|
+
})(n3, e4), !i2.length) return !a3;
|
|
16982
|
+
switch (e4) {
|
|
16983
|
+
case t.Commands.Consent:
|
|
16984
|
+
!(function(n4, e5, t2) {
|
|
16985
|
+
const o3 = t2 || n4.consent;
|
|
16986
|
+
e5.forEach((e6) => {
|
|
16987
|
+
Object.keys(o3).filter((n5) => n5 in e6).forEach((t3) => {
|
|
16988
|
+
ve(e6[t3])(n4, o3);
|
|
16851
16989
|
});
|
|
16852
16990
|
});
|
|
16853
16991
|
})(n3, i2, s3);
|
|
16854
16992
|
break;
|
|
16855
|
-
case
|
|
16856
|
-
case
|
|
16857
|
-
!(function(n4,
|
|
16858
|
-
n4.allowed &&
|
|
16859
|
-
|
|
16993
|
+
case t.Commands.Ready:
|
|
16994
|
+
case t.Commands.Run:
|
|
16995
|
+
!(function(n4, e5) {
|
|
16996
|
+
n4.allowed && e5.forEach((e6) => {
|
|
16997
|
+
ve(e6)(n4);
|
|
16860
16998
|
});
|
|
16861
16999
|
})(n3, i2);
|
|
16862
17000
|
break;
|
|
16863
|
-
case
|
|
16864
|
-
!(function(n4,
|
|
17001
|
+
case t.Commands.Session:
|
|
17002
|
+
!(function(n4, e5) {
|
|
16865
17003
|
if (!n4.session) return;
|
|
16866
|
-
|
|
16867
|
-
|
|
17004
|
+
e5.forEach((e6) => {
|
|
17005
|
+
ve(e6)(n4, n4.session);
|
|
16868
17006
|
});
|
|
16869
17007
|
})(n3, i2);
|
|
16870
17008
|
break;
|
|
16871
17009
|
default:
|
|
16872
|
-
i2.forEach((
|
|
16873
|
-
"function" == typeof
|
|
17010
|
+
i2.forEach((e5) => {
|
|
17011
|
+
"function" == typeof e5 && ve(e5)(n3, r2);
|
|
16874
17012
|
});
|
|
16875
17013
|
}
|
|
16876
17014
|
return !a3;
|
|
16877
17015
|
}
|
|
16878
|
-
async function
|
|
16879
|
-
const { code: o2, config: s3 = {}, env: r2 = {}, before: i2 } =
|
|
16880
|
-
if (!
|
|
16881
|
-
const a3 =
|
|
17016
|
+
async function H3(n3, e4, t2) {
|
|
17017
|
+
const { code: o2, config: s3 = {}, env: r2 = {}, before: i2 } = e4;
|
|
17018
|
+
if (!Z(o2.push)) return N3({ ok: false, failed: { invalid: { type: "invalid", error: "Destination code must have a push method" } } });
|
|
17019
|
+
const a3 = t2 || s3 || { init: false }, c2 = i2 ? { ...a3, before: i2 } : a3, u4 = { ...o2, config: c2, env: L3(o2.env, r2) };
|
|
16882
17020
|
let l2 = u4.config.id;
|
|
16883
17021
|
if (!l2) do {
|
|
16884
|
-
l2 =
|
|
17022
|
+
l2 = se(4);
|
|
16885
17023
|
} while (n3.destinations[l2]);
|
|
16886
|
-
return n3.destinations[l2] = u4, false !== u4.config.queue && (u4.queuePush = [...n3.queue]),
|
|
17024
|
+
return n3.destinations[l2] = u4, false !== u4.config.queue && (u4.queuePush = [...n3.queue]), U3(n3, void 0, {}, { [l2]: u4 });
|
|
16887
17025
|
}
|
|
16888
|
-
async function
|
|
17026
|
+
async function U3(n3, e4, t2 = {}, o2) {
|
|
16889
17027
|
const { allowed: s3, consent: r2, globals: i2, user: u4 } = n3;
|
|
16890
17028
|
if (!s3) return N3({ ok: false });
|
|
16891
|
-
|
|
17029
|
+
e4 && (n3.queue.push(e4), n3.status.in++), o2 || (o2 = n3.destinations);
|
|
16892
17030
|
const f2 = await Promise.all(Object.entries(o2 || {}).map(async ([o3, s4]) => {
|
|
16893
17031
|
let f3 = (s4.queuePush || []).map((n4) => ({ ...n4, consent: r2 }));
|
|
16894
|
-
if (s4.queuePush = [],
|
|
16895
|
-
const n4 =
|
|
17032
|
+
if (s4.queuePush = [], e4) {
|
|
17033
|
+
const n4 = Q(e4);
|
|
16896
17034
|
f3.push(n4);
|
|
16897
17035
|
}
|
|
16898
17036
|
if (!f3.length && !s4.queueOn?.length) return { id: o3, destination: s4, skipped: true };
|
|
16899
17037
|
if (!f3.length && s4.queueOn?.length) {
|
|
16900
|
-
const
|
|
16901
|
-
return { id: o3, destination: s4, skipped: !
|
|
17038
|
+
const e5 = await he(F2)(n3, s4, o3);
|
|
17039
|
+
return { id: o3, destination: s4, skipped: !e5 };
|
|
16902
17040
|
}
|
|
16903
|
-
const
|
|
16904
|
-
const
|
|
16905
|
-
return !
|
|
17041
|
+
const g3 = [], d3 = f3.filter((n4) => {
|
|
17042
|
+
const e5 = ne(s4.config.consent, r2, n4.consent);
|
|
17043
|
+
return !e5 || (n4.consent = e5, g3.push(n4), false);
|
|
16906
17044
|
});
|
|
16907
|
-
if (s4.queuePush.push(...
|
|
16908
|
-
if (!await
|
|
17045
|
+
if (s4.queuePush.push(...d3), !g3.length) return { id: o3, destination: s4, queue: f3 };
|
|
17046
|
+
if (!await he(F2)(n3, s4, o3)) return { id: o3, destination: s4, queue: f3 };
|
|
16909
17047
|
let m3, p2;
|
|
16910
17048
|
s4.dlq || (s4.dlq = []);
|
|
16911
|
-
const w2 = (function(n4,
|
|
16912
|
-
const
|
|
16913
|
-
return
|
|
17049
|
+
const w2 = (function(n4, e5) {
|
|
17050
|
+
const t3 = n4.config.before;
|
|
17051
|
+
return t3 ? E3(t3, D3(e5)) : [];
|
|
16914
17052
|
})(s4, n3.transformers);
|
|
16915
17053
|
let y2 = 0;
|
|
16916
|
-
return await Promise.all(
|
|
16917
|
-
|
|
16918
|
-
let r3 =
|
|
17054
|
+
return await Promise.all(g3.map(async (e5) => {
|
|
17055
|
+
e5.globals = I(i2, e5.globals), e5.user = I(u4, e5.user);
|
|
17056
|
+
let r3 = e5;
|
|
16919
17057
|
if (w2.length > 0 && n3.transformers && Object.keys(n3.transformers).length > 0) {
|
|
16920
|
-
const o4 = await
|
|
16921
|
-
if (null === o4) return
|
|
17058
|
+
const o4 = await S3(n3, n3.transformers, w2, e5, t2.ingest, t2.respond);
|
|
17059
|
+
if (null === o4) return e5;
|
|
16922
17060
|
r3 = o4;
|
|
16923
17061
|
}
|
|
16924
|
-
const c2 = Date.now(), f4 = await
|
|
16925
|
-
const
|
|
16926
|
-
n3.logger.scope(
|
|
16927
|
-
})(n3, s4, o3, r3,
|
|
16928
|
-
return y2 += Date.now() - c2, void 0 !== f4 && (p2 = f4),
|
|
17062
|
+
const c2 = Date.now(), f4 = await he(J2, (e6) => {
|
|
17063
|
+
const t3 = s4.type || "unknown";
|
|
17064
|
+
n3.logger.scope(t3).error("Push failed", { error: e6, event: r3.name }), m3 = e6, s4.dlq.push([r3, e6]);
|
|
17065
|
+
})(n3, s4, o3, r3, t2.ingest, t2.respond);
|
|
17066
|
+
return y2 += Date.now() - c2, void 0 !== f4 && (p2 = f4), e5;
|
|
16929
17067
|
})), { id: o3, destination: s4, error: m3, response: p2, totalDuration: y2 };
|
|
16930
|
-
})),
|
|
16931
|
-
for (const
|
|
16932
|
-
if (
|
|
16933
|
-
const
|
|
16934
|
-
n3.status.destinations[
|
|
16935
|
-
const s4 = n3.status.destinations[
|
|
16936
|
-
|
|
16937
|
-
}
|
|
16938
|
-
return N3({ event:
|
|
16939
|
-
}
|
|
16940
|
-
async function
|
|
16941
|
-
if (
|
|
16942
|
-
const o2 =
|
|
17068
|
+
})), g2 = {}, d2 = {}, m2 = {};
|
|
17069
|
+
for (const e5 of f2) {
|
|
17070
|
+
if (e5.skipped) continue;
|
|
17071
|
+
const t3 = e5.destination, o3 = { type: t3.type || "unknown", data: e5.response };
|
|
17072
|
+
n3.status.destinations[e5.id] || (n3.status.destinations[e5.id] = { count: 0, failed: 0, duration: 0 });
|
|
17073
|
+
const s4 = n3.status.destinations[e5.id], r3 = Date.now();
|
|
17074
|
+
e5.error ? (o3.error = e5.error, m2[e5.id] = o3, s4.failed++, s4.lastAt = r3, s4.duration += e5.totalDuration || 0, n3.status.failed++) : e5.queue && e5.queue.length ? (t3.queuePush = (t3.queuePush || []).concat(e5.queue), d2[e5.id] = o3) : (g2[e5.id] = o3, s4.count++, s4.lastAt = r3, s4.duration += e5.totalDuration || 0, n3.status.out++);
|
|
17075
|
+
}
|
|
17076
|
+
return N3({ event: e4, ...Object.keys(g2).length && { done: g2 }, ...Object.keys(d2).length && { queued: d2 }, ...Object.keys(m2).length && { failed: m2 } });
|
|
17077
|
+
}
|
|
17078
|
+
async function F2(n3, e4, t2) {
|
|
17079
|
+
if (e4.init && !e4.config.init) {
|
|
17080
|
+
const o2 = e4.type || "unknown", s3 = n3.logger.scope(o2), r2 = { collector: n3, logger: s3, id: t2, config: e4.config, env: L3(e4.env, e4.config.env) };
|
|
16943
17081
|
s3.debug("init");
|
|
16944
|
-
const i2 = await
|
|
17082
|
+
const i2 = await _e(e4.init, "DestinationInit", n3.hooks)(r2);
|
|
16945
17083
|
if (false === i2) return i2;
|
|
16946
|
-
if (
|
|
16947
|
-
const o3 =
|
|
16948
|
-
|
|
16949
|
-
for (const { type: s4, data: r3 } of o3)
|
|
17084
|
+
if (e4.config = { ...i2 || e4.config, init: true }, e4.queueOn?.length) {
|
|
17085
|
+
const o3 = e4.queueOn;
|
|
17086
|
+
e4.queueOn = [];
|
|
17087
|
+
for (const { type: s4, data: r3 } of o3) B3(n3, e4, t2, s4, r3);
|
|
16950
17088
|
}
|
|
16951
17089
|
s3.debug("init done");
|
|
16952
17090
|
}
|
|
16953
17091
|
return true;
|
|
16954
17092
|
}
|
|
16955
|
-
async function
|
|
16956
|
-
const { config: i2 } =
|
|
17093
|
+
async function J2(n3, e4, t2, o2, s3, r2) {
|
|
17094
|
+
const { config: i2 } = e4, a3 = await Oe(o2, i2, n3);
|
|
16957
17095
|
if (a3.ignore) return false;
|
|
16958
|
-
const c2 =
|
|
16959
|
-
if (!
|
|
17096
|
+
const c2 = e4.type || "unknown", f2 = n3.logger.scope(c2), l2 = { collector: n3, logger: f2, id: t2, config: i2, data: a3.data, rule: a3.mapping, ingest: s3, env: { ...L3(e4.env, i2.env), ...r2 ? { respond: r2 } : {} } }, d2 = a3.mapping, m2 = a3.mappingKey || "* *";
|
|
17097
|
+
if (!d2?.batch || !e4.pushBatch) {
|
|
16960
17098
|
f2.debug("push", { event: a3.event.name });
|
|
16961
|
-
const
|
|
16962
|
-
return f2.debug("push done"),
|
|
17099
|
+
const t3 = await _e(e4.push, "DestinationPush", n3.hooks)(a3.event, l2);
|
|
17100
|
+
return f2.debug("push done"), t3;
|
|
16963
17101
|
}
|
|
16964
17102
|
{
|
|
16965
|
-
if (
|
|
17103
|
+
if (e4.batches = e4.batches || {}, !e4.batches[m2]) {
|
|
16966
17104
|
const o4 = { key: m2, events: [], data: [] };
|
|
16967
|
-
|
|
16968
|
-
const o5 =
|
|
16969
|
-
f2.debug("push batch", { events: o5.events.length }),
|
|
16970
|
-
},
|
|
17105
|
+
e4.batches[m2] = { batched: o4, batchFn: ae(() => {
|
|
17106
|
+
const o5 = e4.batches[m2].batched, a4 = { collector: n3, logger: f2, id: t2, config: i2, data: void 0, rule: d2, ingest: s3, env: { ...L3(e4.env, i2.env), ...r2 ? { respond: r2 } : {} } };
|
|
17107
|
+
f2.debug("push batch", { events: o5.events.length }), _e(e4.pushBatch, "DestinationPushBatch", n3.hooks)(o5, a4), f2.debug("push batch done"), o5.events = [], o5.data = [];
|
|
17108
|
+
}, d2.batch) };
|
|
16971
17109
|
}
|
|
16972
|
-
const o3 =
|
|
16973
|
-
o3.batched.events.push(a3.event),
|
|
17110
|
+
const o3 = e4.batches[m2];
|
|
17111
|
+
o3.batched.events.push(a3.event), B(a3.data) && o3.batched.data.push(a3.data), o3.batchFn();
|
|
16974
17112
|
}
|
|
16975
17113
|
return true;
|
|
16976
17114
|
}
|
|
@@ -16978,203 +17116,210 @@ function N3(n3) {
|
|
|
16978
17116
|
return { ok: !n3?.failed, ...n3 };
|
|
16979
17117
|
}
|
|
16980
17118
|
function W3(n3) {
|
|
16981
|
-
const { code:
|
|
16982
|
-
return { ...
|
|
17119
|
+
const { code: e4, config: t2 = {}, env: o2 = {} } = n3, { config: s3 } = A3(n3, "before"), r2 = { ...e4.config, ...t2, ...s3 }, i2 = L3(e4.env, o2);
|
|
17120
|
+
return { ...e4, config: r2, env: i2 };
|
|
16983
17121
|
}
|
|
16984
|
-
async function z4(n3,
|
|
16985
|
-
const
|
|
16986
|
-
for (const [o2, s3] of Object.entries(
|
|
16987
|
-
return
|
|
17122
|
+
async function z4(n3, e4 = {}) {
|
|
17123
|
+
const t2 = {};
|
|
17124
|
+
for (const [o2, s3] of Object.entries(e4)) s3.config?.require?.length ? n3.pending.destinations[o2] = s3 : t2[o2] = W3(s3);
|
|
17125
|
+
return t2;
|
|
16988
17126
|
}
|
|
16989
|
-
function L3(n3,
|
|
16990
|
-
return n3 ||
|
|
17127
|
+
function L3(n3, e4) {
|
|
17128
|
+
return n3 || e4 ? e4 ? n3 && q(n3) && q(e4) ? { ...n3, ...e4 } : e4 : n3 : {};
|
|
16991
17129
|
}
|
|
16992
|
-
async function
|
|
17130
|
+
async function X3(n3, e4, t2) {
|
|
16993
17131
|
const o2 = Object.entries(n3).map(async ([n4, o3]) => {
|
|
16994
17132
|
const s3 = o3.destroy;
|
|
16995
17133
|
if (!s3) return;
|
|
16996
|
-
const r2 = o3.type || "unknown", i2 =
|
|
17134
|
+
const r2 = o3.type || "unknown", i2 = t2.scope(r2), a3 = { id: n4, config: o3.config, env: o3.env ?? {}, logger: i2 };
|
|
16997
17135
|
try {
|
|
16998
|
-
await Promise.race([s3(a3), new Promise((
|
|
16999
|
-
} catch (
|
|
17000
|
-
i2.error(`${
|
|
17136
|
+
await Promise.race([s3(a3), new Promise((t3, o4) => setTimeout(() => o4(new Error(`${e4} '${n4}' destroy timed out`)), 5e3))]);
|
|
17137
|
+
} catch (t3) {
|
|
17138
|
+
i2.error(`${e4} '${n4}' destroy failed: ${t3}`);
|
|
17001
17139
|
}
|
|
17002
17140
|
});
|
|
17003
17141
|
await Promise.allSettled(o2);
|
|
17004
17142
|
}
|
|
17005
|
-
async function
|
|
17143
|
+
async function Y3(n3, e4, o2, r2) {
|
|
17006
17144
|
let i2, a3, c2 = false, u4 = false;
|
|
17007
|
-
switch (
|
|
17008
|
-
case
|
|
17009
|
-
|
|
17145
|
+
switch (e4) {
|
|
17146
|
+
case t.Commands.Config:
|
|
17147
|
+
q(o2) && (I(n3.config, o2, { shallow: false }), a3 = o2, c2 = true);
|
|
17010
17148
|
break;
|
|
17011
|
-
case
|
|
17012
|
-
if (
|
|
17013
|
-
const { update:
|
|
17014
|
-
a3 =
|
|
17149
|
+
case t.Commands.Consent:
|
|
17150
|
+
if (q(o2)) {
|
|
17151
|
+
const { update: e5, runQueue: t2 } = s2(n3, o2);
|
|
17152
|
+
a3 = e5, c2 = true, u4 = t2;
|
|
17015
17153
|
}
|
|
17016
17154
|
break;
|
|
17017
|
-
case
|
|
17018
|
-
|
|
17155
|
+
case t.Commands.Custom:
|
|
17156
|
+
q(o2) && (n3.custom = I(n3.custom, o2), a3 = o2, c2 = true);
|
|
17019
17157
|
break;
|
|
17020
|
-
case
|
|
17021
|
-
|
|
17158
|
+
case t.Commands.Destination:
|
|
17159
|
+
q(o2) && ("code" in o2 && q(o2.code) ? i2 = await H3(n3, o2, r2) : Z(o2.push) && (i2 = await H3(n3, { code: o2 }, r2)));
|
|
17022
17160
|
break;
|
|
17023
|
-
case
|
|
17024
|
-
|
|
17161
|
+
case t.Commands.Globals:
|
|
17162
|
+
q(o2) && (n3.globals = I(n3.globals, o2), a3 = o2, c2 = true);
|
|
17025
17163
|
break;
|
|
17026
|
-
case
|
|
17027
|
-
|
|
17164
|
+
case t.Commands.On:
|
|
17165
|
+
X(o2) && await I3(n3, o2, r2);
|
|
17028
17166
|
break;
|
|
17029
|
-
case
|
|
17167
|
+
case t.Commands.Ready:
|
|
17030
17168
|
c2 = true;
|
|
17031
17169
|
break;
|
|
17032
|
-
case
|
|
17033
|
-
i2 = await
|
|
17170
|
+
case t.Commands.Run:
|
|
17171
|
+
i2 = await nn2(n3, o2), c2 = true;
|
|
17034
17172
|
break;
|
|
17035
|
-
case
|
|
17173
|
+
case t.Commands.Session:
|
|
17036
17174
|
c2 = true;
|
|
17037
17175
|
break;
|
|
17038
|
-
case
|
|
17176
|
+
case t.Commands.Shutdown:
|
|
17039
17177
|
await (async function(n4) {
|
|
17040
|
-
const
|
|
17041
|
-
await
|
|
17178
|
+
const e5 = n4.logger;
|
|
17179
|
+
await X3(n4.sources, "source", e5), await X3(n4.destinations, "destination", e5), await X3(n4.transformers, "transformer", e5), await X3(n4.stores, "store", e5);
|
|
17042
17180
|
})(n3);
|
|
17043
17181
|
break;
|
|
17044
|
-
case
|
|
17045
|
-
|
|
17182
|
+
case t.Commands.User:
|
|
17183
|
+
q(o2) && (I(n3.user, o2, { shallow: false }), a3 = o2, c2 = true);
|
|
17046
17184
|
}
|
|
17047
|
-
return c2 && await
|
|
17185
|
+
return c2 && await G2(n3, e4, void 0, a3), u4 && (i2 = await U3(n3)), i2 || N3({ ok: true });
|
|
17048
17186
|
}
|
|
17049
|
-
function
|
|
17050
|
-
if (!
|
|
17051
|
-
const [
|
|
17052
|
-
if (!
|
|
17187
|
+
function Z3(n3, e4) {
|
|
17188
|
+
if (!e4.name) throw new Error("Event name is required");
|
|
17189
|
+
const [t2, o2] = e4.name.split(" ");
|
|
17190
|
+
if (!t2 || !o2) throw new Error("Event name is invalid");
|
|
17053
17191
|
++n3.count;
|
|
17054
|
-
const { timestamp: s3 = Date.now(), group: r2 = n3.group, count: i2 = n3.count } =
|
|
17055
|
-
return { name: a3, data: c2, context: u4, globals: f2, custom: l2, user:
|
|
17192
|
+
const { timestamp: s3 = Date.now(), group: r2 = n3.group, count: i2 = n3.count } = e4, { name: a3 = `${t2} ${o2}`, data: c2 = {}, context: u4 = {}, globals: f2 = n3.globals, custom: l2 = {}, user: g2 = n3.user, nested: d2 = [], consent: m2 = n3.consent, id: p2 = `${s3}-${r2}-${i2}`, trigger: h2 = "", entity: w2 = t2, action: y2 = o2, timing: b2 = 0, version: v2 = { source: n3.version, tagging: n3.config.tagging || 0 }, source: k2 = { type: "collector", id: "", previous_id: "" } } = e4;
|
|
17193
|
+
return { name: a3, data: c2, context: u4, globals: f2, custom: l2, user: g2, nested: d2, consent: m2, id: p2, trigger: h2, entity: w2, action: y2, timestamp: s3, timing: b2, group: r2, count: i2, version: v2, source: k2 };
|
|
17056
17194
|
}
|
|
17057
|
-
async function
|
|
17058
|
-
n3.allowed = true, n3.count = 0, n3.group =
|
|
17195
|
+
async function nn2(n3, e4) {
|
|
17196
|
+
n3.allowed = true, n3.count = 0, n3.group = se(), n3.timing = Date.now(), e4 && (e4.consent && (n3.consent = I(n3.consent, e4.consent)), e4.user && (n3.user = I(n3.user, e4.user)), e4.globals && (n3.globals = I(n3.config.globalsStatic || {}, e4.globals)), e4.custom && (n3.custom = I(n3.custom, e4.custom))), Object.values(n3.destinations).forEach((n4) => {
|
|
17059
17197
|
n4.queuePush = [];
|
|
17060
17198
|
}), n3.queue = [], n3.round++;
|
|
17061
|
-
return await
|
|
17199
|
+
return await U3(n3);
|
|
17062
17200
|
}
|
|
17063
|
-
function
|
|
17064
|
-
return
|
|
17201
|
+
function rn2(n3, e4) {
|
|
17202
|
+
return _e(async (t2, o2 = {}) => await he(async () => {
|
|
17065
17203
|
const s3 = Date.now(), { id: r2, ingest: i2, respond: a3, mapping: c2, preChain: u4 } = o2;
|
|
17066
|
-
let f2 =
|
|
17204
|
+
let f2 = t2;
|
|
17067
17205
|
const l2 = i2 ? Object.freeze(i2) : void 0;
|
|
17068
17206
|
if (c2) {
|
|
17069
|
-
const
|
|
17070
|
-
if (
|
|
17207
|
+
const e5 = await Oe(f2, c2, n3);
|
|
17208
|
+
if (e5.ignore) return N3({ ok: true });
|
|
17071
17209
|
if (c2.consent) {
|
|
17072
|
-
if (!
|
|
17210
|
+
if (!ne(c2.consent, n3.consent, e5.event.consent)) return N3({ ok: true });
|
|
17073
17211
|
}
|
|
17074
|
-
f2 =
|
|
17212
|
+
f2 = e5.event;
|
|
17075
17213
|
}
|
|
17076
17214
|
if (u4?.length && n3.transformers && Object.keys(n3.transformers).length > 0) {
|
|
17077
|
-
const
|
|
17078
|
-
if (null ===
|
|
17079
|
-
f2 =
|
|
17215
|
+
const e5 = await S3(n3, n3.transformers, u4, f2, l2, a3);
|
|
17216
|
+
if (null === e5) return N3({ ok: true });
|
|
17217
|
+
f2 = e5;
|
|
17080
17218
|
}
|
|
17081
|
-
const
|
|
17219
|
+
const g2 = e4(f2), d2 = Z3(n3, g2), m2 = await U3(n3, d2, { id: r2, ingest: l2, respond: a3 });
|
|
17082
17220
|
if (r2) {
|
|
17083
17221
|
n3.status.sources[r2] || (n3.status.sources[r2] = { count: 0, duration: 0 });
|
|
17084
|
-
const
|
|
17085
|
-
|
|
17222
|
+
const e5 = n3.status.sources[r2];
|
|
17223
|
+
e5.count++, e5.lastAt = Date.now(), e5.duration += Date.now() - s3;
|
|
17086
17224
|
}
|
|
17087
17225
|
return m2;
|
|
17088
17226
|
}, () => N3({ ok: false }))(), "Push", n3.hooks);
|
|
17089
17227
|
}
|
|
17090
|
-
async function
|
|
17091
|
-
const
|
|
17092
|
-
return a3.push =
|
|
17093
|
-
return
|
|
17094
|
-
})(a3,
|
|
17095
|
-
const
|
|
17096
|
-
for (const [o3, s4] of Object.entries(
|
|
17097
|
-
const { code:
|
|
17098
|
-
|
|
17099
|
-
}
|
|
17100
|
-
return
|
|
17228
|
+
async function un2(n3) {
|
|
17229
|
+
const e4 = I({ globalsStatic: {}, sessionStatic: {}, tagging: 0, run: true }, n3, { merge: false, extend: false }), t2 = { level: n3.logger?.level, handler: n3.logger?.handler }, o2 = de(t2), s3 = { ...e4.globalsStatic, ...n3.globals }, a3 = { allowed: false, config: e4, consent: n3.consent || {}, count: 0, custom: n3.custom || {}, destinations: {}, transformers: {}, stores: {}, globals: s3, group: "", hooks: {}, logger: o2, on: {}, queue: [], round: 0, session: void 0, status: { startedAt: Date.now(), in: 0, out: 0, failed: 0, sources: {}, destinations: {} }, timing: Date.now(), user: n3.user || {}, version: "2.1.1", sources: {}, pending: { sources: {}, destinations: {} }, push: void 0, command: void 0 };
|
|
17230
|
+
return a3.push = rn2(a3, (n4) => ({ timing: Math.round((Date.now() - a3.timing) / 10) / 100, source: { type: "collector", id: "", previous_id: "" }, ...n4 })), a3.command = (function(n4, e5) {
|
|
17231
|
+
return _e(async (t3, o3, s4) => await he(async () => await e5(n4, t3, o3, s4), () => N3({ ok: false }))(), "Command", n4.hooks);
|
|
17232
|
+
})(a3, Y3), a3.stores = await (async function(n4, e5 = {}) {
|
|
17233
|
+
const t3 = {};
|
|
17234
|
+
for (const [o3, s4] of Object.entries(e5)) {
|
|
17235
|
+
const { code: e6, config: r2 = {}, env: i2 = {} } = s4, a4 = n4.logger.scope("store").scope(o3), c2 = { collector: n4, logger: a4, id: o3, config: r2, env: i2 }, u4 = await e6(c2);
|
|
17236
|
+
t3[o3] = u4;
|
|
17237
|
+
}
|
|
17238
|
+
return t3;
|
|
17239
|
+
})(a3, n3.stores || {}), a3.destinations = await z4(a3, n3.destinations || {}), a3.transformers = await (async function(n4, e5 = {}) {
|
|
17240
|
+
const t3 = {};
|
|
17241
|
+
for (const [o3, s4] of Object.entries(e5)) {
|
|
17242
|
+
const { code: e6, env: r2 = {} } = s4, { config: i2 } = A3(s4, "next"), a4 = n4.logger.scope("transformer").scope(o3), c2 = { collector: n4, logger: a4, id: o3, config: i2, env: r2 }, u4 = await e6(c2);
|
|
17243
|
+
t3[o3] = u4;
|
|
17244
|
+
}
|
|
17245
|
+
return t3;
|
|
17101
17246
|
})(a3, n3.transformers || {}), a3;
|
|
17102
17247
|
}
|
|
17103
|
-
async function
|
|
17248
|
+
async function fn2(n3) {
|
|
17104
17249
|
n3 = n3 || {};
|
|
17105
|
-
const
|
|
17250
|
+
const e4 = await un2(n3), t2 = (o2 = e4, { type: "elb", config: {}, push: async (n4, e5, t3, s4, r3, i3) => {
|
|
17106
17251
|
if ("string" == typeof n4 && n4.startsWith("walker ")) {
|
|
17107
17252
|
const s5 = n4.replace("walker ", "");
|
|
17108
|
-
return o2.command(s5,
|
|
17253
|
+
return o2.command(s5, e5, t3);
|
|
17109
17254
|
}
|
|
17110
17255
|
let a4;
|
|
17111
|
-
if ("string" == typeof n4) a4 = { name: n4 },
|
|
17256
|
+
if ("string" == typeof n4) a4 = { name: n4 }, e5 && "object" == typeof e5 && !Array.isArray(e5) && (a4.data = e5);
|
|
17112
17257
|
else {
|
|
17113
17258
|
if (!n4 || "object" != typeof n4) return N3({ ok: false });
|
|
17114
|
-
a4 = n4,
|
|
17259
|
+
a4 = n4, e5 && "object" == typeof e5 && !Array.isArray(e5) && (a4.data = { ...a4.data || {}, ...e5 });
|
|
17115
17260
|
}
|
|
17116
17261
|
return s4 && "object" == typeof s4 && (a4.context = s4), r3 && Array.isArray(r3) && (a4.nested = r3), i3 && "object" == typeof i3 && (a4.custom = i3), o2.push(a4);
|
|
17117
17262
|
} });
|
|
17118
17263
|
var o2;
|
|
17119
|
-
|
|
17120
|
-
const s3 = await
|
|
17121
|
-
Object.assign(
|
|
17264
|
+
e4.sources.elb = t2;
|
|
17265
|
+
const s3 = await T3(e4, n3.sources || {});
|
|
17266
|
+
Object.assign(e4.sources, s3);
|
|
17122
17267
|
const { consent: r2, user: i2, globals: a3, custom: c2 } = n3;
|
|
17123
|
-
r2 && await
|
|
17124
|
-
let u4 =
|
|
17125
|
-
const f2 = Object.values(
|
|
17126
|
-
return l2 ? u4 = l2.push : f2.length > 0 && (u4 = f2[0].push), { collector:
|
|
17268
|
+
r2 && await e4.command("consent", r2), i2 && await e4.command("user", i2), a3 && Object.assign(e4.globals, a3), c2 && Object.assign(e4.custom, c2), e4.config.run && await e4.command("run");
|
|
17269
|
+
let u4 = t2.push;
|
|
17270
|
+
const f2 = Object.values(e4.sources).filter((n4) => "elb" !== n4.type), l2 = f2.find((n4) => n4.config.primary);
|
|
17271
|
+
return l2 ? u4 = l2.push : f2.length > 0 && (u4 = f2[0].push), { collector: e4, elb: u4 };
|
|
17127
17272
|
}
|
|
17128
|
-
function
|
|
17273
|
+
function ln2(n3) {
|
|
17129
17274
|
if (null === n3 || "object" != typeof n3) return n3;
|
|
17130
|
-
if (Array.isArray(n3)) return n3.map(
|
|
17131
|
-
const
|
|
17132
|
-
for (const [
|
|
17133
|
-
return
|
|
17275
|
+
if (Array.isArray(n3)) return n3.map(ln2);
|
|
17276
|
+
const e4 = {};
|
|
17277
|
+
for (const [t2, o2] of Object.entries(n3)) e4[t2] = "function" == typeof o2 ? o2 : ln2(o2);
|
|
17278
|
+
return e4;
|
|
17134
17279
|
}
|
|
17135
17280
|
function gn2(n3) {
|
|
17136
|
-
const
|
|
17137
|
-
for (const n4 of
|
|
17138
|
-
const
|
|
17281
|
+
const e4 = [], { simulation: t2, ...o2 } = n3, s3 = ln2(o2);
|
|
17282
|
+
for (const n4 of t2) {
|
|
17283
|
+
const t3 = n4.startsWith("call:") ? n4.slice(5) : n4, o3 = t3.split(".");
|
|
17139
17284
|
let r2 = s3;
|
|
17140
17285
|
for (let n5 = 0; n5 < o3.length - 1 && null != r2[o3[n5]]; n5++) r2 = r2[o3[n5]];
|
|
17141
17286
|
const i2 = o3[o3.length - 1];
|
|
17142
17287
|
if (null == r2 || !(i2 in r2)) continue;
|
|
17143
17288
|
const a3 = r2[i2];
|
|
17144
17289
|
"function" == typeof a3 && (r2[i2] = function(...n5) {
|
|
17145
|
-
return
|
|
17290
|
+
return e4.push({ fn: t3, args: n5, ts: Date.now() }), a3.apply(this, n5);
|
|
17146
17291
|
});
|
|
17147
17292
|
}
|
|
17148
|
-
return { wrappedEnv: s3, calls:
|
|
17293
|
+
return { wrappedEnv: s3, calls: e4 };
|
|
17149
17294
|
}
|
|
17150
|
-
async function
|
|
17151
|
-
const
|
|
17295
|
+
async function dn2(n3) {
|
|
17296
|
+
const e4 = Date.now();
|
|
17152
17297
|
try {
|
|
17153
17298
|
switch (n3.step) {
|
|
17154
17299
|
case "transformer":
|
|
17155
|
-
return await (async function(n4,
|
|
17156
|
-
const { code:
|
|
17300
|
+
return await (async function(n4, e5) {
|
|
17301
|
+
const { code: t2, config: o2 = {}, event: s3 } = n4, { collector: r2 } = await fn2({ transformers: { sim: { code: t2, config: o2 } } }), i2 = r2.transformers?.sim;
|
|
17157
17302
|
if (!i2) throw new Error("Transformer failed to initialize");
|
|
17158
17303
|
const a3 = await i2.push(s3, { collector: r2, logger: r2.logger.scope("transformer").scope("sim"), id: "sim", config: i2.config, env: i2.config?.env || {} });
|
|
17159
17304
|
let c2;
|
|
17160
|
-
c2 = false === a3 ? [] : null == a3 ? [s3] : [a3];
|
|
17161
|
-
return { step: "transformer", name: n4.name, events: c2, calls: [], duration: Date.now() -
|
|
17162
|
-
})(n3,
|
|
17305
|
+
c2 = false === a3 ? [] : null == a3 ? [s3] : [a3.event || s3];
|
|
17306
|
+
return { step: "transformer", name: n4.name, events: c2, calls: [], duration: Date.now() - e5 };
|
|
17307
|
+
})(n3, e4);
|
|
17163
17308
|
case "source":
|
|
17164
|
-
return await (async function(n4,
|
|
17165
|
-
const { code:
|
|
17309
|
+
return await (async function(n4, e5) {
|
|
17310
|
+
const { code: t2, config: o2 = {}, setup: s3, input: r2, env: i2, consent: a3 } = n4, c2 = { functional: true, marketing: true, analytics: true };
|
|
17166
17311
|
let u4;
|
|
17167
17312
|
if (s3) {
|
|
17168
17313
|
const n5 = s3(r2, i2);
|
|
17169
17314
|
"function" == typeof n5 && (u4 = n5);
|
|
17170
17315
|
}
|
|
17171
|
-
const f2 = [], { collector: l2 } = await
|
|
17316
|
+
const f2 = [], { collector: l2 } = await fn2({ consent: a3 || c2, sources: { sim: { code: t2, config: o2, env: i2, next: "spy" } }, transformers: { spy: { code: () => ({ type: "spy", config: {}, push: (n5) => (f2.push(JSON.parse(JSON.stringify(n5))), { event: n5 }) }) } } });
|
|
17172
17317
|
u4 && u4();
|
|
17173
|
-
return { step: "source", name: n4.name, events: f2, calls: [], duration: Date.now() -
|
|
17174
|
-
})(n3,
|
|
17318
|
+
return { step: "source", name: n4.name, events: f2, calls: [], duration: Date.now() - e5 };
|
|
17319
|
+
})(n3, e4);
|
|
17175
17320
|
case "destination":
|
|
17176
|
-
return await (async function(n4,
|
|
17177
|
-
const { code:
|
|
17321
|
+
return await (async function(n4, e5) {
|
|
17322
|
+
const { code: t2, config: o2 = {}, event: s3, consent: r2, env: i2, track: a3 } = n4, c2 = { functional: true, marketing: true, analytics: true };
|
|
17178
17323
|
let u4 = [], f2 = i2;
|
|
17179
17324
|
if (i2 && a3 && a3.length > 0) {
|
|
17180
17325
|
const n5 = gn2({ ...i2, simulation: a3 });
|
|
@@ -17182,12 +17327,12 @@ async function mn2(n3) {
|
|
|
17182
17327
|
}
|
|
17183
17328
|
const l2 = { ...o2 };
|
|
17184
17329
|
f2 && (l2.env = f2);
|
|
17185
|
-
const { collector:
|
|
17186
|
-
return await
|
|
17187
|
-
})(n3,
|
|
17330
|
+
const { collector: g2 } = await fn2({ consent: r2 || c2, destinations: { sim: { code: t2, config: l2 } } });
|
|
17331
|
+
return await g2.push(s3), { step: "destination", name: n4.name, events: [], calls: u4, duration: Date.now() - e5 };
|
|
17332
|
+
})(n3, e4);
|
|
17188
17333
|
}
|
|
17189
|
-
} catch (
|
|
17190
|
-
return { step: n3.step, name: n3.name, events: [], calls: [], duration: Date.now() -
|
|
17334
|
+
} catch (t2) {
|
|
17335
|
+
return { step: n3.step, name: n3.name, events: [], calls: [], duration: Date.now() - e4, error: t2 instanceof Error ? t2 : new Error(String(t2)) };
|
|
17191
17336
|
}
|
|
17192
17337
|
}
|
|
17193
17338
|
|
|
@@ -17223,21 +17368,6 @@ async function loadDestinationEnvs(destinations) {
|
|
|
17223
17368
|
}
|
|
17224
17369
|
|
|
17225
17370
|
// src/commands/simulate/simulator.ts
|
|
17226
|
-
function createCollectorLoggerConfigInline(logger2, verbose) {
|
|
17227
|
-
return {
|
|
17228
|
-
level: verbose ? u.DEBUG : u.ERROR,
|
|
17229
|
-
handler: (level, message, context, scope) => {
|
|
17230
|
-
const scopePath = scope.length > 0 ? `[${scope.join(":")}] ` : "";
|
|
17231
|
-
const hasContext = Object.keys(context).length > 0;
|
|
17232
|
-
const contextStr = hasContext ? ` ${JSON.stringify(context)}` : "";
|
|
17233
|
-
if (level === u.ERROR) {
|
|
17234
|
-
logger2.error(`${scopePath}${message}${contextStr}`);
|
|
17235
|
-
} else {
|
|
17236
|
-
logger2.debug(`${scopePath}${message}${contextStr}`);
|
|
17237
|
-
}
|
|
17238
|
-
}
|
|
17239
|
-
};
|
|
17240
|
-
}
|
|
17241
17371
|
function callsToUsage(destName, calls) {
|
|
17242
17372
|
if (!calls.length) return {};
|
|
17243
17373
|
return {
|
|
@@ -17260,7 +17390,6 @@ async function simulateCore(inputPath, event, options = {}) {
|
|
|
17260
17390
|
const result = await executeSimulation(event, inputPath, options.platform, {
|
|
17261
17391
|
flow: options.flow,
|
|
17262
17392
|
step: options.step,
|
|
17263
|
-
logger: logger2,
|
|
17264
17393
|
verbose: options.verbose
|
|
17265
17394
|
});
|
|
17266
17395
|
return result;
|
|
@@ -17315,9 +17444,8 @@ function formatSimulationResult(result, options = {}) {
|
|
|
17315
17444
|
async function executeSimulation(event, inputPath, platformOverride, options = {}) {
|
|
17316
17445
|
const startTime = Date.now();
|
|
17317
17446
|
const tempDir = getTmpPath();
|
|
17318
|
-
const collectorLoggerConfig = options.logger ? createCollectorLoggerConfigInline(options.logger, options.verbose) : void 0;
|
|
17319
17447
|
try {
|
|
17320
|
-
await
|
|
17448
|
+
await fs12.ensureDir(tempDir);
|
|
17321
17449
|
const detected = await detectInput(inputPath, platformOverride);
|
|
17322
17450
|
if (!isObject2(event) || !("name" in event) || typeof event.name !== "string") {
|
|
17323
17451
|
throw new Error(
|
|
@@ -17336,7 +17464,6 @@ async function executeSimulation(event, inputPath, platformOverride, options = {
|
|
|
17336
17464
|
typedEvent,
|
|
17337
17465
|
tempDir,
|
|
17338
17466
|
startTime,
|
|
17339
|
-
collectorLoggerConfig,
|
|
17340
17467
|
options.flow,
|
|
17341
17468
|
options.step
|
|
17342
17469
|
);
|
|
@@ -17349,7 +17476,7 @@ async function executeSimulation(event, inputPath, platformOverride, options = {
|
|
|
17349
17476
|
};
|
|
17350
17477
|
} finally {
|
|
17351
17478
|
if (tempDir) {
|
|
17352
|
-
await
|
|
17479
|
+
await fs12.remove(tempDir).catch(() => {
|
|
17353
17480
|
});
|
|
17354
17481
|
}
|
|
17355
17482
|
}
|
|
@@ -17378,7 +17505,7 @@ function parseStepTarget(stepTarget, flowConfig) {
|
|
|
17378
17505
|
}
|
|
17379
17506
|
throw new Error("No destination found in flow config");
|
|
17380
17507
|
}
|
|
17381
|
-
async function executeConfigSimulation(_content, configPath, typedEvent, tempDir, startTime,
|
|
17508
|
+
async function executeConfigSimulation(_content, configPath, typedEvent, tempDir, startTime, flowName, stepTarget) {
|
|
17382
17509
|
const { flowConfig } = await loadFlowConfig(configPath, {
|
|
17383
17510
|
flowName
|
|
17384
17511
|
});
|
|
@@ -17396,7 +17523,7 @@ async function executeConfigSimulation(_content, configPath, typedEvent, tempDir
|
|
|
17396
17523
|
const destinations = flowConfig.destinations;
|
|
17397
17524
|
const envs = await loadDestinationEnvs(destinations || {});
|
|
17398
17525
|
const destEnv = envs[step.name];
|
|
17399
|
-
const result = await
|
|
17526
|
+
const result = await dn2({
|
|
17400
17527
|
step: "destination",
|
|
17401
17528
|
name: step.name,
|
|
17402
17529
|
code,
|
|
@@ -17421,7 +17548,7 @@ async function executeConfigSimulation(_content, configPath, typedEvent, tempDir
|
|
|
17421
17548
|
}
|
|
17422
17549
|
const mod = await import(packageName);
|
|
17423
17550
|
const code = mod.default || Object.values(mod)[0];
|
|
17424
|
-
const result = await
|
|
17551
|
+
const result = await dn2({
|
|
17425
17552
|
step: "transformer",
|
|
17426
17553
|
name: step.name,
|
|
17427
17554
|
code,
|
|
@@ -17493,7 +17620,7 @@ async function simulateSourceCLI(flowConfig, setupInput, options) {
|
|
|
17493
17620
|
document: dom.window.document,
|
|
17494
17621
|
localStorage: dom.window.localStorage
|
|
17495
17622
|
};
|
|
17496
|
-
const result = await
|
|
17623
|
+
const result = await dn2({
|
|
17497
17624
|
step: "source",
|
|
17498
17625
|
name: options.sourceStep,
|
|
17499
17626
|
code,
|
|
@@ -17631,129 +17758,33 @@ async function simulateCommand(options) {
|
|
|
17631
17758
|
let config2;
|
|
17632
17759
|
if (isStdinPiped() && !options.config) {
|
|
17633
17760
|
const stdinContent = await readStdin();
|
|
17634
|
-
const
|
|
17635
|
-
const
|
|
17761
|
+
const fs16 = await import("fs-extra");
|
|
17762
|
+
const path15 = await import("path");
|
|
17636
17763
|
const tmpPath = getTmpPath(void 0, "stdin-simulate.json");
|
|
17637
|
-
await
|
|
17638
|
-
await
|
|
17764
|
+
await fs16.default.ensureDir(path15.default.dirname(tmpPath));
|
|
17765
|
+
await fs16.default.writeFile(tmpPath, stdinContent, "utf-8");
|
|
17639
17766
|
config2 = tmpPath;
|
|
17640
17767
|
} else {
|
|
17641
17768
|
config2 = options.config || "bundle.config.json";
|
|
17642
17769
|
}
|
|
17643
|
-
|
|
17644
|
-
|
|
17645
|
-
|
|
17646
|
-
|
|
17647
|
-
|
|
17648
|
-
|
|
17649
|
-
|
|
17650
|
-
|
|
17651
|
-
|
|
17652
|
-
flowName = flowNames[0];
|
|
17653
|
-
} else {
|
|
17654
|
-
throw new Error(
|
|
17655
|
-
`Multiple flows found. Use --flow to specify which flow contains the example.
|
|
17656
|
-
Available flows: ${flowNames.join(", ")}`
|
|
17657
|
-
);
|
|
17658
|
-
}
|
|
17659
|
-
}
|
|
17660
|
-
const flowConfig = setup.flows[flowName];
|
|
17661
|
-
if (!flowConfig) {
|
|
17662
|
-
throw new Error(
|
|
17663
|
-
`Flow "${flowName}" not found. Available: ${flowNames.join(", ")}`
|
|
17664
|
-
);
|
|
17665
|
-
}
|
|
17666
|
-
const found = findExample(flowConfig, options.example, options.step);
|
|
17667
|
-
if (found.example.in === void 0) {
|
|
17668
|
-
throw new Error(
|
|
17669
|
-
`Example "${options.example}" in ${found.stepType}.${found.stepName} has no "in" value`
|
|
17670
|
-
);
|
|
17671
|
-
}
|
|
17672
|
-
event = found.example.in;
|
|
17673
|
-
exampleContext = {
|
|
17674
|
-
stepType: found.stepType,
|
|
17675
|
-
stepName: found.stepName,
|
|
17676
|
-
expected: found.example.out
|
|
17677
|
-
};
|
|
17678
|
-
} else {
|
|
17679
|
-
event = await loadJsonFromSource(options.event, {
|
|
17680
|
-
name: "event"
|
|
17681
|
-
});
|
|
17682
|
-
}
|
|
17683
|
-
const isSourceSimulation = exampleContext?.stepType === "source" || options.step?.startsWith("source.");
|
|
17684
|
-
let result;
|
|
17685
|
-
if (isSourceSimulation) {
|
|
17686
|
-
const rawConfig = await loadJsonConfig(config2);
|
|
17687
|
-
const setup = validateFlowSetup(rawConfig);
|
|
17688
|
-
const flowNames = Object.keys(setup.flows);
|
|
17689
|
-
const flowName = options.flow || (flowNames.length === 1 ? flowNames[0] : void 0);
|
|
17690
|
-
if (!flowName) {
|
|
17691
|
-
throw new Error(
|
|
17692
|
-
`Multiple flows found. Use --flow to specify which flow.
|
|
17693
|
-
Available: ${flowNames.join(", ")}`
|
|
17694
|
-
);
|
|
17695
|
-
}
|
|
17696
|
-
const flowConfig = setup.flows[flowName];
|
|
17697
|
-
if (!flowConfig) {
|
|
17698
|
-
throw new Error(
|
|
17699
|
-
`Flow "${flowName}" not found. Available: ${flowNames.join(", ")}`
|
|
17700
|
-
);
|
|
17701
|
-
}
|
|
17702
|
-
const sourceStep = exampleContext?.stepName || options.step.substring("source.".length);
|
|
17703
|
-
result = await simulateSourceCLI(
|
|
17704
|
-
flowConfig,
|
|
17705
|
-
event,
|
|
17706
|
-
{
|
|
17707
|
-
flow: options.flow,
|
|
17708
|
-
sourceStep,
|
|
17709
|
-
json: options.json,
|
|
17710
|
-
verbose: options.verbose,
|
|
17711
|
-
silent: options.silent
|
|
17712
|
-
}
|
|
17713
|
-
);
|
|
17714
|
-
} else {
|
|
17715
|
-
const stepTarget = exampleContext ? `${exampleContext.stepType}.${exampleContext.stepName}` : options.step;
|
|
17716
|
-
result = await simulateCore(config2, event, {
|
|
17717
|
-
flow: options.flow,
|
|
17718
|
-
json: options.json,
|
|
17719
|
-
verbose: options.verbose,
|
|
17720
|
-
silent: options.silent,
|
|
17721
|
-
step: stepTarget
|
|
17722
|
-
});
|
|
17723
|
-
}
|
|
17724
|
-
let exampleMatch;
|
|
17725
|
-
if (exampleContext && result.success) {
|
|
17726
|
-
const stepKey = `${exampleContext.stepType}.${exampleContext.stepName}`;
|
|
17727
|
-
if (exampleContext.expected === false) {
|
|
17728
|
-
const calls = result.usage?.[exampleContext.stepName];
|
|
17729
|
-
const wasFiltered = !calls || calls.length === 0;
|
|
17730
|
-
exampleMatch = {
|
|
17731
|
-
name: options.example,
|
|
17732
|
-
step: stepKey,
|
|
17733
|
-
expected: false,
|
|
17734
|
-
actual: wasFiltered ? false : calls,
|
|
17735
|
-
match: wasFiltered,
|
|
17736
|
-
diff: wasFiltered ? void 0 : `Expected event to be filtered, but ${calls.length} API call(s) were made`
|
|
17737
|
-
};
|
|
17738
|
-
} else if (exampleContext.expected !== void 0) {
|
|
17739
|
-
const actual = result.usage?.[exampleContext.stepName] ?? [];
|
|
17740
|
-
exampleMatch = {
|
|
17741
|
-
name: options.example,
|
|
17742
|
-
step: stepKey,
|
|
17743
|
-
...compareOutput(exampleContext.expected, actual)
|
|
17744
|
-
};
|
|
17745
|
-
}
|
|
17746
|
-
}
|
|
17770
|
+
const result = await simulate(config2, options.event, {
|
|
17771
|
+
flow: options.flow,
|
|
17772
|
+
json: options.json,
|
|
17773
|
+
verbose: options.verbose,
|
|
17774
|
+
silent: options.silent,
|
|
17775
|
+
platform: options.platform,
|
|
17776
|
+
example: options.example,
|
|
17777
|
+
step: options.step
|
|
17778
|
+
});
|
|
17747
17779
|
const resultWithDuration = {
|
|
17748
17780
|
...result,
|
|
17749
|
-
duration: (Date.now() - startTime) / 1e3
|
|
17750
|
-
...exampleMatch ? { exampleMatch } : {}
|
|
17781
|
+
duration: (Date.now() - startTime) / 1e3
|
|
17751
17782
|
};
|
|
17752
17783
|
const formatted = formatSimulationResult(resultWithDuration, {
|
|
17753
17784
|
json: options.json
|
|
17754
17785
|
});
|
|
17755
17786
|
await writeResult(formatted + "\n", { output: options.output });
|
|
17756
|
-
const exitCode = !result.success || exampleMatch && !exampleMatch.match ? 1 : 0;
|
|
17787
|
+
const exitCode = !result.success || result.exampleMatch && !result.exampleMatch.match ? 1 : 0;
|
|
17757
17788
|
process.exit(exitCode);
|
|
17758
17789
|
} catch (error48) {
|
|
17759
17790
|
const errorMessage = getErrorMessage(error48);
|
|
@@ -17774,29 +17805,125 @@ Available: ${flowNames.join(", ")}`
|
|
|
17774
17805
|
process.exit(1);
|
|
17775
17806
|
}
|
|
17776
17807
|
}
|
|
17808
|
+
async function simulate(configOrPath, event, options = {}) {
|
|
17809
|
+
if (typeof configOrPath !== "string") {
|
|
17810
|
+
throw new Error(
|
|
17811
|
+
"simulate() currently only supports config file paths. Config object support will be added in a future version. Please provide a path to a configuration file."
|
|
17812
|
+
);
|
|
17813
|
+
}
|
|
17814
|
+
let resolvedEvent = event;
|
|
17815
|
+
if (typeof event === "string") {
|
|
17816
|
+
resolvedEvent = await loadJsonFromSource(event, { name: "event" });
|
|
17817
|
+
}
|
|
17818
|
+
let exampleContext;
|
|
17819
|
+
if (options.example) {
|
|
17820
|
+
const rawConfig = await loadJsonConfig(configOrPath);
|
|
17821
|
+
const setup = validateFlowSetup(rawConfig);
|
|
17822
|
+
const flowNames = Object.keys(setup.flows);
|
|
17823
|
+
let flowName = options.flow;
|
|
17824
|
+
if (!flowName) {
|
|
17825
|
+
if (flowNames.length === 1) {
|
|
17826
|
+
flowName = flowNames[0];
|
|
17827
|
+
} else {
|
|
17828
|
+
throw new Error(
|
|
17829
|
+
`Multiple flows found. Use --flow to specify which flow contains the example.
|
|
17830
|
+
Available flows: ${flowNames.join(", ")}`
|
|
17831
|
+
);
|
|
17832
|
+
}
|
|
17833
|
+
}
|
|
17834
|
+
const flowConfig = setup.flows[flowName];
|
|
17835
|
+
if (!flowConfig) {
|
|
17836
|
+
throw new Error(
|
|
17837
|
+
`Flow "${flowName}" not found. Available: ${flowNames.join(", ")}`
|
|
17838
|
+
);
|
|
17839
|
+
}
|
|
17840
|
+
const found = findExample(flowConfig, options.example, options.step);
|
|
17841
|
+
if (found.example.in === void 0) {
|
|
17842
|
+
throw new Error(
|
|
17843
|
+
`Example "${options.example}" in ${found.stepType}.${found.stepName} has no "in" value`
|
|
17844
|
+
);
|
|
17845
|
+
}
|
|
17846
|
+
resolvedEvent = found.example.in;
|
|
17847
|
+
exampleContext = {
|
|
17848
|
+
stepType: found.stepType,
|
|
17849
|
+
stepName: found.stepName,
|
|
17850
|
+
expected: found.example.out
|
|
17851
|
+
};
|
|
17852
|
+
}
|
|
17853
|
+
const isSourceSimulation = exampleContext?.stepType === "source" || options.step?.startsWith("source.");
|
|
17854
|
+
let result;
|
|
17855
|
+
if (isSourceSimulation) {
|
|
17856
|
+
const rawConfig = await loadJsonConfig(configOrPath);
|
|
17857
|
+
const setup = validateFlowSetup(rawConfig);
|
|
17858
|
+
const flowNames = Object.keys(setup.flows);
|
|
17859
|
+
const flowName = options.flow || (flowNames.length === 1 ? flowNames[0] : void 0);
|
|
17860
|
+
if (!flowName) {
|
|
17861
|
+
throw new Error(
|
|
17862
|
+
`Multiple flows found. Use --flow to specify which flow.
|
|
17863
|
+
Available: ${flowNames.join(", ")}`
|
|
17864
|
+
);
|
|
17865
|
+
}
|
|
17866
|
+
const flowConfig = setup.flows[flowName];
|
|
17867
|
+
if (!flowConfig) {
|
|
17868
|
+
throw new Error(
|
|
17869
|
+
`Flow "${flowName}" not found. Available: ${flowNames.join(", ")}`
|
|
17870
|
+
);
|
|
17871
|
+
}
|
|
17872
|
+
const sourceStep = exampleContext?.stepName || options.step.substring("source.".length);
|
|
17873
|
+
result = await simulateSourceCLI(
|
|
17874
|
+
flowConfig,
|
|
17875
|
+
resolvedEvent,
|
|
17876
|
+
{
|
|
17877
|
+
flow: options.flow,
|
|
17878
|
+
sourceStep,
|
|
17879
|
+
json: options.json,
|
|
17880
|
+
verbose: options.verbose,
|
|
17881
|
+
silent: options.silent
|
|
17882
|
+
}
|
|
17883
|
+
);
|
|
17884
|
+
} else {
|
|
17885
|
+
const stepTarget = exampleContext ? `${exampleContext.stepType}.${exampleContext.stepName}` : options.step;
|
|
17886
|
+
result = await simulateCore(configOrPath, resolvedEvent, {
|
|
17887
|
+
json: options.json ?? false,
|
|
17888
|
+
verbose: options.verbose ?? false,
|
|
17889
|
+
silent: options.silent ?? false,
|
|
17890
|
+
flow: options.flow,
|
|
17891
|
+
platform: options.platform,
|
|
17892
|
+
step: stepTarget
|
|
17893
|
+
});
|
|
17894
|
+
}
|
|
17895
|
+
if (exampleContext && result.success) {
|
|
17896
|
+
const stepKey = `${exampleContext.stepType}.${exampleContext.stepName}`;
|
|
17897
|
+
if (exampleContext.expected === false) {
|
|
17898
|
+
const calls = result.usage?.[exampleContext.stepName];
|
|
17899
|
+
const wasFiltered = !calls || calls.length === 0;
|
|
17900
|
+
result.exampleMatch = {
|
|
17901
|
+
name: options.example,
|
|
17902
|
+
step: stepKey,
|
|
17903
|
+
expected: false,
|
|
17904
|
+
actual: wasFiltered ? false : calls,
|
|
17905
|
+
match: wasFiltered,
|
|
17906
|
+
diff: wasFiltered ? void 0 : `Expected event to be filtered, but ${calls.length} API call(s) were made`
|
|
17907
|
+
};
|
|
17908
|
+
} else if (exampleContext.expected !== void 0) {
|
|
17909
|
+
const actual = result.usage?.[exampleContext.stepName] ?? [];
|
|
17910
|
+
result.exampleMatch = {
|
|
17911
|
+
name: options.example,
|
|
17912
|
+
step: stepKey,
|
|
17913
|
+
...compareOutput(exampleContext.expected, actual)
|
|
17914
|
+
};
|
|
17915
|
+
}
|
|
17916
|
+
}
|
|
17917
|
+
return result;
|
|
17918
|
+
}
|
|
17777
17919
|
|
|
17778
17920
|
// src/commands/push/index.ts
|
|
17779
17921
|
init_dist();
|
|
17780
|
-
import
|
|
17922
|
+
import path12 from "path";
|
|
17781
17923
|
import { JSDOM as JSDOM2, VirtualConsole as VirtualConsole2 } from "jsdom";
|
|
17782
|
-
import
|
|
17924
|
+
import fs13 from "fs-extra";
|
|
17783
17925
|
init_cli_logger();
|
|
17784
17926
|
init_dist();
|
|
17785
|
-
function createCollectorLoggerConfig(logger2, verbose) {
|
|
17786
|
-
return {
|
|
17787
|
-
level: verbose ? u.DEBUG : u.ERROR,
|
|
17788
|
-
handler: (level, message, context, scope) => {
|
|
17789
|
-
const scopePath = scope.length > 0 ? `[${scope.join(":")}] ` : "";
|
|
17790
|
-
const hasContext = Object.keys(context).length > 0;
|
|
17791
|
-
const contextStr = hasContext ? ` ${JSON.stringify(context)}` : "";
|
|
17792
|
-
if (level === u.ERROR) {
|
|
17793
|
-
logger2.error(`${scopePath}${message}${contextStr}`);
|
|
17794
|
-
} else {
|
|
17795
|
-
logger2.debug(`${scopePath}${message}${contextStr}`);
|
|
17796
|
-
}
|
|
17797
|
-
}
|
|
17798
|
-
};
|
|
17799
|
-
}
|
|
17800
17927
|
async function pushCore(inputPath, event, options = {}) {
|
|
17801
17928
|
const logger2 = createCLILogger({
|
|
17802
17929
|
silent: options.silent,
|
|
@@ -17805,11 +17932,7 @@ async function pushCore(inputPath, event, options = {}) {
|
|
|
17805
17932
|
const startTime = Date.now();
|
|
17806
17933
|
let tempDir;
|
|
17807
17934
|
try {
|
|
17808
|
-
|
|
17809
|
-
if (typeof event === "string") {
|
|
17810
|
-
loadedEvent = await loadJsonFromSource(event, { name: "event" });
|
|
17811
|
-
}
|
|
17812
|
-
const eventResult = i.PartialEventSchema.safeParse(loadedEvent);
|
|
17935
|
+
const eventResult = i.PartialEventSchema.safeParse(event);
|
|
17813
17936
|
if (!eventResult.success) {
|
|
17814
17937
|
const errors = eventResult.error.issues.map((issue2) => `${String(issue2.path.join("."))}: ${issue2.message}`).join(", ");
|
|
17815
17938
|
throw new Error(`Invalid event: ${errors}`);
|
|
@@ -17855,7 +17978,7 @@ async function pushCore(inputPath, event, options = {}) {
|
|
|
17855
17978
|
(dir) => {
|
|
17856
17979
|
tempDir = dir;
|
|
17857
17980
|
},
|
|
17858
|
-
{ logger:
|
|
17981
|
+
{ logger: { level: options.verbose ? u.DEBUG : u.ERROR } }
|
|
17859
17982
|
);
|
|
17860
17983
|
}
|
|
17861
17984
|
return result;
|
|
@@ -17867,7 +17990,7 @@ async function pushCore(inputPath, event, options = {}) {
|
|
|
17867
17990
|
};
|
|
17868
17991
|
} finally {
|
|
17869
17992
|
if (tempDir) {
|
|
17870
|
-
await
|
|
17993
|
+
await fs13.remove(tempDir).catch(() => {
|
|
17871
17994
|
});
|
|
17872
17995
|
}
|
|
17873
17996
|
}
|
|
@@ -17880,14 +18003,13 @@ async function pushCommand(options) {
|
|
|
17880
18003
|
if (isStdinPiped() && !options.config) {
|
|
17881
18004
|
const stdinContent = await readStdin();
|
|
17882
18005
|
const tmpPath = getTmpPath(void 0, "stdin-push.json");
|
|
17883
|
-
await
|
|
17884
|
-
await
|
|
18006
|
+
await fs13.ensureDir(path12.dirname(tmpPath));
|
|
18007
|
+
await fs13.writeFile(tmpPath, stdinContent, "utf-8");
|
|
17885
18008
|
config2 = tmpPath;
|
|
17886
18009
|
} else {
|
|
17887
18010
|
config2 = options.config || "bundle.config.json";
|
|
17888
18011
|
}
|
|
17889
|
-
const
|
|
17890
|
-
const result = await pushCore(config2, event, {
|
|
18012
|
+
const result = await push(config2, options.event, {
|
|
17891
18013
|
flow: options.flow,
|
|
17892
18014
|
json: options.json,
|
|
17893
18015
|
verbose: options.verbose,
|
|
@@ -17943,13 +18065,31 @@ async function pushCommand(options) {
|
|
|
17943
18065
|
process.exit(1);
|
|
17944
18066
|
}
|
|
17945
18067
|
}
|
|
18068
|
+
async function push(configOrPath, event, options = {}) {
|
|
18069
|
+
if (typeof configOrPath !== "string") {
|
|
18070
|
+
throw new Error(
|
|
18071
|
+
"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."
|
|
18072
|
+
);
|
|
18073
|
+
}
|
|
18074
|
+
let resolvedEvent = event;
|
|
18075
|
+
if (typeof event === "string") {
|
|
18076
|
+
resolvedEvent = await loadJsonFromSource(event, { name: "event" });
|
|
18077
|
+
}
|
|
18078
|
+
return await pushCore(configOrPath, resolvedEvent, {
|
|
18079
|
+
json: options.json ?? false,
|
|
18080
|
+
verbose: options.verbose ?? false,
|
|
18081
|
+
silent: options.silent ?? false,
|
|
18082
|
+
flow: options.flow,
|
|
18083
|
+
platform: options.platform
|
|
18084
|
+
});
|
|
18085
|
+
}
|
|
17946
18086
|
async function executeConfigPush(options, validatedEvent, logger2, setTempDir) {
|
|
17947
18087
|
logger2.debug("Loading flow configuration");
|
|
17948
18088
|
const { flowConfig, buildOptions } = await loadFlowConfig(options.config, {
|
|
17949
18089
|
flowName: options.flow,
|
|
17950
18090
|
logger: logger2
|
|
17951
18091
|
});
|
|
17952
|
-
const platform =
|
|
18092
|
+
const platform = D(flowConfig);
|
|
17953
18093
|
logger2.debug("Bundling flow configuration");
|
|
17954
18094
|
const configDir = buildOptions.configDir || process.cwd();
|
|
17955
18095
|
const tempDir = getTmpPath(
|
|
@@ -17957,8 +18097,8 @@ async function executeConfigPush(options, validatedEvent, logger2, setTempDir) {
|
|
|
17957
18097
|
`push-${Date.now()}-${Math.random().toString(36).slice(2, 9)}`
|
|
17958
18098
|
);
|
|
17959
18099
|
setTempDir(tempDir);
|
|
17960
|
-
await
|
|
17961
|
-
const tempPath =
|
|
18100
|
+
await fs13.ensureDir(tempDir);
|
|
18101
|
+
const tempPath = path12.join(
|
|
17962
18102
|
tempDir,
|
|
17963
18103
|
`bundle.${platform === "web" ? "js" : "mjs"}`
|
|
17964
18104
|
);
|
|
@@ -17980,7 +18120,7 @@ async function executeConfigPush(options, validatedEvent, logger2, setTempDir) {
|
|
|
17980
18120
|
} else if (platform === "server") {
|
|
17981
18121
|
logger2.debug("Executing in server environment (Node.js)");
|
|
17982
18122
|
return executeServerPush(tempPath, validatedEvent, logger2, 6e4, {
|
|
17983
|
-
logger:
|
|
18123
|
+
logger: { level: options.verbose ? u.DEBUG : u.ERROR }
|
|
17984
18124
|
});
|
|
17985
18125
|
} else {
|
|
17986
18126
|
throw new Error(`Unsupported platform: ${platform}`);
|
|
@@ -17992,12 +18132,12 @@ async function executeBundlePush(bundleContent, platform, validatedEvent, logger
|
|
|
17992
18132
|
`push-${Date.now()}-${Math.random().toString(36).slice(2, 9)}`
|
|
17993
18133
|
);
|
|
17994
18134
|
setTempDir(tempDir);
|
|
17995
|
-
await
|
|
17996
|
-
const tempPath =
|
|
18135
|
+
await fs13.ensureDir(tempDir);
|
|
18136
|
+
const tempPath = path12.join(
|
|
17997
18137
|
tempDir,
|
|
17998
18138
|
`bundle.${platform === "server" ? "mjs" : "js"}`
|
|
17999
18139
|
);
|
|
18000
|
-
await
|
|
18140
|
+
await fs13.writeFile(tempPath, bundleContent, "utf8");
|
|
18001
18141
|
logger2.debug(`Bundle written to: ${tempPath}`);
|
|
18002
18142
|
if (platform === "web") {
|
|
18003
18143
|
logger2.debug("Executing in web environment (JSDOM)");
|
|
@@ -18019,7 +18159,7 @@ async function executeWebPush(bundlePath, event, logger2) {
|
|
|
18019
18159
|
});
|
|
18020
18160
|
const { window } = dom;
|
|
18021
18161
|
logger2.debug("Loading bundle...");
|
|
18022
|
-
const bundleCode = await
|
|
18162
|
+
const bundleCode = await fs13.readFile(bundlePath, "utf8");
|
|
18023
18163
|
window.eval(bundleCode);
|
|
18024
18164
|
logger2.debug("Waiting for collector...");
|
|
18025
18165
|
await waitForWindowProperty(
|
|
@@ -18051,7 +18191,7 @@ async function executeServerPush(bundlePath, event, logger2, timeout = 6e4, cont
|
|
|
18051
18191
|
const startTime = Date.now();
|
|
18052
18192
|
let timer;
|
|
18053
18193
|
try {
|
|
18054
|
-
const timeoutPromise = new Promise((
|
|
18194
|
+
const timeoutPromise = new Promise((_3, reject) => {
|
|
18055
18195
|
timer = setTimeout(
|
|
18056
18196
|
() => reject(new Error(`Server push timeout after ${timeout}ms`)),
|
|
18057
18197
|
timeout
|
|
@@ -18115,7 +18255,8 @@ function waitForWindowProperty(window, prop, timeout = 5e3) {
|
|
|
18115
18255
|
|
|
18116
18256
|
// src/commands/run/index.ts
|
|
18117
18257
|
init_cli_logger();
|
|
18118
|
-
import
|
|
18258
|
+
import path14 from "path";
|
|
18259
|
+
import { createRequire } from "module";
|
|
18119
18260
|
|
|
18120
18261
|
// src/commands/run/validators.ts
|
|
18121
18262
|
import { existsSync as existsSync3 } from "fs";
|
|
@@ -18228,15 +18369,15 @@ function validatePort(port) {
|
|
|
18228
18369
|
}
|
|
18229
18370
|
|
|
18230
18371
|
// src/commands/run/utils.ts
|
|
18231
|
-
import
|
|
18232
|
-
import
|
|
18372
|
+
import path13 from "path";
|
|
18373
|
+
import fs14 from "fs-extra";
|
|
18233
18374
|
async function prepareBundleForRun(configPath, options) {
|
|
18234
18375
|
const tempDir = getTmpPath(
|
|
18235
18376
|
void 0,
|
|
18236
18377
|
`run-${Date.now()}-${Math.random().toString(36).slice(2, 9)}`
|
|
18237
18378
|
);
|
|
18238
|
-
await
|
|
18239
|
-
const tempPath =
|
|
18379
|
+
await fs14.ensureDir(tempDir);
|
|
18380
|
+
const tempPath = path13.join(tempDir, "bundle.mjs");
|
|
18240
18381
|
await bundle(configPath, {
|
|
18241
18382
|
cache: true,
|
|
18242
18383
|
verbose: options.verbose,
|
|
@@ -18342,7 +18483,7 @@ var instanceId = randomBytes(8).toString("hex");
|
|
|
18342
18483
|
// src/commands/run/execution.ts
|
|
18343
18484
|
var logLevel = process.env.VERBOSE === "true" ? u.DEBUG : u.INFO;
|
|
18344
18485
|
var loggerConfig = { level: logLevel };
|
|
18345
|
-
var logger =
|
|
18486
|
+
var logger = de(loggerConfig);
|
|
18346
18487
|
async function executeRunLocal(flowPath, options) {
|
|
18347
18488
|
const config2 = {
|
|
18348
18489
|
port: options.port,
|
|
@@ -18352,6 +18493,7 @@ async function executeRunLocal(flowPath, options) {
|
|
|
18352
18493
|
}
|
|
18353
18494
|
|
|
18354
18495
|
// src/commands/run/index.ts
|
|
18496
|
+
var esmRequire = createRequire(import.meta.url);
|
|
18355
18497
|
async function runCommand(options) {
|
|
18356
18498
|
const timer = createTimer();
|
|
18357
18499
|
timer.start();
|
|
@@ -18364,7 +18506,7 @@ async function runCommand(options) {
|
|
|
18364
18506
|
const runtimeDeps = ["express", "cors"];
|
|
18365
18507
|
for (const dep of runtimeDeps) {
|
|
18366
18508
|
try {
|
|
18367
|
-
|
|
18509
|
+
esmRequire.resolve(dep);
|
|
18368
18510
|
} catch {
|
|
18369
18511
|
logger2.error(
|
|
18370
18512
|
`Missing runtime dependency "${dep}"
|
|
@@ -18377,8 +18519,8 @@ Run: npm install express cors`
|
|
|
18377
18519
|
const isPreBuilt = isPreBuiltConfig(configPath);
|
|
18378
18520
|
let flowPath;
|
|
18379
18521
|
if (isPreBuilt) {
|
|
18380
|
-
flowPath =
|
|
18381
|
-
logger2.debug(`Using pre-built flow: ${
|
|
18522
|
+
flowPath = path14.resolve(configPath);
|
|
18523
|
+
logger2.debug(`Using pre-built flow: ${path14.basename(flowPath)}`);
|
|
18382
18524
|
} else {
|
|
18383
18525
|
logger2.debug("Building flow bundle");
|
|
18384
18526
|
flowPath = await prepareBundleForRun(configPath, {
|
|
@@ -18546,10 +18688,10 @@ function validateEvent(input) {
|
|
|
18546
18688
|
const zodResult = PartialEventSchema.safeParse(input);
|
|
18547
18689
|
if (!zodResult.success) {
|
|
18548
18690
|
for (const issue2 of zodResult.error.issues) {
|
|
18549
|
-
const
|
|
18550
|
-
if (
|
|
18691
|
+
const path15 = issue2.path.join(".");
|
|
18692
|
+
if (path15 === "name") continue;
|
|
18551
18693
|
errors.push({
|
|
18552
|
-
path:
|
|
18694
|
+
path: path15 || "root",
|
|
18553
18695
|
message: issue2.message,
|
|
18554
18696
|
code: "SCHEMA_VALIDATION"
|
|
18555
18697
|
});
|
|
@@ -18761,10 +18903,10 @@ function buildConnectionGraph(config2) {
|
|
|
18761
18903
|
function checkCompatibility(conn, errors, warnings) {
|
|
18762
18904
|
const fromOuts = Object.entries(conn.from.examples).filter(([, ex]) => ex.out !== void 0 && ex.out !== false).map(([name, ex]) => ({ name, value: ex.out }));
|
|
18763
18905
|
const toIns = Object.entries(conn.to.examples).filter(([, ex]) => ex.in !== void 0).map(([name, ex]) => ({ name, value: ex.in }));
|
|
18764
|
-
const
|
|
18906
|
+
const path15 = `${conn.from.type}.${conn.from.name} \u2192 ${conn.to.type}.${conn.to.name}`;
|
|
18765
18907
|
if (fromOuts.length === 0 || toIns.length === 0) {
|
|
18766
18908
|
warnings.push({
|
|
18767
|
-
path:
|
|
18909
|
+
path: path15,
|
|
18768
18910
|
message: "Cannot check compatibility: missing out or in examples",
|
|
18769
18911
|
suggestion: "Add out examples to the source step or in examples to the target step"
|
|
18770
18912
|
});
|
|
@@ -18782,7 +18924,7 @@ function checkCompatibility(conn, errors, warnings) {
|
|
|
18782
18924
|
}
|
|
18783
18925
|
if (!hasMatch) {
|
|
18784
18926
|
errors.push({
|
|
18785
|
-
path:
|
|
18927
|
+
path: path15,
|
|
18786
18928
|
message: "No compatible out/in pair found between connected steps",
|
|
18787
18929
|
code: "INCOMPATIBLE_EXAMPLES"
|
|
18788
18930
|
});
|
|
@@ -18795,7 +18937,7 @@ function isStructurallyCompatible(a3, b2) {
|
|
|
18795
18937
|
if (typeof a3 === "object" && typeof b2 === "object") {
|
|
18796
18938
|
const keysA = Object.keys(a3);
|
|
18797
18939
|
const keysB = Object.keys(b2);
|
|
18798
|
-
const shared = keysA.filter((
|
|
18940
|
+
const shared = keysA.filter((k2) => keysB.includes(k2));
|
|
18799
18941
|
return shared.length >= Math.min(keysA.length, keysB.length) * 0.5;
|
|
18800
18942
|
}
|
|
18801
18943
|
return true;
|
|
@@ -18878,13 +19020,13 @@ function validateMapping(input) {
|
|
|
18878
19020
|
init_dist();
|
|
18879
19021
|
import Ajv from "ajv";
|
|
18880
19022
|
var SECTIONS = ["destinations", "sources", "transformers"];
|
|
18881
|
-
function resolveEntry(
|
|
19023
|
+
function resolveEntry(path15, flowConfig) {
|
|
18882
19024
|
const flows = flowConfig.flows;
|
|
18883
19025
|
if (!flows || typeof flows !== "object") return "No flows found in config";
|
|
18884
19026
|
const flowName = Object.keys(flows)[0];
|
|
18885
19027
|
const flow = flows[flowName];
|
|
18886
19028
|
if (!flow) return `Flow "${flowName}" is empty`;
|
|
18887
|
-
const parts =
|
|
19029
|
+
const parts = path15.split(".");
|
|
18888
19030
|
if (parts.length === 2) {
|
|
18889
19031
|
const [section, key] = parts;
|
|
18890
19032
|
if (!SECTIONS.includes(section)) {
|
|
@@ -18921,15 +19063,15 @@ function resolveEntry(path14, flowConfig) {
|
|
|
18921
19063
|
}
|
|
18922
19064
|
return { section: matches[0].section, key, entry: matches[0].entry };
|
|
18923
19065
|
}
|
|
18924
|
-
return `Invalid path "${
|
|
19066
|
+
return `Invalid path "${path15}". Use "section.key" or just "key"`;
|
|
18925
19067
|
}
|
|
18926
|
-
async function validateEntry(
|
|
18927
|
-
const resolved = resolveEntry(
|
|
19068
|
+
async function validateEntry(path15, flowConfig) {
|
|
19069
|
+
const resolved = resolveEntry(path15, flowConfig);
|
|
18928
19070
|
if (typeof resolved === "string") {
|
|
18929
19071
|
return {
|
|
18930
19072
|
valid: false,
|
|
18931
19073
|
type: "entry",
|
|
18932
|
-
errors: [{ path:
|
|
19074
|
+
errors: [{ path: path15, message: resolved, code: "ENTRY_VALIDATION" }],
|
|
18933
19075
|
warnings: [],
|
|
18934
19076
|
details: {}
|
|
18935
19077
|
};
|
|
@@ -18952,7 +19094,7 @@ async function validateEntry(path14, flowConfig) {
|
|
|
18952
19094
|
}
|
|
18953
19095
|
let schemas;
|
|
18954
19096
|
try {
|
|
18955
|
-
const info = await
|
|
19097
|
+
const info = await Be(packageName);
|
|
18956
19098
|
schemas = info.schemas;
|
|
18957
19099
|
} catch (error48) {
|
|
18958
19100
|
return {
|
|
@@ -18960,7 +19102,7 @@ async function validateEntry(path14, flowConfig) {
|
|
|
18960
19102
|
type: "entry",
|
|
18961
19103
|
errors: [
|
|
18962
19104
|
{
|
|
18963
|
-
path:
|
|
19105
|
+
path: path15,
|
|
18964
19106
|
message: error48 instanceof Error ? error48.message : "Unknown error",
|
|
18965
19107
|
code: "ENTRY_VALIDATION"
|
|
18966
19108
|
}
|
|
@@ -18985,10 +19127,10 @@ async function validateEntry(path14, flowConfig) {
|
|
|
18985
19127
|
const validate2 = ajv.compile(settingsSchema);
|
|
18986
19128
|
const isValid = validate2(settings || {});
|
|
18987
19129
|
if (!isValid) {
|
|
18988
|
-
const errors = (validate2.errors || []).map((
|
|
18989
|
-
path:
|
|
18990
|
-
message:
|
|
18991
|
-
code:
|
|
19130
|
+
const errors = (validate2.errors || []).map((e4) => ({
|
|
19131
|
+
path: e4.instancePath || "/",
|
|
19132
|
+
message: e4.message || "Unknown error",
|
|
19133
|
+
code: e4.keyword
|
|
18992
19134
|
}));
|
|
18993
19135
|
return {
|
|
18994
19136
|
valid: false,
|
|
@@ -19009,18 +19151,25 @@ async function validateEntry(path14, flowConfig) {
|
|
|
19009
19151
|
|
|
19010
19152
|
// src/commands/validate/index.ts
|
|
19011
19153
|
async function validate(type, input, options = {}) {
|
|
19154
|
+
let resolved = input;
|
|
19155
|
+
if (typeof input === "string") {
|
|
19156
|
+
resolved = await loadJsonFromSource(input, {
|
|
19157
|
+
name: type,
|
|
19158
|
+
required: true
|
|
19159
|
+
});
|
|
19160
|
+
}
|
|
19012
19161
|
if (options.path) {
|
|
19013
|
-
return validateEntry(options.path,
|
|
19162
|
+
return validateEntry(options.path, resolved);
|
|
19014
19163
|
}
|
|
19015
19164
|
switch (type) {
|
|
19016
19165
|
case "contract":
|
|
19017
|
-
return validateContract(
|
|
19166
|
+
return validateContract(resolved);
|
|
19018
19167
|
case "event":
|
|
19019
|
-
return validateEvent(
|
|
19168
|
+
return validateEvent(resolved);
|
|
19020
19169
|
case "flow":
|
|
19021
|
-
return validateFlow(
|
|
19170
|
+
return validateFlow(resolved, { flow: options.flow });
|
|
19022
19171
|
case "mapping":
|
|
19023
|
-
return validateMapping(
|
|
19172
|
+
return validateMapping(resolved);
|
|
19024
19173
|
default:
|
|
19025
19174
|
throw new Error(`Unknown validation type: ${type}`);
|
|
19026
19175
|
}
|
|
@@ -19071,10 +19220,7 @@ async function validateCommand(options) {
|
|
|
19071
19220
|
throw new Error("Invalid JSON received on stdin");
|
|
19072
19221
|
}
|
|
19073
19222
|
} else {
|
|
19074
|
-
input =
|
|
19075
|
-
name: options.type,
|
|
19076
|
-
required: true
|
|
19077
|
-
});
|
|
19223
|
+
input = options.input;
|
|
19078
19224
|
}
|
|
19079
19225
|
const result = await validate(options.type, input, {
|
|
19080
19226
|
flow: options.flow,
|
|
@@ -19117,7 +19263,7 @@ async function validateCommand(options) {
|
|
|
19117
19263
|
}
|
|
19118
19264
|
|
|
19119
19265
|
// src/commands/cache.ts
|
|
19120
|
-
import
|
|
19266
|
+
import fs15 from "fs-extra";
|
|
19121
19267
|
init_cli_logger();
|
|
19122
19268
|
function registerCacheCommand(program2) {
|
|
19123
19269
|
const cache = program2.command("cache").description("Manage the CLI cache");
|
|
@@ -19125,14 +19271,14 @@ function registerCacheCommand(program2) {
|
|
|
19125
19271
|
const logger2 = createCLILogger({ silent: options.silent });
|
|
19126
19272
|
const tmpDir = options.tmpDir;
|
|
19127
19273
|
if (options.packages) {
|
|
19128
|
-
await
|
|
19274
|
+
await fs15.remove(getTmpPath(tmpDir, "cache", "packages"));
|
|
19129
19275
|
logger2.info("Package cache cleared");
|
|
19130
19276
|
} else if (options.builds) {
|
|
19131
|
-
await
|
|
19277
|
+
await fs15.remove(getTmpPath(tmpDir, "cache", "builds"));
|
|
19132
19278
|
logger2.info("Build cache cleared");
|
|
19133
19279
|
} else {
|
|
19134
19280
|
const cacheDir = getTmpPath(tmpDir, "cache");
|
|
19135
|
-
await
|
|
19281
|
+
await fs15.remove(cacheDir);
|
|
19136
19282
|
logger2.info(`Cache cleared: ${cacheDir}`);
|
|
19137
19283
|
}
|
|
19138
19284
|
});
|
|
@@ -19149,8 +19295,8 @@ function registerCacheCommand(program2) {
|
|
|
19149
19295
|
});
|
|
19150
19296
|
}
|
|
19151
19297
|
async function countEntries(dir) {
|
|
19152
|
-
if (!await
|
|
19153
|
-
const entries = await
|
|
19298
|
+
if (!await fs15.pathExists(dir)) return 0;
|
|
19299
|
+
const entries = await fs15.readdir(dir);
|
|
19154
19300
|
return entries.length;
|
|
19155
19301
|
}
|
|
19156
19302
|
|
|
@@ -19405,7 +19551,10 @@ async function getFlow(options) {
|
|
|
19405
19551
|
const { data, error: error48 } = await client.GET(
|
|
19406
19552
|
"/api/projects/{projectId}/flows/{flowId}",
|
|
19407
19553
|
{
|
|
19408
|
-
params: {
|
|
19554
|
+
params: {
|
|
19555
|
+
path: { projectId: id, flowId: options.flowId },
|
|
19556
|
+
query: options.fields ? { fields: options.fields.join(",") } : {}
|
|
19557
|
+
}
|
|
19409
19558
|
}
|
|
19410
19559
|
);
|
|
19411
19560
|
if (error48) throw new Error(error48.error?.message || "Failed to get flow");
|
|
@@ -19433,7 +19582,10 @@ async function updateFlow(options) {
|
|
|
19433
19582
|
{
|
|
19434
19583
|
params: { path: { projectId: id, flowId: options.flowId } },
|
|
19435
19584
|
// Dynamically constructed body; server validates the full schema
|
|
19436
|
-
body
|
|
19585
|
+
body,
|
|
19586
|
+
...options.mergePatch && {
|
|
19587
|
+
headers: { "Content-Type": "application/merge-patch+json" }
|
|
19588
|
+
}
|
|
19437
19589
|
}
|
|
19438
19590
|
);
|
|
19439
19591
|
if (error48) throw new Error(error48.error?.message || "Failed to update flow");
|
|
@@ -19860,7 +20012,7 @@ async function createDeployCommand(config2, options) {
|
|
|
19860
20012
|
const result2 = await loadFlowConfig(config2, {
|
|
19861
20013
|
flowName: options.flow
|
|
19862
20014
|
});
|
|
19863
|
-
type =
|
|
20015
|
+
type = D(result2.flowConfig);
|
|
19864
20016
|
}
|
|
19865
20017
|
const deployment = await createDeployment({
|
|
19866
20018
|
type,
|