@usesocial/cli 0.11.3 → 0.11.5

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.mjs CHANGED
@@ -3,7 +3,6 @@ import { createRequire } from "node:module";
3
3
  import * as fs from "node:fs";
4
4
  import { createReadStream, mkdirSync, readFileSync, realpathSync, writeFileSync } from "node:fs";
5
5
  import { fileURLToPath } from "node:url";
6
- import { Result, TaggedError } from "better-result";
7
6
  import { homedir } from "node:os";
8
7
  import { basename, dirname, extname, join, resolve } from "node:path";
9
8
  import { parseArgs, styleText } from "node:util";
@@ -41,6 +40,367 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
41
40
  }) : target, mod));
42
41
  var __require = /* @__PURE__ */ createRequire(import.meta.url);
43
42
  //#endregion
43
+ //#region ../../node_modules/.bun/better-result@2.9.2/node_modules/better-result/dist/index.mjs
44
+ function e(e, t) {
45
+ return e === 2 ? ((...e) => e.length >= 2 ? t(e[0], e[1]) : (n) => t(n, e[0])) : e === 3 ? ((...e) => e.length >= 3 ? t(e[0], e[1], e[2]) : (n) => t(n, e[0], e[1])) : e === 4 ? ((...e) => e.length >= 4 ? t(e[0], e[1], e[2], e[3]) : (n) => t(n, e[0], e[1], e[2])) : ((...n) => n.length >= e ? t(...n) : (e) => t(e, ...n));
46
+ }
47
+ const t = (e) => e instanceof Error ? {
48
+ name: e.name,
49
+ message: e.message,
50
+ stack: e.stack
51
+ } : e;
52
+ var n$1 = class e extends Error {
53
+ _tag = `Panic`;
54
+ static is(t) {
55
+ return t instanceof e;
56
+ }
57
+ constructor(e) {
58
+ if (super(e.message, e.cause === void 0 ? void 0 : { cause: e.cause }), Object.assign(this, e), Object.setPrototypeOf(this, new.target.prototype), this.name = `Panic`, e.cause instanceof Error && e.cause.stack) {
59
+ let t = e.cause.stack.replace(/\n/g, `
60
+ `);
61
+ this.stack = `${this.stack}\nCaused by: ${t}`;
62
+ }
63
+ }
64
+ toJSON() {
65
+ return {
66
+ ...this,
67
+ _tag: this._tag,
68
+ name: this.name,
69
+ message: this.message,
70
+ cause: t(this.cause),
71
+ stack: this.stack
72
+ };
73
+ }
74
+ *[Symbol.iterator]() {
75
+ return yield* d$1(this), i$1(`Unreachable: Err yielded in Panic but generator continued`, this);
76
+ }
77
+ };
78
+ const i$1 = (e, t) => {
79
+ throw new n$1({
80
+ message: e,
81
+ cause: t
82
+ });
83
+ }, a = (e, t) => {
84
+ try {
85
+ return e();
86
+ } catch (e) {
87
+ throw i$1(t, e);
88
+ }
89
+ }, o = async (e, t) => {
90
+ try {
91
+ return await e();
92
+ } catch (e) {
93
+ throw i$1(t, e);
94
+ }
95
+ };
96
+ var s = class e {
97
+ status = `ok`;
98
+ constructor(e) {
99
+ this.value = e;
100
+ }
101
+ isOk() {
102
+ return !0;
103
+ }
104
+ isErr() {
105
+ return !1;
106
+ }
107
+ map(t) {
108
+ return a(() => new e(t(this.value)), `map callback threw`);
109
+ }
110
+ mapError(e) {
111
+ return this;
112
+ }
113
+ tryRecover(e) {
114
+ return this;
115
+ }
116
+ tryRecoverAsync(e) {
117
+ return Promise.resolve(this);
118
+ }
119
+ andThen(e) {
120
+ return a(() => e(this.value), `andThen callback threw`);
121
+ }
122
+ andThenAsync(e) {
123
+ return o(() => e(this.value), `andThenAsync callback threw`);
124
+ }
125
+ match(e) {
126
+ return a(() => e.ok(this.value), `match ok handler threw`);
127
+ }
128
+ unwrap(e) {
129
+ return this.value;
130
+ }
131
+ unwrapOr(e) {
132
+ return this.value;
133
+ }
134
+ tap(e) {
135
+ return a(() => (e(this.value), this), `tap callback threw`);
136
+ }
137
+ tapAsync(e) {
138
+ return o(async () => (await e(this.value), this), `tapAsync callback threw`);
139
+ }
140
+ tapError(e) {
141
+ return this;
142
+ }
143
+ tapErrorAsync(e) {
144
+ return Promise.resolve(this);
145
+ }
146
+ tapBoth(e) {
147
+ return a(() => (e.ok(this.value), this), `tapBoth ok callback threw`);
148
+ }
149
+ tapBothAsync(e) {
150
+ return o(async () => (await e.ok(this.value), this), `tapBothAsync ok callback threw`);
151
+ }
152
+ *[Symbol.iterator]() {
153
+ return this.value;
154
+ }
155
+ }, c = class e {
156
+ status = `error`;
157
+ constructor(e) {
158
+ this.error = e;
159
+ }
160
+ isOk() {
161
+ return !1;
162
+ }
163
+ isErr() {
164
+ return !0;
165
+ }
166
+ map(e) {
167
+ return this;
168
+ }
169
+ mapError(t) {
170
+ return a(() => new e(t(this.error)), `mapError callback threw`);
171
+ }
172
+ tryRecover(e) {
173
+ return a(() => e(this.error), `tryRecover callback threw`);
174
+ }
175
+ tryRecoverAsync(e) {
176
+ return o(() => e(this.error), `tryRecoverAsync callback threw`);
177
+ }
178
+ andThen(e) {
179
+ return this;
180
+ }
181
+ andThenAsync(e) {
182
+ return Promise.resolve(this);
183
+ }
184
+ match(e) {
185
+ return a(() => e.err(this.error), `match err handler threw`);
186
+ }
187
+ unwrap(e) {
188
+ return i$1(e ?? `Unwrap called on Err: ${String(this.error)}`, this.error);
189
+ }
190
+ unwrapOr(e) {
191
+ return e;
192
+ }
193
+ tap(e) {
194
+ return this;
195
+ }
196
+ tapError(e) {
197
+ return a(() => (e(this.error), this), `tapError callback threw`);
198
+ }
199
+ tapAsync(e) {
200
+ return Promise.resolve(this);
201
+ }
202
+ tapErrorAsync(e) {
203
+ return o(async () => (await e(this.error), this), `tapErrorAsync callback threw`);
204
+ }
205
+ tapBoth(e) {
206
+ return a(() => (e.err(this.error), this), `tapBoth err callback threw`);
207
+ }
208
+ tapBothAsync(e) {
209
+ return o(async () => (await e.err(this.error), this), `tapBothAsync err callback threw`);
210
+ }
211
+ *[Symbol.iterator]() {
212
+ return yield this, i$1(`Unreachable: Err yielded in Result.gen but generator continued`, this.error);
213
+ }
214
+ };
215
+ function l$1(e) {
216
+ return new s(e);
217
+ }
218
+ const u$1 = (e) => e.status === `ok`, d$1 = (e) => new c(e), f = (e) => e.status === `error`, p = (e) => e instanceof Error ? {
219
+ name: e.name,
220
+ message: e.message,
221
+ stack: e.stack
222
+ } : e, m = (e) => e instanceof Error && `_tag` in e && typeof e._tag == `string`, h = Object.assign((e) => () => {
223
+ class t extends Error {
224
+ _tag = e;
225
+ static is(e) {
226
+ return e instanceof t;
227
+ }
228
+ constructor(t) {
229
+ let n = t && `message` in t && typeof t.message == `string` ? t.message : void 0, r = t && `cause` in t ? t.cause : void 0;
230
+ if (super(n, r === void 0 ? void 0 : { cause: r }), t && Object.assign(this, t), Object.setPrototypeOf(this, new.target.prototype), this.name = e, r instanceof Error && r.stack) {
231
+ let e = r.stack.replace(/\n/g, `
232
+ `);
233
+ this.stack = `${this.stack}\nCaused by: ${e}`;
234
+ }
235
+ }
236
+ toJSON() {
237
+ return {
238
+ ...this,
239
+ _tag: this._tag,
240
+ name: this.name,
241
+ message: this.message,
242
+ cause: p(this.cause),
243
+ stack: this.stack
244
+ };
245
+ }
246
+ *[Symbol.iterator]() {
247
+ return yield* d$1(this), i$1(`Unreachable: Err yielded in TaggedError but generator continued`, this);
248
+ }
249
+ }
250
+ return t;
251
+ }, { is: m });
252
+ var y = class extends h(`UnhandledException`)() {
253
+ constructor(e) {
254
+ let t = e.cause instanceof Error ? `Unhandled exception: ${e.cause.message}` : `Unhandled exception: ${String(e.cause)}`;
255
+ super({
256
+ message: t,
257
+ cause: e.cause
258
+ });
259
+ }
260
+ }, b = class extends h(`ResultDeserializationError`)() {
261
+ constructor(e) {
262
+ super({
263
+ message: `Failed to deserialize value as Result: expected { status: "ok", value } or { status: "error", error }`,
264
+ value: e.value
265
+ });
266
+ }
267
+ };
268
+ const x = (e, t) => {
269
+ try {
270
+ return e();
271
+ } catch (e) {
272
+ throw i$1(t, e);
273
+ }
274
+ }, S = (e, t) => {
275
+ let n = () => {
276
+ if (typeof e == `function`) try {
277
+ return l$1(e());
278
+ } catch (e) {
279
+ return d$1(new y({ cause: e }));
280
+ }
281
+ try {
282
+ return l$1(e.try());
283
+ } catch (t) {
284
+ try {
285
+ return d$1(e.catch(t));
286
+ } catch (e) {
287
+ throw i$1(`Result.try catch handler threw`, e);
288
+ }
289
+ }
290
+ }, r = t?.retry?.times ?? 0, a = n();
291
+ for (let e = 0; e < r && a.status === `error`; e++) a = n();
292
+ return a;
293
+ }, C$1 = async (e, t) => {
294
+ let n = async () => {
295
+ if (typeof e == `function`) try {
296
+ return l$1(await e());
297
+ } catch (e) {
298
+ return d$1(new y({ cause: e }));
299
+ }
300
+ try {
301
+ return l$1(await e.try());
302
+ } catch (t) {
303
+ try {
304
+ return d$1(await e.catch(t));
305
+ } catch (e) {
306
+ throw i$1(`Result.tryPromise catch handler threw`, e);
307
+ }
308
+ }
309
+ }, r = t?.retry;
310
+ if (!r) return n();
311
+ let a = (e) => {
312
+ switch (r.backoff) {
313
+ case `constant`: return r.delayMs;
314
+ case `linear`: return r.delayMs * (e + 1);
315
+ case `exponential`: return r.delayMs * 2 ** e;
316
+ }
317
+ }, o = (e) => new Promise((t) => setTimeout(t, e)), s = await n(), c = r.shouldRetry ?? (() => !0);
318
+ for (let e = 0; e < r.times && s.status === `error`; e++) {
319
+ let t = s.error;
320
+ if (!x(() => c(t), `shouldRetry predicate threw`)) break;
321
+ await o(a(e)), s = await n();
322
+ }
323
+ return s;
324
+ }, w = e(2, (e, t) => e.map(t)), T = e(2, (e, t) => e.mapError(t)), E = e(2, (e, t) => e.tryRecover(t)), D = e(2, (e, t) => e.andThen(t)), O = e(2, (e, t) => e.tryRecoverAsync(t)), k = e(2, (e, t) => e.andThenAsync(t)), A = e(2, (e, t) => e.match(t)), j = e(2, (e, t) => e.tap(t)), M = e(2, (e, t) => e.tapAsync(t)), N = e(2, (e, t) => e.tapError(t)), P = e(2, (e, t) => e.tapErrorAsync(t)), F = e(2, (e, t) => e.tapBoth(t)), I = e(2, (e, t) => e.tapBothAsync(t)), L = (e, t) => e.unwrap(t);
325
+ function R$1(e) {
326
+ if (!(typeof e == `object` && e && `status` in e && (e.status === `ok` || e.status === `error`))) return i$1(`Result.gen body must return Result.ok() or Result.err(), got: ` + (e === null ? `null` : typeof e == `object` ? JSON.stringify(e) : String(e)));
327
+ }
328
+ const z = e(2, (e, t) => e.unwrapOr(t)), B = ((e, t) => {
329
+ let n = e.call(t);
330
+ if (Symbol.asyncIterator in n) return (async () => {
331
+ let e = n, t;
332
+ try {
333
+ t = await e.next();
334
+ } catch (e) {
335
+ throw i$1(`generator body threw`, e);
336
+ }
337
+ if (R$1(t.value), !t.done) try {
338
+ await e.return?.(void 0);
339
+ } catch (e) {
340
+ throw i$1(`generator cleanup threw`, e);
341
+ }
342
+ return t.value;
343
+ })();
344
+ let r = n, a;
345
+ try {
346
+ a = r.next();
347
+ } catch (e) {
348
+ throw i$1(`generator body threw`, e);
349
+ }
350
+ if (R$1(a.value), !a.done) try {
351
+ r.return?.(void 0);
352
+ } catch (e) {
353
+ throw i$1(`generator cleanup threw`, e);
354
+ }
355
+ return a.value;
356
+ });
357
+ async function* V$1(e) {
358
+ return yield* await e;
359
+ }
360
+ function H(e) {
361
+ return typeof e == `object` && !!e && `status` in e && (e.status === `ok` && `value` in e || e.status === `error` && `error` in e);
362
+ }
363
+ const U = (e) => e.status === `ok` ? {
364
+ status: `ok`,
365
+ value: e.value
366
+ } : {
367
+ status: `error`,
368
+ error: e.error
369
+ }, W$2 = (e) => H(e) ? e.status === `ok` ? new s(e.value) : new c(e.error) : d$1(new b({ value: e })), G = {
370
+ ok: l$1,
371
+ isOk: u$1,
372
+ err: d$1,
373
+ isError: f,
374
+ try: S,
375
+ tryPromise: C$1,
376
+ map: w,
377
+ mapError: T,
378
+ tryRecover: E,
379
+ andThen: D,
380
+ tryRecoverAsync: O,
381
+ andThenAsync: k,
382
+ match: A,
383
+ tap: j,
384
+ tapAsync: M,
385
+ tapError: N,
386
+ tapErrorAsync: P,
387
+ tapBoth: F,
388
+ tapBothAsync: I,
389
+ unwrap: L,
390
+ unwrapOr: z,
391
+ gen: B,
392
+ await: V$1,
393
+ serialize: U,
394
+ deserialize: W$2,
395
+ hydrate: (e) => W$2(e),
396
+ partition: (e) => {
397
+ let t = [], n = [];
398
+ for (let r of e) r.status === `ok` ? t.push(r.value) : n.push(r.error);
399
+ return [t, n];
400
+ },
401
+ flatten: (e) => e.status === `ok` ? e.value : e
402
+ };
403
+ //#endregion
44
404
  //#region ../../packages/constants/src/index.ts
45
405
  const org = "usesocial";
46
406
  const cliPackageName = `@${org}/cli`;
@@ -88,8 +448,8 @@ const cliBrand = {
88
448
  skill: skillInstallCommand
89
449
  }
90
450
  };
91
- TaggedError("InvalidPublicBaseURL")();
92
- TaggedError("InvalidPublicRoute")();
451
+ h("InvalidPublicBaseURL")();
452
+ h("InvalidPublicRoute")();
93
453
  const publicURLForLiteral = (route) => new URL(route, brandURLs.publicWebURL).toString();
