@usesocial/cli 0.19.9 → 0.19.11

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 CHANGED
@@ -1,5 +1,17 @@
1
1
  # @usesocial/cli
2
2
 
3
+ ## 0.19.11
4
+
5
+ ### Patch Changes
6
+
7
+ - [#173](https://github.com/usesocial/monorepo/pull/173) [`988f3de`](https://github.com/usesocial/monorepo/commit/988f3ded68966de58701c09116bb66b5fb48190b) Thanks [@CyrusNuevoDia](https://github.com/CyrusNuevoDia)! - Run X OAuth before billing so a distinct authorized account stays resumable across payment retries.
8
+
9
+ ## 0.19.10
10
+
11
+ ### Patch Changes
12
+
13
+ - [#154](https://github.com/usesocial/monorepo/pull/154) [`6cf8bd8`](https://github.com/usesocial/monorepo/commit/6cf8bd8cb2cad1b577eef28bc11176a398b99251) Thanks [@CyrusNuevoDia](https://github.com/CyrusNuevoDia)! - Classify wrapped sync access denials as expected CLI failures while preserving safe telemetry.
14
+
3
15
  ## 0.19.9
4
16
 
5
17
  ### Patch Changes
package/README.md CHANGED
@@ -283,14 +283,15 @@ returned approval or checkout URL, then rerun `social account setup` until it is
283
283
  `ready`.
284
284
 
285
285
  `social account connect <platform>` starts or resumes a server-owned partial
286
- account that purchases only that provider's plan or next seat, or the applicable
287
- legacy Social Pro seat during transition. It normally charges the stored card
288
- directly before returning hosted provider approval. In a non-TTY shell, omit
289
- `--account-id` on the first call, capture the returned `accountId`, and pass it
290
- back as `--account-id <accountId>` on every poll. Surface `paymentURL` only when
291
- `pending_billing` says customer action is required, then surface `connectURL`
292
- for provider approval. Replaying a connected account ID is stable; omit
293
- `--account-id` after completion only to connect another account.
286
+ account. LinkedIn normally charges the stored card before hosted provider
287
+ approval. X starts OAuth without charging, then purchases any missing provider
288
+ or legacy seat after a distinct, owned identity is authorized. Payment retries
289
+ retain that identity and keep the account unavailable until payment succeeds.
290
+ In a non-TTY shell, omit `--account-id` on the first call, capture the returned
291
+ `accountId`, and pass it back as `--account-id <accountId>` on every poll.
292
+ Surface `connectURL` for `pending_approval` and `paymentURL` for `pending_billing`.
293
+ Replaying a connected ID is stable; omit `--account-id` after completion only
294
+ to connect another account.
294
295
 
295
296
  `social account billing` prints Social LinkedIn and Social X independently.
296
297
  Social LinkedIn costs $20 per connected account with flat proxy usage. Social X
package/dist/index.mjs CHANGED
@@ -24845,7 +24845,7 @@ function createEnv(opts) {
24845
24845
  }
24846
24846
  //#endregion
24847
24847
  //#region package.json
24848
- var version$1 = "0.19.9";
24848
+ var version$1 = "0.19.11";
24849
24849
  //#endregion
24850
24850
  //#region src/lib/env.ts
24851
24851
  const URLWithTrailingSlash = url().transform(ensureTrailingSlash);
@@ -31533,20 +31533,42 @@ var SilentExit = class extends Error {
31533
31533
  this.code = code;
31534
31534
  }
31535
31535
  };
31536
+ const isKnownCLIError = (error) => error instanceof SilentExit || error instanceof ZodError || isCittyUsageError(error) || error instanceof UsageError || error instanceof CancelledError || error instanceof AuthError || error instanceof NotFoundError || error instanceof CLIAPIError;
31537
+ const isClassifiedCittyUsageError = (error) => error instanceof Error && error.name === "CLIError" && "code" in error && typeof error.code === "string";
31538
+ /** Returns the first known CLI/API error in a bounded cause chain. */
31539
+ const classificationErrorFor = (error) => {
31540
+ let candidate = error;
31541
+ const seen = /* @__PURE__ */ new Set();
31542
+ for (let depth = 0; depth < 5; depth += 1) {
31543
+ if (isKnownCLIError(candidate)) return candidate;
31544
+ if (!(candidate && typeof candidate === "object")) break;
31545
+ if (seen.has(candidate)) break;
31546
+ seen.add(candidate);
31547
+ if (!("cause" in candidate)) break;
31548
+ candidate = candidate.cause;
31549
+ }
31550
+ };
31536
31551
  const exitCodeFor = (error) => {
31537
- if (error instanceof SilentExit) return error.code;
31538
- if (error instanceof ZodError || isCittyUsageError(error)) return EXIT.usage;
31539
- if (error instanceof UsageError || error instanceof CancelledError) return EXIT.usage;
31540
- if (error instanceof AuthError) return EXIT.auth;
31541
- if (error instanceof NotFoundError) return EXIT.notFound;
31542
- if (error instanceof CLIAPIError) {
31543
- if (error.status === 404) return EXIT.notFound;
31544
- if (error.status === 401 || error.status === 403) return EXIT.auth;
31545
- if (error.status === 429) return EXIT.rateLimited;
31546
- if (error.status >= 400) return EXIT.api;
31552
+ const classified = classificationErrorFor(error);
31553
+ if (!classified) return EXIT.api;
31554
+ if (classified instanceof SilentExit) return classified.code;
31555
+ if (classified instanceof ZodError || isClassifiedCittyUsageError(classified)) return EXIT.usage;
31556
+ if (classified instanceof UsageError || classified instanceof CancelledError) return EXIT.usage;
31557
+ if (classified instanceof AuthError) return EXIT.auth;
31558
+ if (classified instanceof NotFoundError) return EXIT.notFound;
31559
+ if (classified instanceof CLIAPIError) {
31560
+ if (classified.status === 404) return EXIT.notFound;
31561
+ if (classified.status === 401 || classified.status === 403) return EXIT.auth;
31562
+ if (classified.status === 429) return EXIT.rateLimited;
31563
+ if (classified.status >= 400) return EXIT.api;
31547
31564
  }
31548
31565
  return EXIT.api;
31549
31566
  };
31567
+ const isExpectedFailure = (error, exitCode) => {
31568
+ if (exitCode === EXIT.usage || exitCode === EXIT.auth || exitCode === EXIT.notFound || exitCode === EXIT.rateLimited) return true;
31569
+ const classified = classificationErrorFor(error);
31570
+ return classified instanceof CLIAPIError && classified.status < 500;
31571
+ };
31550
31572
  //#endregion
31551
31573
  //#region src/lib/analytics.ts
31552
31574
  /**
@@ -31654,17 +31676,19 @@ const topFrameLabel = (error) => {
31654
31676
  return frame ? `${frame.functionName}@${frame.basename}:${frame.line}` : void 0;
31655
31677
  };
31656
31678
  const failureFingerprint = (error, command) => {
31657
- if (error instanceof CLIAPIError) return `CLIAPIError:${error.status}:${error.code ?? "unknown"}`;
31658
- if (error instanceof ZodError) {
31659
- const [issue] = error.issues;
31679
+ const metadata = errorMetadata(error);
31680
+ const classified = metadata?.name === "SyncPageError" && metadata._tag === "SyncPageError" ? classificationErrorFor(error) : error;
31681
+ if (classified instanceof CLIAPIError) return `CLIAPIError:${classified.status}:${classified.code ?? "unknown"}`;
31682
+ if (classified instanceof ZodError) {
31683
+ const [issue] = classified.issues;
31660
31684
  const issuePath = issue?.path.map(String).join(".") || "unknown";
31661
31685
  return `ZodError:${command ?? "unknown"}:${issuePath}:${issue?.code ?? "unknown"}`;
31662
31686
  }
31663
- if (error instanceof Error) {
31664
- const code = cittyErrorCode(error);
31687
+ if (classified instanceof Error) {
31688
+ const code = cittyErrorCode(classified);
31665
31689
  if (code !== void 0) return `CLIError:${code}:${command ?? "unknown"}`;
31666
31690
  }
31667
- if (isTypedCLIError(error)) return `${error.name}:${command ?? "unknown"}`;
31691
+ if (isTypedCLIError(classified)) return `${classified.name}:${command ?? "unknown"}`;
31668
31692
  return `${errorName(error)}:unknown:${topFrameLabel(error) ?? "unknown"}`;
31669
31693
  };
31670
31694
  const sanitizeExceptionForPostHog = (error, command) => {
@@ -34331,7 +34355,7 @@ const platformLabel = (platform) => platform === "x" ? "X" : "LinkedIn";
34331
34355
  const lifecycleConnectContract = writeCLIContract({
34332
34356
  hazards: [{
34333
34357
  code: "account_connect_billing",
34334
- message: "The first call can start provider billing; pass the returned accountId when polling so retries cannot start another charge."
34358
+ message: "LinkedIn can charge on the first call; X charges after OAuth. Pass the returned accountId on every retry."
34335
34359
  }],
34336
34360
  idField: "accountId",
34337
34361
  idempotency: {
@@ -41158,7 +41182,7 @@ const captureCommandException = (error, exitCode, telemetry, now) => {
41158
41182
  command: commandContext?.command,
41159
41183
  durationMs: commandContext ? now() - commandContext.startedAt : void 0,
41160
41184
  exitCode,
41161
- expected: exitCode === EXIT.usage || exitCode === EXIT.auth || exitCode === EXIT.notFound || exitCode === EXIT.rateLimited || error instanceof CLIAPIError && error.status < 500,
41185
+ expected: isExpectedFailure(error, exitCode),
41162
41186
  group: commandContext?.group,
41163
41187
  handled: true
41164
41188
  }));