@usesocial/cli 0.19.15 → 0.19.16

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.19.16
4
+
5
+ ### Patch Changes
6
+
7
+ - [#188](https://github.com/usesocial/monorepo/pull/188) [`055daa0`](https://github.com/usesocial/monorepo/commit/055daa0322285eaca3cc8bc3f51061ce821e374b) Thanks [@CyrusNuevoDia](https://github.com/CyrusNuevoDia)! - Reuse existing LinkedIn conversations for person-target messages, validate optional invitation notes, reconcile pending requests on complete refresh, and report flat LinkedIn usage in schemas.
8
+
3
9
  ## 0.19.15
4
10
 
5
11
  ### Patch Changes
package/dist/index.mjs CHANGED
@@ -7337,7 +7337,7 @@ const buildRuntimeContract = (adapter, op, context) => {
7337
7337
  responseShaping: adapter.responseShapingFor(op),
7338
7338
  ...adapter.includeIdField === true && op.config.idField ? { idField: op.config.idField } : {},
7339
7339
  ...op.config.itemUrlTemplate ? { itemUrlTemplate: op.config.itemUrlTemplate } : {},
7340
- cost: costFor(adapter, op),
7340
+ cost: adapter.costFor?.(op) ?? costFor(adapter, op),
7341
7341
  examples: [{ command: adapter.exampleCommandFor(op, context) }],
7342
7342
  hazards: adapter.hazardsFor(op)
7343
7343
  };
@@ -9567,8 +9567,11 @@ const runSync = async (deps, opts) => {
9567
9567
  for (const [requestIndex, request] of collection.requests.entries()) {
9568
9568
  if (shouldSkipCompletedRequest(activePartialCursor, requestIndex)) continue;
9569
9569
  const resumeCursor = resumeCursorForRequest(activePartialCursor, requestIndex);
9570
+ const requestType = collection.key === "li_requests" ? request.bakedQuery?.type : void 0;
9571
+ const previousRequests = requestType && !resumeCursor ? deps.cache.query(`SELECT id FROM li_requests_raw WHERE type = '${requestType === "sent" ? "sent" : "received"}'`) : [];
9570
9572
  const result = await walkRequest({
9571
9573
  allowPartialResume: true,
9574
+ collectIds: requestType !== void 0,
9572
9575
  collection,
9573
9576
  credits,
9574
9577
  deps,
@@ -9588,6 +9591,16 @@ const runSync = async (deps, opts) => {
9588
9591
  });
9589
9592
  if (ae.isError(result)) return ae.err(result.error);
9590
9593
  addResult(result.value);
9594
+ if (requestType && !resumeCursor && result.value.stoppedReason === "complete") {
9595
+ const currentIds = new Set(result.value.ids);
9596
+ const removals = previousRequests.filter((row) => !currentIds.has(String(row.id)));
9597
+ for (const row of removals) deps.cache.applyWriteThrough({
9598
+ collection: collection.key,
9599
+ id: String(row.id),
9600
+ op: "delete",
9601
+ table: "li_requests_raw"
9602
+ });
9603
+ }
9591
9604
  if (!preservesBroaderPartialOnSince(activePartialCursor, opts.since, result.value.stoppedReason) && useCheckpoint) pendingCursors.push(singleRequestCheckpoint({
9592
9605
  collection,
9593
9606
  result: result.value
@@ -9611,135 +9624,76 @@ const runSync = async (deps, opts) => {
9611
9624
  if (note !== void 0) summary.note = note;
9612
9625
  return ae.ok(summary);
9613
9626
  };
9614
- // ../../packages/billing/src/pricing.ts
9615
- var UnknownPricingCategory = class extends h("pricing_category_unknown") {};
9616
- const lookupCostBPSForCategoryResult = (table, category) => {
9617
- const costBPS = table.get(category);
9618
- if (costBPS === void 0) return ae.err(new UnknownPricingCategory({
9619
- category,
9620
- message: `Unknown pricing category: ${category}`
9621
- }));
9622
- return ae.ok(costBPS);
9627
+ // ../../packages/linkedin/src/cli/response-projections.ts
9628
+ const ResponseString$1 = string().optional().catch(void 0);
9629
+ const InboxString = string().min(1).optional().catch(void 0);
9630
+ const LinkedinInboxes = array(object({
9631
+ id: InboxString,
9632
+ inbox_id: InboxString,
9633
+ inbox_type: InboxString,
9634
+ label: InboxString,
9635
+ name: InboxString,
9636
+ provider: InboxString,
9637
+ provider_id: InboxString,
9638
+ type: InboxString
9639
+ }).optional().catch(void 0));
9640
+ const OptionalLinkedinInboxes = LinkedinInboxes.optional().catch(void 0);
9641
+ const InboxResponse = union([LinkedinInboxes, object({
9642
+ data: OptionalLinkedinInboxes,
9643
+ inboxes: OptionalLinkedinInboxes,
9644
+ items: OptionalLinkedinInboxes
9645
+ }).transform((response) => response.data ?? response.items ?? response.inboxes ?? [])]);
9646
+ const classicLinkedinInboxIdFrom = (data) => {
9647
+ const response = InboxResponse.safeParse(data);
9648
+ if (!response.success) return;
9649
+ const inboxes = response.data.flatMap((inbox) => {
9650
+ const id = inbox?.id ?? inbox?.inbox_id;
9651
+ if (!inbox || id === void 0) return [];
9652
+ return [{
9653
+ id,
9654
+ text: `${id} ${inbox.provider ?? inbox.provider_id ?? inbox.type ?? inbox.inbox_type ?? inbox.name ?? inbox.label ?? ""}`.toLowerCase()
9655
+ }];
9656
+ });
9657
+ return (inboxes.find(({ id }) => id === "CLASSIC_PRIMARY") ?? inboxes.find(({ text }) => text.includes("classic")) ?? inboxes.find(({ text }) => text.includes("primary")))?.id ?? (inboxes.length === 1 ? inboxes[0]?.id : void 0);
9623
9658
  };
9624
- const createPricing = (resources) => {
9625
- const table = new Map(resources.map((resource) => [resource.key, Math.round(resource.unitPriceUSD * 1e4)]));
9659
+ const providerDataFrom = (data) => data && typeof data === "object" && "data" in data ? data.data : data;
9660
+ const LinkedinCompanyProfile = object({
9661
+ companyId: ResponseString$1,
9662
+ company_id: ResponseString$1,
9663
+ id: ResponseString$1
9664
+ });
9665
+ const LinkedinPost = object({ id: ResponseString$1 });
9666
+ const companyProfileIdFrom = (data) => {
9667
+ const profile = LinkedinCompanyProfile.safeParse(providerDataFrom(data));
9668
+ return profile.success ? profile.data.id ?? profile.data.company_id ?? profile.data.companyId : void 0;
9669
+ };
9670
+ const linkedinPostIdFrom = (data) => {
9671
+ const post = LinkedinPost.safeParse(providerDataFrom(data));
9672
+ return post.success ? post.data.id : void 0;
9673
+ };
9674
+ // ../../packages/linkedin/src/messaging.ts
9675
+ const ChatLookup = object({ data: array(object({
9676
+ chat_id: string().min(1),
9677
+ has_history: boolean$1().optional()
9678
+ })) });
9679
+ const linkedinChatForPerson = async (profileId, get) => {
9680
+ const lookup = ChatLookup.parse(await get(`/users/${encodeURIComponent(profileId)}/chat`));
9681
+ return (lookup.data.find((chat) => chat.has_history) ?? lookup.data[0])?.chat_id ?? null;
9682
+ };
9683
+ const linkedinMessageDestination = async (target, get, getInboxId = async () => classicLinkedinInboxIdFrom(await get("/inboxes"))) => {
9684
+ const chatId = target.kind === "thread" ? target.id : await linkedinChatForPerson(target.id, get);
9685
+ if (chatId !== null) return {
9686
+ chatId,
9687
+ path: `/chats/${encodeURIComponent(chatId)}/messages`
9688
+ };
9689
+ const inboxId = await getInboxId();
9690
+ if (!inboxId) throw new Error("linkedin_classic_inbox_not_found");
9626
9691
  return {
9627
- categories: () => [...table.keys()],
9628
- costBPSForCategory: (category) => lookupCostBPSForCategoryResult(table, category)
9692
+ chatId: null,
9693
+ path: `/inboxes/${encodeURIComponent(inboxId)}/chats`
9629
9694
  };
9630
9695
  };
9631
- // ../../packages/linkedin/src/pricing.ts
9632
- const pricingTable$1 = createPricing([
9633
- {
9634
- "key": "posts_read",
9635
- "label": "Posts: Read",
9636
- "description": "Read LinkedIn posts, comments, reactions, jobs, and other post-like result sets.",
9637
- "unit": "per_resource",
9638
- "unitPriceUSD": .005,
9639
- "featureId": "post_read_resource"
9640
- },
9641
- {
9642
- "key": "user_read",
9643
- "label": "User: Read",
9644
- "description": "Read non-owned LinkedIn profiles, companies, people search, company search, requests, and other profile-like result sets.",
9645
- "unit": "per_resource",
9646
- "unitPriceUSD": .01,
9647
- "featureId": "user_read_resource"
9648
- },
9649
- {
9650
- "key": "dm_event_read",
9651
- "label": "DM Event: Read",
9652
- "description": "Read LinkedIn chats, chat messages, and profile-to-chat lookups.",
9653
- "unit": "per_resource",
9654
- "unitPriceUSD": .01,
9655
- "featureId": "dm_event_read_resource"
9656
- },
9657
- {
9658
- "key": "post_create",
9659
- "label": "Post: Create",
9660
- "description": "Create a simple LinkedIn post without a detected URL.",
9661
- "unit": "per_request",
9662
- "unitPriceUSD": .015,
9663
- "featureId": "content_create_request"
9664
- },
9665
- {
9666
- "key": "content_create",
9667
- "label": "Content: Create",
9668
- "description": "Create LinkedIn comments or other lower-cost content writes.",
9669
- "unit": "per_request",
9670
- "unitPriceUSD": .01,
9671
- "featureId": "content_create_request"
9672
- },
9673
- {
9674
- "key": "content_create_with_url",
9675
- "label": "Content: Create with URL",
9676
- "description": "Create a LinkedIn post when URL presence is unknown or detected, priced conservatively.",
9677
- "unit": "per_request",
9678
- "unitPriceUSD": .2,
9679
- "featureId": "content_create_with_url_request"
9680
- },
9681
- {
9682
- "key": "dm_interaction_create",
9683
- "label": "DM Interaction: Create",
9684
- "description": "Send, modify, delete, or mark LinkedIn chat messages and chat state.",
9685
- "unit": "per_request",
9686
- "unitPriceUSD": .015,
9687
- "featureId": "dm_interaction_create_request"
9688
- },
9689
- {
9690
- "key": "user_interaction_create",
9691
- "label": "User Interaction: Create",
9692
- "description": "Create LinkedIn reactions, connection requests, and relation-request state changes.",
9693
- "unit": "per_request",
9694
- "unitPriceUSD": .015,
9695
- "featureId": "user_interaction_create_request"
9696
- },
9697
- {
9698
- "key": "page_analytics_read",
9699
- "label": "Page Analytics: Read",
9700
- "description": "Read LinkedIn company Page analytics through the raw LinkedIn passthrough.",
9701
- "unit": "per_resource",
9702
- "unitPriceUSD": .02,
9703
- "featureId": "user_read_resource"
9704
- },
9705
- {
9706
- "key": "page_invite_create",
9707
- "label": "Page Invite: Create",
9708
- "description": "Invite LinkedIn users to follow a company Page.",
9709
- "unit": "per_request",
9710
- "unitPriceUSD": .015,
9711
- "featureId": "user_interaction_create_request"
9712
- },
9713
- {
9714
- "key": "proxy_passthrough",
9715
- "label": "Proxy Passthrough",
9716
- "description": "Forward a raw LinkedIn passthrough envelope with conservative write-tier pricing.",
9717
- "unit": "per_request",
9718
- "unitPriceUSD": .2,
9719
- "featureId": "content_create_with_url_request"
9720
- },
9721
- {
9722
- "key": "following_read",
9723
- "label": "Following/Followers: Read",
9724
- "description": "Read LinkedIn connections, priced to match X following and followers reads.",
9725
- "unit": "per_resource",
9726
- "unitPriceUSD": .01,
9727
- "featureId": "following_followers_read_resource"
9728
- },
9729
- {
9730
- "key": "owned_read",
9731
- "label": "Owned: Read",
9732
- "description": "Read the connected LinkedIn account's own profile.",
9733
- "unit": "per_resource",
9734
- "unitPriceUSD": .001,
9735
- "featureId": "owned_read_resource"
9736
- }
9737
- ]);
9738
- const costBPSForCategory$1 = (category) => {
9739
- const costBPS = pricingTable$1.costBPSForCategory(category);
9740
- if (costBPS.status === "error") throw costBPS.error;
9741
- return costBPS.value;
9742
- };
9696
+ const LinkedinConnectionNote = string().max(200);
9743
9697
  // ../../node_modules/.bun/drizzle-orm@0.45.4+05bc982c96526791/node_modules/drizzle-orm/entity.js
9744
9698
  const entityKind = Symbol.for("drizzle:entityKind");
9745
9699
  function is(value, type) {
@@ -14746,6 +14700,129 @@ const parseTypedSocialSelectorResult = (value, options = {}) => {
14746
14700
  value
14747
14701
  }));
14748
14702
  };
14703
+ // ../../packages/billing/src/pricing.ts
14704
+ var UnknownPricingCategory = class extends h("pricing_category_unknown") {};
14705
+ const lookupCostBPSForCategoryResult = (table, category) => {
14706
+ const costBPS = table.get(category);
14707
+ if (costBPS === void 0) return ae.err(new UnknownPricingCategory({
14708
+ category,
14709
+ message: `Unknown pricing category: ${category}`
14710
+ }));
14711
+ return ae.ok(costBPS);
14712
+ };
14713
+ const createPricing = (resources) => {
14714
+ const table = new Map(resources.map((resource) => [resource.key, Math.round(resource.unitPriceUSD * 1e4)]));
14715
+ return {
14716
+ categories: () => [...table.keys()],
14717
+ costBPSForCategory: (category) => lookupCostBPSForCategoryResult(table, category)
14718
+ };
14719
+ };
14720
+ createPricing([
14721
+ {
14722
+ "key": "posts_read",
14723
+ "label": "Posts: Read",
14724
+ "description": "Read LinkedIn posts, comments, reactions, jobs, and other post-like result sets.",
14725
+ "unit": "per_resource",
14726
+ "unitPriceUSD": .005,
14727
+ "featureId": "post_read_resource"
14728
+ },
14729
+ {
14730
+ "key": "user_read",
14731
+ "label": "User: Read",
14732
+ "description": "Read non-owned LinkedIn profiles, companies, people search, company search, requests, and other profile-like result sets.",
14733
+ "unit": "per_resource",
14734
+ "unitPriceUSD": .01,
14735
+ "featureId": "user_read_resource"
14736
+ },
14737
+ {
14738
+ "key": "dm_event_read",
14739
+ "label": "DM Event: Read",
14740
+ "description": "Read LinkedIn chats, chat messages, and profile-to-chat lookups.",
14741
+ "unit": "per_resource",
14742
+ "unitPriceUSD": .01,
14743
+ "featureId": "dm_event_read_resource"
14744
+ },
14745
+ {
14746
+ "key": "post_create",
14747
+ "label": "Post: Create",
14748
+ "description": "Create a simple LinkedIn post without a detected URL.",
14749
+ "unit": "per_request",
14750
+ "unitPriceUSD": .015,
14751
+ "featureId": "content_create_request"
14752
+ },
14753
+ {
14754
+ "key": "content_create",
14755
+ "label": "Content: Create",
14756
+ "description": "Create LinkedIn comments or other lower-cost content writes.",
14757
+ "unit": "per_request",
14758
+ "unitPriceUSD": .01,
14759
+ "featureId": "content_create_request"
14760
+ },
14761
+ {
14762
+ "key": "content_create_with_url",
14763
+ "label": "Content: Create with URL",
14764
+ "description": "Create a LinkedIn post when URL presence is unknown or detected, priced conservatively.",
14765
+ "unit": "per_request",
14766
+ "unitPriceUSD": .2,
14767
+ "featureId": "content_create_with_url_request"
14768
+ },
14769
+ {
14770
+ "key": "dm_interaction_create",
14771
+ "label": "DM Interaction: Create",
14772
+ "description": "Send, modify, delete, or mark LinkedIn chat messages and chat state.",
14773
+ "unit": "per_request",
14774
+ "unitPriceUSD": .015,
14775
+ "featureId": "dm_interaction_create_request"
14776
+ },
14777
+ {
14778
+ "key": "user_interaction_create",
14779
+ "label": "User Interaction: Create",
14780
+ "description": "Create LinkedIn reactions, connection requests, and relation-request state changes.",
14781
+ "unit": "per_request",
14782
+ "unitPriceUSD": .015,
14783
+ "featureId": "user_interaction_create_request"
14784
+ },
14785
+ {
14786
+ "key": "page_analytics_read",
14787
+ "label": "Page Analytics: Read",
14788
+ "description": "Read LinkedIn company Page analytics through the raw LinkedIn passthrough.",
14789
+ "unit": "per_resource",
14790
+ "unitPriceUSD": .02,
14791
+ "featureId": "user_read_resource"
14792
+ },
14793
+ {
14794
+ "key": "page_invite_create",
14795
+ "label": "Page Invite: Create",
14796
+ "description": "Invite LinkedIn users to follow a company Page.",
14797
+ "unit": "per_request",
14798
+ "unitPriceUSD": .015,
14799
+ "featureId": "user_interaction_create_request"
14800
+ },
14801
+ {
14802
+ "key": "proxy_passthrough",
14803
+ "label": "Proxy Passthrough",
14804
+ "description": "Forward a raw LinkedIn passthrough envelope with conservative write-tier pricing.",
14805
+ "unit": "per_request",
14806
+ "unitPriceUSD": .2,
14807
+ "featureId": "content_create_with_url_request"
14808
+ },
14809
+ {
14810
+ "key": "following_read",
14811
+ "label": "Following/Followers: Read",
14812
+ "description": "Read LinkedIn connections, priced to match X following and followers reads.",
14813
+ "unit": "per_resource",
14814
+ "unitPriceUSD": .01,
14815
+ "featureId": "following_followers_read_resource"
14816
+ },
14817
+ {
14818
+ "key": "owned_read",
14819
+ "label": "Owned: Read",
14820
+ "description": "Read the connected LinkedIn account's own profile.",
14821
+ "unit": "per_resource",
14822
+ "unitPriceUSD": .001,
14823
+ "featureId": "owned_read_resource"
14824
+ }
14825
+ ]);
14749
14826
  new RegExp(String.raw`^/search/(?<category>companies|jobs|people|posts)$`);
14750
14827
  object({
14751
14828
  detail: string().includes("Fuse limit was reached"),
@@ -14880,7 +14957,7 @@ const LINKEDIN_OPERATIONS = [
14880
14957
  expose: false,
14881
14958
  group: "messages",
14882
14959
  root: false,
14883
- summary: "List LinkedIn inbox conversations. Costs $0.150 usage per page when not served from cache"
14960
+ summary: "List LinkedIn inbox conversations. Included in the LinkedIn subscription; no per-page usage charge"
14884
14961
  },
14885
14962
  endpoint: {
14886
14963
  billingCategory: "owned_read",
@@ -14943,7 +15020,7 @@ const LINKEDIN_OPERATIONS = [
14943
15020
  group: "messages",
14944
15021
  paramLabels: { chat_id: "target" },
14945
15022
  root: false,
14946
- summary: "List messages in a LinkedIn inbox conversation. Costs $0.075 usage per page when not served from cache",
15023
+ summary: "List messages in a LinkedIn inbox conversation. Included in the LinkedIn subscription; no per-page usage charge",
14947
15024
  targetKind: "chat"
14948
15025
  },
14949
15026
  endpoint: {
@@ -16034,53 +16111,6 @@ const linkedinCacheableEndpointPaths = [
16034
16111
  "GET /users/:identifier/posts",
16035
16112
  "GET /users/me"
16036
16113
  ];
16037
- // ../../packages/linkedin/src/cli/response-projections.ts
16038
- const ResponseString$1 = string().optional().catch(void 0);
16039
- const InboxString = string().min(1).optional().catch(void 0);
16040
- const LinkedinInboxes = array(object({
16041
- id: InboxString,
16042
- inbox_id: InboxString,
16043
- inbox_type: InboxString,
16044
- label: InboxString,
16045
- name: InboxString,
16046
- provider: InboxString,
16047
- provider_id: InboxString,
16048
- type: InboxString
16049
- }).optional().catch(void 0));
16050
- const OptionalLinkedinInboxes = LinkedinInboxes.optional().catch(void 0);
16051
- const InboxResponse = union([LinkedinInboxes, object({
16052
- data: OptionalLinkedinInboxes,
16053
- inboxes: OptionalLinkedinInboxes,
16054
- items: OptionalLinkedinInboxes
16055
- }).transform((response) => response.data ?? response.items ?? response.inboxes ?? [])]);
16056
- const classicLinkedinInboxIdFrom = (data) => {
16057
- const response = InboxResponse.safeParse(data);
16058
- if (!response.success) return;
16059
- const inboxes = response.data.flatMap((inbox) => {
16060
- const id = inbox?.id ?? inbox?.inbox_id;
16061
- if (!inbox || id === void 0) return [];
16062
- return [{
16063
- id,
16064
- text: `${id} ${inbox.provider ?? inbox.provider_id ?? inbox.type ?? inbox.inbox_type ?? inbox.name ?? inbox.label ?? ""}`.toLowerCase()
16065
- }];
16066
- });
16067
- return (inboxes.find(({ id }) => id === "CLASSIC_PRIMARY") ?? inboxes.find(({ text }) => text.includes("classic")) ?? inboxes.find(({ text }) => text.includes("primary")))?.id ?? (inboxes.length === 1 ? inboxes[0]?.id : void 0);
16068
- };
16069
- const providerDataFrom = (data) => data && typeof data === "object" && "data" in data ? data.data : data;
16070
- const LinkedinCompanyProfile = object({
16071
- companyId: ResponseString$1,
16072
- company_id: ResponseString$1,
16073
- id: ResponseString$1
16074
- });
16075
- const LinkedinPost = object({ id: ResponseString$1 });
16076
- const companyProfileIdFrom = (data) => {
16077
- const profile = LinkedinCompanyProfile.safeParse(providerDataFrom(data));
16078
- return profile.success ? profile.data.id ?? profile.data.company_id ?? profile.data.companyId : void 0;
16079
- };
16080
- const linkedinPostIdFrom = (data) => {
16081
- const post = LinkedinPost.safeParse(providerDataFrom(data));
16082
- return post.success ? post.data.id : void 0;
16083
- };
16084
16114
  // ../../packages/linkedin/src/cli/policy.ts
16085
16115
  const bodyParamArg = (name, param) => param.arg ?? name;
16086
16116
  const camelCaseFrom = (value) => value.replaceAll(/-(?<part>[a-z0-9])/g, (_match, part) => part.toUpperCase());
@@ -16611,7 +16641,6 @@ var UnexpectedLinkedinResponseError = class extends Error {
16611
16641
  const commandMeta$2 = (meta) => commandMeta$3(meta);
16612
16642
  const { inputSchema: inputSchema$1, schema: schema$1 } = runtimeSchemaRegistry(schemas$1, (name) => /* @__PURE__ */ new Error(`Missing generated LinkedIn CLI schema: ${name}`));
16613
16643
  const isCacheable$1 = (e) => linkedinCacheableEndpointPaths.includes(`${e.method} ${e.path}`);
16614
- const creditsForCostBPS = (costBPS) => priceUsage(costBPS).credits;
16615
16644
  var UnsupportedLinkedinCLIFlagError = class extends UsageError {
16616
16645
  name = "UnsupportedLinkedinCLIFlagError";
16617
16646
  constructor(flag, commandName) {
@@ -16744,6 +16773,16 @@ const linkedinRuntimeAdapter = {
16744
16773
  ],
16745
16774
  commandPath: commandPathFor,
16746
16775
  contractInputSchemaName,
16776
+ costFor: (op) => ({
16777
+ cacheable: isCacheable$1(op.endpoint),
16778
+ estimate: {
16779
+ kind: "per_call",
16780
+ usageUSD: 0
16781
+ },
16782
+ metered: false,
16783
+ notes: ["LinkedIn proxy usage is included in the subscription."],
16784
+ unit: "usage_usd"
16785
+ }),
16747
16786
  defineCommand: (definition) => definition,
16748
16787
  emptyBodyFromParts: true,
16749
16788
  exampleCommandFor: (op, context) => exampleCommandFor$1(op, context.root === true),
@@ -16765,7 +16804,11 @@ const linkedinRuntimeAdapter = {
16765
16804
  parametersForArgs: pageParametersForRuntimeInput,
16766
16805
  parametersForInput: pageParametersForRuntimeInput,
16767
16806
  platform: "linkedin",
16768
- priceUsage,
16807
+ priceUsage: () => ({
16808
+ billedBPS: 0,
16809
+ credits: 0,
16810
+ customerUSD: 0
16811
+ }),
16769
16812
  queryArrayMode: (op, param) => param.kind === "array" || op.schemaBaseName === "UserProfile" && param.name === "with_sections" ? "repeat" : "set",
16770
16813
  resolveOwnAccount: (deps, args) => deps.resolveOwnLinkedinAccount(args),
16771
16814
  responseShapingFor: () => ({
@@ -16976,11 +17019,6 @@ const planLinkedinSyncRateLimitRetry = ({ commandArgs, collectionKey, cursorPers
16976
17019
  };
16977
17020
  // ../../packages/linkedin/src/cli/commands.ts
16978
17021
  const defineLinkedinCommand = (command) => command;
16979
- const DM_INTERACTION_BILLING_CATEGORY = "dm_interaction_create";
16980
- const DM_INTERACTION_ENDPOINT_BILLING = {
16981
- billingCategory: DM_INTERACTION_BILLING_CATEGORY,
16982
- costBPS: costBPSForCategory$1(DM_INTERACTION_BILLING_CATEGORY)
16983
- };
16984
17022
  const LINKEDIN_RATE_LIMIT_RETRY_LIMIT$1 = 25;
16985
17023
  const LINKEDIN_RATE_LIMIT_MAX_FALLBACK_SECONDS$1 = 60;
16986
17024
  const defaultLinkedinCommandServices = {
@@ -17216,7 +17254,7 @@ const buildSync$1 = (deps, platform) => defineLinkedinCommand({
17216
17254
  },
17217
17255
  meta: commandMeta$2({
17218
17256
  capability: "read",
17219
- description: "Sync a collection into the local cache (spends usage)",
17257
+ description: "Sync a collection into the local cache (included in subscription)",
17220
17258
  method: "GET",
17221
17259
  mutates: true,
17222
17260
  name: "sync",
@@ -17228,24 +17266,17 @@ const buildSync$1 = (deps, platform) => defineLinkedinCommand({
17228
17266
  },
17229
17267
  capability: "read",
17230
17268
  cost: {
17231
- metered: true,
17232
- notes: ["Upstream reads during sync are metered."],
17269
+ metered: false,
17270
+ notes: ["LinkedIn proxy usage is included in the subscription."],
17233
17271
  unit: "usage_usd"
17234
17272
  },
17235
17273
  examples: [{ command: "social linkedin sync connections" }],
17236
- hazard: {
17237
- confirm: "advisory",
17238
- kind: "spends_usage"
17239
- },
17240
17274
  hazards: [{
17241
17275
  code: "local_cache_write",
17242
17276
  message: "Writes synced LinkedIn rows and cursor state to the local cache."
17243
- }, {
17244
- code: "usage_usd_spend",
17245
- message: "May spend usage dollars while reading upstream LinkedIn data."
17246
17277
  }],
17247
17278
  idempotency: {
17248
- reason: "Repeated syncs can spend additional usage dollars and update local rows.",
17279
+ reason: "Repeated syncs update local rows; LinkedIn proxy usage is included.",
17249
17280
  retry: "never",
17250
17281
  safe: false
17251
17282
  },
@@ -17521,10 +17552,10 @@ const buildMark = (deps) => {
17521
17552
  estimate: {
17522
17553
  basis: "successful upstream write",
17523
17554
  kind: "per_call",
17524
- usageUSD: creditsToUsageUSD(creditsForCostBPS(DM_INTERACTION_ENDPOINT_BILLING.costBPS))
17555
+ usageUSD: 0
17525
17556
  },
17526
- metered: true,
17527
- notes: ["Fresh upstream calls are metered."],
17557
+ metered: false,
17558
+ notes: ["LinkedIn proxy usage is included in the subscription."],
17528
17559
  unit: "usage_usd"
17529
17560
  },
17530
17561
  examples: [{ command: "linkedin messages <target> mark read" }],
@@ -17622,8 +17653,8 @@ const writeCost$1 = (usageUSD) => ({
17622
17653
  kind: "per_call",
17623
17654
  usageUSD
17624
17655
  },
17625
- metered: true,
17626
- notes: ["Fresh upstream calls are metered."],
17656
+ metered: false,
17657
+ notes: ["LinkedIn proxy usage is included in the subscription."],
17627
17658
  unit: "usage_usd"
17628
17659
  });
17629
17660
  const messageBodySchema = object({
@@ -17817,7 +17848,7 @@ const buildMessageDelete = (deps) => {
17817
17848
  scopes: ["read", "write"]
17818
17849
  },
17819
17850
  capability: "write",
17820
- cost: writeCost$1(creditsToUsageUSD(creditsForCostBPS(DM_INTERACTION_ENDPOINT_BILLING.costBPS))),
17851
+ cost: writeCost$1(0),
17821
17852
  examples: [{ command: "linkedin message <target> delete message_id:<id>" }],
17822
17853
  hazard: {
17823
17854
  confirm: "advisory",
@@ -17911,7 +17942,7 @@ const buildMessageEdit = (deps) => {
17911
17942
  scopes: ["read", "write"]
17912
17943
  },
17913
17944
  capability: "write",
17914
- cost: writeCost$1(creditsToUsageUSD(creditsForCostBPS(DM_INTERACTION_ENDPOINT_BILLING.costBPS))),
17945
+ cost: writeCost$1(0),
17915
17946
  examples: [{ command: "echo \"fixed text\" | linkedin message <target> edit message_id:<id>" }],
17916
17947
  hazard: {
17917
17948
  confirm: "advisory",
@@ -18095,27 +18126,31 @@ const buildMessage$1 = (deps, sendCommand) => {
18095
18126
  const own = await deps.resolveOwnLinkedinAccount({ account });
18096
18127
  const accountIdHeader = selectedAccount.selector;
18097
18128
  const headers = accountHeadersFor(accountIdHeader);
18098
- const response = classified.kind === "thread" ? await deps.api.post("linkedin/chats/".concat(encodeURIComponent(classified.id), "/messages"), {
18099
- headers,
18100
- json
18101
- }) : await deps.api.post("linkedin/inboxes/".concat(encodeURIComponent(await linkedinClassicInboxId({
18129
+ const destination = await linkedinMessageDestination(classified, async (path) => {
18130
+ return (await deps.api.get(`linkedin${path}`, { headers })).json();
18131
+ }, () => linkedinClassicInboxId({
18102
18132
  api: deps.api,
18103
18133
  cacheKey: accountIdHeader ?? selectedAccount.username,
18104
18134
  headers
18105
- })), "/chats"), {
18135
+ }));
18136
+ const response = await deps.api.post(`linkedin${destination.path}`, {
18106
18137
  headers,
18107
- json: {
18138
+ json: destination.chatId === null ? {
18108
18139
  ...json,
18109
18140
  text,
18110
18141
  users_ids: classified.id
18111
- }
18142
+ } : json
18112
18143
  });
18113
18144
  const data = await response.json();
18114
18145
  const projected = MutationResponse.parse(data);
18115
18146
  const fields = projected?.data ?? projected;
18116
18147
  const messageId = fields?.message_id;
18117
- const chatId = classified.kind === "thread" ? classified.id : fields?.chat_id ?? fields?.id;
18118
- if (responseSucceeded$1(response) && chatId !== void 0) await patchChatReadStatus(deps, chatId, headers, true);
18148
+ const chatId = destination.chatId ?? fields?.chat_id ?? fields?.id;
18149
+ if (responseSucceeded$1(response) && chatId !== void 0) try {
18150
+ await patchChatReadStatus(deps, chatId, headers, true);
18151
+ } catch {
18152
+ console.warn("linkedin.message.mark_read_failed");
18153
+ }
18119
18154
  if (responseSucceeded$1(response) && messageId !== void 0 && chatId !== void 0) {
18120
18155
  const ownAccountId = requireAccountSelector$1(own.accountIdHeader);
18121
18156
  writeThroughLinkedinCache({
@@ -18164,6 +18199,7 @@ const buildRequestsSend = (deps, liveCommand) => defineLinkedinCommand({
18164
18199
  const piped = trimTrailingNewline$1(await deps.readStdin());
18165
18200
  if (piped.length > 0) body = parseStdinBody$1(deps, "message", "message", piped);
18166
18201
  }
18202
+ if (body.message !== void 0) body.message = LinkedinConnectionNote.parse(body.message);
18167
18203
  const own = await deps.resolveOwnLinkedinAccount({ account });
18168
18204
  const ownAccountId = requireAccountSelector$1(own.accountIdHeader);
18169
18205
  const headers = { "x-social-account-id": ownAccountId };
@@ -26767,7 +26803,7 @@ function createEnv(opts) {
26767
26803
  } });
26768
26804
  }
26769
26805
  // package.json
26770
- var version$1 = "0.19.15";
26806
+ var version$1 = "0.19.16";
26771
26807
  // src/lib/env.ts
26772
26808
  const URLWithTrailingSlash = url().transform(ensureTrailingSlash);
26773
26809
  const env = createEnv({