@usesocial/cli 0.19.4 → 0.19.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 CHANGED
@@ -1,5 +1,17 @@
1
1
  # @usesocial/cli
2
2
 
3
+ ## 0.19.6
4
+
5
+ ### Patch Changes
6
+
7
+ - [#147](https://github.com/usesocial/monorepo/pull/147) [`df61320`](https://github.com/usesocial/monorepo/commit/df61320ec0e5d4eacc9eae02c843710be388d532) Thanks [@CyrusNuevoDia](https://github.com/CyrusNuevoDia)! - Advertise normalized X and LinkedIn result envelopes, simplify LinkedIn mirror views, and keep LinkedIn usage logs at zero cost.
8
+
9
+ ## 0.19.5
10
+
11
+ ### Patch Changes
12
+
13
+ - [#145](https://github.com/usesocial/monorepo/pull/145) [`53da7fa`](https://github.com/usesocial/monorepo/commit/53da7fae95987f30845666f836cb82f5f7c8a309) Thanks [@CyrusNuevoDia](https://github.com/CyrusNuevoDia)! - Replace `--attempt` with `--account-id` for resumable LinkedIn and X connections.
14
+
3
15
  ## 0.19.4
4
16
 
5
17
  ### Patch Changes
package/README.md CHANGED
@@ -159,8 +159,8 @@ profile lookup is needed.
159
159
  | `(bare)` | Show who is signed in and list connected accounts. | |
160
160
  | `login` | Device sign-in and scope selection. | |
161
161
  | `logout` | Revoke the session and clear the saved token. | |
162
- | `connect linkedin [--attempt <id>]` | Start a LinkedIn billing-and-connect attempt, or resume the exact returned attempt. | write |
163
- | `connect x [--attempt <id>]` | Start an X billing-and-connect attempt, or resume the exact returned attempt. | write |
162
+ | `connect linkedin [--account-id <id>]` | Start a LinkedIn connection, or resume the exact returned account. | write |
163
+ | `connect x [--account-id <id>]` | Start an X connection, or resume the exact returned account. | write |
164
164
  | `reconnect linkedin <account>` | Re-auth an existing LinkedIn account. | write |
165
165
  | `reconnect x <account>` | Re-auth an existing X account. | write |
166
166
  | `disconnect linkedin <account>` | Disconnect a LinkedIn account. | write |
@@ -282,15 +282,15 @@ session and removes the stored token. Non-interactive callers should surface the
282
282
  returned approval or checkout URL, then rerun `social account setup` until it is
283
283
  `ready`.
284
284
 
285
- `social account connect <platform>` starts or resumes a server-owned attempt
286
- that purchases only that provider's plan or next seat, or the applicable legacy
287
- Social Pro seat during transition. It normally charges the stored card directly
288
- before returning hosted provider approval. In a non-TTY
289
- shell, omit `--attempt` on the first call, capture the returned `attemptId`, and
290
- pass it back as `--attempt <attemptId>` on every poll. Surface `paymentURL` only
291
- when `pending_billing` says customer action is required, then surface
292
- `connectURL` for provider approval. Replaying a completed attempt is stable;
293
- omit `--attempt` after completion only to connect another account.
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.
294
294
 
295
295
  `social account billing` prints Social LinkedIn and Social X independently.
296
296
  Social LinkedIn costs $20 per connected account with flat proxy usage. Social X
package/dist/index.mjs CHANGED
@@ -1246,16 +1246,123 @@ const helpDescriptionFor = (adapter, op, context) => {
1246
1246
  };
1247
1247
  const buildRuntimeContract = (adapter, op, context) => {
1248
1248
  const hazard = adapter.hazardFor(op);
1249
+ const upstreamPagination = op.endpoint.pagination;
1250
+ const listOutput = upstreamPagination.style !== "none";
1251
+ const pagination = upstreamPagination.style === "none" ? upstreamPagination : upstreamPagination.style === "cursor" ? {
1252
+ style: "cursor",
1253
+ ...upstreamPagination.limitParam ? { limitParam: upstreamPagination.limitParam } : {},
1254
+ ...upstreamPagination.cursorParam ? { cursorParam: upstreamPagination.cursorParam } : {},
1255
+ cursorPath: "meta.cursor",
1256
+ itemsPath: "items",
1257
+ ..."totalCountPath" in upstreamPagination && upstreamPagination.totalCountPath ? { totalCountPath: "meta.totalCount" } : {}
1258
+ } : {
1259
+ style: "offset",
1260
+ ...upstreamPagination.limitParam ? { limitParam: upstreamPagination.limitParam } : {},
1261
+ offsetParam: upstreamPagination.offsetParam,
1262
+ itemsPath: "items",
1263
+ ...upstreamPagination.totalCountPath ? { totalCountPath: "meta.totalCount" } : {}
1264
+ };
1265
+ const outputSchema = {
1266
+ $schema: "https://json-schema.org/draft/2020-12/schema",
1267
+ type: "object",
1268
+ properties: {
1269
+ account: {
1270
+ type: "object",
1271
+ properties: {
1272
+ platform: { type: "string" },
1273
+ username: { type: ["string", "null"] }
1274
+ },
1275
+ required: ["platform"],
1276
+ additionalProperties: false
1277
+ },
1278
+ ...listOutput ? { items: {
1279
+ type: "array",
1280
+ items: {}
1281
+ } } : { data: {
1282
+ type: "object",
1283
+ additionalProperties: true
1284
+ } },
1285
+ meta: {
1286
+ type: "object",
1287
+ properties: {
1288
+ resolved: {
1289
+ type: "array",
1290
+ items: {
1291
+ type: "object",
1292
+ properties: {
1293
+ input: { type: "string" },
1294
+ id: { type: "string" },
1295
+ url: { type: "string" },
1296
+ source: { type: "string" }
1297
+ },
1298
+ required: [
1299
+ "input",
1300
+ "id",
1301
+ "source"
1302
+ ],
1303
+ additionalProperties: true
1304
+ }
1305
+ },
1306
+ cost: {
1307
+ type: "number",
1308
+ minimum: 0
1309
+ },
1310
+ cache: {
1311
+ type: "object",
1312
+ properties: {
1313
+ hit: { type: "boolean" },
1314
+ status: { type: "string" },
1315
+ age_s: { type: ["number", "null"] },
1316
+ source: { type: "string" },
1317
+ tables: {
1318
+ type: "array",
1319
+ items: {
1320
+ type: "object",
1321
+ additionalProperties: true
1322
+ }
1323
+ },
1324
+ migration: {
1325
+ type: "object",
1326
+ additionalProperties: true
1327
+ }
1328
+ },
1329
+ required: ["hit"],
1330
+ additionalProperties: true
1331
+ },
1332
+ cursor: { type: "string" },
1333
+ totalCount: { type: "number" },
1334
+ errors: {
1335
+ type: "array",
1336
+ items: {}
1337
+ },
1338
+ includes: {
1339
+ type: "object",
1340
+ additionalProperties: true
1341
+ }
1342
+ },
1343
+ required: ["resolved", "cache"],
1344
+ additionalProperties: true
1345
+ }
1346
+ },
1347
+ required: [
1348
+ "account",
1349
+ listOutput ? "items" : "data",
1350
+ "meta"
1351
+ ],
1352
+ additionalProperties: false
1353
+ };
1249
1354
  return {
1250
1355
  inputSchema: adapter.schema(adapter.contractInputSchemaName(op)),
1251
- outputSchema: adapter.schema(`${op.schemaBaseName}Output`),
1356
+ outputSchema,
1357
+ upstreamOutputSchema: adapter.schema(`${op.schemaBaseName}Output`),
1252
1358
  auth: adapter.authFor(op),
1253
1359
  capability: op.endpoint.capability,
1254
1360
  mutates: op.endpoint.mutates,
1255
1361
  method: op.endpoint.method,
1256
1362
  idempotency: adapter.idempotencyFor(op),
1257
1363
  ...hazard ? { hazard } : {},
1258
- pagination: op.endpoint.pagination,
1364
+ pagination,
1365
+ upstreamPagination,
1259
1366
  responseShaping: adapter.responseShapingFor(op),
1260
1367
  ...adapter.includeIdField === true && op.config.idField ? { idField: op.config.idField } : {},
1261
1368
  ...op.config.itemUrlTemplate ? { itemUrlTemplate: op.config.itemUrlTemplate } : {},
@@ -1793,7 +1900,7 @@ const userTypeValues = ["individual", "organization"];
1793
1900
  const LINKEDIN_CACHE_METADATA = {
1794
1901
  joins: [
1795
1902
  "li_*.user_id = li_profiles.provider_id",
1796
- "li_messages.conversation_id = li_conversations.id",
1903
+ "li_messages.chat_id = li_conversations.chat_id",
1797
1904
  "li_messages.sender_id = li_profiles.provider_id",
1798
1905
  "li_posts.author_id = li_profiles.provider_id"
1799
1906
  ],
@@ -1803,8 +1910,7 @@ const LINKEDIN_CACHE_METADATA = {
1803
1910
  "li_conversations.user_type": userTypeValues,
1804
1911
  "li_messages.sender_type": userTypeValues,
1805
1912
  "li_posts.author_type": userTypeValues,
1806
- "li_requests.type": ["received", "sent"],
1807
- "li_requests.user_type": userTypeValues
1913
+ "li_requests.type": ["received", "sent"]
1808
1914
  },
1809
1915
  indexed: {
1810
1916
  li_connections: [
@@ -1823,7 +1929,7 @@ const LINKEDIN_CACHE_METADATA = {
1823
1929
  ],
1824
1930
  li_messages: [
1825
1931
  "created_at",
1826
- "conversation_id",
1932
+ "chat_id",
1827
1933
  "sender_id"
1828
1934
  ],
1829
1935
  li_posts: [
@@ -2430,6 +2536,10 @@ const MIGRATIONS = [
2430
2536
  {
2431
2537
  "tag": "0010_x_timeline",
2432
2538
  "sql": "CREATE TABLE \"x_timeline_raw\" (\n \"id\" text PRIMARY KEY NOT NULL,\n \"created_at\" integer,\n \"author_id\" text,\n \"conversation_id\" text,\n \"in_reply_to_user_id\" text,\n \"lang\" text,\n \"reply_settings\" text,\n \"text\" text,\n \"url\" text,\n \"paid_partnership\" integer,\n \"possibly_sensitive\" integer,\n \"like_count\" integer,\n \"retweet_count\" integer,\n \"reply_count\" integer,\n \"quote_count\" integer,\n \"bookmark_count\" integer,\n \"impression_count\" integer,\n \"raw\" text NOT NULL,\n \"synced_at\" integer NOT NULL\n);\n--> statement-breakpoint\nCREATE INDEX \"x_timeline_created_at_idx\" ON \"x_timeline_raw\" (\"created_at\");--> statement-breakpoint\nCREATE INDEX \"x_timeline_author_id_created_at_idx\" ON \"x_timeline_raw\" (\"author_id\",\"created_at\");--> statement-breakpoint\nCREATE INDEX \"x_timeline_conversation_id_created_at_idx\" ON \"x_timeline_raw\" (\"conversation_id\",\"created_at\");--> statement-breakpoint\nCREATE VIEW \"x_timeline\" AS\nSELECT \"id\", \"created_at\", \"author_id\", \"conversation_id\", \"in_reply_to_user_id\", \"lang\",\n \"reply_settings\", \"text\", \"url\", \"paid_partnership\", \"possibly_sensitive\",\n \"like_count\", \"retweet_count\", \"reply_count\", \"quote_count\", \"bookmark_count\",\n \"impression_count\"\nFROM \"x_timeline_raw\";\n"
2539
+ },
2540
+ {
2541
+ "tag": "0011_linkedin_public_views",
2542
+ "sql": "DROP VIEW IF EXISTS \"li_requests\";\nDROP VIEW IF EXISTS \"li_conversations\";\nDROP VIEW IF EXISTS \"li_messages\";\nCREATE VIEW \"li_requests\" AS\nSELECT \"id\", \"created_at\", \"type\", json_extract(\"raw\", '$.message') AS \"message\",\n \"user_id\", \"user_public_identifier\" AS \"user_username\",\n \"user_display_name\" AS \"user_name\",\n COALESCE(\"user_headline\", \"user_description\") AS \"user_headline\",\n \"user_profile_url\", \"user_public_picture_url\" AS \"user_avatar_url\"\nFROM \"li_requests_raw\";\nCREATE VIEW \"li_conversations\" AS\nSELECT \"id\" AS \"chat_id\", \"created_at\", \"last_message_timestamp\" AS \"last_message_at\", \"name\",\n CASE\n WHEN \"is_1to1\" = 1 THEN '1to1'\n WHEN \"is_group\" = 1 THEN 'group'\n ELSE \"type\"\n END AS \"type\",\n \"unread_count\", \"is_archived\", \"is_pinned\", \"is_readonly\", \"is_channel\",\n \"muted_until\", \"image_url\", \"creator_id\", \"user_id\",\n \"user_public_identifier\" AS \"user_username\", \"user_display_name\" AS \"user_name\",\n COALESCE(\"user_headline\", \"user_description\") AS \"user_headline\", \"user_description\",\n \"user_profile_url\", \"user_public_picture_url\" AS \"user_avatar_url\", \"user_type\",\n \"user_specifics_network_distance\" AS \"user_distance\"\nFROM \"li_conversations_raw\";\nCREATE VIEW \"li_messages\" AS\nSELECT \"id\", \"timestamp\" AS \"created_at\", \"chat_id\", \"text\",\n \"sender_id\", \"is_deleted\", \"is_delivered\", \"is_edited\", \"is_event\", \"is_hidden\",\n \"is_mentionned\" AS \"is_mentioned\", \"is_pinned\", \"is_seen\", \"is_sender\",\n \"sender_public_identifier\" AS \"sender_username\",\n \"sender_display_name\" AS \"sender_name\", \"sender_description\" AS \"sender_headline\",\n \"sender_public_picture_url\" AS \"sender_avatar_url\", \"sender_profile_url\",\n \"sender_type\", \"sender_specifics_network_distance\" AS \"sender_distance\"\nFROM \"li_messages_raw\";\n"
2433
2543
  }
2434
2544
  ];
2435
2545
  //#endregion
@@ -11042,20 +11152,19 @@ function uniqueIndex(name) {
11042
11152
  //#endregion
11043
11153
  //#region ../../packages/db/src/domain.ts
11044
11154
  const PLATFORMS = ["linkedin", "x"];
11045
- const CONNECTED_ACCOUNT_STATUSES = [
11155
+ const MATERIALIZED_CONNECTED_ACCOUNT_STATUSES = [
11046
11156
  "connected",
11047
11157
  "credentials",
11048
11158
  "connecting",
11049
11159
  "disconnected",
11050
11160
  "error"
11051
11161
  ];
11052
- const ACCOUNT_CONNECT_ATTEMPT_LANES = ["provider", "legacy"];
11053
- const ACCOUNT_CONNECT_ATTEMPT_STATUSES = [
11162
+ const CONNECTED_ACCOUNT_STATUSES = [
11163
+ ...MATERIALIZED_CONNECTED_ACCOUNT_STATUSES,
11054
11164
  "pending_billing",
11055
11165
  "pending_approval",
11056
- "connected",
11057
- "expired",
11058
- "failed"
11166
+ "failed",
11167
+ "expired"
11059
11168
  ];
11060
11169
  const PROXY_SURFACES = [
11061
11170
  "cli",
@@ -11118,8 +11227,7 @@ const WEBHOOK_OPERATION_STATES = [
11118
11227
  ];
11119
11228
  _enum(PLATFORMS);
11120
11229
  _enum(CONNECTED_ACCOUNT_STATUSES);
11121
- _enum(ACCOUNT_CONNECT_ATTEMPT_LANES);
11122
- _enum(ACCOUNT_CONNECT_ATTEMPT_STATUSES);
11230
+ _enum(MATERIALIZED_CONNECTED_ACCOUNT_STATUSES);
11123
11231
  _enum(PROXY_SURFACES);
11124
11232
  _enum(PROXY_CACHE_STATUSES);
11125
11233
  _enum(PROXY_CAPABILITIES);
@@ -11294,52 +11402,36 @@ const connectedAccounts = pgTable("connected_accounts", {
11294
11402
  id: text$1("id").primaryKey().$defaultFn(() => crypto.randomUUID()),
11295
11403
  userId: text$1("user_id").notNull().references(() => user.id, { onDelete: "cascade" }),
11296
11404
  platform: text$1("platform", { enum: PLATFORMS }).notNull(),
11297
- platformAccountId: text$1("platform_account_id").notNull(),
11298
- platformProfileId: text$1("platform_profile_id").notNull(),
11299
- username: text$1("username").notNull(),
11300
- displayName: text$1("display_name").notNull(),
11405
+ platformAccountId: text$1("platform_account_id"),
11406
+ platformProfileId: text$1("platform_profile_id"),
11407
+ username: text$1("username"),
11408
+ displayName: text$1("display_name"),
11301
11409
  profileImageURL: text$1("profile_image_url"),
11302
11410
  status: text$1("status", { enum: CONNECTED_ACCOUNT_STATUSES }).notNull().default("connected"),
11303
11411
  platformData: jsonb("platform_data").$type().notNull().default(sql`'{}'::jsonb`),
11304
- connectedAt: timestamptz("connected_at").notNull().defaultNow(),
11305
- lastSeenAt: timestamptz("last_seen_at").notNull().defaultNow()
11306
- }, (table) => [
11307
- uniqueIndex("connected_accounts_platform_account_pkey").on(table.platform, table.platformAccountId),
11308
- uniqueIndex("connected_accounts_user_platform_pkey").on(table.userId, table.platform, table.platformAccountId),
11309
- uniqueIndex("connected_accounts_user_platform_id_key").on(table.userId, table.platform, table.id),
11310
- index("connected_accounts_user_platform_idx").on(table.userId, table.platform).where(sql`${table.status} = 'connected'`),
11311
- index("connected_accounts_user_username_idx").on(table.userId, table.platform, table.username),
11312
- check("connected_accounts_platform_check", sqlCheckIn(table.platform, PLATFORMS)),
11313
- check("connected_accounts_status_check", sqlCheckIn(table.status, CONNECTED_ACCOUNT_STATUSES))
11314
- ]);
11315
- pgTable("account_connect_attempts", {
11316
- id: text$1("id").primaryKey().$defaultFn(() => crypto.randomUUID()),
11317
- userId: text$1("user_id").notNull().references(() => user.id, { onDelete: "cascade" }),
11318
- platform: text$1("platform", { enum: PLATFORMS }).notNull(),
11319
- lane: text$1("lane", { enum: ACCOUNT_CONNECT_ATTEMPT_LANES }).notNull(),
11320
- targetPaidSeats: integer("target_paid_seats").notNull(),
11321
- status: text$1("status", { enum: ACCOUNT_CONNECT_ATTEMPT_STATUSES }).notNull().default("pending_billing"),
11322
- connectedAccountId: text$1("connected_account_id").references(() => connectedAccounts.id, { onDelete: "set null" }),
11323
- operationKey: text$1("operation_key").notNull(),
11412
+ connectExpiresAt: timestamptz("connect_expires_at"),
11413
+ connectURL: text$1("connect_url"),
11324
11414
  billingPaymentURL: text$1("billing_payment_url"),
11325
11415
  billingRequiredAction: jsonb("billing_required_action").$type(),
11326
11416
  failureCode: text$1("failure_code"),
11327
11417
  failureStage: text$1("failure_stage"),
11328
- hostedAuthBindingId: text$1("hosted_auth_binding_id"),
11329
- hostedAuthAccountId: text$1("hosted_auth_account_id"),
11330
- hostedAuthBoundAt: timestamptz("hosted_auth_bound_at"),
11331
- expiresAt: timestamptz("expires_at").notNull(),
11418
+ connectedAt: timestamptz("connected_at"),
11419
+ lastSeenAt: timestamptz("last_seen_at"),
11332
11420
  createdAt: timestamptz("created_at").notNull().defaultNow(),
11333
11421
  updatedAt: timestamptz("updated_at").notNull().defaultNow().$onUpdate(() => /* @__PURE__ */ new Date())
11334
11422
  }, (table) => [
11335
- uniqueIndex("account_connect_attempts_operation_key_key").on(table.operationKey),
11336
- uniqueIndex("account_connect_attempts_hosted_auth_binding_id_key").on(table.hostedAuthBindingId),
11337
- uniqueIndex("account_connect_attempts_active_user_platform_key").on(table.userId, table.platform).where(sql`${table.status} in ('pending_billing', 'pending_approval')`),
11338
- index("account_connect_attempts_expiry_idx").on(table.expiresAt).where(sql`${table.status} in ('pending_billing', 'pending_approval')`),
11339
- check("account_connect_attempts_platform_check", sqlCheckIn(table.platform, PLATFORMS)),
11340
- check("account_connect_attempts_lane_check", sqlCheckIn(table.lane, ACCOUNT_CONNECT_ATTEMPT_LANES)),
11341
- check("account_connect_attempts_status_check", sqlCheckIn(table.status, ACCOUNT_CONNECT_ATTEMPT_STATUSES)),
11342
- check("account_connect_attempts_target_paid_seats_check", sql`${table.targetPaidSeats} >= 0`)
11423
+ uniqueIndex("connected_accounts_platform_account_pkey").on(table.platform, table.platformAccountId),
11424
+ uniqueIndex("connected_accounts_platform_profile_pkey").on(table.platform, table.platformProfileId).where(sql`${table.platformProfileId} is not null`),
11425
+ uniqueIndex("connected_accounts_user_platform_pkey").on(table.userId, table.platform, table.platformAccountId),
11426
+ uniqueIndex("connected_accounts_user_platform_id_key").on(table.userId, table.platform, table.id),
11427
+ index("connected_accounts_user_platform_idx").on(table.userId, table.platform).where(sql`${table.status} = 'connected'`),
11428
+ index("connected_accounts_user_username_idx").on(table.userId, table.platform, table.username),
11429
+ uniqueIndex("connected_accounts_active_partial_user_platform_key").on(table.userId, table.platform).where(sql`${table.status} in ('pending_billing', 'pending_approval')`),
11430
+ index("connected_accounts_partial_expiry_idx").on(table.connectExpiresAt).where(sql`${table.status} in ('pending_billing', 'pending_approval')`),
11431
+ index("connected_accounts_terminal_updated_idx").on(table.updatedAt).where(sql`${table.status} in ('failed', 'expired')`),
11432
+ check("connected_accounts_platform_check", sqlCheckIn(table.platform, PLATFORMS)),
11433
+ check("connected_accounts_status_check", sqlCheckIn(table.status, CONNECTED_ACCOUNT_STATUSES)),
11434
+ check("connected_accounts_materialized_fields_check", sql`${table.status} in ('pending_billing', 'pending_approval', 'failed', 'expired') or (${table.platformAccountId} is not null and ${table.platformProfileId} is not null and ${table.username} is not null and ${table.displayName} is not null and ${table.connectedAt} is not null and ${table.lastSeenAt} is not null)`)
11343
11435
  ]);
11344
11436
  pgTable("account_defaults", {
11345
11437
  userId: text$1("user_id").notNull(),
@@ -22836,18 +22928,18 @@ const resolveDisconnectTarget = async (deps, identifier) => {
22836
22928
  if (ae.isError(account)) throw account.error;
22837
22929
  return account.value;
22838
22930
  };
22839
- const connectLinkedinAccount = async (deps, attemptId) => {
22931
+ const connectLinkedinAccount = async (deps, accountId) => {
22840
22932
  const intervalMs = deps.pollIntervalMs ?? DEFAULT_POLL_INTERVAL_MS;
22841
22933
  const sleep = deps.sleep ?? setTimeout$1;
22842
22934
  const startedAt = Date.now();
22843
- let currentAttemptId = attemptId;
22935
+ let currentAccountId = accountId;
22844
22936
  const surfacedURLs = /* @__PURE__ */ new Set();
22845
22937
  while (Date.now() - startedAt < CONNECT_POLL_TIMEOUT_MS) {
22846
22938
  const state = await deps.client.connectStep({
22847
22939
  platform: LINKEDIN_PLATFORM,
22848
- ...currentAttemptId ? { attemptId: currentAttemptId } : {}
22940
+ ...currentAccountId ? { accountId: currentAccountId } : {}
22849
22941
  });
22850
- currentAttemptId = state.attemptId;
22942
+ currentAccountId = state.accountId;
22851
22943
  if (state.status === "connected") return {
22852
22944
  platform: LINKEDIN_PLATFORM,
22853
22945
  status: "connected",
@@ -23013,18 +23105,18 @@ const listXLifecycleAccounts = async (deps, includeDisconnected) => ae.ok(await
23013
23105
  platform: "x",
23014
23106
  includeDisconnected
23015
23107
  }));
23016
- const connectXAccount = async (deps, attemptId) => {
23108
+ const connectXAccount = async (deps, accountId) => {
23017
23109
  const sleep = deps.sleep ?? defaultSleep;
23018
23110
  const now = deps.now ?? Date.now;
23019
23111
  const startedAt = now();
23020
- let currentAttemptId = attemptId;
23112
+ let currentAccountId = accountId;
23021
23113
  const surfacedURLs = /* @__PURE__ */ new Set();
23022
23114
  while (now() - startedAt < CONNECT_TIMEOUT_MS) {
23023
23115
  const state = await deps.client.connectStep({
23024
23116
  platform: "x",
23025
- ...currentAttemptId ? { attemptId: currentAttemptId } : {}
23117
+ ...currentAccountId ? { accountId: currentAccountId } : {}
23026
23118
  });
23027
- currentAttemptId = state.attemptId;
23119
+ currentAccountId = state.accountId;
23028
23120
  if (state.status === "connected") return ae.ok({
23029
23121
  platform: "x",
23030
23122
  status: "connected",
@@ -24489,7 +24581,7 @@ function createEnv(opts) {
24489
24581
  }
24490
24582
  //#endregion
24491
24583
  //#region package.json
24492
- var version$1 = "0.19.4";
24584
+ var version$1 = "0.19.6";
24493
24585
  //#endregion
24494
24586
  //#region src/lib/env.ts
24495
24587
  const URLWithTrailingSlash = url().transform(ensureTrailingSlash);
@@ -25158,14 +25250,14 @@ const cacheFromLocal = (local, now) => ({
25158
25250
  });
25159
25251
  const nextCursorFrom = (contract, data) => {
25160
25252
  if (!isRecord$7(contract)) return;
25161
- const pagination = contract.pagination;
25253
+ const pagination = contract.upstreamPagination ?? contract.pagination;
25162
25254
  if (!isRecord$7(pagination)) return;
25163
25255
  const response = pagination.response;
25164
25256
  return stringAtPath(data, isRecord$7(response) ? response.nextCursorPath : null) ?? stringAtPath(data, pagination.cursorPath);
25165
25257
  };
25166
25258
  const totalCountFrom = (contract, data) => {
25167
25259
  if (!isRecord$7(contract)) return;
25168
- const pagination = contract.pagination;
25260
+ const pagination = contract.upstreamPagination ?? contract.pagination;
25169
25261
  if (!isRecord$7(pagination)) return;
25170
25262
  return numberAtPath(data, pagination.totalCountPath);
25171
25263
  };
@@ -33483,22 +33575,26 @@ const USAGE_LOG_PAGE_LIMIT = 100;
33483
33575
  const USAGE_LOG_MAX_AUTO_PAGES = 50;
33484
33576
  const cursorFrom = (usage) => usage.nextCursor ?? null;
33485
33577
  const normalizeUsageLogForOutput = (item) => {
33578
+ const withLinkedinSeatPricing = (log) => log.platform === "linkedin" ? {
33579
+ ...log,
33580
+ usageUSD: 0
33581
+ } : log;
33486
33582
  if (typeof item === "object" && item !== null && "createdAt" in item && item.createdAt instanceof Date) {
33487
33583
  const { credits, ...rest } = item;
33488
- return {
33584
+ return withLinkedinSeatPricing({
33489
33585
  ...rest,
33490
33586
  createdAt: item.createdAt.toISOString(),
33491
33587
  ...typeof credits === "number" ? { usageUSD: creditsToUsageUSD(credits) } : {}
33492
- };
33588
+ });
33493
33589
  }
33494
33590
  if (typeof item === "object" && item !== null && "credits" in item) {
33495
33591
  const { credits, ...rest } = item;
33496
- return {
33592
+ return withLinkedinSeatPricing({
33497
33593
  ...rest,
33498
33594
  ...typeof credits === "number" ? { usageUSD: creditsToUsageUSD(credits) } : {}
33499
- };
33595
+ });
33500
33596
  }
33501
- return item;
33597
+ return typeof item === "object" && item !== null ? withLinkedinSeatPricing(item) : item;
33502
33598
  };
33503
33599
  const sumByFrom = (value) => {
33504
33600
  if (value === void 0) return;
@@ -33661,13 +33757,13 @@ const AccountDefaultSetInput = AccountDefaultGetInput.extend({ account: string()
33661
33757
  const AccountConnectStateOutput = discriminatedUnion("status", [
33662
33758
  object({
33663
33759
  status: literal("connected"),
33664
- attemptId: uuid$1(),
33760
+ accountId: uuid$1(),
33665
33761
  platform: _enum(["linkedin", "x"]),
33666
33762
  account: LifecycleAccountOutput
33667
33763
  }),
33668
33764
  object({
33669
33765
  status: literal("pending_billing"),
33670
- attemptId: uuid$1(),
33766
+ accountId: uuid$1(),
33671
33767
  platform: _enum(["linkedin", "x"]),
33672
33768
  plan: object({
33673
33769
  id: string(),
@@ -33686,14 +33782,14 @@ const AccountConnectStateOutput = discriminatedUnion("status", [
33686
33782
  }),
33687
33783
  object({
33688
33784
  status: literal("pending_approval"),
33689
- attemptId: uuid$1(),
33785
+ accountId: uuid$1(),
33690
33786
  platform: _enum(["linkedin", "x"]),
33691
33787
  connectURL: string().nullable(),
33692
33788
  expiresAt: string()
33693
33789
  }),
33694
33790
  object({
33695
33791
  status: _enum(["expired", "failed"]),
33696
- attemptId: uuid$1(),
33792
+ accountId: uuid$1(),
33697
33793
  platform: _enum(["linkedin", "x"]),
33698
33794
  code: string(),
33699
33795
  retryable: boolean$1()
@@ -33788,12 +33884,12 @@ const lifecycleConnectContract = writeCLIContract({
33788
33884
  responseShaping: { supported: false },
33789
33885
  idempotency: {
33790
33886
  idempotent: false,
33791
- retrySafeWith: "attemptId"
33887
+ retrySafeWith: "accountId"
33792
33888
  },
33793
- idField: "attemptId",
33889
+ idField: "accountId",
33794
33890
  hazards: [{
33795
33891
  code: "account_connect_billing",
33796
- message: "The first call can start provider billing; pass the returned attemptId when polling so retries cannot start another charge."
33892
+ message: "The first call can start provider billing; pass the returned accountId when polling so retries cannot start another charge."
33797
33893
  }]
33798
33894
  });
33799
33895
  const usernameLabelFor = (account) => account.username.startsWith("@") ? account.username : `@${account.username}`;
@@ -33825,11 +33921,11 @@ const runConnectOutput = async (deps, connect) => {
33825
33921
  writeText(deps, `${usernameLabelFor(result.account)} connected!`);
33826
33922
  };
33827
33923
  const isInteractiveConnect = (deps) => deps.isInteractiveTerminal?.() === true;
33828
- /** One retry-safe connect step for a non-TTY caller; the JSON carries its next attempt ID. */
33829
- const runConnectStep = async (deps, platform, attemptId) => {
33924
+ /** One retry-safe connect step for a non-TTY caller; the JSON carries its account ID. */
33925
+ const runConnectStep = async (deps, platform, accountId) => {
33830
33926
  const state = await deps.client.connectStep({
33831
33927
  platform,
33832
- ...attemptId ? { attemptId } : {}
33928
+ ...accountId ? { accountId } : {}
33833
33929
  });
33834
33930
  await writeOutput(deps, state);
33835
33931
  };
@@ -33841,12 +33937,13 @@ const createConnectPlatformCommand = (platform, run) => defineCommand({
33841
33937
  contract: lifecycleConnectContract,
33842
33938
  mutates: true
33843
33939
  }),
33844
- args: { attempt: {
33940
+ args: { "account-id": {
33845
33941
  type: "string",
33846
- description: "Resume the exact connect attempt returned by a previous call."
33942
+ description: "Resume the exact connection returned by a previous call."
33847
33943
  } },
33848
- run: async ({ args }) => {
33849
- await run({ attempt: typeof args.attempt === "string" ? args.attempt : void 0 });
33944
+ run: async ({ args, rawArgs }) => {
33945
+ if (rawArgs?.includes("--attempt") || rawArgs?.some((arg) => arg.startsWith("--attempt="))) throw new UsageError("--attempt was removed; use --account-id.");
33946
+ await run({ accountId: typeof args["account-id"] === "string" ? args["account-id"] : void 0 });
33850
33947
  }
33851
33948
  });
33852
33949
  const createAccountPlatformCommand = (platform, description, run, options = {}) => defineCommand({
@@ -33932,23 +34029,23 @@ const createAccountCommand = (deps, accountSetupCommand = setupCommand) => {
33932
34029
  description: "Connect a LinkedIn or X account."
33933
34030
  },
33934
34031
  subCommands: {
33935
- linkedin: createConnectPlatformCommand("linkedin", async ({ attempt }) => {
34032
+ linkedin: createConnectPlatformCommand("linkedin", async ({ accountId }) => {
33936
34033
  if (isInteractiveConnect(deps)) {
33937
- await runConnectOutput(deps, (connectDeps) => connectLinkedinAccount(connectDeps, attempt));
34034
+ await runConnectOutput(deps, (connectDeps) => connectLinkedinAccount(connectDeps, accountId));
33938
34035
  return;
33939
34036
  }
33940
- await runConnectStep(deps, "linkedin", attempt);
34037
+ await runConnectStep(deps, "linkedin", accountId);
33941
34038
  }),
33942
- x: createConnectPlatformCommand("x", async ({ attempt }) => {
34039
+ x: createConnectPlatformCommand("x", async ({ accountId }) => {
33943
34040
  if (isInteractiveConnect(deps)) {
33944
34041
  await runConnectOutput(deps, async (connectDeps) => {
33945
- const result = await connectXAccount(connectDeps, attempt);
34042
+ const result = await connectXAccount(connectDeps, accountId);
33946
34043
  if (ae.isError(result)) throwXLifecycleError(result.error);
33947
34044
  return result.value;
33948
34045
  });
33949
34046
  return;
33950
34047
  }
33951
- await runConnectStep(deps, "x", attempt);
34048
+ await runConnectStep(deps, "x", accountId);
33952
34049
  })
33953
34050
  }
33954
34051
  });
@@ -39539,7 +39636,9 @@ const CLIContractMetadata = object({
39539
39636
  outputSchema: unknown().optional(),
39540
39637
  pagination: JSONMetadata.optional(),
39541
39638
  params: record(string(), JSONMetadata).optional(),
39542
- responseShaping: JSONMetadata.optional()
39639
+ responseShaping: JSONMetadata.optional(),
39640
+ upstreamOutputSchema: unknown().optional(),
39641
+ upstreamPagination: JSONMetadata.optional()
39543
39642
  }).strict();
39544
39643
  const issueSummary = (error) => error.issues.map((issue) => `${issue.path.join(".") || "<root>"}: ${issue.message}`).join("; ");
39545
39644
  const invalidMetadataError = (label, error) => /* @__PURE__ */ new Error(`Invalid CLI contract metadata for ${label}: ${issueSummary(error)}`);