@usesocial/cli 0.19.1 → 0.19.2

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,12 @@
1
1
  # @usesocial/cli
2
2
 
3
+ ## 0.19.2
4
+
5
+ ### Patch Changes
6
+
7
+ - [#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
8
+ errors and expansions in response metadata.
9
+
3
10
  ## 0.19.1
4
11
 
5
12
  ### 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
@@ -11425,7 +11425,6 @@ pgTable("webhook_operations", {
11425
11425
  pgTable("billing_overrides", {
11426
11426
  email: text$1("email").primaryKey(),
11427
11427
  userId: text$1("user_id").references(() => user.id, { onDelete: "cascade" }),
11428
- seatAllowance: integer("seat_allowance").notNull().default(2),
11429
11428
  seatAllowanceLinkedin: integer("seat_allowance_linkedin").notNull().default(2),
11430
11429
  seatAllowanceX: integer("seat_allowance_x").notNull().default(2),
11431
11430
  monthlyUsageCredits: integer("monthly_usage_credits").notNull().default(6e4),
@@ -11437,7 +11436,6 @@ pgTable("billing_overrides", {
11437
11436
  uniqueIndex("billing_overrides_user_id_key").on(table.userId).where(sql`${table.userId} is not null`),
11438
11437
  check("billing_overrides_email_lower_check", sql`lower(${table.email}) = ${table.email}`),
11439
11438
  check("billing_overrides_email_nonempty_check", sql`length(${table.email}) > 0`),
11440
- check("billing_overrides_seat_allowance_check", sql`${table.seatAllowance} >= 0`),
11441
11439
  check("billing_overrides_seat_allowance_linkedin_check", sql`${table.seatAllowanceLinkedin} >= 0`),
11442
11440
  check("billing_overrides_seat_allowance_x_check", sql`${table.seatAllowanceX} >= 0`),
11443
11441
  check("billing_overrides_monthly_usage_credits_check", sql`${table.monthlyUsageCredits} >= 0`)
@@ -19701,15 +19699,23 @@ const hazardFor = (method) => {
19701
19699
  confirm: "advisory"
19702
19700
  };
19703
19701
  };
19704
- const responseShapingFor = (params) => {
19705
- const names = params.map((p) => p.name);
19702
+ const responseShapingFor = (op) => {
19703
+ const names = op.parameters.map((p) => p.name);
19706
19704
  const fields = names.filter((n) => n.endsWith(".fields"));
19707
19705
  const expansions = names.includes("expansions");
19708
- if (fields.length === 0 && !expansions) return { supported: false };
19706
+ const singleResource = op.endpoint.method === "GET" && op.endpoint.pagination.style === "none";
19707
+ if (fields.length === 0 && !expansions && !singleResource) return { supported: false };
19709
19708
  return {
19710
19709
  supported: true,
19711
19710
  fields,
19712
- expansions
19711
+ expansions,
19712
+ ...singleResource ? {
19713
+ resourcePath: "data",
19714
+ metadataPaths: {
19715
+ errors: "errors",
19716
+ includes: "includes"
19717
+ }
19718
+ } : {}
19713
19719
  };
19714
19720
  };
19715
19721
  const hazardsFor = (op) => {
@@ -19873,7 +19879,7 @@ const xRuntimeAdapter = {
19873
19879
  }),
19874
19880
  idempotencyFor: (op) => idempotencyFor(op.endpoint.method),
19875
19881
  hazardFor: (op) => hazardFor(op.endpoint.method),
19876
- responseShapingFor: (op) => responseShapingFor(op.parameters),
19882
+ responseShapingFor,
19877
19883
  hazardsFor,
19878
19884
  exampleCommandFor: (op, context) => exampleCommandFor(op, context.commandName, context.group ?? ""),
19879
19885
  resolveOwnAccount: (deps, args) => deps.resolveOwnXAccount(args),
@@ -21793,7 +21799,14 @@ const listReadContract = (inputSchema, pagination) => manualSchemaContract({
21793
21799
  responseShaping: {
21794
21800
  supported: true,
21795
21801
  fields: ["list.fields", "user.fields"],
21796
- expansions: true
21802
+ expansions: true,
21803
+ ...pagination.style === "none" ? {
21804
+ resourcePath: "data",
21805
+ metadataPaths: {
21806
+ errors: "errors",
21807
+ includes: "includes"
21808
+ }
21809
+ } : {}
21797
21810
  },
21798
21811
  itemUrlTemplate: "https://x.com/i/lists/{id}",
21799
21812
  examples: [],
@@ -24474,7 +24487,7 @@ function createEnv(opts) {
24474
24487
  }
24475
24488
  //#endregion
24476
24489
  //#region package.json
24477
- var version$1 = "0.19.1";
24490
+ var version$1 = "0.19.2";
24478
24491
  //#endregion
24479
24492
  //#region src/lib/env.ts
24480
24493
  const URLWithTrailingSlash = url().transform(ensureTrailingSlash);
@@ -25043,6 +25056,20 @@ const shapedRecord = (value, itemURLTemplate, idField) => {
25043
25056
  };
25044
25057
  const itemURLTemplateFrom = (contract) => isRecord$7(contract) && typeof contract.itemUrlTemplate === "string" ? contract.itemUrlTemplate : void 0;
25045
25058
  const idFieldFrom = (contract) => isRecord$7(contract) && typeof contract.idField === "string" && contract.idField.length > 0 ? contract.idField : void 0;
25059
+ const responseShapingFrom = (contract) => isRecord$7(contract) && isRecord$7(contract.responseShaping) ? contract.responseShaping : void 0;
25060
+ const resourcePathFrom = (contract) => {
25061
+ const resourcePath = responseShapingFrom(contract)?.resourcePath;
25062
+ return typeof resourcePath === "string" && resourcePath.length > 0 ? resourcePath : void 0;
25063
+ };
25064
+ const providerMetadataFrom = (contract, data) => {
25065
+ const metadataPaths = responseShapingFrom(contract)?.metadataPaths;
25066
+ if (!isRecord$7(metadataPaths)) return {};
25067
+ return Object.fromEntries(Object.entries(metadataPaths).flatMap(([name, path]) => {
25068
+ if (typeof path !== "string") return [];
25069
+ const value = valueAtPath(data, path);
25070
+ return value === void 0 ? [] : [[name, value]];
25071
+ }));
25072
+ };
25046
25073
  const usersByIdFromIncludes = (data) => {
25047
25074
  if (!(isRecord$7(data) && isRecord$7(data.includes) && Array.isArray(data.includes.users))) return /* @__PURE__ */ new Map();
25048
25075
  return new Map(data.includes.users.flatMap((user) => {
@@ -25059,11 +25086,13 @@ const withAuthorFromIncludes = (value, usersById) => {
25059
25086
  };
25060
25087
  };
25061
25088
  const shapedItem = (value, itemURLTemplate, idField, usersById) => withAuthorFromIncludes(shapedRecord(value, itemURLTemplate, idField), usersById);
25062
- const outputPayloadFor = (data, itemURLTemplate, idField) => {
25089
+ const outputPayloadFor = (data, itemURLTemplate, idField, resourcePath) => {
25063
25090
  const usersById = usersByIdFromIncludes(data);
25064
25091
  if (Array.isArray(data)) return { items: data.map((item) => shapedItem(item, itemURLTemplate, idField, usersById)) };
25065
25092
  if (isRecord$7(data) && Array.isArray(data.items)) return { items: data.items.map((item) => shapedItem(item, itemURLTemplate, idField, usersById)) };
25066
25093
  if (isRecord$7(data) && Array.isArray(data.data)) return { items: data.data.map((item) => shapedItem(item, itemURLTemplate, idField, usersById)) };
25094
+ const resource = valueAtPath(data, resourcePath);
25095
+ if (resourcePath !== void 0 && resource !== void 0) return { data: shapedRecord(resource, itemURLTemplate, idField) };
25067
25096
  return { data: shapedRecord(data, itemURLTemplate, idField) };
25068
25097
  };
25069
25098
  const numberFromHeader = (headers, name) => {
@@ -25141,7 +25170,8 @@ const totalCountFrom = (contract, data) => {
25141
25170
  const resultEnvelope = ({ account, contract, data, local, now = Date.now, resolved = [], responseHeaders, usage }) => {
25142
25171
  const itemURLTemplate = itemURLTemplateFrom(contract);
25143
25172
  const idField = idFieldFrom(contract);
25144
- const payload = outputPayloadFor(data, itemURLTemplate, idField);
25173
+ const payload = outputPayloadFor(data, itemURLTemplate, idField, resourcePathFrom(contract));
25174
+ const providerMetadata = providerMetadataFrom(contract, data);
25145
25175
  const cache = local === void 0 ? cacheFromHeaders(responseHeaders) : cacheFromLocal(local, now);
25146
25176
  const itemCount = "items" in payload && Array.isArray(payload.items) ? payload.items.length : 1;
25147
25177
  const cursor = nextCursorFrom(contract, data);
@@ -25160,6 +25190,7 @@ const resultEnvelope = ({ account, contract, data, local, now = Date.now, resolv
25160
25190
  cache,
25161
25191
  ...cursor === void 0 ? {} : { cursor },
25162
25192
  ...totalCount === void 0 ? {} : { totalCount },
25193
+ ...providerMetadata,
25163
25194
  ...usage === void 0 ? {} : { usage: usageSummaryForOutput(usage) }
25164
25195
  }
25165
25196
  };