@usesocial/cli 0.19.1 → 0.19.3

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,18 @@
1
1
  # @usesocial/cli
2
2
 
3
+ ## 0.19.3
4
+
5
+ ### Patch Changes
6
+
7
+ - [#139](https://github.com/usesocial/monorepo/pull/139) [`1f924b9`](https://github.com/usesocial/monorepo/commit/1f924b9a8c9229109210bab72cae3731912b3125) Thanks [@CyrusNuevoDia](https://github.com/CyrusNuevoDia)! - Clarify when disconnected accounts must use connect and when credential failures can reconnect without changing billing.
8
+
9
+ ## 0.19.2
10
+
11
+ ### Patch Changes
12
+
13
+ - [#118](https://github.com/usesocial/monorepo/pull/118) [`e6fbb0e`](https://github.com/usesocial/monorepo/commit/e6fbb0e5f3c9d94231a2835de0b39b2880cd4197) Thanks [@CyrusNuevoDia](https://github.com/CyrusNuevoDia)! - Return X profile, tweet, and list resources directly under `.data`, and preserve partial provider
14
+ errors and expansions in response metadata.
15
+
3
16
  ## 0.19.1
4
17
 
5
18
  ### Patch Changes
package/README.md CHANGED
@@ -235,6 +235,9 @@ profile lookup is needed.
235
235
  `.data`, metadata lives under `.meta`. Sync commands use `{ data, meta }`.
236
236
  `social account` service commands return bare JSON; `account logs` returns
237
237
  `{ items, meta: { cursor } }`.
238
+ - X single-resource reads keep partial expansion failures under `.meta.errors`
239
+ and returned expansion objects under `.meta.includes`, so the primary
240
+ resource remains directly usable at `.data`.
238
241
  - Schema-backed planning: `social schema --list` is the compact runnable index.
239
242
  - Local SQL is the free surface for your own synced data.
240
243
 
package/dist/index.mjs CHANGED
@@ -11069,6 +11069,11 @@ const PROXY_CACHE_STATUSES = [
11069
11069
  "n/a"
11070
11070
  ];
11071
11071
  const PROXY_CAPABILITIES = ["read", "write"];
11072
+ const BILLING_OPERATION_LEASE_KINDS = [
11073
+ "proxy_request",
11074
+ "seat_mutation",
11075
+ "social_plan_migration"
11076
+ ];
11072
11077
  const CLI_SCOPE_ALIASES$1 = ["read", "read,write"];
11073
11078
  const CLI_CAPABILITIES = [
11074
11079
  "social:read",
@@ -11118,6 +11123,7 @@ _enum(ACCOUNT_CONNECT_ATTEMPT_STATUSES);
11118
11123
  _enum(PROXY_SURFACES);
11119
11124
  _enum(PROXY_CACHE_STATUSES);
11120
11125
  _enum(PROXY_CAPABILITIES);
11126
+ _enum(BILLING_OPERATION_LEASE_KINDS);
11121
11127
  _enum(CLI_SCOPE_ALIASES$1);
11122
11128
  _enum(CLI_CAPABILITIES);
11123
11129
  _enum(FEEDBACK_TYPES);
@@ -11425,7 +11431,6 @@ pgTable("webhook_operations", {
11425
11431
  pgTable("billing_overrides", {
11426
11432
  email: text$1("email").primaryKey(),
11427
11433
  userId: text$1("user_id").references(() => user.id, { onDelete: "cascade" }),
11428
- seatAllowance: integer("seat_allowance").notNull().default(2),
11429
11434
  seatAllowanceLinkedin: integer("seat_allowance_linkedin").notNull().default(2),
11430
11435
  seatAllowanceX: integer("seat_allowance_x").notNull().default(2),
11431
11436
  monthlyUsageCredits: integer("monthly_usage_credits").notNull().default(6e4),
@@ -11437,7 +11442,6 @@ pgTable("billing_overrides", {
11437
11442
  uniqueIndex("billing_overrides_user_id_key").on(table.userId).where(sql`${table.userId} is not null`),
11438
11443
  check("billing_overrides_email_lower_check", sql`lower(${table.email}) = ${table.email}`),
11439
11444
  check("billing_overrides_email_nonempty_check", sql`length(${table.email}) > 0`),
11440
- check("billing_overrides_seat_allowance_check", sql`${table.seatAllowance} >= 0`),
11441
11445
  check("billing_overrides_seat_allowance_linkedin_check", sql`${table.seatAllowanceLinkedin} >= 0`),
11442
11446
  check("billing_overrides_seat_allowance_x_check", sql`${table.seatAllowanceX} >= 0`),
11443
11447
  check("billing_overrides_monthly_usage_credits_check", sql`${table.monthlyUsageCredits} >= 0`)
@@ -11483,6 +11487,17 @@ pgTable("proxy_call_logs", {
11483
11487
  check("proxy_call_logs_surface_check", sqlCheckIn(table.surface, PROXY_SURFACES)),
11484
11488
  check("proxy_call_logs_cache_status_check", sqlCheckIn(table.cacheStatus, PROXY_CACHE_STATUSES))
11485
11489
  ]);
11490
+ pgTable("billing_operation_leases", {
11491
+ id: text$1("id").primaryKey(),
11492
+ userId: text$1("user_id").notNull().references(() => user.id, { onDelete: "cascade" }),
11493
+ kind: text$1("kind", { enum: BILLING_OPERATION_LEASE_KINDS }).notNull(),
11494
+ expiresAt: timestamptz("expires_at").notNull(),
11495
+ createdAt: timestamptz("created_at").notNull().defaultNow()
11496
+ }, (table) => [
11497
+ uniqueIndex("billing_operation_leases_migration_user_key").on(table.userId).where(sql`${table.kind} = 'social_plan_migration'`),
11498
+ index("billing_operation_leases_user_kind_expiry_idx").on(table.userId, table.kind, table.expiresAt),
11499
+ check("billing_operation_leases_kind_check", sqlCheckIn(table.kind, BILLING_OPERATION_LEASE_KINDS))
11500
+ ]);
11486
11501
  const profiles = pgTable("profiles", {
11487
11502
  id: text$1("id").primaryKey().$defaultFn(() => crypto.randomUUID()),
11488
11503
  platform: text$1("platform", { enum: PLATFORMS }).notNull(),
@@ -19701,15 +19716,23 @@ const hazardFor = (method) => {
19701
19716
  confirm: "advisory"
19702
19717
  };
19703
19718
  };
19704
- const responseShapingFor = (params) => {
19705
- const names = params.map((p) => p.name);
19719
+ const responseShapingFor = (op) => {
19720
+ const names = op.parameters.map((p) => p.name);
19706
19721
  const fields = names.filter((n) => n.endsWith(".fields"));
19707
19722
  const expansions = names.includes("expansions");
19708
- if (fields.length === 0 && !expansions) return { supported: false };
19723
+ const singleResource = op.endpoint.method === "GET" && op.endpoint.pagination.style === "none";
19724
+ if (fields.length === 0 && !expansions && !singleResource) return { supported: false };
19709
19725
  return {
19710
19726
  supported: true,
19711
19727
  fields,
19712
- expansions
19728
+ expansions,
19729
+ ...singleResource ? {
19730
+ resourcePath: "data",
19731
+ metadataPaths: {
19732
+ errors: "errors",
19733
+ includes: "includes"
19734
+ }
19735
+ } : {}
19713
19736
  };
19714
19737
  };
19715
19738
  const hazardsFor = (op) => {
@@ -19873,7 +19896,7 @@ const xRuntimeAdapter = {
19873
19896
  }),
19874
19897
  idempotencyFor: (op) => idempotencyFor(op.endpoint.method),
19875
19898
  hazardFor: (op) => hazardFor(op.endpoint.method),
19876
- responseShapingFor: (op) => responseShapingFor(op.parameters),
19899
+ responseShapingFor,
19877
19900
  hazardsFor,
19878
19901
  exampleCommandFor: (op, context) => exampleCommandFor(op, context.commandName, context.group ?? ""),
19879
19902
  resolveOwnAccount: (deps, args) => deps.resolveOwnXAccount(args),
@@ -21793,7 +21816,14 @@ const listReadContract = (inputSchema, pagination) => manualSchemaContract({
21793
21816
  responseShaping: {
21794
21817
  supported: true,
21795
21818
  fields: ["list.fields", "user.fields"],
21796
- expansions: true
21819
+ expansions: true,
21820
+ ...pagination.style === "none" ? {
21821
+ resourcePath: "data",
21822
+ metadataPaths: {
21823
+ errors: "errors",
21824
+ includes: "includes"
21825
+ }
21826
+ } : {}
21797
21827
  },
21798
21828
  itemUrlTemplate: "https://x.com/i/lists/{id}",
21799
21829
  examples: [],
@@ -22810,7 +22840,7 @@ const reconnectAccountForIdentifier = async (deps, identifier) => {
22810
22840
  if (ae.isError(account)) {
22811
22841
  if (LinkedinLifecycleNoAccountMatch.is(account.error)) {
22812
22842
  const disconnected = resolveLinkedinLifecycleAccount(accounts.filter((candidate) => candidate.status === "disconnected"), identifier);
22813
- if (ae.isOk(disconnected)) throw new Error(`LinkedIn account @${accountUsername(disconnected.value)} is disconnected and its seat was released. Run \`social account connect linkedin\` to connect it again.`);
22843
+ if (ae.isOk(disconnected)) throw new Error(`LinkedIn account @${accountUsername(disconnected.value)} is disconnected and its seat was released. Run \`social account connect linkedin\` to connect it again. Connecting it again may require billing approval.`);
22814
22844
  }
22815
22845
  throw account.error;
22816
22846
  }
@@ -22912,7 +22942,7 @@ var XReconnectRequiresConnect = class extends h("XReconnectRequiresConnect") {
22912
22942
  super({
22913
22943
  operation: "reconnect",
22914
22944
  account,
22915
- message: `X account ${account} is disconnected and its seat was released. Run \`social account connect x\` to connect it again.`
22945
+ message: `X account ${account} is disconnected and its seat was released. Run \`social account connect x\` to connect it again. Connecting it again may require billing approval.`
22916
22946
  });
22917
22947
  this.name = "XReconnectRequiresConnect";
22918
22948
  }
@@ -24474,7 +24504,7 @@ function createEnv(opts) {
24474
24504
  }
24475
24505
  //#endregion
24476
24506
  //#region package.json
24477
- var version$1 = "0.19.1";
24507
+ var version$1 = "0.19.3";
24478
24508
  //#endregion
24479
24509
  //#region src/lib/env.ts
24480
24510
  const URLWithTrailingSlash = url().transform(ensureTrailingSlash);
@@ -25043,6 +25073,20 @@ const shapedRecord = (value, itemURLTemplate, idField) => {
25043
25073
  };
25044
25074
  const itemURLTemplateFrom = (contract) => isRecord$7(contract) && typeof contract.itemUrlTemplate === "string" ? contract.itemUrlTemplate : void 0;
25045
25075
  const idFieldFrom = (contract) => isRecord$7(contract) && typeof contract.idField === "string" && contract.idField.length > 0 ? contract.idField : void 0;
25076
+ const responseShapingFrom = (contract) => isRecord$7(contract) && isRecord$7(contract.responseShaping) ? contract.responseShaping : void 0;
25077
+ const resourcePathFrom = (contract) => {
25078
+ const resourcePath = responseShapingFrom(contract)?.resourcePath;
25079
+ return typeof resourcePath === "string" && resourcePath.length > 0 ? resourcePath : void 0;
25080
+ };
25081
+ const providerMetadataFrom = (contract, data) => {
25082
+ const metadataPaths = responseShapingFrom(contract)?.metadataPaths;
25083
+ if (!isRecord$7(metadataPaths)) return {};
25084
+ return Object.fromEntries(Object.entries(metadataPaths).flatMap(([name, path]) => {
25085
+ if (typeof path !== "string") return [];
25086
+ const value = valueAtPath(data, path);
25087
+ return value === void 0 ? [] : [[name, value]];
25088
+ }));
25089
+ };
25046
25090
  const usersByIdFromIncludes = (data) => {
25047
25091
  if (!(isRecord$7(data) && isRecord$7(data.includes) && Array.isArray(data.includes.users))) return /* @__PURE__ */ new Map();
25048
25092
  return new Map(data.includes.users.flatMap((user) => {
@@ -25059,11 +25103,13 @@ const withAuthorFromIncludes = (value, usersById) => {
25059
25103
  };
25060
25104
  };
25061
25105
  const shapedItem = (value, itemURLTemplate, idField, usersById) => withAuthorFromIncludes(shapedRecord(value, itemURLTemplate, idField), usersById);
25062
- const outputPayloadFor = (data, itemURLTemplate, idField) => {
25106
+ const outputPayloadFor = (data, itemURLTemplate, idField, resourcePath) => {
25063
25107
  const usersById = usersByIdFromIncludes(data);
25064
25108
  if (Array.isArray(data)) return { items: data.map((item) => shapedItem(item, itemURLTemplate, idField, usersById)) };
25065
25109
  if (isRecord$7(data) && Array.isArray(data.items)) return { items: data.items.map((item) => shapedItem(item, itemURLTemplate, idField, usersById)) };
25066
25110
  if (isRecord$7(data) && Array.isArray(data.data)) return { items: data.data.map((item) => shapedItem(item, itemURLTemplate, idField, usersById)) };
25111
+ const resource = valueAtPath(data, resourcePath);
25112
+ if (resourcePath !== void 0 && resource !== void 0) return { data: shapedRecord(resource, itemURLTemplate, idField) };
25067
25113
  return { data: shapedRecord(data, itemURLTemplate, idField) };
25068
25114
  };
25069
25115
  const numberFromHeader = (headers, name) => {
@@ -25141,7 +25187,8 @@ const totalCountFrom = (contract, data) => {
25141
25187
  const resultEnvelope = ({ account, contract, data, local, now = Date.now, resolved = [], responseHeaders, usage }) => {
25142
25188
  const itemURLTemplate = itemURLTemplateFrom(contract);
25143
25189
  const idField = idFieldFrom(contract);
25144
- const payload = outputPayloadFor(data, itemURLTemplate, idField);
25190
+ const payload = outputPayloadFor(data, itemURLTemplate, idField, resourcePathFrom(contract));
25191
+ const providerMetadata = providerMetadataFrom(contract, data);
25145
25192
  const cache = local === void 0 ? cacheFromHeaders(responseHeaders) : cacheFromLocal(local, now);
25146
25193
  const itemCount = "items" in payload && Array.isArray(payload.items) ? payload.items.length : 1;
25147
25194
  const cursor = nextCursorFrom(contract, data);
@@ -25160,6 +25207,7 @@ const resultEnvelope = ({ account, contract, data, local, now = Date.now, resolv
25160
25207
  cache,
25161
25208
  ...cursor === void 0 ? {} : { cursor },
25162
25209
  ...totalCount === void 0 ? {} : { totalCount },
25210
+ ...providerMetadata,
25163
25211
  ...usage === void 0 ? {} : { usage: usageSummaryForOutput(usage) }
25164
25212
  }
25165
25213
  };