94
454
  const publicRouteURLs = {
95
455
  pricing: publicURLForLiteral(publicLinks.pricing),
@@ -222,7 +582,7 @@ function kebabCase$1(str) {
222
582
  const flagName = (name) => kebabCase$1(name.replace(/[._]/g, "-"));
223
583
  //#endregion
224
584
  //#region ../../packages/codegen/src/runtime/index.ts
225
- var RuntimeUsageProblem = class extends TaggedError("RuntimeUsageProblem")() {
585
+ var RuntimeUsageProblem = class extends h("RuntimeUsageProblem")() {
226
586
  constructor(input) {
227
587
  super({
228
588
  ...input,
@@ -230,12 +590,12 @@ var RuntimeUsageProblem = class extends TaggedError("RuntimeUsageProblem")() {
230
590
  });
231
591
  }
232
592
  };
233
- var RuntimeBodyProblem = class extends TaggedError("RuntimeBodyProblem")() {
593
+ var RuntimeBodyProblem = class extends h("RuntimeBodyProblem")() {
234
594
  constructor(input) {
235
595
  super(input);
236
596
  }
237
597
  };
238
- var RuntimeMediaProblem = class extends TaggedError("RuntimeMediaProblem")() {
598
+ var RuntimeMediaProblem = class extends h("RuntimeMediaProblem")() {
239
599
  constructor(input) {
240
600
  super(input);
241
601
  }
@@ -262,19 +622,19 @@ const resolvePathTemplateResult = (template, values) => {
262
622
  continue;
263
623
  }
264
624
  const value = values[name];
265
- if (value === void 0) return Result.err(new RuntimeUsageProblem({
625
+ if (value === void 0) return G.err(new RuntimeUsageProblem({
266
626
  kind: "missing_path_parameter",
267
627
  paramName: name
268
628
  }));
269
629
  resolvedSegments.push(safePathSegment(value));
270
630
  }
271
631
  const resolvedPath = resolvedSegments.join("/");
272
- if (!resolvedPath) return Result.ok(template.startsWith("/") ? "/" : "");
273
- return Result.ok(`${template.startsWith("/") ? "/" : ""}${resolvedPath}`);
632
+ if (!resolvedPath) return G.ok(template.startsWith("/") ? "/" : "");
633
+ return G.ok(`${template.startsWith("/") ? "/" : ""}${resolvedPath}`);
274
634
  };
275
635
  const resolvePathTemplate = (template, values) => {
276
636
  const resolved = resolvePathTemplateResult(template, values);
277
- if (Result.isError(resolved)) throw new Error(resolved.error.message);
637
+ if (G.isError(resolved)) throw new Error(resolved.error.message);
278
638
  return resolved.value;
279
639
  };
280
640
  const cliFlagNameFor$1 = (adapter, name) => adapter.cliFlagName?.(name) ?? flagName(name);
@@ -306,7 +666,7 @@ const validateMediaAttachmentsResult = (attachments, opts) => {
306
666
  if (opts.rule === "post") {
307
667
  const images = attachments.filter((attachment) => attachment.content_type.startsWith("image/")).length;
308
668
  const others = attachments.length - images;
309
- if (others > 0 && attachments.length > 1) return Result.err(new RuntimeMediaProblem({
669
+ if (others > 0 && attachments.length > 1) return G.err(new RuntimeMediaProblem({
310
670
  kind: "post_attachment_mix",
311
671
  imageCount: images,
312
672
  otherCount: others,
@@ -314,13 +674,13 @@ const validateMediaAttachmentsResult = (attachments, opts) => {
314
674
  }));
315
675
  } else {
316
676
  const total = attachments.reduce((sum, attachment) => sum + attachment.byteLength, 0);
317
- if (total > 20 * 1024 * 1024) return Result.err(new RuntimeMediaProblem({
677
+ if (total > 20 * 1024 * 1024) return G.err(new RuntimeMediaProblem({
318
678
  kind: "message_attachments_too_large",
319
679
  totalBytes: total,
320
680
  message: `LinkedIn message attachments cap at 20 MB combined; yours total ${(total / (1024 * 1024)).toFixed(1)} MB.`
321
681
  }));
322
682
  }
323
- return Result.ok(attachments.map(({ content, content_type, filename }) => ({
683
+ return G.ok(attachments.map(({ content, content_type, filename }) => ({
324
684
  content,
325
685
  content_type,
326
686
  filename
@@ -331,7 +691,7 @@ const mediaAttachmentsFrom = async (deps, paths, opts) => {
331
691
  const attachments = [];
332
692
  for (const path of paths) attachments.push(await deps.readMedia(path));
333
693
  const validated = validateMediaAttachmentsResult(attachments, opts);
334
- if (Result.isError(validated)) throw opts.usageError(validated.error.message);
694
+ if (G.isError(validated)) throw opts.usageError(validated.error.message);
335
695
  return validated.value;
336
696
  };
337
697
  const trimTrailingNewline$1 = (value) => value.endsWith("\r\n") ? value.slice(0, -2) : value.endsWith("\n") ? value.slice(0, -1) : value;
@@ -340,9 +700,9 @@ const parseStdinBodyResult = (deps, bodyTextName, bodyTextKey, value) => {
340
700
  JSON.parse(value);
341
701
  } catch {
342
702
  try {
343
- return Result.ok({ [bodyTextKey]: deps.parseBodyText(`<${bodyTextName}>`, value) });
703
+ return G.ok({ [bodyTextKey]: deps.parseBodyText(`<${bodyTextName}>`, value) });
344
704
  } catch (error) {
345
- return Result.err(new RuntimeBodyProblem({
705
+ return G.err(new RuntimeBodyProblem({
346
706
  kind: "body_parse_failed",
347
707
  message: error instanceof Error ? error.message : "Could not parse stdin body text.",
348
708
  cause: error
@@ -350,9 +710,9 @@ const parseStdinBodyResult = (deps, bodyTextName, bodyTextKey, value) => {
350
710
  }
351
711
  }
352
712
  try {
353
- return Result.ok(deps.parseJSONObject("stdin", value));
713
+ return G.ok(deps.parseJSONObject("stdin", value));
354
714
  } catch (error) {
355
- return Result.err(new RuntimeBodyProblem({
715
+ return G.err(new RuntimeBodyProblem({
356
716
  kind: "body_parse_failed",
357
717
  message: error instanceof Error ? error.message : "Could not parse stdin JSON body.",
358
718
  cause: error
@@ -361,7 +721,7 @@ const parseStdinBodyResult = (deps, bodyTextName, bodyTextKey, value) => {
361
721
  };
362
722
  const parseStdinBody$2 = (deps, bodyTextName, bodyTextKey, value) => {
363
723
  const parsed = parseStdinBodyResult(deps, bodyTextName, bodyTextKey, value);
364
- if (Result.isError(parsed)) throw parsed.error.cause ?? parsed.error;
724
+ if (G.isError(parsed)) throw parsed.error.cause ?? parsed.error;
365
725
  return parsed.value;
366
726
  };
367
727
  const hasStdinBodyText = (adapter, op) => op.config.bodyTextArg !== void 0 && adapter.bodyTextResolvesTarget?.(op) !== true;
@@ -449,16 +809,16 @@ const defaultArgAliases = (name) => new Set([name, flagName(name)]);
449
809
  const rejectUnsupportedRuntimeArgsResult = (adapter, op, args, allowedArgNames = Object.keys(buildRuntimeArgs(adapter, op))) => {
450
810
  const allowed = new Set(["_"]);
451
811
  for (const name of allowedArgNames) for (const alias of adapter.argAliases?.(name) ?? defaultArgAliases(name)) allowed.add(alias);
452
- for (const [name, value] of Object.entries(args)) if (!allowed.has(name) && (adapter.ignoreUndefinedUnsupportedArgs !== true || value !== void 0)) return Result.err(new RuntimeUsageProblem({
812
+ for (const [name, value] of Object.entries(args)) if (!allowed.has(name) && (adapter.ignoreUndefinedUnsupportedArgs !== true || value !== void 0)) return G.err(new RuntimeUsageProblem({
453
813
  kind: "unsupported_arg",
454
814
  argName: name,
455
815
  value
456
816
  }));
457
- return Result.ok();
817
+ return G.ok();
458
818
  };
459
819
  const rejectUnsupportedRuntimeArgs = (adapter, op, args, allowedArgNames = Object.keys(buildRuntimeArgs(adapter, op))) => {
460
820
  const rejected = rejectUnsupportedRuntimeArgsResult(adapter, op, args, allowedArgNames);
461
- if (Result.isError(rejected)) {
821
+ if (G.isError(rejected)) {
462
822
  if (rejected.error.kind === "unsupported_arg" && rejected.error.argName !== void 0) throw adapter.unsupportedArgError(rejected.error.argName, rejected.error.value, op);
463
823
  throw adapter.usageError(rejected.error.message);
464
824
  }
@@ -535,8 +895,8 @@ const bodyRequiredPreparseProblem = (adapter, op) => new RuntimeBodyProblem({
535
895
  message: op.config.bodyTextArg && Object.keys(op.config.bodyParams ?? {}).length === 0 ? `Pass <${bodyTextDisplayKeyFor(op) ?? op.config.bodyTextArg}>.` : "Pass required body positional arguments or --body."
536
896
  });
537
897
  const checkBodyRequiredResult = (adapter, op, args, bodyTextOptional) => {
538
- if (!op.hasBody || adapter.checkBodyRequiredBeforeInput !== true) return Result.ok();
539
- if (bodyTextOptional) return Result.ok();
898
+ if (!op.hasBody || adapter.checkBodyRequiredBeforeInput !== true) return G.ok();
899
+ if (bodyTextOptional) return G.ok();
540
900
  const expressions = [];
541
901
  const bodyTextArg = op.config.bodyTextArg;
542
902
  if (bodyTextArg && op.config.bodyTextRequired !== false) expressions.push(args[bodyTextDisplayKeyFor(op) ?? bodyTextArg] === void 0);
@@ -544,25 +904,25 @@ const checkBodyRequiredResult = (adapter, op, args, bodyTextOptional) => {
544
904
  const positionalValuePresent = param.positional && Array.isArray(args._) && args._.length > 0;
545
905
  expressions.push(args[flagName(bodyParamArgFor(adapter, name, param))] === void 0 && !positionalValuePresent);
546
906
  }
547
- if (expressions.length > 0 && typeof args.body !== "string" && expressions.some(Boolean)) return Result.err(bodyRequiredPreparseProblem(adapter, op));
548
- return Result.ok();
907
+ if (expressions.length > 0 && typeof args.body !== "string" && expressions.some(Boolean)) return G.err(bodyRequiredPreparseProblem(adapter, op));
908
+ return G.ok();
549
909
  };
550
910
  const throwRuntimeBodyProblem = (adapter, problem) => {
551
911
  throw problem.cause ?? adapter.usageError(problem.message);
552
912
  };
553
913
  const checkBodyRequired = (adapter, op, args, bodyTextOptional) => {
554
914
  const checked = checkBodyRequiredResult(adapter, op, args, bodyTextOptional);
555
- if (Result.isError(checked)) throwRuntimeBodyProblem(adapter, checked.error);
915
+ if (G.isError(checked)) throwRuntimeBodyProblem(adapter, checked.error);
556
916
  };
557
917
  const buildBodyResult = (adapter, deps, op, input, bodyTextOptional) => {
558
918
  const bodyTextArg = op.config.bodyTextArg;
559
919
  const bodyParamEntries = Object.entries(op.config.bodyParams ?? {});
560
920
  if (!bodyTextArg && bodyParamEntries.length === 0) {
561
- if (input.body === void 0) return Result.ok(void 0);
921
+ if (input.body === void 0) return G.ok(void 0);
562
922
  try {
563
- return Result.ok(deps.parseJSONObject("--body", input.body));
923
+ return G.ok(deps.parseJSONObject("--body", input.body));
564
924
  } catch (error) {
565
- return Result.err(new RuntimeBodyProblem({
925
+ return G.err(new RuntimeBodyProblem({
566
926
  kind: "body_parse_failed",
567
927
  message: error instanceof Error ? error.message : "Could not parse --body JSON.",
568
928
  cause: error
@@ -573,7 +933,7 @@ const buildBodyResult = (adapter, deps, op, input, bodyTextOptional) => {
573
933
  if (input.body !== void 0) try {
574
934
  bodyFromJSON = deps.parseJSONObject(hasStdinBodyText(adapter, op) ? "stdin" : "--body", input.body);
575
935
  } catch (error) {
576
- return Result.err(new RuntimeBodyProblem({
936
+ return G.err(new RuntimeBodyProblem({
577
937
  kind: "body_parse_failed",
578
938
  message: error instanceof Error ? error.message : "Could not parse request body JSON.",
579
939
  cause: error
@@ -584,7 +944,7 @@ const buildBodyResult = (adapter, deps, op, input, bodyTextOptional) => {
584
944
  if (bodyTextArg && input[bodyTextArg] !== void 0) try {
585
945
  bodyText = deps.parseBodyText(`<${displayTextArg}>`, input[bodyTextArg]);
586
946
  } catch (error) {
587
- return Result.err(new RuntimeBodyProblem({
947
+ return G.err(new RuntimeBodyProblem({
588
948
  kind: "body_parse_failed",
589
949
  message: error instanceof Error ? error.message : "Could not parse body text.",
590
950
  cause: error
@@ -597,7 +957,7 @@ const buildBodyResult = (adapter, deps, op, input, bodyTextOptional) => {
597
957
  try {
598
958
  bodyParamValues.set(name, value === void 0 ? param.default : param.kind === "array" ? deps.parseResourceIdList(displayName, Array.isArray(value) ? value : [value]) : deps.parseQueryString(displayName, value));
599
959
  } catch (error) {
600
- return Result.err(new RuntimeBodyProblem({
960
+ return G.err(new RuntimeBodyProblem({
601
961
  kind: "body_parse_failed",
602
962
  message: error instanceof Error ? error.message : `Could not parse ${displayName}.`,
603
963
  cause: error
@@ -623,45 +983,45 @@ const buildBodyResult = (adapter, deps, op, input, bodyTextOptional) => {
623
983
  input,
624
984
  op
625
985
  });
626
- if (error) return Result.err(new RuntimeBodyProblem({
986
+ if (error) return G.err(new RuntimeBodyProblem({
627
987
  kind: "body_validation_failed",
628
988
  message: error.message,
629
989
  cause: error
630
990
  }));
631
- return Result.ok(resolvedBody);
991
+ return G.ok(resolvedBody);
632
992
  };
633
993
  const buildBody = (adapter, deps, op, input, bodyTextOptional) => {
634
994
  const built = buildBodyResult(adapter, deps, op, input, bodyTextOptional);
635
- if (Result.isOk(built)) return built.value;
995
+ if (G.isOk(built)) return built.value;
636
996
  throwRuntimeBodyProblem(adapter, built.error);
637
997
  };
638
998
  const resolveBodyTextFromStdinResult = async (adapter, op, deps, args, commandLabel, bodyTextOptional) => {
639
- if (!hasStdinBodyText(adapter, op)) return Result.ok();
999
+ if (!hasStdinBodyText(adapter, op)) return G.ok();
640
1000
  const bodyTextArg = op.config.bodyTextArg;
641
- if (bodyTextArg === void 0) return Result.ok();
1001
+ if (bodyTextArg === void 0) return G.ok();
642
1002
  const displayTextArg = bodyTextDisplayKeyFor(op) ?? bodyTextArg;
643
1003
  const required = stdinBodyTextRequired(adapter, op) && !bodyTextOptional;
644
1004
  if (deps.isStdinTTY()) {
645
- if (required) return Result.err(new RuntimeBodyProblem({
1005
+ if (required) return G.err(new RuntimeBodyProblem({
646
1006
  kind: "stdin_body_required",
647
1007
  message: bodyTextPipeMessage(commandLabel)
648
1008
  }));
649
- return Result.ok();
1009
+ return G.ok();
650
1010
  }
651
1011
  const piped = trimTrailingNewline$1(await deps.readStdin());
652
1012
  if (piped.length > 0) {
653
1013
  const parsed = parseStdinBodyResult(deps, displayTextArg, bodyTextArg, piped);
654
- if (Result.isError(parsed)) return Result.err(parsed.error);
1014
+ if (G.isError(parsed)) return G.err(parsed.error);
655
1015
  args.body = JSON.stringify(parsed.value);
656
- } else if (required) return Result.err(new RuntimeBodyProblem({
1016
+ } else if (required) return G.err(new RuntimeBodyProblem({
657
1017
  kind: "stdin_body_required",
658
1018
  message: bodyTextPipeMessage(commandLabel)
659
1019
  }));
660
- return Result.ok();
1020
+ return G.ok();
661
1021
  };
662
1022
  const resolveBodyTextFromStdin = async (adapter, op, deps, args, commandLabel, bodyTextOptional) => {
663
1023
  const resolved = await resolveBodyTextFromStdinResult(adapter, op, deps, args, commandLabel, bodyTextOptional);
664
- if (Result.isError(resolved)) throwRuntimeBodyProblem(adapter, resolved.error);
1024
+ if (G.isError(resolved)) throwRuntimeBodyProblem(adapter, resolved.error);
665
1025
  };
666
1026
  const maximumItemsHintFor$2 = (adapter, op) => adapter.maximumItemsHintFor?.(op);
667
1027
  const costFor = (adapter, op) => {
@@ -992,32 +1352,32 @@ const normalizeLiftedRow = (collection, row) => {
992
1352
  const columns = collectionColumns(collection);
993
1353
  const columnSet = new Set(columns);
994
1354
  const normalized = {};
995
- for (const column of Object.keys(row)) if (!columnSet.has(column)) return Result.err({
1355
+ for (const column of Object.keys(row)) if (!columnSet.has(column)) return G.err({
996
1356
  kind: "unsupportedValue",
997
1357
  column,
998
1358
  message: `${collection.key} produced unexpected column ${column}`
999
1359
  });
1000
1360
  for (const column of columns) {
1001
1361
  const value = row[column];
1002
- if (unsupportedRowValue(value)) return Result.err({
1362
+ if (unsupportedRowValue(value)) return G.err({
1003
1363
  kind: "unsupportedValue",
1004
1364
  column,
1005
1365
  message: `${collection.key} produced unsupported value for ${column}`
1006
1366
  });
1007
1367
  normalized[column] = value ?? null;
1008
1368
  }
1009
- if (normalized.id === null || normalized.id === "") return Result.err({
1369
+ if (normalized.id === null || normalized.id === "") return G.err({
1010
1370
  kind: "missingId",
1011
1371
  column: "id",
1012
1372
  message: `${collection.key} row is missing id`
1013
1373
  });
1014
- return Result.ok(normalized);
1374
+ return G.ok(normalized);
1015
1375
  };
1016
1376
  const liftCollectionRow = (collection, item) => {
1017
1377
  try {
1018
1378
  return normalizeLiftedRow(collection, collection.lift(item));
1019
1379
  } catch (error) {
1020
- return Result.err(normalizationErrorFrom(error));
1380
+ return G.err(normalizationErrorFrom(error));
1021
1381
  }
1022
1382
  };
1023
1383
  const withCollectionColumns = (collection) => ({
@@ -1828,7 +2188,7 @@ const metadataForPlatform = (platform) => {
1828
2188
  //#endregion
1829
2189
  //#region ../../packages/sqlsync/src/cursor.ts
1830
2190
  const PARTIAL_SYNC_CURSOR_PREFIX = "partial-sync-v1:";
1831
- var CorruptPartialSyncCursor = class extends TaggedError("CorruptPartialSyncCursor")() {
2191
+ var CorruptPartialSyncCursor = class extends h("CorruptPartialSyncCursor")() {
1832
2192
  constructor(args) {
1833
2193
  super({
1834
2194
  cursor: args.cursor,
@@ -1841,19 +2201,19 @@ const isRecord$12 = (value) => value !== null && typeof value === "object" && !A
1841
2201
  const validPartialSyncCursor = (value) => value.version === 1 && Number.isInteger(value.requestIndex) && typeof value.requestIndex === "number" && value.requestIndex >= 0 && typeof value.cursor === "string" && (typeof value.checkpoint === "string" || value.checkpoint === null) && (typeof value.newestId === "string" || value.newestId === null) && (typeof value.since === "number" || value.since === null) && (value.phase === void 0 || value.phase === "collection" || value.phase === "parent" || value.phase === "child") && (value.parentId === void 0 || typeof value.parentId === "string" || value.parentId === null);
1842
2202
  const encodePartialSyncCursor = (cursor) => `${PARTIAL_SYNC_CURSOR_PREFIX}${JSON.stringify(cursor)}`;
1843
2203
  const parsePartialSyncCursor = (value) => {
1844
- if (!value.startsWith("partial-sync-v1:")) return Result.err(new CorruptPartialSyncCursor({
2204
+ if (!value.startsWith("partial-sync-v1:")) return G.err(new CorruptPartialSyncCursor({
1845
2205
  cursor: value,
1846
2206
  reason: "missing partial-sync-v1 prefix"
1847
2207
  }));
1848
2208
  try {
1849
2209
  const parsed = JSON.parse(value.slice(16));
1850
- if (isRecord$12(parsed) && validPartialSyncCursor(parsed)) return Result.ok(parsed);
1851
- return Result.err(new CorruptPartialSyncCursor({
2210
+ if (isRecord$12(parsed) && validPartialSyncCursor(parsed)) return G.ok(parsed);
2211
+ return G.err(new CorruptPartialSyncCursor({
1852
2212
  cursor: value,
1853
2213
  reason: "payload does not match the partial cursor shape"
1854
2214
  }));
1855
2215
  } catch (error) {
1856
- return Result.err(new CorruptPartialSyncCursor({
2216
+ return G.err(new CorruptPartialSyncCursor({
1857
2217
  cursor: value,
1858
2218
  reason: "payload is not valid JSON",
1859
2219
  cause: error
@@ -1861,12 +2221,12 @@ const parsePartialSyncCursor = (value) => {
1861
2221
  }
1862
2222
  };
1863
2223
  const readPartialSyncCursorResult = (value) => {
1864
- if (!value?.startsWith("partial-sync-v1:")) return Result.ok(void 0);
2224
+ if (!value?.startsWith("partial-sync-v1:")) return G.ok(void 0);
1865
2225
  return parsePartialSyncCursor(value);
1866
2226
  };
1867
2227
  const readPartialSyncCursor = (value) => {
1868
2228
  const parsed = readPartialSyncCursorResult(value);
1869
- return Result.isError(parsed) ? void 0 : parsed.value;
2229
+ return G.isError(parsed) ? void 0 : parsed.value;
1870
2230
  };
1871
2231
  const partialCursorMatchesSince = (cursor, since) => {
1872
2232
  const requestedSince = since ?? null;
@@ -1931,7 +2291,7 @@ const readUserVersion = (db) => {
1931
2291
  const setUserVersion = (db, version) => {
1932
2292
  db.exec(`PRAGMA user_version = ${version}`);
1933
2293
  };
1934
- var MissingMigration = class extends TaggedError("MissingMigration")() {
2294
+ var MissingMigration = class extends h("MissingMigration")() {
1935
2295
  constructor(index) {
1936
2296
  super({
1937
2297
  index,
@@ -1939,7 +2299,7 @@ var MissingMigration = class extends TaggedError("MissingMigration")() {
1939
2299
  });
1940
2300
  }
1941
2301
  };
1942
- var StaleMigrationSchema = class extends TaggedError("StaleMigrationSchema")() {
2302
+ var StaleMigrationSchema = class extends h("StaleMigrationSchema")() {
1943
2303
  constructor(currentVersion, finalVersion) {
1944
2304
  super({
1945
2305
  currentVersion,
@@ -1950,20 +2310,20 @@ var StaleMigrationSchema = class extends TaggedError("StaleMigrationSchema")() {
1950
2310
  };
1951
2311
  const migrateResult = (db) => {
1952
2312
  const currentVersion = readUserVersion(db);
1953
- if (currentVersion >= MIGRATIONS.length) return Result.ok({
2313
+ if (currentVersion >= MIGRATIONS.length) return G.ok({
1954
2314
  fromVersion: currentVersion,
1955
2315
  toVersion: currentVersion,
1956
2316
  applied: 0
1957
2317
  });
1958
2318
  for (let index = currentVersion; index < MIGRATIONS.length; index += 1) {
1959
2319
  const migration = MIGRATIONS[index];
1960
- if (!migration) return Result.err(new MissingMigration(index));
2320
+ if (!migration) return G.err(new MissingMigration(index));
1961
2321
  db.transaction(() => {
1962
2322
  db.exec(migration.sql);
1963
2323
  setUserVersion(db, index + 1);
1964
2324
  });
1965
2325
  }
1966
- return Result.ok({
2326
+ return G.ok({
1967
2327
  fromVersion: currentVersion,
1968
2328
  toVersion: MIGRATIONS.length,
1969
2329
  applied: MIGRATIONS.length - currentVersion
@@ -1972,8 +2332,8 @@ const migrateResult = (db) => {
1972
2332
  const migrate = (db) => migrateResult(db).unwrap();
1973
2333
  const assertAtLatestResult = (db) => {
1974
2334
  const currentVersion = readUserVersion(db);
1975
- if (currentVersion < MIGRATIONS.length) return Result.err(new StaleMigrationSchema(currentVersion, MIGRATIONS.length));
1976
- return Result.ok(void 0);
2335
+ if (currentVersion < MIGRATIONS.length) return G.err(new StaleMigrationSchema(currentVersion, MIGRATIONS.length));
2336
+ return G.ok(void 0);
1977
2337
  };
1978
2338
  const assertAtLatest = (db) => {
1979
2339
  assertAtLatestResult(db).unwrap();
@@ -2090,7 +2450,7 @@ const applyWriteThrough = (db, args) => {
2090
2450
  };
2091
2451
  //#endregion
2092
2452
  //#region ../../packages/sqlsync/src/cache.ts
2093
- var UnknownCacheTable = class extends TaggedError("UnknownCacheTable")() {
2453
+ var UnknownCacheTable = class extends h("UnknownCacheTable")() {
2094
2454
  constructor(args) {
2095
2455
  super({
2096
2456
  table: args.table,
@@ -2098,7 +2458,7 @@ var UnknownCacheTable = class extends TaggedError("UnknownCacheTable")() {
2098
2458
  });
2099
2459
  }
2100
2460
  };
2101
- var ForbiddenCacheTableRead = class extends TaggedError("ForbiddenCacheTableRead")() {
2461
+ var ForbiddenCacheTableRead = class extends h("ForbiddenCacheTableRead")() {
2102
2462
  constructor(args) {
2103
2463
  const tables = [...args.tables].sort();
2104
2464
  super({
@@ -2108,7 +2468,7 @@ var ForbiddenCacheTableRead = class extends TaggedError("ForbiddenCacheTableRead
2108
2468
  });
2109
2469
  }
2110
2470
  };
2111
- var UnknownCachePlatform = class extends TaggedError("UnknownCachePlatform")() {
2471
+ var UnknownCachePlatform = class extends h("UnknownCachePlatform")() {
2112
2472
  constructor(platform) {
2113
2473
  super({
2114
2474
  platform,
@@ -2121,40 +2481,40 @@ const resolveCachePath = (path) => path === ":memory:" ? path : resolve(path);
2121
2481
  const stringOrNull = (value) => typeof value === "string" ? value : null;
2122
2482
  const numberOrNull = (value) => typeof value === "number" ? value : null;
2123
2483
  const parseCachePlatform = (platform) => {
2124
- if (platform === "linkedin" || platform === "x") return Result.ok(platform);
2125
- return Result.err(new UnknownCachePlatform(platform));
2484
+ if (platform === "linkedin" || platform === "x") return G.ok(platform);
2485
+ return G.err(new UnknownCachePlatform(platform));
2126
2486
  };
2127
2487
  const requireCachePlatform = (platform) => {
2128
2488
  const parsed = parseCachePlatform(platform);
2129
- if (Result.isError(parsed)) throw parsed.error;
2489
+ if (G.isError(parsed)) throw parsed.error;
2130
2490
  return parsed.value;
2131
2491
  };
2132
2492
  const parseCacheTable = (table) => {
2133
- if (!cacheTableNames.has(table)) return Result.err(new UnknownCacheTable({ table }));
2134
- return Result.ok(table);
2493
+ if (!cacheTableNames.has(table)) return G.err(new UnknownCacheTable({ table }));
2494
+ return G.ok(table);
2135
2495
  };
2136
2496
  const requireCacheTable = (table) => {
2137
2497
  const parsed = parseCacheTable(table);
2138
- if (Result.isError(parsed)) throw parsed.error;
2498
+ if (G.isError(parsed)) throw parsed.error;
2139
2499
  return parsed.value;
2140
2500
  };
2141
2501
  const checkPlatformQuery = (sql, platform) => {
2142
2502
  const allowedTables = tablesForPlatform(platform);
2143
2503
  const rejectedTables = new Set(knownTableTokens(sql).filter((table) => !allowedTables.has(table)));
2144
- if (rejectedTables.size > 0) return Result.err(new ForbiddenCacheTableRead({
2504
+ if (rejectedTables.size > 0) return G.err(new ForbiddenCacheTableRead({
2145
2505
  platform,
2146
2506
  tables: rejectedTables
2147
2507
  }));
2148
- return Result.ok();
2508
+ return G.ok();
2149
2509
  };
2150
2510
  const assertPlatformQuery = (sql, platform) => {
2151
2511
  const checked = checkPlatformQuery(sql, platform);
2152
- if (Result.isError(checked)) throw checked.error;
2512
+ if (G.isError(checked)) throw checked.error;
2153
2513
  };
2154
2514
  const classifyCacheRead = (sql, platform) => {
2155
2515
  const checked = checkPlatformQuery(sql, platform);
2156
- if (Result.isError(checked)) return Result.err(checked.error);
2157
- return Result.ok({ tables: referencedTablesForRead(sql, platform) });
2516
+ if (G.isError(checked)) return G.err(checked.error);
2517
+ return G.ok({ tables: referencedTablesForRead(sql, platform) });
2158
2518
  };
2159
2519
  const unknownTableFromSQLiteError = (error) => {
2160
2520
  return (error instanceof Error ? error.message : String(error)).match(/\bno such table: ([^\s]+)/)?.[1]?.replace(/^["'`]|["'`]$/g, "");
@@ -2299,7 +2659,7 @@ const createCache = (path, db) => ({
2299
2659
  },
2300
2660
  read: (sql, opts) => {
2301
2661
  const classification = classifyCacheRead(sql, opts.platform);
2302
- if (Result.isError(classification)) return Result.err(classification.error);
2662
+ if (G.isError(classification)) return G.err(classification.error);
2303
2663
  const tables = classification.value.tables.map((name) => {
2304
2664
  return {
2305
2665
  name,
@@ -2311,10 +2671,10 @@ const createCache = (path, db) => ({
2311
2671
  rows = db.prepare(sql).all();
2312
2672
  } catch (error) {
2313
2673
  const table = unknownTableFromSQLiteError(error);
2314
- if (table) return Result.err(new UnknownCacheTable({ table }));
2674
+ if (table) return G.err(new UnknownCacheTable({ table }));
2315
2675
  throw error;
2316
2676
  }
2317
- return Result.ok({
2677
+ return G.ok({
2318
2678
  rows,
2319
2679
  tables
2320
2680
  });
@@ -7095,7 +7455,7 @@ const planPagePersistence = (state, page, opts) => {
7095
7455
  const profileTableFor = (platform) => platform === "x" ? "x_profiles_raw" : "li_profiles_raw";
7096
7456
  //#endregion
7097
7457
  //#region ../../packages/sqlsync/src/sync-plan.ts
7098
- var SinceUnsupported = class extends TaggedError("SinceUnsupported")() {
7458
+ var SinceUnsupported = class extends h("SinceUnsupported")() {
7099
7459
  constructor(collectionKey) {
7100
7460
  super({
7101
7461
  collectionKey,
@@ -7103,7 +7463,7 @@ var SinceUnsupported = class extends TaggedError("SinceUnsupported")() {
7103
7463
  });
7104
7464
  }
7105
7465
  };
7106
- var FullInitialSyncRequired = class extends TaggedError("FullInitialSyncRequired")() {
7466
+ var FullInitialSyncRequired = class extends h("FullInitialSyncRequired")() {
7107
7467
  constructor(collectionKey) {
7108
7468
  super({
7109
7469
  collectionKey,
@@ -7111,7 +7471,7 @@ var FullInitialSyncRequired = class extends TaggedError("FullInitialSyncRequired
7111
7471
  });
7112
7472
  }
7113
7473
  };
7114
- var MissingParentCollection = class extends TaggedError("MissingParentCollection")() {
7474
+ var MissingParentCollection = class extends h("MissingParentCollection")() {
7115
7475
  constructor(collectionKey, parentCollectionKey) {
7116
7476
  super({
7117
7477
  collectionKey,
@@ -7120,7 +7480,7 @@ var MissingParentCollection = class extends TaggedError("MissingParentCollection
7120
7480
  });
7121
7481
  }
7122
7482
  };
7123
- var InvalidPartialCursor = class extends TaggedError("InvalidPartialCursor")() {
7483
+ var InvalidPartialCursor = class extends h("InvalidPartialCursor")() {
7124
7484
  constructor(collectionKey, cursor, cause) {
7125
7485
  super({
7126
7486
  collectionKey,
@@ -7132,19 +7492,19 @@ var InvalidPartialCursor = class extends TaggedError("InvalidPartialCursor")() {
7132
7492
  };
7133
7493
  const parseStoredPartialCursor = (collectionKey, cursor) => {
7134
7494
  const parsed = readPartialSyncCursorResult(cursor);
7135
- if (Result.isError(parsed)) return Result.err(new InvalidPartialCursor(collectionKey, cursor ?? "", parsed.error));
7136
- return Result.ok(parsed.value);
7495
+ if (G.isError(parsed)) return G.err(new InvalidPartialCursor(collectionKey, cursor ?? "", parsed.error));
7496
+ return G.ok(parsed.value);
7137
7497
  };
7138
7498
  const validateSyncOptions = (deps, opts) => {
7139
7499
  const { collection } = opts;
7140
- if (opts.since != null && collection.sinceField === void 0) return Result.err(new SinceUnsupported(collection.key));
7500
+ if (opts.since != null && collection.sinceField === void 0) return G.err(new SinceUnsupported(collection.key));
7141
7501
  const storedState = deps.cache.getCursor(collection.key);
7142
7502
  const storedPartialCursor = parseStoredPartialCursor(collection.key, storedState?.cursor);
7143
- if (Result.isError(storedPartialCursor)) return Result.err(storedPartialCursor.error);
7144
- if (opts.since != null && collection.requiresFullInitialSync && (storedState?.lastSynced == null || storedPartialCursor.value !== void 0)) return Result.err(new FullInitialSyncRequired(collection.key));
7503
+ if (G.isError(storedPartialCursor)) return G.err(storedPartialCursor.error);
7504
+ if (opts.since != null && collection.requiresFullInitialSync && (storedState?.lastSynced == null || storedPartialCursor.value !== void 0)) return G.err(new FullInitialSyncRequired(collection.key));
7145
7505
  const parentCollection = collection.parentCollection === void 0 ? void 0 : collectionByKey(collection.parentCollection);
7146
- if (collection.parentCollection && !parentCollection) return Result.err(new MissingParentCollection(collection.key, collection.parentCollection));
7147
- return Result.ok({
7506
+ if (collection.parentCollection && !parentCollection) return G.err(new MissingParentCollection(collection.key, collection.parentCollection));
7507
+ return G.ok({
7148
7508
  collection,
7149
7509
  since: opts.since,
7150
7510
  storedState,
@@ -7178,7 +7538,7 @@ const planCompletedCollectionCursor = (args) => ({
7178
7538
  //#region ../../packages/sqlsync/src/sync.ts
7179
7539
  const sleep = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
7180
7540
  const pageDelayFor = (pageDelayMs, pagesCompleted) => typeof pageDelayMs === "function" ? pageDelayMs(pagesCompleted) : pageDelayMs;
7181
- var UnsupportedSinceCollection = class extends TaggedError("UnsupportedSinceCollection")() {
7541
+ var UnsupportedSinceCollection = class extends h("UnsupportedSinceCollection")() {
7182
7542
  constructor(collectionKey) {
7183
7543
  super({
7184
7544
  collectionKey,
@@ -7186,7 +7546,7 @@ var UnsupportedSinceCollection = class extends TaggedError("UnsupportedSinceColl
7186
7546
  });
7187
7547
  }
7188
7548
  };
7189
- var InitialSyncRequired = class extends TaggedError("InitialSyncRequired")() {
7549
+ var InitialSyncRequired = class extends h("InitialSyncRequired")() {
7190
7550
  constructor(collectionKey) {
7191
7551
  super({
7192
7552
  collectionKey,
@@ -7343,7 +7703,7 @@ const walkRequest = async (args) => {
7343
7703
  break;
7344
7704
  } catch (error) {
7345
7705
  if (await waitForRateLimit(error)) continue;
7346
- return Result.err(pageError({
7706
+ return G.err(pageError({
7347
7707
  ...pageContext,
7348
7708
  cursorPersisted: persistPartialCursor() || partialCursorPersisted || void 0
7349
7709
  }, error));
@@ -7354,7 +7714,7 @@ const walkRequest = async (args) => {
7354
7714
  try {
7355
7715
  json = await response.json();
7356
7716
  } catch (error) {
7357
- return Result.err(pageError({
7717
+ return G.err(pageError({
7358
7718
  ...pageContext,
7359
7719
  creditsSpent: args.credits.spent
7360
7720
  }, error));
@@ -7395,7 +7755,7 @@ const walkRequest = async (args) => {
7395
7755
  break;
7396
7756
  }
7397
7757
  }
7398
- return Result.ok({
7758
+ return G.ok({
7399
7759
  ids,
7400
7760
  newestId: state.newestId,
7401
7761
  pages,
@@ -7419,10 +7779,10 @@ const parentIdsFromCache = (deps, collection, since) => {
7419
7779
  };
7420
7780
  const runSync = async (deps, opts) => {
7421
7781
  const syncPlan = validateSyncOptions(deps, opts);
7422
- if (Result.isError(syncPlan)) {
7423
- if (syncPlan.error instanceof SinceUnsupported) return Result.err(new UnsupportedSinceCollection(syncPlan.error.collectionKey));
7424
- if (syncPlan.error instanceof FullInitialSyncRequired) return Result.err(new InitialSyncRequired(syncPlan.error.collectionKey));
7425
- return Result.err(syncPlan.error);
7782
+ if (G.isError(syncPlan)) {
7783
+ if (syncPlan.error instanceof SinceUnsupported) return G.err(new UnsupportedSinceCollection(syncPlan.error.collectionKey));
7784
+ if (syncPlan.error instanceof FullInitialSyncRequired) return G.err(new InitialSyncRequired(syncPlan.error.collectionKey));
7785
+ return G.err(syncPlan.error);
7426
7786
  }
7427
7787
  const { collection, parentCollection, storedPartialCursor } = syncPlan.value;
7428
7788
  const credits = { spent: 0 };
@@ -7447,7 +7807,7 @@ const runSync = async (deps, opts) => {
7447
7807
  deps.cache.setCursor(pending.collection, pending.cursor, pending.objectCount, pending.lastSynced);
7448
7808
  };
7449
7809
  if (collection.parentCollection) {
7450
- if (!parentCollection) return Result.err(new MissingParentCollection(collection.key, collection.parentCollection));
7810
+ if (!parentCollection) return G.err(new MissingParentCollection(collection.key, collection.parentCollection));
7451
7811
  let activePartialCursor = activeParentedPartialCursor({
7452
7812
  storedPartialCursor,
7453
7813
  since: opts.since
@@ -7487,7 +7847,7 @@ const runSync = async (deps, opts) => {
7487
7847
  onPage: opts.onPage,
7488
7848
  onProgress: opts.onProgress
7489
7849
  });
7490
- if (Result.isError(result)) return Result.err(result.error);
7850
+ if (G.isError(result)) return G.err(result.error);
7491
7851
  addResult(result.value);
7492
7852
  parentIds.push(...result.value.ids);
7493
7853
  if (parentPersistsCheckpoint) parentCheckpoint = singleRequestCheckpoint({
@@ -7534,7 +7894,7 @@ const runSync = async (deps, opts) => {
7534
7894
  onPage: opts.onPage,
7535
7895
  onProgress: opts.onProgress
7536
7896
  });
7537
- if (Result.isError(result)) return Result.err(result.error);
7897
+ if (G.isError(result)) return G.err(result.error);
7538
7898
  addResult(result.value);
7539
7899
  if (activePartialCursor?.phase === "child" && activePartialCursor.parentId === parentId) activePartialCursor = void 0;
7540
7900
  }
@@ -7572,7 +7932,7 @@ const runSync = async (deps, opts) => {
7572
7932
  onPage: opts.onPage,
7573
7933
  onProgress: opts.onProgress
7574
7934
  });
7575
- if (Result.isError(result)) return Result.err(result.error);
7935
+ if (G.isError(result)) return G.err(result.error);
7576
7936
  addResult(result.value);
7577
7937
  if (!preservesBroaderPartialOnSince(activePartialCursor, opts.since, result.value.stoppedReason) && useCheckpoint) pendingCursors.push(singleRequestCheckpoint({
7578
7938
  collection,
@@ -7585,7 +7945,7 @@ const runSync = async (deps, opts) => {
7585
7945
  })));
7586
7946
  }
7587
7947
  for (const pending of pendingCursors) writePendingCursor(pending);
7588
- return Result.ok({
7948
+ return G.ok({
7589
7949
  collection: collection.key,
7590
7950
  objectsUpserted: upserted,
7591
7951
  pages,
@@ -8012,14 +8372,14 @@ function renderDescription(arg, required) {
8012
8372
  }
8013
8373
  //#endregion
8014
8374
  //#region ../../packages/billing/src/pricing.ts
8015
- var UnknownPricingCategory = class extends TaggedError("pricing_category_unknown")() {};
8375
+ var UnknownPricingCategory = class extends h("pricing_category_unknown")() {};
8016
8376
  const lookupCostBPSForCategoryResult = (table, category) => {
8017
8377
  const costBPS = table.get(category);
8018
- if (costBPS === void 0) return Result.err(new UnknownPricingCategory({
8378
+ if (costBPS === void 0) return G.err(new UnknownPricingCategory({
8019
8379
  category,
8020
8380
  message: `Unknown pricing category: ${category}`
8021
8381
  }));
8022
- return Result.ok(costBPS);
8382
+ return G.ok(costBPS);
8023
8383
  };
8024
8384
  const createPricing = (resources) => {
8025
8385
  const table = new Map(resources.map((resource) => [resource.key, Math.round(resource.unitPriceUSD * 1e4)]));
@@ -10500,8 +10860,8 @@ _enum(FEEDBACK_TYPES);
10500
10860
  _enum(WRAPPED_STATUSES);
10501
10861
  string().trim().min(1).transform((email) => email.toLowerCase()).brand();
10502
10862
  union([number(), string().trim().min(1)]).transform((value) => Number(value)).pipe(number().int().nonnegative()).brand();
10503
- TaggedError("InvalidBillingOverrideEmail")();
10504
- TaggedError("InvalidNonnegativeAllowance")();
10863
+ h("InvalidBillingOverrideEmail")();
10864
+ h("InvalidNonnegativeAllowance")();
10505
10865
  const sqlStringLiteral = (value) => `'${value.replaceAll("'", "''")}'`;
10506
10866
  const sqlStringList = (values) => sql.raw(values.map(sqlStringLiteral).join(", "));
10507
10867
  const sqlCheckIn = (column, values) => sql`${column} in (${sqlStringList(values)})`;
@@ -10711,8 +11071,8 @@ pgTable("linkedin_connections", {
10711
11071
  connectedAt: timestamptz("connected_at"),
10712
11072
  createdAt: timestamptz("created_at").notNull().defaultNow()
10713
11073
  }, (table) => [uniqueIndex("linkedin_connections_of_profile_key").on(table.ofProfileId, table.profileId), index("linkedin_connections_profile_idx").on(table.profileId)]);
10714
- TaggedError("ProfileStoreUnavailable")();
10715
- TaggedError("InvalidProfileRow")();
11074
+ h("ProfileStoreUnavailable")();
11075
+ h("InvalidProfileRow")();
10716
11076
  //#endregion
10717
11077
  //#region ../../packages/lib/src/url.ts
10718
11078
  const stripTrailingSlashes = (value) => value.replace(/\/+$/, "");
@@ -10723,7 +11083,7 @@ const absoluteURLPathPattern = /^[a-z][a-z0-9+.-]*:/i;
10723
11083
  const protocolRelativeURLPathPattern = /^\/\//;
10724
11084
  const unsafeRelativeURLPathMessage = "createURL: path must be relative, not absolute or protocol-relative";
10725
11085
  /** Returned when a URL path is absolute or protocol-relative instead of relative. */
10726
- var InvalidRelativeURLPath = class extends TaggedError("InvalidRelativeURLPath")() {
11086
+ var InvalidRelativeURLPath = class extends h("InvalidRelativeURLPath")() {
10727
11087
  constructor({ path }) {
10728
11088
  super({
10729
11089
  path,
@@ -10731,7 +11091,7 @@ var InvalidRelativeURLPath = class extends TaggedError("InvalidRelativeURLPath")
10731
11091
  });
10732
11092
  }
10733
11093
  };
10734
- var InvalidBaseURL = class extends TaggedError("InvalidBaseURL")() {
11094
+ var InvalidBaseURL = class extends h("InvalidBaseURL")() {
10735
11095
  constructor({ baseURL }) {
10736
11096
  super({
10737
11097
  baseURL,
@@ -10742,25 +11102,25 @@ var InvalidBaseURL = class extends TaggedError("InvalidBaseURL")() {
10742
11102
  /** Parse a path that is safe to resolve against a caller-provided base URL. */
10743
11103
  const parseRelativeURLPath = (path) => {
10744
11104
  const trimmedPath = path.trimStart();
10745
- if (absoluteURLPathPattern.test(trimmedPath) || protocolRelativeURLPathPattern.test(trimmedPath)) return Result.err(new InvalidRelativeURLPath({ path }));
10746
- return Result.ok(stripLeadingSlashes(path));
11105
+ if (absoluteURLPathPattern.test(trimmedPath) || protocolRelativeURLPathPattern.test(trimmedPath)) return G.err(new InvalidRelativeURLPath({ path }));
11106
+ return G.ok(stripLeadingSlashes(path));
10747
11107
  };
10748
11108
  const createURLResult = (baseURL, path) => {
10749
11109
  const parsedPath = parseRelativeURLPath(path);
10750
- if (Result.isError(parsedPath)) return Result.err(parsedPath.error);
11110
+ if (G.isError(parsedPath)) return G.err(parsedPath.error);
10751
11111
  try {
10752
- return Result.ok(new URL(parsedPath.value, ensureTrailingSlash(stripTrailingSlashes(baseURL.toString()))));
11112
+ return G.ok(new URL(parsedPath.value, ensureTrailingSlash(stripTrailingSlashes(baseURL.toString()))));
10753
11113
  } catch {
10754
- return Result.err(new InvalidBaseURL({ baseURL: baseURL.toString() }));
11114
+ return G.err(new InvalidBaseURL({ baseURL: baseURL.toString() }));
10755
11115
  }
10756
11116
  };
10757
11117
  const createURL = (baseURL, path) => {
10758
11118
  const url = createURLResult(baseURL, path);
10759
- if (Result.isError(url)) throw url.error;
11119
+ if (G.isError(url)) throw url.error;
10760
11120
  return url.value;
10761
11121
  };
10762
11122
  const createAbsoluteURL = (baseURL, path) => createURL(baseURL, path).toString();
10763
- TaggedError("MissingPathTemplateParam")();
11123
+ h("MissingPathTemplateParam")();
10764
11124
  //#endregion
10765
11125
  //#region ../../node_modules/.bun/ky@2.0.2/node_modules/ky/distribution/errors/KyError.js
10766
11126
  /**
@@ -12047,8 +12407,8 @@ object({
12047
12407
  status: number(),
12048
12408
  type: string()
12049
12409
  });
12050
- TaggedError("UnipileAPIError")();
12051
- TaggedError("UnipileHostedAuthURLMissingError")();
12410
+ h("UnipileAPIError")();
12411
+ h("UnipileHostedAuthURLMissingError")();
12052
12412
  looseObject({
12053
12413
  object: literal("HostedAuthLink"),
12054
12414
  link: string()
@@ -12084,7 +12444,7 @@ const SocialTargetPrefixes = {
12084
12444
  company_id: "company",
12085
12445
  request_id: "request"
12086
12446
  };
12087
- var InvalidSocialSelector = class extends TaggedError("InvalidSocialSelector")() {
12447
+ var InvalidSocialSelector = class extends h("InvalidSocialSelector")() {
12088
12448
  constructor({ value, reason }) {
12089
12449
  super({
12090
12450
  value,
@@ -12145,42 +12505,42 @@ const linkedInURNKindFrom = (value) => {
12145
12505
  };
12146
12506
  const parseTypedSocialSelector = (value, options = {}) => {
12147
12507
  const parsed = parseTypedSocialSelectorResult(value, options);
12148
- return Result.isOk(parsed) ? parsed.value : void 0;
12508
+ return G.isOk(parsed) ? parsed.value : void 0;
12149
12509
  };
12150
12510
  const parseTypedSocialSelectorResult = (value, options = {}) => {
12151
12511
  const trimmed = value.trim();
12152
12512
  const colon = trimmed.indexOf(":");
12153
- if (colon <= 0) return Result.err(new InvalidSocialSelector({
12513
+ if (colon <= 0) return G.err(new InvalidSocialSelector({
12154
12514
  value,
12155
12515
  reason: "missing-prefix"
12156
12516
  }));
12157
12517
  const prefix = trimmed.slice(0, colon);
12158
- if (!isSocialTargetPrefix(prefix)) return Result.err(new InvalidSocialSelector({
12518
+ if (!isSocialTargetPrefix(prefix)) return G.err(new InvalidSocialSelector({
12159
12519
  value,
12160
12520
  reason: "unsupported-prefix"
12161
12521
  }));
12162
- if (options.prefixes && !options.prefixes.includes(prefix)) return Result.err(new InvalidSocialSelector({
12522
+ if (options.prefixes && !options.prefixes.includes(prefix)) return G.err(new InvalidSocialSelector({
12163
12523
  value,
12164
12524
  reason: "disallowed-prefix"
12165
12525
  }));
12166
12526
  const id = trimmed.slice(colon + 1).trim();
12167
- if (options.idMode === "lenient") return Result.ok({
12527
+ if (options.idMode === "lenient") return G.ok({
12168
12528
  prefix,
12169
12529
  kind: SocialTargetPrefixes[prefix],
12170
12530
  id
12171
12531
  });
12172
12532
  const parsed = plainResourceIdSchema(prefix).safeParse(id);
12173
- return parsed.success ? Result.ok({
12533
+ return parsed.success ? G.ok({
12174
12534
  prefix,
12175
12535
  kind: SocialTargetPrefixes[prefix],
12176
12536
  id: parsed.data
12177
- }) : Result.err(new InvalidSocialSelector({
12537
+ }) : G.err(new InvalidSocialSelector({
12178
12538
  value,
12179
12539
  reason: "invalid-id"
12180
12540
  }));
12181
12541
  };
12182
- TaggedError("InvalidLinkedinUpstreamPlanInput")();
12183
- TaggedError("InvalidUnipileCredentials")();
12542
+ h("InvalidLinkedinUpstreamPlanInput")();
12543
+ h("InvalidUnipileCredentials")();
12184
12544
  //#endregion
12185
12545
  //#region ../../packages/linkedin/src/profiles.ts
12186
12546
  const displayNameFrom = (firstName, lastName, username) => [firstName, lastName].filter(Boolean).join(" ").trim() || username || "";
@@ -12299,8 +12659,8 @@ looseObject({
12299
12659
  data: array(GroupParticipant),
12300
12660
  next_cursor: string().nullish()
12301
12661
  });
12302
- TaggedError("ChatListParseError")();
12303
- TaggedError("ChatParticipantsFetchError")();
12662
+ h("ChatListParseError")();
12663
+ h("ChatParticipantsFetchError")();
12304
12664
  const linkedinProfileExtractors = {
12305
12665
  "GET /users/me": extractProfile$1,
12306
12666
  "GET /users/:identifier": extractProfile$1,
@@ -14268,7 +14628,7 @@ const isoDatePattern = /^\d{4}-(0[1-9]|1[0-2])-(0[1-9]|[12]\d|3[01])$/;
14268
14628
  const isoDateTimePattern = /^\d{4}-(0[1-9]|1[0-2])-(0[1-9]|[12]\d|3[01])T([01]\d|2[0-3]):[0-5]\d(?::[0-5]\d(?:\.\d{1,3})?)?(?:Z|[+-]([01]\d|2[0-3]):[0-5]\d)?$/;
14269
14629
  const timezonePattern = /(Z|[+-]\d{2}:\d{2})$/;
14270
14630
  const invalidSinceMessage = "Invalid --since value. Use an ISO 8601 date like 2026-05-04 or datetime like 2026-05-04T00:00:00Z.";
14271
- var InvalidSince = class extends TaggedError("InvalidSince")() {
14631
+ var InvalidSince = class extends h("InvalidSince")() {
14272
14632
  constructor(input) {
14273
14633
  super({
14274
14634
  input,
@@ -14296,23 +14656,23 @@ const parseSinceResult = (input) => {
14296
14656
  const isISODateTime = isoDateTimePattern.test(value);
14297
14657
  const normalized = isISODateTime && !timezonePattern.test(value) ? `${value}Z` : value;
14298
14658
  const parsed = (isISODate || isISODateTime) && hasValidDate(value) ? Date.parse(normalized) : NaN;
14299
- if (Number.isNaN(parsed)) return Result.err(new InvalidSince(input));
14300
- return Result.ok(parsed);
14659
+ if (Number.isNaN(parsed)) return G.err(new InvalidSince(input));
14660
+ return G.ok(parsed);
14301
14661
  };
14302
14662
  //#endregion
14303
14663
  //#region ../../packages/linkedin/src/cli/sync-plan.ts
14304
- var UnknownLinkedinSyncCollection = class extends TaggedError("UnknownLinkedinSyncCollection")() {};
14305
- var LinkedinSyncResetRequiresCollection = class extends TaggedError("LinkedinSyncResetRequiresCollection")() {
14664
+ var UnknownLinkedinSyncCollection = class extends h("UnknownLinkedinSyncCollection")() {};
14665
+ var LinkedinSyncResetRequiresCollection = class extends h("LinkedinSyncResetRequiresCollection")() {
14306
14666
  constructor() {
14307
14667
  super({ message: "--reset requires a collection" });
14308
14668
  }
14309
14669
  };
14310
- var LinkedinSyncResetWithSince = class extends TaggedError("LinkedinSyncResetWithSince")() {
14670
+ var LinkedinSyncResetWithSince = class extends h("LinkedinSyncResetWithSince")() {
14311
14671
  constructor() {
14312
14672
  super({ message: "--reset cannot be combined with --since" });
14313
14673
  }
14314
14674
  };
14315
- var LinkedinSyncUnsupportedSince = class extends TaggedError("LinkedinSyncUnsupportedSince")() {
14675
+ var LinkedinSyncUnsupportedSince = class extends h("LinkedinSyncUnsupportedSince")() {
14316
14676
  constructor(collection) {
14317
14677
  super({
14318
14678
  collection,
@@ -14320,7 +14680,7 @@ var LinkedinSyncUnsupportedSince = class extends TaggedError("LinkedinSyncUnsupp
14320
14680
  });
14321
14681
  }
14322
14682
  };
14323
- var LinkedinSyncMissingInitialFullSync = class extends TaggedError("LinkedinSyncMissingInitialFullSync")() {
14683
+ var LinkedinSyncMissingInitialFullSync = class extends h("LinkedinSyncMissingInitialFullSync")() {
14324
14684
  constructor(collection) {
14325
14685
  super({
14326
14686
  collection,
@@ -14328,36 +14688,36 @@ var LinkedinSyncMissingInitialFullSync = class extends TaggedError("LinkedinSync
14328
14688
  });
14329
14689
  }
14330
14690
  };
14331
- var InvalidLinkedinSyncSince = class extends TaggedError("InvalidLinkedinSyncSince")() {};
14691
+ var InvalidLinkedinSyncSince = class extends h("InvalidLinkedinSyncSince")() {};
14332
14692
  const linkedinSyncCollectionShortName = (collection) => collection.key.replace(/^(x|li)_/, "");
14333
14693
  const linkedinSyncCollectionFor = (collections, collection) => {
14334
14694
  const found = collections.find((candidate) => linkedinSyncCollectionShortName(candidate) === collection || candidate.key === collection);
14335
- if (found) return Result.ok(found);
14695
+ if (found) return G.ok(found);
14336
14696
  const available = collections.map(linkedinSyncCollectionShortName);
14337
- return Result.err(new UnknownLinkedinSyncCollection({
14697
+ return G.err(new UnknownLinkedinSyncCollection({
14338
14698
  collection,
14339
14699
  available,
14340
14700
  message: `Unknown collection "${collection}". Available: ${available.join(", ")}`
14341
14701
  }));
14342
14702
  };
14343
14703
  const planLinkedinSyncCommand = ({ args, collections, cursorState }) => {
14344
- if (!args.collection) return args.reset === true ? Result.err(new LinkedinSyncResetRequiresCollection()) : Result.ok({ mode: "list" });
14704
+ if (!args.collection) return args.reset === true ? G.err(new LinkedinSyncResetRequiresCollection()) : G.ok({ mode: "list" });
14345
14705
  const collection = linkedinSyncCollectionFor(collections, String(args.collection));
14346
- if (Result.isError(collection)) return Result.err(collection.error);
14347
- if (args.reset === true) return args.since == null ? Result.ok({
14706
+ if (G.isError(collection)) return G.err(collection.error);
14707
+ if (args.reset === true) return args.since == null ? G.ok({
14348
14708
  mode: "reset",
14349
14709
  collection: collection.value
14350
- }) : Result.err(new LinkedinSyncResetWithSince());
14351
- if (args.since == null) return Result.ok({
14710
+ }) : G.err(new LinkedinSyncResetWithSince());
14711
+ if (args.since == null) return G.ok({
14352
14712
  mode: "run",
14353
14713
  collection: collection.value
14354
14714
  });
14355
14715
  const shortName = linkedinSyncCollectionShortName(collection.value);
14356
- if (!collection.value.sinceField) return Result.err(new LinkedinSyncUnsupportedSince(shortName));
14357
- if (collection.value.requiresFullInitialSync && cursorState?.lastSynced == null) return Result.err(new LinkedinSyncMissingInitialFullSync(shortName));
14716
+ if (!collection.value.sinceField) return G.err(new LinkedinSyncUnsupportedSince(shortName));
14717
+ if (collection.value.requiresFullInitialSync && cursorState?.lastSynced == null) return G.err(new LinkedinSyncMissingInitialFullSync(shortName));
14358
14718
  const parsedSince = parseSinceResult(String(args.since));
14359
- if (Result.isError(parsedSince)) return Result.err(new InvalidLinkedinSyncSince({ message: parsedSince.error.message }));
14360
- return Result.ok({
14719
+ if (G.isError(parsedSince)) return G.err(new InvalidLinkedinSyncSince({ message: parsedSince.error.message }));
14720
+ return G.ok({
14361
14721
  mode: "run",
14362
14722
  collection: collection.value,
14363
14723
  since: parsedSince.value
@@ -14787,7 +15147,7 @@ const buildSync$1 = (deps, platform) => defineCommand({
14787
15147
  }
14788
15148
  })() : void 0
14789
15149
  });
14790
- if (Result.isError(plan)) throw new UsageError(plan.error.message);
15150
+ if (G.isError(plan)) throw new UsageError(plan.error.message);
14791
15151
  if (plan.value.mode === "list") {
14792
15152
  const cache = openLinkedinCache({
14793
15153
  platform,
@@ -14864,7 +15224,7 @@ const buildSync$1 = (deps, platform) => defineCommand({
14864
15224
  if (rateLimitError) throw rateLimitError;
14865
15225
  throw error;
14866
15226
  }
14867
- if (Result.isError(result)) {
15227
+ if (G.isError(result)) {
14868
15228
  progress.error();
14869
15229
  const rateLimitError = enrichRateLimitSyncError$1({
14870
15230
  error: result.error,
@@ -14973,7 +15333,7 @@ const buildSql$1 = (deps, platform) => defineCommand({
14973
15333
  } catch (error) {
14974
15334
  throw new UsageError(`Query failed (cache is read-only): ${error instanceof Error ? error.message : String(error)}`);
14975
15335
  }
14976
- if (Result.isError(result)) throw new UsageError(`Query failed (cache is read-only): ${result.error.message}`);
15336
+ if (G.isError(result)) throw new UsageError(`Query failed (cache is read-only): ${result.error.message}`);
14977
15337
  await deps.printResult({
14978
15338
  account: res.account,
14979
15339
  contract,
@@ -19015,7 +19375,7 @@ const contractFor$1 = (op, commandName, group) => buildRuntimeContract(xRuntimeA
19015
19375
  const defineOperationCommand = (op, deps) => defineRuntimeOperationCommand(xRuntimeAdapter, op, deps);
19016
19376
  //#endregion
19017
19377
  //#region ../../packages/x/src/cli/sync-plan.ts
19018
- var XSyncPlanError = class extends TaggedError("XSyncPlanError")() {
19378
+ var XSyncPlanError = class extends h("XSyncPlanError")() {
19019
19379
  constructor(args) {
19020
19380
  super(args);
19021
19381
  this.name = "XSyncPlanError";
@@ -19024,30 +19384,30 @@ var XSyncPlanError = class extends TaggedError("XSyncPlanError")() {
19024
19384
  const shortSyncCollectionName = (collection) => collection.key.replace(/^(x|li)_/, "");
19025
19385
  const findSyncCollection = (collections, input) => collections.find((collection) => shortSyncCollectionName(collection) === input || collection.key === input);
19026
19386
  const parseTimeoutSeconds = (value) => {
19027
- if (value == null) return Result.ok(void 0);
19387
+ if (value == null) return G.ok(void 0);
19028
19388
  const timeoutSeconds = Number(value);
19029
- if (!Number.isInteger(timeoutSeconds) || timeoutSeconds < 1) return Result.err(new XSyncPlanError({
19389
+ if (!Number.isInteger(timeoutSeconds) || timeoutSeconds < 1) return G.err(new XSyncPlanError({
19030
19390
  kind: "invalid-timeout",
19031
19391
  message: "--timeout must be at least 1."
19032
19392
  }));
19033
- return Result.ok(timeoutSeconds);
19393
+ return G.ok(timeoutSeconds);
19034
19394
  };
19035
19395
  const planXSync = (input) => {
19036
19396
  const accountSelector = input.accountSelector;
19037
- if (accountSelector === void 0 || accountSelector.length === 0) return Result.err(new XSyncPlanError({
19397
+ if (accountSelector === void 0 || accountSelector.length === 0) return G.err(new XSyncPlanError({
19038
19398
  kind: "missing-account-selector",
19039
19399
  message: "Selected X account is missing an account selector."
19040
19400
  }));
19041
19401
  const timeout = parseTimeoutSeconds(input.timeout);
19042
- if (Result.isError(timeout)) return Result.err(timeout.error);
19402
+ if (G.isError(timeout)) return G.err(timeout.error);
19043
19403
  const accountHeaders = { "x-social-account-id": accountSelector };
19044
19404
  const collectionInput = typeof input.collection === "string" && input.collection.length > 0 ? input.collection : void 0;
19045
19405
  if (collectionInput === void 0) {
19046
- if (input.reset === true) return Result.err(new XSyncPlanError({
19406
+ if (input.reset === true) return G.err(new XSyncPlanError({
19047
19407
  kind: "reset-without-collection",
19048
19408
  message: "--reset requires a collection"
19049
19409
  }));
19050
- return Result.ok({
19410
+ return G.ok({
19051
19411
  kind: "list",
19052
19412
  accountHeaders,
19053
19413
  accountSelector,
@@ -19055,19 +19415,19 @@ const planXSync = (input) => {
19055
19415
  });
19056
19416
  }
19057
19417
  const collection = findSyncCollection(input.collections, collectionInput);
19058
- if (collection === void 0) return Result.err(new XSyncPlanError({
19418
+ if (collection === void 0) return G.err(new XSyncPlanError({
19059
19419
  kind: "unknown-collection",
19060
19420
  collection: collectionInput,
19061
19421
  message: `Unknown collection "${collectionInput}". Available: ${input.collections.map(shortSyncCollectionName).join(", ")}`
19062
19422
  }));
19063
19423
  if (input.reset === true) {
19064
- if (input.since != null) return Result.err(new XSyncPlanError({
19424
+ if (input.since != null) return G.err(new XSyncPlanError({
19065
19425
  kind: "reset-with-since",
19066
19426
  collection: collection.key,
19067
19427
  message: "--reset cannot be combined with --since"
19068
19428
  }));
19069
19429
  const resetCollections = resetTablesFor(collection);
19070
- return Result.ok({
19430
+ return G.ok({
19071
19431
  kind: "reset",
19072
19432
  accountHeaders,
19073
19433
  accountSelector,
@@ -19078,20 +19438,20 @@ const planXSync = (input) => {
19078
19438
  }
19079
19439
  let since;
19080
19440
  if (input.since != null) {
19081
- if (!collection.sinceField) return Result.err(new XSyncPlanError({
19441
+ if (!collection.sinceField) return G.err(new XSyncPlanError({
19082
19442
  kind: "since-unsupported",
19083
19443
  collection: collection.key,
19084
19444
  message: `${shortSyncCollectionName(collection)} does not support --since`
19085
19445
  }));
19086
19446
  const parsedSince = parseSinceResult(String(input.since));
19087
- if (Result.isError(parsedSince)) return Result.err(new XSyncPlanError({
19447
+ if (G.isError(parsedSince)) return G.err(new XSyncPlanError({
19088
19448
  kind: "since-unsupported",
19089
19449
  collection: collection.key,
19090
19450
  message: parsedSince.error.message
19091
19451
  }));
19092
19452
  since = parsedSince.value;
19093
19453
  }
19094
- return Result.ok({
19454
+ return G.ok({
19095
19455
  kind: "run",
19096
19456
  accountHeaders,
19097
19457
  accountSelector,
@@ -19102,7 +19462,7 @@ const planXSync = (input) => {
19102
19462
  };
19103
19463
  //#endregion
19104
19464
  //#region ../../packages/x/src/cli/write-plan.ts
19105
- var XWritePlanError = class extends TaggedError("XWritePlanError")() {
19465
+ var XWritePlanError = class extends h("XWritePlanError")() {
19106
19466
  constructor(args) {
19107
19467
  super(args);
19108
19468
  this.name = "XWritePlanError";
@@ -19124,16 +19484,16 @@ const responseString = (data, keys) => {
19124
19484
  const responseMediaIdResult = (data) => {
19125
19485
  const root = isObjectRecord$1(data) ? data : void 0;
19126
19486
  const id = (isObjectRecord$1(root?.data) ? root.data : void 0)?.id ?? root?.id;
19127
- if (typeof id !== "string" && typeof id !== "number") return Result.err(new XWritePlanError({
19487
+ if (typeof id !== "string" && typeof id !== "number") return G.err(new XWritePlanError({
19128
19488
  kind: "missing-media-id",
19129
19489
  message: "Media upload did not return a media id."
19130
19490
  }));
19131
- return Result.ok(String(id));
19491
+ return G.ok(String(id));
19132
19492
  };
19133
- const requiredTargetResult = (target) => target === void 0 ? Result.err(new XWritePlanError({
19493
+ const requiredTargetResult = (target) => target === void 0 ? G.err(new XWritePlanError({
19134
19494
  kind: "missing-target",
19135
19495
  message: "target is required."
19136
- })) : Result.ok(target);
19496
+ })) : G.ok(target);
19137
19497
  const postMediaByExtension = {
19138
19498
  ".gif": {
19139
19499
  mediaType: "image/gif",
@@ -19166,22 +19526,22 @@ const postMediaByExtension = {
19166
19526
  };
19167
19527
  const parsePostMediaFileResult = (path) => {
19168
19528
  const media = postMediaByExtension[extname(path).toLowerCase()];
19169
- if (media === void 0) return Result.err(new XWritePlanError({
19529
+ if (media === void 0) return G.err(new XWritePlanError({
19170
19530
  kind: "invalid-media-type",
19171
19531
  message: `Unsupported media type for ${path}. Supported types: jpg, jpeg, png, webp, gif, mp4, mov.`
19172
19532
  }));
19173
- return Result.ok({
19533
+ return G.ok({
19174
19534
  ...media,
19175
19535
  path
19176
19536
  });
19177
19537
  };
19178
19538
  const parsePostMediaIdResult = (value) => {
19179
19539
  const mediaId = value.trim();
19180
- if (mediaId.length === 0) return Result.err(new XWritePlanError({
19540
+ if (mediaId.length === 0) return G.err(new XWritePlanError({
19181
19541
  kind: "empty-media-id",
19182
19542
  message: "--media-id cannot be empty."
19183
19543
  }));
19184
- return Result.ok(mediaId);
19544
+ return G.ok(mediaId);
19185
19545
  };
19186
19546
  const postBodyHasText = (body) => {
19187
19547
  const text = body?.text;
@@ -19193,7 +19553,7 @@ const postBodyMediaIds = (body) => {
19193
19553
  };
19194
19554
  const postBodyHasPoll = (body) => isObjectRecord$1(body?.poll);
19195
19555
  const validatePostMediaResult = (mediaFiles, mediaIds) => {
19196
- if (mediaFiles.length + mediaIds.length > 4) return Result.err(new XWritePlanError({
19556
+ if (mediaFiles.length + mediaIds.length > 4) return G.err(new XWritePlanError({
19197
19557
  kind: "invalid-media-mix",
19198
19558
  message: "Attach at most 4 media items."
19199
19559
  }));
@@ -19205,35 +19565,35 @@ const validatePostMediaResult = (mediaFiles, mediaIds) => {
19205
19565
  gifCount > 0,
19206
19566
  videoCount > 0
19207
19567
  ].filter(Boolean).length;
19208
- if (imageCount > 4) return Result.err(new XWritePlanError({
19568
+ if (imageCount > 4) return G.err(new XWritePlanError({
19209
19569
  kind: "invalid-media-mix",
19210
19570
  message: "Attach at most 4 images."
19211
19571
  }));
19212
- if (gifCount > 1) return Result.err(new XWritePlanError({
19572
+ if (gifCount > 1) return G.err(new XWritePlanError({
19213
19573
  kind: "invalid-media-mix",
19214
19574
  message: "Attach at most 1 GIF."
19215
19575
  }));
19216
- if (videoCount > 1) return Result.err(new XWritePlanError({
19576
+ if (videoCount > 1) return G.err(new XWritePlanError({
19217
19577
  kind: "invalid-media-mix",
19218
19578
  message: "Attach at most 1 video."
19219
19579
  }));
19220
- if (localCategoryCount > 1) return Result.err(new XWritePlanError({
19580
+ if (localCategoryCount > 1) return G.err(new XWritePlanError({
19221
19581
  kind: "invalid-media-mix",
19222
19582
  message: "Do not mix images, GIFs, and videos in one post."
19223
19583
  }));
19224
- return Result.ok();
19584
+ return G.ok();
19225
19585
  };
19226
19586
  const validatePostPollMediaResult = (args) => {
19227
19587
  const explicitMediaCount = args.mediaFiles.length + args.mediaIds.length;
19228
19588
  const bodyMediaIds = explicitMediaCount > 0 ? [] : postBodyMediaIds(args.bodyFields);
19229
19589
  const hasMedia = explicitMediaCount + bodyMediaIds.length > 0;
19230
19590
  const hasPoll = args.poll !== void 0 || postBodyHasPoll(args.bodyFields);
19231
- if (hasPoll && hasMedia) return Result.err(new XWritePlanError({
19591
+ if (hasPoll && hasMedia) return G.err(new XWritePlanError({
19232
19592
  kind: "invalid-media-mix",
19233
19593
  message: "--poll-option cannot be combined with media attachments."
19234
19594
  }));
19235
19595
  const media = validatePostMediaResult(args.mediaFiles, [...args.mediaIds, ...bodyMediaIds]);
19236
- return Result.isError(media) ? Result.err(media.error) : Result.ok({
19596
+ return G.isError(media) ? G.err(media.error) : G.ok({
19237
19597
  bodyMediaIds,
19238
19598
  hasMedia,
19239
19599
  hasPoll
@@ -19303,12 +19663,12 @@ const planPostRequest = (args) => {
19303
19663
  };
19304
19664
  };
19305
19665
  const planMessageRequestResult = (args) => {
19306
- if (args.body === void 0) return Result.err(new XWritePlanError({
19666
+ if (args.body === void 0) return G.err(new XWritePlanError({
19307
19667
  kind: "missing-message-body",
19308
19668
  message: "Message body is required."
19309
19669
  }));
19310
19670
  const text = typeof args.body.text === "string" ? args.body.text : void 0;
19311
- if (args.threadResolution !== void 0) return Result.ok({
19671
+ if (args.threadResolution !== void 0) return G.ok({
19312
19672
  method: "POST",
19313
19673
  path: `x/dm_conversations/${encodeURIComponent(args.threadResolution.id)}/messages`,
19314
19674
  headers: args.headers,
@@ -19320,11 +19680,11 @@ const planMessageRequestResult = (args) => {
19320
19680
  });
19321
19681
  if (args.recipients.length === 1) {
19322
19682
  const [participant] = args.participantResolutions;
19323
- if (participant === void 0) return Result.err(new XWritePlanError({
19683
+ if (participant === void 0) return G.err(new XWritePlanError({
19324
19684
  kind: "missing-target",
19325
19685
  message: "Pass at least one recipient."
19326
19686
  }));
19327
- return Result.ok({
19687
+ return G.ok({
19328
19688
  method: "POST",
19329
19689
  path: `x/dm_conversations/with/${encodeURIComponent(participant.id)}/messages`,
19330
19690
  headers: args.headers,
@@ -19337,7 +19697,7 @@ const planMessageRequestResult = (args) => {
19337
19697
  }
19338
19698
  const participantIds = args.participantResolutions.map((resolution) => resolution.id);
19339
19699
  const { text: bodyText, ...bodyFields } = args.body;
19340
- return Result.ok({
19700
+ return G.ok({
19341
19701
  method: "POST",
19342
19702
  path: "x/dm_conversations",
19343
19703
  headers: args.headers,
@@ -19816,7 +20176,7 @@ const buildSync = (deps, platform) => defineCommand({
19816
20176
  since: args.since,
19817
20177
  timeout: args.timeout
19818
20178
  });
19819
- if (Result.isError(planned)) throw new UsageError(planned.error instanceof XSyncPlanError ? planned.error.message : String(planned.error));
20179
+ if (G.isError(planned)) throw new UsageError(planned.error instanceof XSyncPlanError ? planned.error.message : String(planned.error));
19820
20180
  const plan = planned.value;
19821
20181
  if (plan.kind === "list") {
19822
20182
  const cache = openXCacheFor(deps, {
@@ -19884,7 +20244,7 @@ const buildSync = (deps, platform) => defineCommand({
19884
20244
  if (rateLimitError) throw rateLimitError;
19885
20245
  throw error;
19886
20246
  }
19887
- if (Result.isError(result)) {
20247
+ if (G.isError(result)) {
19888
20248
  const rateLimitError = enrichRateLimitSyncError({
19889
20249
  error: result.error,
19890
20250
  platform,
@@ -19991,7 +20351,7 @@ const buildSql = (deps, platform) => {
19991
20351
  } catch (error) {
19992
20352
  throw new UsageError(`Query failed (cache is read-only): ${errorMessageFrom(error)}`);
19993
20353
  }
19994
- if (Result.isError(result)) throw new UsageError(`Query failed (cache is read-only): ${result.error.message}`);
20354
+ if (G.isError(result)) throw new UsageError(`Query failed (cache is read-only): ${result.error.message}`);
19995
20355
  await deps.printResult({
19996
20356
  account: account.account,
19997
20357
  contract: schemaContract,
@@ -20076,7 +20436,7 @@ const throwWritePlanError = (error) => {
20076
20436
  };
20077
20437
  const requireWriteTarget = (target) => {
20078
20438
  const required = requiredTargetResult(target);
20079
- if (Result.isError(required)) return throwWritePlanError(required.error);
20439
+ if (G.isError(required)) return throwWritePlanError(required.error);
20080
20440
  return required.value;
20081
20441
  };
20082
20442
  const executeWriteRequest = (deps, plan) => plan.method === "POST" ? deps.api.post(plan.path, {
@@ -20129,7 +20489,7 @@ const repeatableValues = (name, value, rawArgs) => {
20129
20489
  };
20130
20490
  const parsePostMediaId = (deps, value) => {
20131
20491
  const mediaId = parsePostMediaIdResult(value);
20132
- if (Result.isError(mediaId)) throw new UsageError(mediaId.error.message);
20492
+ if (G.isError(mediaId)) throw new UsageError(mediaId.error.message);
20133
20493
  return deps.parseResourceId("--media-id", mediaId.value);
20134
20494
  };
20135
20495
  const parsePostPoll = (deps, args, rawArgs) => {
@@ -20213,7 +20573,7 @@ const uploadPostMedia = async (deps, headers, media, timeoutSeconds) => {
20213
20573
  initBody.set("total_bytes", String(file.byteLength));
20214
20574
  initBody.set("media_category", media.category);
20215
20575
  const mediaId = responseMediaIdResult(await (await postMediaForm(deps, "x/media/upload/init", headers, initBody)).json());
20216
- if (Result.isError(mediaId)) throw new UsageError(mediaId.error.message);
20576
+ if (G.isError(mediaId)) throw new UsageError(mediaId.error.message);
20217
20577
  for (let segmentIndex = 0, offset = 0; offset < file.byteLength; segmentIndex += 1, offset += postMediaChunkSize) {
20218
20578
  const chunk = file.subarray(offset, offset + postMediaChunkSize);
20219
20579
  const appendBody = new FormData();
@@ -20475,7 +20835,7 @@ const buildPost = (deps) => {
20475
20835
  const commandArgs = args;
20476
20836
  const mediaFiles = repeatableValues("media", commandArgs.media, rawArgs).map((path) => {
20477
20837
  const media = parsePostMediaFileResult(path);
20478
- if (Result.isError(media)) throw new UsageError(media.error.message);
20838
+ if (G.isError(media)) throw new UsageError(media.error.message);
20479
20839
  return media.value;
20480
20840
  });
20481
20841
  const mediaIds = repeatableValues("media-id", commandArgs["media-id"], rawArgs).map((mediaId) => parsePostMediaId(deps, mediaId));
@@ -20487,7 +20847,7 @@ const buildPost = (deps) => {
20487
20847
  mediaIds,
20488
20848
  poll
20489
20849
  });
20490
- if (Result.isError(postInputs)) throw new UsageError(postInputs.error.message);
20850
+ if (G.isError(postInputs)) throw new UsageError(postInputs.error.message);
20491
20851
  const timeoutSeconds = commandArgs.timeout === void 0 ? postMediaProcessingTimeoutSeconds : deps.parseIntegerString("--timeout", commandArgs.timeout, { min: 1 });
20492
20852
  const stdinBody = await readPostStdinBody(deps, postInputs.value.hasMedia, bodyFields);
20493
20853
  const account = typeof commandArgs.account === "string" ? commandArgs.account : void 0;
@@ -20799,7 +21159,7 @@ const buildMessage = (deps) => {
20799
21159
  recipients,
20800
21160
  threadResolution
20801
21161
  });
20802
- if (Result.isError(request)) throw new UsageError(request.error.message);
21162
+ if (G.isError(request)) throw new UsageError(request.error.message);
20803
21163
  const response = await deps.api.post(request.value.path, {
20804
21164
  headers: request.value.headers,
20805
21165
  json: request.value.body
@@ -21080,10 +21440,10 @@ createXCommands({
21080
21440
  //#endregion
21081
21441
  //#region ../../packages/linkedin/src/cli/lifecycle-plan.ts
21082
21442
  const LINKEDIN_CONNECTED_STATUS = "connected";
21083
- var InvalidLinkedinLifecycleTarget = class extends TaggedError("InvalidLinkedinLifecycleTarget")() {};
21084
- var LinkedinLifecycleNoAccountMatch = class extends TaggedError("LinkedinLifecycleNoAccountMatch")() {};
21085
- var LinkedinLifecycleAmbiguousAccount = class extends TaggedError("LinkedinLifecycleAmbiguousAccount")() {};
21086
- var LinkedinLifecycleSeatTimeout = class extends TaggedError("LinkedinLifecycleSeatTimeout")() {
21443
+ var InvalidLinkedinLifecycleTarget = class extends h("InvalidLinkedinLifecycleTarget")() {};
21444
+ var LinkedinLifecycleNoAccountMatch = class extends h("LinkedinLifecycleNoAccountMatch")() {};
21445
+ var LinkedinLifecycleAmbiguousAccount = class extends h("LinkedinLifecycleAmbiguousAccount")() {};
21446
+ var LinkedinLifecycleSeatTimeout = class extends h("LinkedinLifecycleSeatTimeout")() {
21087
21447
  constructor() {
21088
21448
  super({ message: "billing_seat_timed_out" });
21089
21449
  }
@@ -21093,22 +21453,22 @@ const parseLinkedinReconnectTarget = (value) => {
21093
21453
  const trimmed = value.trim();
21094
21454
  if (trimmed.startsWith("@")) {
21095
21455
  const username = normalizeSocialIdentifier(trimmed);
21096
- if (username) return Result.ok({
21456
+ if (username) return G.ok({
21097
21457
  type: "username",
21098
21458
  value: username
21099
21459
  });
21100
21460
  }
21101
21461
  const profileSelector = parseTypedSocialSelector(trimmed, { prefixes: ["profile_id"] });
21102
- if (profileSelector) return Result.ok({
21462
+ if (profileSelector) return G.ok({
21103
21463
  type: "profileId",
21104
21464
  value: profileSelector.id.toLowerCase()
21105
21465
  });
21106
21466
  const publicIdentifier = linkedInProfileIdentifierFromURL(trimmed);
21107
- if (publicIdentifier) return Result.ok({
21467
+ if (publicIdentifier) return G.ok({
21108
21468
  type: "username",
21109
21469
  value: publicIdentifier
21110
21470
  });
21111
- return Result.err(new InvalidLinkedinLifecycleTarget({
21471
+ return G.err(new InvalidLinkedinLifecycleTarget({
21112
21472
  value,
21113
21473
  message: "LinkedIn reconnect account must be @username, a LinkedIn profile URL, or profile_id:<id>."
21114
21474
  }));
@@ -21124,14 +21484,14 @@ const reconnectCommandTargetFor = (account) => {
21124
21484
  const connectedLinkedinLifecycleAccounts = (accounts) => accounts.filter((account) => account.status === LINKEDIN_CONNECTED_STATUS);
21125
21485
  const resolveLinkedinLifecycleAccount = (accounts, identifier) => {
21126
21486
  const target = parseLinkedinReconnectTarget(identifier);
21127
- if (Result.isError(target)) return Result.err(target.error);
21487
+ if (G.isError(target)) return G.err(target.error);
21128
21488
  const matches = accounts.filter((candidate) => linkedinLifecycleAccountMatchesTarget(candidate, target.value));
21129
- if (matches.length === 1 && matches[0]) return Result.ok(matches[0]);
21130
- if (matches.length === 0) return Result.err(new LinkedinLifecycleNoAccountMatch({
21489
+ if (matches.length === 1 && matches[0]) return G.ok(matches[0]);
21490
+ if (matches.length === 0) return G.err(new LinkedinLifecycleNoAccountMatch({
21131
21491
  value: identifier,
21132
21492
  message: `No LinkedIn account matches "${identifier}".`
21133
21493
  }));
21134
- return Result.err(new LinkedinLifecycleAmbiguousAccount({
21494
+ return G.err(new LinkedinLifecycleAmbiguousAccount({
21135
21495
  value: identifier,
21136
21496
  message: `Multiple LinkedIn accounts match "${identifier}". Pass profile_id:<id>.`
21137
21497
  }));
@@ -21139,9 +21499,9 @@ const resolveLinkedinLifecycleAccount = (accounts, identifier) => {
21139
21499
  const resolveLinkedinDisconnectAccount = (accounts, identifier) => {
21140
21500
  if (identifier) return resolveLinkedinLifecycleAccount(accounts, identifier);
21141
21501
  const connected = connectedLinkedinLifecycleAccounts(accounts);
21142
- if (connected.length === 1 && connected[0]) return Result.ok(connected[0]);
21143
- if (connected.length === 0) return Result.err(new LinkedinLifecycleNoAccountMatch({ message: "No connected LinkedIn accounts found." }));
21144
- return Result.err(new LinkedinLifecycleAmbiguousAccount({ message: "Multiple LinkedIn accounts are connected. Pass a public identifier." }));
21502
+ if (connected.length === 1 && connected[0]) return G.ok(connected[0]);
21503
+ if (connected.length === 0) return G.err(new LinkedinLifecycleNoAccountMatch({ message: "No connected LinkedIn accounts found." }));
21504
+ return G.err(new LinkedinLifecycleAmbiguousAccount({ message: "Multiple LinkedIn accounts are connected. Pass a public identifier." }));
21145
21505
  };
21146
21506
  //#endregion
21147
21507
  //#region ../../packages/linkedin/src/cli/lifecycle.ts
@@ -21207,12 +21567,12 @@ const authURLFor$1 = async (deps, operation) => ({
21207
21567
  });
21208
21568
  const reconnectAccountForIdentifier = async (deps, identifier) => {
21209
21569
  const account = resolveLinkedinLifecycleAccount(await listLinkedinLifecycleAccounts(deps), identifier);
21210
- if (Result.isError(account)) throw account.error;
21570
+ if (G.isError(account)) throw account.error;
21211
21571
  return account.value;
21212
21572
  };
21213
21573
  const resolveDisconnectTarget = async (deps, identifier) => {
21214
21574
  const account = resolveLinkedinDisconnectAccount(await listLinkedinLifecycleAccounts(deps, Boolean(identifier)), identifier);
21215
- if (Result.isError(account)) throw account.error;
21575
+ if (G.isError(account)) throw account.error;
21216
21576
  return account.value;
21217
21577
  };
21218
21578
  const connectLinkedinAccount = async (deps) => {
@@ -21260,7 +21620,7 @@ const disconnectLinkedinAccount = async (deps, identifier) => {
21260
21620
  const CONNECT_TIMEOUT_MS = 300 * 1e3;
21261
21621
  const SEAT_POLL_TIMEOUT_MS$1 = 600 * 1e3;
21262
21622
  const POLL_INTERVAL_MS = 2 * 1e3;
21263
- var XConnectTimedOut = class extends TaggedError("XConnectTimedOut")() {
21623
+ var XConnectTimedOut = class extends h("XConnectTimedOut")() {
21264
21624
  constructor(args) {
21265
21625
  super({
21266
21626
  ...args,
@@ -21269,7 +21629,7 @@ var XConnectTimedOut = class extends TaggedError("XConnectTimedOut")() {
21269
21629
  this.name = "XConnectTimedOut";
21270
21630
  }
21271
21631
  };
21272
- var XBillingSeatTimedOut = class extends TaggedError("XBillingSeatTimedOut")() {
21632
+ var XBillingSeatTimedOut = class extends h("XBillingSeatTimedOut")() {
21273
21633
  constructor() {
21274
21634
  super({
21275
21635
  operation: "prepareAccountConnect",
@@ -21279,7 +21639,7 @@ var XBillingSeatTimedOut = class extends TaggedError("XBillingSeatTimedOut")() {
21279
21639
  this.name = "XBillingSeatTimedOut";
21280
21640
  }
21281
21641
  };
21282
- var XAccountNotFound = class extends TaggedError("XAccountNotFound")() {
21642
+ var XAccountNotFound = class extends h("XAccountNotFound")() {
21283
21643
  constructor(args) {
21284
21644
  super({
21285
21645
  ...args,
@@ -21288,9 +21648,9 @@ var XAccountNotFound = class extends TaggedError("XAccountNotFound")() {
21288
21648
  this.name = "XAccountNotFound";
21289
21649
  }
21290
21650
  };
21291
- TaggedError("XAccountNotConnected")();
21292
- TaggedError("XAccountRequired")();
21293
- var XInvalidSelector = class extends TaggedError("XInvalidSelector")() {
21651
+ h("XAccountNotConnected")();
21652
+ h("XAccountRequired")();
21653
+ var XInvalidSelector = class extends h("XInvalidSelector")() {
21294
21654
  constructor(args) {
21295
21655
  super({
21296
21656
  ...args,
@@ -21333,10 +21693,10 @@ const pollForAccount = async (deps, operation, matches) => {
21333
21693
  platform: "x",
21334
21694
  includeDisconnected: true
21335
21695
  })).find(matches);
21336
- if (account) return Result.ok(account);
21696
+ if (account) return G.ok(account);
21337
21697
  await sleep(POLL_INTERVAL_MS);
21338
21698
  }
21339
- return Result.err(new XConnectTimedOut({
21699
+ return G.err(new XConnectTimedOut({
21340
21700
  operation,
21341
21701
  timeoutMS: CONNECT_TIMEOUT_MS
21342
21702
  }));
@@ -21350,15 +21710,15 @@ const pollForSeat$1 = async (deps) => {
21350
21710
  const now = deps.now ?? Date.now;
21351
21711
  const startedAt = now();
21352
21712
  while (now() - startedAt < SEAT_POLL_TIMEOUT_MS$1) {
21353
- if ((await deps.client.billing.status()).canConnect) return Result.ok();
21713
+ if ((await deps.client.billing.status()).canConnect) return G.ok();
21354
21714
  await sleep(POLL_INTERVAL_MS);
21355
21715
  }
21356
- return Result.err(new XBillingSeatTimedOut());
21716
+ return G.err(new XBillingSeatTimedOut());
21357
21717
  };
21358
21718
  const prepareAccountConnect = async (deps) => {
21359
- if ((await deps.client.billing.status()).canConnect) return Result.ok();
21719
+ if ((await deps.client.billing.status()).canConnect) return G.ok();
21360
21720
  const status = await deps.client.billing.prepareAccountConnect();
21361
- if (status.canConnect) return Result.ok();
21721
+ if (status.canConnect) return G.ok();
21362
21722
  if (status.paymentURL) await openOrPrint(deps, status.paymentURL);
21363
21723
  return pollForSeat$1(deps);
21364
21724
  };
@@ -21370,18 +21730,18 @@ const parseXAccountSelector = (target, operation) => {
21370
21730
  const trimmed = target.trim();
21371
21731
  if (trimmed.startsWith("profile_id:")) {
21372
21732
  const profileId = trimmed.slice(11).trim();
21373
- if (profileId && !/[/?#%]/.test(profileId)) return Result.ok({
21733
+ if (profileId && !/[/?#%]/.test(profileId)) return G.ok({
21374
21734
  kind: "profileId",
21375
21735
  normalized: profileId.toLowerCase(),
21376
21736
  raw: target
21377
21737
  });
21378
21738
  }
21379
- if (trimmed.startsWith("@") && !/[/?#%]/.test(trimmed)) return Result.ok({
21739
+ if (trimmed.startsWith("@") && !/[/?#%]/.test(trimmed)) return G.ok({
21380
21740
  kind: "username",
21381
21741
  normalized: normalizeIdentifier(trimmed),
21382
21742
  raw: target
21383
21743
  });
21384
- return Result.err(new XInvalidSelector({
21744
+ return G.err(new XInvalidSelector({
21385
21745
  operation,
21386
21746
  account: target
21387
21747
  }));
@@ -21390,7 +21750,7 @@ const findXLifecycleAccount = (accounts, selector) => {
21390
21750
  if (selector.kind === "profileId") return accounts.find((account) => account.profileId.toLowerCase() === selector.normalized);
21391
21751
  return accounts.find((account) => normalizeIdentifier(account.username) === selector.normalized);
21392
21752
  };
21393
- const listXLifecycleAccounts = async (deps, includeDisconnected) => Result.ok(await deps.client.accounts.list({
21753
+ const listXLifecycleAccounts = async (deps, includeDisconnected) => G.ok(await deps.client.accounts.list({
21394
21754
  platform: "x",
21395
21755
  includeDisconnected
21396
21756
  }));
@@ -21401,12 +21761,12 @@ const listXLifecycleAccounts = async (deps, includeDisconnected) => Result.ok(aw
21401
21761
  const createXConnectURL = (deps, reconnectProfileId) => connectURLFor(deps, reconnectProfileId);
21402
21762
  const connectXAccount = async (deps) => {
21403
21763
  const beforeResult = await listXLifecycleAccounts(deps, true);
21404
- if (Result.isError(beforeResult)) return Result.err(beforeResult.error);
21764
+ if (G.isError(beforeResult)) return G.err(beforeResult.error);
21405
21765
  const before = beforeResult.value;
21406
21766
  const connectedBefore = new Set(before.filter((account) => account.status === "connected").map(accountKey));
21407
21767
  const lastSeenBefore = new Map(before.filter((account) => account.status === "connected").map((account) => [accountKey(account), timestampMS(account.lastSeenAt)]));
21408
21768
  const prepared = await prepareAccountConnect(deps);
21409
- if (Result.isError(prepared)) return Result.err(prepared.error);
21769
+ if (G.isError(prepared)) return G.err(prepared.error);
21410
21770
  const authURL = await authURLFor(deps, () => connectURLFor(deps));
21411
21771
  await openOrPrint(deps, authURL.url, { log: !authURL.openingLogged });
21412
21772
  const account = await pollForAccount(deps, "connect", (candidate) => {
@@ -21416,8 +21776,8 @@ const connectXAccount = async (deps) => {
21416
21776
  const currentLastSeen = timestampMS(candidate.lastSeenAt);
21417
21777
  return previousLastSeen !== void 0 && currentLastSeen !== void 0 && currentLastSeen > previousLastSeen;
21418
21778
  });
21419
- if (Result.isError(account)) return Result.err(account.error);
21420
- return Result.ok({
21779
+ if (G.isError(account)) return G.err(account.error);
21780
+ return G.ok({
21421
21781
  platform: "x",
21422
21782
  status: "connected",
21423
21783
  account: account.value
@@ -21425,20 +21785,20 @@ const connectXAccount = async (deps) => {
21425
21785
  };
21426
21786
  const reconnectXAccount = async (deps, args) => {
21427
21787
  const selector = parseXAccountSelector(args.account, "reconnect");
21428
- if (Result.isError(selector)) return Result.err(selector.error);
21788
+ if (G.isError(selector)) return G.err(selector.error);
21429
21789
  const accountsResult = await listXLifecycleAccounts(deps, true);
21430
- if (Result.isError(accountsResult)) return Result.err(accountsResult.error);
21790
+ if (G.isError(accountsResult)) return G.err(accountsResult.error);
21431
21791
  const accounts = accountsResult.value;
21432
21792
  const existing = findXLifecycleAccount(accounts, selector.value);
21433
- if (!existing) return Result.err(new XAccountNotFound({
21793
+ if (!existing) return G.err(new XAccountNotFound({
21434
21794
  operation: "reconnect",
21435
21795
  account: args.account
21436
21796
  }));
21437
21797
  const authURL = await authURLFor(deps, () => connectURLFor(deps, existing.profileId));
21438
21798
  await openOrPrint(deps, authURL.url, { log: !authURL.openingLogged });
21439
21799
  const account = await pollForAccount(deps, "reconnect", (candidate) => candidate.profileId === existing.profileId && candidate.status === "connected");
21440
- if (Result.isError(account)) return Result.err(account.error);
21441
- return Result.ok({
21800
+ if (G.isError(account)) return G.err(account.error);
21801
+ return G.ok({
21442
21802
  platform: "x",
21443
21803
  status: "connected",
21444
21804
  account: account.value
@@ -21446,12 +21806,12 @@ const reconnectXAccount = async (deps, args) => {
21446
21806
  };
21447
21807
  const disconnectXAccount = async (deps, target) => {
21448
21808
  const selector = parseXAccountSelector(target, "disconnect");
21449
- if (Result.isError(selector)) return Result.err(selector.error);
21809
+ if (G.isError(selector)) return G.err(selector.error);
21450
21810
  const accountsResult = await listXLifecycleAccounts(deps);
21451
- if (Result.isError(accountsResult)) return Result.err(accountsResult.error);
21811
+ if (G.isError(accountsResult)) return G.err(accountsResult.error);
21452
21812
  const accounts = accountsResult.value;
21453
21813
  const account = findXLifecycleAccount(accounts, selector.value);
21454
- if (!account) return Result.err(new XAccountNotFound({
21814
+ if (!account) return G.err(new XAccountNotFound({
21455
21815
  operation: "disconnect",
21456
21816
  account: target
21457
21817
  }));
@@ -21459,7 +21819,7 @@ const disconnectXAccount = async (deps, target) => {
21459
21819
  platform: "x",
21460
21820
  account: accountSelectorFor$1(account)
21461
21821
  });
21462
- return Result.ok({
21822
+ return G.ok({
21463
21823
  platform: "x",
21464
21824
  account,
21465
21825
  result
@@ -22823,7 +23183,7 @@ function createEnv(opts) {
22823
23183
  }
22824
23184
  //#endregion
22825
23185
  //#region package.json
22826
- var version$1 = "0.11.3";
23186
+ var version$1 = "0.11.5";
22827
23187
  //#endregion
22828
23188
  //#region src/lib/env.ts
22829
23189
  const URLWithTrailingSlash = url().transform(ensureTrailingSlash);
@@ -24062,11 +24422,11 @@ const CLI_SCOPE_ALIASES = ["read", "read,write"];
24062
24422
  `${productBrand.name}`, `${productBrand.name}`;
24063
24423
  const isCLIScopeAlias = (scope) => CLI_SCOPE_ALIASES.some((alias) => alias === scope);
24064
24424
  const parseDeviceScopeAlias = (scope) => {
24065
- if (!isCLIScopeAlias(scope)) return Result.err({
24425
+ if (!isCLIScopeAlias(scope)) return G.err({
24066
24426
  code: "invalid_device_authorization_scope",
24067
24427
  scope
24068
24428
  });
24069
- return Result.ok(scope);
24429
+ return G.ok(scope);
24070
24430
  };
24071
24431
  const parseCLIScopeAlias = parseDeviceScopeAlias;
24072
24432
  const scopeAliasFromAccessChoices$1 = (choices) => choices.includes("write") ? "read,write" : "read";
@@ -29828,7 +30188,7 @@ const accessPhase = async (ctx) => {
29828
30188
  data: { scopeAlias }
29829
30189
  };
29830
30190
  };
29831
- TaggedError("InvalidEmailHint")();
30191
+ h("InvalidEmailHint")();
29832
30192
  const base64URLFromText = (value) => {
29833
30193
  const bytes = new TextEncoder().encode(value);
29834
30194
  let binary = "";
@@ -29988,7 +30348,7 @@ const resolvePhoneNumber = async (ctx) => {
29988
30348
  };
29989
30349
  //#endregion
29990
30350
  //#region src/lib/expected-errors.ts
29991
- var InvalidScope = class extends TaggedError("InvalidScope")() {
30351
+ var InvalidScope = class extends h("InvalidScope")() {
29992
30352
  constructor(scope) {
29993
30353
  super({
29994
30354
  scope,
@@ -29996,7 +30356,7 @@ var InvalidScope = class extends TaggedError("InvalidScope")() {
29996
30356
  });
29997
30357
  }
29998
30358
  };
29999
- var AccountNotFound = class extends TaggedError("AccountNotFound")() {
30359
+ var AccountNotFound = class extends h("AccountNotFound")() {
30000
30360
  constructor({ account, platform }) {
30001
30361
  super({
30002
30362
  account,
@@ -30005,7 +30365,7 @@ var AccountNotFound = class extends TaggedError("AccountNotFound")() {
30005
30365
  });
30006
30366
  }
30007
30367
  };
30008
- var NoConnectedAccount = class extends TaggedError("NoConnectedAccount")() {
30368
+ var NoConnectedAccount = class extends h("NoConnectedAccount")() {
30009
30369
  constructor(platform) {
30010
30370
  super({
30011
30371
  platform,
@@ -30013,7 +30373,7 @@ var NoConnectedAccount = class extends TaggedError("NoConnectedAccount")() {
30013
30373
  });
30014
30374
  }
30015
30375
  };
30016
- var LookupPayloadInvalid = class extends TaggedError("LookupPayloadInvalid")() {
30376
+ var LookupPayloadInvalid = class extends h("LookupPayloadInvalid")() {
30017
30377
  constructor({ input, platform }) {
30018
30378
  super({
30019
30379
  input,
@@ -30022,7 +30382,7 @@ var LookupPayloadInvalid = class extends TaggedError("LookupPayloadInvalid")() {
30022
30382
  });
30023
30383
  }
30024
30384
  };
30025
- var SchemaPathUnknown = class extends TaggedError("SchemaPathUnknown")() {
30385
+ var SchemaPathUnknown = class extends h("SchemaPathUnknown")() {
30026
30386
  constructor({ message, path }) {
30027
30387
  super({
30028
30388
  message,
@@ -30030,7 +30390,7 @@ var SchemaPathUnknown = class extends TaggedError("SchemaPathUnknown")() {
30030
30390
  });
30031
30391
  }
30032
30392
  };
30033
- var SchemaContractInvalid = class extends TaggedError("SchemaContractInvalid")() {
30393
+ var SchemaContractInvalid = class extends h("SchemaContractInvalid")() {
30034
30394
  constructor({ label, message }) {
30035
30395
  super({
30036
30396
  label,
@@ -30038,7 +30398,7 @@ var SchemaContractInvalid = class extends TaggedError("SchemaContractInvalid")()
30038
30398
  });
30039
30399
  }
30040
30400
  };
30041
- var UsagePaginationLimit = class extends TaggedError("UsagePaginationLimit")() {
30401
+ var UsagePaginationLimit = class extends h("UsagePaginationLimit")() {
30042
30402
  constructor(limit) {
30043
30403
  super({
30044
30404
  limit,
@@ -30046,7 +30406,7 @@ var UsagePaginationLimit = class extends TaggedError("UsagePaginationLimit")() {
30046
30406
  });
30047
30407
  }
30048
30408
  };
30049
- var LogoutRevocationFailed = class extends TaggedError("LogoutRevocationFailed")() {
30409
+ var LogoutRevocationFailed = class extends h("LogoutRevocationFailed")() {
30050
30410
  constructor() {
30051
30411
  super({ message: "Could not revoke the server-side session; local credentials were cleared." });
30052
30412
  }
@@ -30055,16 +30415,16 @@ var LogoutRevocationFailed = class extends TaggedError("LogoutRevocationFailed")
30055
30415
  //#region src/login/phases/1.scope.ts
30056
30416
  const DEFAULT_SCOPE_ALIAS = "read,write";
30057
30417
  const parseScopeAliasResult = (value) => {
30058
- if (value === void 0 || value === null || value === "") return Result.ok(DEFAULT_SCOPE_ALIAS);
30059
- if (typeof value !== "string") return Result.err(new InvalidScope(String(value)));
30418
+ if (value === void 0 || value === null || value === "") return G.ok(DEFAULT_SCOPE_ALIAS);
30419
+ if (typeof value !== "string") return G.err(new InvalidScope(String(value)));
30060
30420
  const scope = value === "write" ? DEFAULT_SCOPE_ALIAS : value;
30061
30421
  const parsed = parseCLIScopeAlias(scope);
30062
- if (Result.isError(parsed)) return Result.err(new InvalidScope(scope));
30063
- return Result.ok(parsed.value);
30422
+ if (G.isError(parsed)) return G.err(new InvalidScope(scope));
30423
+ return G.ok(parsed.value);
30064
30424
  };
30065
30425
  const parseScopeAlias = (value) => {
30066
30426
  const parsed = parseScopeAliasResult(value);
30067
- if (Result.isOk(parsed)) return parsed.value;
30427
+ if (G.isOk(parsed)) return parsed.value;
30068
30428
  throw new Error(parsed.error.message);
30069
30429
  };
30070
30430
  const scopePhase = async (ctx) => {
@@ -30557,7 +30917,7 @@ const revokeServerSide = async (accessToken) => {
30557
30917
  return false;
30558
30918
  }
30559
30919
  };
30560
- const logoutRevocationResult = (revoked) => revoked ? Result.ok(null) : Result.err(new LogoutRevocationFailed());
30920
+ const logoutRevocationResult = (revoked) => revoked ? G.ok(null) : G.err(new LogoutRevocationFailed());
30561
30921
  const logoutCommand = defineCommand({
30562
30922
  meta: commandMeta({
30563
30923
  name: "logout",
@@ -30586,7 +30946,7 @@ const logoutCommand = defineCommand({
30586
30946
  const revoked = await revokeServerSide(credentials.accessToken);
30587
30947
  await clearCredentials();
30588
30948
  const revocation = logoutRevocationResult(revoked);
30589
- if (Result.isError(revocation)) throw new Error(revocation.error.message);
30949
+ if (G.isError(revocation)) throw new Error(revocation.error.message);
30590
30950
  analytics.capture("logout");
30591
30951
  analytics.reset();
30592
30952
  }
@@ -30725,7 +31085,7 @@ const fetchUsageLogs = async (client, input) => {
30725
31085
  let nextCursor = null;
30726
31086
  let pages = 0;
30727
31087
  do {
30728
- if (pages >= USAGE_LOG_MAX_AUTO_PAGES) return Result.err(new UsagePaginationLimit(USAGE_LOG_MAX_AUTO_PAGES));
31088
+ if (pages >= USAGE_LOG_MAX_AUTO_PAGES) return G.err(new UsagePaginationLimit(USAGE_LOG_MAX_AUTO_PAGES));
30729
31089
  const remaining = input.limit === void 0 ? USAGE_LOG_PAGE_LIMIT : input.limit - items.length;
30730
31090
  const usage = await client.usage.list({
30731
31091
  platform: input.platform,
@@ -30739,7 +31099,7 @@ const fetchUsageLogs = async (client, input) => {
30739
31099
  cursor = nextCursor ?? void 0;
30740
31100
  pages += 1;
30741
31101
  } while (nextCursor && (input.limit === void 0 || items.length < input.limit));
30742
- return Result.ok({
31102
+ return G.ok({
30743
31103
  items: input.limit === void 0 ? items : items.slice(0, input.limit),
30744
31104
  cursor: nextCursor
30745
31105
  });
@@ -30807,7 +31167,7 @@ const createUsageLogsCommand = (deps = {}) => defineCommand({
30807
31167
  from,
30808
31168
  to
30809
31169
  });
30810
- if (Result.isError(usage)) throw new UsageError(usage.error.message);
31170
+ if (G.isError(usage)) throw new UsageError(usage.error.message);
30811
31171
  await writeOutput$1(deps, {
30812
31172
  items: aggregateLogs(usage.value.items, sumBy),
30813
31173
  meta: {
@@ -30825,7 +31185,7 @@ const createUsageLogsCommand = (deps = {}) => defineCommand({
30825
31185
  from,
30826
31186
  to
30827
31187
  });
30828
- if (Result.isError(usage)) throw new UsageError(usage.error.message);
31188
+ if (G.isError(usage)) throw new UsageError(usage.error.message);
30829
31189
  await writeOutput$1(deps, {
30830
31190
  items: usage.value.items,
30831
31191
  meta: { cursor: usage.value.cursor }
@@ -31064,14 +31424,14 @@ const createAccountCommand = (deps) => {
31064
31424
  if (isInteractiveConnect(deps)) {
31065
31425
  await runConnectOutput(deps, async (connectDeps) => {
31066
31426
  const result = await connectXAccount(connectDeps);
31067
- if (Result.isError(result)) throwXLifecycleError(result.error);
31427
+ if (G.isError(result)) throwXLifecycleError(result.error);
31068
31428
  return result.value;
31069
31429
  });
31070
31430
  return;
31071
31431
  }
31072
31432
  await runConnectStep(deps, "x", async () => {
31073
31433
  const result = await listXLifecycleAccounts(deps, true);
31074
- if (Result.isError(result)) throwXLifecycleError(result.error);
31434
+ if (G.isError(result)) throwXLifecycleError(result.error);
31075
31435
  return result.value;
31076
31436
  }, () => createXConnectURL(deps));
31077
31437
  })
@@ -31089,7 +31449,7 @@ const createAccountCommand = (deps) => {
31089
31449
  x: createAccountPlatformCommand("x", "Reconnect an X account.", async (args) => {
31090
31450
  await runConnectOutput(deps, async (connectDeps) => {
31091
31451
  const result = await reconnectXAccount(connectDeps, { account: String(args.account) });
31092
- if (Result.isError(result)) throwXLifecycleError(result.error);
31452
+ if (G.isError(result)) throwXLifecycleError(result.error);
31093
31453
  return result.value;
31094
31454
  });
31095
31455
  }, { accountArg: xAccountArg })
@@ -31114,7 +31474,7 @@ const createAccountCommand = (deps) => {
31114
31474
  }) }),
31115
31475
  x: createAccountPlatformCommand("x", "Disconnect an X account.", async (args) => {
31116
31476
  const result = await disconnectXAccount(deps, String(args.account));
31117
- if (Result.isError(result)) throwXLifecycleError(result.error);
31477
+ if (G.isError(result)) throwXLifecycleError(result.error);
31118
31478
  await writeOutput(deps, result.value);
31119
31479
  }, {
31120
31480
  accountArg: xAccountArg,
@@ -31197,7 +31557,8 @@ const createSubmitCommand = (deps, type) => {
31197
31557
  name: type,
31198
31558
  description: `Submit a ${noun} [write] | usage: \`echo "..." | ${label}\``,
31199
31559
  capability: "write",
31200
- contract: submitContract
31560
+ contract: submitContract,
31561
+ stdin: true
31201
31562
  }),
31202
31563
  run: async () => {
31203
31564
  const text = await readPipedText(deps, label);
@@ -31257,12 +31618,12 @@ const selectAccountOutcome = ({ accounts, defaultAccount, explicitAccount }) =>
31257
31618
  };
31258
31619
  };
31259
31620
  const requireSelectedAccount = (outcome, platform) => {
31260
- if (outcome.status === "selected") return Result.ok(outcome);
31261
- if (outcome.status === "missingExplicitAccount") return Result.err(new AccountNotFound({
31621
+ if (outcome.status === "selected") return G.ok(outcome);
31622
+ if (outcome.status === "missingExplicitAccount") return G.err(new AccountNotFound({
31262
31623
  account: outcome.account,
31263
31624
  platform
31264
31625
  }));
31265
- return Result.err(new NoConnectedAccount(platform));
31626
+ return G.err(new NoConnectedAccount(platform));
31266
31627
  };
31267
31628
  const isRecord$1 = (value) => Boolean(value && typeof value === "object" && !Array.isArray(value));
31268
31629
  const stringField = (value, key) => {
@@ -31275,35 +31636,35 @@ const stringOrNumberField = (value, key) => {
31275
31636
  return typeof field === "number" && Number.isFinite(field) ? String(field) : void 0;
31276
31637
  };
31277
31638
  const parseXLookupResponse = (data, input) => {
31278
- if (!(isRecord$1(data) && isRecord$1(data.data))) return Result.err(new LookupPayloadInvalid({
31639
+ if (!(isRecord$1(data) && isRecord$1(data.data))) return G.err(new LookupPayloadInvalid({
31279
31640
  input,
31280
31641
  platform: "x"
31281
31642
  }));
31282
31643
  const id = stringOrNumberField(data.data, "id");
31283
- if (!id) return Result.err(new LookupPayloadInvalid({
31644
+ if (!id) return G.err(new LookupPayloadInvalid({
31284
31645
  input,
31285
31646
  platform: "x"
31286
31647
  }));
31287
31648
  const inputUsername = input.replace(/^@+/, "");
31288
31649
  const resolvedUsername = stringField(data.data, "username") ?? inputUsername;
31289
- return Result.ok({
31650
+ return G.ok({
31290
31651
  id,
31291
31652
  url: `https://x.com/${resolvedUsername}`
31292
31653
  });
31293
31654
  };
31294
31655
  const parseLinkedinProfileLookupResponse = (data, input) => {
31295
31656
  const profile = isRecord$1(data) && isRecord$1(data.data) ? data.data : data;
31296
- if (!isRecord$1(profile)) return Result.err(new LookupPayloadInvalid({
31657
+ if (!isRecord$1(profile)) return G.err(new LookupPayloadInvalid({
31297
31658
  input,
31298
31659
  platform: "linkedin"
31299
31660
  }));
31300
31661
  const id = stringOrNumberField(profile, "provider_id") ?? stringOrNumberField(profile, "providerId") ?? stringOrNumberField(profile, "id");
31301
- if (!id) return Result.err(new LookupPayloadInvalid({
31662
+ if (!id) return G.err(new LookupPayloadInvalid({
31302
31663
  input,
31303
31664
  platform: "linkedin"
31304
31665
  }));
31305
31666
  const publicIdentifier = stringField(profile, "public_identifier") ?? stringField(profile, "publicIdentifier");
31306
- return Result.ok({
31667
+ return G.ok({
31307
31668
  id,
31308
31669
  ...publicIdentifier ? { url: `https://www.linkedin.com/in/${encodeURIComponent(publicIdentifier)}` } : {}
31309
31670
  });
@@ -31321,7 +31682,7 @@ const headerValuesFromRawArgs = (rawArgs = []) => {
31321
31682
  if (arg === "--") break;
31322
31683
  if (arg === "--header" || arg === "-H") {
31323
31684
  const value = rawArgs[index + 1];
31324
- if (value === void 0) return Result.err(headerError("missingHeaderValue", `Pass a value for ${arg}.`));
31685
+ if (value === void 0) return G.err(headerError("missingHeaderValue", `Pass a value for ${arg}.`));
31325
31686
  values.push(value);
31326
31687
  index += 1;
31327
31688
  continue;
@@ -31332,25 +31693,25 @@ const headerValuesFromRawArgs = (rawArgs = []) => {
31332
31693
  }
31333
31694
  if (arg?.startsWith("-H=")) values.push(arg.slice(3));
31334
31695
  }
31335
- return Result.ok(values);
31696
+ return G.ok(values);
31336
31697
  };
31337
31698
  const commandHeaderValuesFrom = ({ headers, rawArgs }) => {
31338
31699
  const rawValues = headerValuesFromRawArgs(rawArgs);
31339
- if (Result.isError(rawValues)) return rawValues;
31700
+ if (G.isError(rawValues)) return rawValues;
31340
31701
  if (rawValues.value.length > 0) return rawValues;
31341
- if (headers === void 0) return Result.ok([]);
31342
- if (typeof headers === "string") return Result.ok([headers]);
31343
- if (Array.isArray(headers) && headers.every((header) => typeof header === "string")) return Result.ok(headers);
31344
- return Result.err(headerError("invalidHeaderList", "Pass --header as Name: value."));
31702
+ if (headers === void 0) return G.ok([]);
31703
+ if (typeof headers === "string") return G.ok([headers]);
31704
+ if (Array.isArray(headers) && headers.every((header) => typeof header === "string")) return G.ok(headers);
31705
+ return G.err(headerError("invalidHeaderList", "Pass --header as Name: value."));
31345
31706
  };
31346
31707
  const parsedHeaderFrom = (header) => {
31347
31708
  const colon = header.indexOf(":");
31348
- if (colon <= 0) return Result.err(headerError("malformedHeader", "Pass --header as Name: value."));
31709
+ if (colon <= 0) return G.err(headerError("malformedHeader", "Pass --header as Name: value."));
31349
31710
  const name = header.slice(0, colon).trim();
31350
31711
  const value = header.slice(colon + 1).trim();
31351
31712
  const normalized = name.toLowerCase();
31352
- if (normalized === "authorization" || normalized === "content-type" || normalized.startsWith("x-social-")) return Result.err(headerError("reservedHeader", `Header ${name} is reserved and cannot be set with --header.`));
31353
- return Result.ok({
31713
+ if (normalized === "authorization" || normalized === "content-type" || normalized.startsWith("x-social-")) return G.err(headerError("reservedHeader", `Header ${name} is reserved and cannot be set with --header.`));
31714
+ return G.ok({
31354
31715
  name,
31355
31716
  value
31356
31717
  });
@@ -31358,17 +31719,17 @@ const parsedHeaderFrom = (header) => {
31358
31719
  const commandHeadersFrom = (defaults, args = {}) => {
31359
31720
  const headers = new Headers(defaults);
31360
31721
  const rawHeaders = commandHeaderValuesFrom(args);
31361
- if (Result.isError(rawHeaders)) return Result.err(rawHeaders.error);
31722
+ if (G.isError(rawHeaders)) return G.err(rawHeaders.error);
31362
31723
  for (const rawHeader of rawHeaders.value) {
31363
31724
  const parsed = parsedHeaderFrom(rawHeader);
31364
- if (Result.isError(parsed)) return Result.err(parsed.error);
31725
+ if (G.isError(parsed)) return G.err(parsed.error);
31365
31726
  try {
31366
31727
  headers.set(parsed.value.name, parsed.value.value);
31367
31728
  } catch {
31368
- return Result.err(headerError("invalidHeader", `Invalid header ${parsed.value.name}.`));
31729
+ return G.err(headerError("invalidHeader", `Invalid header ${parsed.value.name}.`));
31369
31730
  }
31370
31731
  }
31371
- return Result.ok(Object.fromEntries(headers.entries()));
31732
+ return G.ok(Object.fromEntries(headers.entries()));
31372
31733
  };
31373
31734
  //#endregion
31374
31735
  //#region ../../node_modules/.bun/@borewit+text-codec@0.2.2/node_modules/@borewit/text-codec/lib/index.js
@@ -36305,7 +36666,7 @@ const createCLIDeps = () => {
36305
36666
  platform
36306
36667
  });
36307
36668
  const selected = requireSelectedAccount(outcome, platform);
36308
- if (Result.isOk(selected)) return selected.value;
36669
+ if (G.isOk(selected)) return selected.value;
36309
36670
  if (outcome.status === "missingExplicitAccount") throw new NotFoundError(`${platform}_account_not_found`);
36310
36671
  throw new Error(`${platform}_account_not_connected`);
36311
36672
  };
@@ -36320,7 +36681,7 @@ const createCLIDeps = () => {
36320
36681
  ...selectedAccount.selector === void 0 ? {} : { "x-social-account-id": selectedAccount.selector }
36321
36682
  };
36322
36683
  const parsed = parseXLookupResponse(await api.get(`x/users/by/username/${encodeURIComponent(inputUsername)}`, { headers }).json(), input);
36323
- if (Result.isError(parsed)) throw new Error(`Could not resolve X username ${input}.`);
36684
+ if (G.isError(parsed)) throw new Error(`Could not resolve X username ${input}.`);
36324
36685
  return parsed.value;
36325
36686
  };
36326
36687
  const lookupLinkedinProfile = async (input, account, selectedAccount) => {
@@ -36333,7 +36694,7 @@ const createCLIDeps = () => {
36333
36694
  ...resolvedAccount.selector === void 0 ? {} : { "x-social-account-id": resolvedAccount.selector }
36334
36695
  };
36335
36696
  const parsed = parseLinkedinProfileLookupResponse(await api.get(`linkedin/users/${encodeURIComponent(input)}`, { headers }).json(), input);
36336
- if (Result.isError(parsed)) throw new Error(`Could not resolve LinkedIn profile ${input}.`);
36697
+ if (G.isError(parsed)) throw new Error(`Could not resolve LinkedIn profile ${input}.`);
36337
36698
  return parsed.value;
36338
36699
  };
36339
36700
  return {
@@ -36392,7 +36753,7 @@ const createCLIDeps = () => {
36392
36753
  }),
36393
36754
  commandHeaders: async (args) => {
36394
36755
  const headers = commandHeadersFrom({ "Cache-Control": await cacheControlHeaderFromConfig() }, args);
36395
- if (Result.isError(headers)) throw new UsageError(headers.error.message);
36756
+ if (G.isError(headers)) throw new UsageError(headers.error.message);
36396
36757
  return headers.value;
36397
36758
  },
36398
36759
  printData,
@@ -36827,7 +37188,7 @@ const schemaAtPath = (command, commandPathInput, options = {}) => {
36827
37188
  command,
36828
37189
  path: []
36829
37190
  } : commandAtPath(command, parts);
36830
- return Result.ok({
37191
+ return G.ok({
36831
37192
  schemaVersion: "2.0",
36832
37193
  commands: Object.fromEntries(leafSchemasForCommand(selectedCommand, path))
36833
37194
  });
@@ -36837,31 +37198,31 @@ const schemaAtPath = (command, commandPathInput, options = {}) => {
36837
37198
  command,
36838
37199
  path: []
36839
37200
  } : commandAtPath(command, parts);
36840
- return Result.ok({
37201
+ return G.ok({
36841
37202
  schemaVersion: "2.0",
36842
37203
  commands: Object.fromEntries(compactLeafSchemasForCommand(selectedCommand, path))
36843
37204
  });
36844
37205
  }
36845
- if (parts.length === 0) return Result.ok({
37206
+ if (parts.length === 0) return G.ok({
36846
37207
  schemaVersion: "2.0",
36847
37208
  ...schemaTreeForCommand(command)
36848
37209
  });
36849
37210
  const { command: selectedCommand, path, positionalMatch } = commandAtPath(command, parts);
36850
- if (positionalMatch) return Result.ok({
37211
+ if (positionalMatch) return G.ok({
36851
37212
  schemaVersion: "2.0",
36852
37213
  ...schemaForCommand(selectedCommand, path),
36853
37214
  ...positionalMatch
36854
37215
  });
36855
- if (selectedCommand.subCommands && typeof selectedCommand.run !== "function") return Result.ok({
37216
+ if (selectedCommand.subCommands && typeof selectedCommand.run !== "function") return G.ok({
36856
37217
  schemaVersion: "2.0",
36857
37218
  ...schemaTreeForCommand(selectedCommand, path)
36858
37219
  });
36859
- return Result.ok({
37220
+ return G.ok({
36860
37221
  schemaVersion: "2.0",
36861
37222
  ...schemaForCommand(selectedCommand, path)
36862
37223
  });
36863
37224
  } catch (error) {
36864
- return Result.err(schemaErrorFor(error, parts));
37225
+ return G.err(schemaErrorFor(error, parts));
36865
37226
  }
36866
37227
  };
36867
37228
  const schemaCommand = defineCommand({
@@ -36896,7 +37257,7 @@ const schemaCommand = defineCommand({
36896
37257
  if (!rootCommand) throw new Error("schema_root_command_unconfigured");
36897
37258
  const commandPathInput = Array.isArray(args._) && args._.length > 1 ? args._ : args.commandPath;
36898
37259
  const schema = schemaAtPath(rootCommand, commandPathInput, { mode: args.leaves === true ? "leaves" : args.list === true ? "list" : "leaf" });
36899
- if (Result.isError(schema)) throw new Error(schema.error.message);
37260
+ if (G.isError(schema)) throw new Error(schema.error.message);
36900
37261
  printData(schema.value);
36901
37262
  }
36902
37263
  });