@usesocial/cli 0.12.2 → 0.12.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,11 @@
1
1
  # @usesocial/cli
2
2
 
3
+ ## 0.12.3
4
+
5
+ ### Patch Changes
6
+
7
+ - [#81](https://github.com/usesocial/monorepo/pull/81) [`f4ef94b`](https://github.com/usesocial/monorepo/commit/f4ef94ba089bf4d8bd4a0b42495be6f88608b85e) Thanks [@CyrusNuevoDia](https://github.com/CyrusNuevoDia)! - Return a checkout URL from non-interactive account connect when a billing seat must be activated.
8
+
3
9
  ## 0.12.2
4
10
 
5
11
  ### Patch Changes
package/dist/index.mjs CHANGED
@@ -1598,7 +1598,7 @@ const LINKEDIN_COLLECTIONS = [
1598
1598
  parentCollection: "li_conversations",
1599
1599
  parentIdToken: ":chat_id",
1600
1600
  pagination: linkedinCursorPagination,
1601
- pageSize: 250,
1601
+ pageSize: 100,
1602
1602
  sinceField: "timestamp",
1603
1603
  lift: liftMessage
1604
1604
  },
@@ -12663,6 +12663,45 @@ looseObject({
12663
12663
  });
12664
12664
  h("ChatListParseError")();
12665
12665
  h("ChatParticipantsFetchError")();
12666
+ const dropLinkedinInmailEligibility = (value) => {
12667
+ if (Array.isArray(value)) {
12668
+ let changed = false;
12669
+ const items = value.map((item) => {
12670
+ const stripped = dropLinkedinInmailEligibility(item);
12671
+ changed ||= stripped.changed;
12672
+ return stripped.value;
12673
+ });
12674
+ return changed ? {
12675
+ value: items,
12676
+ changed
12677
+ } : {
12678
+ value,
12679
+ changed
12680
+ };
12681
+ }
12682
+ if (!(value && typeof value === "object")) return {
12683
+ value,
12684
+ changed: false
12685
+ };
12686
+ let changed = false;
12687
+ const next = {};
12688
+ for (const [key, child] of Object.entries(value)) {
12689
+ if (key === "can_send_inmail") {
12690
+ changed = true;
12691
+ continue;
12692
+ }
12693
+ const stripped = dropLinkedinInmailEligibility(child);
12694
+ changed ||= stripped.changed;
12695
+ next[key] = stripped.value;
12696
+ }
12697
+ return changed ? {
12698
+ value: next,
12699
+ changed
12700
+ } : {
12701
+ value,
12702
+ changed
12703
+ };
12704
+ };
12666
12705
  const linkedinProfileExtractors = {
12667
12706
  "GET /users/me": extractProfile$1,
12668
12707
  "GET /users/:identifier": extractProfile$1,
@@ -23922,7 +23961,7 @@ function createEnv(opts) {
23922
23961
  }
23923
23962
  //#endregion
23924
23963
  //#region package.json
23925
- var version$1 = "0.12.2";
23964
+ var version$1 = "0.12.3";
23926
23965
  //#endregion
23927
23966
  //#region src/lib/env.ts
23928
23967
  const URLWithTrailingSlash = url().transform(ensureTrailingSlash);
@@ -31880,15 +31919,32 @@ const LifecycleAccountOutput = object({
31880
31919
  connectedAt: string().optional(),
31881
31920
  lastSeenAt: string().optional()
31882
31921
  }).passthrough();
31883
- const AccountConnectStateOutput = discriminatedUnion("status", [object({
31884
- status: literal("connected"),
31885
- platform: _enum(["linkedin", "x"]),
31886
- account: LifecycleAccountOutput
31887
- }), object({
31888
- status: literal("pending_approval"),
31889
- platform: _enum(["linkedin", "x"]),
31890
- connectURL: string()
31891
- })]);
31922
+ const AccountConnectStateOutput = discriminatedUnion("status", [
31923
+ object({
31924
+ status: literal("connected"),
31925
+ platform: _enum(["linkedin", "x"]),
31926
+ account: LifecycleAccountOutput
31927
+ }),
31928
+ object({
31929
+ status: literal("pending_billing"),
31930
+ platform: _enum(["linkedin", "x"]),
31931
+ paymentURL: string().nullable(),
31932
+ requiredAction: object({
31933
+ code: string(),
31934
+ reason: string()
31935
+ }).nullable(),
31936
+ seats: object({
31937
+ total: number().int().nonnegative(),
31938
+ used: number().int().nonnegative(),
31939
+ available: number().int().nonnegative()
31940
+ })
31941
+ }),
31942
+ object({
31943
+ status: literal("pending_approval"),
31944
+ platform: _enum(["linkedin", "x"]),
31945
+ connectURL: string()
31946
+ })
31947
+ ]);
31892
31948
  const AccountConnectOutput = union([string(), AccountConnectStateOutput]);
31893
31949
  const AccountDisconnectOutput = object({
31894
31950
  platform: _enum(["linkedin", "x"]),
@@ -32022,6 +32078,20 @@ const runConnectStep = async (deps, platform, listConnected, connectURL) => {
32022
32078
  });
32023
32079
  return;
32024
32080
  }
32081
+ const billing = await deps.client.billing.prepareAccountConnect();
32082
+ if (!billing.canConnect) {
32083
+ if (!billing.seats) throw new Error("billing_prepare_missing_seats");
32084
+ if (billing.paymentURL) writeText(deps, `Open this URL: ${billing.paymentURL}`);
32085
+ else if (billing.requiredAction) writeText(deps, billing.requiredAction.reason);
32086
+ await writeOutput(deps, {
32087
+ status: "pending_billing",
32088
+ platform,
32089
+ paymentURL: billing.paymentURL ?? null,
32090
+ requiredAction: billing.requiredAction ?? null,
32091
+ seats: billing.seats
32092
+ });
32093
+ return;
32094
+ }
32025
32095
  const url = await connectURL();
32026
32096
  writeText(deps, `Open this URL: ${url}`);
32027
32097
  await writeOutput(deps, {