@usesocial/cli 0.11.4 → 0.11.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +12 -0
- package/README.md +3 -3
- package/dist/index.mjs +698 -439
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
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";
|
|
@@ -16,7 +15,6 @@ import l__default, { createInterface } from "node:readline";
|
|
|
16
15
|
import { AsyncLocalStorage } from "node:async_hooks";
|
|
17
16
|
import process$1, { stdin, stdout } from "node:process";
|
|
18
17
|
import { ReadStream } from "node:tty";
|
|
19
|
-
import { spawn } from "node:child_process";
|
|
20
18
|
//#region \0rolldown/runtime.js
|
|
21
19
|
var __create = Object.create;
|
|
22
20
|
var __defProp = Object.defineProperty;
|
|
@@ -41,6 +39,367 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
41
39
|
}) : target, mod));
|
|
42
40
|
var __require = /* @__PURE__ */ createRequire(import.meta.url);
|
|
43
41
|
//#endregion
|
|
42
|
+
//#region ../../node_modules/.bun/better-result@2.9.2/node_modules/better-result/dist/index.mjs
|
|
43
|
+
function e(e, t) {
|
|
44
|
+
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));
|
|
45
|
+
}
|
|
46
|
+
const t = (e) => e instanceof Error ? {
|
|
47
|
+
name: e.name,
|
|
48
|
+
message: e.message,
|
|
49
|
+
stack: e.stack
|
|
50
|
+
} : e;
|
|
51
|
+
var n$1 = class e extends Error {
|
|
52
|
+
_tag = `Panic`;
|
|
53
|
+
static is(t) {
|
|
54
|
+
return t instanceof e;
|
|
55
|
+
}
|
|
56
|
+
constructor(e) {
|
|
57
|
+
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) {
|
|
58
|
+
let t = e.cause.stack.replace(/\n/g, `
|
|
59
|
+
`);
|
|
60
|
+
this.stack = `${this.stack}\nCaused by: ${t}`;
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
toJSON() {
|
|
64
|
+
return {
|
|
65
|
+
...this,
|
|
66
|
+
_tag: this._tag,
|
|
67
|
+
name: this.name,
|
|
68
|
+
message: this.message,
|
|
69
|
+
cause: t(this.cause),
|
|
70
|
+
stack: this.stack
|
|
71
|
+
};
|
|
72
|
+
}
|
|
73
|
+
*[Symbol.iterator]() {
|
|
74
|
+
return yield* d$1(this), i$1(`Unreachable: Err yielded in Panic but generator continued`, this);
|
|
75
|
+
}
|
|
76
|
+
};
|
|
77
|
+
const i$1 = (e, t) => {
|
|
78
|
+
throw new n$1({
|
|
79
|
+
message: e,
|
|
80
|
+
cause: t
|
|
81
|
+
});
|
|
82
|
+
}, a = (e, t) => {
|
|
83
|
+
try {
|
|
84
|
+
return e();
|
|
85
|
+
} catch (e) {
|
|
86
|
+
throw i$1(t, e);
|
|
87
|
+
}
|
|
88
|
+
}, o = async (e, t) => {
|
|
89
|
+
try {
|
|
90
|
+
return await e();
|
|
91
|
+
} catch (e) {
|
|
92
|
+
throw i$1(t, e);
|
|
93
|
+
}
|
|
94
|
+
};
|
|
95
|
+
var s = class e {
|
|
96
|
+
status = `ok`;
|
|
97
|
+
constructor(e) {
|
|
98
|
+
this.value = e;
|
|
99
|
+
}
|
|
100
|
+
isOk() {
|
|
101
|
+
return !0;
|
|
102
|
+
}
|
|
103
|
+
isErr() {
|
|
104
|
+
return !1;
|
|
105
|
+
}
|
|
106
|
+
map(t) {
|
|
107
|
+
return a(() => new e(t(this.value)), `map callback threw`);
|
|
108
|
+
}
|
|
109
|
+
mapError(e) {
|
|
110
|
+
return this;
|
|
111
|
+
}
|
|
112
|
+
tryRecover(e) {
|
|
113
|
+
return this;
|
|
114
|
+
}
|
|
115
|
+
tryRecoverAsync(e) {
|
|
116
|
+
return Promise.resolve(this);
|
|
117
|
+
}
|
|
118
|
+
andThen(e) {
|
|
119
|
+
return a(() => e(this.value), `andThen callback threw`);
|
|
120
|
+
}
|
|
121
|
+
andThenAsync(e) {
|
|
122
|
+
return o(() => e(this.value), `andThenAsync callback threw`);
|
|
123
|
+
}
|
|
124
|
+
match(e) {
|
|
125
|
+
return a(() => e.ok(this.value), `match ok handler threw`);
|
|
126
|
+
}
|
|
127
|
+
unwrap(e) {
|
|
128
|
+
return this.value;
|
|
129
|
+
}
|
|
130
|
+
unwrapOr(e) {
|
|
131
|
+
return this.value;
|
|
132
|
+
}
|
|
133
|
+
tap(e) {
|
|
134
|
+
return a(() => (e(this.value), this), `tap callback threw`);
|
|
135
|
+
}
|
|
136
|
+
tapAsync(e) {
|
|
137
|
+
return o(async () => (await e(this.value), this), `tapAsync callback threw`);
|
|
138
|
+
}
|
|
139
|
+
tapError(e) {
|
|
140
|
+
return this;
|
|
141
|
+
}
|
|
142
|
+
tapErrorAsync(e) {
|
|
143
|
+
return Promise.resolve(this);
|
|
144
|
+
}
|
|
145
|
+
tapBoth(e) {
|
|
146
|
+
return a(() => (e.ok(this.value), this), `tapBoth ok callback threw`);
|
|
147
|
+
}
|
|
148
|
+
tapBothAsync(e) {
|
|
149
|
+
return o(async () => (await e.ok(this.value), this), `tapBothAsync ok callback threw`);
|
|
150
|
+
}
|
|
151
|
+
*[Symbol.iterator]() {
|
|
152
|
+
return this.value;
|
|
153
|
+
}
|
|
154
|
+
}, c = class e {
|
|
155
|
+
status = `error`;
|
|
156
|
+
constructor(e) {
|
|
157
|
+
this.error = e;
|
|
158
|
+
}
|
|
159
|
+
isOk() {
|
|
160
|
+
return !1;
|
|
161
|
+
}
|
|
162
|
+
isErr() {
|
|
163
|
+
return !0;
|
|
164
|
+
}
|
|
165
|
+
map(e) {
|
|
166
|
+
return this;
|
|
167
|
+
}
|
|
168
|
+
mapError(t) {
|
|
169
|
+
return a(() => new e(t(this.error)), `mapError callback threw`);
|
|
170
|
+
}
|
|
171
|
+
tryRecover(e) {
|
|
172
|
+
return a(() => e(this.error), `tryRecover callback threw`);
|
|
173
|
+
}
|
|
174
|
+
tryRecoverAsync(e) {
|
|
175
|
+
return o(() => e(this.error), `tryRecoverAsync callback threw`);
|
|
176
|
+
}
|
|
177
|
+
andThen(e) {
|
|
178
|
+
return this;
|
|
179
|
+
}
|
|
180
|
+
andThenAsync(e) {
|
|
181
|
+
return Promise.resolve(this);
|
|
182
|
+
}
|
|
183
|
+
match(e) {
|
|
184
|
+
return a(() => e.err(this.error), `match err handler threw`);
|
|
185
|
+
}
|
|
186
|
+
unwrap(e) {
|
|
187
|
+
return i$1(e ?? `Unwrap called on Err: ${String(this.error)}`, this.error);
|
|
188
|
+
}
|
|
189
|
+
unwrapOr(e) {
|
|
190
|
+
return e;
|
|
191
|
+
}
|
|
192
|
+
tap(e) {
|
|
193
|
+
return this;
|
|
194
|
+
}
|
|
195
|
+
tapError(e) {
|
|
196
|
+
return a(() => (e(this.error), this), `tapError callback threw`);
|
|
197
|
+
}
|
|
198
|
+
tapAsync(e) {
|
|
199
|
+
return Promise.resolve(this);
|
|
200
|
+
}
|
|
201
|
+
tapErrorAsync(e) {
|
|
202
|
+
return o(async () => (await e(this.error), this), `tapErrorAsync callback threw`);
|
|
203
|
+
}
|
|
204
|
+
tapBoth(e) {
|
|
205
|
+
return a(() => (e.err(this.error), this), `tapBoth err callback threw`);
|
|
206
|
+
}
|
|
207
|
+
tapBothAsync(e) {
|
|
208
|
+
return o(async () => (await e.err(this.error), this), `tapBothAsync err callback threw`);
|
|
209
|
+
}
|
|
210
|
+
*[Symbol.iterator]() {
|
|
211
|
+
return yield this, i$1(`Unreachable: Err yielded in Result.gen but generator continued`, this.error);
|
|
212
|
+
}
|
|
213
|
+
};
|
|
214
|
+
function l$1(e) {
|
|
215
|
+
return new s(e);
|
|
216
|
+
}
|
|
217
|
+
const u$1 = (e) => e.status === `ok`, d$1 = (e) => new c(e), f = (e) => e.status === `error`, p = (e) => e instanceof Error ? {
|
|
218
|
+
name: e.name,
|
|
219
|
+
message: e.message,
|
|
220
|
+
stack: e.stack
|
|
221
|
+
} : e, m = (e) => e instanceof Error && `_tag` in e && typeof e._tag == `string`, h = Object.assign((e) => () => {
|
|
222
|
+
class t extends Error {
|
|
223
|
+
_tag = e;
|
|
224
|
+
static is(e) {
|
|
225
|
+
return e instanceof t;
|
|
226
|
+
}
|
|
227
|
+
constructor(t) {
|
|
228
|
+
let n = t && `message` in t && typeof t.message == `string` ? t.message : void 0, r = t && `cause` in t ? t.cause : void 0;
|
|
229
|
+
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) {
|
|
230
|
+
let e = r.stack.replace(/\n/g, `
|
|
231
|
+
`);
|
|
232
|
+
this.stack = `${this.stack}\nCaused by: ${e}`;
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
toJSON() {
|
|
236
|
+
return {
|
|
237
|
+
...this,
|
|
238
|
+
_tag: this._tag,
|
|
239
|
+
name: this.name,
|
|
240
|
+
message: this.message,
|
|
241
|
+
cause: p(this.cause),
|
|
242
|
+
stack: this.stack
|
|
243
|
+
};
|
|
244
|
+
}
|
|
245
|
+
*[Symbol.iterator]() {
|
|
246
|
+
return yield* d$1(this), i$1(`Unreachable: Err yielded in TaggedError but generator continued`, this);
|
|
247
|
+
}
|
|
248
|
+
}
|
|
249
|
+
return t;
|
|
250
|
+
}, { is: m });
|
|
251
|
+
var y = class extends h(`UnhandledException`)() {
|
|
252
|
+
constructor(e) {
|
|
253
|
+
let t = e.cause instanceof Error ? `Unhandled exception: ${e.cause.message}` : `Unhandled exception: ${String(e.cause)}`;
|
|
254
|
+
super({
|
|
255
|
+
message: t,
|
|
256
|
+
cause: e.cause
|
|
257
|
+
});
|
|
258
|
+
}
|
|
259
|
+
}, b = class extends h(`ResultDeserializationError`)() {
|
|
260
|
+
constructor(e) {
|
|
261
|
+
super({
|
|
262
|
+
message: `Failed to deserialize value as Result: expected { status: "ok", value } or { status: "error", error }`,
|
|
263
|
+
value: e.value
|
|
264
|
+
});
|
|
265
|
+
}
|
|
266
|
+
};
|
|
267
|
+
const x = (e, t) => {
|
|
268
|
+
try {
|
|
269
|
+
return e();
|
|
270
|
+
} catch (e) {
|
|
271
|
+
throw i$1(t, e);
|
|
272
|
+
}
|
|
273
|
+
}, S = (e, t) => {
|
|
274
|
+
let n = () => {
|
|
275
|
+
if (typeof e == `function`) try {
|
|
276
|
+
return l$1(e());
|
|
277
|
+
} catch (e) {
|
|
278
|
+
return d$1(new y({ cause: e }));
|
|
279
|
+
}
|
|
280
|
+
try {
|
|
281
|
+
return l$1(e.try());
|
|
282
|
+
} catch (t) {
|
|
283
|
+
try {
|
|
284
|
+
return d$1(e.catch(t));
|
|
285
|
+
} catch (e) {
|
|
286
|
+
throw i$1(`Result.try catch handler threw`, e);
|
|
287
|
+
}
|
|
288
|
+
}
|
|
289
|
+
}, r = t?.retry?.times ?? 0, a = n();
|
|
290
|
+
for (let e = 0; e < r && a.status === `error`; e++) a = n();
|
|
291
|
+
return a;
|
|
292
|
+
}, C$1 = async (e, t) => {
|
|
293
|
+
let n = async () => {
|
|
294
|
+
if (typeof e == `function`) try {
|
|
295
|
+
return l$1(await e());
|
|
296
|
+
} catch (e) {
|
|
297
|
+
return d$1(new y({ cause: e }));
|
|
298
|
+
}
|
|
299
|
+
try {
|
|
300
|
+
return l$1(await e.try());
|
|
301
|
+
} catch (t) {
|
|
302
|
+
try {
|
|
303
|
+
return d$1(await e.catch(t));
|
|
304
|
+
} catch (e) {
|
|
305
|
+
throw i$1(`Result.tryPromise catch handler threw`, e);
|
|
306
|
+
}
|
|
307
|
+
}
|
|
308
|
+
}, r = t?.retry;
|
|
309
|
+
if (!r) return n();
|
|
310
|
+
let a = (e) => {
|
|
311
|
+
switch (r.backoff) {
|
|
312
|
+
case `constant`: return r.delayMs;
|
|
313
|
+
case `linear`: return r.delayMs * (e + 1);
|
|
314
|
+
case `exponential`: return r.delayMs * 2 ** e;
|
|
315
|
+
}
|
|
316
|
+
}, o = (e) => new Promise((t) => setTimeout(t, e)), s = await n(), c = r.shouldRetry ?? (() => !0);
|
|
317
|
+
for (let e = 0; e < r.times && s.status === `error`; e++) {
|
|
318
|
+
let t = s.error;
|
|
319
|
+
if (!x(() => c(t), `shouldRetry predicate threw`)) break;
|
|
320
|
+
await o(a(e)), s = await n();
|
|
321
|
+
}
|
|
322
|
+
return s;
|
|
323
|
+
}, 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);
|
|
324
|
+
function R$1(e) {
|
|
325
|
+
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)));
|
|
326
|
+
}
|
|
327
|
+
const z = e(2, (e, t) => e.unwrapOr(t)), B = ((e, t) => {
|
|
328
|
+
let n = e.call(t);
|
|
329
|
+
if (Symbol.asyncIterator in n) return (async () => {
|
|
330
|
+
let e = n, t;
|
|
331
|
+
try {
|
|
332
|
+
t = await e.next();
|
|
333
|
+
} catch (e) {
|
|
334
|
+
throw i$1(`generator body threw`, e);
|
|
335
|
+
}
|
|
336
|
+
if (R$1(t.value), !t.done) try {
|
|
337
|
+
await e.return?.(void 0);
|
|
338
|
+
} catch (e) {
|
|
339
|
+
throw i$1(`generator cleanup threw`, e);
|
|
340
|
+
}
|
|
341
|
+
return t.value;
|
|
342
|
+
})();
|
|
343
|
+
let r = n, a;
|
|
344
|
+
try {
|
|
345
|
+
a = r.next();
|
|
346
|
+
} catch (e) {
|
|
347
|
+
throw i$1(`generator body threw`, e);
|
|
348
|
+
}
|
|
349
|
+
if (R$1(a.value), !a.done) try {
|
|
350
|
+
r.return?.(void 0);
|
|
351
|
+
} catch (e) {
|
|
352
|
+
throw i$1(`generator cleanup threw`, e);
|
|
353
|
+
}
|
|
354
|
+
return a.value;
|
|
355
|
+
});
|
|
356
|
+
async function* V$1(e) {
|
|
357
|
+
return yield* await e;
|
|
358
|
+
}
|
|
359
|
+
function H(e) {
|
|
360
|
+
return typeof e == `object` && !!e && `status` in e && (e.status === `ok` && `value` in e || e.status === `error` && `error` in e);
|
|
361
|
+
}
|
|
362
|
+
const U = (e) => e.status === `ok` ? {
|
|
363
|
+
status: `ok`,
|
|
364
|
+
value: e.value
|
|
365
|
+
} : {
|
|
366
|
+
status: `error`,
|
|
367
|
+
error: e.error
|
|
368
|
+
}, W$2 = (e) => H(e) ? e.status === `ok` ? new s(e.value) : new c(e.error) : d$1(new b({ value: e })), G = {
|
|
369
|
+
ok: l$1,
|
|
370
|
+
isOk: u$1,
|
|
371
|
+
err: d$1,
|
|
372
|
+
isError: f,
|
|
373
|
+
try: S,
|
|
374
|
+
tryPromise: C$1,
|
|
375
|
+
map: w,
|
|
376
|
+
mapError: T,
|
|
377
|
+
tryRecover: E,
|
|
378
|
+
andThen: D,
|
|
379
|
+
tryRecoverAsync: O,
|
|
380
|
+
andThenAsync: k,
|
|
381
|
+
match: A,
|
|
382
|
+
tap: j,
|
|
383
|
+
tapAsync: M,
|
|
384
|
+
tapError: N,
|
|
385
|
+
tapErrorAsync: P,
|
|
386
|
+
tapBoth: F,
|
|
387
|
+
tapBothAsync: I,
|
|
388
|
+
unwrap: L,
|
|
389
|
+
unwrapOr: z,
|
|
390
|
+
gen: B,
|
|
391
|
+
await: V$1,
|
|
392
|
+
serialize: U,
|
|
393
|
+
deserialize: W$2,
|
|
394
|
+
hydrate: (e) => W$2(e),
|
|
395
|
+
partition: (e) => {
|
|
396
|
+
let t = [], n = [];
|
|
397
|
+
for (let r of e) r.status === `ok` ? t.push(r.value) : n.push(r.error);
|
|
398
|
+
return [t, n];
|
|
399
|
+
},
|
|
400
|
+
flatten: (e) => e.status === `ok` ? e.value : e
|
|
401
|
+
};
|
|
402
|
+
//#endregion
|
|
44
403
|
//#region ../../packages/constants/src/index.ts
|
|
45
404
|
const org = "usesocial";
|
|
46
405
|
const cliPackageName = `@${org}/cli`;
|
|
@@ -88,8 +447,8 @@ const cliBrand = {
|
|
|
88
447
|
skill: skillInstallCommand
|
|
89
448
|
}
|
|
90
449
|
};
|
|
91
|
-
|
|
92
|
-
|
|
450
|
+
h("InvalidPublicBaseURL")();
|
|
451
|
+
h("InvalidPublicRoute")();
|
|
93
452
|
const publicURLForLiteral = (route) => new URL(route, brandURLs.publicWebURL).toString();
|
|
94
453
|
const publicRouteURLs = {
|
|
95
454
|
pricing: publicURLForLiteral(publicLinks.pricing),
|
|
@@ -222,7 +581,7 @@ function kebabCase$1(str) {
|
|
|
222
581
|
const flagName = (name) => kebabCase$1(name.replace(/[._]/g, "-"));
|
|
223
582
|
//#endregion
|
|
224
583
|
//#region ../../packages/codegen/src/runtime/index.ts
|
|
225
|
-
var RuntimeUsageProblem = class extends
|
|
584
|
+
var RuntimeUsageProblem = class extends h("RuntimeUsageProblem")() {
|
|
226
585
|
constructor(input) {
|
|
227
586
|
super({
|
|
228
587
|
...input,
|
|
@@ -230,12 +589,12 @@ var RuntimeUsageProblem = class extends TaggedError("RuntimeUsageProblem")() {
|
|
|
230
589
|
});
|
|
231
590
|
}
|
|
232
591
|
};
|
|
233
|
-
var RuntimeBodyProblem = class extends
|
|
592
|
+
var RuntimeBodyProblem = class extends h("RuntimeBodyProblem")() {
|
|
234
593
|
constructor(input) {
|
|
235
594
|
super(input);
|
|
236
595
|
}
|
|
237
596
|
};
|
|
238
|
-
var RuntimeMediaProblem = class extends
|
|
597
|
+
var RuntimeMediaProblem = class extends h("RuntimeMediaProblem")() {
|
|
239
598
|
constructor(input) {
|
|
240
599
|
super(input);
|
|
241
600
|
}
|
|
@@ -262,19 +621,19 @@ const resolvePathTemplateResult = (template, values) => {
|
|
|
262
621
|
continue;
|
|
263
622
|
}
|
|
264
623
|
const value = values[name];
|
|
265
|
-
if (value === void 0) return
|
|
624
|
+
if (value === void 0) return G.err(new RuntimeUsageProblem({
|
|
266
625
|
kind: "missing_path_parameter",
|
|
267
626
|
paramName: name
|
|
268
627
|
}));
|
|
269
628
|
resolvedSegments.push(safePathSegment(value));
|
|
270
629
|
}
|
|
271
630
|
const resolvedPath = resolvedSegments.join("/");
|
|
272
|
-
if (!resolvedPath) return
|
|
273
|
-
return
|
|
631
|
+
if (!resolvedPath) return G.ok(template.startsWith("/") ? "/" : "");
|
|
632
|
+
return G.ok(`${template.startsWith("/") ? "/" : ""}${resolvedPath}`);
|
|
274
633
|
};
|
|
275
634
|
const resolvePathTemplate = (template, values) => {
|
|
276
635
|
const resolved = resolvePathTemplateResult(template, values);
|
|
277
|
-
if (
|
|
636
|
+
if (G.isError(resolved)) throw new Error(resolved.error.message);
|
|
278
637
|
return resolved.value;
|
|
279
638
|
};
|
|
280
639
|
const cliFlagNameFor$1 = (adapter, name) => adapter.cliFlagName?.(name) ?? flagName(name);
|
|
@@ -306,7 +665,7 @@ const validateMediaAttachmentsResult = (attachments, opts) => {
|
|
|
306
665
|
if (opts.rule === "post") {
|
|
307
666
|
const images = attachments.filter((attachment) => attachment.content_type.startsWith("image/")).length;
|
|
308
667
|
const others = attachments.length - images;
|
|
309
|
-
if (others > 0 && attachments.length > 1) return
|
|
668
|
+
if (others > 0 && attachments.length > 1) return G.err(new RuntimeMediaProblem({
|
|
310
669
|
kind: "post_attachment_mix",
|
|
311
670
|
imageCount: images,
|
|
312
671
|
otherCount: others,
|
|
@@ -314,13 +673,13 @@ const validateMediaAttachmentsResult = (attachments, opts) => {
|
|
|
314
673
|
}));
|
|
315
674
|
} else {
|
|
316
675
|
const total = attachments.reduce((sum, attachment) => sum + attachment.byteLength, 0);
|
|
317
|
-
if (total > 20 * 1024 * 1024) return
|
|
676
|
+
if (total > 20 * 1024 * 1024) return G.err(new RuntimeMediaProblem({
|
|
318
677
|
kind: "message_attachments_too_large",
|
|
319
678
|
totalBytes: total,
|
|
320
679
|
message: `LinkedIn message attachments cap at 20 MB combined; yours total ${(total / (1024 * 1024)).toFixed(1)} MB.`
|
|
321
680
|
}));
|
|
322
681
|
}
|
|
323
|
-
return
|
|
682
|
+
return G.ok(attachments.map(({ content, content_type, filename }) => ({
|
|
324
683
|
content,
|
|
325
684
|
content_type,
|
|
326
685
|
filename
|
|
@@ -331,7 +690,7 @@ const mediaAttachmentsFrom = async (deps, paths, opts) => {
|
|
|
331
690
|
const attachments = [];
|
|
332
691
|
for (const path of paths) attachments.push(await deps.readMedia(path));
|
|
333
692
|
const validated = validateMediaAttachmentsResult(attachments, opts);
|
|
334
|
-
if (
|
|
693
|
+
if (G.isError(validated)) throw opts.usageError(validated.error.message);
|
|
335
694
|
return validated.value;
|
|
336
695
|
};
|
|
337
696
|
const trimTrailingNewline$1 = (value) => value.endsWith("\r\n") ? value.slice(0, -2) : value.endsWith("\n") ? value.slice(0, -1) : value;
|
|
@@ -340,9 +699,9 @@ const parseStdinBodyResult = (deps, bodyTextName, bodyTextKey, value) => {
|
|
|
340
699
|
JSON.parse(value);
|
|
341
700
|
} catch {
|
|
342
701
|
try {
|
|
343
|
-
return
|
|
702
|
+
return G.ok({ [bodyTextKey]: deps.parseBodyText(`<${bodyTextName}>`, value) });
|
|
344
703
|
} catch (error) {
|
|
345
|
-
return
|
|
704
|
+
return G.err(new RuntimeBodyProblem({
|
|
346
705
|
kind: "body_parse_failed",
|
|
347
706
|
message: error instanceof Error ? error.message : "Could not parse stdin body text.",
|
|
348
707
|
cause: error
|
|
@@ -350,9 +709,9 @@ const parseStdinBodyResult = (deps, bodyTextName, bodyTextKey, value) => {
|
|
|
350
709
|
}
|
|
351
710
|
}
|
|
352
711
|
try {
|
|
353
|
-
return
|
|
712
|
+
return G.ok(deps.parseJSONObject("stdin", value));
|
|
354
713
|
} catch (error) {
|
|
355
|
-
return
|
|
714
|
+
return G.err(new RuntimeBodyProblem({
|
|
356
715
|
kind: "body_parse_failed",
|
|
357
716
|
message: error instanceof Error ? error.message : "Could not parse stdin JSON body.",
|
|
358
717
|
cause: error
|
|
@@ -361,7 +720,7 @@ const parseStdinBodyResult = (deps, bodyTextName, bodyTextKey, value) => {
|
|
|
361
720
|
};
|
|
362
721
|
const parseStdinBody$2 = (deps, bodyTextName, bodyTextKey, value) => {
|
|
363
722
|
const parsed = parseStdinBodyResult(deps, bodyTextName, bodyTextKey, value);
|
|
364
|
-
if (
|
|
723
|
+
if (G.isError(parsed)) throw parsed.error.cause ?? parsed.error;
|
|
365
724
|
return parsed.value;
|
|
366
725
|
};
|
|
367
726
|
const hasStdinBodyText = (adapter, op) => op.config.bodyTextArg !== void 0 && adapter.bodyTextResolvesTarget?.(op) !== true;
|
|
@@ -449,16 +808,16 @@ const defaultArgAliases = (name) => new Set([name, flagName(name)]);
|
|
|
449
808
|
const rejectUnsupportedRuntimeArgsResult = (adapter, op, args, allowedArgNames = Object.keys(buildRuntimeArgs(adapter, op))) => {
|
|
450
809
|
const allowed = new Set(["_"]);
|
|
451
810
|
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
|
|
811
|
+
for (const [name, value] of Object.entries(args)) if (!allowed.has(name) && (adapter.ignoreUndefinedUnsupportedArgs !== true || value !== void 0)) return G.err(new RuntimeUsageProblem({
|
|
453
812
|
kind: "unsupported_arg",
|
|
454
813
|
argName: name,
|
|
455
814
|
value
|
|
456
815
|
}));
|
|
457
|
-
return
|
|
816
|
+
return G.ok();
|
|
458
817
|
};
|
|
459
818
|
const rejectUnsupportedRuntimeArgs = (adapter, op, args, allowedArgNames = Object.keys(buildRuntimeArgs(adapter, op))) => {
|
|
460
819
|
const rejected = rejectUnsupportedRuntimeArgsResult(adapter, op, args, allowedArgNames);
|
|
461
|
-
if (
|
|
820
|
+
if (G.isError(rejected)) {
|
|
462
821
|
if (rejected.error.kind === "unsupported_arg" && rejected.error.argName !== void 0) throw adapter.unsupportedArgError(rejected.error.argName, rejected.error.value, op);
|
|
463
822
|
throw adapter.usageError(rejected.error.message);
|
|
464
823
|
}
|
|
@@ -535,8 +894,8 @@ const bodyRequiredPreparseProblem = (adapter, op) => new RuntimeBodyProblem({
|
|
|
535
894
|
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
895
|
});
|
|
537
896
|
const checkBodyRequiredResult = (adapter, op, args, bodyTextOptional) => {
|
|
538
|
-
if (!op.hasBody || adapter.checkBodyRequiredBeforeInput !== true) return
|
|
539
|
-
if (bodyTextOptional) return
|
|
897
|
+
if (!op.hasBody || adapter.checkBodyRequiredBeforeInput !== true) return G.ok();
|
|
898
|
+
if (bodyTextOptional) return G.ok();
|
|
540
899
|
const expressions = [];
|
|
541
900
|
const bodyTextArg = op.config.bodyTextArg;
|
|
542
901
|
if (bodyTextArg && op.config.bodyTextRequired !== false) expressions.push(args[bodyTextDisplayKeyFor(op) ?? bodyTextArg] === void 0);
|
|
@@ -544,25 +903,25 @@ const checkBodyRequiredResult = (adapter, op, args, bodyTextOptional) => {
|
|
|
544
903
|
const positionalValuePresent = param.positional && Array.isArray(args._) && args._.length > 0;
|
|
545
904
|
expressions.push(args[flagName(bodyParamArgFor(adapter, name, param))] === void 0 && !positionalValuePresent);
|
|
546
905
|
}
|
|
547
|
-
if (expressions.length > 0 && typeof args.body !== "string" && expressions.some(Boolean)) return
|
|
548
|
-
return
|
|
906
|
+
if (expressions.length > 0 && typeof args.body !== "string" && expressions.some(Boolean)) return G.err(bodyRequiredPreparseProblem(adapter, op));
|
|
907
|
+
return G.ok();
|
|
549
908
|
};
|
|
550
909
|
const throwRuntimeBodyProblem = (adapter, problem) => {
|
|
551
910
|
throw problem.cause ?? adapter.usageError(problem.message);
|
|
552
911
|
};
|
|
553
912
|
const checkBodyRequired = (adapter, op, args, bodyTextOptional) => {
|
|
554
913
|
const checked = checkBodyRequiredResult(adapter, op, args, bodyTextOptional);
|
|
555
|
-
if (
|
|
914
|
+
if (G.isError(checked)) throwRuntimeBodyProblem(adapter, checked.error);
|
|
556
915
|
};
|
|
557
916
|
const buildBodyResult = (adapter, deps, op, input, bodyTextOptional) => {
|
|
558
917
|
const bodyTextArg = op.config.bodyTextArg;
|
|
559
918
|
const bodyParamEntries = Object.entries(op.config.bodyParams ?? {});
|
|
560
919
|
if (!bodyTextArg && bodyParamEntries.length === 0) {
|
|
561
|
-
if (input.body === void 0) return
|
|
920
|
+
if (input.body === void 0) return G.ok(void 0);
|
|
562
921
|
try {
|
|
563
|
-
return
|
|
922
|
+
return G.ok(deps.parseJSONObject("--body", input.body));
|
|
564
923
|
} catch (error) {
|
|
565
|
-
return
|
|
924
|
+
return G.err(new RuntimeBodyProblem({
|
|
566
925
|
kind: "body_parse_failed",
|
|
567
926
|
message: error instanceof Error ? error.message : "Could not parse --body JSON.",
|
|
568
927
|
cause: error
|
|
@@ -573,7 +932,7 @@ const buildBodyResult = (adapter, deps, op, input, bodyTextOptional) => {
|
|
|
573
932
|
if (input.body !== void 0) try {
|
|
574
933
|
bodyFromJSON = deps.parseJSONObject(hasStdinBodyText(adapter, op) ? "stdin" : "--body", input.body);
|
|
575
934
|
} catch (error) {
|
|
576
|
-
return
|
|
935
|
+
return G.err(new RuntimeBodyProblem({
|
|
577
936
|
kind: "body_parse_failed",
|
|
578
937
|
message: error instanceof Error ? error.message : "Could not parse request body JSON.",
|
|
579
938
|
cause: error
|
|
@@ -584,7 +943,7 @@ const buildBodyResult = (adapter, deps, op, input, bodyTextOptional) => {
|
|
|
584
943
|
if (bodyTextArg && input[bodyTextArg] !== void 0) try {
|
|
585
944
|
bodyText = deps.parseBodyText(`<${displayTextArg}>`, input[bodyTextArg]);
|
|
586
945
|
} catch (error) {
|
|
587
|
-
return
|
|
946
|
+
return G.err(new RuntimeBodyProblem({
|
|
588
947
|
kind: "body_parse_failed",
|
|
589
948
|
message: error instanceof Error ? error.message : "Could not parse body text.",
|
|
590
949
|
cause: error
|
|
@@ -597,7 +956,7 @@ const buildBodyResult = (adapter, deps, op, input, bodyTextOptional) => {
|
|
|
597
956
|
try {
|
|
598
957
|
bodyParamValues.set(name, value === void 0 ? param.default : param.kind === "array" ? deps.parseResourceIdList(displayName, Array.isArray(value) ? value : [value]) : deps.parseQueryString(displayName, value));
|
|
599
958
|
} catch (error) {
|
|
600
|
-
return
|
|
959
|
+
return G.err(new RuntimeBodyProblem({
|
|
601
960
|
kind: "body_parse_failed",
|
|
602
961
|
message: error instanceof Error ? error.message : `Could not parse ${displayName}.`,
|
|
603
962
|
cause: error
|
|
@@ -623,45 +982,45 @@ const buildBodyResult = (adapter, deps, op, input, bodyTextOptional) => {
|
|
|
623
982
|
input,
|
|
624
983
|
op
|
|
625
984
|
});
|
|
626
|
-
if (error) return
|
|
985
|
+
if (error) return G.err(new RuntimeBodyProblem({
|
|
627
986
|
kind: "body_validation_failed",
|
|
628
987
|
message: error.message,
|
|
629
988
|
cause: error
|
|
630
989
|
}));
|
|
631
|
-
return
|
|
990
|
+
return G.ok(resolvedBody);
|
|
632
991
|
};
|
|
633
992
|
const buildBody = (adapter, deps, op, input, bodyTextOptional) => {
|
|
634
993
|
const built = buildBodyResult(adapter, deps, op, input, bodyTextOptional);
|
|
635
|
-
if (
|
|
994
|
+
if (G.isOk(built)) return built.value;
|
|
636
995
|
throwRuntimeBodyProblem(adapter, built.error);
|
|
637
996
|
};
|
|
638
997
|
const resolveBodyTextFromStdinResult = async (adapter, op, deps, args, commandLabel, bodyTextOptional) => {
|
|
639
|
-
if (!hasStdinBodyText(adapter, op)) return
|
|
998
|
+
if (!hasStdinBodyText(adapter, op)) return G.ok();
|
|
640
999
|
const bodyTextArg = op.config.bodyTextArg;
|
|
641
|
-
if (bodyTextArg === void 0) return
|
|
1000
|
+
if (bodyTextArg === void 0) return G.ok();
|
|
642
1001
|
const displayTextArg = bodyTextDisplayKeyFor(op) ?? bodyTextArg;
|
|
643
1002
|
const required = stdinBodyTextRequired(adapter, op) && !bodyTextOptional;
|
|
644
1003
|
if (deps.isStdinTTY()) {
|
|
645
|
-
if (required) return
|
|
1004
|
+
if (required) return G.err(new RuntimeBodyProblem({
|
|
646
1005
|
kind: "stdin_body_required",
|
|
647
1006
|
message: bodyTextPipeMessage(commandLabel)
|
|
648
1007
|
}));
|
|
649
|
-
return
|
|
1008
|
+
return G.ok();
|
|
650
1009
|
}
|
|
651
1010
|
const piped = trimTrailingNewline$1(await deps.readStdin());
|
|
652
1011
|
if (piped.length > 0) {
|
|
653
1012
|
const parsed = parseStdinBodyResult(deps, displayTextArg, bodyTextArg, piped);
|
|
654
|
-
if (
|
|
1013
|
+
if (G.isError(parsed)) return G.err(parsed.error);
|
|
655
1014
|
args.body = JSON.stringify(parsed.value);
|
|
656
|
-
} else if (required) return
|
|
1015
|
+
} else if (required) return G.err(new RuntimeBodyProblem({
|
|
657
1016
|
kind: "stdin_body_required",
|
|
658
1017
|
message: bodyTextPipeMessage(commandLabel)
|
|
659
1018
|
}));
|
|
660
|
-
return
|
|
1019
|
+
return G.ok();
|
|
661
1020
|
};
|
|
662
1021
|
const resolveBodyTextFromStdin = async (adapter, op, deps, args, commandLabel, bodyTextOptional) => {
|
|
663
1022
|
const resolved = await resolveBodyTextFromStdinResult(adapter, op, deps, args, commandLabel, bodyTextOptional);
|
|
664
|
-
if (
|
|
1023
|
+
if (G.isError(resolved)) throwRuntimeBodyProblem(adapter, resolved.error);
|
|
665
1024
|
};
|
|
666
1025
|
const maximumItemsHintFor$2 = (adapter, op) => adapter.maximumItemsHintFor?.(op);
|
|
667
1026
|
const costFor = (adapter, op) => {
|
|
@@ -992,32 +1351,32 @@ const normalizeLiftedRow = (collection, row) => {
|
|
|
992
1351
|
const columns = collectionColumns(collection);
|
|
993
1352
|
const columnSet = new Set(columns);
|
|
994
1353
|
const normalized = {};
|
|
995
|
-
for (const column of Object.keys(row)) if (!columnSet.has(column)) return
|
|
1354
|
+
for (const column of Object.keys(row)) if (!columnSet.has(column)) return G.err({
|
|
996
1355
|
kind: "unsupportedValue",
|
|
997
1356
|
column,
|
|
998
1357
|
message: `${collection.key} produced unexpected column ${column}`
|
|
999
1358
|
});
|
|
1000
1359
|
for (const column of columns) {
|
|
1001
1360
|
const value = row[column];
|
|
1002
|
-
if (unsupportedRowValue(value)) return
|
|
1361
|
+
if (unsupportedRowValue(value)) return G.err({
|
|
1003
1362
|
kind: "unsupportedValue",
|
|
1004
1363
|
column,
|
|
1005
1364
|
message: `${collection.key} produced unsupported value for ${column}`
|
|
1006
1365
|
});
|
|
1007
1366
|
normalized[column] = value ?? null;
|
|
1008
1367
|
}
|
|
1009
|
-
if (normalized.id === null || normalized.id === "") return
|
|
1368
|
+
if (normalized.id === null || normalized.id === "") return G.err({
|
|
1010
1369
|
kind: "missingId",
|
|
1011
1370
|
column: "id",
|
|
1012
1371
|
message: `${collection.key} row is missing id`
|
|
1013
1372
|
});
|
|
1014
|
-
return
|
|
1373
|
+
return G.ok(normalized);
|
|
1015
1374
|
};
|
|
1016
1375
|
const liftCollectionRow = (collection, item) => {
|
|
1017
1376
|
try {
|
|
1018
1377
|
return normalizeLiftedRow(collection, collection.lift(item));
|
|
1019
1378
|
} catch (error) {
|
|
1020
|
-
return
|
|
1379
|
+
return G.err(normalizationErrorFrom(error));
|
|
1021
1380
|
}
|
|
1022
1381
|
};
|
|
1023
1382
|
const withCollectionColumns = (collection) => ({
|
|
@@ -1828,7 +2187,7 @@ const metadataForPlatform = (platform) => {
|
|
|
1828
2187
|
//#endregion
|
|
1829
2188
|
//#region ../../packages/sqlsync/src/cursor.ts
|
|
1830
2189
|
const PARTIAL_SYNC_CURSOR_PREFIX = "partial-sync-v1:";
|
|
1831
|
-
var CorruptPartialSyncCursor = class extends
|
|
2190
|
+
var CorruptPartialSyncCursor = class extends h("CorruptPartialSyncCursor")() {
|
|
1832
2191
|
constructor(args) {
|
|
1833
2192
|
super({
|
|
1834
2193
|
cursor: args.cursor,
|
|
@@ -1841,19 +2200,19 @@ const isRecord$12 = (value) => value !== null && typeof value === "object" && !A
|
|
|
1841
2200
|
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
2201
|
const encodePartialSyncCursor = (cursor) => `${PARTIAL_SYNC_CURSOR_PREFIX}${JSON.stringify(cursor)}`;
|
|
1843
2202
|
const parsePartialSyncCursor = (value) => {
|
|
1844
|
-
if (!value.startsWith("partial-sync-v1:")) return
|
|
2203
|
+
if (!value.startsWith("partial-sync-v1:")) return G.err(new CorruptPartialSyncCursor({
|
|
1845
2204
|
cursor: value,
|
|
1846
2205
|
reason: "missing partial-sync-v1 prefix"
|
|
1847
2206
|
}));
|
|
1848
2207
|
try {
|
|
1849
2208
|
const parsed = JSON.parse(value.slice(16));
|
|
1850
|
-
if (isRecord$12(parsed) && validPartialSyncCursor(parsed)) return
|
|
1851
|
-
return
|
|
2209
|
+
if (isRecord$12(parsed) && validPartialSyncCursor(parsed)) return G.ok(parsed);
|
|
2210
|
+
return G.err(new CorruptPartialSyncCursor({
|
|
1852
2211
|
cursor: value,
|
|
1853
2212
|
reason: "payload does not match the partial cursor shape"
|
|
1854
2213
|
}));
|
|
1855
2214
|
} catch (error) {
|
|
1856
|
-
return
|
|
2215
|
+
return G.err(new CorruptPartialSyncCursor({
|
|
1857
2216
|
cursor: value,
|
|
1858
2217
|
reason: "payload is not valid JSON",
|
|
1859
2218
|
cause: error
|
|
@@ -1861,12 +2220,12 @@ const parsePartialSyncCursor = (value) => {
|
|
|
1861
2220
|
}
|
|
1862
2221
|
};
|
|
1863
2222
|
const readPartialSyncCursorResult = (value) => {
|
|
1864
|
-
if (!value?.startsWith("partial-sync-v1:")) return
|
|
2223
|
+
if (!value?.startsWith("partial-sync-v1:")) return G.ok(void 0);
|
|
1865
2224
|
return parsePartialSyncCursor(value);
|
|
1866
2225
|
};
|
|
1867
2226
|
const readPartialSyncCursor = (value) => {
|
|
1868
2227
|
const parsed = readPartialSyncCursorResult(value);
|
|
1869
|
-
return
|
|
2228
|
+
return G.isError(parsed) ? void 0 : parsed.value;
|
|
1870
2229
|
};
|
|
1871
2230
|
const partialCursorMatchesSince = (cursor, since) => {
|
|
1872
2231
|
const requestedSince = since ?? null;
|
|
@@ -1931,7 +2290,7 @@ const readUserVersion = (db) => {
|
|
|
1931
2290
|
const setUserVersion = (db, version) => {
|
|
1932
2291
|
db.exec(`PRAGMA user_version = ${version}`);
|
|
1933
2292
|
};
|
|
1934
|
-
var MissingMigration = class extends
|
|
2293
|
+
var MissingMigration = class extends h("MissingMigration")() {
|
|
1935
2294
|
constructor(index) {
|
|
1936
2295
|
super({
|
|
1937
2296
|
index,
|
|
@@ -1939,7 +2298,7 @@ var MissingMigration = class extends TaggedError("MissingMigration")() {
|
|
|
1939
2298
|
});
|
|
1940
2299
|
}
|
|
1941
2300
|
};
|
|
1942
|
-
var StaleMigrationSchema = class extends
|
|
2301
|
+
var StaleMigrationSchema = class extends h("StaleMigrationSchema")() {
|
|
1943
2302
|
constructor(currentVersion, finalVersion) {
|
|
1944
2303
|
super({
|
|
1945
2304
|
currentVersion,
|
|
@@ -1950,20 +2309,20 @@ var StaleMigrationSchema = class extends TaggedError("StaleMigrationSchema")() {
|
|
|
1950
2309
|
};
|
|
1951
2310
|
const migrateResult = (db) => {
|
|
1952
2311
|
const currentVersion = readUserVersion(db);
|
|
1953
|
-
if (currentVersion >= MIGRATIONS.length) return
|
|
2312
|
+
if (currentVersion >= MIGRATIONS.length) return G.ok({
|
|
1954
2313
|
fromVersion: currentVersion,
|
|
1955
2314
|
toVersion: currentVersion,
|
|
1956
2315
|
applied: 0
|
|
1957
2316
|
});
|
|
1958
2317
|
for (let index = currentVersion; index < MIGRATIONS.length; index += 1) {
|
|
1959
2318
|
const migration = MIGRATIONS[index];
|
|
1960
|
-
if (!migration) return
|
|
2319
|
+
if (!migration) return G.err(new MissingMigration(index));
|
|
1961
2320
|
db.transaction(() => {
|
|
1962
2321
|
db.exec(migration.sql);
|
|
1963
2322
|
setUserVersion(db, index + 1);
|
|
1964
2323
|
});
|
|
1965
2324
|
}
|
|
1966
|
-
return
|
|
2325
|
+
return G.ok({
|
|
1967
2326
|
fromVersion: currentVersion,
|
|
1968
2327
|
toVersion: MIGRATIONS.length,
|
|
1969
2328
|
applied: MIGRATIONS.length - currentVersion
|
|
@@ -1972,8 +2331,8 @@ const migrateResult = (db) => {
|
|
|
1972
2331
|
const migrate = (db) => migrateResult(db).unwrap();
|
|
1973
2332
|
const assertAtLatestResult = (db) => {
|
|
1974
2333
|
const currentVersion = readUserVersion(db);
|
|
1975
|
-
if (currentVersion < MIGRATIONS.length) return
|
|
1976
|
-
return
|
|
2334
|
+
if (currentVersion < MIGRATIONS.length) return G.err(new StaleMigrationSchema(currentVersion, MIGRATIONS.length));
|
|
2335
|
+
return G.ok(void 0);
|
|
1977
2336
|
};
|
|
1978
2337
|
const assertAtLatest = (db) => {
|
|
1979
2338
|
assertAtLatestResult(db).unwrap();
|
|
@@ -2090,7 +2449,7 @@ const applyWriteThrough = (db, args) => {
|
|
|
2090
2449
|
};
|
|
2091
2450
|
//#endregion
|
|
2092
2451
|
//#region ../../packages/sqlsync/src/cache.ts
|
|
2093
|
-
var UnknownCacheTable = class extends
|
|
2452
|
+
var UnknownCacheTable = class extends h("UnknownCacheTable")() {
|
|
2094
2453
|
constructor(args) {
|
|
2095
2454
|
super({
|
|
2096
2455
|
table: args.table,
|
|
@@ -2098,7 +2457,7 @@ var UnknownCacheTable = class extends TaggedError("UnknownCacheTable")() {
|
|
|
2098
2457
|
});
|
|
2099
2458
|
}
|
|
2100
2459
|
};
|
|
2101
|
-
var ForbiddenCacheTableRead = class extends
|
|
2460
|
+
var ForbiddenCacheTableRead = class extends h("ForbiddenCacheTableRead")() {
|
|
2102
2461
|
constructor(args) {
|
|
2103
2462
|
const tables = [...args.tables].sort();
|
|
2104
2463
|
super({
|
|
@@ -2108,7 +2467,7 @@ var ForbiddenCacheTableRead = class extends TaggedError("ForbiddenCacheTableRead
|
|
|
2108
2467
|
});
|
|
2109
2468
|
}
|
|
2110
2469
|
};
|
|
2111
|
-
var UnknownCachePlatform = class extends
|
|
2470
|
+
var UnknownCachePlatform = class extends h("UnknownCachePlatform")() {
|
|
2112
2471
|
constructor(platform) {
|
|
2113
2472
|
super({
|
|
2114
2473
|
platform,
|
|
@@ -2121,40 +2480,40 @@ const resolveCachePath = (path) => path === ":memory:" ? path : resolve(path);
|
|
|
2121
2480
|
const stringOrNull = (value) => typeof value === "string" ? value : null;
|
|
2122
2481
|
const numberOrNull = (value) => typeof value === "number" ? value : null;
|
|
2123
2482
|
const parseCachePlatform = (platform) => {
|
|
2124
|
-
if (platform === "linkedin" || platform === "x") return
|
|
2125
|
-
return
|
|
2483
|
+
if (platform === "linkedin" || platform === "x") return G.ok(platform);
|
|
2484
|
+
return G.err(new UnknownCachePlatform(platform));
|
|
2126
2485
|
};
|
|
2127
2486
|
const requireCachePlatform = (platform) => {
|
|
2128
2487
|
const parsed = parseCachePlatform(platform);
|
|
2129
|
-
if (
|
|
2488
|
+
if (G.isError(parsed)) throw parsed.error;
|
|
2130
2489
|
return parsed.value;
|
|
2131
2490
|
};
|
|
2132
2491
|
const parseCacheTable = (table) => {
|
|
2133
|
-
if (!cacheTableNames.has(table)) return
|
|
2134
|
-
return
|
|
2492
|
+
if (!cacheTableNames.has(table)) return G.err(new UnknownCacheTable({ table }));
|
|
2493
|
+
return G.ok(table);
|
|
2135
2494
|
};
|
|
2136
2495
|
const requireCacheTable = (table) => {
|
|
2137
2496
|
const parsed = parseCacheTable(table);
|
|
2138
|
-
if (
|
|
2497
|
+
if (G.isError(parsed)) throw parsed.error;
|
|
2139
2498
|
return parsed.value;
|
|
2140
2499
|
};
|
|
2141
2500
|
const checkPlatformQuery = (sql, platform) => {
|
|
2142
2501
|
const allowedTables = tablesForPlatform(platform);
|
|
2143
2502
|
const rejectedTables = new Set(knownTableTokens(sql).filter((table) => !allowedTables.has(table)));
|
|
2144
|
-
if (rejectedTables.size > 0) return
|
|
2503
|
+
if (rejectedTables.size > 0) return G.err(new ForbiddenCacheTableRead({
|
|
2145
2504
|
platform,
|
|
2146
2505
|
tables: rejectedTables
|
|
2147
2506
|
}));
|
|
2148
|
-
return
|
|
2507
|
+
return G.ok();
|
|
2149
2508
|
};
|
|
2150
2509
|
const assertPlatformQuery = (sql, platform) => {
|
|
2151
2510
|
const checked = checkPlatformQuery(sql, platform);
|
|
2152
|
-
if (
|
|
2511
|
+
if (G.isError(checked)) throw checked.error;
|
|
2153
2512
|
};
|
|
2154
2513
|
const classifyCacheRead = (sql, platform) => {
|
|
2155
2514
|
const checked = checkPlatformQuery(sql, platform);
|
|
2156
|
-
if (
|
|
2157
|
-
return
|
|
2515
|
+
if (G.isError(checked)) return G.err(checked.error);
|
|
2516
|
+
return G.ok({ tables: referencedTablesForRead(sql, platform) });
|
|
2158
2517
|
};
|
|
2159
2518
|
const unknownTableFromSQLiteError = (error) => {
|
|
2160
2519
|
return (error instanceof Error ? error.message : String(error)).match(/\bno such table: ([^\s]+)/)?.[1]?.replace(/^["'`]|["'`]$/g, "");
|
|
@@ -2299,7 +2658,7 @@ const createCache = (path, db) => ({
|
|
|
2299
2658
|
},
|
|
2300
2659
|
read: (sql, opts) => {
|
|
2301
2660
|
const classification = classifyCacheRead(sql, opts.platform);
|
|
2302
|
-
if (
|
|
2661
|
+
if (G.isError(classification)) return G.err(classification.error);
|
|
2303
2662
|
const tables = classification.value.tables.map((name) => {
|
|
2304
2663
|
return {
|
|
2305
2664
|
name,
|
|
@@ -2311,10 +2670,10 @@ const createCache = (path, db) => ({
|
|
|
2311
2670
|
rows = db.prepare(sql).all();
|
|
2312
2671
|
} catch (error) {
|
|
2313
2672
|
const table = unknownTableFromSQLiteError(error);
|
|
2314
|
-
if (table) return
|
|
2673
|
+
if (table) return G.err(new UnknownCacheTable({ table }));
|
|
2315
2674
|
throw error;
|
|
2316
2675
|
}
|
|
2317
|
-
return
|
|
2676
|
+
return G.ok({
|
|
2318
2677
|
rows,
|
|
2319
2678
|
tables
|
|
2320
2679
|
});
|
|
@@ -7095,7 +7454,7 @@ const planPagePersistence = (state, page, opts) => {
|
|
|
7095
7454
|
const profileTableFor = (platform) => platform === "x" ? "x_profiles_raw" : "li_profiles_raw";
|
|
7096
7455
|
//#endregion
|
|
7097
7456
|
//#region ../../packages/sqlsync/src/sync-plan.ts
|
|
7098
|
-
var SinceUnsupported = class extends
|
|
7457
|
+
var SinceUnsupported = class extends h("SinceUnsupported")() {
|
|
7099
7458
|
constructor(collectionKey) {
|
|
7100
7459
|
super({
|
|
7101
7460
|
collectionKey,
|
|
@@ -7103,7 +7462,7 @@ var SinceUnsupported = class extends TaggedError("SinceUnsupported")() {
|
|
|
7103
7462
|
});
|
|
7104
7463
|
}
|
|
7105
7464
|
};
|
|
7106
|
-
var FullInitialSyncRequired = class extends
|
|
7465
|
+
var FullInitialSyncRequired = class extends h("FullInitialSyncRequired")() {
|
|
7107
7466
|
constructor(collectionKey) {
|
|
7108
7467
|
super({
|
|
7109
7468
|
collectionKey,
|
|
@@ -7111,7 +7470,7 @@ var FullInitialSyncRequired = class extends TaggedError("FullInitialSyncRequired
|
|
|
7111
7470
|
});
|
|
7112
7471
|
}
|
|
7113
7472
|
};
|
|
7114
|
-
var MissingParentCollection = class extends
|
|
7473
|
+
var MissingParentCollection = class extends h("MissingParentCollection")() {
|
|
7115
7474
|
constructor(collectionKey, parentCollectionKey) {
|
|
7116
7475
|
super({
|
|
7117
7476
|
collectionKey,
|
|
@@ -7120,7 +7479,7 @@ var MissingParentCollection = class extends TaggedError("MissingParentCollection
|
|
|
7120
7479
|
});
|
|
7121
7480
|
}
|
|
7122
7481
|
};
|
|
7123
|
-
var InvalidPartialCursor = class extends
|
|
7482
|
+
var InvalidPartialCursor = class extends h("InvalidPartialCursor")() {
|
|
7124
7483
|
constructor(collectionKey, cursor, cause) {
|
|
7125
7484
|
super({
|
|
7126
7485
|
collectionKey,
|
|
@@ -7132,19 +7491,19 @@ var InvalidPartialCursor = class extends TaggedError("InvalidPartialCursor")() {
|
|
|
7132
7491
|
};
|
|
7133
7492
|
const parseStoredPartialCursor = (collectionKey, cursor) => {
|
|
7134
7493
|
const parsed = readPartialSyncCursorResult(cursor);
|
|
7135
|
-
if (
|
|
7136
|
-
return
|
|
7494
|
+
if (G.isError(parsed)) return G.err(new InvalidPartialCursor(collectionKey, cursor ?? "", parsed.error));
|
|
7495
|
+
return G.ok(parsed.value);
|
|
7137
7496
|
};
|
|
7138
7497
|
const validateSyncOptions = (deps, opts) => {
|
|
7139
7498
|
const { collection } = opts;
|
|
7140
|
-
if (opts.since != null && collection.sinceField === void 0) return
|
|
7499
|
+
if (opts.since != null && collection.sinceField === void 0) return G.err(new SinceUnsupported(collection.key));
|
|
7141
7500
|
const storedState = deps.cache.getCursor(collection.key);
|
|
7142
7501
|
const storedPartialCursor = parseStoredPartialCursor(collection.key, storedState?.cursor);
|
|
7143
|
-
if (
|
|
7144
|
-
if (opts.since != null && collection.requiresFullInitialSync && (storedState?.lastSynced == null || storedPartialCursor.value !== void 0)) return
|
|
7502
|
+
if (G.isError(storedPartialCursor)) return G.err(storedPartialCursor.error);
|
|
7503
|
+
if (opts.since != null && collection.requiresFullInitialSync && (storedState?.lastSynced == null || storedPartialCursor.value !== void 0)) return G.err(new FullInitialSyncRequired(collection.key));
|
|
7145
7504
|
const parentCollection = collection.parentCollection === void 0 ? void 0 : collectionByKey(collection.parentCollection);
|
|
7146
|
-
if (collection.parentCollection && !parentCollection) return
|
|
7147
|
-
return
|
|
7505
|
+
if (collection.parentCollection && !parentCollection) return G.err(new MissingParentCollection(collection.key, collection.parentCollection));
|
|
7506
|
+
return G.ok({
|
|
7148
7507
|
collection,
|
|
7149
7508
|
since: opts.since,
|
|
7150
7509
|
storedState,
|
|
@@ -7178,7 +7537,7 @@ const planCompletedCollectionCursor = (args) => ({
|
|
|
7178
7537
|
//#region ../../packages/sqlsync/src/sync.ts
|
|
7179
7538
|
const sleep = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
|
|
7180
7539
|
const pageDelayFor = (pageDelayMs, pagesCompleted) => typeof pageDelayMs === "function" ? pageDelayMs(pagesCompleted) : pageDelayMs;
|
|
7181
|
-
var UnsupportedSinceCollection = class extends
|
|
7540
|
+
var UnsupportedSinceCollection = class extends h("UnsupportedSinceCollection")() {
|
|
7182
7541
|
constructor(collectionKey) {
|
|
7183
7542
|
super({
|
|
7184
7543
|
collectionKey,
|
|
@@ -7186,7 +7545,7 @@ var UnsupportedSinceCollection = class extends TaggedError("UnsupportedSinceColl
|
|
|
7186
7545
|
});
|
|
7187
7546
|
}
|
|
7188
7547
|
};
|
|
7189
|
-
var InitialSyncRequired = class extends
|
|
7548
|
+
var InitialSyncRequired = class extends h("InitialSyncRequired")() {
|
|
7190
7549
|
constructor(collectionKey) {
|
|
7191
7550
|
super({
|
|
7192
7551
|
collectionKey,
|
|
@@ -7343,7 +7702,7 @@ const walkRequest = async (args) => {
|
|
|
7343
7702
|
break;
|
|
7344
7703
|
} catch (error) {
|
|
7345
7704
|
if (await waitForRateLimit(error)) continue;
|
|
7346
|
-
return
|
|
7705
|
+
return G.err(pageError({
|
|
7347
7706
|
...pageContext,
|
|
7348
7707
|
cursorPersisted: persistPartialCursor() || partialCursorPersisted || void 0
|
|
7349
7708
|
}, error));
|
|
@@ -7354,7 +7713,7 @@ const walkRequest = async (args) => {
|
|
|
7354
7713
|
try {
|
|
7355
7714
|
json = await response.json();
|
|
7356
7715
|
} catch (error) {
|
|
7357
|
-
return
|
|
7716
|
+
return G.err(pageError({
|
|
7358
7717
|
...pageContext,
|
|
7359
7718
|
creditsSpent: args.credits.spent
|
|
7360
7719
|
}, error));
|
|
@@ -7395,7 +7754,7 @@ const walkRequest = async (args) => {
|
|
|
7395
7754
|
break;
|
|
7396
7755
|
}
|
|
7397
7756
|
}
|
|
7398
|
-
return
|
|
7757
|
+
return G.ok({
|
|
7399
7758
|
ids,
|
|
7400
7759
|
newestId: state.newestId,
|
|
7401
7760
|
pages,
|
|
@@ -7419,10 +7778,10 @@ const parentIdsFromCache = (deps, collection, since) => {
|
|
|
7419
7778
|
};
|
|
7420
7779
|
const runSync = async (deps, opts) => {
|
|
7421
7780
|
const syncPlan = validateSyncOptions(deps, opts);
|
|
7422
|
-
if (
|
|
7423
|
-
if (syncPlan.error instanceof SinceUnsupported) return
|
|
7424
|
-
if (syncPlan.error instanceof FullInitialSyncRequired) return
|
|
7425
|
-
return
|
|
7781
|
+
if (G.isError(syncPlan)) {
|
|
7782
|
+
if (syncPlan.error instanceof SinceUnsupported) return G.err(new UnsupportedSinceCollection(syncPlan.error.collectionKey));
|
|
7783
|
+
if (syncPlan.error instanceof FullInitialSyncRequired) return G.err(new InitialSyncRequired(syncPlan.error.collectionKey));
|
|
7784
|
+
return G.err(syncPlan.error);
|
|
7426
7785
|
}
|
|
7427
7786
|
const { collection, parentCollection, storedPartialCursor } = syncPlan.value;
|
|
7428
7787
|
const credits = { spent: 0 };
|
|
@@ -7447,7 +7806,7 @@ const runSync = async (deps, opts) => {
|
|
|
7447
7806
|
deps.cache.setCursor(pending.collection, pending.cursor, pending.objectCount, pending.lastSynced);
|
|
7448
7807
|
};
|
|
7449
7808
|
if (collection.parentCollection) {
|
|
7450
|
-
if (!parentCollection) return
|
|
7809
|
+
if (!parentCollection) return G.err(new MissingParentCollection(collection.key, collection.parentCollection));
|
|
7451
7810
|
let activePartialCursor = activeParentedPartialCursor({
|
|
7452
7811
|
storedPartialCursor,
|
|
7453
7812
|
since: opts.since
|
|
@@ -7487,7 +7846,7 @@ const runSync = async (deps, opts) => {
|
|
|
7487
7846
|
onPage: opts.onPage,
|
|
7488
7847
|
onProgress: opts.onProgress
|
|
7489
7848
|
});
|
|
7490
|
-
if (
|
|
7849
|
+
if (G.isError(result)) return G.err(result.error);
|
|
7491
7850
|
addResult(result.value);
|
|
7492
7851
|
parentIds.push(...result.value.ids);
|
|
7493
7852
|
if (parentPersistsCheckpoint) parentCheckpoint = singleRequestCheckpoint({
|
|
@@ -7534,7 +7893,7 @@ const runSync = async (deps, opts) => {
|
|
|
7534
7893
|
onPage: opts.onPage,
|
|
7535
7894
|
onProgress: opts.onProgress
|
|
7536
7895
|
});
|
|
7537
|
-
if (
|
|
7896
|
+
if (G.isError(result)) return G.err(result.error);
|
|
7538
7897
|
addResult(result.value);
|
|
7539
7898
|
if (activePartialCursor?.phase === "child" && activePartialCursor.parentId === parentId) activePartialCursor = void 0;
|
|
7540
7899
|
}
|
|
@@ -7572,7 +7931,7 @@ const runSync = async (deps, opts) => {
|
|
|
7572
7931
|
onPage: opts.onPage,
|
|
7573
7932
|
onProgress: opts.onProgress
|
|
7574
7933
|
});
|
|
7575
|
-
if (
|
|
7934
|
+
if (G.isError(result)) return G.err(result.error);
|
|
7576
7935
|
addResult(result.value);
|
|
7577
7936
|
if (!preservesBroaderPartialOnSince(activePartialCursor, opts.since, result.value.stoppedReason) && useCheckpoint) pendingCursors.push(singleRequestCheckpoint({
|
|
7578
7937
|
collection,
|
|
@@ -7585,7 +7944,7 @@ const runSync = async (deps, opts) => {
|
|
|
7585
7944
|
})));
|
|
7586
7945
|
}
|
|
7587
7946
|
for (const pending of pendingCursors) writePendingCursor(pending);
|
|
7588
|
-
return
|
|
7947
|
+
return G.ok({
|
|
7589
7948
|
collection: collection.key,
|
|
7590
7949
|
objectsUpserted: upserted,
|
|
7591
7950
|
pages,
|
|
@@ -7844,7 +8203,7 @@ async function resolvePlugins(plugins) {
|
|
|
7844
8203
|
function defineCommand(def) {
|
|
7845
8204
|
return def;
|
|
7846
8205
|
}
|
|
7847
|
-
async function runCommand
|
|
8206
|
+
async function runCommand(cmd, opts) {
|
|
7848
8207
|
const cmdArgs = await resolveValue$1(cmd.args || {});
|
|
7849
8208
|
const parsedArgs = parseArgs$1(opts.rawArgs, cmdArgs);
|
|
7850
8209
|
const context = {
|
|
@@ -7866,14 +8225,14 @@ async function runCommand$1(cmd, opts) {
|
|
|
7866
8225
|
if (explicitName) {
|
|
7867
8226
|
const subCommand = await _findSubCommand(subCommands, explicitName);
|
|
7868
8227
|
if (!subCommand) throw new CLIError(`Unknown command ${cyan(explicitName)}`, "E_UNKNOWN_COMMAND");
|
|
7869
|
-
await runCommand
|
|
8228
|
+
await runCommand(subCommand, { rawArgs: opts.rawArgs.slice(subCommandArgIndex + 1) });
|
|
7870
8229
|
} else {
|
|
7871
8230
|
const defaultSubCommand = await resolveValue$1(cmd.default);
|
|
7872
8231
|
if (defaultSubCommand) {
|
|
7873
8232
|
if (cmd.run) throw new CLIError(`Cannot specify both 'run' and 'default' on the same command.`, "E_DEFAULT_CONFLICT");
|
|
7874
8233
|
const subCommand = await _findSubCommand(subCommands, defaultSubCommand);
|
|
7875
8234
|
if (!subCommand) throw new CLIError(`Default sub command ${cyan(defaultSubCommand)} not found in subCommands.`, "E_UNKNOWN_COMMAND");
|
|
7876
|
-
await runCommand
|
|
8235
|
+
await runCommand(subCommand, { rawArgs: opts.rawArgs });
|
|
7877
8236
|
} else if (!cmd.run) throw new CLIError(`No command specified.`, "E_NO_COMMAND");
|
|
7878
8237
|
}
|
|
7879
8238
|
}
|
|
@@ -8012,14 +8371,14 @@ function renderDescription(arg, required) {
|
|
|
8012
8371
|
}
|
|
8013
8372
|
//#endregion
|
|
8014
8373
|
//#region ../../packages/billing/src/pricing.ts
|
|
8015
|
-
var UnknownPricingCategory = class extends
|
|
8374
|
+
var UnknownPricingCategory = class extends h("pricing_category_unknown")() {};
|
|
8016
8375
|
const lookupCostBPSForCategoryResult = (table, category) => {
|
|
8017
8376
|
const costBPS = table.get(category);
|
|
8018
|
-
if (costBPS === void 0) return
|
|
8377
|
+
if (costBPS === void 0) return G.err(new UnknownPricingCategory({
|
|
8019
8378
|
category,
|
|
8020
8379
|
message: `Unknown pricing category: ${category}`
|
|
8021
8380
|
}));
|
|
8022
|
-
return
|
|
8381
|
+
return G.ok(costBPS);
|
|
8023
8382
|
};
|
|
8024
8383
|
const createPricing = (resources) => {
|
|
8025
8384
|
const table = new Map(resources.map((resource) => [resource.key, Math.round(resource.unitPriceUSD * 1e4)]));
|
|
@@ -10500,8 +10859,8 @@ _enum(FEEDBACK_TYPES);
|
|
|
10500
10859
|
_enum(WRAPPED_STATUSES);
|
|
10501
10860
|
string().trim().min(1).transform((email) => email.toLowerCase()).brand();
|
|
10502
10861
|
union([number(), string().trim().min(1)]).transform((value) => Number(value)).pipe(number().int().nonnegative()).brand();
|
|
10503
|
-
|
|
10504
|
-
|
|
10862
|
+
h("InvalidBillingOverrideEmail")();
|
|
10863
|
+
h("InvalidNonnegativeAllowance")();
|
|
10505
10864
|
const sqlStringLiteral = (value) => `'${value.replaceAll("'", "''")}'`;
|
|
10506
10865
|
const sqlStringList = (values) => sql.raw(values.map(sqlStringLiteral).join(", "));
|
|
10507
10866
|
const sqlCheckIn = (column, values) => sql`${column} in (${sqlStringList(values)})`;
|
|
@@ -10711,8 +11070,8 @@ pgTable("linkedin_connections", {
|
|
|
10711
11070
|
connectedAt: timestamptz("connected_at"),
|
|
10712
11071
|
createdAt: timestamptz("created_at").notNull().defaultNow()
|
|
10713
11072
|
}, (table) => [uniqueIndex("linkedin_connections_of_profile_key").on(table.ofProfileId, table.profileId), index("linkedin_connections_profile_idx").on(table.profileId)]);
|
|
10714
|
-
|
|
10715
|
-
|
|
11073
|
+
h("ProfileStoreUnavailable")();
|
|
11074
|
+
h("InvalidProfileRow")();
|
|
10716
11075
|
//#endregion
|
|
10717
11076
|
//#region ../../packages/lib/src/url.ts
|
|
10718
11077
|
const stripTrailingSlashes = (value) => value.replace(/\/+$/, "");
|
|
@@ -10723,7 +11082,7 @@ const absoluteURLPathPattern = /^[a-z][a-z0-9+.-]*:/i;
|
|
|
10723
11082
|
const protocolRelativeURLPathPattern = /^\/\//;
|
|
10724
11083
|
const unsafeRelativeURLPathMessage = "createURL: path must be relative, not absolute or protocol-relative";
|
|
10725
11084
|
/** Returned when a URL path is absolute or protocol-relative instead of relative. */
|
|
10726
|
-
var InvalidRelativeURLPath = class extends
|
|
11085
|
+
var InvalidRelativeURLPath = class extends h("InvalidRelativeURLPath")() {
|
|
10727
11086
|
constructor({ path }) {
|
|
10728
11087
|
super({
|
|
10729
11088
|
path,
|
|
@@ -10731,7 +11090,7 @@ var InvalidRelativeURLPath = class extends TaggedError("InvalidRelativeURLPath")
|
|
|
10731
11090
|
});
|
|
10732
11091
|
}
|
|
10733
11092
|
};
|
|
10734
|
-
var InvalidBaseURL = class extends
|
|
11093
|
+
var InvalidBaseURL = class extends h("InvalidBaseURL")() {
|
|
10735
11094
|
constructor({ baseURL }) {
|
|
10736
11095
|
super({
|
|
10737
11096
|
baseURL,
|
|
@@ -10742,25 +11101,25 @@ var InvalidBaseURL = class extends TaggedError("InvalidBaseURL")() {
|
|
|
10742
11101
|
/** Parse a path that is safe to resolve against a caller-provided base URL. */
|
|
10743
11102
|
const parseRelativeURLPath = (path) => {
|
|
10744
11103
|
const trimmedPath = path.trimStart();
|
|
10745
|
-
if (absoluteURLPathPattern.test(trimmedPath) || protocolRelativeURLPathPattern.test(trimmedPath)) return
|
|
10746
|
-
return
|
|
11104
|
+
if (absoluteURLPathPattern.test(trimmedPath) || protocolRelativeURLPathPattern.test(trimmedPath)) return G.err(new InvalidRelativeURLPath({ path }));
|
|
11105
|
+
return G.ok(stripLeadingSlashes(path));
|
|
10747
11106
|
};
|
|
10748
11107
|
const createURLResult = (baseURL, path) => {
|
|
10749
11108
|
const parsedPath = parseRelativeURLPath(path);
|
|
10750
|
-
if (
|
|
11109
|
+
if (G.isError(parsedPath)) return G.err(parsedPath.error);
|
|
10751
11110
|
try {
|
|
10752
|
-
return
|
|
11111
|
+
return G.ok(new URL(parsedPath.value, ensureTrailingSlash(stripTrailingSlashes(baseURL.toString()))));
|
|
10753
11112
|
} catch {
|
|
10754
|
-
return
|
|
11113
|
+
return G.err(new InvalidBaseURL({ baseURL: baseURL.toString() }));
|
|
10755
11114
|
}
|
|
10756
11115
|
};
|
|
10757
11116
|
const createURL = (baseURL, path) => {
|
|
10758
11117
|
const url = createURLResult(baseURL, path);
|
|
10759
|
-
if (
|
|
11118
|
+
if (G.isError(url)) throw url.error;
|
|
10760
11119
|
return url.value;
|
|
10761
11120
|
};
|
|
10762
11121
|
const createAbsoluteURL = (baseURL, path) => createURL(baseURL, path).toString();
|
|
10763
|
-
|
|
11122
|
+
h("MissingPathTemplateParam")();
|
|
10764
11123
|
//#endregion
|
|
10765
11124
|
//#region ../../node_modules/.bun/ky@2.0.2/node_modules/ky/distribution/errors/KyError.js
|
|
10766
11125
|
/**
|
|
@@ -12047,8 +12406,8 @@ object({
|
|
|
12047
12406
|
status: number(),
|
|
12048
12407
|
type: string()
|
|
12049
12408
|
});
|
|
12050
|
-
|
|
12051
|
-
|
|
12409
|
+
h("UnipileAPIError")();
|
|
12410
|
+
h("UnipileHostedAuthURLMissingError")();
|
|
12052
12411
|
looseObject({
|
|
12053
12412
|
object: literal("HostedAuthLink"),
|
|
12054
12413
|
link: string()
|
|
@@ -12084,7 +12443,7 @@ const SocialTargetPrefixes = {
|
|
|
12084
12443
|
company_id: "company",
|
|
12085
12444
|
request_id: "request"
|
|
12086
12445
|
};
|
|
12087
|
-
var InvalidSocialSelector = class extends
|
|
12446
|
+
var InvalidSocialSelector = class extends h("InvalidSocialSelector")() {
|
|
12088
12447
|
constructor({ value, reason }) {
|
|
12089
12448
|
super({
|
|
12090
12449
|
value,
|
|
@@ -12145,42 +12504,42 @@ const linkedInURNKindFrom = (value) => {
|
|
|
12145
12504
|
};
|
|
12146
12505
|
const parseTypedSocialSelector = (value, options = {}) => {
|
|
12147
12506
|
const parsed = parseTypedSocialSelectorResult(value, options);
|
|
12148
|
-
return
|
|
12507
|
+
return G.isOk(parsed) ? parsed.value : void 0;
|
|
12149
12508
|
};
|
|
12150
12509
|
const parseTypedSocialSelectorResult = (value, options = {}) => {
|
|
12151
12510
|
const trimmed = value.trim();
|
|
12152
12511
|
const colon = trimmed.indexOf(":");
|
|
12153
|
-
if (colon <= 0) return
|
|
12512
|
+
if (colon <= 0) return G.err(new InvalidSocialSelector({
|
|
12154
12513
|
value,
|
|
12155
12514
|
reason: "missing-prefix"
|
|
12156
12515
|
}));
|
|
12157
12516
|
const prefix = trimmed.slice(0, colon);
|
|
12158
|
-
if (!isSocialTargetPrefix(prefix)) return
|
|
12517
|
+
if (!isSocialTargetPrefix(prefix)) return G.err(new InvalidSocialSelector({
|
|
12159
12518
|
value,
|
|
12160
12519
|
reason: "unsupported-prefix"
|
|
12161
12520
|
}));
|
|
12162
|
-
if (options.prefixes && !options.prefixes.includes(prefix)) return
|
|
12521
|
+
if (options.prefixes && !options.prefixes.includes(prefix)) return G.err(new InvalidSocialSelector({
|
|
12163
12522
|
value,
|
|
12164
12523
|
reason: "disallowed-prefix"
|
|
12165
12524
|
}));
|
|
12166
12525
|
const id = trimmed.slice(colon + 1).trim();
|
|
12167
|
-
if (options.idMode === "lenient") return
|
|
12526
|
+
if (options.idMode === "lenient") return G.ok({
|
|
12168
12527
|
prefix,
|
|
12169
12528
|
kind: SocialTargetPrefixes[prefix],
|
|
12170
12529
|
id
|
|
12171
12530
|
});
|
|
12172
12531
|
const parsed = plainResourceIdSchema(prefix).safeParse(id);
|
|
12173
|
-
return parsed.success ?
|
|
12532
|
+
return parsed.success ? G.ok({
|
|
12174
12533
|
prefix,
|
|
12175
12534
|
kind: SocialTargetPrefixes[prefix],
|
|
12176
12535
|
id: parsed.data
|
|
12177
|
-
}) :
|
|
12536
|
+
}) : G.err(new InvalidSocialSelector({
|
|
12178
12537
|
value,
|
|
12179
12538
|
reason: "invalid-id"
|
|
12180
12539
|
}));
|
|
12181
12540
|
};
|
|
12182
|
-
|
|
12183
|
-
|
|
12541
|
+
h("InvalidLinkedinUpstreamPlanInput")();
|
|
12542
|
+
h("InvalidUnipileCredentials")();
|
|
12184
12543
|
//#endregion
|
|
12185
12544
|
//#region ../../packages/linkedin/src/profiles.ts
|
|
12186
12545
|
const displayNameFrom = (firstName, lastName, username) => [firstName, lastName].filter(Boolean).join(" ").trim() || username || "";
|
|
@@ -12299,8 +12658,8 @@ looseObject({
|
|
|
12299
12658
|
data: array(GroupParticipant),
|
|
12300
12659
|
next_cursor: string().nullish()
|
|
12301
12660
|
});
|
|
12302
|
-
|
|
12303
|
-
|
|
12661
|
+
h("ChatListParseError")();
|
|
12662
|
+
h("ChatParticipantsFetchError")();
|
|
12304
12663
|
const linkedinProfileExtractors = {
|
|
12305
12664
|
"GET /users/me": extractProfile$1,
|
|
12306
12665
|
"GET /users/:identifier": extractProfile$1,
|
|
@@ -14268,7 +14627,7 @@ const isoDatePattern = /^\d{4}-(0[1-9]|1[0-2])-(0[1-9]|[12]\d|3[01])$/;
|
|
|
14268
14627
|
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
14628
|
const timezonePattern = /(Z|[+-]\d{2}:\d{2})$/;
|
|
14270
14629
|
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
|
|
14630
|
+
var InvalidSince = class extends h("InvalidSince")() {
|
|
14272
14631
|
constructor(input) {
|
|
14273
14632
|
super({
|
|
14274
14633
|
input,
|
|
@@ -14296,23 +14655,23 @@ const parseSinceResult = (input) => {
|
|
|
14296
14655
|
const isISODateTime = isoDateTimePattern.test(value);
|
|
14297
14656
|
const normalized = isISODateTime && !timezonePattern.test(value) ? `${value}Z` : value;
|
|
14298
14657
|
const parsed = (isISODate || isISODateTime) && hasValidDate(value) ? Date.parse(normalized) : NaN;
|
|
14299
|
-
if (Number.isNaN(parsed)) return
|
|
14300
|
-
return
|
|
14658
|
+
if (Number.isNaN(parsed)) return G.err(new InvalidSince(input));
|
|
14659
|
+
return G.ok(parsed);
|
|
14301
14660
|
};
|
|
14302
14661
|
//#endregion
|
|
14303
14662
|
//#region ../../packages/linkedin/src/cli/sync-plan.ts
|
|
14304
|
-
var UnknownLinkedinSyncCollection = class extends
|
|
14305
|
-
var LinkedinSyncResetRequiresCollection = class extends
|
|
14663
|
+
var UnknownLinkedinSyncCollection = class extends h("UnknownLinkedinSyncCollection")() {};
|
|
14664
|
+
var LinkedinSyncResetRequiresCollection = class extends h("LinkedinSyncResetRequiresCollection")() {
|
|
14306
14665
|
constructor() {
|
|
14307
14666
|
super({ message: "--reset requires a collection" });
|
|
14308
14667
|
}
|
|
14309
14668
|
};
|
|
14310
|
-
var LinkedinSyncResetWithSince = class extends
|
|
14669
|
+
var LinkedinSyncResetWithSince = class extends h("LinkedinSyncResetWithSince")() {
|
|
14311
14670
|
constructor() {
|
|
14312
14671
|
super({ message: "--reset cannot be combined with --since" });
|
|
14313
14672
|
}
|
|
14314
14673
|
};
|
|
14315
|
-
var LinkedinSyncUnsupportedSince = class extends
|
|
14674
|
+
var LinkedinSyncUnsupportedSince = class extends h("LinkedinSyncUnsupportedSince")() {
|
|
14316
14675
|
constructor(collection) {
|
|
14317
14676
|
super({
|
|
14318
14677
|
collection,
|
|
@@ -14320,7 +14679,7 @@ var LinkedinSyncUnsupportedSince = class extends TaggedError("LinkedinSyncUnsupp
|
|
|
14320
14679
|
});
|
|
14321
14680
|
}
|
|
14322
14681
|
};
|
|
14323
|
-
var LinkedinSyncMissingInitialFullSync = class extends
|
|
14682
|
+
var LinkedinSyncMissingInitialFullSync = class extends h("LinkedinSyncMissingInitialFullSync")() {
|
|
14324
14683
|
constructor(collection) {
|
|
14325
14684
|
super({
|
|
14326
14685
|
collection,
|
|
@@ -14328,36 +14687,36 @@ var LinkedinSyncMissingInitialFullSync = class extends TaggedError("LinkedinSync
|
|
|
14328
14687
|
});
|
|
14329
14688
|
}
|
|
14330
14689
|
};
|
|
14331
|
-
var InvalidLinkedinSyncSince = class extends
|
|
14690
|
+
var InvalidLinkedinSyncSince = class extends h("InvalidLinkedinSyncSince")() {};
|
|
14332
14691
|
const linkedinSyncCollectionShortName = (collection) => collection.key.replace(/^(x|li)_/, "");
|
|
14333
14692
|
const linkedinSyncCollectionFor = (collections, collection) => {
|
|
14334
14693
|
const found = collections.find((candidate) => linkedinSyncCollectionShortName(candidate) === collection || candidate.key === collection);
|
|
14335
|
-
if (found) return
|
|
14694
|
+
if (found) return G.ok(found);
|
|
14336
14695
|
const available = collections.map(linkedinSyncCollectionShortName);
|
|
14337
|
-
return
|
|
14696
|
+
return G.err(new UnknownLinkedinSyncCollection({
|
|
14338
14697
|
collection,
|
|
14339
14698
|
available,
|
|
14340
14699
|
message: `Unknown collection "${collection}". Available: ${available.join(", ")}`
|
|
14341
14700
|
}));
|
|
14342
14701
|
};
|
|
14343
14702
|
const planLinkedinSyncCommand = ({ args, collections, cursorState }) => {
|
|
14344
|
-
if (!args.collection) return args.reset === true ?
|
|
14703
|
+
if (!args.collection) return args.reset === true ? G.err(new LinkedinSyncResetRequiresCollection()) : G.ok({ mode: "list" });
|
|
14345
14704
|
const collection = linkedinSyncCollectionFor(collections, String(args.collection));
|
|
14346
|
-
if (
|
|
14347
|
-
if (args.reset === true) return args.since == null ?
|
|
14705
|
+
if (G.isError(collection)) return G.err(collection.error);
|
|
14706
|
+
if (args.reset === true) return args.since == null ? G.ok({
|
|
14348
14707
|
mode: "reset",
|
|
14349
14708
|
collection: collection.value
|
|
14350
|
-
}) :
|
|
14351
|
-
if (args.since == null) return
|
|
14709
|
+
}) : G.err(new LinkedinSyncResetWithSince());
|
|
14710
|
+
if (args.since == null) return G.ok({
|
|
14352
14711
|
mode: "run",
|
|
14353
14712
|
collection: collection.value
|
|
14354
14713
|
});
|
|
14355
14714
|
const shortName = linkedinSyncCollectionShortName(collection.value);
|
|
14356
|
-
if (!collection.value.sinceField) return
|
|
14357
|
-
if (collection.value.requiresFullInitialSync && cursorState?.lastSynced == null) return
|
|
14715
|
+
if (!collection.value.sinceField) return G.err(new LinkedinSyncUnsupportedSince(shortName));
|
|
14716
|
+
if (collection.value.requiresFullInitialSync && cursorState?.lastSynced == null) return G.err(new LinkedinSyncMissingInitialFullSync(shortName));
|
|
14358
14717
|
const parsedSince = parseSinceResult(String(args.since));
|
|
14359
|
-
if (
|
|
14360
|
-
return
|
|
14718
|
+
if (G.isError(parsedSince)) return G.err(new InvalidLinkedinSyncSince({ message: parsedSince.error.message }));
|
|
14719
|
+
return G.ok({
|
|
14361
14720
|
mode: "run",
|
|
14362
14721
|
collection: collection.value,
|
|
14363
14722
|
since: parsedSince.value
|
|
@@ -14787,7 +15146,7 @@ const buildSync$1 = (deps, platform) => defineCommand({
|
|
|
14787
15146
|
}
|
|
14788
15147
|
})() : void 0
|
|
14789
15148
|
});
|
|
14790
|
-
if (
|
|
15149
|
+
if (G.isError(plan)) throw new UsageError(plan.error.message);
|
|
14791
15150
|
if (plan.value.mode === "list") {
|
|
14792
15151
|
const cache = openLinkedinCache({
|
|
14793
15152
|
platform,
|
|
@@ -14864,7 +15223,7 @@ const buildSync$1 = (deps, platform) => defineCommand({
|
|
|
14864
15223
|
if (rateLimitError) throw rateLimitError;
|
|
14865
15224
|
throw error;
|
|
14866
15225
|
}
|
|
14867
|
-
if (
|
|
15226
|
+
if (G.isError(result)) {
|
|
14868
15227
|
progress.error();
|
|
14869
15228
|
const rateLimitError = enrichRateLimitSyncError$1({
|
|
14870
15229
|
error: result.error,
|
|
@@ -14973,7 +15332,7 @@ const buildSql$1 = (deps, platform) => defineCommand({
|
|
|
14973
15332
|
} catch (error) {
|
|
14974
15333
|
throw new UsageError(`Query failed (cache is read-only): ${error instanceof Error ? error.message : String(error)}`);
|
|
14975
15334
|
}
|
|
14976
|
-
if (
|
|
15335
|
+
if (G.isError(result)) throw new UsageError(`Query failed (cache is read-only): ${result.error.message}`);
|
|
14977
15336
|
await deps.printResult({
|
|
14978
15337
|
account: res.account,
|
|
14979
15338
|
contract,
|
|
@@ -19015,7 +19374,7 @@ const contractFor$1 = (op, commandName, group) => buildRuntimeContract(xRuntimeA
|
|
|
19015
19374
|
const defineOperationCommand = (op, deps) => defineRuntimeOperationCommand(xRuntimeAdapter, op, deps);
|
|
19016
19375
|
//#endregion
|
|
19017
19376
|
//#region ../../packages/x/src/cli/sync-plan.ts
|
|
19018
|
-
var XSyncPlanError = class extends
|
|
19377
|
+
var XSyncPlanError = class extends h("XSyncPlanError")() {
|
|
19019
19378
|
constructor(args) {
|
|
19020
19379
|
super(args);
|
|
19021
19380
|
this.name = "XSyncPlanError";
|
|
@@ -19024,30 +19383,30 @@ var XSyncPlanError = class extends TaggedError("XSyncPlanError")() {
|
|
|
19024
19383
|
const shortSyncCollectionName = (collection) => collection.key.replace(/^(x|li)_/, "");
|
|
19025
19384
|
const findSyncCollection = (collections, input) => collections.find((collection) => shortSyncCollectionName(collection) === input || collection.key === input);
|
|
19026
19385
|
const parseTimeoutSeconds = (value) => {
|
|
19027
|
-
if (value == null) return
|
|
19386
|
+
if (value == null) return G.ok(void 0);
|
|
19028
19387
|
const timeoutSeconds = Number(value);
|
|
19029
|
-
if (!Number.isInteger(timeoutSeconds) || timeoutSeconds < 1) return
|
|
19388
|
+
if (!Number.isInteger(timeoutSeconds) || timeoutSeconds < 1) return G.err(new XSyncPlanError({
|
|
19030
19389
|
kind: "invalid-timeout",
|
|
19031
19390
|
message: "--timeout must be at least 1."
|
|
19032
19391
|
}));
|
|
19033
|
-
return
|
|
19392
|
+
return G.ok(timeoutSeconds);
|
|
19034
19393
|
};
|
|
19035
19394
|
const planXSync = (input) => {
|
|
19036
19395
|
const accountSelector = input.accountSelector;
|
|
19037
|
-
if (accountSelector === void 0 || accountSelector.length === 0) return
|
|
19396
|
+
if (accountSelector === void 0 || accountSelector.length === 0) return G.err(new XSyncPlanError({
|
|
19038
19397
|
kind: "missing-account-selector",
|
|
19039
19398
|
message: "Selected X account is missing an account selector."
|
|
19040
19399
|
}));
|
|
19041
19400
|
const timeout = parseTimeoutSeconds(input.timeout);
|
|
19042
|
-
if (
|
|
19401
|
+
if (G.isError(timeout)) return G.err(timeout.error);
|
|
19043
19402
|
const accountHeaders = { "x-social-account-id": accountSelector };
|
|
19044
19403
|
const collectionInput = typeof input.collection === "string" && input.collection.length > 0 ? input.collection : void 0;
|
|
19045
19404
|
if (collectionInput === void 0) {
|
|
19046
|
-
if (input.reset === true) return
|
|
19405
|
+
if (input.reset === true) return G.err(new XSyncPlanError({
|
|
19047
19406
|
kind: "reset-without-collection",
|
|
19048
19407
|
message: "--reset requires a collection"
|
|
19049
19408
|
}));
|
|
19050
|
-
return
|
|
19409
|
+
return G.ok({
|
|
19051
19410
|
kind: "list",
|
|
19052
19411
|
accountHeaders,
|
|
19053
19412
|
accountSelector,
|
|
@@ -19055,19 +19414,19 @@ const planXSync = (input) => {
|
|
|
19055
19414
|
});
|
|
19056
19415
|
}
|
|
19057
19416
|
const collection = findSyncCollection(input.collections, collectionInput);
|
|
19058
|
-
if (collection === void 0) return
|
|
19417
|
+
if (collection === void 0) return G.err(new XSyncPlanError({
|
|
19059
19418
|
kind: "unknown-collection",
|
|
19060
19419
|
collection: collectionInput,
|
|
19061
19420
|
message: `Unknown collection "${collectionInput}". Available: ${input.collections.map(shortSyncCollectionName).join(", ")}`
|
|
19062
19421
|
}));
|
|
19063
19422
|
if (input.reset === true) {
|
|
19064
|
-
if (input.since != null) return
|
|
19423
|
+
if (input.since != null) return G.err(new XSyncPlanError({
|
|
19065
19424
|
kind: "reset-with-since",
|
|
19066
19425
|
collection: collection.key,
|
|
19067
19426
|
message: "--reset cannot be combined with --since"
|
|
19068
19427
|
}));
|
|
19069
19428
|
const resetCollections = resetTablesFor(collection);
|
|
19070
|
-
return
|
|
19429
|
+
return G.ok({
|
|
19071
19430
|
kind: "reset",
|
|
19072
19431
|
accountHeaders,
|
|
19073
19432
|
accountSelector,
|
|
@@ -19078,20 +19437,20 @@ const planXSync = (input) => {
|
|
|
19078
19437
|
}
|
|
19079
19438
|
let since;
|
|
19080
19439
|
if (input.since != null) {
|
|
19081
|
-
if (!collection.sinceField) return
|
|
19440
|
+
if (!collection.sinceField) return G.err(new XSyncPlanError({
|
|
19082
19441
|
kind: "since-unsupported",
|
|
19083
19442
|
collection: collection.key,
|
|
19084
19443
|
message: `${shortSyncCollectionName(collection)} does not support --since`
|
|
19085
19444
|
}));
|
|
19086
19445
|
const parsedSince = parseSinceResult(String(input.since));
|
|
19087
|
-
if (
|
|
19446
|
+
if (G.isError(parsedSince)) return G.err(new XSyncPlanError({
|
|
19088
19447
|
kind: "since-unsupported",
|
|
19089
19448
|
collection: collection.key,
|
|
19090
19449
|
message: parsedSince.error.message
|
|
19091
19450
|
}));
|
|
19092
19451
|
since = parsedSince.value;
|
|
19093
19452
|
}
|
|
19094
|
-
return
|
|
19453
|
+
return G.ok({
|
|
19095
19454
|
kind: "run",
|
|
19096
19455
|
accountHeaders,
|
|
19097
19456
|
accountSelector,
|
|
@@ -19102,7 +19461,7 @@ const planXSync = (input) => {
|
|
|
19102
19461
|
};
|
|
19103
19462
|
//#endregion
|
|
19104
19463
|
//#region ../../packages/x/src/cli/write-plan.ts
|
|
19105
|
-
var XWritePlanError = class extends
|
|
19464
|
+
var XWritePlanError = class extends h("XWritePlanError")() {
|
|
19106
19465
|
constructor(args) {
|
|
19107
19466
|
super(args);
|
|
19108
19467
|
this.name = "XWritePlanError";
|
|
@@ -19124,16 +19483,16 @@ const responseString = (data, keys) => {
|
|
|
19124
19483
|
const responseMediaIdResult = (data) => {
|
|
19125
19484
|
const root = isObjectRecord$1(data) ? data : void 0;
|
|
19126
19485
|
const id = (isObjectRecord$1(root?.data) ? root.data : void 0)?.id ?? root?.id;
|
|
19127
|
-
if (typeof id !== "string" && typeof id !== "number") return
|
|
19486
|
+
if (typeof id !== "string" && typeof id !== "number") return G.err(new XWritePlanError({
|
|
19128
19487
|
kind: "missing-media-id",
|
|
19129
19488
|
message: "Media upload did not return a media id."
|
|
19130
19489
|
}));
|
|
19131
|
-
return
|
|
19490
|
+
return G.ok(String(id));
|
|
19132
19491
|
};
|
|
19133
|
-
const requiredTargetResult = (target) => target === void 0 ?
|
|
19492
|
+
const requiredTargetResult = (target) => target === void 0 ? G.err(new XWritePlanError({
|
|
19134
19493
|
kind: "missing-target",
|
|
19135
19494
|
message: "target is required."
|
|
19136
|
-
})) :
|
|
19495
|
+
})) : G.ok(target);
|
|
19137
19496
|
const postMediaByExtension = {
|
|
19138
19497
|
".gif": {
|
|
19139
19498
|
mediaType: "image/gif",
|
|
@@ -19166,22 +19525,22 @@ const postMediaByExtension = {
|
|
|
19166
19525
|
};
|
|
19167
19526
|
const parsePostMediaFileResult = (path) => {
|
|
19168
19527
|
const media = postMediaByExtension[extname(path).toLowerCase()];
|
|
19169
|
-
if (media === void 0) return
|
|
19528
|
+
if (media === void 0) return G.err(new XWritePlanError({
|
|
19170
19529
|
kind: "invalid-media-type",
|
|
19171
19530
|
message: `Unsupported media type for ${path}. Supported types: jpg, jpeg, png, webp, gif, mp4, mov.`
|
|
19172
19531
|
}));
|
|
19173
|
-
return
|
|
19532
|
+
return G.ok({
|
|
19174
19533
|
...media,
|
|
19175
19534
|
path
|
|
19176
19535
|
});
|
|
19177
19536
|
};
|
|
19178
19537
|
const parsePostMediaIdResult = (value) => {
|
|
19179
19538
|
const mediaId = value.trim();
|
|
19180
|
-
if (mediaId.length === 0) return
|
|
19539
|
+
if (mediaId.length === 0) return G.err(new XWritePlanError({
|
|
19181
19540
|
kind: "empty-media-id",
|
|
19182
19541
|
message: "--media-id cannot be empty."
|
|
19183
19542
|
}));
|
|
19184
|
-
return
|
|
19543
|
+
return G.ok(mediaId);
|
|
19185
19544
|
};
|
|
19186
19545
|
const postBodyHasText = (body) => {
|
|
19187
19546
|
const text = body?.text;
|
|
@@ -19193,7 +19552,7 @@ const postBodyMediaIds = (body) => {
|
|
|
19193
19552
|
};
|
|
19194
19553
|
const postBodyHasPoll = (body) => isObjectRecord$1(body?.poll);
|
|
19195
19554
|
const validatePostMediaResult = (mediaFiles, mediaIds) => {
|
|
19196
|
-
if (mediaFiles.length + mediaIds.length > 4) return
|
|
19555
|
+
if (mediaFiles.length + mediaIds.length > 4) return G.err(new XWritePlanError({
|
|
19197
19556
|
kind: "invalid-media-mix",
|
|
19198
19557
|
message: "Attach at most 4 media items."
|
|
19199
19558
|
}));
|
|
@@ -19205,35 +19564,35 @@ const validatePostMediaResult = (mediaFiles, mediaIds) => {
|
|
|
19205
19564
|
gifCount > 0,
|
|
19206
19565
|
videoCount > 0
|
|
19207
19566
|
].filter(Boolean).length;
|
|
19208
|
-
if (imageCount > 4) return
|
|
19567
|
+
if (imageCount > 4) return G.err(new XWritePlanError({
|
|
19209
19568
|
kind: "invalid-media-mix",
|
|
19210
19569
|
message: "Attach at most 4 images."
|
|
19211
19570
|
}));
|
|
19212
|
-
if (gifCount > 1) return
|
|
19571
|
+
if (gifCount > 1) return G.err(new XWritePlanError({
|
|
19213
19572
|
kind: "invalid-media-mix",
|
|
19214
19573
|
message: "Attach at most 1 GIF."
|
|
19215
19574
|
}));
|
|
19216
|
-
if (videoCount > 1) return
|
|
19575
|
+
if (videoCount > 1) return G.err(new XWritePlanError({
|
|
19217
19576
|
kind: "invalid-media-mix",
|
|
19218
19577
|
message: "Attach at most 1 video."
|
|
19219
19578
|
}));
|
|
19220
|
-
if (localCategoryCount > 1) return
|
|
19579
|
+
if (localCategoryCount > 1) return G.err(new XWritePlanError({
|
|
19221
19580
|
kind: "invalid-media-mix",
|
|
19222
19581
|
message: "Do not mix images, GIFs, and videos in one post."
|
|
19223
19582
|
}));
|
|
19224
|
-
return
|
|
19583
|
+
return G.ok();
|
|
19225
19584
|
};
|
|
19226
19585
|
const validatePostPollMediaResult = (args) => {
|
|
19227
19586
|
const explicitMediaCount = args.mediaFiles.length + args.mediaIds.length;
|
|
19228
19587
|
const bodyMediaIds = explicitMediaCount > 0 ? [] : postBodyMediaIds(args.bodyFields);
|
|
19229
19588
|
const hasMedia = explicitMediaCount + bodyMediaIds.length > 0;
|
|
19230
19589
|
const hasPoll = args.poll !== void 0 || postBodyHasPoll(args.bodyFields);
|
|
19231
|
-
if (hasPoll && hasMedia) return
|
|
19590
|
+
if (hasPoll && hasMedia) return G.err(new XWritePlanError({
|
|
19232
19591
|
kind: "invalid-media-mix",
|
|
19233
19592
|
message: "--poll-option cannot be combined with media attachments."
|
|
19234
19593
|
}));
|
|
19235
19594
|
const media = validatePostMediaResult(args.mediaFiles, [...args.mediaIds, ...bodyMediaIds]);
|
|
19236
|
-
return
|
|
19595
|
+
return G.isError(media) ? G.err(media.error) : G.ok({
|
|
19237
19596
|
bodyMediaIds,
|
|
19238
19597
|
hasMedia,
|
|
19239
19598
|
hasPoll
|
|
@@ -19303,12 +19662,12 @@ const planPostRequest = (args) => {
|
|
|
19303
19662
|
};
|
|
19304
19663
|
};
|
|
19305
19664
|
const planMessageRequestResult = (args) => {
|
|
19306
|
-
if (args.body === void 0) return
|
|
19665
|
+
if (args.body === void 0) return G.err(new XWritePlanError({
|
|
19307
19666
|
kind: "missing-message-body",
|
|
19308
19667
|
message: "Message body is required."
|
|
19309
19668
|
}));
|
|
19310
19669
|
const text = typeof args.body.text === "string" ? args.body.text : void 0;
|
|
19311
|
-
if (args.threadResolution !== void 0) return
|
|
19670
|
+
if (args.threadResolution !== void 0) return G.ok({
|
|
19312
19671
|
method: "POST",
|
|
19313
19672
|
path: `x/dm_conversations/${encodeURIComponent(args.threadResolution.id)}/messages`,
|
|
19314
19673
|
headers: args.headers,
|
|
@@ -19320,11 +19679,11 @@ const planMessageRequestResult = (args) => {
|
|
|
19320
19679
|
});
|
|
19321
19680
|
if (args.recipients.length === 1) {
|
|
19322
19681
|
const [participant] = args.participantResolutions;
|
|
19323
|
-
if (participant === void 0) return
|
|
19682
|
+
if (participant === void 0) return G.err(new XWritePlanError({
|
|
19324
19683
|
kind: "missing-target",
|
|
19325
19684
|
message: "Pass at least one recipient."
|
|
19326
19685
|
}));
|
|
19327
|
-
return
|
|
19686
|
+
return G.ok({
|
|
19328
19687
|
method: "POST",
|
|
19329
19688
|
path: `x/dm_conversations/with/${encodeURIComponent(participant.id)}/messages`,
|
|
19330
19689
|
headers: args.headers,
|
|
@@ -19337,7 +19696,7 @@ const planMessageRequestResult = (args) => {
|
|
|
19337
19696
|
}
|
|
19338
19697
|
const participantIds = args.participantResolutions.map((resolution) => resolution.id);
|
|
19339
19698
|
const { text: bodyText, ...bodyFields } = args.body;
|
|
19340
|
-
return
|
|
19699
|
+
return G.ok({
|
|
19341
19700
|
method: "POST",
|
|
19342
19701
|
path: "x/dm_conversations",
|
|
19343
19702
|
headers: args.headers,
|
|
@@ -19816,7 +20175,7 @@ const buildSync = (deps, platform) => defineCommand({
|
|
|
19816
20175
|
since: args.since,
|
|
19817
20176
|
timeout: args.timeout
|
|
19818
20177
|
});
|
|
19819
|
-
if (
|
|
20178
|
+
if (G.isError(planned)) throw new UsageError(planned.error instanceof XSyncPlanError ? planned.error.message : String(planned.error));
|
|
19820
20179
|
const plan = planned.value;
|
|
19821
20180
|
if (plan.kind === "list") {
|
|
19822
20181
|
const cache = openXCacheFor(deps, {
|
|
@@ -19884,7 +20243,7 @@ const buildSync = (deps, platform) => defineCommand({
|
|
|
19884
20243
|
if (rateLimitError) throw rateLimitError;
|
|
19885
20244
|
throw error;
|
|
19886
20245
|
}
|
|
19887
|
-
if (
|
|
20246
|
+
if (G.isError(result)) {
|
|
19888
20247
|
const rateLimitError = enrichRateLimitSyncError({
|
|
19889
20248
|
error: result.error,
|
|
19890
20249
|
platform,
|
|
@@ -19991,7 +20350,7 @@ const buildSql = (deps, platform) => {
|
|
|
19991
20350
|
} catch (error) {
|
|
19992
20351
|
throw new UsageError(`Query failed (cache is read-only): ${errorMessageFrom(error)}`);
|
|
19993
20352
|
}
|
|
19994
|
-
if (
|
|
20353
|
+
if (G.isError(result)) throw new UsageError(`Query failed (cache is read-only): ${result.error.message}`);
|
|
19995
20354
|
await deps.printResult({
|
|
19996
20355
|
account: account.account,
|
|
19997
20356
|
contract: schemaContract,
|
|
@@ -20076,7 +20435,7 @@ const throwWritePlanError = (error) => {
|
|
|
20076
20435
|
};
|
|
20077
20436
|
const requireWriteTarget = (target) => {
|
|
20078
20437
|
const required = requiredTargetResult(target);
|
|
20079
|
-
if (
|
|
20438
|
+
if (G.isError(required)) return throwWritePlanError(required.error);
|
|
20080
20439
|
return required.value;
|
|
20081
20440
|
};
|
|
20082
20441
|
const executeWriteRequest = (deps, plan) => plan.method === "POST" ? deps.api.post(plan.path, {
|
|
@@ -20129,7 +20488,7 @@ const repeatableValues = (name, value, rawArgs) => {
|
|
|
20129
20488
|
};
|
|
20130
20489
|
const parsePostMediaId = (deps, value) => {
|
|
20131
20490
|
const mediaId = parsePostMediaIdResult(value);
|
|
20132
|
-
if (
|
|
20491
|
+
if (G.isError(mediaId)) throw new UsageError(mediaId.error.message);
|
|
20133
20492
|
return deps.parseResourceId("--media-id", mediaId.value);
|
|
20134
20493
|
};
|
|
20135
20494
|
const parsePostPoll = (deps, args, rawArgs) => {
|
|
@@ -20213,7 +20572,7 @@ const uploadPostMedia = async (deps, headers, media, timeoutSeconds) => {
|
|
|
20213
20572
|
initBody.set("total_bytes", String(file.byteLength));
|
|
20214
20573
|
initBody.set("media_category", media.category);
|
|
20215
20574
|
const mediaId = responseMediaIdResult(await (await postMediaForm(deps, "x/media/upload/init", headers, initBody)).json());
|
|
20216
|
-
if (
|
|
20575
|
+
if (G.isError(mediaId)) throw new UsageError(mediaId.error.message);
|
|
20217
20576
|
for (let segmentIndex = 0, offset = 0; offset < file.byteLength; segmentIndex += 1, offset += postMediaChunkSize) {
|
|
20218
20577
|
const chunk = file.subarray(offset, offset + postMediaChunkSize);
|
|
20219
20578
|
const appendBody = new FormData();
|
|
@@ -20475,7 +20834,7 @@ const buildPost = (deps) => {
|
|
|
20475
20834
|
const commandArgs = args;
|
|
20476
20835
|
const mediaFiles = repeatableValues("media", commandArgs.media, rawArgs).map((path) => {
|
|
20477
20836
|
const media = parsePostMediaFileResult(path);
|
|
20478
|
-
if (
|
|
20837
|
+
if (G.isError(media)) throw new UsageError(media.error.message);
|
|
20479
20838
|
return media.value;
|
|
20480
20839
|
});
|
|
20481
20840
|
const mediaIds = repeatableValues("media-id", commandArgs["media-id"], rawArgs).map((mediaId) => parsePostMediaId(deps, mediaId));
|
|
@@ -20487,7 +20846,7 @@ const buildPost = (deps) => {
|
|
|
20487
20846
|
mediaIds,
|
|
20488
20847
|
poll
|
|
20489
20848
|
});
|
|
20490
|
-
if (
|
|
20849
|
+
if (G.isError(postInputs)) throw new UsageError(postInputs.error.message);
|
|
20491
20850
|
const timeoutSeconds = commandArgs.timeout === void 0 ? postMediaProcessingTimeoutSeconds : deps.parseIntegerString("--timeout", commandArgs.timeout, { min: 1 });
|
|
20492
20851
|
const stdinBody = await readPostStdinBody(deps, postInputs.value.hasMedia, bodyFields);
|
|
20493
20852
|
const account = typeof commandArgs.account === "string" ? commandArgs.account : void 0;
|
|
@@ -20799,7 +21158,7 @@ const buildMessage = (deps) => {
|
|
|
20799
21158
|
recipients,
|
|
20800
21159
|
threadResolution
|
|
20801
21160
|
});
|
|
20802
|
-
if (
|
|
21161
|
+
if (G.isError(request)) throw new UsageError(request.error.message);
|
|
20803
21162
|
const response = await deps.api.post(request.value.path, {
|
|
20804
21163
|
headers: request.value.headers,
|
|
20805
21164
|
json: request.value.body
|
|
@@ -21080,10 +21439,10 @@ createXCommands({
|
|
|
21080
21439
|
//#endregion
|
|
21081
21440
|
//#region ../../packages/linkedin/src/cli/lifecycle-plan.ts
|
|
21082
21441
|
const LINKEDIN_CONNECTED_STATUS = "connected";
|
|
21083
|
-
var InvalidLinkedinLifecycleTarget = class extends
|
|
21084
|
-
var LinkedinLifecycleNoAccountMatch = class extends
|
|
21085
|
-
var LinkedinLifecycleAmbiguousAccount = class extends
|
|
21086
|
-
var LinkedinLifecycleSeatTimeout = class extends
|
|
21442
|
+
var InvalidLinkedinLifecycleTarget = class extends h("InvalidLinkedinLifecycleTarget")() {};
|
|
21443
|
+
var LinkedinLifecycleNoAccountMatch = class extends h("LinkedinLifecycleNoAccountMatch")() {};
|
|
21444
|
+
var LinkedinLifecycleAmbiguousAccount = class extends h("LinkedinLifecycleAmbiguousAccount")() {};
|
|
21445
|
+
var LinkedinLifecycleSeatTimeout = class extends h("LinkedinLifecycleSeatTimeout")() {
|
|
21087
21446
|
constructor() {
|
|
21088
21447
|
super({ message: "billing_seat_timed_out" });
|
|
21089
21448
|
}
|
|
@@ -21093,22 +21452,22 @@ const parseLinkedinReconnectTarget = (value) => {
|
|
|
21093
21452
|
const trimmed = value.trim();
|
|
21094
21453
|
if (trimmed.startsWith("@")) {
|
|
21095
21454
|
const username = normalizeSocialIdentifier(trimmed);
|
|
21096
|
-
if (username) return
|
|
21455
|
+
if (username) return G.ok({
|
|
21097
21456
|
type: "username",
|
|
21098
21457
|
value: username
|
|
21099
21458
|
});
|
|
21100
21459
|
}
|
|
21101
21460
|
const profileSelector = parseTypedSocialSelector(trimmed, { prefixes: ["profile_id"] });
|
|
21102
|
-
if (profileSelector) return
|
|
21461
|
+
if (profileSelector) return G.ok({
|
|
21103
21462
|
type: "profileId",
|
|
21104
21463
|
value: profileSelector.id.toLowerCase()
|
|
21105
21464
|
});
|
|
21106
21465
|
const publicIdentifier = linkedInProfileIdentifierFromURL(trimmed);
|
|
21107
|
-
if (publicIdentifier) return
|
|
21466
|
+
if (publicIdentifier) return G.ok({
|
|
21108
21467
|
type: "username",
|
|
21109
21468
|
value: publicIdentifier
|
|
21110
21469
|
});
|
|
21111
|
-
return
|
|
21470
|
+
return G.err(new InvalidLinkedinLifecycleTarget({
|
|
21112
21471
|
value,
|
|
21113
21472
|
message: "LinkedIn reconnect account must be @username, a LinkedIn profile URL, or profile_id:<id>."
|
|
21114
21473
|
}));
|
|
@@ -21124,14 +21483,14 @@ const reconnectCommandTargetFor = (account) => {
|
|
|
21124
21483
|
const connectedLinkedinLifecycleAccounts = (accounts) => accounts.filter((account) => account.status === LINKEDIN_CONNECTED_STATUS);
|
|
21125
21484
|
const resolveLinkedinLifecycleAccount = (accounts, identifier) => {
|
|
21126
21485
|
const target = parseLinkedinReconnectTarget(identifier);
|
|
21127
|
-
if (
|
|
21486
|
+
if (G.isError(target)) return G.err(target.error);
|
|
21128
21487
|
const matches = accounts.filter((candidate) => linkedinLifecycleAccountMatchesTarget(candidate, target.value));
|
|
21129
|
-
if (matches.length === 1 && matches[0]) return
|
|
21130
|
-
if (matches.length === 0) return
|
|
21488
|
+
if (matches.length === 1 && matches[0]) return G.ok(matches[0]);
|
|
21489
|
+
if (matches.length === 0) return G.err(new LinkedinLifecycleNoAccountMatch({
|
|
21131
21490
|
value: identifier,
|
|
21132
21491
|
message: `No LinkedIn account matches "${identifier}".`
|
|
21133
21492
|
}));
|
|
21134
|
-
return
|
|
21493
|
+
return G.err(new LinkedinLifecycleAmbiguousAccount({
|
|
21135
21494
|
value: identifier,
|
|
21136
21495
|
message: `Multiple LinkedIn accounts match "${identifier}". Pass profile_id:<id>.`
|
|
21137
21496
|
}));
|
|
@@ -21139,9 +21498,9 @@ const resolveLinkedinLifecycleAccount = (accounts, identifier) => {
|
|
|
21139
21498
|
const resolveLinkedinDisconnectAccount = (accounts, identifier) => {
|
|
21140
21499
|
if (identifier) return resolveLinkedinLifecycleAccount(accounts, identifier);
|
|
21141
21500
|
const connected = connectedLinkedinLifecycleAccounts(accounts);
|
|
21142
|
-
if (connected.length === 1 && connected[0]) return
|
|
21143
|
-
if (connected.length === 0) return
|
|
21144
|
-
return
|
|
21501
|
+
if (connected.length === 1 && connected[0]) return G.ok(connected[0]);
|
|
21502
|
+
if (connected.length === 0) return G.err(new LinkedinLifecycleNoAccountMatch({ message: "No connected LinkedIn accounts found." }));
|
|
21503
|
+
return G.err(new LinkedinLifecycleAmbiguousAccount({ message: "Multiple LinkedIn accounts are connected. Pass a public identifier." }));
|
|
21145
21504
|
};
|
|
21146
21505
|
//#endregion
|
|
21147
21506
|
//#region ../../packages/linkedin/src/cli/lifecycle.ts
|
|
@@ -21149,15 +21508,9 @@ const LINKEDIN_PLATFORM = "linkedin";
|
|
|
21149
21508
|
const DEFAULT_POLL_INTERVAL_MS = 2e3;
|
|
21150
21509
|
const DEFAULT_POLL_TIMEOUT_MS = 12e4;
|
|
21151
21510
|
const SEAT_POLL_TIMEOUT_MS$2 = 600 * 1e3;
|
|
21152
|
-
const
|
|
21153
|
-
const openURL = async (deps, url, options = {}) => {
|
|
21511
|
+
const surfaceURL$1 = (deps, url, options = {}) => {
|
|
21154
21512
|
const log = deps.log ?? console.error;
|
|
21155
|
-
if (options.log ?? true) log(`
|
|
21156
|
-
if (!(isInteractiveTerminal$1(deps) && deps.openURL)) return {
|
|
21157
|
-
opened: false,
|
|
21158
|
-
url
|
|
21159
|
-
};
|
|
21160
|
-
return await Promise.resolve(deps.openURL(url));
|
|
21513
|
+
if (options.log ?? true) log(`Open this URL: ${url}`);
|
|
21161
21514
|
};
|
|
21162
21515
|
const pollForSeat$2 = async (deps) => {
|
|
21163
21516
|
const intervalMs = deps.pollIntervalMs ?? DEFAULT_POLL_INTERVAL_MS;
|
|
@@ -21173,7 +21526,7 @@ const prepareAccountConnect$1 = async (deps) => {
|
|
|
21173
21526
|
if ((await deps.client.billing.status()).canConnect) return;
|
|
21174
21527
|
const status = await deps.client.billing.prepareAccountConnect();
|
|
21175
21528
|
if (status.canConnect) return;
|
|
21176
|
-
if (status.paymentURL)
|
|
21529
|
+
if (status.paymentURL) surfaceURL$1(deps, status.paymentURL);
|
|
21177
21530
|
await pollForSeat$2(deps);
|
|
21178
21531
|
};
|
|
21179
21532
|
const accountUsername = (account) => account.username.replace(/^@+/, "");
|
|
@@ -21207,12 +21560,12 @@ const authURLFor$1 = async (deps, operation) => ({
|
|
|
21207
21560
|
});
|
|
21208
21561
|
const reconnectAccountForIdentifier = async (deps, identifier) => {
|
|
21209
21562
|
const account = resolveLinkedinLifecycleAccount(await listLinkedinLifecycleAccounts(deps), identifier);
|
|
21210
|
-
if (
|
|
21563
|
+
if (G.isError(account)) throw account.error;
|
|
21211
21564
|
return account.value;
|
|
21212
21565
|
};
|
|
21213
21566
|
const resolveDisconnectTarget = async (deps, identifier) => {
|
|
21214
21567
|
const account = resolveLinkedinDisconnectAccount(await listLinkedinLifecycleAccounts(deps, Boolean(identifier)), identifier);
|
|
21215
|
-
if (
|
|
21568
|
+
if (G.isError(account)) throw account.error;
|
|
21216
21569
|
return account.value;
|
|
21217
21570
|
};
|
|
21218
21571
|
const connectLinkedinAccount = async (deps) => {
|
|
@@ -21223,7 +21576,7 @@ const connectLinkedinAccount = async (deps) => {
|
|
|
21223
21576
|
platform: LINKEDIN_PLATFORM,
|
|
21224
21577
|
mode: "create"
|
|
21225
21578
|
})).url);
|
|
21226
|
-
|
|
21579
|
+
surfaceURL$1(deps, authURL.url, { log: !authURL.openingLogged });
|
|
21227
21580
|
return {
|
|
21228
21581
|
platform: LINKEDIN_PLATFORM,
|
|
21229
21582
|
status: "connected",
|
|
@@ -21237,7 +21590,7 @@ const reconnectLinkedinAccount = async (deps, identifier) => {
|
|
|
21237
21590
|
mode: "reconnect",
|
|
21238
21591
|
account: reconnectCommandTargetFor(account)
|
|
21239
21592
|
})).url);
|
|
21240
|
-
|
|
21593
|
+
surfaceURL$1(deps, authURL.url, { log: !authURL.openingLogged });
|
|
21241
21594
|
return {
|
|
21242
21595
|
platform: LINKEDIN_PLATFORM,
|
|
21243
21596
|
status: "connected",
|
|
@@ -21260,7 +21613,7 @@ const disconnectLinkedinAccount = async (deps, identifier) => {
|
|
|
21260
21613
|
const CONNECT_TIMEOUT_MS = 300 * 1e3;
|
|
21261
21614
|
const SEAT_POLL_TIMEOUT_MS$1 = 600 * 1e3;
|
|
21262
21615
|
const POLL_INTERVAL_MS = 2 * 1e3;
|
|
21263
|
-
var XConnectTimedOut = class extends
|
|
21616
|
+
var XConnectTimedOut = class extends h("XConnectTimedOut")() {
|
|
21264
21617
|
constructor(args) {
|
|
21265
21618
|
super({
|
|
21266
21619
|
...args,
|
|
@@ -21269,7 +21622,7 @@ var XConnectTimedOut = class extends TaggedError("XConnectTimedOut")() {
|
|
|
21269
21622
|
this.name = "XConnectTimedOut";
|
|
21270
21623
|
}
|
|
21271
21624
|
};
|
|
21272
|
-
var XBillingSeatTimedOut = class extends
|
|
21625
|
+
var XBillingSeatTimedOut = class extends h("XBillingSeatTimedOut")() {
|
|
21273
21626
|
constructor() {
|
|
21274
21627
|
super({
|
|
21275
21628
|
operation: "prepareAccountConnect",
|
|
@@ -21279,7 +21632,7 @@ var XBillingSeatTimedOut = class extends TaggedError("XBillingSeatTimedOut")() {
|
|
|
21279
21632
|
this.name = "XBillingSeatTimedOut";
|
|
21280
21633
|
}
|
|
21281
21634
|
};
|
|
21282
|
-
var XAccountNotFound = class extends
|
|
21635
|
+
var XAccountNotFound = class extends h("XAccountNotFound")() {
|
|
21283
21636
|
constructor(args) {
|
|
21284
21637
|
super({
|
|
21285
21638
|
...args,
|
|
@@ -21288,9 +21641,9 @@ var XAccountNotFound = class extends TaggedError("XAccountNotFound")() {
|
|
|
21288
21641
|
this.name = "XAccountNotFound";
|
|
21289
21642
|
}
|
|
21290
21643
|
};
|
|
21291
|
-
|
|
21292
|
-
|
|
21293
|
-
var XInvalidSelector = class extends
|
|
21644
|
+
h("XAccountNotConnected")();
|
|
21645
|
+
h("XAccountRequired")();
|
|
21646
|
+
var XInvalidSelector = class extends h("XInvalidSelector")() {
|
|
21294
21647
|
constructor(args) {
|
|
21295
21648
|
super({
|
|
21296
21649
|
...args,
|
|
@@ -21309,20 +21662,16 @@ const throwXLifecycleError = (error) => {
|
|
|
21309
21662
|
const defaultSleep = async (ms) => {
|
|
21310
21663
|
await new Promise((resolve) => setTimeout(resolve, ms));
|
|
21311
21664
|
};
|
|
21312
|
-
const resolveWebBaseURL = async (deps) => {
|
|
21313
|
-
return (typeof deps.webBaseURL === "function" ? await deps.webBaseURL() : deps.webBaseURL).replace(/\/+$/, "");
|
|
21314
|
-
};
|
|
21315
21665
|
const connectURLFor = async (deps, reconnectProfileId) => {
|
|
21316
|
-
|
|
21317
|
-
|
|
21318
|
-
|
|
21666
|
+
return (await deps.client.accounts.reconnectURL({
|
|
21667
|
+
platform: "x",
|
|
21668
|
+
mode: reconnectProfileId ? "reconnect" : "create",
|
|
21669
|
+
...reconnectProfileId ? { account: `profile_id:${reconnectProfileId}` } : {}
|
|
21670
|
+
})).url;
|
|
21319
21671
|
};
|
|
21320
|
-
const
|
|
21321
|
-
const openOrPrint = async (deps, url, options = {}) => {
|
|
21672
|
+
const surfaceURL = (deps, url, options = {}) => {
|
|
21322
21673
|
const log = deps.log ?? console.error;
|
|
21323
|
-
if (options.log ?? true) log(`
|
|
21324
|
-
if (!(isInteractiveTerminal(deps) && deps.openBrowser)) return;
|
|
21325
|
-
await deps.openBrowser(url);
|
|
21674
|
+
if (options.log ?? true) log(`Open this URL: ${url}`);
|
|
21326
21675
|
};
|
|
21327
21676
|
const pollForAccount = async (deps, operation, matches) => {
|
|
21328
21677
|
const sleep = deps.sleep ?? defaultSleep;
|
|
@@ -21333,10 +21682,10 @@ const pollForAccount = async (deps, operation, matches) => {
|
|
|
21333
21682
|
platform: "x",
|
|
21334
21683
|
includeDisconnected: true
|
|
21335
21684
|
})).find(matches);
|
|
21336
|
-
if (account) return
|
|
21685
|
+
if (account) return G.ok(account);
|
|
21337
21686
|
await sleep(POLL_INTERVAL_MS);
|
|
21338
21687
|
}
|
|
21339
|
-
return
|
|
21688
|
+
return G.err(new XConnectTimedOut({
|
|
21340
21689
|
operation,
|
|
21341
21690
|
timeoutMS: CONNECT_TIMEOUT_MS
|
|
21342
21691
|
}));
|
|
@@ -21350,16 +21699,16 @@ const pollForSeat$1 = async (deps) => {
|
|
|
21350
21699
|
const now = deps.now ?? Date.now;
|
|
21351
21700
|
const startedAt = now();
|
|
21352
21701
|
while (now() - startedAt < SEAT_POLL_TIMEOUT_MS$1) {
|
|
21353
|
-
if ((await deps.client.billing.status()).canConnect) return
|
|
21702
|
+
if ((await deps.client.billing.status()).canConnect) return G.ok();
|
|
21354
21703
|
await sleep(POLL_INTERVAL_MS);
|
|
21355
21704
|
}
|
|
21356
|
-
return
|
|
21705
|
+
return G.err(new XBillingSeatTimedOut());
|
|
21357
21706
|
};
|
|
21358
21707
|
const prepareAccountConnect = async (deps) => {
|
|
21359
|
-
if ((await deps.client.billing.status()).canConnect) return
|
|
21708
|
+
if ((await deps.client.billing.status()).canConnect) return G.ok();
|
|
21360
21709
|
const status = await deps.client.billing.prepareAccountConnect();
|
|
21361
|
-
if (status.canConnect) return
|
|
21362
|
-
if (status.paymentURL)
|
|
21710
|
+
if (status.canConnect) return G.ok();
|
|
21711
|
+
if (status.paymentURL) surfaceURL(deps, status.paymentURL);
|
|
21363
21712
|
return pollForSeat$1(deps);
|
|
21364
21713
|
};
|
|
21365
21714
|
const accountKey = (account) => account.profileId;
|
|
@@ -21370,18 +21719,18 @@ const parseXAccountSelector = (target, operation) => {
|
|
|
21370
21719
|
const trimmed = target.trim();
|
|
21371
21720
|
if (trimmed.startsWith("profile_id:")) {
|
|
21372
21721
|
const profileId = trimmed.slice(11).trim();
|
|
21373
|
-
if (profileId && !/[/?#%]/.test(profileId)) return
|
|
21722
|
+
if (profileId && !/[/?#%]/.test(profileId)) return G.ok({
|
|
21374
21723
|
kind: "profileId",
|
|
21375
21724
|
normalized: profileId.toLowerCase(),
|
|
21376
21725
|
raw: target
|
|
21377
21726
|
});
|
|
21378
21727
|
}
|
|
21379
|
-
if (trimmed.startsWith("@") && !/[/?#%]/.test(trimmed)) return
|
|
21728
|
+
if (trimmed.startsWith("@") && !/[/?#%]/.test(trimmed)) return G.ok({
|
|
21380
21729
|
kind: "username",
|
|
21381
21730
|
normalized: normalizeIdentifier(trimmed),
|
|
21382
21731
|
raw: target
|
|
21383
21732
|
});
|
|
21384
|
-
return
|
|
21733
|
+
return G.err(new XInvalidSelector({
|
|
21385
21734
|
operation,
|
|
21386
21735
|
account: target
|
|
21387
21736
|
}));
|
|
@@ -21390,7 +21739,7 @@ const findXLifecycleAccount = (accounts, selector) => {
|
|
|
21390
21739
|
if (selector.kind === "profileId") return accounts.find((account) => account.profileId.toLowerCase() === selector.normalized);
|
|
21391
21740
|
return accounts.find((account) => normalizeIdentifier(account.username) === selector.normalized);
|
|
21392
21741
|
};
|
|
21393
|
-
const listXLifecycleAccounts = async (deps, includeDisconnected) =>
|
|
21742
|
+
const listXLifecycleAccounts = async (deps, includeDisconnected) => G.ok(await deps.client.accounts.list({
|
|
21394
21743
|
platform: "x",
|
|
21395
21744
|
includeDisconnected
|
|
21396
21745
|
}));
|
|
@@ -21401,14 +21750,14 @@ const listXLifecycleAccounts = async (deps, includeDisconnected) => Result.ok(aw
|
|
|
21401
21750
|
const createXConnectURL = (deps, reconnectProfileId) => connectURLFor(deps, reconnectProfileId);
|
|
21402
21751
|
const connectXAccount = async (deps) => {
|
|
21403
21752
|
const beforeResult = await listXLifecycleAccounts(deps, true);
|
|
21404
|
-
if (
|
|
21753
|
+
if (G.isError(beforeResult)) return G.err(beforeResult.error);
|
|
21405
21754
|
const before = beforeResult.value;
|
|
21406
21755
|
const connectedBefore = new Set(before.filter((account) => account.status === "connected").map(accountKey));
|
|
21407
21756
|
const lastSeenBefore = new Map(before.filter((account) => account.status === "connected").map((account) => [accountKey(account), timestampMS(account.lastSeenAt)]));
|
|
21408
21757
|
const prepared = await prepareAccountConnect(deps);
|
|
21409
|
-
if (
|
|
21758
|
+
if (G.isError(prepared)) return G.err(prepared.error);
|
|
21410
21759
|
const authURL = await authURLFor(deps, () => connectURLFor(deps));
|
|
21411
|
-
|
|
21760
|
+
surfaceURL(deps, authURL.url, { log: !authURL.openingLogged });
|
|
21412
21761
|
const account = await pollForAccount(deps, "connect", (candidate) => {
|
|
21413
21762
|
if (candidate.status !== "connected") return false;
|
|
21414
21763
|
if (!connectedBefore.has(candidate.profileId)) return true;
|
|
@@ -21416,8 +21765,8 @@ const connectXAccount = async (deps) => {
|
|
|
21416
21765
|
const currentLastSeen = timestampMS(candidate.lastSeenAt);
|
|
21417
21766
|
return previousLastSeen !== void 0 && currentLastSeen !== void 0 && currentLastSeen > previousLastSeen;
|
|
21418
21767
|
});
|
|
21419
|
-
if (
|
|
21420
|
-
return
|
|
21768
|
+
if (G.isError(account)) return G.err(account.error);
|
|
21769
|
+
return G.ok({
|
|
21421
21770
|
platform: "x",
|
|
21422
21771
|
status: "connected",
|
|
21423
21772
|
account: account.value
|
|
@@ -21425,20 +21774,20 @@ const connectXAccount = async (deps) => {
|
|
|
21425
21774
|
};
|
|
21426
21775
|
const reconnectXAccount = async (deps, args) => {
|
|
21427
21776
|
const selector = parseXAccountSelector(args.account, "reconnect");
|
|
21428
|
-
if (
|
|
21777
|
+
if (G.isError(selector)) return G.err(selector.error);
|
|
21429
21778
|
const accountsResult = await listXLifecycleAccounts(deps, true);
|
|
21430
|
-
if (
|
|
21779
|
+
if (G.isError(accountsResult)) return G.err(accountsResult.error);
|
|
21431
21780
|
const accounts = accountsResult.value;
|
|
21432
21781
|
const existing = findXLifecycleAccount(accounts, selector.value);
|
|
21433
|
-
if (!existing) return
|
|
21782
|
+
if (!existing) return G.err(new XAccountNotFound({
|
|
21434
21783
|
operation: "reconnect",
|
|
21435
21784
|
account: args.account
|
|
21436
21785
|
}));
|
|
21437
21786
|
const authURL = await authURLFor(deps, () => connectURLFor(deps, existing.profileId));
|
|
21438
|
-
|
|
21787
|
+
surfaceURL(deps, authURL.url, { log: !authURL.openingLogged });
|
|
21439
21788
|
const account = await pollForAccount(deps, "reconnect", (candidate) => candidate.profileId === existing.profileId && candidate.status === "connected");
|
|
21440
|
-
if (
|
|
21441
|
-
return
|
|
21789
|
+
if (G.isError(account)) return G.err(account.error);
|
|
21790
|
+
return G.ok({
|
|
21442
21791
|
platform: "x",
|
|
21443
21792
|
status: "connected",
|
|
21444
21793
|
account: account.value
|
|
@@ -21446,12 +21795,12 @@ const reconnectXAccount = async (deps, args) => {
|
|
|
21446
21795
|
};
|
|
21447
21796
|
const disconnectXAccount = async (deps, target) => {
|
|
21448
21797
|
const selector = parseXAccountSelector(target, "disconnect");
|
|
21449
|
-
if (
|
|
21798
|
+
if (G.isError(selector)) return G.err(selector.error);
|
|
21450
21799
|
const accountsResult = await listXLifecycleAccounts(deps);
|
|
21451
|
-
if (
|
|
21800
|
+
if (G.isError(accountsResult)) return G.err(accountsResult.error);
|
|
21452
21801
|
const accounts = accountsResult.value;
|
|
21453
21802
|
const account = findXLifecycleAccount(accounts, selector.value);
|
|
21454
|
-
if (!account) return
|
|
21803
|
+
if (!account) return G.err(new XAccountNotFound({
|
|
21455
21804
|
operation: "disconnect",
|
|
21456
21805
|
account: target
|
|
21457
21806
|
}));
|
|
@@ -21459,7 +21808,7 @@ const disconnectXAccount = async (deps, target) => {
|
|
|
21459
21808
|
platform: "x",
|
|
21460
21809
|
account: accountSelectorFor$1(account)
|
|
21461
21810
|
});
|
|
21462
|
-
return
|
|
21811
|
+
return G.ok({
|
|
21463
21812
|
platform: "x",
|
|
21464
21813
|
account,
|
|
21465
21814
|
result
|
|
@@ -22823,7 +23172,7 @@ function createEnv(opts) {
|
|
|
22823
23172
|
}
|
|
22824
23173
|
//#endregion
|
|
22825
23174
|
//#region package.json
|
|
22826
|
-
var version$1 = "0.11.
|
|
23175
|
+
var version$1 = "0.11.6";
|
|
22827
23176
|
//#endregion
|
|
22828
23177
|
//#region src/lib/env.ts
|
|
22829
23178
|
const URLWithTrailingSlash = url().transform(ensureTrailingSlash);
|
|
@@ -24018,22 +24367,21 @@ const createBillingCommand = (deps = {}) => {
|
|
|
24018
24367
|
const portal = defineCommand({
|
|
24019
24368
|
meta: commandMeta({
|
|
24020
24369
|
name: "portal",
|
|
24021
|
-
description: "
|
|
24370
|
+
description: "Print the hosted billing portal URL.",
|
|
24022
24371
|
capability: "read",
|
|
24023
24372
|
contract: readCLIContract({
|
|
24024
24373
|
outputSchema: BillingPortalOutput,
|
|
24025
24374
|
hazards: [{
|
|
24026
24375
|
code: "billing_portal_handoff",
|
|
24027
|
-
message: "Hosted billing portal handoff; billing changes happen outside the CLI after the URL
|
|
24376
|
+
message: "Hosted billing portal handoff; billing changes happen outside the CLI after the URL is opened."
|
|
24028
24377
|
}]
|
|
24029
24378
|
})
|
|
24030
24379
|
}),
|
|
24031
24380
|
run: async () => {
|
|
24032
24381
|
const { url } = await clientFrom(deps).billing.portalURL();
|
|
24033
|
-
const result = deps.isInteractiveTerminal?.() === true && deps.openURL !== void 0 ? await deps.openURL?.(url) : void 0;
|
|
24034
24382
|
await writeOutput$2(deps, {
|
|
24035
|
-
url
|
|
24036
|
-
opened:
|
|
24383
|
+
url,
|
|
24384
|
+
opened: false
|
|
24037
24385
|
});
|
|
24038
24386
|
}
|
|
24039
24387
|
});
|
|
@@ -24062,11 +24410,11 @@ const CLI_SCOPE_ALIASES = ["read", "read,write"];
|
|
|
24062
24410
|
`${productBrand.name}`, `${productBrand.name}`;
|
|
24063
24411
|
const isCLIScopeAlias = (scope) => CLI_SCOPE_ALIASES.some((alias) => alias === scope);
|
|
24064
24412
|
const parseDeviceScopeAlias = (scope) => {
|
|
24065
|
-
if (!isCLIScopeAlias(scope)) return
|
|
24413
|
+
if (!isCLIScopeAlias(scope)) return G.err({
|
|
24066
24414
|
code: "invalid_device_authorization_scope",
|
|
24067
24415
|
scope
|
|
24068
24416
|
});
|
|
24069
|
-
return
|
|
24417
|
+
return G.ok(scope);
|
|
24070
24418
|
};
|
|
24071
24419
|
const parseCLIScopeAlias = parseDeviceScopeAlias;
|
|
24072
24420
|
const scopeAliasFromAccessChoices$1 = (choices) => choices.includes("write") ? "read,write" : "read";
|
|
@@ -29828,7 +30176,7 @@ const accessPhase = async (ctx) => {
|
|
|
29828
30176
|
data: { scopeAlias }
|
|
29829
30177
|
};
|
|
29830
30178
|
};
|
|
29831
|
-
|
|
30179
|
+
h("InvalidEmailHint")();
|
|
29832
30180
|
const base64URLFromText = (value) => {
|
|
29833
30181
|
const bytes = new TextEncoder().encode(value);
|
|
29834
30182
|
let binary = "";
|
|
@@ -29988,7 +30336,7 @@ const resolvePhoneNumber = async (ctx) => {
|
|
|
29988
30336
|
};
|
|
29989
30337
|
//#endregion
|
|
29990
30338
|
//#region src/lib/expected-errors.ts
|
|
29991
|
-
var InvalidScope = class extends
|
|
30339
|
+
var InvalidScope = class extends h("InvalidScope")() {
|
|
29992
30340
|
constructor(scope) {
|
|
29993
30341
|
super({
|
|
29994
30342
|
scope,
|
|
@@ -29996,7 +30344,7 @@ var InvalidScope = class extends TaggedError("InvalidScope")() {
|
|
|
29996
30344
|
});
|
|
29997
30345
|
}
|
|
29998
30346
|
};
|
|
29999
|
-
var AccountNotFound = class extends
|
|
30347
|
+
var AccountNotFound = class extends h("AccountNotFound")() {
|
|
30000
30348
|
constructor({ account, platform }) {
|
|
30001
30349
|
super({
|
|
30002
30350
|
account,
|
|
@@ -30005,7 +30353,7 @@ var AccountNotFound = class extends TaggedError("AccountNotFound")() {
|
|
|
30005
30353
|
});
|
|
30006
30354
|
}
|
|
30007
30355
|
};
|
|
30008
|
-
var NoConnectedAccount = class extends
|
|
30356
|
+
var NoConnectedAccount = class extends h("NoConnectedAccount")() {
|
|
30009
30357
|
constructor(platform) {
|
|
30010
30358
|
super({
|
|
30011
30359
|
platform,
|
|
@@ -30013,7 +30361,7 @@ var NoConnectedAccount = class extends TaggedError("NoConnectedAccount")() {
|
|
|
30013
30361
|
});
|
|
30014
30362
|
}
|
|
30015
30363
|
};
|
|
30016
|
-
var LookupPayloadInvalid = class extends
|
|
30364
|
+
var LookupPayloadInvalid = class extends h("LookupPayloadInvalid")() {
|
|
30017
30365
|
constructor({ input, platform }) {
|
|
30018
30366
|
super({
|
|
30019
30367
|
input,
|
|
@@ -30022,7 +30370,7 @@ var LookupPayloadInvalid = class extends TaggedError("LookupPayloadInvalid")() {
|
|
|
30022
30370
|
});
|
|
30023
30371
|
}
|
|
30024
30372
|
};
|
|
30025
|
-
var SchemaPathUnknown = class extends
|
|
30373
|
+
var SchemaPathUnknown = class extends h("SchemaPathUnknown")() {
|
|
30026
30374
|
constructor({ message, path }) {
|
|
30027
30375
|
super({
|
|
30028
30376
|
message,
|
|
@@ -30030,7 +30378,7 @@ var SchemaPathUnknown = class extends TaggedError("SchemaPathUnknown")() {
|
|
|
30030
30378
|
});
|
|
30031
30379
|
}
|
|
30032
30380
|
};
|
|
30033
|
-
var SchemaContractInvalid = class extends
|
|
30381
|
+
var SchemaContractInvalid = class extends h("SchemaContractInvalid")() {
|
|
30034
30382
|
constructor({ label, message }) {
|
|
30035
30383
|
super({
|
|
30036
30384
|
label,
|
|
@@ -30038,7 +30386,7 @@ var SchemaContractInvalid = class extends TaggedError("SchemaContractInvalid")()
|
|
|
30038
30386
|
});
|
|
30039
30387
|
}
|
|
30040
30388
|
};
|
|
30041
|
-
var UsagePaginationLimit = class extends
|
|
30389
|
+
var UsagePaginationLimit = class extends h("UsagePaginationLimit")() {
|
|
30042
30390
|
constructor(limit) {
|
|
30043
30391
|
super({
|
|
30044
30392
|
limit,
|
|
@@ -30046,7 +30394,7 @@ var UsagePaginationLimit = class extends TaggedError("UsagePaginationLimit")() {
|
|
|
30046
30394
|
});
|
|
30047
30395
|
}
|
|
30048
30396
|
};
|
|
30049
|
-
var LogoutRevocationFailed = class extends
|
|
30397
|
+
var LogoutRevocationFailed = class extends h("LogoutRevocationFailed")() {
|
|
30050
30398
|
constructor() {
|
|
30051
30399
|
super({ message: "Could not revoke the server-side session; local credentials were cleared." });
|
|
30052
30400
|
}
|
|
@@ -30055,16 +30403,16 @@ var LogoutRevocationFailed = class extends TaggedError("LogoutRevocationFailed")
|
|
|
30055
30403
|
//#region src/login/phases/1.scope.ts
|
|
30056
30404
|
const DEFAULT_SCOPE_ALIAS = "read,write";
|
|
30057
30405
|
const parseScopeAliasResult = (value) => {
|
|
30058
|
-
if (value === void 0 || value === null || value === "") return
|
|
30059
|
-
if (typeof value !== "string") return
|
|
30406
|
+
if (value === void 0 || value === null || value === "") return G.ok(DEFAULT_SCOPE_ALIAS);
|
|
30407
|
+
if (typeof value !== "string") return G.err(new InvalidScope(String(value)));
|
|
30060
30408
|
const scope = value === "write" ? DEFAULT_SCOPE_ALIAS : value;
|
|
30061
30409
|
const parsed = parseCLIScopeAlias(scope);
|
|
30062
|
-
if (
|
|
30063
|
-
return
|
|
30410
|
+
if (G.isError(parsed)) return G.err(new InvalidScope(scope));
|
|
30411
|
+
return G.ok(parsed.value);
|
|
30064
30412
|
};
|
|
30065
30413
|
const parseScopeAlias = (value) => {
|
|
30066
30414
|
const parsed = parseScopeAliasResult(value);
|
|
30067
|
-
if (
|
|
30415
|
+
if (G.isOk(parsed)) return parsed.value;
|
|
30068
30416
|
throw new Error(parsed.error.message);
|
|
30069
30417
|
};
|
|
30070
30418
|
const scopePhase = async (ctx) => {
|
|
@@ -30075,85 +30423,6 @@ const scopePhase = async (ctx) => {
|
|
|
30075
30423
|
};
|
|
30076
30424
|
};
|
|
30077
30425
|
//#endregion
|
|
30078
|
-
//#region src/lib/browser.ts
|
|
30079
|
-
const WSL_VERSION = /microsoft|wsl/i;
|
|
30080
|
-
const BROWSER_TARGET_TIMEOUT_MS = 5e3;
|
|
30081
|
-
const LOCAL_HOSTS = new Set([
|
|
30082
|
-
"localhost",
|
|
30083
|
-
"127.0.0.1",
|
|
30084
|
-
"::1"
|
|
30085
|
-
]);
|
|
30086
|
-
const displayURL = (url) => {
|
|
30087
|
-
try {
|
|
30088
|
-
const parsed = new URL(url);
|
|
30089
|
-
parsed.searchParams.delete("token");
|
|
30090
|
-
parsed.hash = "";
|
|
30091
|
-
return parsed.toString();
|
|
30092
|
-
} catch {
|
|
30093
|
-
return url;
|
|
30094
|
-
}
|
|
30095
|
-
};
|
|
30096
|
-
const hintFor = (url) => LOCAL_HOSTS.has(url.hostname) ? "Start the web app or local worker, or set SOCIAL_API_URL to your deployed social API." : "Check SOCIAL_API_URL and your connection, then try again.";
|
|
30097
|
-
const assertBrowserTargetReachable = async (url) => {
|
|
30098
|
-
let parsed;
|
|
30099
|
-
try {
|
|
30100
|
-
parsed = new URL(url);
|
|
30101
|
-
} catch {
|
|
30102
|
-
return;
|
|
30103
|
-
}
|
|
30104
|
-
if (parsed.protocol !== "http:" && parsed.protocol !== "https:") return;
|
|
30105
|
-
if (!LOCAL_HOSTS.has(parsed.hostname)) return;
|
|
30106
|
-
const controller = new AbortController();
|
|
30107
|
-
const timeout = setTimeout(() => controller.abort(), BROWSER_TARGET_TIMEOUT_MS);
|
|
30108
|
-
const target = parsed.origin;
|
|
30109
|
-
try {
|
|
30110
|
-
const response = await fetch(target, {
|
|
30111
|
-
method: "GET",
|
|
30112
|
-
redirect: "manual",
|
|
30113
|
-
signal: controller.signal
|
|
30114
|
-
});
|
|
30115
|
-
if (response.status >= 400) throw new Error(`social is reachable at ${displayURL(target)}, but it returned ${response.status}. Try again in a moment.`);
|
|
30116
|
-
} catch (error) {
|
|
30117
|
-
if (error instanceof Error && error.message.startsWith("social is reachable")) throw error;
|
|
30118
|
-
throw new Error(`Can't reach ${displayURL(target)}. ${hintFor(parsed)}`);
|
|
30119
|
-
} finally {
|
|
30120
|
-
clearTimeout(timeout);
|
|
30121
|
-
}
|
|
30122
|
-
};
|
|
30123
|
-
const runCommand = async (command) => await new Promise((resolve) => {
|
|
30124
|
-
const [file, ...args] = command;
|
|
30125
|
-
if (!file) {
|
|
30126
|
-
resolve(false);
|
|
30127
|
-
return;
|
|
30128
|
-
}
|
|
30129
|
-
const proc = spawn(file, args, { stdio: "ignore" });
|
|
30130
|
-
proc.once("error", () => resolve(false));
|
|
30131
|
-
proc.once("exit", (code) => resolve(code === 0));
|
|
30132
|
-
});
|
|
30133
|
-
const isWSL = async () => {
|
|
30134
|
-
if (env.WSL_DISTRO_NAME || env.WSL_INTEROP) return true;
|
|
30135
|
-
const version = await readFile("/proc/version", "utf8").catch(() => "");
|
|
30136
|
-
return WSL_VERSION.test(version);
|
|
30137
|
-
};
|
|
30138
|
-
const openBrowser = async (url) => {
|
|
30139
|
-
await assertBrowserTargetReachable(url);
|
|
30140
|
-
if (process.platform === "darwin") return await runCommand(["open", url]);
|
|
30141
|
-
if (process.platform === "win32") return await runCommand([
|
|
30142
|
-
"cmd",
|
|
30143
|
-
"/c",
|
|
30144
|
-
"start",
|
|
30145
|
-
url
|
|
30146
|
-
]);
|
|
30147
|
-
if (await isWSL()) return await runCommand(["wslview", url]) || await runCommand([
|
|
30148
|
-
"powershell.exe",
|
|
30149
|
-
"-NoProfile",
|
|
30150
|
-
"-Command",
|
|
30151
|
-
"Start-Process",
|
|
30152
|
-
url
|
|
30153
|
-
]);
|
|
30154
|
-
return await runCommand(["xdg-open", url]);
|
|
30155
|
-
};
|
|
30156
|
-
//#endregion
|
|
30157
30426
|
//#region src/login/phases/2.seat.ts
|
|
30158
30427
|
const SEAT_BILLING_DETAILS_URL = publicRouteURLs.pricing;
|
|
30159
30428
|
const SEAT_PRICING_MESSAGE = `${productBrand.name} costs $20/month/account + usage. Full details at ${SEAT_BILLING_DETAILS_URL}. Continue?`;
|
|
@@ -30175,7 +30444,6 @@ const pollForSeat = async (ctx, deps = {}) => {
|
|
|
30175
30444
|
throw new Error("Billing checkout did not complete within 30 minutes. Finish checkout in the browser, then run `social account login` again.");
|
|
30176
30445
|
};
|
|
30177
30446
|
const runSeatPhase = async (ctx, deps = {}) => {
|
|
30178
|
-
const openBrowser$1 = deps.openBrowser ?? openBrowser;
|
|
30179
30447
|
const status = await ctx.client.billing.status();
|
|
30180
30448
|
if (seatAvailable(status)) return {
|
|
30181
30449
|
status: "done",
|
|
@@ -30191,7 +30459,6 @@ const runSeatPhase = async (ctx, deps = {}) => {
|
|
|
30191
30459
|
};
|
|
30192
30460
|
const checkout = await ctx.client.billing.checkoutURL({ returnPath: SEAT_CHECKOUT_RETURN_PATH });
|
|
30193
30461
|
ctx.ui.info(checkout.url);
|
|
30194
|
-
await openBrowser$1(checkout.url);
|
|
30195
30462
|
return {
|
|
30196
30463
|
status: "done",
|
|
30197
30464
|
data: await ctx.ui.spinElapsed("Waiting for billing checkout", () => pollForSeat(ctx, deps), "Billing ready")
|
|
@@ -30557,7 +30824,7 @@ const revokeServerSide = async (accessToken) => {
|
|
|
30557
30824
|
return false;
|
|
30558
30825
|
}
|
|
30559
30826
|
};
|
|
30560
|
-
const logoutRevocationResult = (revoked) => revoked ?
|
|
30827
|
+
const logoutRevocationResult = (revoked) => revoked ? G.ok(null) : G.err(new LogoutRevocationFailed());
|
|
30561
30828
|
const logoutCommand = defineCommand({
|
|
30562
30829
|
meta: commandMeta({
|
|
30563
30830
|
name: "logout",
|
|
@@ -30586,7 +30853,7 @@ const logoutCommand = defineCommand({
|
|
|
30586
30853
|
const revoked = await revokeServerSide(credentials.accessToken);
|
|
30587
30854
|
await clearCredentials();
|
|
30588
30855
|
const revocation = logoutRevocationResult(revoked);
|
|
30589
|
-
if (
|
|
30856
|
+
if (G.isError(revocation)) throw new Error(revocation.error.message);
|
|
30590
30857
|
analytics.capture("logout");
|
|
30591
30858
|
analytics.reset();
|
|
30592
30859
|
}
|
|
@@ -30725,7 +30992,7 @@ const fetchUsageLogs = async (client, input) => {
|
|
|
30725
30992
|
let nextCursor = null;
|
|
30726
30993
|
let pages = 0;
|
|
30727
30994
|
do {
|
|
30728
|
-
if (pages >= USAGE_LOG_MAX_AUTO_PAGES) return
|
|
30995
|
+
if (pages >= USAGE_LOG_MAX_AUTO_PAGES) return G.err(new UsagePaginationLimit(USAGE_LOG_MAX_AUTO_PAGES));
|
|
30729
30996
|
const remaining = input.limit === void 0 ? USAGE_LOG_PAGE_LIMIT : input.limit - items.length;
|
|
30730
30997
|
const usage = await client.usage.list({
|
|
30731
30998
|
platform: input.platform,
|
|
@@ -30739,7 +31006,7 @@ const fetchUsageLogs = async (client, input) => {
|
|
|
30739
31006
|
cursor = nextCursor ?? void 0;
|
|
30740
31007
|
pages += 1;
|
|
30741
31008
|
} while (nextCursor && (input.limit === void 0 || items.length < input.limit));
|
|
30742
|
-
return
|
|
31009
|
+
return G.ok({
|
|
30743
31010
|
items: input.limit === void 0 ? items : items.slice(0, input.limit),
|
|
30744
31011
|
cursor: nextCursor
|
|
30745
31012
|
});
|
|
@@ -30807,7 +31074,7 @@ const createUsageLogsCommand = (deps = {}) => defineCommand({
|
|
|
30807
31074
|
from,
|
|
30808
31075
|
to
|
|
30809
31076
|
});
|
|
30810
|
-
if (
|
|
31077
|
+
if (G.isError(usage)) throw new UsageError(usage.error.message);
|
|
30811
31078
|
await writeOutput$1(deps, {
|
|
30812
31079
|
items: aggregateLogs(usage.value.items, sumBy),
|
|
30813
31080
|
meta: {
|
|
@@ -30825,7 +31092,7 @@ const createUsageLogsCommand = (deps = {}) => defineCommand({
|
|
|
30825
31092
|
from,
|
|
30826
31093
|
to
|
|
30827
31094
|
});
|
|
30828
|
-
if (
|
|
31095
|
+
if (G.isError(usage)) throw new UsageError(usage.error.message);
|
|
30829
31096
|
await writeOutput$1(deps, {
|
|
30830
31097
|
items: usage.value.items,
|
|
30831
31098
|
meta: { cursor: usage.value.cursor }
|
|
@@ -30969,7 +31236,7 @@ const lifecycleDepsWithTextLogs = (deps) => ({
|
|
|
30969
31236
|
spinner.start(authHandshakeMessage);
|
|
30970
31237
|
try {
|
|
30971
31238
|
const url = await operation();
|
|
30972
|
-
spinner.stop(`
|
|
31239
|
+
spinner.stop(`Open this URL: ${url}`);
|
|
30973
31240
|
return url;
|
|
30974
31241
|
} catch (error) {
|
|
30975
31242
|
spinner.error(authHandshakeMessage);
|
|
@@ -30978,7 +31245,7 @@ const lifecycleDepsWithTextLogs = (deps) => ({
|
|
|
30978
31245
|
}
|
|
30979
31246
|
writeText(deps, authHandshakeMessage);
|
|
30980
31247
|
const url = await operation();
|
|
30981
|
-
writeText(deps, `
|
|
31248
|
+
writeText(deps, `Open this URL: ${url}`);
|
|
30982
31249
|
return url;
|
|
30983
31250
|
}
|
|
30984
31251
|
});
|
|
@@ -31003,7 +31270,7 @@ const runConnectStep = async (deps, platform, listConnected, connectURL) => {
|
|
|
31003
31270
|
return;
|
|
31004
31271
|
}
|
|
31005
31272
|
const url = await connectURL();
|
|
31006
|
-
writeText(deps, `
|
|
31273
|
+
writeText(deps, `Open this URL: ${url}`);
|
|
31007
31274
|
await writeOutput(deps, {
|
|
31008
31275
|
status: "pending_approval",
|
|
31009
31276
|
platform,
|
|
@@ -31064,14 +31331,14 @@ const createAccountCommand = (deps) => {
|
|
|
31064
31331
|
if (isInteractiveConnect(deps)) {
|
|
31065
31332
|
await runConnectOutput(deps, async (connectDeps) => {
|
|
31066
31333
|
const result = await connectXAccount(connectDeps);
|
|
31067
|
-
if (
|
|
31334
|
+
if (G.isError(result)) throwXLifecycleError(result.error);
|
|
31068
31335
|
return result.value;
|
|
31069
31336
|
});
|
|
31070
31337
|
return;
|
|
31071
31338
|
}
|
|
31072
31339
|
await runConnectStep(deps, "x", async () => {
|
|
31073
31340
|
const result = await listXLifecycleAccounts(deps, true);
|
|
31074
|
-
if (
|
|
31341
|
+
if (G.isError(result)) throwXLifecycleError(result.error);
|
|
31075
31342
|
return result.value;
|
|
31076
31343
|
}, () => createXConnectURL(deps));
|
|
31077
31344
|
})
|
|
@@ -31089,7 +31356,7 @@ const createAccountCommand = (deps) => {
|
|
|
31089
31356
|
x: createAccountPlatformCommand("x", "Reconnect an X account.", async (args) => {
|
|
31090
31357
|
await runConnectOutput(deps, async (connectDeps) => {
|
|
31091
31358
|
const result = await reconnectXAccount(connectDeps, { account: String(args.account) });
|
|
31092
|
-
if (
|
|
31359
|
+
if (G.isError(result)) throwXLifecycleError(result.error);
|
|
31093
31360
|
return result.value;
|
|
31094
31361
|
});
|
|
31095
31362
|
}, { accountArg: xAccountArg })
|
|
@@ -31114,7 +31381,7 @@ const createAccountCommand = (deps) => {
|
|
|
31114
31381
|
}) }),
|
|
31115
31382
|
x: createAccountPlatformCommand("x", "Disconnect an X account.", async (args) => {
|
|
31116
31383
|
const result = await disconnectXAccount(deps, String(args.account));
|
|
31117
|
-
if (
|
|
31384
|
+
if (G.isError(result)) throwXLifecycleError(result.error);
|
|
31118
31385
|
await writeOutput(deps, result.value);
|
|
31119
31386
|
}, {
|
|
31120
31387
|
accountArg: xAccountArg,
|
|
@@ -31258,12 +31525,12 @@ const selectAccountOutcome = ({ accounts, defaultAccount, explicitAccount }) =>
|
|
|
31258
31525
|
};
|
|
31259
31526
|
};
|
|
31260
31527
|
const requireSelectedAccount = (outcome, platform) => {
|
|
31261
|
-
if (outcome.status === "selected") return
|
|
31262
|
-
if (outcome.status === "missingExplicitAccount") return
|
|
31528
|
+
if (outcome.status === "selected") return G.ok(outcome);
|
|
31529
|
+
if (outcome.status === "missingExplicitAccount") return G.err(new AccountNotFound({
|
|
31263
31530
|
account: outcome.account,
|
|
31264
31531
|
platform
|
|
31265
31532
|
}));
|
|
31266
|
-
return
|
|
31533
|
+
return G.err(new NoConnectedAccount(platform));
|
|
31267
31534
|
};
|
|
31268
31535
|
const isRecord$1 = (value) => Boolean(value && typeof value === "object" && !Array.isArray(value));
|
|
31269
31536
|
const stringField = (value, key) => {
|
|
@@ -31276,35 +31543,35 @@ const stringOrNumberField = (value, key) => {
|
|
|
31276
31543
|
return typeof field === "number" && Number.isFinite(field) ? String(field) : void 0;
|
|
31277
31544
|
};
|
|
31278
31545
|
const parseXLookupResponse = (data, input) => {
|
|
31279
|
-
if (!(isRecord$1(data) && isRecord$1(data.data))) return
|
|
31546
|
+
if (!(isRecord$1(data) && isRecord$1(data.data))) return G.err(new LookupPayloadInvalid({
|
|
31280
31547
|
input,
|
|
31281
31548
|
platform: "x"
|
|
31282
31549
|
}));
|
|
31283
31550
|
const id = stringOrNumberField(data.data, "id");
|
|
31284
|
-
if (!id) return
|
|
31551
|
+
if (!id) return G.err(new LookupPayloadInvalid({
|
|
31285
31552
|
input,
|
|
31286
31553
|
platform: "x"
|
|
31287
31554
|
}));
|
|
31288
31555
|
const inputUsername = input.replace(/^@+/, "");
|
|
31289
31556
|
const resolvedUsername = stringField(data.data, "username") ?? inputUsername;
|
|
31290
|
-
return
|
|
31557
|
+
return G.ok({
|
|
31291
31558
|
id,
|
|
31292
31559
|
url: `https://x.com/${resolvedUsername}`
|
|
31293
31560
|
});
|
|
31294
31561
|
};
|
|
31295
31562
|
const parseLinkedinProfileLookupResponse = (data, input) => {
|
|
31296
31563
|
const profile = isRecord$1(data) && isRecord$1(data.data) ? data.data : data;
|
|
31297
|
-
if (!isRecord$1(profile)) return
|
|
31564
|
+
if (!isRecord$1(profile)) return G.err(new LookupPayloadInvalid({
|
|
31298
31565
|
input,
|
|
31299
31566
|
platform: "linkedin"
|
|
31300
31567
|
}));
|
|
31301
31568
|
const id = stringOrNumberField(profile, "provider_id") ?? stringOrNumberField(profile, "providerId") ?? stringOrNumberField(profile, "id");
|
|
31302
|
-
if (!id) return
|
|
31569
|
+
if (!id) return G.err(new LookupPayloadInvalid({
|
|
31303
31570
|
input,
|
|
31304
31571
|
platform: "linkedin"
|
|
31305
31572
|
}));
|
|
31306
31573
|
const publicIdentifier = stringField(profile, "public_identifier") ?? stringField(profile, "publicIdentifier");
|
|
31307
|
-
return
|
|
31574
|
+
return G.ok({
|
|
31308
31575
|
id,
|
|
31309
31576
|
...publicIdentifier ? { url: `https://www.linkedin.com/in/${encodeURIComponent(publicIdentifier)}` } : {}
|
|
31310
31577
|
});
|
|
@@ -31322,7 +31589,7 @@ const headerValuesFromRawArgs = (rawArgs = []) => {
|
|
|
31322
31589
|
if (arg === "--") break;
|
|
31323
31590
|
if (arg === "--header" || arg === "-H") {
|
|
31324
31591
|
const value = rawArgs[index + 1];
|
|
31325
|
-
if (value === void 0) return
|
|
31592
|
+
if (value === void 0) return G.err(headerError("missingHeaderValue", `Pass a value for ${arg}.`));
|
|
31326
31593
|
values.push(value);
|
|
31327
31594
|
index += 1;
|
|
31328
31595
|
continue;
|
|
@@ -31333,25 +31600,25 @@ const headerValuesFromRawArgs = (rawArgs = []) => {
|
|
|
31333
31600
|
}
|
|
31334
31601
|
if (arg?.startsWith("-H=")) values.push(arg.slice(3));
|
|
31335
31602
|
}
|
|
31336
|
-
return
|
|
31603
|
+
return G.ok(values);
|
|
31337
31604
|
};
|
|
31338
31605
|
const commandHeaderValuesFrom = ({ headers, rawArgs }) => {
|
|
31339
31606
|
const rawValues = headerValuesFromRawArgs(rawArgs);
|
|
31340
|
-
if (
|
|
31607
|
+
if (G.isError(rawValues)) return rawValues;
|
|
31341
31608
|
if (rawValues.value.length > 0) return rawValues;
|
|
31342
|
-
if (headers === void 0) return
|
|
31343
|
-
if (typeof headers === "string") return
|
|
31344
|
-
if (Array.isArray(headers) && headers.every((header) => typeof header === "string")) return
|
|
31345
|
-
return
|
|
31609
|
+
if (headers === void 0) return G.ok([]);
|
|
31610
|
+
if (typeof headers === "string") return G.ok([headers]);
|
|
31611
|
+
if (Array.isArray(headers) && headers.every((header) => typeof header === "string")) return G.ok(headers);
|
|
31612
|
+
return G.err(headerError("invalidHeaderList", "Pass --header as Name: value."));
|
|
31346
31613
|
};
|
|
31347
31614
|
const parsedHeaderFrom = (header) => {
|
|
31348
31615
|
const colon = header.indexOf(":");
|
|
31349
|
-
if (colon <= 0) return
|
|
31616
|
+
if (colon <= 0) return G.err(headerError("malformedHeader", "Pass --header as Name: value."));
|
|
31350
31617
|
const name = header.slice(0, colon).trim();
|
|
31351
31618
|
const value = header.slice(colon + 1).trim();
|
|
31352
31619
|
const normalized = name.toLowerCase();
|
|
31353
|
-
if (normalized === "authorization" || normalized === "content-type" || normalized.startsWith("x-social-")) return
|
|
31354
|
-
return
|
|
31620
|
+
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.`));
|
|
31621
|
+
return G.ok({
|
|
31355
31622
|
name,
|
|
31356
31623
|
value
|
|
31357
31624
|
});
|
|
@@ -31359,17 +31626,17 @@ const parsedHeaderFrom = (header) => {
|
|
|
31359
31626
|
const commandHeadersFrom = (defaults, args = {}) => {
|
|
31360
31627
|
const headers = new Headers(defaults);
|
|
31361
31628
|
const rawHeaders = commandHeaderValuesFrom(args);
|
|
31362
|
-
if (
|
|
31629
|
+
if (G.isError(rawHeaders)) return G.err(rawHeaders.error);
|
|
31363
31630
|
for (const rawHeader of rawHeaders.value) {
|
|
31364
31631
|
const parsed = parsedHeaderFrom(rawHeader);
|
|
31365
|
-
if (
|
|
31632
|
+
if (G.isError(parsed)) return G.err(parsed.error);
|
|
31366
31633
|
try {
|
|
31367
31634
|
headers.set(parsed.value.name, parsed.value.value);
|
|
31368
31635
|
} catch {
|
|
31369
|
-
return
|
|
31636
|
+
return G.err(headerError("invalidHeader", `Invalid header ${parsed.value.name}.`));
|
|
31370
31637
|
}
|
|
31371
31638
|
}
|
|
31372
|
-
return
|
|
31639
|
+
return G.ok(Object.fromEntries(headers.entries()));
|
|
31373
31640
|
};
|
|
31374
31641
|
//#endregion
|
|
31375
31642
|
//#region ../../node_modules/.bun/@borewit+text-codec@0.2.2/node_modules/@borewit/text-codec/lib/index.js
|
|
@@ -36306,7 +36573,7 @@ const createCLIDeps = () => {
|
|
|
36306
36573
|
platform
|
|
36307
36574
|
});
|
|
36308
36575
|
const selected = requireSelectedAccount(outcome, platform);
|
|
36309
|
-
if (
|
|
36576
|
+
if (G.isOk(selected)) return selected.value;
|
|
36310
36577
|
if (outcome.status === "missingExplicitAccount") throw new NotFoundError(`${platform}_account_not_found`);
|
|
36311
36578
|
throw new Error(`${platform}_account_not_connected`);
|
|
36312
36579
|
};
|
|
@@ -36321,7 +36588,7 @@ const createCLIDeps = () => {
|
|
|
36321
36588
|
...selectedAccount.selector === void 0 ? {} : { "x-social-account-id": selectedAccount.selector }
|
|
36322
36589
|
};
|
|
36323
36590
|
const parsed = parseXLookupResponse(await api.get(`x/users/by/username/${encodeURIComponent(inputUsername)}`, { headers }).json(), input);
|
|
36324
|
-
if (
|
|
36591
|
+
if (G.isError(parsed)) throw new Error(`Could not resolve X username ${input}.`);
|
|
36325
36592
|
return parsed.value;
|
|
36326
36593
|
};
|
|
36327
36594
|
const lookupLinkedinProfile = async (input, account, selectedAccount) => {
|
|
@@ -36334,7 +36601,7 @@ const createCLIDeps = () => {
|
|
|
36334
36601
|
...resolvedAccount.selector === void 0 ? {} : { "x-social-account-id": resolvedAccount.selector }
|
|
36335
36602
|
};
|
|
36336
36603
|
const parsed = parseLinkedinProfileLookupResponse(await api.get(`linkedin/users/${encodeURIComponent(input)}`, { headers }).json(), input);
|
|
36337
|
-
if (
|
|
36604
|
+
if (G.isError(parsed)) throw new Error(`Could not resolve LinkedIn profile ${input}.`);
|
|
36338
36605
|
return parsed.value;
|
|
36339
36606
|
};
|
|
36340
36607
|
return {
|
|
@@ -36344,6 +36611,7 @@ const createCLIDeps = () => {
|
|
|
36344
36611
|
disconnectAccount: client.accounts.disconnect,
|
|
36345
36612
|
accounts: {
|
|
36346
36613
|
list: client.accounts.list,
|
|
36614
|
+
reconnectURL: client.accounts.reconnectURL,
|
|
36347
36615
|
disconnect: client.accounts.disconnect
|
|
36348
36616
|
},
|
|
36349
36617
|
billing: {
|
|
@@ -36393,7 +36661,7 @@ const createCLIDeps = () => {
|
|
|
36393
36661
|
}),
|
|
36394
36662
|
commandHeaders: async (args) => {
|
|
36395
36663
|
const headers = commandHeadersFrom({ "Cache-Control": await cacheControlHeaderFromConfig() }, args);
|
|
36396
|
-
if (
|
|
36664
|
+
if (G.isError(headers)) throw new UsageError(headers.error.message);
|
|
36397
36665
|
return headers.value;
|
|
36398
36666
|
},
|
|
36399
36667
|
printData,
|
|
@@ -36434,17 +36702,8 @@ const createCLIDeps = () => {
|
|
|
36434
36702
|
providerId: profile.id
|
|
36435
36703
|
};
|
|
36436
36704
|
},
|
|
36437
|
-
openBrowser,
|
|
36438
36705
|
isInteractiveTerminal: () => process.stdout.isTTY === true,
|
|
36439
36706
|
webBaseURL: () => env.SOCIAL_WEB_URL,
|
|
36440
|
-
openURL: async (url) => {
|
|
36441
|
-
const opened = await openBrowser(url);
|
|
36442
|
-
if (!opened) console.error(url);
|
|
36443
|
-
return {
|
|
36444
|
-
opened,
|
|
36445
|
-
url
|
|
36446
|
-
};
|
|
36447
|
-
},
|
|
36448
36707
|
writeOutput: printData,
|
|
36449
36708
|
ui: createUI(process.stdout.isTTY === true)
|
|
36450
36709
|
};
|
|
@@ -36828,7 +37087,7 @@ const schemaAtPath = (command, commandPathInput, options = {}) => {
|
|
|
36828
37087
|
command,
|
|
36829
37088
|
path: []
|
|
36830
37089
|
} : commandAtPath(command, parts);
|
|
36831
|
-
return
|
|
37090
|
+
return G.ok({
|
|
36832
37091
|
schemaVersion: "2.0",
|
|
36833
37092
|
commands: Object.fromEntries(leafSchemasForCommand(selectedCommand, path))
|
|
36834
37093
|
});
|
|
@@ -36838,31 +37097,31 @@ const schemaAtPath = (command, commandPathInput, options = {}) => {
|
|
|
36838
37097
|
command,
|
|
36839
37098
|
path: []
|
|
36840
37099
|
} : commandAtPath(command, parts);
|
|
36841
|
-
return
|
|
37100
|
+
return G.ok({
|
|
36842
37101
|
schemaVersion: "2.0",
|
|
36843
37102
|
commands: Object.fromEntries(compactLeafSchemasForCommand(selectedCommand, path))
|
|
36844
37103
|
});
|
|
36845
37104
|
}
|
|
36846
|
-
if (parts.length === 0) return
|
|
37105
|
+
if (parts.length === 0) return G.ok({
|
|
36847
37106
|
schemaVersion: "2.0",
|
|
36848
37107
|
...schemaTreeForCommand(command)
|
|
36849
37108
|
});
|
|
36850
37109
|
const { command: selectedCommand, path, positionalMatch } = commandAtPath(command, parts);
|
|
36851
|
-
if (positionalMatch) return
|
|
37110
|
+
if (positionalMatch) return G.ok({
|
|
36852
37111
|
schemaVersion: "2.0",
|
|
36853
37112
|
...schemaForCommand(selectedCommand, path),
|
|
36854
37113
|
...positionalMatch
|
|
36855
37114
|
});
|
|
36856
|
-
if (selectedCommand.subCommands && typeof selectedCommand.run !== "function") return
|
|
37115
|
+
if (selectedCommand.subCommands && typeof selectedCommand.run !== "function") return G.ok({
|
|
36857
37116
|
schemaVersion: "2.0",
|
|
36858
37117
|
...schemaTreeForCommand(selectedCommand, path)
|
|
36859
37118
|
});
|
|
36860
|
-
return
|
|
37119
|
+
return G.ok({
|
|
36861
37120
|
schemaVersion: "2.0",
|
|
36862
37121
|
...schemaForCommand(selectedCommand, path)
|
|
36863
37122
|
});
|
|
36864
37123
|
} catch (error) {
|
|
36865
|
-
return
|
|
37124
|
+
return G.err(schemaErrorFor(error, parts));
|
|
36866
37125
|
}
|
|
36867
37126
|
};
|
|
36868
37127
|
const schemaCommand = defineCommand({
|
|
@@ -36897,7 +37156,7 @@ const schemaCommand = defineCommand({
|
|
|
36897
37156
|
if (!rootCommand) throw new Error("schema_root_command_unconfigured");
|
|
36898
37157
|
const commandPathInput = Array.isArray(args._) && args._.length > 1 ? args._ : args.commandPath;
|
|
36899
37158
|
const schema = schemaAtPath(rootCommand, commandPathInput, { mode: args.leaves === true ? "leaves" : args.list === true ? "list" : "leaf" });
|
|
36900
|
-
if (
|
|
37159
|
+
if (G.isError(schema)) throw new Error(schema.error.message);
|
|
36901
37160
|
printData(schema.value);
|
|
36902
37161
|
}
|
|
36903
37162
|
});
|
|
@@ -37129,7 +37388,7 @@ const runSocial = async ({ command = createSocialCommand(), now = Date.now, rawA
|
|
|
37129
37388
|
try {
|
|
37130
37389
|
const loginArgError = loginExtraArgError(rawArgs, path);
|
|
37131
37390
|
if (loginArgError) throw loginArgError;
|
|
37132
|
-
await runCommand
|
|
37391
|
+
await runCommand(command, { rawArgs });
|
|
37133
37392
|
} catch (error) {
|
|
37134
37393
|
if (error instanceof SilentExit) return await finish(error.code, telemetry, now);
|
|
37135
37394
|
if (isCittyUsageError(error) && process.stderr.isTTY) await printUsage(command, rawArgs);
|