@go-labs-sg/event-tech 1.6.0 → 1.8.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -35,7 +35,7 @@ var __toESM = (mod, isNodeMode, target) => {
35
35
  var __commonJS = (cb, mod) => () => (mod || cb((mod = { exports: {} }).exports, mod), mod.exports);
36
36
  var __require = import.meta.require;
37
37
 
38
- // ../../../node_modules/.bun/dotenv@18.0.9/node_modules/dotenv/dist/index.cjs
38
+ // ../../../node_modules/.bun/dotenv@18.0.10/node_modules/dotenv/dist/index.cjs
39
39
  var require_dist = __commonJS(function(exports, module) {
40
40
  var j = (e, n) => () => {
41
41
  try {
@@ -44,428 +44,227 @@ var require_dist = __commonJS(function(exports, module) {
44
44
  throw n = 0, t;
45
45
  }
46
46
  };
47
- var k = j((xe, U) => {
48
- function G(e) {
47
+ var R = j((Z, N) => {
48
+ function T(e) {
49
49
  return typeof e == "string" ? !["false", "0", "no", "off", ""].includes(e.toLowerCase()) : !!e;
50
50
  }
51
- function Y(e = process.env) {
51
+ function U(e = process.env) {
52
52
  let n = {};
53
53
  for (let t of ["ENCODING", "PATH", "QUIET", "DEBUG", "OVERRIDE", "FAST"]) {
54
- let o = e[`DOTENV_${t}`] != null ? e[`DOTENV_${t}`] : e[`DOTENV_CONFIG_${t}`];
55
- o != null && (n[t.toLowerCase()] = t === "ENCODING" || t === "PATH" ? o : G(o));
54
+ let r = e[`DOTENV_${t}`] != null ? e[`DOTENV_${t}`] : e[`DOTENV_CONFIG_${t}`];
55
+ r != null && (n[t.toLowerCase()] = t === "ENCODING" || t === "PATH" ? r : T(r));
56
56
  }
57
57
  return n;
58
58
  }
59
- U.exports = { parseBoolean: G, optionsFromEnv: Y };
59
+ N.exports = { parseBoolean: T, optionsFromEnv: U };
60
60
  });
61
- var N = j((ye, x) => {
62
- var z = __require("fs"), I = __require("path"), Z = __require("os"), { URL: ee, fileURLToPath: te } = __require("url"), { parseBoolean: $, optionsFromEnv: B } = k(), re = /(?:^|^)\s*(?:export\s+)?([\w.-]+)(?:\s*=\s*?|:\s+?)(\s*'(?:\\'|[^'])*'|\s*"(?:\\"|[^"])*"|\s*`(?:\\`|[^`])*`|[^#\r\n]+)?\s*(?:#.*)?(?:$|$)/mg, b = new Uint8Array(256);
61
+ var P = j((ee, b) => {
62
+ var F = __require("fs"), _ = __require("path"), B = __require("os"), { URL: L, fileURLToPath: Q } = __require("url"), { parseBoolean: $, optionsFromEnv: I } = R(), G = /(?:^|^)\s*(?:export\s+)?([\w.-]+)(?:\s*=\s*?|:\s+?)(\s*'(?:\\'|[^'])*'|\s*"(?:\\"|[^"])*"|\s*`(?:\\`|[^`])*`|[^#\r\n]+)?\s*(?:#.*)?(?:$|$)/mg, y = new Uint8Array(256);
63
63
  for (let e = 48;e <= 57; e++)
64
- b[e] = 1;
64
+ y[e] = 1;
65
65
  for (let e = 65;e <= 90; e++)
66
- b[e] = 1;
66
+ y[e] = 1;
67
67
  for (let e = 97;e <= 122; e++)
68
- b[e] = 1;
69
- b[45] = 1;
70
- b[46] = 1;
71
- b[95] = 1;
72
- function ne(e) {
68
+ y[e] = 1;
69
+ y[45] = 1;
70
+ y[46] = 1;
71
+ y[95] = 1;
72
+ function H(e) {
73
73
  let n = {}, t = e.toString();
74
74
  t = t.replace(/\r\n?/mg, `
75
75
  `);
76
- let o;
77
- for (;(o = re.exec(t)) != null; ) {
78
- let r = o[1], s = o[2] || "";
79
- s = s.trim();
80
- let i = s[0];
81
- s = s.replace(/^(['"`])([\s\S]*)\1$/mg, "$2"), i === '"' && (s = s.replace(/\\n/g, `
82
- `), s = s.replace(/\\r/g, "\r")), n[r] = s;
76
+ let r;
77
+ for (;(r = G.exec(t)) != null; ) {
78
+ let o = r[1], i = r[2] || "";
79
+ i = i.trim();
80
+ let c = i[0];
81
+ i = i.replace(/^(['"`])([\s\S]*)\1$/mg, "$2"), c === '"' && (i = i.replace(/\\n/g, `
82
+ `), i = i.replace(/\\r/g, "\r")), n[o] = i;
83
83
  }
84
84
  return n;
85
85
  }
86
- function w(e) {
86
+ function g(e) {
87
87
  return e <= 32 ? e === 32 || e >= 9 && e <= 13 : e >= 160 && (e === 160 || e === 5760 || e >= 8192 && e <= 8202 || e === 8232 || e === 8233 || e === 8239 || e === 8287 || e === 12288 || e === 65279);
88
88
  }
89
- function q(e) {
89
+ function O(e) {
90
90
  return e === 10 || e === 8232 || e === 8233;
91
91
  }
92
- function oe(e) {
92
+ function V(e) {
93
93
  let n = {}, t = typeof e == "string" ? e : e.toString();
94
94
  t.indexOf("\r") !== -1 && (t = t.replace(/\r\n?/g, `
95
95
  `));
96
- let o = t.length, r = 0;
97
- for (;r < o; ) {
98
- let s = t.charCodeAt(r);
99
- for (;r < o && w(s); )
100
- r++, s = t.charCodeAt(r);
101
- if (r >= o)
96
+ let r = t.length, o = 0;
97
+ for (;o < r; ) {
98
+ let i = t.charCodeAt(o);
99
+ for (;o < r && g(i); )
100
+ o++, i = t.charCodeAt(o);
101
+ if (o >= r)
102
102
  break;
103
- if (s === 35) {
104
- for (;r < o && !q(t.charCodeAt(r)); )
105
- r++;
103
+ if (i === 35) {
104
+ for (;o < r && !O(t.charCodeAt(o)); )
105
+ o++;
106
106
  continue;
107
107
  }
108
- let i = -1;
109
- if (s === 101 && r + 6 < o && t.charCodeAt(r + 1) === 120 && t.charCodeAt(r + 2) === 112 && t.charCodeAt(r + 3) === 111 && t.charCodeAt(r + 4) === 114 && t.charCodeAt(r + 5) === 116) {
110
- let v = t.charCodeAt(r + 6);
111
- if (w(v)) {
112
- let u = r + 7;
113
- for (;u < o && w(t.charCodeAt(u)); )
114
- u++;
115
- b[t.charCodeAt(u)] && (i = r + 6, r = u);
108
+ let c = -1;
109
+ if (i === 101 && o + 6 < r && t.charCodeAt(o + 1) === 120 && t.charCodeAt(o + 2) === 112 && t.charCodeAt(o + 3) === 111 && t.charCodeAt(o + 4) === 114 && t.charCodeAt(o + 5) === 116) {
110
+ let u = t.charCodeAt(o + 6);
111
+ if (g(u)) {
112
+ let s = o + 7;
113
+ for (;s < r && g(t.charCodeAt(s)); )
114
+ s++;
115
+ y[t.charCodeAt(s)] && (c = o + 6, o = s);
116
116
  } else
117
- s = t.charCodeAt(r);
118
- }
119
- let l = r, d = 0;
120
- for (;r < o && (d = t.charCodeAt(r), b[d]); )
121
- r++;
122
- if (r === l) {
123
- for (;r < o && !q(t.charCodeAt(r)); )
124
- r++;
117
+ i = t.charCodeAt(o);
118
+ }
119
+ let E = o, p = 0;
120
+ for (;o < r && (p = t.charCodeAt(o), y[p]); )
121
+ o++;
122
+ if (o === E) {
123
+ for (;o < r && !O(t.charCodeAt(o)); )
124
+ o++;
125
125
  continue;
126
126
  }
127
- let h = t.slice(l, r), f = r;
128
- if (r >= o && (d = 0), w(d))
127
+ let k = t.slice(E, o), D = o;
128
+ if (o >= r && (p = 0), g(p))
129
129
  do
130
- r++, d = r < o ? t.charCodeAt(r) : 0;
131
- while (w(d));
132
- if (d === 61)
133
- r++;
134
- else if (d === 58 && r === f && r + 1 < o && w(t.charCodeAt(r + 1)))
135
- r += 2;
130
+ o++, p = o < r ? t.charCodeAt(o) : 0;
131
+ while (g(p));
132
+ if (p === 61)
133
+ o++;
134
+ else if (p === 58 && o === D && o + 1 < r && g(t.charCodeAt(o + 1)))
135
+ o += 2;
136
136
  else {
137
- for (r = i === -1 ? f : i;r < o && !q(t.charCodeAt(r)); )
138
- r++;
137
+ for (o = c === -1 ? D : c;o < r && !O(t.charCodeAt(o)); )
138
+ o++;
139
139
  continue;
140
140
  }
141
- let c = r, a = r;
142
- for (;a < o && w(t.charCodeAt(a)); )
143
- a++;
144
- let g = t.charCodeAt(a), p, y = false;
145
- if (g === 39 || g === 34 || g === 96) {
146
- let v = t[a], u = t.indexOf(v, a + 1), m = -1, C = -1;
147
- for (;u !== -1; ) {
148
- let O = t.charCodeAt(u - 1) === 92, E = u + 1;
149
- for (;E < o && !q(t.charCodeAt(E)) && w(t.charCodeAt(E)); )
150
- E++;
151
- if ((E === o || q(t.charCodeAt(E)) || t.charCodeAt(E) === 35) && (m = u, C = E), !O)
141
+ let d = o, l = o;
142
+ for (;l < r && g(t.charCodeAt(l)); )
143
+ l++;
144
+ let C = t.charCodeAt(l), a, q = false;
145
+ if (C === 39 || C === 34 || C === 96) {
146
+ let u = t[l], s = t.indexOf(u, l + 1), f = -1, h = -1;
147
+ for (;s !== -1; ) {
148
+ let x = t.charCodeAt(s - 1) === 92, w = s + 1;
149
+ for (;w < r && !O(t.charCodeAt(w)) && g(t.charCodeAt(w)); )
150
+ w++;
151
+ if ((w === r || O(t.charCodeAt(w)) || t.charCodeAt(w) === 35) && (f = s, h = w), !x)
152
152
  break;
153
- u = t.indexOf(v, u + 1);
153
+ s = t.indexOf(u, s + 1);
154
154
  }
155
- if (m !== -1) {
156
- if (p = t.slice(a + 1, m), r = C, t.charCodeAt(r) === 35)
157
- for (;r < o && !q(t.charCodeAt(r)); )
158
- r++;
159
- y = true;
155
+ if (f !== -1) {
156
+ if (a = t.slice(l + 1, f), o = h, t.charCodeAt(o) === 35)
157
+ for (;o < r && !O(t.charCodeAt(o)); )
158
+ o++;
159
+ q = true;
160
160
  }
161
161
  }
162
- if (!y) {
163
- let v = t.indexOf(`
164
- `, c);
165
- v === -1 && (v = o);
166
- let u;
167
- if (o < 4096)
168
- u = t.indexOf("#", c), (u === -1 || u > v) && (u = v);
162
+ if (!q) {
163
+ let u = t.indexOf(`
164
+ `, d);
165
+ u === -1 && (u = r);
166
+ let s;
167
+ if (r < 4096)
168
+ s = t.indexOf("#", d), (s === -1 || s > u) && (s = u);
169
169
  else
170
- for (u = c;u < v && t.charCodeAt(u) !== 35; )
171
- u++;
172
- let m = c, C = u;
173
- for (;m < C && w(t.charCodeAt(m)); )
174
- m++;
175
- for (;C > m && w(t.charCodeAt(C - 1)); )
176
- C--;
177
- let O = t.charCodeAt(m);
178
- if (p = t.slice(m, C), p.includes("\u2028") || p.includes("\u2029") ? p = p.replace(/^(['"`])([\s\S]*)\1$/mg, "$2") : C - m >= 2 && (O === 39 || O === 34 || O === 96) && t.charCodeAt(C - 1) === O && (p = t.slice(m + 1, C - 1)), r = u, u < v)
179
- for (;r < o && !q(t.charCodeAt(r)); )
180
- r++;
181
- }
182
- g === 34 && (y || a < r) && p.indexOf("\\") !== -1 && (p = p.replace(/\\n/g, `
183
- `).replace(/\\r/g, "\r")), n[h] = p;
170
+ for (s = d;s < u && t.charCodeAt(s) !== 35; )
171
+ s++;
172
+ let f = d, h = s;
173
+ for (;f < h && g(t.charCodeAt(f)); )
174
+ f++;
175
+ for (;h > f && g(t.charCodeAt(h - 1)); )
176
+ h--;
177
+ let x = t.charCodeAt(f);
178
+ if (a = t.slice(f, h), a.includes("\u2028") || a.includes("\u2029") ? a = a.replace(/^(['"`])([\s\S]*)\1$/mg, "$2") : h - f >= 2 && (x === 39 || x === 34 || x === 96) && t.charCodeAt(h - 1) === x && (a = t.slice(f + 1, h - 1)), o = s, s < u)
179
+ for (;o < r && !O(t.charCodeAt(o)); )
180
+ o++;
181
+ }
182
+ C === 34 && (q || l < o) && a.indexOf("\\") !== -1 && (a = a.replace(/\\n/g, `
183
+ `).replace(/\\r/g, "\r")), n[k] = a;
184
184
  }
185
185
  return n;
186
186
  }
187
- function se(e, n) {
188
- return n && $(n.fast) ? oe(e) : ne(e);
187
+ function J(e, n) {
188
+ return n && $(n.fast) ? V(e) : H(e);
189
189
  }
190
- function T(e) {
190
+ function v(e) {
191
191
  console.log(`\u2506 ${e}`);
192
192
  }
193
- function ie(e) {
193
+ function W(e) {
194
194
  console.error(`\u25C7 ${e}`);
195
195
  }
196
- function V(e) {
197
- return e[0] === "~" ? I.join(Z.homedir(), e.slice(1)) : e;
196
+ function S(e) {
197
+ return e[0] === "~" ? _.join(B.homedir(), e.slice(1)) : e;
198
198
  }
199
- function ce(e = {}) {
199
+ function K(e = {}) {
200
200
  let n = { ...e };
201
201
  for (let t of Object.keys(n))
202
202
  n[t] === undefined && delete n[t];
203
- return { ...B(), ...n };
204
- }
205
- function ae(e) {
206
- e = ce(e);
207
- let n = I.resolve(process.cwd(), ".env"), t = "utf8", o = process.env;
208
- e && e.processEnv != null && (o = e.processEnv);
209
- let r = $(e && e.debug);
210
- e && e.encoding ? t = e.encoding : r && T("no encoding is specified (UTF-8 is used by default)");
211
- let s = [n];
203
+ return { ...I(), ...n };
204
+ }
205
+ function M(e) {
206
+ e = K(e);
207
+ let n = _.resolve(process.cwd(), ".env"), t = "utf8", r = process.env;
208
+ e && e.processEnv != null && (r = e.processEnv);
209
+ let o = $(e && e.debug);
210
+ e && e.encoding ? t = e.encoding : o && v("no encoding is specified (UTF-8 is used by default)");
211
+ let i = [n];
212
212
  if (e && e.path)
213
213
  if (!Array.isArray(e.path))
214
- s = [V(e.path)];
214
+ i = [S(e.path)];
215
215
  else {
216
- s = [];
217
- for (let c of e.path)
218
- s.push(V(c));
216
+ i = [];
217
+ for (let d of e.path)
218
+ i.push(S(d));
219
219
  }
220
- let i, l = {}, d = { fast: e.fast };
221
- for (let c of s)
220
+ let c, E = {}, p = { fast: e.fast };
221
+ for (let d of i)
222
222
  try {
223
- let a = A.parse(z.readFileSync(c, { encoding: t }), d);
224
- A.populate(l, a, e);
225
- } catch (a) {
226
- r && T(`failed to load ${c} ${a.message}`), i = a;
227
- }
228
- let h = A.populate(o, l, e), f = $(Object.prototype.hasOwnProperty.call(e, "quiet") ? e.quiet : B(o).quiet);
229
- if (r || !f) {
230
- let c = Object.keys(h).length, a = [];
231
- for (let g of s)
223
+ let l = A.parse(F.readFileSync(d, { encoding: t }), p);
224
+ A.populate(E, l, e);
225
+ } catch (l) {
226
+ o && v(`failed to load ${d} ${l.message}`), c = l;
227
+ }
228
+ let k = A.populate(r, E, e), D = $(Object.prototype.hasOwnProperty.call(e, "quiet") ? e.quiet : I(r).quiet);
229
+ if (o || !D) {
230
+ let d = Object.keys(k).length, l = [];
231
+ for (let C of i)
232
232
  try {
233
- let p = I.relative(process.cwd(), g instanceof ee ? te(g) : g);
234
- a.push(p);
235
- } catch (p) {
236
- r && T(`failed to load ${g} ${p.message}`), i = p;
233
+ let a = _.relative(process.cwd(), C instanceof L ? Q(C) : C);
234
+ l.push(a);
235
+ } catch (a) {
236
+ o && v(`failed to load ${C} ${a.message}`), c = a;
237
237
  }
238
- ie(`injected env (${c}) from ${a.join(",")}`);
238
+ W(`injected env (${d}) from ${l.join(",")}`);
239
239
  }
240
- return i ? { parsed: l, error: i } : { parsed: l };
240
+ return c ? { parsed: E, error: c } : { parsed: E };
241
241
  }
242
- function le(e) {
242
+ function Y(e) {
243
243
  return A.configDotenv(e);
244
244
  }
245
- function fe(e, n, t = {}) {
246
- let o = $(t && t.debug), r = $(t && t.override), s = {};
245
+ function z(e, n, t = {}) {
246
+ let r = $(t && t.debug), o = $(t && t.override), i = {};
247
247
  if (e === null || typeof e != "object" || n === null || typeof n != "object") {
248
- let i = new Error("OBJECT_REQUIRED: Please check the processEnv argument being passed to populate");
249
- throw i.code = "OBJECT_REQUIRED", i;
250
- }
251
- for (let i of Object.keys(n))
252
- Object.prototype.hasOwnProperty.call(e, i) ? (r === true && (e[i] = n[i], s[i] = n[i]), o && T(r === true ? `"${i}" is already defined and WAS overwritten` : `"${i}" is already defined and was NOT overwritten`)) : (e[i] = n[i], s[i] = n[i]);
253
- return s;
254
- }
255
- var A = { configDotenv: ae, config: le, parse: se, populate: fe };
256
- x.exports.configDotenv = A.configDotenv;
257
- x.exports.config = A.config;
258
- x.exports.parse = A.parse;
259
- x.exports.populate = A.populate;
260
- x.exports = A;
261
- });
262
- var M = j((Te, W) => {
263
- var _ = __require("child_process"), ue = __require("fs"), L = __require("path");
264
- function de(e) {
265
- let n = ['"'], t = 0;
266
- for (let o of e) {
267
- if (o === "\\") {
268
- t++;
269
- continue;
270
- }
271
- o === '"' ? n.push("\\".repeat(t * 2 + 1), '"') : n.push("\\".repeat(t), o), t = 0;
272
- }
273
- return n.push("\\".repeat(t * 2), '"'), n.join("");
274
- }
275
- function H(e, n = 1) {
276
- for (let t = 0;t < n; t++) {
277
- let o = [];
278
- for (let r of e) {
279
- let s = r.charCodeAt(0), i = s >= 48 && s <= 57 || s >= 65 && s <= 90 || s >= 97 && s <= 122, l = "\\/:._-".includes(r);
280
- !i && !l && s < 128 && o.push("^"), o.push(r);
281
- }
282
- e = o.join("");
283
- }
284
- return e;
285
- }
286
- function P(e, n) {
287
- let t = Object.keys(e).reverse().find((o) => o.toUpperCase() === n);
288
- return t === undefined ? undefined : e[t];
289
- }
290
- function pe(e, n, t) {
291
- let o = (P(n, "PATHEXT") || ".COM;.EXE;.BAT;.CMD").split(";").filter(Boolean), s = o.some((l) => e.toLowerCase().endsWith(l.toLowerCase())) ? ["", ...o] : [...o, ""], i = /[\\/]/.test(e) ? [t] : [t, ...(P(n, "PATH") || "").split(";")];
292
- for (let l of i)
293
- for (let d of s) {
294
- let h = L.resolve(t, l.replace(/^"|"$/g, ""), e + d);
295
- try {
296
- if (ue.statSync(h).isFile())
297
- return h;
298
- } catch {}
299
- }
300
- }
301
- function he(e, n, t) {
302
- if (process.platform !== "win32")
303
- return _.spawn(e, n, t);
304
- let o = t.env || process.env, r = pe(e, o, t.cwd || process.cwd());
305
- if (r && /\.(?:exe|com)$/i.test(r))
306
- return _.spawn(r, n, t);
307
- let s = /\.(?:bat|cmd)$/i.test(r || e), i = [H(L.normalize(r || e))];
308
- for (let d of n)
309
- i.push(H(de(d), s ? 2 : 1));
310
- let l = i.join(" ");
311
- return _.spawn(P(o, "COMSPEC") || "cmd.exe", ["/d", "/v:off", "/s", "/c", `"${l}"`], { ...t, windowsVerbatimArguments: true });
312
- }
313
- W.exports = he;
314
- });
315
- var X = j(($e, F) => {
316
- var ge = __require("fs"), me = __require("os"), Q = __require("path"), ve = __require("child_process"), Ce = M(), R = N(), { optionsFromEnv: J } = k();
317
- function D() {
318
- console.log(["Usage: dotenv run [--help] [-q|--quiet] [--debug] [--override] [--fast] [-f|--file <paths>] [--] <command> [args...]", "", "Run a command with environment variables from a .env file.", "Place dotenv options before the command; all following arguments go to the command.", "", "Options:", " -f, --file <paths> .env paths, comma-separated or repeated (default: .env)", " -q, --quiet suppress the injected env message", " --debug enable debug logging", " --override override existing environment variables", " --fast use the faster character-scanner parser", "", "Environment variables (DOTENV_CONFIG_* names remain as fallbacks):", " DOTENV_PATH, DOTENV_ENCODING, DOTENV_QUIET,", " DOTENV_DEBUG, DOTENV_OVERRIDE,", " DOTENV_FAST"].join(`
319
- `));
320
- }
321
- function we(e) {
322
- let n = [], t = false, o, r, s, i, l = -1;
323
- for (let h = 0;h < e.length; h++) {
324
- let f = e[h];
325
- if (f === "--") {
326
- l = h + 1;
327
- break;
328
- }
329
- if (f === "--help" || f === "-h")
330
- return { help: true };
331
- if (f === "--quiet" || f === "-q") {
332
- o = true;
333
- continue;
334
- }
335
- if (f === "--debug") {
336
- r = true;
337
- continue;
338
- }
339
- if (f === "--override") {
340
- s = true;
341
- continue;
342
- }
343
- if (f === "--fast") {
344
- i = true;
345
- continue;
346
- }
347
- if (f === "-f" || f === "--file" || f.startsWith("-f=") || f.startsWith("--file=")) {
348
- let c = f.indexOf("="), a = c === -1 ? f : f.slice(0, c), g = c === -1 ? e[++h] : f.slice(c + 1);
349
- if (!g || g === "--")
350
- return { error: `${a} requires a path` };
351
- let p = g.split(",").map((y) => y.trim()).filter(Boolean);
352
- if (p.length === 0)
353
- return { error: `${a} requires a path` };
354
- n.push(...p), t = true;
355
- continue;
356
- }
357
- if (f.startsWith("-"))
358
- return { error: `unknown option: ${f}` };
359
- l = h;
360
- break;
361
- }
362
- let d = l === -1 ? [] : e.slice(l);
363
- return { paths: n, pathSet: t, quiet: o, debug: r, override: s, fast: i, command: d };
364
- }
365
- function Ae(e) {
366
- return e[0] === "~" ? Q.join(me.homedir(), e.slice(1)) : e;
367
- }
368
- function Ee(e) {
369
- let n = J(), t = { encoding: n.encoding || "utf8", quiet: n.quiet, debug: n.debug === true, override: n.override === true, fast: n.fast === true, paths: [".env"], defaultPath: true };
370
- return n.path && (t.paths = [n.path], t.defaultPath = false), e.pathSet && (t.paths = e.paths, t.defaultPath = false), e.quiet != null && (t.quiet = e.quiet), e.debug != null && (t.debug = e.debug), e.override != null && (t.override = e.override), e.fast != null && (t.fast = e.fast), t;
371
- }
372
- function be(e) {
373
- let n = {}, t = [], o = { override: e.override, debug: e.debug };
374
- for (let s of e.paths) {
375
- let i = Q.resolve(process.cwd(), Ae(s));
376
- try {
377
- let l = R.parse(ge.readFileSync(i, { encoding: e.encoding }), { fast: e.fast });
378
- R.populate(n, l, o), t.push(s);
379
- } catch (l) {
380
- if (e.debug && console.log(`\u2506 failed to load ${s} ${l.message}`), !(e.defaultPath && l.code === "ENOENT"))
381
- throw l;
382
- }
383
- }
384
- return { injected: R.populate(process.env, n, o), loadedPaths: t };
385
- }
386
- function K(e) {
387
- let n = e[0];
388
- if (n === "--help" || n === "-h") {
389
- D();
390
- return;
391
- }
392
- if (n !== "run") {
393
- D(), process.exitCode = 1;
394
- return;
395
- }
396
- let t = we(e.slice(1));
397
- if (t.help) {
398
- D();
399
- return;
400
- }
401
- if (t.error) {
402
- console.error(`dotenv: ${t.error}`), D(), process.exitCode = 1;
403
- return;
404
- }
405
- if (t.command.length === 0) {
406
- D(), process.exitCode = 1;
407
- return;
408
- }
409
- let o = Ee(t);
410
- try {
411
- let c = be(o);
412
- if (!(o.quiet == null ? J().quiet : o.quiet)) {
413
- let g = `\u25C7 injected env (${Object.keys(c.injected).length})`;
414
- c.loadedPaths.length > 0 && (g += ` from ${c.loadedPaths.join(", ")}`), console.error(g);
415
- }
416
- } catch (c) {
417
- console.error(`dotenv: ${c.message}`), process.exitCode = 1;
418
- return;
419
- }
420
- let r = !!process.stdin.isTTY, s = process.platform !== "win32" && !r, i = Ce(t.command[0], t.command.slice(1), { stdio: "inherit", detached: s }), l = new Map, d = 0;
421
- function h(c) {
422
- if (!(!i.pid || i.exitCode !== null || i.signalCode !== null)) {
423
- if (process.platform === "win32") {
424
- ve.spawnSync("taskkill", ["/pid", String(i.pid), "/T", "/F"], { stdio: "ignore" });
425
- return;
426
- }
427
- try {
428
- process.kill(s ? -i.pid : i.pid, c);
429
- } catch (a) {
430
- if (a.code !== "ESRCH")
431
- throw a;
432
- }
433
- }
434
- }
435
- function f() {
436
- for (let [c, a] of l)
437
- process.removeListener(c, a);
438
- }
439
- for (let c of ["SIGINT", "SIGTERM", "SIGHUP", "SIGQUIT"]) {
440
- let a = () => {
441
- if (c === "SIGINT") {
442
- if (d++, r && process.platform !== "win32" && d === 1)
443
- return;
444
- if (d > 1) {
445
- h(d === 2 ? "SIGTERM" : "SIGKILL");
446
- return;
447
- }
448
- }
449
- h(c);
450
- };
451
- l.set(c, a), process.on(c, a);
248
+ let c = new Error("OBJECT_REQUIRED: Please check the processEnv argument being passed to populate");
249
+ throw c.code = "OBJECT_REQUIRED", c;
452
250
  }
453
- i.on("error", function(c) {
454
- f(), console.error(`dotenv: ${c.message}`), process.exitCode = 1;
455
- }), i.on("exit", function(c, a) {
456
- f(), typeof c == "number" ? process.exit(c) : (setInterval(() => {}, 1000), process.kill(process.pid, a));
457
- });
458
- }
459
- F.exports = K;
460
- F === __require.main && K(process.argv.slice(2));
251
+ for (let c of Object.keys(n))
252
+ Object.prototype.hasOwnProperty.call(e, c) ? (o === true && (e[c] = n[c], i[c] = n[c]), r && v(o === true ? `"${c}" is already defined and WAS overwritten` : `"${c}" is already defined and was NOT overwritten`)) : (e[c] = n[c], i[c] = n[c]);
253
+ return i;
254
+ }
255
+ var A = { configDotenv: M, config: Y, parse: J, populate: z };
256
+ b.exports.configDotenv = A.configDotenv;
257
+ b.exports.config = A.config;
258
+ b.exports.parse = A.parse;
259
+ b.exports.populate = A.populate;
260
+ b.exports = A;
461
261
  });
462
- var S = N();
463
- var qe = X();
464
- module.exports = S;
465
- module.exports.config = S.config;
466
- module.exports.configDotenv = S.configDotenv;
467
- module.exports.parse = S.parse;
468
- module.exports.populate = S.populate;
262
+ var m = P();
263
+ module.exports = m;
264
+ module.exports.config = m.config;
265
+ module.exports.configDotenv = m.configDotenv;
266
+ module.exports.parse = m.parse;
267
+ module.exports.populate = m.populate;
469
268
  });
470
269
 
471
270
  // src/load-env.ts
@@ -6535,38 +6334,48 @@ var getCredentialLockPath = async (product, account) => {
6535
6334
  const key = createHash2("sha256").update(`${product}:${account}`).digest("hex");
6536
6335
  return join(await ensurePrivateCredentialLockDirectory(), `${key}.lock`);
6537
6336
  };
6337
+ var hasErrorCode = (cause, code) => cause instanceof Error && ("code" in cause) && cause.code === code;
6338
+ var createRefreshLockFile = async (path) => {
6339
+ const handle = await open2(path, "wx");
6340
+ const owner = randomUUID();
6341
+ try {
6342
+ await handle.writeFile(owner);
6343
+ } catch (cause) {
6344
+ await handle.close().catch(() => {
6345
+ return;
6346
+ });
6347
+ await unlink(path).catch(() => {
6348
+ return;
6349
+ });
6350
+ throw cause;
6351
+ }
6352
+ return { handle, owner };
6353
+ };
6354
+ var refreshLockVanished = async (path) => {
6355
+ try {
6356
+ const lock = await stat(path);
6357
+ if (Date.now() - lock.mtimeMs > refreshLockTimeoutMs) {
6358
+ throw new Error(`The CLI credential lock appears stale at ${path}. Ensure no CLI authentication command is running, remove that lock file, and retry.`);
6359
+ }
6360
+ } catch (statCause) {
6361
+ if (hasErrorCode(statCause, "ENOENT")) {
6362
+ return true;
6363
+ }
6364
+ throw statCause;
6365
+ }
6366
+ return false;
6367
+ };
6538
6368
  var acquireRefreshLock = async (path) => {
6539
6369
  const deadline = Date.now() + refreshLockTimeoutMs;
6540
6370
  while (Date.now() < deadline) {
6541
6371
  try {
6542
- const handle = await open2(path, "wx");
6543
- const owner = randomUUID();
6544
- try {
6545
- await handle.writeFile(owner);
6546
- } catch (cause) {
6547
- await handle.close().catch(() => {
6548
- return;
6549
- });
6550
- await unlink(path).catch(() => {
6551
- return;
6552
- });
6553
- throw cause;
6554
- }
6555
- return { handle, owner };
6372
+ return await createRefreshLockFile(path);
6556
6373
  } catch (cause) {
6557
- if (!(cause instanceof Error) || !("code" in cause) || cause.code !== "EEXIST") {
6374
+ if (!hasErrorCode(cause, "EEXIST")) {
6558
6375
  throw cause;
6559
6376
  }
6560
- try {
6561
- const lock = await stat(path);
6562
- if (Date.now() - lock.mtimeMs > refreshLockTimeoutMs) {
6563
- throw new Error(`The CLI credential lock appears stale at ${path}. Ensure no CLI authentication command is running, remove that lock file, and retry.`);
6564
- }
6565
- } catch (statCause) {
6566
- if (statCause instanceof Error && "code" in statCause && statCause.code === "ENOENT") {
6567
- continue;
6568
- }
6569
- throw statCause;
6377
+ if (await refreshLockVanished(path)) {
6378
+ continue;
6570
6379
  }
6571
6380
  await Bun.sleep(refreshLockRetryMs);
6572
6381
  }
@@ -6716,6 +6525,36 @@ var openSystemBrowser = async (url) => {
6716
6525
  return false;
6717
6526
  }
6718
6527
  };
6528
+ var persistLoginCredentials = async ({
6529
+ store,
6530
+ credentials,
6531
+ baseUrl,
6532
+ fetchImplementation
6533
+ }) => {
6534
+ try {
6535
+ await withCredentialLock(store, () => persistIssuedCredentials({
6536
+ store,
6537
+ credentials,
6538
+ apiBaseUrl: baseUrl,
6539
+ fetch: fetchImplementation,
6540
+ phase: "login"
6541
+ }));
6542
+ } catch (error) {
6543
+ if (error instanceof CliCredentialPersistenceError)
6544
+ throw error;
6545
+ throw new CliCredentialPersistenceError(await revokeIssuedCredentials(fetchImplementation, baseUrl, credentials), false, "login");
6546
+ }
6547
+ };
6548
+ var nextPollIntervalMs = (errorCode, intervalMs) => {
6549
+ if (errorCode === "authorization_pending")
6550
+ return intervalMs;
6551
+ if (errorCode === "slow_down")
6552
+ return intervalMs + 5000;
6553
+ if (errorCode === "access_denied") {
6554
+ throw new Error("CLI authentication was denied in the browser.");
6555
+ }
6556
+ throw new Error("CLI authentication expired. Run auth login again.");
6557
+ };
6719
6558
  var loginWithBrowser = async ({
6720
6559
  apiBaseUrl,
6721
6560
  clientName = hostname(),
@@ -6758,35 +6597,19 @@ var loginWithBrowser = async ({
6758
6597
  if (response.ok) {
6759
6598
  const issued = tokenResponseSchema.parse(payload);
6760
6599
  const credentials = toStoredCredentials(issued, baseUrl, now());
6761
- try {
6762
- await withCredentialLock(store, () => persistIssuedCredentials({
6763
- store,
6764
- credentials,
6765
- apiBaseUrl: baseUrl,
6766
- fetch: fetchImplementation,
6767
- phase: "login"
6768
- }));
6769
- } catch (error) {
6770
- if (error instanceof CliCredentialPersistenceError)
6771
- throw error;
6772
- throw new CliCredentialPersistenceError(await revokeIssuedCredentials(fetchImplementation, baseUrl, credentials), false, "login");
6773
- }
6600
+ await persistLoginCredentials({
6601
+ store,
6602
+ credentials,
6603
+ baseUrl,
6604
+ fetchImplementation
6605
+ });
6774
6606
  return credentials;
6775
6607
  }
6776
6608
  const error = deviceTokenErrorSchema.safeParse(payload);
6777
6609
  if (!error.success) {
6778
6610
  throw new Error(`CLI authentication failed with HTTP ${response.status}.`);
6779
6611
  }
6780
- if (error.data.error === "authorization_pending")
6781
- continue;
6782
- if (error.data.error === "slow_down") {
6783
- intervalMs += 5000;
6784
- continue;
6785
- }
6786
- if (error.data.error === "access_denied") {
6787
- throw new Error("CLI authentication was denied in the browser.");
6788
- }
6789
- throw new Error("CLI authentication expired. Run auth login again.");
6612
+ intervalMs = nextPollIntervalMs(error.data.error, intervalMs);
6790
6613
  }
6791
6614
  throw new Error("CLI authentication expired. Run auth login again.");
6792
6615
  };
@@ -6798,6 +6621,40 @@ var revokeIssuedCredentials = async (fetchImplementation, apiBaseUrl, credential
6798
6621
  return false;
6799
6622
  }
6800
6623
  };
6624
+ var restoreLoginSnapshot = async (store, credentials, current, prior) => {
6625
+ if (isDeepStrictEqual(current, prior))
6626
+ return true;
6627
+ if (current !== null && current.refreshToken !== credentials.refreshToken) {
6628
+ return false;
6629
+ }
6630
+ if (prior)
6631
+ await store.set(prior);
6632
+ else
6633
+ await store.delete();
6634
+ return isDeepStrictEqual(await store.get(), prior);
6635
+ };
6636
+ var removeRefreshedCredentials = async (store, current) => {
6637
+ if (current)
6638
+ await store.delete();
6639
+ return await store.get() === null;
6640
+ };
6641
+ var restoreLocalCredentials = async ({
6642
+ store,
6643
+ credentials,
6644
+ phase,
6645
+ prior
6646
+ }) => {
6647
+ try {
6648
+ const current = await store.get();
6649
+ if (phase === "login" && prior !== undefined) {
6650
+ return await restoreLoginSnapshot(store, credentials, current, prior);
6651
+ }
6652
+ if (phase === "refresh" && (!current || current.refreshToken === credentials.refreshToken || current.refreshToken === prior?.refreshToken)) {
6653
+ return await removeRefreshedCredentials(store, current);
6654
+ }
6655
+ } catch {}
6656
+ return false;
6657
+ };
6801
6658
  var persistIssuedCredentials = async ({
6802
6659
  store,
6803
6660
  credentials,
@@ -6817,25 +6674,12 @@ var persistIssuedCredentials = async ({
6817
6674
  return;
6818
6675
  } catch {
6819
6676
  const remoteRevoked = await revokeIssuedCredentials(fetchImplementation, apiBaseUrl, credentials);
6820
- let localRestored = false;
6821
- try {
6822
- const current = await store.get();
6823
- if (phase === "login" && prior !== undefined) {
6824
- if (isDeepStrictEqual(current, prior))
6825
- localRestored = true;
6826
- else if (current === null || current.refreshToken === credentials.refreshToken) {
6827
- if (prior)
6828
- await store.set(prior);
6829
- else
6830
- await store.delete();
6831
- localRestored = isDeepStrictEqual(await store.get(), prior);
6832
- }
6833
- } else if (phase === "refresh" && (!current || current.refreshToken === credentials.refreshToken || current.refreshToken === prior?.refreshToken)) {
6834
- if (current)
6835
- await store.delete();
6836
- localRestored = await store.get() === null;
6837
- }
6838
- } catch {}
6677
+ const localRestored = await restoreLocalCredentials({
6678
+ store,
6679
+ credentials,
6680
+ phase,
6681
+ prior
6682
+ });
6839
6683
  throw new CliCredentialPersistenceError(remoteRevoked, localRestored, phase);
6840
6684
  }
6841
6685
  };
@@ -6999,43 +6843,1473 @@ var DEPRECATED_EVENT_TYPES = [
6999
6843
  var activeEventTypeSchema = _enum(EventType).exclude(DEPRECATED_EVENT_TYPES);
7000
6844
  var ACTIVE_EVENT_TYPES = activeEventTypeSchema.options;
7001
6845
 
7002
- // src/api-client.ts
7003
- import {
7004
- createTRPCProxyClient,
7005
- httpBatchLink
7006
- } from "@trpc/client";
7007
- import SuperJSON from "superjson";
7008
-
7009
- // src/config.ts
7010
- var DEFAULT_EVENT_TECH_API_BASE_URL = "https://app.getout.events";
7011
-
7012
- class CliConfigurationError extends Error {
7013
- code = "CONFIGURATION";
7014
- constructor(message) {
7015
- super(message);
7016
- this.name = "CliConfigurationError";
6846
+ // ../../../node_modules/.bun/@trpc+server@11.25.2+aec250ebf9e68690/node_modules/@trpc/server/dist/observable-kpFFzvou.mjs
6847
+ function observable(subscribe) {
6848
+ const self = {
6849
+ subscribe(observer) {
6850
+ let teardownRef = null;
6851
+ let isDone = false;
6852
+ let unsubscribed = false;
6853
+ let teardownImmediately = false;
6854
+ let subscribing = true;
6855
+ let thrownWhileSubscribing = null;
6856
+ function end(notify) {
6857
+ try {
6858
+ notify();
6859
+ } catch (cause) {
6860
+ var _thrownWhileSubscribi;
6861
+ if (!subscribing)
6862
+ throw cause;
6863
+ (_thrownWhileSubscribi = thrownWhileSubscribing) !== null && _thrownWhileSubscribi !== undefined || (thrownWhileSubscribing = { cause });
6864
+ } finally {
6865
+ unsubscribe();
6866
+ }
6867
+ }
6868
+ function unsubscribe() {
6869
+ if (teardownRef === null) {
6870
+ teardownImmediately = true;
6871
+ return;
6872
+ }
6873
+ if (unsubscribed)
6874
+ return;
6875
+ unsubscribed = true;
6876
+ if (typeof teardownRef === "function")
6877
+ teardownRef();
6878
+ else if (teardownRef)
6879
+ teardownRef.unsubscribe();
6880
+ }
6881
+ teardownRef = subscribe({
6882
+ next(value) {
6883
+ var _observer$next;
6884
+ if (isDone)
6885
+ return;
6886
+ (_observer$next = observer.next) === null || _observer$next === undefined || _observer$next.call(observer, value);
6887
+ },
6888
+ error(err) {
6889
+ if (isDone)
6890
+ return;
6891
+ isDone = true;
6892
+ end(() => {
6893
+ var _observer$error;
6894
+ return (_observer$error = observer.error) === null || _observer$error === undefined ? undefined : _observer$error.call(observer, err);
6895
+ });
6896
+ },
6897
+ complete() {
6898
+ if (isDone)
6899
+ return;
6900
+ isDone = true;
6901
+ end(() => {
6902
+ var _observer$complete;
6903
+ return (_observer$complete = observer.complete) === null || _observer$complete === undefined ? undefined : _observer$complete.call(observer);
6904
+ });
6905
+ }
6906
+ });
6907
+ subscribing = false;
6908
+ if (teardownImmediately)
6909
+ unsubscribe();
6910
+ if (thrownWhileSubscribing)
6911
+ throw thrownWhileSubscribing.cause;
6912
+ return { unsubscribe };
6913
+ },
6914
+ pipe(...operations) {
6915
+ return operations.reduce(pipeReducer, self);
6916
+ }
6917
+ };
6918
+ return self;
6919
+ }
6920
+ function pipeReducer(prev, fn) {
6921
+ return fn(prev);
6922
+ }
6923
+ function observableToPromise(observable) {
6924
+ const ac = new AbortController;
6925
+ return new Promise((resolve, reject) => {
6926
+ let isDone = false;
6927
+ function onDone() {
6928
+ if (isDone)
6929
+ return;
6930
+ isDone = true;
6931
+ obs$.unsubscribe();
6932
+ }
6933
+ ac.signal.addEventListener("abort", () => {
6934
+ reject(ac.signal.reason);
6935
+ });
6936
+ const obs$ = observable.subscribe({
6937
+ next(data) {
6938
+ isDone = true;
6939
+ resolve(data);
6940
+ onDone();
6941
+ },
6942
+ error(data) {
6943
+ reject(data);
6944
+ },
6945
+ complete() {
6946
+ ac.abort();
6947
+ onDone();
6948
+ }
6949
+ });
6950
+ });
6951
+ }
6952
+ function observableToAsyncIterable(observable, signal) {
6953
+ const values = [];
6954
+ const pending = [];
6955
+ let error = null;
6956
+ let finished = false;
6957
+ let subscription = null;
6958
+ function unsubscribe() {
6959
+ if (finished)
6960
+ return null;
6961
+ finished = true;
6962
+ signal.removeEventListener("abort", abort);
6963
+ try {
6964
+ subscription === null || subscription === undefined || subscription.unsubscribe();
6965
+ return null;
6966
+ } catch (cause) {
6967
+ return { cause };
6968
+ }
7017
6969
  }
6970
+ function settle() {
6971
+ const first = error ? pending.shift() : undefined;
6972
+ if (error && first) {
6973
+ const { cause } = error;
6974
+ error = null;
6975
+ first.reject(cause);
6976
+ }
6977
+ for (const promise of pending.splice(0))
6978
+ promise.resolve({
6979
+ value: undefined,
6980
+ done: true
6981
+ });
6982
+ }
6983
+ function finish() {
6984
+ const failure = unsubscribe();
6985
+ settle();
6986
+ if (failure)
6987
+ throw failure.cause;
6988
+ }
6989
+ function abort() {
6990
+ const failure = unsubscribe();
6991
+ if (failure)
6992
+ error = failure;
6993
+ settle();
6994
+ }
6995
+ subscription = observable.subscribe({
6996
+ next(value) {
6997
+ if (finished)
6998
+ return;
6999
+ const promise = pending.shift();
7000
+ if (promise)
7001
+ promise.resolve({
7002
+ value,
7003
+ done: false
7004
+ });
7005
+ else
7006
+ values.push(value);
7007
+ },
7008
+ error(cause) {
7009
+ if (finished)
7010
+ return;
7011
+ error = { cause };
7012
+ finish();
7013
+ },
7014
+ complete: finish
7015
+ });
7016
+ if (finished)
7017
+ subscription.unsubscribe();
7018
+ else if (signal.aborted)
7019
+ abort();
7020
+ else
7021
+ signal.addEventListener("abort", abort, { once: true });
7022
+ const iterator = {
7023
+ [Symbol.asyncIterator]() {
7024
+ return iterator;
7025
+ },
7026
+ async next() {
7027
+ if (values.length > 0)
7028
+ return {
7029
+ value: values.shift(),
7030
+ done: false
7031
+ };
7032
+ if (error) {
7033
+ const { cause } = error;
7034
+ error = null;
7035
+ throw cause;
7036
+ }
7037
+ if (finished)
7038
+ return {
7039
+ value: undefined,
7040
+ done: true
7041
+ };
7042
+ return new Promise((resolve, reject) => {
7043
+ pending.push({
7044
+ resolve,
7045
+ reject
7046
+ });
7047
+ });
7048
+ },
7049
+ async return() {
7050
+ values.length = 0;
7051
+ error = null;
7052
+ finish();
7053
+ return {
7054
+ value: undefined,
7055
+ done: true
7056
+ };
7057
+ }
7058
+ };
7059
+ return iterator;
7018
7060
  }
7019
- var normalizeApiBaseUrl = (value) => {
7020
- let url;
7061
+
7062
+ // ../../../node_modules/.bun/@trpc+server@11.25.2+aec250ebf9e68690/node_modules/@trpc/server/dist/observable-Cmd1MFy3.mjs
7063
+ function share(_opts) {
7064
+ return (source) => {
7065
+ let refCount = 0;
7066
+ let subscription = null;
7067
+ let isConnecting = false;
7068
+ let observers = /* @__PURE__ */ new Set;
7069
+ function startIfNeeded() {
7070
+ if (subscription || isConnecting)
7071
+ return;
7072
+ isConnecting = true;
7073
+ let isDone = false;
7074
+ let sourceSubscription;
7075
+ try {
7076
+ sourceSubscription = source.subscribe({
7077
+ next(value) {
7078
+ notify(observers, (observer) => {
7079
+ var _observer$next;
7080
+ return (_observer$next = observer.next) === null || _observer$next === undefined ? undefined : _observer$next.call(observer, value);
7081
+ });
7082
+ },
7083
+ error(error) {
7084
+ isDone = true;
7085
+ terminate((observer) => {
7086
+ var _observer$error;
7087
+ return (_observer$error = observer.error) === null || _observer$error === undefined ? undefined : _observer$error.call(observer, error);
7088
+ });
7089
+ },
7090
+ complete() {
7091
+ isDone = true;
7092
+ terminate((observer) => {
7093
+ var _observer$complete;
7094
+ return (_observer$complete = observer.complete) === null || _observer$complete === undefined ? undefined : _observer$complete.call(observer);
7095
+ });
7096
+ }
7097
+ });
7098
+ } finally {
7099
+ isConnecting = false;
7100
+ }
7101
+ if (isDone)
7102
+ sourceSubscription.unsubscribe();
7103
+ else
7104
+ subscription = sourceSubscription;
7105
+ }
7106
+ function notify(targets, callback) {
7107
+ for (const observer of [...targets])
7108
+ if (targets.has(observer))
7109
+ callback(observer);
7110
+ }
7111
+ function terminate(callback) {
7112
+ const _sub = subscription;
7113
+ const terminatedObservers = observers;
7114
+ subscription = null;
7115
+ observers = /* @__PURE__ */ new Set;
7116
+ isConnecting = false;
7117
+ try {
7118
+ notify(terminatedObservers, callback);
7119
+ } finally {
7120
+ _sub === null || _sub === undefined || _sub.unsubscribe();
7121
+ }
7122
+ }
7123
+ function resetSource() {
7124
+ const _sub = subscription;
7125
+ subscription = null;
7126
+ _sub === null || _sub === undefined || _sub.unsubscribe();
7127
+ }
7128
+ function resetIfNeeded() {
7129
+ if (refCount === 0 && subscription)
7130
+ resetSource();
7131
+ }
7132
+ return observable((subscriber) => {
7133
+ refCount++;
7134
+ const subscriberObservers = observers;
7135
+ subscriberObservers.add(subscriber);
7136
+ startIfNeeded();
7137
+ return { unsubscribe() {
7138
+ refCount--;
7139
+ resetIfNeeded();
7140
+ subscriberObservers.delete(subscriber);
7141
+ } };
7142
+ });
7143
+ };
7144
+ }
7145
+ var distinctUnsetMarker = Symbol();
7146
+ function callObserver(callback) {
7021
7147
  try {
7022
- url = new URL(value);
7023
- } catch {
7024
- throw new CliConfigurationError("Event Tech API URL must be a valid URL.");
7025
- }
7026
- const isLocalHttp = url.protocol === "http:" && (url.hostname === "localhost" || url.hostname === "127.0.0.1");
7027
- if (url.protocol !== "https:" && !isLocalHttp) {
7028
- throw new CliConfigurationError("Event Tech API URL must use HTTPS, except for localhost development.");
7148
+ callback();
7149
+ } catch (error) {
7150
+ setTimeout(() => {
7151
+ throw error;
7152
+ });
7029
7153
  }
7030
- url.pathname = url.pathname.replace(/\/$/, "");
7031
- return url.toString().replace(/\/$/, "");
7032
- };
7154
+ }
7155
+ function behaviorSubject(initialValue) {
7156
+ let value = initialValue;
7157
+ const observerList = /* @__PURE__ */ new Set;
7158
+ const addObserver = (observer) => {
7159
+ if (value !== undefined)
7160
+ observer.next(value);
7161
+ observerList.add(observer);
7162
+ };
7163
+ const removeObserver = (observer) => {
7164
+ observerList.delete(observer);
7165
+ };
7166
+ const obs = observable((observer) => {
7167
+ addObserver(observer);
7168
+ return () => {
7169
+ removeObserver(observer);
7170
+ };
7171
+ });
7172
+ obs.next = (nextValue) => {
7173
+ if (value === nextValue)
7174
+ return;
7175
+ value = nextValue;
7176
+ for (const observer of [...observerList])
7177
+ if (observerList.has(observer))
7178
+ callObserver(() => observer.next(nextValue));
7179
+ };
7180
+ obs.get = () => value;
7181
+ return obs;
7182
+ }
7033
7183
 
7034
- // src/api-client.ts
7035
- var createEventTechClient = (apiBaseUrl, readAccessToken, fetchImplementation = fetch) => createTRPCProxyClient({
7036
- links: [
7037
- httpBatchLink({
7038
- url: `${apiBaseUrl}/api/trpc`,
7184
+ // ../../../node_modules/.bun/@trpc+client@11.25.2+73a9f6e6dedcb27f/node_modules/@trpc/client/dist/splitLink-DcpFI5s5.mjs
7185
+ function createChain(opts) {
7186
+ return observable((observer) => {
7187
+ function execute(index = 0, op = opts.op) {
7188
+ const next = opts.links[index];
7189
+ if (!next)
7190
+ throw new Error("No more links to execute - did you forget to add an ending link?");
7191
+ return next({
7192
+ op,
7193
+ next(nextOp) {
7194
+ return execute(index + 1, nextOp);
7195
+ }
7196
+ });
7197
+ }
7198
+ return execute().subscribe(observer);
7199
+ });
7200
+ }
7201
+
7202
+ // ../../../node_modules/.bun/@trpc+client@11.25.2+73a9f6e6dedcb27f/node_modules/@trpc/client/dist/objectSpread2-weooBxVk.mjs
7203
+ function _typeof(o) {
7204
+ "@babel/helpers - typeof";
7205
+ return _typeof = typeof Symbol == "function" && typeof Symbol.iterator == "symbol" ? function(o) {
7206
+ return typeof o;
7207
+ } : function(o) {
7208
+ return o && typeof Symbol == "function" && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o;
7209
+ }, _typeof(o);
7210
+ }
7211
+ function toPrimitive(t, r) {
7212
+ if (_typeof(t) != "object" || !t)
7213
+ return t;
7214
+ var e = t[Symbol.toPrimitive];
7215
+ if (e !== undefined) {
7216
+ var i = e.call(t, r || "default");
7217
+ if (_typeof(i) != "object")
7218
+ return i;
7219
+ throw new TypeError("@@toPrimitive must return a primitive value.");
7220
+ }
7221
+ return (r === "string" ? String : Number)(t);
7222
+ }
7223
+ function toPropertyKey(t) {
7224
+ var i = toPrimitive(t, "string");
7225
+ return _typeof(i) == "symbol" ? i : i + "";
7226
+ }
7227
+ function _defineProperty(e, r, t) {
7228
+ return (r = toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
7229
+ value: t,
7230
+ enumerable: true,
7231
+ configurable: true,
7232
+ writable: true
7233
+ }) : e[r] = t, e;
7234
+ }
7235
+ function ownKeys(e, r) {
7236
+ var t = Object.keys(e);
7237
+ if (Object.getOwnPropertySymbols) {
7238
+ var o = Object.getOwnPropertySymbols(e);
7239
+ r && (o = o.filter(function(r) {
7240
+ return Object.getOwnPropertyDescriptor(e, r).enumerable;
7241
+ })), t.push.apply(t, o);
7242
+ }
7243
+ return t;
7244
+ }
7245
+ function _objectSpread2(e) {
7246
+ for (var r = 1;r < arguments.length; r++) {
7247
+ var t = arguments[r] != null ? arguments[r] : {};
7248
+ r % 2 ? ownKeys(Object(t), true).forEach(function(r) {
7249
+ _defineProperty(e, r, t[r]);
7250
+ }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function(r) {
7251
+ Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r));
7252
+ });
7253
+ }
7254
+ return e;
7255
+ }
7256
+
7257
+ // ../../../node_modules/.bun/@trpc+server@11.25.2+aec250ebf9e68690/node_modules/@trpc/server/dist/codes-nbrm_zWY.mjs
7258
+ function isObject2(value) {
7259
+ return !!value && !Array.isArray(value) && typeof value === "object";
7260
+ }
7261
+ function emptyObject() {
7262
+ return Object.create(null);
7263
+ }
7264
+ var TRPC_ERROR_CODES_BY_KEY = {
7265
+ PARSE_ERROR: -32700,
7266
+ BAD_REQUEST: -32600,
7267
+ INTERNAL_SERVER_ERROR: -32603,
7268
+ NOT_IMPLEMENTED: -32603,
7269
+ BAD_GATEWAY: -32603,
7270
+ SERVICE_UNAVAILABLE: -32603,
7271
+ GATEWAY_TIMEOUT: -32603,
7272
+ UNAUTHORIZED: -32001,
7273
+ PAYMENT_REQUIRED: -32002,
7274
+ FORBIDDEN: -32003,
7275
+ NOT_FOUND: -32004,
7276
+ METHOD_NOT_SUPPORTED: -32005,
7277
+ TIMEOUT: -32008,
7278
+ CONFLICT: -32009,
7279
+ PRECONDITION_FAILED: -32012,
7280
+ PAYLOAD_TOO_LARGE: -32013,
7281
+ UNSUPPORTED_MEDIA_TYPE: -32015,
7282
+ UNPROCESSABLE_CONTENT: -32022,
7283
+ PRECONDITION_REQUIRED: -32028,
7284
+ TOO_MANY_REQUESTS: -32029,
7285
+ CLIENT_CLOSED_REQUEST: -32099
7286
+ };
7287
+ var retryableRpcCodes = [
7288
+ TRPC_ERROR_CODES_BY_KEY.BAD_GATEWAY,
7289
+ TRPC_ERROR_CODES_BY_KEY.SERVICE_UNAVAILABLE,
7290
+ TRPC_ERROR_CODES_BY_KEY.GATEWAY_TIMEOUT,
7291
+ TRPC_ERROR_CODES_BY_KEY.INTERNAL_SERVER_ERROR
7292
+ ];
7293
+
7294
+ // ../../../node_modules/.bun/@trpc+server@11.25.2+aec250ebf9e68690/node_modules/@trpc/server/dist/getErrorShape-B5jPKHJ3.mjs
7295
+ var noop = () => {};
7296
+ var freezeIfAvailable = (obj) => {
7297
+ if (Object.freeze)
7298
+ Object.freeze(obj);
7299
+ };
7300
+ function createInnerProxy(callback, path, memo) {
7301
+ var _memo$cacheKey;
7302
+ const cacheKey = path.join(".");
7303
+ (_memo$cacheKey = memo[cacheKey]) !== null && _memo$cacheKey !== undefined || (memo[cacheKey] = new Proxy(noop, {
7304
+ get(_obj, key) {
7305
+ if (typeof key !== "string" || key === "then")
7306
+ return;
7307
+ return createInnerProxy(callback, [...path, key], memo);
7308
+ },
7309
+ apply(_1, _2, args) {
7310
+ const lastOfPath = path[path.length - 1];
7311
+ if (lastOfPath === "valueOf" || lastOfPath === "toString" || lastOfPath === "toJSON")
7312
+ return `tRPC.proxy(${path.slice(0, -1).join(".")})`;
7313
+ let opts = {
7314
+ args,
7315
+ path
7316
+ };
7317
+ if (lastOfPath === "call")
7318
+ opts = {
7319
+ args: args.length >= 2 ? [args[1]] : [],
7320
+ path: path.slice(0, -1)
7321
+ };
7322
+ else if (lastOfPath === "apply")
7323
+ opts = {
7324
+ args: args.length >= 2 ? args[1] : [],
7325
+ path: path.slice(0, -1)
7326
+ };
7327
+ freezeIfAvailable(opts.args);
7328
+ freezeIfAvailable(opts.path);
7329
+ return callback(opts);
7330
+ }
7331
+ }));
7332
+ return memo[cacheKey];
7333
+ }
7334
+ var createRecursiveProxy = (callback) => createInnerProxy(callback, [], emptyObject());
7335
+ var createFlatProxy = (callback) => {
7336
+ return new Proxy(noop, { get(_obj, name) {
7337
+ if (name === "then")
7338
+ return;
7339
+ return callback(name);
7340
+ } });
7341
+ };
7342
+ var formattedShapeSymbol = Symbol("trpc_formattedErrorShape");
7343
+ function _typeof2(o) {
7344
+ "@babel/helpers - typeof";
7345
+ return _typeof2 = typeof Symbol == "function" && typeof Symbol.iterator == "symbol" ? function(o) {
7346
+ return typeof o;
7347
+ } : function(o) {
7348
+ return o && typeof Symbol == "function" && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o;
7349
+ }, _typeof2(o);
7350
+ }
7351
+ function toPrimitive2(t, r) {
7352
+ if (_typeof2(t) != "object" || !t)
7353
+ return t;
7354
+ var e = t[Symbol.toPrimitive];
7355
+ if (e !== undefined) {
7356
+ var i = e.call(t, r || "default");
7357
+ if (_typeof2(i) != "object")
7358
+ return i;
7359
+ throw new TypeError("@@toPrimitive must return a primitive value.");
7360
+ }
7361
+ return (r === "string" ? String : Number)(t);
7362
+ }
7363
+ function toPropertyKey2(t) {
7364
+ var i = toPrimitive2(t, "string");
7365
+ return _typeof2(i) == "symbol" ? i : i + "";
7366
+ }
7367
+ function _defineProperty2(e, r, t) {
7368
+ return (r = toPropertyKey2(r)) in e ? Object.defineProperty(e, r, {
7369
+ value: t,
7370
+ enumerable: true,
7371
+ configurable: true,
7372
+ writable: true
7373
+ }) : e[r] = t, e;
7374
+ }
7375
+ function ownKeys2(e, r) {
7376
+ var t = Object.keys(e);
7377
+ if (Object.getOwnPropertySymbols) {
7378
+ var o = Object.getOwnPropertySymbols(e);
7379
+ r && (o = o.filter(function(r) {
7380
+ return Object.getOwnPropertyDescriptor(e, r).enumerable;
7381
+ })), t.push.apply(t, o);
7382
+ }
7383
+ return t;
7384
+ }
7385
+ function _objectSpread22(e) {
7386
+ for (var r = 1;r < arguments.length; r++) {
7387
+ var t = arguments[r] != null ? arguments[r] : {};
7388
+ r % 2 ? ownKeys2(Object(t), true).forEach(function(r) {
7389
+ _defineProperty2(e, r, t[r]);
7390
+ }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys2(Object(t)).forEach(function(r) {
7391
+ Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r));
7392
+ });
7393
+ }
7394
+ return e;
7395
+ }
7396
+
7397
+ // ../../../node_modules/.bun/@trpc+server@11.25.2+aec250ebf9e68690/node_modules/@trpc/server/dist/asyncGeneratorDelegate-JWx0LJUD.mjs
7398
+ function transformResultInner(response, transformer) {
7399
+ if ("error" in response) {
7400
+ const error = transformer.deserialize(response.error);
7401
+ return {
7402
+ ok: false,
7403
+ error: _objectSpread22(_objectSpread22({}, response), {}, { error })
7404
+ };
7405
+ }
7406
+ return {
7407
+ ok: true,
7408
+ result: _objectSpread22(_objectSpread22({}, response.result), (!response.result.type || response.result.type === "data") && {
7409
+ type: "data",
7410
+ data: transformer.deserialize(response.result.data)
7411
+ })
7412
+ };
7413
+ }
7414
+ var TransformResultError = class extends Error {
7415
+ constructor() {
7416
+ super("Unable to transform response from server");
7417
+ }
7418
+ };
7419
+ function transformResult(response, transformer) {
7420
+ let result;
7421
+ try {
7422
+ result = transformResultInner(response, transformer);
7423
+ } catch (_unused) {
7424
+ throw new TransformResultError;
7425
+ }
7426
+ if (!result.ok && (!isObject2(result.error.error) || typeof result.error.error["code"] !== "number"))
7427
+ throw new TransformResultError;
7428
+ if (result.ok && !isObject2(result.result))
7429
+ throw new TransformResultError;
7430
+ return result;
7431
+ }
7432
+ function resolvePathSeparator(value) {
7433
+ return value !== null && value !== undefined ? value : ".";
7434
+ }
7435
+ function procedurePathToURLPath(path, separator) {
7436
+ if (separator === ".")
7437
+ return path;
7438
+ return path.split(".").join(separator);
7439
+ }
7440
+ function _OverloadYield(e, d) {
7441
+ this.v = e, this.k = d;
7442
+ }
7443
+ function AsyncGenerator(e) {
7444
+ var r, t;
7445
+ function resume(r, t) {
7446
+ try {
7447
+ var n = e[r](t), o = n.value, u = o instanceof _OverloadYield;
7448
+ Promise.resolve(u ? o.v : o).then(function(t) {
7449
+ if (u) {
7450
+ var i = r === "return" ? "return" : "next";
7451
+ if (!o.k || t.done)
7452
+ return resume(i, t);
7453
+ t = e[i](t).value;
7454
+ }
7455
+ settle(n.done ? "return" : "normal", t);
7456
+ }, function(e) {
7457
+ resume("throw", e);
7458
+ });
7459
+ } catch (e) {
7460
+ settle("throw", e);
7461
+ }
7462
+ }
7463
+ function settle(e, n) {
7464
+ switch (e) {
7465
+ case "return":
7466
+ r.resolve({
7467
+ value: n,
7468
+ done: true
7469
+ });
7470
+ break;
7471
+ case "throw":
7472
+ r.reject(n);
7473
+ break;
7474
+ default:
7475
+ r.resolve({
7476
+ value: n,
7477
+ done: false
7478
+ });
7479
+ }
7480
+ (r = r.next) ? resume(r.key, r.arg) : t = null;
7481
+ }
7482
+ this._invoke = function(e, n) {
7483
+ return new Promise(function(o, u) {
7484
+ var i = {
7485
+ key: e,
7486
+ arg: n,
7487
+ resolve: o,
7488
+ reject: u,
7489
+ next: null
7490
+ };
7491
+ t ? t = t.next = i : (r = t = i, resume(e, n));
7492
+ });
7493
+ }, typeof e["return"] != "function" && (this["return"] = undefined);
7494
+ }
7495
+ AsyncGenerator.prototype[typeof Symbol == "function" && Symbol.asyncIterator || "@@asyncIterator"] = function() {
7496
+ return this;
7497
+ }, AsyncGenerator.prototype.next = function(e) {
7498
+ return this._invoke("next", e);
7499
+ }, AsyncGenerator.prototype["throw"] = function(e) {
7500
+ return this._invoke("throw", e);
7501
+ }, AsyncGenerator.prototype["return"] = function(e) {
7502
+ return this._invoke("return", e);
7503
+ };
7504
+ var trackedSymbol = Symbol();
7505
+
7506
+ // ../../../node_modules/.bun/@trpc+client@11.25.2+73a9f6e6dedcb27f/node_modules/@trpc/client/dist/TRPCClientError-Byo7P4QG.mjs
7507
+ function isTRPCClientError(cause) {
7508
+ return cause instanceof TRPCClientError;
7509
+ }
7510
+ function isTRPCErrorResponse(obj) {
7511
+ return isObject2(obj) && isObject2(obj["error"]) && typeof obj["error"]["code"] === "number" && typeof obj["error"]["message"] === "string";
7512
+ }
7513
+ function getMessageFromUnknownError(err, fallback) {
7514
+ if (typeof err === "string")
7515
+ return err;
7516
+ if (isObject2(err) && typeof err["message"] === "string")
7517
+ return err["message"];
7518
+ return fallback;
7519
+ }
7520
+ var TRPCClientError = class TRPCClientError extends Error {
7521
+ constructor(message, opts) {
7522
+ var _opts$result, _opts$result2;
7523
+ const cause = opts === null || opts === undefined ? undefined : opts.cause;
7524
+ super(message, { cause });
7525
+ _defineProperty(this, "cause", undefined);
7526
+ _defineProperty(this, "shape", undefined);
7527
+ _defineProperty(this, "data", undefined);
7528
+ _defineProperty(this, "meta", undefined);
7529
+ this.meta = opts === null || opts === undefined ? undefined : opts.meta;
7530
+ this.cause = cause;
7531
+ this.shape = opts === null || opts === undefined || (_opts$result = opts.result) === null || _opts$result === undefined ? undefined : _opts$result.error;
7532
+ this.data = opts === null || opts === undefined || (_opts$result2 = opts.result) === null || _opts$result2 === undefined ? undefined : _opts$result2.error.data;
7533
+ this.name = "TRPCClientError";
7534
+ Object.setPrototypeOf(this, TRPCClientError.prototype);
7535
+ }
7536
+ static from(_cause, opts = {}) {
7537
+ const cause = _cause;
7538
+ if (isTRPCClientError(cause)) {
7539
+ if (opts.meta)
7540
+ cause.meta = _objectSpread2(_objectSpread2({}, cause.meta), opts.meta);
7541
+ return cause;
7542
+ }
7543
+ if (isTRPCErrorResponse(cause))
7544
+ return new TRPCClientError(cause.error.message, _objectSpread2(_objectSpread2({}, opts), {}, {
7545
+ result: cause,
7546
+ cause: opts.cause
7547
+ }));
7548
+ return new TRPCClientError(getMessageFromUnknownError(cause, "Unknown error"), _objectSpread2(_objectSpread2({}, opts), {}, { cause }));
7549
+ }
7550
+ };
7551
+
7552
+ // ../../../node_modules/.bun/@trpc+client@11.25.2+73a9f6e6dedcb27f/node_modules/@trpc/client/dist/unstable-internals.mjs
7553
+ function getTransformer(transformer) {
7554
+ const _transformer = transformer;
7555
+ if (!_transformer)
7556
+ return {
7557
+ input: {
7558
+ serialize: (data) => data,
7559
+ deserialize: (data) => data
7560
+ },
7561
+ output: {
7562
+ serialize: (data) => data,
7563
+ deserialize: (data) => data
7564
+ }
7565
+ };
7566
+ if ("input" in _transformer)
7567
+ return _transformer;
7568
+ return {
7569
+ input: _transformer,
7570
+ output: _transformer
7571
+ };
7572
+ }
7573
+
7574
+ // ../../../node_modules/.bun/@trpc+client@11.25.2+73a9f6e6dedcb27f/node_modules/@trpc/client/dist/httpUtils-5Hmhcy-z.mjs
7575
+ var isFunction2 = (fn) => typeof fn === "function";
7576
+ function getFetch(customFetchImpl) {
7577
+ if (customFetchImpl)
7578
+ return customFetchImpl;
7579
+ if (typeof window !== "undefined" && isFunction2(window.fetch))
7580
+ return window.fetch.bind(window);
7581
+ if (typeof globalThis !== "undefined" && isFunction2(globalThis.fetch))
7582
+ return globalThis.fetch;
7583
+ throw new Error("No fetch implementation found");
7584
+ }
7585
+ function allAbortSignals(...signals) {
7586
+ const ac = new AbortController;
7587
+ const count = signals.length;
7588
+ let abortedCount = 0;
7589
+ const onAbort = () => {
7590
+ if (++abortedCount === count)
7591
+ ac.abort();
7592
+ };
7593
+ for (const signal of signals)
7594
+ if (signal === null || signal === undefined ? undefined : signal.aborted)
7595
+ onAbort();
7596
+ else
7597
+ signal === null || signal === undefined || signal.addEventListener("abort", onAbort, { once: true });
7598
+ return ac.signal;
7599
+ }
7600
+ function raceAbortSignalsWithCleanup(...signals) {
7601
+ const ac = new AbortController;
7602
+ const cleanup = () => {
7603
+ for (const signal of signals)
7604
+ signal === null || signal === undefined || signal.removeEventListener("abort", onAbort);
7605
+ };
7606
+ const onAbort = () => {
7607
+ cleanup();
7608
+ ac.abort();
7609
+ };
7610
+ for (const signal of signals) {
7611
+ if (signal === null || signal === undefined ? undefined : signal.aborted) {
7612
+ onAbort();
7613
+ break;
7614
+ }
7615
+ signal === null || signal === undefined || signal.addEventListener("abort", onAbort, { once: true });
7616
+ }
7617
+ return {
7618
+ signal: ac.signal,
7619
+ cleanup
7620
+ };
7621
+ }
7622
+ function resolveHTTPLinkOptions(opts) {
7623
+ return {
7624
+ url: opts.url.toString(),
7625
+ fetch: opts.fetch,
7626
+ transformer: getTransformer(opts.transformer),
7627
+ methodOverride: opts.methodOverride,
7628
+ pathSeparator: resolvePathSeparator(opts.pathSeparator)
7629
+ };
7630
+ }
7631
+ function arrayToDict(array) {
7632
+ const dict = {};
7633
+ for (let index = 0;index < array.length; index++) {
7634
+ const element = array[index];
7635
+ dict[index] = element;
7636
+ }
7637
+ return dict;
7638
+ }
7639
+ var METHOD = {
7640
+ query: "GET",
7641
+ mutation: "POST",
7642
+ subscription: "PATCH"
7643
+ };
7644
+ function getInput(opts) {
7645
+ return "input" in opts ? opts.transformer.input.serialize(opts.input) : arrayToDict(opts.inputs.map((_input) => opts.transformer.input.serialize(_input)));
7646
+ }
7647
+ var getUrl = (opts) => {
7648
+ const parts = opts.url.split("?");
7649
+ let url = parts[0].replace(/\/$/, "") + "/" + procedurePathToURLPath(opts.path, opts.pathSeparator);
7650
+ const queryParts = [];
7651
+ if (parts[1])
7652
+ queryParts.push(parts[1]);
7653
+ if ("inputs" in opts)
7654
+ queryParts.push("batch=1");
7655
+ if (opts.type === "query" || opts.type === "subscription") {
7656
+ const input = getInput(opts);
7657
+ if (input !== undefined && opts.methodOverride !== "POST")
7658
+ queryParts.push(`input=${encodeURIComponent(JSON.stringify(input))}`);
7659
+ }
7660
+ if (queryParts.length)
7661
+ url += "?" + queryParts.join("&");
7662
+ return url;
7663
+ };
7664
+ var getBody = (opts) => {
7665
+ if (opts.type === "query" && opts.methodOverride !== "POST")
7666
+ return;
7667
+ const input = getInput(opts);
7668
+ return input !== undefined ? JSON.stringify(input) : undefined;
7669
+ };
7670
+ var jsonHttpRequester = (opts) => {
7671
+ return httpRequest(_objectSpread2(_objectSpread2({}, opts), {}, {
7672
+ contentTypeHeader: "application/json",
7673
+ getUrl,
7674
+ getBody
7675
+ }));
7676
+ };
7677
+ var AbortError = class extends Error {
7678
+ constructor() {
7679
+ const name = "AbortError";
7680
+ super(name);
7681
+ this.name = name;
7682
+ this.message = name;
7683
+ }
7684
+ };
7685
+ var throwIfAborted = (signal) => {
7686
+ var _signal$throwIfAborte;
7687
+ if (!(signal === null || signal === undefined ? undefined : signal.aborted))
7688
+ return;
7689
+ (_signal$throwIfAborte = signal.throwIfAborted) === null || _signal$throwIfAborte === undefined || _signal$throwIfAborte.call(signal);
7690
+ if (typeof DOMException !== "undefined")
7691
+ throw new DOMException("AbortError", "AbortError");
7692
+ throw new AbortError;
7693
+ };
7694
+ async function fetchHTTPResponse(opts) {
7695
+ var _opts$methodOverride, _opts$trpcAcceptHeade;
7696
+ throwIfAborted(opts.signal);
7697
+ const url = opts.getUrl(opts);
7698
+ const body = opts.getBody(opts);
7699
+ const method = (_opts$methodOverride = opts.methodOverride) !== null && _opts$methodOverride !== undefined ? _opts$methodOverride : METHOD[opts.type];
7700
+ const resolvedHeaders = await (async () => {
7701
+ const heads = await opts.headers();
7702
+ if (Symbol.iterator in heads)
7703
+ return Object.fromEntries(heads);
7704
+ return heads;
7705
+ })();
7706
+ const hasContentType = Object.keys(resolvedHeaders).some((key) => key.toLowerCase() === "content-type");
7707
+ const headers = _objectSpread2(_objectSpread2(_objectSpread2({}, opts.contentTypeHeader && method !== "GET" && !hasContentType ? { "content-type": opts.contentTypeHeader } : {}), opts.trpcAcceptHeader ? { [(_opts$trpcAcceptHeade = opts.trpcAcceptHeaderKey) !== null && _opts$trpcAcceptHeade !== undefined ? _opts$trpcAcceptHeade : "trpc-accept"]: opts.trpcAcceptHeader } : undefined), resolvedHeaders);
7708
+ return getFetch(opts.fetch)(url, {
7709
+ method,
7710
+ signal: opts.signal,
7711
+ body,
7712
+ headers
7713
+ });
7714
+ }
7715
+ async function httpRequest(opts) {
7716
+ const meta = {};
7717
+ const res = await fetchHTTPResponse(opts);
7718
+ meta.response = res;
7719
+ const json = await res.json();
7720
+ meta.responseJSON = json;
7721
+ return {
7722
+ json,
7723
+ meta
7724
+ };
7725
+ }
7726
+
7727
+ // ../../../node_modules/.bun/@trpc+client@11.25.2+73a9f6e6dedcb27f/node_modules/@trpc/client/dist/httpBatchLink-aPx7u_sr.mjs
7728
+ var throwFatalError = () => {
7729
+ throw new Error("Something went wrong. Please submit an issue at https://github.com/trpc/trpc/issues/new");
7730
+ };
7731
+ function dataLoader(batchLoader) {
7732
+ let pendingItems = null;
7733
+ let dispatchTimer = null;
7734
+ const destroyTimerAndPendingItems = () => {
7735
+ clearTimeout(dispatchTimer);
7736
+ dispatchTimer = null;
7737
+ pendingItems = null;
7738
+ };
7739
+ function groupItems(items) {
7740
+ const groupedItems = [[]];
7741
+ let index = 0;
7742
+ while (true) {
7743
+ const item = items[index];
7744
+ if (!item)
7745
+ break;
7746
+ const lastGroup = groupedItems[groupedItems.length - 1];
7747
+ if (item.aborted) {
7748
+ var _item$reject;
7749
+ (_item$reject = item.reject) === null || _item$reject === undefined || _item$reject.call(item, /* @__PURE__ */ new Error("Aborted"));
7750
+ index++;
7751
+ continue;
7752
+ }
7753
+ let isValid;
7754
+ try {
7755
+ isValid = batchLoader.validate(lastGroup.concat(item).map((it) => it.key));
7756
+ } catch (cause) {
7757
+ var _item$reject2;
7758
+ (_item$reject2 = item.reject) === null || _item$reject2 === undefined || _item$reject2.call(item, cause);
7759
+ index++;
7760
+ continue;
7761
+ }
7762
+ if (isValid) {
7763
+ lastGroup.push(item);
7764
+ index++;
7765
+ continue;
7766
+ }
7767
+ if (lastGroup.length === 0) {
7768
+ var _item$reject3;
7769
+ (_item$reject3 = item.reject) === null || _item$reject3 === undefined || _item$reject3.call(item, /* @__PURE__ */ new Error("Input is too big for a single dispatch"));
7770
+ index++;
7771
+ continue;
7772
+ }
7773
+ groupedItems.push([]);
7774
+ }
7775
+ return groupedItems;
7776
+ }
7777
+ function dispatch() {
7778
+ const groupedItems = groupItems(pendingItems);
7779
+ destroyTimerAndPendingItems();
7780
+ for (const items of groupedItems) {
7781
+ if (!items.length)
7782
+ continue;
7783
+ const batch = { items };
7784
+ for (const item of items)
7785
+ item.batch = batch;
7786
+ batchLoader.fetch(batch.items.map((_item) => _item.key)).then(async (result) => {
7787
+ await Promise.all(result.map(async (valueOrPromise, index) => {
7788
+ const item = batch.items[index];
7789
+ try {
7790
+ var _item$resolve;
7791
+ const value = await Promise.resolve(valueOrPromise);
7792
+ (_item$resolve = item.resolve) === null || _item$resolve === undefined || _item$resolve.call(item, value);
7793
+ } catch (cause) {
7794
+ var _item$reject4;
7795
+ (_item$reject4 = item.reject) === null || _item$reject4 === undefined || _item$reject4.call(item, cause);
7796
+ }
7797
+ item.batch = null;
7798
+ item.reject = null;
7799
+ item.resolve = null;
7800
+ }));
7801
+ for (const item of batch.items) {
7802
+ var _item$reject5;
7803
+ (_item$reject5 = item.reject) === null || _item$reject5 === undefined || _item$reject5.call(item, /* @__PURE__ */ new Error("Missing result"));
7804
+ item.batch = null;
7805
+ }
7806
+ }).catch((cause) => {
7807
+ for (const item of batch.items) {
7808
+ var _item$reject6;
7809
+ (_item$reject6 = item.reject) === null || _item$reject6 === undefined || _item$reject6.call(item, cause);
7810
+ item.batch = null;
7811
+ }
7812
+ });
7813
+ }
7814
+ }
7815
+ function load(key) {
7816
+ var _dispatchTimer;
7817
+ const item = {
7818
+ aborted: false,
7819
+ key,
7820
+ batch: null,
7821
+ resolve: throwFatalError,
7822
+ reject: throwFatalError
7823
+ };
7824
+ const promise = new Promise((resolve, reject) => {
7825
+ var _pendingItems;
7826
+ item.reject = reject;
7827
+ item.resolve = resolve;
7828
+ (_pendingItems = pendingItems) !== null && _pendingItems !== undefined || (pendingItems = []);
7829
+ pendingItems.push(item);
7830
+ });
7831
+ (_dispatchTimer = dispatchTimer) !== null && _dispatchTimer !== undefined || (dispatchTimer = setTimeout(dispatch));
7832
+ return promise;
7833
+ }
7834
+ return { load };
7835
+ }
7836
+ function httpBatchLink(opts) {
7837
+ var _opts$maxURLLength, _opts$maxItems;
7838
+ const resolvedOpts = resolveHTTPLinkOptions(opts);
7839
+ const maxURLLength = (_opts$maxURLLength = opts.maxURLLength) !== null && _opts$maxURLLength !== undefined ? _opts$maxURLLength : Infinity;
7840
+ const maxItems = (_opts$maxItems = opts.maxItems) !== null && _opts$maxItems !== undefined ? _opts$maxItems : Infinity;
7841
+ return () => {
7842
+ const batchLoader = (type) => {
7843
+ return {
7844
+ validate(batchOps) {
7845
+ if (maxURLLength === Infinity && maxItems === Infinity)
7846
+ return true;
7847
+ if (batchOps.length > maxItems)
7848
+ return false;
7849
+ const path = batchOps.map((op) => op.path).join(",");
7850
+ const inputs = batchOps.map((op) => op.input);
7851
+ return getUrl(_objectSpread2(_objectSpread2({}, resolvedOpts), {}, {
7852
+ type,
7853
+ path,
7854
+ inputs,
7855
+ signal: null
7856
+ })).length <= maxURLLength;
7857
+ },
7858
+ async fetch(batchOps) {
7859
+ const path = batchOps.map((op) => op.path).join(",");
7860
+ const inputs = batchOps.map((op) => op.input);
7861
+ const signal = allAbortSignals(...batchOps.map((op) => op.signal));
7862
+ const res = await jsonHttpRequester(_objectSpread2(_objectSpread2({}, resolvedOpts), {}, {
7863
+ path,
7864
+ inputs,
7865
+ type,
7866
+ headers() {
7867
+ if (!opts.headers)
7868
+ return {};
7869
+ if (typeof opts.headers === "function")
7870
+ return opts.headers({ opList: batchOps });
7871
+ return opts.headers;
7872
+ },
7873
+ signal
7874
+ }));
7875
+ return (Array.isArray(res.json) ? res.json : batchOps.map(() => res.json)).map((item) => ({
7876
+ meta: res.meta,
7877
+ json: item
7878
+ }));
7879
+ }
7880
+ };
7881
+ };
7882
+ const loaders = {
7883
+ query: dataLoader(batchLoader("query")),
7884
+ mutation: dataLoader(batchLoader("mutation"))
7885
+ };
7886
+ return ({ op }) => {
7887
+ return observable((observer) => {
7888
+ if (op.type === "subscription")
7889
+ throw new Error("Subscriptions are unsupported by `httpLink` - use `httpSubscriptionLink` or `wsLink`");
7890
+ const ac = new AbortController;
7891
+ const { signal, cleanup } = raceAbortSignalsWithCleanup(op.signal, ac.signal);
7892
+ const promise = loaders[op.type].load(_objectSpread2(_objectSpread2({}, op), {}, { signal }));
7893
+ let isDone = false;
7894
+ let _res = undefined;
7895
+ promise.then((res) => {
7896
+ isDone = true;
7897
+ _res = res;
7898
+ const transformed = transformResult(res.json, resolvedOpts.transformer.output);
7899
+ if (!transformed.ok) {
7900
+ observer.error(TRPCClientError.from(transformed.error, { meta: res.meta }));
7901
+ return;
7902
+ }
7903
+ observer.next({
7904
+ context: res.meta,
7905
+ result: transformed.result
7906
+ });
7907
+ observer.complete();
7908
+ }).catch((err) => {
7909
+ isDone = true;
7910
+ observer.error(TRPCClientError.from(err, { meta: _res === null || _res === undefined ? undefined : _res.meta }));
7911
+ });
7912
+ return () => {
7913
+ if (!isDone)
7914
+ ac.abort();
7915
+ cleanup();
7916
+ };
7917
+ });
7918
+ };
7919
+ };
7920
+ }
7921
+
7922
+ // ../../../node_modules/.bun/@trpc+client@11.25.2+73a9f6e6dedcb27f/node_modules/@trpc/client/dist/wsLink-l0dX0ah6.mjs
7923
+ var resultOf = (value, ...args) => {
7924
+ return typeof value === "function" ? value(...args) : value;
7925
+ };
7926
+ function withResolvers() {
7927
+ let resolve;
7928
+ let reject;
7929
+ return {
7930
+ promise: new Promise((res, rej) => {
7931
+ resolve = res;
7932
+ reject = rej;
7933
+ }),
7934
+ resolve,
7935
+ reject
7936
+ };
7937
+ }
7938
+ async function prepareUrl(urlOptions) {
7939
+ const url = await resultOf(urlOptions.url);
7940
+ if (!urlOptions.connectionParams)
7941
+ return url;
7942
+ return url + `${url.includes("?") ? "&" : "?"}connectionParams=1`;
7943
+ }
7944
+ async function buildConnectionMessage(connectionParams, encoder) {
7945
+ const message = {
7946
+ method: "connectionParams",
7947
+ data: await resultOf(connectionParams)
7948
+ };
7949
+ return encoder.encode(message);
7950
+ }
7951
+ function asyncWsOpen(ws) {
7952
+ const { promise, resolve, reject } = withResolvers();
7953
+ ws.addEventListener("open", () => {
7954
+ ws.removeEventListener("error", reject);
7955
+ resolve();
7956
+ });
7957
+ ws.addEventListener("error", reject);
7958
+ return promise;
7959
+ }
7960
+ var pongCallbacks = /* @__PURE__ */ new WeakMap;
7961
+ function sendPing(ws, onPong) {
7962
+ let callbacks = pongCallbacks.get(ws);
7963
+ if (!callbacks) {
7964
+ const queue = [];
7965
+ callbacks = queue;
7966
+ pongCallbacks.set(ws, queue);
7967
+ ws.addEventListener("message", ({ data }) => {
7968
+ var _queue$shift;
7969
+ if (data === "PONG")
7970
+ (_queue$shift = queue.shift()) === null || _queue$shift === undefined || _queue$shift();
7971
+ });
7972
+ }
7973
+ callbacks.push(onPong);
7974
+ ws.send("PING");
7975
+ }
7976
+ function setupPingInterval(ws, { intervalMs, pongTimeoutMs }) {
7977
+ let pingTimeout;
7978
+ let pongTimeout;
7979
+ function start() {
7980
+ pingTimeout = setTimeout(() => {
7981
+ sendPing(ws, null);
7982
+ pongTimeout = setTimeout(() => {
7983
+ ws.close();
7984
+ }, pongTimeoutMs);
7985
+ }, intervalMs);
7986
+ }
7987
+ function reset() {
7988
+ clearTimeout(pingTimeout);
7989
+ start();
7990
+ }
7991
+ function pong() {
7992
+ clearTimeout(pongTimeout);
7993
+ reset();
7994
+ }
7995
+ ws.addEventListener("open", start);
7996
+ ws.addEventListener("message", ({ data }) => {
7997
+ clearTimeout(pingTimeout);
7998
+ start();
7999
+ if (data === "PONG")
8000
+ pong();
8001
+ });
8002
+ ws.addEventListener("close", () => {
8003
+ clearTimeout(pingTimeout);
8004
+ clearTimeout(pongTimeout);
8005
+ });
8006
+ }
8007
+ var WsConnection = class WsConnection {
8008
+ constructor(opts) {
8009
+ var _opts$WebSocketPonyfi;
8010
+ _defineProperty(this, "id", ++WsConnection.connectCount);
8011
+ _defineProperty(this, "WebSocketPonyfill", undefined);
8012
+ _defineProperty(this, "urlOptions", undefined);
8013
+ _defineProperty(this, "keepAliveOpts", undefined);
8014
+ _defineProperty(this, "encoder", undefined);
8015
+ _defineProperty(this, "wsObservable", behaviorSubject(null));
8016
+ _defineProperty(this, "openPromise", null);
8017
+ this.WebSocketPonyfill = (_opts$WebSocketPonyfi = opts.WebSocketPonyfill) !== null && _opts$WebSocketPonyfi !== undefined ? _opts$WebSocketPonyfi : WebSocket;
8018
+ if (!this.WebSocketPonyfill)
8019
+ throw new Error("No WebSocket implementation found - you probably don't want to use this on the server, but if you do you need to pass a `WebSocket`-ponyfill");
8020
+ this.urlOptions = opts.urlOptions;
8021
+ this.keepAliveOpts = opts.keepAlive;
8022
+ this.encoder = opts.encoder;
8023
+ }
8024
+ get ws() {
8025
+ return this.wsObservable.get();
8026
+ }
8027
+ set ws(ws) {
8028
+ this.wsObservable.next(ws);
8029
+ }
8030
+ isOpen() {
8031
+ return !!this.ws && this.ws.readyState === this.WebSocketPonyfill.OPEN && !this.openPromise;
8032
+ }
8033
+ isClosed() {
8034
+ return !!this.ws && (this.ws.readyState === this.WebSocketPonyfill.CLOSING || this.ws.readyState === this.WebSocketPonyfill.CLOSED);
8035
+ }
8036
+ async open() {
8037
+ if (this.openPromise)
8038
+ return this.openPromise;
8039
+ this.id = ++WsConnection.connectCount;
8040
+ const wsPromise = prepareUrl(this.urlOptions).then((url) => new this.WebSocketPonyfill(url));
8041
+ this.openPromise = wsPromise.then(async (ws) => {
8042
+ this.ws = ws;
8043
+ ws.binaryType = "arraybuffer";
8044
+ ws.addEventListener("message", function({ data }) {
8045
+ if (data === "PING")
8046
+ this.send("PONG");
8047
+ });
8048
+ if (this.keepAliveOpts.enabled)
8049
+ setupPingInterval(ws, this.keepAliveOpts);
8050
+ ws.addEventListener("close", () => {
8051
+ if (this.ws === ws)
8052
+ this.ws = null;
8053
+ });
8054
+ await asyncWsOpen(ws);
8055
+ if (this.urlOptions.connectionParams)
8056
+ ws.send(await buildConnectionMessage(this.urlOptions.connectionParams, this.encoder));
8057
+ });
8058
+ try {
8059
+ await this.openPromise;
8060
+ } finally {
8061
+ this.openPromise = null;
8062
+ }
8063
+ }
8064
+ async close() {
8065
+ try {
8066
+ await this.openPromise;
8067
+ } finally {
8068
+ var _this$ws;
8069
+ (_this$ws = this.ws) === null || _this$ws === undefined || _this$ws.close();
8070
+ }
8071
+ }
8072
+ };
8073
+ _defineProperty(WsConnection, "connectCount", 0);
8074
+
8075
+ // ../../../node_modules/.bun/@trpc+client@11.25.2+73a9f6e6dedcb27f/node_modules/@trpc/client/dist/index.mjs
8076
+ var observerKeys = [
8077
+ "onStarted",
8078
+ "onData",
8079
+ "onError",
8080
+ "onStopped",
8081
+ "onComplete",
8082
+ "onConnectionStateChange"
8083
+ ];
8084
+ var TRPCUntypedClient = class {
8085
+ constructor(opts) {
8086
+ _defineProperty(this, "links", undefined);
8087
+ _defineProperty(this, "runtime", undefined);
8088
+ _defineProperty(this, "requestId", undefined);
8089
+ this.requestId = 0;
8090
+ this.runtime = {};
8091
+ this.links = opts.links.map((link) => link(this.runtime));
8092
+ }
8093
+ $request(opts) {
8094
+ var _opts$context;
8095
+ return createChain({
8096
+ links: this.links,
8097
+ op: _objectSpread2(_objectSpread2({}, opts), {}, {
8098
+ context: (_opts$context = opts.context) !== null && _opts$context !== undefined ? _opts$context : {},
8099
+ id: ++this.requestId
8100
+ })
8101
+ }).pipe(share());
8102
+ }
8103
+ async requestAsPromise(opts) {
8104
+ try {
8105
+ const req$ = this.$request(opts);
8106
+ return (await observableToPromise(req$)).result.data;
8107
+ } catch (err) {
8108
+ throw TRPCClientError.from(err);
8109
+ }
8110
+ }
8111
+ query(path, input, opts) {
8112
+ return this.requestAsPromise({
8113
+ type: "query",
8114
+ path,
8115
+ input,
8116
+ context: opts === null || opts === undefined ? undefined : opts.context,
8117
+ signal: opts === null || opts === undefined ? undefined : opts.signal
8118
+ });
8119
+ }
8120
+ mutation(path, input, opts) {
8121
+ return this.requestAsPromise({
8122
+ type: "mutation",
8123
+ path,
8124
+ input,
8125
+ context: opts === null || opts === undefined ? undefined : opts.context,
8126
+ signal: opts === null || opts === undefined ? undefined : opts.signal
8127
+ });
8128
+ }
8129
+ subscription(path, input, opts = {}) {
8130
+ const hasCallbacks = observerKeys.some((key) => typeof opts[key] === "function");
8131
+ const observable$ = this.$request({
8132
+ type: "subscription",
8133
+ path,
8134
+ input,
8135
+ context: opts.context,
8136
+ signal: opts.signal
8137
+ });
8138
+ if (!hasCallbacks) {
8139
+ var _opts$signal;
8140
+ const data$ = observable((observer) => observable$.subscribe({
8141
+ next(envelope) {
8142
+ if (envelope.result.type === "data" || envelope.result.type === undefined)
8143
+ observer.next(envelope.result.data);
8144
+ },
8145
+ error: (err) => observer.error(err),
8146
+ complete: () => observer.complete()
8147
+ }));
8148
+ const iterator = observableToAsyncIterable(data$, (_opts$signal = opts.signal) !== null && _opts$signal !== undefined ? _opts$signal : new AbortController().signal);
8149
+ let iterated = false;
8150
+ iterator[Symbol.asyncIterator] = () => {
8151
+ if (iterated)
8152
+ throw new Error("A subscription can only be iterated once. Call subscribe() again for another loop.");
8153
+ iterated = true;
8154
+ return iterator;
8155
+ };
8156
+ return iterator;
8157
+ }
8158
+ return observable$.subscribe({
8159
+ next(envelope) {
8160
+ switch (envelope.result.type) {
8161
+ case "state":
8162
+ var _opts$onConnectionSta;
8163
+ (_opts$onConnectionSta = opts.onConnectionStateChange) === null || _opts$onConnectionSta === undefined || _opts$onConnectionSta.call(opts, envelope.result);
8164
+ break;
8165
+ case "started":
8166
+ var _opts$onStarted;
8167
+ (_opts$onStarted = opts.onStarted) === null || _opts$onStarted === undefined || _opts$onStarted.call(opts, { context: envelope.context });
8168
+ break;
8169
+ case "stopped":
8170
+ var _opts$onStopped;
8171
+ (_opts$onStopped = opts.onStopped) === null || _opts$onStopped === undefined || _opts$onStopped.call(opts);
8172
+ break;
8173
+ case "data":
8174
+ case undefined:
8175
+ var _opts$onData;
8176
+ (_opts$onData = opts.onData) === null || _opts$onData === undefined || _opts$onData.call(opts, envelope.result.data);
8177
+ }
8178
+ },
8179
+ error(err) {
8180
+ var _opts$onError;
8181
+ (_opts$onError = opts.onError) === null || _opts$onError === undefined || _opts$onError.call(opts, err);
8182
+ },
8183
+ complete() {
8184
+ var _opts$onComplete;
8185
+ (_opts$onComplete = opts.onComplete) === null || _opts$onComplete === undefined || _opts$onComplete.call(opts);
8186
+ }
8187
+ });
8188
+ }
8189
+ };
8190
+ var untypedClientSymbol = Symbol.for("trpc_untypedClient");
8191
+ var clientCallTypeMap = {
8192
+ query: "query",
8193
+ mutate: "mutation",
8194
+ subscribe: "subscription"
8195
+ };
8196
+ var clientCallTypeToProcedureType = (clientCallType) => {
8197
+ return clientCallTypeMap[clientCallType];
8198
+ };
8199
+ function createTRPCClientProxy(client) {
8200
+ const proxy = createRecursiveProxy(({ path, args }) => {
8201
+ const pathCopy = [...path];
8202
+ const procedureType = clientCallTypeToProcedureType(pathCopy.pop());
8203
+ const fullPath = pathCopy.join(".");
8204
+ return client[procedureType](fullPath, ...args);
8205
+ });
8206
+ return createFlatProxy((key) => {
8207
+ if (key === untypedClientSymbol)
8208
+ return client;
8209
+ return proxy[key];
8210
+ });
8211
+ }
8212
+ function createTRPCClient(opts) {
8213
+ return createTRPCClientProxy(new TRPCUntypedClient(opts));
8214
+ }
8215
+ function _OverloadYield2(e, d) {
8216
+ this.v = e, this.k = d;
8217
+ }
8218
+ function AsyncGenerator2(e) {
8219
+ var r, t;
8220
+ function resume(r, t) {
8221
+ try {
8222
+ var n = e[r](t), o = n.value, u = o instanceof _OverloadYield2;
8223
+ Promise.resolve(u ? o.v : o).then(function(t) {
8224
+ if (u) {
8225
+ var i = r === "return" ? "return" : "next";
8226
+ if (!o.k || t.done)
8227
+ return resume(i, t);
8228
+ t = e[i](t).value;
8229
+ }
8230
+ settle(n.done ? "return" : "normal", t);
8231
+ }, function(e) {
8232
+ resume("throw", e);
8233
+ });
8234
+ } catch (e) {
8235
+ settle("throw", e);
8236
+ }
8237
+ }
8238
+ function settle(e, n) {
8239
+ switch (e) {
8240
+ case "return":
8241
+ r.resolve({
8242
+ value: n,
8243
+ done: true
8244
+ });
8245
+ break;
8246
+ case "throw":
8247
+ r.reject(n);
8248
+ break;
8249
+ default:
8250
+ r.resolve({
8251
+ value: n,
8252
+ done: false
8253
+ });
8254
+ }
8255
+ (r = r.next) ? resume(r.key, r.arg) : t = null;
8256
+ }
8257
+ this._invoke = function(e, n) {
8258
+ return new Promise(function(o, u) {
8259
+ var i = {
8260
+ key: e,
8261
+ arg: n,
8262
+ resolve: o,
8263
+ reject: u,
8264
+ next: null
8265
+ };
8266
+ t ? t = t.next = i : (r = t = i, resume(e, n));
8267
+ });
8268
+ }, typeof e["return"] != "function" && (this["return"] = undefined);
8269
+ }
8270
+ AsyncGenerator2.prototype[typeof Symbol == "function" && Symbol.asyncIterator || "@@asyncIterator"] = function() {
8271
+ return this;
8272
+ }, AsyncGenerator2.prototype.next = function(e) {
8273
+ return this._invoke("next", e);
8274
+ }, AsyncGenerator2.prototype["throw"] = function(e) {
8275
+ return this._invoke("throw", e);
8276
+ }, AsyncGenerator2.prototype["return"] = function(e) {
8277
+ return this._invoke("return", e);
8278
+ };
8279
+
8280
+ // src/api-client.ts
8281
+ import SuperJSON from "superjson";
8282
+
8283
+ // src/config.ts
8284
+ var DEFAULT_EVENT_TECH_API_BASE_URL = "https://app.getout.events";
8285
+
8286
+ class CliConfigurationError extends Error {
8287
+ code = "CONFIGURATION";
8288
+ constructor(message) {
8289
+ super(message);
8290
+ this.name = "CliConfigurationError";
8291
+ }
8292
+ }
8293
+ var normalizeApiBaseUrl = (value) => {
8294
+ let url;
8295
+ try {
8296
+ url = new URL(value);
8297
+ } catch {
8298
+ throw new CliConfigurationError("Event Tech API URL must be a valid URL.");
8299
+ }
8300
+ const isLocalHttp = url.protocol === "http:" && (url.hostname === "localhost" || url.hostname === "127.0.0.1");
8301
+ if (url.protocol !== "https:" && !isLocalHttp) {
8302
+ throw new CliConfigurationError("Event Tech API URL must use HTTPS, except for localhost development.");
8303
+ }
8304
+ url.pathname = url.pathname.replace(/\/$/, "");
8305
+ return url.toString().replace(/\/$/, "");
8306
+ };
8307
+
8308
+ // src/api-client.ts
8309
+ var createEventTechClient = (apiBaseUrl, readAccessToken, fetchImplementation = fetch) => createTRPCClient({
8310
+ links: [
8311
+ httpBatchLink({
8312
+ url: `${apiBaseUrl}/api/trpc`,
7039
8313
  transformer: SuperJSON,
7040
8314
  fetch: fetchImplementation,
7041
8315
  headers: () => ({
@@ -7045,7 +8319,7 @@ var createEventTechClient = (apiBaseUrl, readAccessToken, fetchImplementation =
7045
8319
  })
7046
8320
  ]
7047
8321
  });
7048
- var createEventTechPublicClient = (apiBaseUrl, fetchImplementation = fetch) => createTRPCProxyClient({
8322
+ var createEventTechPublicClient = (apiBaseUrl, fetchImplementation = fetch) => createTRPCClient({
7049
8323
  links: [
7050
8324
  httpBatchLink({
7051
8325
  url: `${apiBaseUrl}/api/trpc`,
@@ -7149,6 +8423,29 @@ var booleanFlags = new Set([
7149
8423
  "public",
7150
8424
  "version"
7151
8425
  ]);
8426
+ var recordFlag = (args, index, token, flags) => {
8427
+ const [rawName, inlineValue] = token.slice(2).split("=", 2);
8428
+ if (!rawName)
8429
+ throw new CliUsageError("Flag names cannot be empty.");
8430
+ if (booleanFlags.has(rawName)) {
8431
+ if (inlineValue !== undefined) {
8432
+ throw new CliUsageError(`--${rawName} is a bare flag and does not take a value.`);
8433
+ }
8434
+ flags.set(rawName, true);
8435
+ return index;
8436
+ }
8437
+ if (inlineValue !== undefined) {
8438
+ flags.set(rawName, inlineValue);
8439
+ return index;
8440
+ }
8441
+ const nextValue = args[index + 1];
8442
+ if (nextValue && !nextValue.startsWith("--")) {
8443
+ flags.set(rawName, nextValue);
8444
+ return index + 1;
8445
+ }
8446
+ flags.set(rawName, true);
8447
+ return index;
8448
+ };
7152
8449
  var parseArguments = (args) => {
7153
8450
  const positionals = [];
7154
8451
  const flags = new Map;
@@ -7160,27 +8457,7 @@ var parseArguments = (args) => {
7160
8457
  positionals.push(token);
7161
8458
  continue;
7162
8459
  }
7163
- const [rawName, inlineValue] = token.slice(2).split("=", 2);
7164
- if (!rawName)
7165
- throw new CliUsageError("Flag names cannot be empty.");
7166
- if (booleanFlags.has(rawName)) {
7167
- if (inlineValue !== undefined) {
7168
- throw new CliUsageError(`--${rawName} is a bare flag and does not take a value.`);
7169
- }
7170
- flags.set(rawName, true);
7171
- continue;
7172
- }
7173
- if (inlineValue !== undefined) {
7174
- flags.set(rawName, inlineValue);
7175
- continue;
7176
- }
7177
- const nextValue = args[index + 1];
7178
- if (nextValue && !nextValue.startsWith("--")) {
7179
- flags.set(rawName, nextValue);
7180
- index += 1;
7181
- } else {
7182
- flags.set(rawName, true);
7183
- }
8460
+ index = recordFlag(args, index, token, flags);
7184
8461
  }
7185
8462
  return { positionals, flags };
7186
8463
  };
@@ -7356,7 +8633,8 @@ Event Passport:
7356
8633
 
7357
8634
  Organization and event setup:
7358
8635
  organization create is global-admin only. It provisions the org and emails an owner invitation
7359
- to --owner-email; deliveryStatus reports whether that email was sent. Names must be unique.
8636
+ to --owner-email after it is saved; deliveryStatus (sent/failed) and
8637
+ ownerInvitation.emailDeliveryStatus report the outcome. Names must be unique.
7360
8638
  event create needs org owner/admin (or global admin). --type is an active event type such as
7361
8639
  LUCKY_DRAW; a LUCKY_DRAW event gets its board with default config automatically.
7362
8640
  --start/--end are ISO 8601 date-times with an offset, for example 2026-11-20T18:00:00+08:00.
@@ -7577,187 +8855,229 @@ var parsePrizeList = (raw) => {
7577
8855
  return result.data;
7578
8856
  });
7579
8857
  };
7580
- var loadCurrentConfig = async (eventId) => (await api2.event.luckyDraw.getLuckyDrawByEventId.query({ eventId })).config;
7581
- var loadPrizes = async (eventId) => (await api2.event.luckyDraw.getLuckyDrawPrizesByEventId.query({ eventId })).prizes;
7582
- var assertPrizesBelongToEvent = (prizes, prizeIds, eventId) => {
7583
- const known = new Set(prizes.map((prize) => prize.id));
7584
- const missing = prizeIds.filter((id) => !known.has(id));
7585
- if (missing.length > 0) {
7586
- throw new CliUsageError(`Prize ID(s) not found on event ${eventId}: ${missing.join(", ")}.`);
8858
+ var loadCurrentConfig = async (eventId) => (await api2.event.luckyDraw.getLuckyDrawByEventId.query({ eventId })).config;
8859
+ var loadPrizes = async (eventId) => (await api2.event.luckyDraw.getLuckyDrawPrizesByEventId.query({ eventId })).prizes;
8860
+ var assertPrizesBelongToEvent = (prizes, prizeIds, eventId) => {
8861
+ const known = new Set(prizes.map((prize) => prize.id));
8862
+ const missing = prizeIds.filter((id) => !known.has(id));
8863
+ if (missing.length > 0) {
8864
+ throw new CliUsageError(`Prize ID(s) not found on event ${eventId}: ${missing.join(", ")}.`);
8865
+ }
8866
+ };
8867
+ var saveConfig = (eventId, config) => api2.event.luckyDraw.updateLuckyDrawConfigJson.mutate({ eventId, config });
8868
+ var runConfigGet = async ({
8869
+ parsed,
8870
+ runtime,
8871
+ authenticate
8872
+ }) => {
8873
+ assertPositionalCount(parsed, 3);
8874
+ assertOnlyFlags(parsed, ["event-id"]);
8875
+ const eventId = getRequiredFlag(parsed, "event-id");
8876
+ await authenticate();
8877
+ writeSuccess(runtime, await api2.event.luckyDraw.getLuckyDrawByEventId.query({ eventId }));
8878
+ };
8879
+ var runConfigUpdate = async ({
8880
+ parsed,
8881
+ runtime,
8882
+ authenticate
8883
+ }) => {
8884
+ assertPositionalCount(parsed, 3);
8885
+ assertOnlyFlags(parsed, ["event-id", "config", "config-file", "dry-run"]);
8886
+ const eventId = getRequiredFlag(parsed, "event-id");
8887
+ const patch = parseLuckyDrawConfigPatch(await readInlineOrFile(parsed, "config", "config-file"));
8888
+ await authenticate();
8889
+ const config = mergeLuckyDrawConfig(await loadCurrentConfig(eventId), patch);
8890
+ if (parsed.flags.get("dry-run") === true) {
8891
+ writeSuccess(runtime, {
8892
+ dryRun: true,
8893
+ changedFields: Object.keys(patch).sort(),
8894
+ config
8895
+ });
8896
+ return;
8897
+ }
8898
+ writeSuccess(runtime, await saveConfig(eventId, config));
8899
+ };
8900
+ var runBackgroundUpload = async ({
8901
+ parsed,
8902
+ runtime,
8903
+ authenticate
8904
+ }) => {
8905
+ assertPositionalCount(parsed, 3);
8906
+ assertOnlyFlags(parsed, ["event-id", "file", "content-type"]);
8907
+ const eventId = getRequiredFlag(parsed, "event-id");
8908
+ const filePath = getRequiredFlag(parsed, "file");
8909
+ const contentType = getRequiredFlag(parsed, "content-type");
8910
+ if (!contentType.startsWith("image/")) {
8911
+ throw new CliUsageError("--content-type must be an image MIME type.");
8912
+ }
8913
+ let file;
8914
+ try {
8915
+ file = await readFile3(filePath);
8916
+ } catch {
8917
+ throw new CliUsageError("--file could not be read.");
8918
+ }
8919
+ await authenticate();
8920
+ const signed = await api2.attachment.getPresignedUrlToUpload.mutate({
8921
+ folder: LUCKY_DRAW_BACKGROUND_FOLDER,
8922
+ fileName: basename(filePath),
8923
+ contentType,
8924
+ size: file.byteLength,
8925
+ eventId
8926
+ });
8927
+ const uploadResponse = await fetch(signed.uploadUrl, {
8928
+ method: "PUT",
8929
+ headers: { "content-type": contentType },
8930
+ body: file
8931
+ });
8932
+ if (!uploadResponse.ok) {
8933
+ throw new Error(`Lucky draw background upload failed with HTTP ${uploadResponse.status}.`);
8934
+ }
8935
+ const config = mergeLuckyDrawConfig(await loadCurrentConfig(eventId), {
8936
+ customBackgroundImage: signed.key
8937
+ });
8938
+ await saveConfig(eventId, config);
8939
+ writeSuccess(runtime, await api2.event.luckyDraw.getLuckyDrawByEventId.query({ eventId }));
8940
+ };
8941
+ var runBackgroundClear = async ({
8942
+ parsed,
8943
+ runtime,
8944
+ authenticate
8945
+ }) => {
8946
+ assertPositionalCount(parsed, 3);
8947
+ assertOnlyFlags(parsed, ["event-id", "allow-state-change", "target"]);
8948
+ const eventId = getRequiredFlag(parsed, "event-id");
8949
+ assertStateChangeTarget(parsed, eventId);
8950
+ await authenticate();
8951
+ const config = mergeLuckyDrawConfig(await loadCurrentConfig(eventId), {
8952
+ customBackgroundImage: null
8953
+ });
8954
+ writeSuccess(runtime, await saveConfig(eventId, config));
8955
+ };
8956
+ var runPrizesList = async ({
8957
+ parsed,
8958
+ runtime,
8959
+ authenticate
8960
+ }) => {
8961
+ assertPositionalCount(parsed, 3);
8962
+ assertOnlyFlags(parsed, ["event-id"]);
8963
+ const eventId = getRequiredFlag(parsed, "event-id");
8964
+ await authenticate();
8965
+ writeSuccess(runtime, await api2.event.luckyDraw.getLuckyDrawPrizesByEventId.query({ eventId }));
8966
+ };
8967
+ var runPrizesCreate = async ({
8968
+ parsed,
8969
+ runtime,
8970
+ authenticate
8971
+ }) => {
8972
+ assertPositionalCount(parsed, 3);
8973
+ assertOnlyFlags(parsed, [
8974
+ "event-id",
8975
+ "name",
8976
+ "description",
8977
+ "prizes",
8978
+ "prizes-file"
8979
+ ]);
8980
+ const eventId = getRequiredFlag(parsed, "event-id");
8981
+ const name = getOptionalFlag(parsed, "name");
8982
+ const description = getOptionalFlag(parsed, "description");
8983
+ const hasList = parsed.flags.has("prizes") || parsed.flags.has("prizes-file");
8984
+ if (hasList === (name !== undefined)) {
8985
+ throw new CliUsageError("Provide either --name [--description] or one of --prizes / --prizes-file.");
8986
+ }
8987
+ if (hasList && description !== undefined) {
8988
+ throw new CliUsageError("--description is only valid with --name; include descriptions in the --prizes JSON.");
8989
+ }
8990
+ const prizes = hasList ? parsePrizeList(await readInlineOrFile(parsed, "prizes", "prizes-file")) : parsePrizeList(JSON.stringify([
8991
+ { name, ...description === undefined ? {} : { description } }
8992
+ ]));
8993
+ await authenticate();
8994
+ writeSuccess(runtime, await api2.event.luckyDraw.createLuckyDrawPrize.mutate({
8995
+ eventId,
8996
+ prizes
8997
+ }));
8998
+ };
8999
+ var runPrizesUpdate = async ({
9000
+ parsed,
9001
+ runtime,
9002
+ authenticate
9003
+ }) => {
9004
+ assertPositionalCount(parsed, 3);
9005
+ assertOnlyFlags(parsed, ["event-id", "prize-id", "name", "description"]);
9006
+ const eventId = getRequiredFlag(parsed, "event-id");
9007
+ const prizeId = getRequiredFlag(parsed, "prize-id");
9008
+ const name = getRequiredFlag(parsed, "name");
9009
+ const description = getOptionalFlag(parsed, "description");
9010
+ await authenticate();
9011
+ assertPrizesBelongToEvent(await loadPrizes(eventId), [prizeId], eventId);
9012
+ writeSuccess(runtime, await api2.event.luckyDraw.updateLuckyDrawPrize.mutate({
9013
+ id: prizeId,
9014
+ name,
9015
+ ...description === undefined ? {} : { description }
9016
+ }));
9017
+ };
9018
+ var runPrizesDelete = async ({
9019
+ parsed,
9020
+ runtime,
9021
+ authenticate
9022
+ }) => {
9023
+ assertPositionalCount(parsed, 3);
9024
+ assertOnlyFlags(parsed, [
9025
+ "event-id",
9026
+ "prize-ids",
9027
+ "allow-state-change",
9028
+ "target"
9029
+ ]);
9030
+ const eventId = getRequiredFlag(parsed, "event-id");
9031
+ const prizeIds = parseIdList(getRequiredFlag(parsed, "prize-ids"), "prize-ids");
9032
+ assertStateChangeTarget(parsed, eventId);
9033
+ await authenticate();
9034
+ assertPrizesBelongToEvent(await loadPrizes(eventId), prizeIds, eventId);
9035
+ writeSuccess(runtime, await api2.event.luckyDraw.deleteLuckyDrawPrize.mutate({ prizeIds }));
9036
+ };
9037
+ var runPrizesReorder = async ({
9038
+ parsed,
9039
+ runtime,
9040
+ authenticate
9041
+ }) => {
9042
+ assertPositionalCount(parsed, 3);
9043
+ assertOnlyFlags(parsed, ["event-id", "prize-ids"]);
9044
+ const eventId = getRequiredFlag(parsed, "event-id");
9045
+ const prizeIds = parseIdList(getRequiredFlag(parsed, "prize-ids"), "prize-ids");
9046
+ await authenticate();
9047
+ const prizes = await loadPrizes(eventId);
9048
+ assertPrizesBelongToEvent(prizes, prizeIds, eventId);
9049
+ if (prizeIds.length !== prizes.length) {
9050
+ throw new CliUsageError(`--prize-ids must list all ${prizes.length} active prizes in the new order.`);
7587
9051
  }
9052
+ const namesById = new Map(prizes.map((prize) => [prize.id, prize.name]));
9053
+ writeSuccess(runtime, await api2.event.luckyDraw.updateLuckyDrawPrizesOrder.mutate({
9054
+ eventId,
9055
+ prizes: prizeIds.map((id, order) => ({
9056
+ id,
9057
+ order,
9058
+ name: namesById.get(id) ?? ""
9059
+ }))
9060
+ }));
7588
9061
  };
7589
- var saveConfig = (eventId, config) => api2.event.luckyDraw.updateLuckyDrawConfigJson.mutate({ eventId, config });
9062
+ var LUCKY_DRAW_SETUP_HANDLERS = new Map([
9063
+ ["config get", runConfigGet],
9064
+ ["config update", runConfigUpdate],
9065
+ ["background upload", runBackgroundUpload],
9066
+ ["background clear", runBackgroundClear],
9067
+ ["prizes list", runPrizesList],
9068
+ ["prizes create", runPrizesCreate],
9069
+ ["prizes update", runPrizesUpdate],
9070
+ ["prizes delete", runPrizesDelete],
9071
+ ["prizes reorder", runPrizesReorder]
9072
+ ]);
7590
9073
  var runLuckyDrawSetupCommand = async (input) => {
7591
9074
  const { parsed, runtime, authenticate } = input;
7592
9075
  const [, action, subAction] = parsed.positionals;
7593
- if (action === "config" && subAction === "get") {
7594
- assertPositionalCount(parsed, 3);
7595
- assertOnlyFlags(parsed, ["event-id"]);
7596
- const eventId = getRequiredFlag(parsed, "event-id");
7597
- await authenticate();
7598
- writeSuccess(runtime, await api2.event.luckyDraw.getLuckyDrawByEventId.query({ eventId }));
7599
- return true;
7600
- }
7601
- if (action === "config" && subAction === "update") {
7602
- assertPositionalCount(parsed, 3);
7603
- assertOnlyFlags(parsed, ["event-id", "config", "config-file", "dry-run"]);
7604
- const eventId = getRequiredFlag(parsed, "event-id");
7605
- const patch = parseLuckyDrawConfigPatch(await readInlineOrFile(parsed, "config", "config-file"));
7606
- await authenticate();
7607
- const config = mergeLuckyDrawConfig(await loadCurrentConfig(eventId), patch);
7608
- if (parsed.flags.get("dry-run") === true) {
7609
- writeSuccess(runtime, {
7610
- dryRun: true,
7611
- changedFields: Object.keys(patch).sort(),
7612
- config
7613
- });
7614
- return true;
7615
- }
7616
- writeSuccess(runtime, await saveConfig(eventId, config));
7617
- return true;
7618
- }
7619
- if (action === "background" && subAction === "upload") {
7620
- assertPositionalCount(parsed, 3);
7621
- assertOnlyFlags(parsed, ["event-id", "file", "content-type"]);
7622
- const eventId = getRequiredFlag(parsed, "event-id");
7623
- const filePath = getRequiredFlag(parsed, "file");
7624
- const contentType = getRequiredFlag(parsed, "content-type");
7625
- if (!contentType.startsWith("image/")) {
7626
- throw new CliUsageError("--content-type must be an image MIME type.");
7627
- }
7628
- let file;
7629
- try {
7630
- file = await readFile3(filePath);
7631
- } catch {
7632
- throw new CliUsageError("--file could not be read.");
7633
- }
7634
- await authenticate();
7635
- const signed = await api2.attachment.getPresignedUrlToUpload.mutate({
7636
- folder: LUCKY_DRAW_BACKGROUND_FOLDER,
7637
- fileName: basename(filePath),
7638
- contentType,
7639
- size: file.byteLength,
7640
- eventId
7641
- });
7642
- const uploadResponse = await fetch(signed.uploadUrl, {
7643
- method: "PUT",
7644
- headers: { "content-type": contentType },
7645
- body: file
7646
- });
7647
- if (!uploadResponse.ok) {
7648
- throw new Error(`Lucky draw background upload failed with HTTP ${uploadResponse.status}.`);
7649
- }
7650
- const config = mergeLuckyDrawConfig(await loadCurrentConfig(eventId), {
7651
- customBackgroundImage: signed.key
7652
- });
7653
- await saveConfig(eventId, config);
7654
- writeSuccess(runtime, await api2.event.luckyDraw.getLuckyDrawByEventId.query({ eventId }));
7655
- return true;
7656
- }
7657
- if (action === "background" && subAction === "clear") {
7658
- assertPositionalCount(parsed, 3);
7659
- assertOnlyFlags(parsed, ["event-id", "allow-state-change", "target"]);
7660
- const eventId = getRequiredFlag(parsed, "event-id");
7661
- assertStateChangeTarget(parsed, eventId);
7662
- await authenticate();
7663
- const config = mergeLuckyDrawConfig(await loadCurrentConfig(eventId), {
7664
- customBackgroundImage: null
7665
- });
7666
- writeSuccess(runtime, await saveConfig(eventId, config));
7667
- return true;
7668
- }
7669
- if (action === "prizes" && subAction === "list") {
7670
- assertPositionalCount(parsed, 3);
7671
- assertOnlyFlags(parsed, ["event-id"]);
7672
- const eventId = getRequiredFlag(parsed, "event-id");
7673
- await authenticate();
7674
- writeSuccess(runtime, await api2.event.luckyDraw.getLuckyDrawPrizesByEventId.query({ eventId }));
7675
- return true;
7676
- }
7677
- if (action === "prizes" && subAction === "create") {
7678
- assertPositionalCount(parsed, 3);
7679
- assertOnlyFlags(parsed, [
7680
- "event-id",
7681
- "name",
7682
- "description",
7683
- "prizes",
7684
- "prizes-file"
7685
- ]);
7686
- const eventId = getRequiredFlag(parsed, "event-id");
7687
- const name = getOptionalFlag(parsed, "name");
7688
- const description = getOptionalFlag(parsed, "description");
7689
- const hasList = parsed.flags.has("prizes") || parsed.flags.has("prizes-file");
7690
- if (hasList === (name !== undefined)) {
7691
- throw new CliUsageError("Provide either --name [--description] or one of --prizes / --prizes-file.");
7692
- }
7693
- if (hasList && description !== undefined) {
7694
- throw new CliUsageError("--description is only valid with --name; include descriptions in the --prizes JSON.");
7695
- }
7696
- const prizes = hasList ? parsePrizeList(await readInlineOrFile(parsed, "prizes", "prizes-file")) : parsePrizeList(JSON.stringify([
7697
- { name, ...description === undefined ? {} : { description } }
7698
- ]));
7699
- await authenticate();
7700
- writeSuccess(runtime, await api2.event.luckyDraw.createLuckyDrawPrize.mutate({
7701
- eventId,
7702
- prizes
7703
- }));
7704
- return true;
7705
- }
7706
- if (action === "prizes" && subAction === "update") {
7707
- assertPositionalCount(parsed, 3);
7708
- assertOnlyFlags(parsed, ["event-id", "prize-id", "name", "description"]);
7709
- const eventId = getRequiredFlag(parsed, "event-id");
7710
- const prizeId = getRequiredFlag(parsed, "prize-id");
7711
- const name = getRequiredFlag(parsed, "name");
7712
- const description = getOptionalFlag(parsed, "description");
7713
- await authenticate();
7714
- assertPrizesBelongToEvent(await loadPrizes(eventId), [prizeId], eventId);
7715
- writeSuccess(runtime, await api2.event.luckyDraw.updateLuckyDrawPrize.mutate({
7716
- id: prizeId,
7717
- name,
7718
- ...description === undefined ? {} : { description }
7719
- }));
7720
- return true;
7721
- }
7722
- if (action === "prizes" && subAction === "delete") {
7723
- assertPositionalCount(parsed, 3);
7724
- assertOnlyFlags(parsed, [
7725
- "event-id",
7726
- "prize-ids",
7727
- "allow-state-change",
7728
- "target"
7729
- ]);
7730
- const eventId = getRequiredFlag(parsed, "event-id");
7731
- const prizeIds = parseIdList(getRequiredFlag(parsed, "prize-ids"), "prize-ids");
7732
- assertStateChangeTarget(parsed, eventId);
7733
- await authenticate();
7734
- assertPrizesBelongToEvent(await loadPrizes(eventId), prizeIds, eventId);
7735
- writeSuccess(runtime, await api2.event.luckyDraw.deleteLuckyDrawPrize.mutate({ prizeIds }));
7736
- return true;
7737
- }
7738
- if (action === "prizes" && subAction === "reorder") {
7739
- assertPositionalCount(parsed, 3);
7740
- assertOnlyFlags(parsed, ["event-id", "prize-ids"]);
7741
- const eventId = getRequiredFlag(parsed, "event-id");
7742
- const prizeIds = parseIdList(getRequiredFlag(parsed, "prize-ids"), "prize-ids");
7743
- await authenticate();
7744
- const prizes = await loadPrizes(eventId);
7745
- assertPrizesBelongToEvent(prizes, prizeIds, eventId);
7746
- if (prizeIds.length !== prizes.length) {
7747
- throw new CliUsageError(`--prize-ids must list all ${prizes.length} active prizes in the new order.`);
7748
- }
7749
- const namesById = new Map(prizes.map((prize) => [prize.id, prize.name]));
7750
- writeSuccess(runtime, await api2.event.luckyDraw.updateLuckyDrawPrizesOrder.mutate({
7751
- eventId,
7752
- prizes: prizeIds.map((id, order) => ({
7753
- id,
7754
- order,
7755
- name: namesById.get(id) ?? ""
7756
- }))
7757
- }));
7758
- return true;
7759
- }
7760
- return false;
9076
+ const handler = LUCKY_DRAW_SETUP_HANDLERS.get(`${action} ${subAction}`);
9077
+ if (!handler)
9078
+ return false;
9079
+ await handler({ parsed, runtime, authenticate });
9080
+ return true;
7761
9081
  };
7762
9082
 
7763
9083
  // ../validators/src/event-passport/passport-input.schema.ts
@@ -8019,6 +9339,56 @@ var date3 = (value, name) => {
8019
9339
  throw new CliUsageError(`${name} must be a valid ISO date-time.`);
8020
9340
  return parsed;
8021
9341
  };
9342
+ var parseStaffTallyCollection = (item, extras) => {
9343
+ keys(item, [
9344
+ "collectionMode",
9345
+ "tallyItems",
9346
+ "tallyEarnsStamp",
9347
+ "stampValue",
9348
+ "category"
9349
+ ], "collection");
9350
+ if (!Array.isArray(item.tallyItems))
9351
+ throw new CliUsageError("tallyItems must be an array of item names.");
9352
+ if (item.tallyItems.length < 1 || item.tallyItems.length > 30)
9353
+ throw new CliUsageError("tallyItems must have 1 to 30 items.");
9354
+ const tallyItems = item.tallyItems.map((name, index) => text(name, `tallyItems[${index}]`, 60));
9355
+ if (new Set(tallyItems.map((name) => name.toLocaleLowerCase())).size !== tallyItems.length)
9356
+ throw new CliUsageError("tallyItems must be unique ignoring case.");
9357
+ if (item.tallyEarnsStamp !== undefined && typeof item.tallyEarnsStamp !== "boolean")
9358
+ throw new CliUsageError("tallyEarnsStamp must be true or false.");
9359
+ return {
9360
+ collectionMode: "STAFF_TALLY",
9361
+ tallyItems,
9362
+ tallyEarnsStamp: item.tallyEarnsStamp === true,
9363
+ ...extras
9364
+ };
9365
+ };
9366
+ var parsePassportCollection = (raw) => {
9367
+ const item = object2(raw, "collection");
9368
+ const stampValue = item.stampValue === undefined ? {} : { stampValue: integer2(item.stampValue, "stampValue", 0, 1000) };
9369
+ const category = item.category === undefined ? {} : { category: stationCategory(item.category) };
9370
+ if (item.collectionMode === "STAFF_SCORE") {
9371
+ keys(item, ["collectionMode", "maxPoints", "stampValue", "category"], "collection");
9372
+ return {
9373
+ collectionMode: "STAFF_SCORE",
9374
+ maxPoints: integer2(item.maxPoints, "maxPoints"),
9375
+ ...stampValue,
9376
+ ...category
9377
+ };
9378
+ }
9379
+ if (item.collectionMode === "STAFF_TALLY") {
9380
+ return parseStaffTallyCollection(item, { ...stampValue, ...category });
9381
+ }
9382
+ if (item.collectionMode === "SELF_SCAN" || item.collectionMode === "STAFF_SCAN") {
9383
+ keys(item, ["collectionMode", "stampValue", "category"], "collection");
9384
+ return {
9385
+ collectionMode: item.collectionMode,
9386
+ ...stampValue,
9387
+ ...category
9388
+ };
9389
+ }
9390
+ throw new CliUsageError("collectionMode must be SELF_SCAN, STAFF_SCAN, STAFF_SCORE or STAFF_TALLY.");
9391
+ };
8022
9392
  var parsePassportStationInput = (raw, eventId) => {
8023
9393
  const value = json(raw, "--station-json");
8024
9394
  keys(value, [
@@ -8032,53 +9402,7 @@ var parsePassportStationInput = (raw, eventId) => {
8032
9402
  "closesAt",
8033
9403
  "collection"
8034
9404
  ], "Station");
8035
- let collection;
8036
- if (value.collection !== undefined) {
8037
- const item = object2(value.collection, "collection");
8038
- const stampValue = item.stampValue === undefined ? {} : { stampValue: integer2(item.stampValue, "stampValue", 0, 1000) };
8039
- const category = item.category === undefined ? {} : { category: stationCategory(item.category) };
8040
- if (item.collectionMode === "STAFF_SCORE") {
8041
- keys(item, ["collectionMode", "maxPoints", "stampValue", "category"], "collection");
8042
- collection = {
8043
- collectionMode: "STAFF_SCORE",
8044
- maxPoints: integer2(item.maxPoints, "maxPoints"),
8045
- ...stampValue,
8046
- ...category
8047
- };
8048
- } else if (item.collectionMode === "STAFF_TALLY") {
8049
- keys(item, [
8050
- "collectionMode",
8051
- "tallyItems",
8052
- "tallyEarnsStamp",
8053
- "stampValue",
8054
- "category"
8055
- ], "collection");
8056
- if (!Array.isArray(item.tallyItems))
8057
- throw new CliUsageError("tallyItems must be an array of item names.");
8058
- if (item.tallyItems.length < 1 || item.tallyItems.length > 30)
8059
- throw new CliUsageError("tallyItems must have 1 to 30 items.");
8060
- const tallyItems = item.tallyItems.map((name, index) => text(name, `tallyItems[${index}]`, 60));
8061
- if (new Set(tallyItems.map((name) => name.toLocaleLowerCase())).size !== tallyItems.length)
8062
- throw new CliUsageError("tallyItems must be unique ignoring case.");
8063
- if (item.tallyEarnsStamp !== undefined && typeof item.tallyEarnsStamp !== "boolean")
8064
- throw new CliUsageError("tallyEarnsStamp must be true or false.");
8065
- collection = {
8066
- collectionMode: "STAFF_TALLY",
8067
- tallyItems,
8068
- tallyEarnsStamp: item.tallyEarnsStamp === true,
8069
- ...stampValue,
8070
- ...category
8071
- };
8072
- } else if (item.collectionMode === "SELF_SCAN" || item.collectionMode === "STAFF_SCAN") {
8073
- keys(item, ["collectionMode", "stampValue", "category"], "collection");
8074
- collection = {
8075
- collectionMode: item.collectionMode,
8076
- ...stampValue,
8077
- ...category
8078
- };
8079
- } else
8080
- throw new CliUsageError("collectionMode must be SELF_SCAN, STAFF_SCAN, STAFF_SCORE or STAFF_TALLY.");
8081
- }
9405
+ const collection = value.collection === undefined ? undefined : parsePassportCollection(value.collection);
8082
9406
  return {
8083
9407
  eventId,
8084
9408
  ...value.id === undefined ? {} : { id: text(value.id, "id", 200) },
@@ -8127,6 +9451,7 @@ var parsePassportSettingsInput = (raw, eventId) => {
8127
9451
  ...loginMethods ? { loginMethods } : {}
8128
9452
  };
8129
9453
  };
9454
+ var optionalEntry = (key, value, parse) => value === undefined ? {} : { [key]: parse(value) };
8130
9455
  var runPassportCommand = async (input) => {
8131
9456
  const { flags, positionals } = input;
8132
9457
  const action = positionals.slice(1).join(" ");
@@ -8230,7 +9555,7 @@ var runPassportCommand = async (input) => {
8230
9555
  const payload = {
8231
9556
  ...station(),
8232
9557
  profileCode: requiredFlag(flags, "profile-code"),
8233
- ...points === undefined ? {} : { points: integer2(points, "--points") }
9558
+ ...optionalEntry("points", points, (raw) => integer2(raw, "--points"))
8234
9559
  };
8235
9560
  operation = () => api2.event.passport.collectPassportStampByStaff.mutate(payload);
8236
9561
  break;
@@ -8250,7 +9575,7 @@ var runPassportCommand = async (input) => {
8250
9575
  participantId: requiredFlag(flags, "participant-id"),
8251
9576
  stamped: boolean3(requiredFlag(flags, "stamped"), "--stamped"),
8252
9577
  reason: requiredFlag(flags, "reason"),
8253
- ...points === undefined ? {} : { points: integer2(points, "--points") }
9578
+ ...optionalEntry("points", points, (raw) => integer2(raw, "--points"))
8254
9579
  };
8255
9580
  operation = () => api2.event.passport.correctPassportStamp.mutate(payload);
8256
9581
  break;
@@ -8276,11 +9601,11 @@ var runPassportCommand = async (input) => {
8276
9601
  keys(value, ["id", "name", "description", "stock", "stampCost", "order"], "Prize");
8277
9602
  const payload = {
8278
9603
  eventId,
8279
- ...value.id === undefined ? {} : { id: text(value.id, "id", 200) },
9604
+ ...optionalEntry("id", value.id, (raw) => text(raw, "id", 200)),
8280
9605
  name: text(value.name, "name", 100),
8281
9606
  description: nullableText(value.description, "description", 1000),
8282
9607
  stock: integer2(value.stock, "stock"),
8283
- ...value.stampCost === undefined ? {} : { stampCost: integer2(value.stampCost, "stampCost", 0, 1e5) },
9608
+ ...optionalEntry("stampCost", value.stampCost, (raw) => integer2(raw, "stampCost", 0, 1e5)),
8284
9609
  order: integer2(value.order ?? 0, "order")
8285
9610
  };
8286
9611
  operation = () => api2.event.passport.upsertPassportPrize.mutate(payload);
@@ -8298,7 +9623,7 @@ var runPassportCommand = async (input) => {
8298
9623
  const quantity = flag(flags, "quantity", false);
8299
9624
  const payload = {
8300
9625
  eventId,
8301
- ...quantity === undefined ? {} : { quantity: integer2(quantity, "--quantity", 1, 20) },
9626
+ ...optionalEntry("quantity", quantity, (raw) => integer2(raw, "--quantity", 1, 20)),
8302
9627
  prizeId: requiredFlag(flags, "prize-id"),
8303
9628
  participantId: requiredFlag(flags, "participant-id")
8304
9629
  };
@@ -8323,7 +9648,7 @@ var runPassportCommand = async (input) => {
8323
9648
  ...station(),
8324
9649
  profileCode: requiredFlag(flags, "profile-code"),
8325
9650
  item: requiredFlag(flags, "item"),
8326
- ...quantity === undefined ? {} : { quantity: integer2(quantity, "--quantity", 1, 20) }
9651
+ ...optionalEntry("quantity", quantity, (raw) => integer2(raw, "--quantity", 1, 20))
8327
9652
  };
8328
9653
  operation = () => api2.event.passport.recordPassportTally.mutate(payload);
8329
9654
  break;
@@ -8362,7 +9687,7 @@ var command_manifest_default = [
8362
9687
  path: ["organization", "member", "list"],
8363
9688
  procedure: "organization.getOrganizationMembersById",
8364
9689
  operation: "query",
8365
- summary: "List an organization's members and pending invitations (paged).",
9690
+ summary: "List an organization's members and pending invitations (paged), with each invitation's stored emailDeliveryStatus.",
8366
9691
  effects: [],
8367
9692
  dates: [],
8368
9693
  input: {
@@ -8412,7 +9737,7 @@ var command_manifest_default = [
8412
9737
  path: ["organization", "member", "invite"],
8413
9738
  procedure: "organization.createOrganizationMember",
8414
9739
  operation: "mutation",
8415
- summary: "Invite a member to an organization and email the invitation.",
9740
+ summary: "Invite a member to an organization and email the invitation; reports deliveryStatus and the stored emailDeliveryStatus.",
8416
9741
  effects: ["state-change", "email"],
8417
9742
  target: "email",
8418
9743
  dates: [],
@@ -8437,6 +9762,29 @@ var command_manifest_default = [
8437
9762
  required: ["email", "organizationId"]
8438
9763
  }
8439
9764
  },
9765
+ {
9766
+ path: ["organization", "member", "invitation-resend"],
9767
+ procedure: "organization.resendOrganizationMemberInvitation",
9768
+ operation: "mutation",
9769
+ summary: "Resend the invitation email to a pending legacy (policy v1) member; reports deliveryStatus and the stored emailDeliveryStatus.",
9770
+ effects: ["state-change", "email"],
9771
+ target: "memberId",
9772
+ dates: [],
9773
+ input: {
9774
+ type: "object",
9775
+ properties: {
9776
+ organizationId: {
9777
+ type: "string",
9778
+ minLength: 1
9779
+ },
9780
+ memberId: {
9781
+ type: "string",
9782
+ minLength: 1
9783
+ }
9784
+ },
9785
+ required: ["organizationId", "memberId"]
9786
+ }
9787
+ },
8440
9788
  {
8441
9789
  path: ["organization", "member", "remove"],
8442
9790
  procedure: "organization.deleteOrganizationMember",
@@ -8659,7 +10007,7 @@ var command_manifest_default = [
8659
10007
  path: ["organization", "invitation", "resend"],
8660
10008
  procedure: "organization.resendInvitation",
8661
10009
  operation: "mutation",
8662
- summary: "Resend a pending organization invitation email.",
10010
+ summary: "Replace a pending organization invitation and email it; reports deliveryStatus and the stored emailDeliveryStatus.",
8663
10011
  effects: ["state-change", "email"],
8664
10012
  target: "invitationId",
8665
10013
  dates: [],
@@ -9510,7 +10858,7 @@ var command_manifest_default = [
9510
10858
  path: ["event", "access", "list"],
9511
10859
  procedure: "access.listEventAssignments",
9512
10860
  operation: "query",
9513
- summary: "List event staff assignments and pending staff invitations.",
10861
+ summary: "List event staff assignments and pending staff invitations, with each invitation's stored emailDeliveryStatus.",
9514
10862
  effects: [],
9515
10863
  dates: [],
9516
10864
  input: {
@@ -9532,7 +10880,7 @@ var command_manifest_default = [
9532
10880
  path: ["event", "access", "invite"],
9533
10881
  procedure: "access.inviteEventStaff",
9534
10882
  operation: "mutation",
9535
- summary: "Invite event staff by email. startsAt/expiresAt are ISO date-times or null.",
10883
+ summary: "Invite event staff by email; reports deliveryStatus and the stored emailDeliveryStatus. startsAt/expiresAt are ISO date-times or null.",
9536
10884
  effects: ["state-change", "email"],
9537
10885
  target: "email",
9538
10886
  dates: ["expiresAt", "startsAt"],
@@ -9588,7 +10936,7 @@ var command_manifest_default = [
9588
10936
  path: ["event", "access", "invitation-resend"],
9589
10937
  procedure: "access.resendEventStaffInvitation",
9590
10938
  operation: "mutation",
9591
- summary: "Resend a pending event staff invitation email.",
10939
+ summary: "Replace a pending event staff invitation and email it; reports deliveryStatus and the stored emailDeliveryStatus.",
9592
10940
  effects: ["state-change", "email"],
9593
10941
  target: "invitationId",
9594
10942
  dates: [],
@@ -11810,6 +13158,36 @@ var parseRetainedIds = (value) => {
11810
13158
  return parsed;
11811
13159
  };
11812
13160
  var luckyDrawParticipantFields = new Set(["email", "luckyDrawId", "name"]);
13161
+ var asParticipantRecord = (participant, index) => {
13162
+ if (typeof participant !== "object" || participant === null || Array.isArray(participant)) {
13163
+ throw new CliUsageError(`--participants[${index}] must be an object.`);
13164
+ }
13165
+ if (Object.keys(participant).some((key) => !luckyDrawParticipantFields.has(key))) {
13166
+ throw new CliUsageError(`--participants[${index}] contains an unsupported field.`);
13167
+ }
13168
+ return participant;
13169
+ };
13170
+ var readParticipantField = (participant, key) => (key in participant) ? participant[key] : undefined;
13171
+ var parseLuckyDrawParticipant = (participant, index) => {
13172
+ const record = asParticipantRecord(participant, index);
13173
+ const luckyDrawId = readParticipantField(record, "luckyDrawId");
13174
+ const name = readParticipantField(record, "name");
13175
+ const email = readParticipantField(record, "email");
13176
+ if (typeof luckyDrawId !== "string") {
13177
+ throw new CliUsageError(`--participants[${index}].luckyDrawId must be a string.`);
13178
+ }
13179
+ if (name !== undefined && typeof name !== "string") {
13180
+ throw new CliUsageError(`--participants[${index}].name must be a string.`);
13181
+ }
13182
+ if (email !== undefined && email !== null && typeof email !== "string") {
13183
+ throw new CliUsageError(`--participants[${index}].email must be a string or null.`);
13184
+ }
13185
+ return {
13186
+ luckyDrawId,
13187
+ ...name === undefined ? {} : { name },
13188
+ ...email === undefined ? {} : { email }
13189
+ };
13190
+ };
11813
13191
  var parseLuckyDrawParticipants = (value) => {
11814
13192
  let parsed;
11815
13193
  try {
@@ -11820,31 +13198,7 @@ var parseLuckyDrawParticipants = (value) => {
11820
13198
  if (!Array.isArray(parsed)) {
11821
13199
  throw new CliUsageError("--participants must be a JSON array.");
11822
13200
  }
11823
- return parsed.map((participant, index) => {
11824
- if (typeof participant !== "object" || participant === null || Array.isArray(participant)) {
11825
- throw new CliUsageError(`--participants[${index}] must be an object.`);
11826
- }
11827
- if (Object.keys(participant).some((key) => !luckyDrawParticipantFields.has(key))) {
11828
- throw new CliUsageError(`--participants[${index}] contains an unsupported field.`);
11829
- }
11830
- const luckyDrawId = "luckyDrawId" in participant ? participant.luckyDrawId : undefined;
11831
- const name = "name" in participant ? participant.name : undefined;
11832
- const email = "email" in participant ? participant.email : undefined;
11833
- if (typeof luckyDrawId !== "string") {
11834
- throw new CliUsageError(`--participants[${index}].luckyDrawId must be a string.`);
11835
- }
11836
- if (name !== undefined && typeof name !== "string") {
11837
- throw new CliUsageError(`--participants[${index}].name must be a string.`);
11838
- }
11839
- if (email !== undefined && email !== null && typeof email !== "string") {
11840
- throw new CliUsageError(`--participants[${index}].email must be a string or null.`);
11841
- }
11842
- return {
11843
- luckyDrawId,
11844
- ...name === undefined ? {} : { name },
11845
- ...email === undefined ? {} : { email }
11846
- };
11847
- });
13201
+ return parsed.map(parseLuckyDrawParticipant);
11848
13202
  };
11849
13203
  var parseAppearanceMediaType = (value) => {
11850
13204
  if (value === "image" || value === "video")
@@ -11892,6 +13246,361 @@ var parseIsoDateTime = (value, name) => {
11892
13246
  }
11893
13247
  return parsed;
11894
13248
  };
13249
+ var commandKey = (action, subAction) => JSON.stringify([action ?? null, subAction ?? null]);
13250
+ var runAuthLogin = async ({
13251
+ parsed,
13252
+ runtime,
13253
+ credentialStore,
13254
+ apiBaseUrl,
13255
+ cliVersion
13256
+ }) => {
13257
+ assertPositionalCount(parsed, 2);
13258
+ assertOnlyFlags(parsed, ["no-browser"]);
13259
+ const credentials = await loginWithBrowser({
13260
+ apiBaseUrl,
13261
+ clientVersion: cliVersion,
13262
+ onVerification: ({ browserOpened, userCode, verificationUriComplete }) => {
13263
+ runtime.stderr.write(`${browserOpened ? "Opened" : "Open"} ${verificationUriComplete}
13264
+ Code: ${userCode}
13265
+ Waiting for approval\u2026
13266
+ `);
13267
+ },
13268
+ ...parsed.flags.get("no-browser") === true ? { openBrowser: async () => false } : {},
13269
+ store: credentialStore
13270
+ });
13271
+ writeSuccess(runtime, {
13272
+ authenticated: true,
13273
+ session: credentials.session,
13274
+ storage: "Bun.secrets"
13275
+ });
13276
+ };
13277
+ var runAuthStatus = async ({
13278
+ parsed,
13279
+ runtime,
13280
+ credentialStore,
13281
+ apiBaseUrl
13282
+ }) => {
13283
+ assertPositionalCount(parsed, 2);
13284
+ assertOnlyFlags(parsed, []);
13285
+ const credentials = await credentialStore.get();
13286
+ writeSuccess(runtime, credentials && isCliCredentialForIssuer(credentials, apiBaseUrl) ? {
13287
+ authenticated: true,
13288
+ accessTokenExpiresAt: credentials.accessTokenExpiresAt,
13289
+ refreshTokenExpiresAt: credentials.refreshTokenExpiresAt,
13290
+ session: credentials.session,
13291
+ storage: "Bun.secrets"
13292
+ } : { authenticated: false, storage: "Bun.secrets" });
13293
+ };
13294
+ var runAuthLogout = async ({
13295
+ parsed,
13296
+ runtime,
13297
+ credentialStore,
13298
+ apiBaseUrl
13299
+ }) => {
13300
+ assertPositionalCount(parsed, 2);
13301
+ assertOnlyFlags(parsed, []);
13302
+ writeSuccess(runtime, {
13303
+ loggedOut: true,
13304
+ ...await logoutCliSession({ apiBaseUrl, store: credentialStore })
13305
+ });
13306
+ };
13307
+ var runAuthWhoami = async ({
13308
+ parsed,
13309
+ runtime,
13310
+ ensureAuthentication
13311
+ }) => {
13312
+ assertPositionalCount(parsed, 2);
13313
+ assertOnlyFlags(parsed, []);
13314
+ await ensureAuthentication();
13315
+ writeSuccess(runtime, await api2.auth.whoami.query(undefined));
13316
+ };
13317
+ var runOrganizationList = async ({
13318
+ parsed,
13319
+ runtime,
13320
+ ensureAuthentication
13321
+ }) => {
13322
+ assertPositionalCount(parsed, 2);
13323
+ assertOnlyFlags(parsed, []);
13324
+ await ensureAuthentication();
13325
+ writeSuccess(runtime, await api2.organization.getOrganizationsForUser.query(undefined));
13326
+ };
13327
+ var runOrganizationGet = async ({
13328
+ parsed,
13329
+ runtime,
13330
+ ensureAuthentication
13331
+ }) => {
13332
+ assertPositionalCount(parsed, 2);
13333
+ assertOnlyFlags(parsed, ["organization-id"]);
13334
+ await ensureAuthentication();
13335
+ writeSuccess(runtime, await api2.organization.getOrganizationById.query({
13336
+ organizationId: getRequiredFlag(parsed, "organization-id")
13337
+ }));
13338
+ };
13339
+ var runOrganizationCreate = async ({
13340
+ parsed,
13341
+ runtime,
13342
+ ensureAuthentication
13343
+ }) => {
13344
+ assertPositionalCount(parsed, 2);
13345
+ assertOnlyFlags(parsed, ["name", "owner-email", "allowed-event-types"]);
13346
+ const allowedEventTypes = getOptionalFlag(parsed, "allowed-event-types");
13347
+ const input = {
13348
+ name: getRequiredFlag(parsed, "name"),
13349
+ ownerEmail: getRequiredFlag(parsed, "owner-email"),
13350
+ ...allowedEventTypes === undefined ? {} : { allowedEventTypes: parseEventTypeList(allowedEventTypes) }
13351
+ };
13352
+ await ensureAuthentication();
13353
+ writeSuccess(runtime, await api2.admin.organization.createOrganization.mutate(input));
13354
+ };
13355
+ var runEventCreate = async ({
13356
+ parsed,
13357
+ runtime,
13358
+ ensureAuthentication
13359
+ }) => {
13360
+ assertPositionalCount(parsed, 2);
13361
+ assertOnlyFlags(parsed, [
13362
+ "organization-id",
13363
+ "name",
13364
+ "type",
13365
+ "start",
13366
+ "end",
13367
+ "location"
13368
+ ]);
13369
+ const end = getOptionalFlag(parsed, "end");
13370
+ const input = {
13371
+ organizationId: getRequiredFlag(parsed, "organization-id"),
13372
+ name: getRequiredFlag(parsed, "name"),
13373
+ type: parseCreatableEventType(getRequiredFlag(parsed, "type")),
13374
+ location: getRequiredFlag(parsed, "location"),
13375
+ eventDateRange: {
13376
+ from: parseIsoDateTime(getRequiredFlag(parsed, "start"), "start"),
13377
+ ...end === undefined ? {} : { to: parseIsoDateTime(end, "end") }
13378
+ }
13379
+ };
13380
+ await ensureAuthentication();
13381
+ writeSuccess(runtime, await api2.event.createEvent.mutate(input));
13382
+ };
13383
+ var runEventList = async ({
13384
+ parsed,
13385
+ runtime,
13386
+ ensureAuthentication
13387
+ }) => {
13388
+ assertPositionalCount(parsed, 2);
13389
+ assertOnlyFlags(parsed, [
13390
+ "organization-id",
13391
+ "page",
13392
+ "per-page",
13393
+ "name",
13394
+ "status",
13395
+ "archive-status"
13396
+ ]);
13397
+ const input = {
13398
+ organizationId: getRequiredFlag(parsed, "organization-id"),
13399
+ page: parsePositiveInteger(getOptionalFlag(parsed, "page") ?? "1", "page"),
13400
+ perPage: parsePositiveInteger(getOptionalFlag(parsed, "per-page") ?? "20", "per-page"),
13401
+ name: getOptionalFlag(parsed, "name") ?? "",
13402
+ status: parseEventListStatus(getOptionalFlag(parsed, "status") ?? "ALL"),
13403
+ archiveStatus: parseArchiveStatus(getOptionalFlag(parsed, "archive-status") ?? "active")
13404
+ };
13405
+ await ensureAuthentication();
13406
+ writeSuccess(runtime, await api2.event.getEventsByOrgId.query(input));
13407
+ };
13408
+ var runEventGet = async ({
13409
+ parsed,
13410
+ runtime,
13411
+ ensureAuthentication
13412
+ }) => {
13413
+ assertPositionalCount(parsed, 2);
13414
+ assertOnlyFlags(parsed, ["event-id"]);
13415
+ await ensureAuthentication();
13416
+ writeSuccess(runtime, await api2.event.getEventForNav.query({
13417
+ eventId: getRequiredFlag(parsed, "event-id")
13418
+ }));
13419
+ };
13420
+ var runEventAppearanceGet = async ({
13421
+ parsed,
13422
+ runtime,
13423
+ ensureAuthentication
13424
+ }) => {
13425
+ assertPositionalCount(parsed, 3);
13426
+ assertOnlyFlags(parsed, ["event-id", "public"]);
13427
+ const eventId = getRequiredFlag(parsed, "event-id");
13428
+ if (parsed.flags.get("public") === true) {
13429
+ writeSuccess(runtime, await api2.public.getEventAppearance.query({ eventId }));
13430
+ return;
13431
+ }
13432
+ await ensureAuthentication();
13433
+ writeSuccess(runtime, await api2.event.getEventAppearance.query({
13434
+ eventId
13435
+ }));
13436
+ };
13437
+ var runEventAppearanceUpdate = async ({
13438
+ parsed,
13439
+ runtime,
13440
+ ensureAuthentication
13441
+ }) => {
13442
+ assertPositionalCount(parsed, 3);
13443
+ assertOnlyFlags(parsed, [
13444
+ "event-id",
13445
+ "appearance-version",
13446
+ "appearance",
13447
+ "reset"
13448
+ ]);
13449
+ const reset = parsed.positionals[2] === "reset" || parsed.flags.get("reset") === true;
13450
+ const appearanceValue = getOptionalFlag(parsed, "appearance");
13451
+ if (reset && appearanceValue !== undefined) {
13452
+ throw new CliUsageError("Use either --appearance or --reset, not both.");
13453
+ }
13454
+ if (!reset && appearanceValue === undefined) {
13455
+ throw new CliUsageError("--appearance is required unless --reset is provided.");
13456
+ }
13457
+ const input = {
13458
+ eventId: getRequiredFlag(parsed, "event-id"),
13459
+ appearanceVersion: parseNonnegativeInteger(getRequiredFlag(parsed, "appearance-version"), "appearance-version"),
13460
+ appearance: reset ? null : parseAppearance(appearanceValue)
13461
+ };
13462
+ await ensureAuthentication();
13463
+ writeSuccess(runtime, await api2.event.updateEventAppearance.mutate(input));
13464
+ };
13465
+ var runEventAppearanceUpload = async ({
13466
+ parsed,
13467
+ runtime,
13468
+ ensureAuthentication
13469
+ }) => {
13470
+ assertPositionalCount(parsed, 3);
13471
+ assertOnlyFlags(parsed, ["event-id", "file", "content-type", "media-type"]);
13472
+ const eventId = getRequiredFlag(parsed, "event-id");
13473
+ const filePath = getRequiredFlag(parsed, "file");
13474
+ const contentType = getRequiredFlag(parsed, "content-type");
13475
+ const mediaType = parseAppearanceMediaType(getRequiredFlag(parsed, "media-type"));
13476
+ const file = await readFile4(filePath);
13477
+ await ensureAuthentication();
13478
+ const signed = await api2.attachment.getPresignedUrlToUpload.mutate({
13479
+ folder: `event-appearance/${mediaType === "image" ? "images" : "videos"}`,
13480
+ fileName: basename2(filePath),
13481
+ contentType,
13482
+ size: file.byteLength,
13483
+ eventId
13484
+ });
13485
+ const uploadResponse = await fetch(signed.uploadUrl, {
13486
+ method: "PUT",
13487
+ headers: { "content-type": contentType },
13488
+ body: file
13489
+ });
13490
+ if (!uploadResponse.ok) {
13491
+ throw new Error(`Appearance media upload failed with HTTP ${uploadResponse.status}.`);
13492
+ }
13493
+ writeSuccess(runtime, signed);
13494
+ };
13495
+ var runPhotoWallDisplayItems = async ({
13496
+ parsed,
13497
+ runtime,
13498
+ ensureAuthentication
13499
+ }) => {
13500
+ assertPositionalCount(parsed, 3);
13501
+ assertOnlyFlags(parsed, ["event-id", "limit", "cursor", "retained-ids"]);
13502
+ const cursorValue = getOptionalFlag(parsed, "cursor");
13503
+ const retainedIdsValue = getOptionalFlag(parsed, "retained-ids");
13504
+ const input = {
13505
+ eventId: getRequiredFlag(parsed, "event-id"),
13506
+ limit: parseBoundedInteger(getOptionalFlag(parsed, "limit") ?? "30", "limit", 1, 60),
13507
+ ...cursorValue === undefined ? {} : { cursor: parseCursor(cursorValue) },
13508
+ retainedIds: retainedIdsValue === undefined ? [] : parseRetainedIds(retainedIdsValue)
13509
+ };
13510
+ await ensureAuthentication();
13511
+ writeSuccess(runtime, await api2.event.photoWall.getPhotoWallDisplayItems.query(input));
13512
+ };
13513
+ var runLuckyDrawPreDraw = async ({
13514
+ parsed,
13515
+ runtime,
13516
+ ensureAuthentication
13517
+ }) => {
13518
+ assertPositionalCount(parsed, 2);
13519
+ assertOnlyFlags(parsed, ["event-id", "prize-count"]);
13520
+ const input = {
13521
+ eventId: getRequiredFlag(parsed, "event-id"),
13522
+ prizeCount: parsePositiveInteger(getRequiredFlag(parsed, "prize-count"), "prize-count")
13523
+ };
13524
+ await ensureAuthentication();
13525
+ writeSuccess(runtime, await api2.event.luckyDraw.preDrawPrizes.mutate(input));
13526
+ };
13527
+ var runLuckyDrawParticipantsReplace = async ({
13528
+ parsed,
13529
+ runtime,
13530
+ ensureAuthentication
13531
+ }) => {
13532
+ assertPositionalCount(parsed, 3);
13533
+ assertOnlyFlags(parsed, [
13534
+ "event-id",
13535
+ "participants",
13536
+ "participants-file",
13537
+ "allow-state-change",
13538
+ "target"
13539
+ ]);
13540
+ const eventId = getRequiredFlag(parsed, "event-id");
13541
+ assertStateChangeTarget(parsed, eventId);
13542
+ const input = {
13543
+ eventId,
13544
+ participants: parseLuckyDrawParticipants(await readInlineOrFile(parsed, "participants", "participants-file"))
13545
+ };
13546
+ await ensureAuthentication();
13547
+ writeSuccess(runtime, await api2.event.luckyDraw.createLuckyDrawParticipant.mutate(input));
13548
+ };
13549
+ var runLuckyDrawParticipantsList = async ({
13550
+ parsed,
13551
+ runtime,
13552
+ ensureAuthentication
13553
+ }) => {
13554
+ assertPositionalCount(parsed, 3);
13555
+ assertOnlyFlags(parsed, ["event-id", "page", "per-page"]);
13556
+ const input = {
13557
+ eventId: getRequiredFlag(parsed, "event-id"),
13558
+ page: parsePositiveInteger(getOptionalFlag(parsed, "page") ?? "1", "page"),
13559
+ perPage: parseBoundedInteger(getOptionalFlag(parsed, "per-page") ?? "100", "per-page", 1, 100)
13560
+ };
13561
+ await ensureAuthentication();
13562
+ writeSuccess(runtime, await api2.event.luckyDraw.getLuckyDrawParticipantsByEventId.query(input));
13563
+ };
13564
+ var organizationCommands = new Map([
13565
+ [commandKey("list"), runOrganizationList],
13566
+ [commandKey("get"), runOrganizationGet],
13567
+ [commandKey("create"), runOrganizationCreate]
13568
+ ]);
13569
+ var commandTable = new Map([
13570
+ [
13571
+ "auth",
13572
+ new Map([
13573
+ [commandKey("login"), runAuthLogin],
13574
+ [commandKey("status"), runAuthStatus],
13575
+ [commandKey("logout"), runAuthLogout],
13576
+ [commandKey("whoami"), runAuthWhoami]
13577
+ ])
13578
+ ],
13579
+ ["organization", organizationCommands],
13580
+ ["org", organizationCommands],
13581
+ [
13582
+ "event",
13583
+ new Map([
13584
+ [commandKey("create"), runEventCreate],
13585
+ [commandKey("list"), runEventList],
13586
+ [commandKey("get"), runEventGet],
13587
+ [commandKey("appearance", "get"), runEventAppearanceGet],
13588
+ [commandKey("appearance", "update"), runEventAppearanceUpdate],
13589
+ [commandKey("appearance", "reset"), runEventAppearanceUpdate],
13590
+ [commandKey("appearance", "upload"), runEventAppearanceUpload],
13591
+ [commandKey("photo-wall", "display-items"), runPhotoWallDisplayItems],
13592
+ [commandKey("photo-wall", "display"), runPhotoWallDisplayItems]
13593
+ ])
13594
+ ],
13595
+ [
13596
+ "lucky-draw",
13597
+ new Map([
13598
+ [commandKey("pre-draw"), runLuckyDrawPreDraw],
13599
+ [commandKey("participants", "replace"), runLuckyDrawParticipantsReplace],
13600
+ [commandKey("participants", "list"), runLuckyDrawParticipantsList]
13601
+ ])
13602
+ ]
13603
+ ]);
11895
13604
  var runCommand = async (parsed, runtime, credentialStore, apiBaseUrl, configureAccessToken) => {
11896
13605
  const [group, action, subAction] = parsed.positionals;
11897
13606
  const cliVersion = getInstalledCliVersion();
@@ -11934,227 +13643,6 @@ var runCommand = async (parsed, runtime, credentialStore, apiBaseUrl, configureA
11934
13643
  });
11935
13644
  return;
11936
13645
  }
11937
- if (group === "auth" && action === "login" && subAction === undefined) {
11938
- assertPositionalCount(parsed, 2);
11939
- assertOnlyFlags(parsed, ["no-browser"]);
11940
- const credentials = await loginWithBrowser({
11941
- apiBaseUrl,
11942
- clientVersion: cliVersion,
11943
- onVerification: ({
11944
- browserOpened,
11945
- userCode,
11946
- verificationUriComplete
11947
- }) => {
11948
- runtime.stderr.write(`${browserOpened ? "Opened" : "Open"} ${verificationUriComplete}
11949
- Code: ${userCode}
11950
- Waiting for approval\u2026
11951
- `);
11952
- },
11953
- ...parsed.flags.get("no-browser") === true ? { openBrowser: async () => false } : {},
11954
- store: credentialStore
11955
- });
11956
- writeSuccess(runtime, {
11957
- authenticated: true,
11958
- session: credentials.session,
11959
- storage: "Bun.secrets"
11960
- });
11961
- return;
11962
- }
11963
- if (group === "auth" && action === "status" && subAction === undefined) {
11964
- assertPositionalCount(parsed, 2);
11965
- assertOnlyFlags(parsed, []);
11966
- const credentials = await credentialStore.get();
11967
- writeSuccess(runtime, credentials && isCliCredentialForIssuer(credentials, apiBaseUrl) ? {
11968
- authenticated: true,
11969
- accessTokenExpiresAt: credentials.accessTokenExpiresAt,
11970
- refreshTokenExpiresAt: credentials.refreshTokenExpiresAt,
11971
- session: credentials.session,
11972
- storage: "Bun.secrets"
11973
- } : { authenticated: false, storage: "Bun.secrets" });
11974
- return;
11975
- }
11976
- if (group === "auth" && action === "logout" && subAction === undefined) {
11977
- assertPositionalCount(parsed, 2);
11978
- assertOnlyFlags(parsed, []);
11979
- writeSuccess(runtime, {
11980
- loggedOut: true,
11981
- ...await logoutCliSession({ apiBaseUrl, store: credentialStore })
11982
- });
11983
- return;
11984
- }
11985
- if (group === "auth" && action === "whoami" && subAction === undefined) {
11986
- assertPositionalCount(parsed, 2);
11987
- assertOnlyFlags(parsed, []);
11988
- await ensureAuthentication();
11989
- writeSuccess(runtime, await api2.auth.whoami.query(undefined));
11990
- return;
11991
- }
11992
- if ((group === "organization" || group === "org") && action === "list" && subAction === undefined) {
11993
- assertPositionalCount(parsed, 2);
11994
- assertOnlyFlags(parsed, []);
11995
- await ensureAuthentication();
11996
- writeSuccess(runtime, await api2.organization.getOrganizationsForUser.query(undefined));
11997
- return;
11998
- }
11999
- if ((group === "organization" || group === "org") && action === "get" && subAction === undefined) {
12000
- assertPositionalCount(parsed, 2);
12001
- assertOnlyFlags(parsed, ["organization-id"]);
12002
- await ensureAuthentication();
12003
- writeSuccess(runtime, await api2.organization.getOrganizationById.query({
12004
- organizationId: getRequiredFlag(parsed, "organization-id")
12005
- }));
12006
- return;
12007
- }
12008
- if ((group === "organization" || group === "org") && action === "create" && subAction === undefined) {
12009
- assertPositionalCount(parsed, 2);
12010
- assertOnlyFlags(parsed, ["name", "owner-email", "allowed-event-types"]);
12011
- const allowedEventTypes = getOptionalFlag(parsed, "allowed-event-types");
12012
- const input = {
12013
- name: getRequiredFlag(parsed, "name"),
12014
- ownerEmail: getRequiredFlag(parsed, "owner-email"),
12015
- ...allowedEventTypes === undefined ? {} : { allowedEventTypes: parseEventTypeList(allowedEventTypes) }
12016
- };
12017
- await ensureAuthentication();
12018
- writeSuccess(runtime, await api2.admin.organization.createOrganization.mutate(input));
12019
- return;
12020
- }
12021
- if (group === "event" && action === "create" && subAction === undefined) {
12022
- assertPositionalCount(parsed, 2);
12023
- assertOnlyFlags(parsed, [
12024
- "organization-id",
12025
- "name",
12026
- "type",
12027
- "start",
12028
- "end",
12029
- "location"
12030
- ]);
12031
- const end = getOptionalFlag(parsed, "end");
12032
- const input = {
12033
- organizationId: getRequiredFlag(parsed, "organization-id"),
12034
- name: getRequiredFlag(parsed, "name"),
12035
- type: parseCreatableEventType(getRequiredFlag(parsed, "type")),
12036
- location: getRequiredFlag(parsed, "location"),
12037
- eventDateRange: {
12038
- from: parseIsoDateTime(getRequiredFlag(parsed, "start"), "start"),
12039
- ...end === undefined ? {} : { to: parseIsoDateTime(end, "end") }
12040
- }
12041
- };
12042
- await ensureAuthentication();
12043
- writeSuccess(runtime, await api2.event.createEvent.mutate(input));
12044
- return;
12045
- }
12046
- if (group === "event" && action === "list" && subAction === undefined) {
12047
- assertPositionalCount(parsed, 2);
12048
- assertOnlyFlags(parsed, [
12049
- "organization-id",
12050
- "page",
12051
- "per-page",
12052
- "name",
12053
- "status",
12054
- "archive-status"
12055
- ]);
12056
- const input = {
12057
- organizationId: getRequiredFlag(parsed, "organization-id"),
12058
- page: parsePositiveInteger(getOptionalFlag(parsed, "page") ?? "1", "page"),
12059
- perPage: parsePositiveInteger(getOptionalFlag(parsed, "per-page") ?? "20", "per-page"),
12060
- name: getOptionalFlag(parsed, "name") ?? "",
12061
- status: parseEventListStatus(getOptionalFlag(parsed, "status") ?? "ALL"),
12062
- archiveStatus: parseArchiveStatus(getOptionalFlag(parsed, "archive-status") ?? "active")
12063
- };
12064
- await ensureAuthentication();
12065
- writeSuccess(runtime, await api2.event.getEventsByOrgId.query(input));
12066
- return;
12067
- }
12068
- if (group === "event" && action === "get" && subAction === undefined) {
12069
- assertPositionalCount(parsed, 2);
12070
- assertOnlyFlags(parsed, ["event-id"]);
12071
- await ensureAuthentication();
12072
- writeSuccess(runtime, await api2.event.getEventForNav.query({
12073
- eventId: getRequiredFlag(parsed, "event-id")
12074
- }));
12075
- return;
12076
- }
12077
- if (group === "event" && action === "appearance" && subAction === "get") {
12078
- assertPositionalCount(parsed, 3);
12079
- assertOnlyFlags(parsed, ["event-id", "public"]);
12080
- const eventId = getRequiredFlag(parsed, "event-id");
12081
- if (parsed.flags.get("public") === true) {
12082
- writeSuccess(runtime, await api2.public.getEventAppearance.query({ eventId }));
12083
- return;
12084
- }
12085
- await ensureAuthentication();
12086
- writeSuccess(runtime, await api2.event.getEventAppearance.query({
12087
- eventId
12088
- }));
12089
- return;
12090
- }
12091
- if (group === "event" && action === "appearance" && (subAction === "update" || subAction === "reset")) {
12092
- assertPositionalCount(parsed, 3);
12093
- assertOnlyFlags(parsed, [
12094
- "event-id",
12095
- "appearance-version",
12096
- "appearance",
12097
- "reset"
12098
- ]);
12099
- const reset = subAction === "reset" || parsed.flags.get("reset") === true;
12100
- const appearanceValue = getOptionalFlag(parsed, "appearance");
12101
- if (reset && appearanceValue !== undefined) {
12102
- throw new CliUsageError("Use either --appearance or --reset, not both.");
12103
- }
12104
- if (!reset && appearanceValue === undefined) {
12105
- throw new CliUsageError("--appearance is required unless --reset is provided.");
12106
- }
12107
- const input = {
12108
- eventId: getRequiredFlag(parsed, "event-id"),
12109
- appearanceVersion: parseNonnegativeInteger(getRequiredFlag(parsed, "appearance-version"), "appearance-version"),
12110
- appearance: reset ? null : parseAppearance(appearanceValue)
12111
- };
12112
- await ensureAuthentication();
12113
- writeSuccess(runtime, await api2.event.updateEventAppearance.mutate(input));
12114
- return;
12115
- }
12116
- if (group === "event" && action === "appearance" && subAction === "upload") {
12117
- assertPositionalCount(parsed, 3);
12118
- assertOnlyFlags(parsed, ["event-id", "file", "content-type", "media-type"]);
12119
- const eventId = getRequiredFlag(parsed, "event-id");
12120
- const filePath = getRequiredFlag(parsed, "file");
12121
- const contentType = getRequiredFlag(parsed, "content-type");
12122
- const mediaType = parseAppearanceMediaType(getRequiredFlag(parsed, "media-type"));
12123
- const file = await readFile4(filePath);
12124
- await ensureAuthentication();
12125
- const signed = await api2.attachment.getPresignedUrlToUpload.mutate({
12126
- folder: `event-appearance/${mediaType === "image" ? "images" : "videos"}`,
12127
- fileName: basename2(filePath),
12128
- contentType,
12129
- size: file.byteLength,
12130
- eventId
12131
- });
12132
- const uploadResponse = await fetch(signed.uploadUrl, {
12133
- method: "PUT",
12134
- headers: { "content-type": contentType },
12135
- body: file
12136
- });
12137
- if (!uploadResponse.ok) {
12138
- throw new Error(`Appearance media upload failed with HTTP ${uploadResponse.status}.`);
12139
- }
12140
- writeSuccess(runtime, signed);
12141
- return;
12142
- }
12143
- if (group === "event" && action === "photo-wall" && (subAction === "display-items" || subAction === "display")) {
12144
- assertPositionalCount(parsed, 3);
12145
- assertOnlyFlags(parsed, ["event-id", "limit", "cursor", "retained-ids"]);
12146
- const cursorValue = getOptionalFlag(parsed, "cursor");
12147
- const retainedIdsValue = getOptionalFlag(parsed, "retained-ids");
12148
- const input = {
12149
- eventId: getRequiredFlag(parsed, "event-id"),
12150
- limit: parseBoundedInteger(getOptionalFlag(parsed, "limit") ?? "30", "limit", 1, 60),
12151
- ...cursorValue === undefined ? {} : { cursor: parseCursor(cursorValue) },
12152
- retainedIds: retainedIdsValue === undefined ? [] : parseRetainedIds(retainedIdsValue)
12153
- };
12154
- await ensureAuthentication();
12155
- writeSuccess(runtime, await api2.event.photoWall.getPhotoWallDisplayItems.query(input));
12156
- return;
12157
- }
12158
13646
  if (group === "lucky-draw" && await runLuckyDrawSetupCommand({
12159
13647
  parsed,
12160
13648
  runtime,
@@ -12162,49 +13650,18 @@ Waiting for approval\u2026
12162
13650
  })) {
12163
13651
  return;
12164
13652
  }
12165
- if (group === "lucky-draw" && action === "pre-draw" && subAction === undefined) {
12166
- assertPositionalCount(parsed, 2);
12167
- assertOnlyFlags(parsed, ["event-id", "prize-count"]);
12168
- const input = {
12169
- eventId: getRequiredFlag(parsed, "event-id"),
12170
- prizeCount: parsePositiveInteger(getRequiredFlag(parsed, "prize-count"), "prize-count")
12171
- };
12172
- await ensureAuthentication();
12173
- writeSuccess(runtime, await api2.event.luckyDraw.preDrawPrizes.mutate(input));
12174
- return;
12175
- }
12176
- if (group === "lucky-draw" && action === "participants" && subAction === "replace") {
12177
- assertPositionalCount(parsed, 3);
12178
- assertOnlyFlags(parsed, [
12179
- "event-id",
12180
- "participants",
12181
- "participants-file",
12182
- "allow-state-change",
12183
- "target"
12184
- ]);
12185
- const eventId = getRequiredFlag(parsed, "event-id");
12186
- assertStateChangeTarget(parsed, eventId);
12187
- const input = {
12188
- eventId,
12189
- participants: parseLuckyDrawParticipants(await readInlineOrFile(parsed, "participants", "participants-file"))
12190
- };
12191
- await ensureAuthentication();
12192
- writeSuccess(runtime, await api2.event.luckyDraw.createLuckyDrawParticipant.mutate(input));
12193
- return;
12194
- }
12195
- if (group === "lucky-draw" && action === "participants" && subAction === "list") {
12196
- assertPositionalCount(parsed, 3);
12197
- assertOnlyFlags(parsed, ["event-id", "page", "per-page"]);
12198
- const input = {
12199
- eventId: getRequiredFlag(parsed, "event-id"),
12200
- page: parsePositiveInteger(getOptionalFlag(parsed, "page") ?? "1", "page"),
12201
- perPage: parseBoundedInteger(getOptionalFlag(parsed, "per-page") ?? "100", "per-page", 1, 100)
12202
- };
12203
- await ensureAuthentication();
12204
- writeSuccess(runtime, await api2.event.luckyDraw.getLuckyDrawParticipantsByEventId.query(input));
12205
- return;
13653
+ const handler = group === undefined ? undefined : commandTable.get(group)?.get(commandKey(action, subAction));
13654
+ if (handler === undefined) {
13655
+ throw new CliUsageError("Unknown command. Run `et --help` for available commands.");
12206
13656
  }
12207
- throw new CliUsageError("Unknown command. Run `et --help` for available commands.");
13657
+ await handler({
13658
+ parsed,
13659
+ runtime,
13660
+ credentialStore,
13661
+ apiBaseUrl,
13662
+ cliVersion,
13663
+ ensureAuthentication
13664
+ });
12208
13665
  };
12209
13666
  var runCli = async (args, runtime = processRuntime, credentialStore = createBunCredentialStore({
12210
13667
  product: "event-tech"