@wirecat/hubspot-cli 0.0.0-stage → 0.2.0

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.
Files changed (261) hide show
  1. package/CHANGELOG.md +53 -0
  2. package/LICENSE +204 -0
  3. package/README.md +280 -2
  4. package/contracts/wirecat.json +3270 -0
  5. package/dist/bin/hubspot.d.ts +3 -0
  6. package/dist/bin/hubspot.d.ts.map +1 -0
  7. package/dist/bin/hubspot.js +40 -0
  8. package/dist/bin/hubspot.js.map +1 -0
  9. package/dist/bundle/all-profiles-64JAUYW4.js +279 -0
  10. package/dist/bundle/anthropic-VJOS4OUM.js +91 -0
  11. package/dist/bundle/app-server-GXV2OFML.js +245 -0
  12. package/dist/bundle/bun-M3J2QTR3.js +169 -0
  13. package/dist/bundle/bun-sqlite-IX3XYA5F.js +76 -0
  14. package/dist/bundle/chunk-24ERVFJP.js +73 -0
  15. package/dist/bundle/chunk-2QZK5BEP.js +392 -0
  16. package/dist/bundle/chunk-2UOJ7DLZ.js +46 -0
  17. package/dist/bundle/chunk-2VGD63G6.js +604 -0
  18. package/dist/bundle/chunk-2VGZRYEH.js +334 -0
  19. package/dist/bundle/chunk-36ITRDYY.js +63116 -0
  20. package/dist/bundle/chunk-3WLYWRGG.js +1395 -0
  21. package/dist/bundle/chunk-43EKCUBJ.js +72 -0
  22. package/dist/bundle/chunk-4W6BMH45.js +731 -0
  23. package/dist/bundle/chunk-5A6ZYNAQ.js +2003 -0
  24. package/dist/bundle/chunk-5D4AEUVA.js +24783 -0
  25. package/dist/bundle/chunk-5GBUCHRU.js +274 -0
  26. package/dist/bundle/chunk-5K7QLJMM.js +4072 -0
  27. package/dist/bundle/chunk-65TWQ7BV.js +54 -0
  28. package/dist/bundle/chunk-7ELMWE3P.js +12066 -0
  29. package/dist/bundle/chunk-ADLS6FVG.js +24600 -0
  30. package/dist/bundle/chunk-B3MANLNK.js +602 -0
  31. package/dist/bundle/chunk-C32AKHTY.js +2310 -0
  32. package/dist/bundle/chunk-CLAN3FES.js +1246 -0
  33. package/dist/bundle/chunk-CWXOXIWS.js +46 -0
  34. package/dist/bundle/chunk-D72URWJE.js +532 -0
  35. package/dist/bundle/chunk-DB2XKHI4.js +72 -0
  36. package/dist/bundle/chunk-DBEQI5YM.js +100 -0
  37. package/dist/bundle/chunk-DFCHHR5M.js +38 -0
  38. package/dist/bundle/chunk-DFDN6AUB.js +21 -0
  39. package/dist/bundle/chunk-DRWWJLI6.js +188 -0
  40. package/dist/bundle/chunk-DSP36YHQ.js +29 -0
  41. package/dist/bundle/chunk-E52JAS35.js +1028 -0
  42. package/dist/bundle/chunk-E5WLE7BM.js +78 -0
  43. package/dist/bundle/chunk-ECEZOLOD.js +230 -0
  44. package/dist/bundle/chunk-EH6ZEJGT.js +932 -0
  45. package/dist/bundle/chunk-FBCCBCFH.js +288 -0
  46. package/dist/bundle/chunk-FKA7DOCK.js +53 -0
  47. package/dist/bundle/chunk-FOZYMDRL.js +259 -0
  48. package/dist/bundle/chunk-FPUGMDJV.js +7 -0
  49. package/dist/bundle/chunk-FTFV3HFW.js +721 -0
  50. package/dist/bundle/chunk-GPYCBYX5.js +218 -0
  51. package/dist/bundle/chunk-H3TNVEQX.js +782 -0
  52. package/dist/bundle/chunk-HC5ZWE5X.js +193 -0
  53. package/dist/bundle/chunk-HCAZV5NP.js +95 -0
  54. package/dist/bundle/chunk-HZRQLAHO.js +16 -0
  55. package/dist/bundle/chunk-IJADZW42.js +195 -0
  56. package/dist/bundle/chunk-IMJQRPLN.js +92 -0
  57. package/dist/bundle/chunk-JLDBMEKZ.js +106 -0
  58. package/dist/bundle/chunk-LOBVOGOE.js +66 -0
  59. package/dist/bundle/chunk-LXZ66MCH.js +1328 -0
  60. package/dist/bundle/chunk-MFNMKHML.js +26462 -0
  61. package/dist/bundle/chunk-MVA5HVKL.js +1392 -0
  62. package/dist/bundle/chunk-N2XADGL4.js +76 -0
  63. package/dist/bundle/chunk-NHHJHXMQ.js +58 -0
  64. package/dist/bundle/chunk-NUU4WZVL.js +52 -0
  65. package/dist/bundle/chunk-NWHEHV3K.js +133 -0
  66. package/dist/bundle/chunk-NXERIDPJ.js +319 -0
  67. package/dist/bundle/chunk-O3DYRCIT.js +23 -0
  68. package/dist/bundle/chunk-O55RWNSH.js +161 -0
  69. package/dist/bundle/chunk-P5BHKKBI.js +206 -0
  70. package/dist/bundle/chunk-PPHBRESD.js +82 -0
  71. package/dist/bundle/chunk-PVKF24ZW.js +364 -0
  72. package/dist/bundle/chunk-Q2OLOMHL.js +4045 -0
  73. package/dist/bundle/chunk-QGFX5MXL.js +460 -0
  74. package/dist/bundle/chunk-QJW35N5V.js +761 -0
  75. package/dist/bundle/chunk-QU25DA5N.js +360 -0
  76. package/dist/bundle/chunk-RMIYKDUL.js +1068 -0
  77. package/dist/bundle/chunk-RR5MX5TM.js +142 -0
  78. package/dist/bundle/chunk-SDQGB4KB.js +185 -0
  79. package/dist/bundle/chunk-TBJYLC5K.js +2788 -0
  80. package/dist/bundle/chunk-TI46WQXQ.js +1197 -0
  81. package/dist/bundle/chunk-TKVL2C3B.js +170 -0
  82. package/dist/bundle/chunk-TLKEPUAV.js +786 -0
  83. package/dist/bundle/chunk-TOSCB4SO.js +1227 -0
  84. package/dist/bundle/chunk-TP7GDWVF.js +6848 -0
  85. package/dist/bundle/chunk-URX6YDUL.js +9393 -0
  86. package/dist/bundle/chunk-UUMUL4L3.js +72 -0
  87. package/dist/bundle/chunk-VOH7S5M4.js +40963 -0
  88. package/dist/bundle/chunk-W53EJOFQ.js +63 -0
  89. package/dist/bundle/chunk-W7HM2VGO.js +24 -0
  90. package/dist/bundle/chunk-WE4UFASG.js +88 -0
  91. package/dist/bundle/chunk-X2M6NIQG.js +18 -0
  92. package/dist/bundle/chunk-XRREFEIW.js +372 -0
  93. package/dist/bundle/chunk-Y5E2WNWB.js +35 -0
  94. package/dist/bundle/chunk-YMCY7VRE.js +1846 -0
  95. package/dist/bundle/chunk-Z73OL5HV.js +41 -0
  96. package/dist/bundle/chunk-ZVVMGPBJ.js +50 -0
  97. package/dist/bundle/command-contract-C6CBFXZF.js +40 -0
  98. package/dist/bundle/command-server-entry-DJKVVZCQ.js +169 -0
  99. package/dist/bundle/decode-FC65Y4IV.js +297 -0
  100. package/dist/bundle/definitions-MVPICAWV.js +2991 -0
  101. package/dist/bundle/dispatch-KOISQ5QJ.js +411 -0
  102. package/dist/bundle/dist-7TGU56B2.js +7577 -0
  103. package/dist/bundle/echarts-FVTUDXDU.js +42501 -0
  104. package/dist/bundle/embed-VNBZFPYH.js +38 -0
  105. package/dist/bundle/embedder-6U4NOFRO.js +111 -0
  106. package/dist/bundle/failure-FZ6VYKEQ.js +25 -0
  107. package/dist/bundle/first-run-UWAFSINQ.js +29 -0
  108. package/dist/bundle/first-screen-RTVMGHAE.js +40 -0
  109. package/dist/bundle/hubspot.js +198 -0
  110. package/dist/bundle/instructions-HET7BCYK.js +11 -0
  111. package/dist/bundle/mcp-RGNRW77S.js +167 -0
  112. package/dist/bundle/meeting-combined-L5AGBPYX.js +25 -0
  113. package/dist/bundle/meeting-model-NTB4RK3F.js +25 -0
  114. package/dist/bundle/meeting-semantic-JY3OGCBS.js +22 -0
  115. package/dist/bundle/node-CXZIFHZC.js +176 -0
  116. package/dist/bundle/node-P4E63KXA.js +2340 -0
  117. package/dist/bundle/node-TLZSIHIJ.js +21 -0
  118. package/dist/bundle/node-sqlite-P3O7XN7Q.js +74 -0
  119. package/dist/bundle/oauth-HNCY4B2S.js +20 -0
  120. package/dist/bundle/open-F4P6YV54.js +23 -0
  121. package/dist/bundle/openai-4AICLIK3.js +238 -0
  122. package/dist/bundle/process-5RUXWGYS.js +91 -0
  123. package/dist/bundle/program-XA4C44Z4.js +9374 -0
  124. package/dist/bundle/prompt-NFMDVBZ4.js +17 -0
  125. package/dist/bundle/recognize-DKN3RY4V.js +26 -0
  126. package/dist/bundle/remote-6QHAGQWY.js +31 -0
  127. package/dist/bundle/rerank-M4KHEHUZ.js +52 -0
  128. package/dist/bundle/schemas-JRL3DLMP.js +952 -0
  129. package/dist/bundle/serve-DNU43ND6.js +199 -0
  130. package/dist/bundle/server-ATG5KY7K.js +207 -0
  131. package/dist/bundle/server-VNWVVH7A.js +77 -0
  132. package/dist/bundle/source-54HR4IWG.js +661 -0
  133. package/dist/bundle/sqlite-runtime-EMQAC63N.js +20 -0
  134. package/dist/bundle/state-T45CX7VY.js +36 -0
  135. package/dist/bundle/store-6LCEVBAZ.js +176 -0
  136. package/dist/bundle/store-6TZ2FCVA.js +295 -0
  137. package/dist/bundle/store-DXWYNVVB.js +32 -0
  138. package/dist/bundle/store-maintenance-command-J57HCJYY.js +68 -0
  139. package/dist/bundle/writer-NLLI5YRM.js +79 -0
  140. package/dist/commands/account.d.ts +3 -0
  141. package/dist/commands/account.d.ts.map +1 -0
  142. package/dist/commands/account.js +87 -0
  143. package/dist/commands/account.js.map +1 -0
  144. package/dist/commands/api.d.ts +9 -0
  145. package/dist/commands/api.d.ts.map +1 -0
  146. package/dist/commands/api.js +70 -0
  147. package/dist/commands/api.js.map +1 -0
  148. package/dist/commands/crm-shared.d.ts +8 -0
  149. package/dist/commands/crm-shared.d.ts.map +1 -0
  150. package/dist/commands/crm-shared.js +109 -0
  151. package/dist/commands/crm-shared.js.map +1 -0
  152. package/dist/commands/schedule.d.ts +3 -0
  153. package/dist/commands/schedule.d.ts.map +1 -0
  154. package/dist/commands/schedule.js +9 -0
  155. package/dist/commands/schedule.js.map +1 -0
  156. package/dist/commands/session.d.ts +14 -0
  157. package/dist/commands/session.d.ts.map +1 -0
  158. package/dist/commands/session.js +164 -0
  159. package/dist/commands/session.js.map +1 -0
  160. package/dist/config.d.ts +60 -0
  161. package/dist/config.d.ts.map +1 -0
  162. package/dist/config.js +153 -0
  163. package/dist/config.js.map +1 -0
  164. package/dist/context.d.ts +88 -0
  165. package/dist/context.d.ts.map +1 -0
  166. package/dist/context.js +137 -0
  167. package/dist/context.js.map +1 -0
  168. package/dist/crm/activities.d.ts +24 -0
  169. package/dist/crm/activities.d.ts.map +1 -0
  170. package/dist/crm/activities.js +214 -0
  171. package/dist/crm/activities.js.map +1 -0
  172. package/dist/crm/associations.d.ts +20 -0
  173. package/dist/crm/associations.d.ts.map +1 -0
  174. package/dist/crm/associations.js +47 -0
  175. package/dist/crm/associations.js.map +1 -0
  176. package/dist/crm/records.d.ts +63 -0
  177. package/dist/crm/records.d.ts.map +1 -0
  178. package/dist/crm/records.js +333 -0
  179. package/dist/crm/records.js.map +1 -0
  180. package/dist/crm/search.d.ts +57 -0
  181. package/dist/crm/search.d.ts.map +1 -0
  182. package/dist/crm/search.js +47 -0
  183. package/dist/crm/search.js.map +1 -0
  184. package/dist/crm/source.d.ts +37 -0
  185. package/dist/crm/source.d.ts.map +1 -0
  186. package/dist/crm/source.js +366 -0
  187. package/dist/crm/source.js.map +1 -0
  188. package/dist/crm/writer.d.ts +15 -0
  189. package/dist/crm/writer.d.ts.map +1 -0
  190. package/dist/crm/writer.js +199 -0
  191. package/dist/crm/writer.js.map +1 -0
  192. package/dist/generated/definitions.d.ts +3 -0
  193. package/dist/generated/definitions.d.ts.map +1 -0
  194. package/dist/generated/definitions.js +2987 -0
  195. package/dist/generated/definitions.js.map +1 -0
  196. package/dist/generated/manifest.d.ts +6 -0
  197. package/dist/generated/manifest.d.ts.map +1 -0
  198. package/dist/generated/manifest.js +6504 -0
  199. package/dist/generated/manifest.js.map +1 -0
  200. package/dist/generated/schemas.d.ts +205 -0
  201. package/dist/generated/schemas.d.ts.map +1 -0
  202. package/dist/generated/schemas.js +810 -0
  203. package/dist/generated/schemas.js.map +1 -0
  204. package/dist/generated/types.d.ts +1114 -0
  205. package/dist/generated/types.d.ts.map +1 -0
  206. package/dist/generated/types.js +5 -0
  207. package/dist/generated/types.js.map +1 -0
  208. package/dist/hubspot/account.d.ts +12 -0
  209. package/dist/hubspot/account.d.ts.map +1 -0
  210. package/dist/hubspot/account.js +23 -0
  211. package/dist/hubspot/account.js.map +1 -0
  212. package/dist/hubspot/transport.d.ts +81 -0
  213. package/dist/hubspot/transport.d.ts.map +1 -0
  214. package/dist/hubspot/transport.js +354 -0
  215. package/dist/hubspot/transport.js.map +1 -0
  216. package/dist/identity.d.ts +7 -0
  217. package/dist/identity.d.ts.map +1 -0
  218. package/dist/identity.js +32 -0
  219. package/dist/identity.js.map +1 -0
  220. package/dist/index.d.ts +3 -0
  221. package/dist/index.d.ts.map +1 -0
  222. package/dist/index.js +3 -0
  223. package/dist/index.js.map +1 -0
  224. package/dist/program.d.ts +6 -0
  225. package/dist/program.d.ts.map +1 -0
  226. package/dist/program.js +78 -0
  227. package/dist/program.js.map +1 -0
  228. package/dist/reasons.d.ts +10 -0
  229. package/dist/reasons.d.ts.map +1 -0
  230. package/dist/reasons.js +33 -0
  231. package/dist/reasons.js.map +1 -0
  232. package/dist/setup/flow.d.ts +2 -0
  233. package/dist/setup/flow.d.ts.map +1 -0
  234. package/dist/setup/flow.js +97 -0
  235. package/dist/setup/flow.js.map +1 -0
  236. package/dist/setup/texts.en.json +19 -0
  237. package/dist/setup/texts.es.json +19 -0
  238. package/dist/setup/texts.ru.json +19 -0
  239. package/dist/store.d.ts +16 -0
  240. package/dist/store.d.ts.map +1 -0
  241. package/dist/store.js +34 -0
  242. package/dist/store.js.map +1 -0
  243. package/dist/version.d.ts +2 -0
  244. package/dist/version.d.ts.map +1 -0
  245. package/dist/version.js +2 -0
  246. package/dist/version.js.map +1 -0
  247. package/dist/wcat.d.ts +3 -0
  248. package/dist/wcat.d.ts.map +1 -0
  249. package/dist/wcat.js +4 -0
  250. package/dist/wcat.js.map +1 -0
  251. package/dist/whoami.d.ts +19 -0
  252. package/dist/whoami.d.ts.map +1 -0
  253. package/dist/whoami.js +15 -0
  254. package/dist/whoami.js.map +1 -0
  255. package/package.json +98 -4
  256. package/skills/hubspot-cli/SKILL.md +102 -0
  257. package/skills/hubspot-cli/references/api/api-advanced.md +51 -0
  258. package/skills/hubspot-cli/references/api/api-basic.md +1064 -0
  259. package/skills/hubspot-cli/references/api/api-batch.md +724 -0
  260. package/skills/hubspot-cli/references/api/api-search.md +147 -0
  261. package/skills/hubspot-cli/references/api.md +16 -0
@@ -0,0 +1,87 @@
1
+ import { readFileSync } from "node:fs";
2
+ import { join } from "node:path";
3
+ import { CliError, resolvePaths } from "@wirecat/cli-base";
4
+ import { annotate } from "@wirecat/cli-base/commands";
5
+ import { accountFileFor, accountRemoveCommand, LOCAL_READ, LOCAL_WRITE, profilesHere, } from "@wirecat/cli-core/cli";
6
+ import { Command } from "commander";
7
+ import { configuration } from "../config.js";
8
+ import { contextOf } from "../context.js";
9
+ import { IDENTITY } from "../identity.js";
10
+ import { PROVIDER } from "../store.js";
11
+ import { signedInTo } from "./session.js";
12
+ /** The portal id `session start` remembered: it outlives `session end`, so a copy can still be found. */
13
+ const rememberedOf = (env, profile) => {
14
+ try {
15
+ const { account } = JSON.parse(readFileSync(accountFileFor(IDENTITY, profile, env), "utf8"));
16
+ return typeof account === "string" && /^\d+$/.test(account) ? account : undefined;
17
+ }
18
+ catch {
19
+ return undefined;
20
+ }
21
+ };
22
+ const portalOf = (env, keyring, profile) => {
23
+ try {
24
+ return signedInTo(env, keyring, profile) ?? rememberedOf(env, profile);
25
+ }
26
+ catch {
27
+ return rememberedOf(env, profile);
28
+ }
29
+ };
30
+ const removal = {
31
+ // HubSpot has no call that revokes a service key or a private app token; the account's settings do.
32
+ signOut: async (profile) => ({
33
+ revoked: null,
34
+ removed: [`the sign-in of ${profile} (the key stays valid in HubSpot until you delete or rotate it there)`],
35
+ }),
36
+ account: (profile, { env, keyring }) => {
37
+ const portal = portalOf(env, keyring, profile);
38
+ return portal ? { provider: PROVIDER.name, account: portal } : undefined;
39
+ },
40
+ secrets: (profile, { env, keyring }) => [
41
+ {
42
+ credentials: {
43
+ configDir: resolvePaths({ appName: IDENTITY.appName, prefix: IDENTITY.envPrefix, env }).config,
44
+ service: IDENTITY.appName,
45
+ envVar: `${IDENTITY.envPrefix}_TOKEN`,
46
+ env,
47
+ ...(keyring ? { keyring } : {}),
48
+ },
49
+ accounts: [`token:${profile}`],
50
+ },
51
+ ],
52
+ stateFiles: (profile, { env }) => [
53
+ join(resolvePaths({ appName: IDENTITY.appName, prefix: IDENTITY.envPrefix, env }).state, "crm", profile),
54
+ ],
55
+ };
56
+ /**
57
+ * The store keeps one copy per account, so deleting one profile's data deletes every profile's on that account. A
58
+ * second sign-in to it is refused, but a profile that ended its session still remembers its account.
59
+ */
60
+ const refuseSharedDelete = (command) => {
61
+ if (command.opts().deleteData !== true)
62
+ return;
63
+ const { env, keyring, profile, renderer } = contextOf(command);
64
+ const own = portalOf(env, keyring, profile);
65
+ if (!own)
66
+ return;
67
+ // biome-ignore lint/plugin/no-own-settings: this check reads every profile, and baseContext names one
68
+ const { configuredProfiles } = configuration.resolveSettings({}, { env, needsProfile: false });
69
+ const sharing = profilesHere(IDENTITY, configuredProfiles, env).filter((one) => one !== profile && portalOf(env, keyring, one) === own);
70
+ if (sharing.length === 0)
71
+ return;
72
+ const names = sharing.join(", ");
73
+ // A dry run lists what --delete-data would delete, and says the real run refuses.
74
+ if (command.opts().dryRun === true) {
75
+ renderer.warn(`without --dry-run this refuses: ${names} also read${sharing.length === 1 ? "s" : ""} ${own}`);
76
+ return;
77
+ }
78
+ throw new CliError("conflict", `${names} also read${sharing.length === 1 ? "s" : ""} account ${own}, and the store keeps one copy of an ` +
79
+ `account: --delete-data would delete their deals, contacts and companies too. Use --keep-data, or remove ` +
80
+ `${names} first`, { reason: "account-remove.account-shared", profiles: sharing, account: own });
81
+ };
82
+ export const accountCommand = () => annotate(new Command("account"), { effects: LOCAL_READ })
83
+ .description("this profile on this computer")
84
+ .addCommand(annotate(accountRemoveCommand(IDENTITY, removal, { resolveSettings: configuration.resolveSettings }), {
85
+ effects: LOCAL_WRITE,
86
+ }).hook("preAction", (_, action) => refuseSharedDelete(action)));
87
+ //# sourceMappingURL=account.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":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M,KAAK,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,IAAI,GAAG,EAAE,CAAC,CAAA;QAC5G,OAAM;IACR,CAAC;IACD,MAAM,IAAI,QAAQ,CAChB,UAAU,EACV,GAAG,KAAK,aAAa,OAAO,CAAC,MAAM,KAAK,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,YAAY,GAAG,uCAAuC;QACxG,0GAA0G;QAC1G,GAAG,KAAK,QAAQ,EAClB,EAAE,MAAM,EAAE,+BAA+B,EAAE,QAAQ,EAAE,OAAO,EAAE,OAAO,EAAE,GAAG,EAAE,CAC7E,CAAA;AACH,CAAC,CAAA;AAED,MAAM,CAAC,MAAM,cAAc,GAAG,GAAY,EAAE,CAC1C,QAAQ,CAAC,IAAI,OAAO,CAAC,SAAS,CAAC,EAAE,EAAE,OAAO,EAAE,UAAU,EAAE,CAAC;KACtD,WAAW,CAAC,+BAA+B,CAAC;KAC5C,UAAU,CACT,QAAQ,CAAC,oBAAoB,CAAC,QAAQ,EAAE,OAAO,EAAE,EAAE,eAAe,EAAE,aAAa,CAAC,eAAe,EAAE,CAAC,EAAE;IACpG,OAAO,EAAE,WAAW;CACrB,CAAC,CAAC,IAAI,CAAC,WAAW,EAAE,CAAC,CAAC,EAAE,MAAM,EAAE,EAAE,CAAC,kBAAkB,CAAC,MAAM,CAAC,CAAC,CAChE,CAAA"}
@@ -0,0 +1,9 @@
1
+ import type { Command } from "commander";
2
+ /**
3
+ * HubSpot's CRM API from its spec: `api list`, `api show` and one command per operation, through cli-core's shared
4
+ * group, each write and delete behind its keys. The requests keep the account's pace beside the CRM commands, the token
5
+ * is the profile's own, and a refusal reads as the CRM commands' do: the scope a 403 names, the daily limit and its
6
+ * midnight, and a write HubSpot failed during as `outcome_unknown`.
7
+ */
8
+ export declare const apiCommand: () => Command;
9
+ //# sourceMappingURL=api.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"api.d.ts","sourceRoot":"","sources":["../../src/commands/api.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AAiCxC;;;;;GAKG;AACH,eAAO,MAAM,UAAU,QAAO,OAmC7B,CAAA"}
@@ -0,0 +1,70 @@
1
+ import { CliError } from "@wirecat/cli-base";
2
+ import { hostFetch, retrying } from "@wirecat/cli-base/http";
3
+ import { serviceApiCommand } from "@wirecat/cli-core/cli";
4
+ import { API, configuration } from "../config.js";
5
+ import { contextOf, pacerFor, storedSignIn, tokenOf } from "../context.js";
6
+ import { failureOf, isRecord, LONGEST_PACE_WAIT_MS } from "../hubspot/transport.js";
7
+ import { DESKTOP, IDENTITY } from "../identity.js";
8
+ /**
9
+ * A 429 for the account's daily allowance ends the request at once: `retrying` would send it again within seconds,
10
+ * and it only comes back at the account's midnight. Every process on the account then holds off until then.
11
+ */
12
+ const stopAtDailyLimit = (send, sent, pacer) => async (input, init) => {
13
+ const response = await send(input, init);
14
+ if (response.status !== 429)
15
+ return response;
16
+ const body = await response
17
+ .clone()
18
+ .json()
19
+ .catch(() => undefined);
20
+ if (!isRecord(body) || body.policyName !== "DAILY")
21
+ return response;
22
+ await response.body?.cancel().catch(() => { });
23
+ const failure = failureOf({ status: 429, writes: false, body, now: sent.now(), timeZone: sent.timeZone });
24
+ const wait = failure.details.retry_after_ms;
25
+ if (typeof wait === "number")
26
+ await pacer.holdFor(wait).catch(() => undefined);
27
+ throw new CliError(failure.code, failure.message, { ...failure.details, retryable: false });
28
+ };
29
+ /**
30
+ * HubSpot's CRM API from its spec: `api list`, `api show` and one command per operation, through cli-core's shared
31
+ * group, each write and delete behind its keys. The requests keep the account's pace beside the CRM commands, the token
32
+ * is the profile's own, and a refusal reads as the CRM commands' do: the scope a 403 names, the daily limit and its
33
+ * midnight, and a write HubSpot failed during as `outcome_unknown`.
34
+ */
35
+ export const apiCommand = () => {
36
+ const sent = { now: Date.now };
37
+ return serviceApiCommand({
38
+ ...API,
39
+ app: IDENTITY,
40
+ configuration,
41
+ fetch: (command) => {
42
+ const { environment } = contextOf(command);
43
+ const { now } = environment;
44
+ const signIn = storedSignIn(command);
45
+ sent.now = now ?? Date.now;
46
+ sent.timeZone = signIn?.timeZone;
47
+ const pacer = pacerFor(command, signIn?.portalId);
48
+ const send = hostFetch({ hosts: DESKTOP.hosts ?? [], ...(environment.fetch ? { fetch: environment.fetch } : {}) });
49
+ // A hold longer than this, such as the daily limit's until midnight, ends the command at once, as the CRM
50
+ // commands do, instead of sleeping in it.
51
+ return retrying(stopAtDailyLimit(send, sent, pacer), {
52
+ pacer,
53
+ budget: LONGEST_PACE_WAIT_MS,
54
+ ...(environment.sleep ? { sleep: environment.sleep } : {}),
55
+ ...(now ? { now: () => new Date(now()) } : {}),
56
+ });
57
+ },
58
+ failure: (status, answer, operation) => failureOf({
59
+ status,
60
+ writes: operation.effect !== "read",
61
+ body: answer,
62
+ now: sent.now(),
63
+ timeZone: sent.timeZone,
64
+ }),
65
+ token: tokenOf,
66
+ schemas: () => import("../generated/schemas.js").then((module) => module.schemas),
67
+ definitions: () => import("../generated/definitions.js").then((module) => module.definitions),
68
+ });
69
+ };
70
+ //# sourceMappingURL=api.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"api.js","sourceRoot":"","sources":["../../src/commands/api.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAA;AAE5C,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,wBAAwB,CAAA;AAC5D,OAAO,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAA;AAGzD,OAAO,EAAE,GAAG,EAAE,aAAa,EAAE,MAAM,cAAc,CAAA;AACjD,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,YAAY,EAAE,OAAO,EAAE,MAAM,eAAe,CAAA;AAC1E,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,oBAAoB,EAAE,MAAM,yBAAyB,CAAA;A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AC,IAAI,IAAI,CAAC,GAAG,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;aAC/C,CAAC,CAAA;QACJ,CAAC;QACD,OAAO,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,SAAS,EAAE,EAAE,CACrC,SAAS,CAAC;YACR,MAAM;YACN,MAAM,EAAE,SAAS,CAAC,MAAM,KAAK,MAAM;YACnC,IAAI,EAAE,MAAM;YACZ,GAAG,EAAE,IAAI,CAAC,GAAG,EAAE;YACf,QAAQ,EAAE,IAAI,CAAC,QAAQ;SACxB,CAAC;QACJ,KAAK,EAAE,OAAO;QACd,OAAO,EAAE,GAAG,EAAE,CAAC,MAAM,CAAC,yBAAyB,CAAC,CAAC,IAAI,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM,CAAC,OAAO,CAAC;QACjF,WAAW,EAAE,GAAG,EAAE,CAAC,MAAM,CAAC,6BAA6B,CAAC,CAAC,IAAI,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM,CAAC,WAAW,CAAC;KAC9F,CAAC,CAAA;AACJ,CAAC,CAAA"}
@@ -0,0 +1,8 @@
1
+ import { Command } from "commander";
2
+ /**
3
+ * cli-core's shared CRM commands over the account: `sync`, `store status`, `deals`, `leads`, `pipelines`, `stages`,
4
+ * `fields`, `activities`, `changes`, `search all`, `people`, `organizations` and `users` read live, and the writes of
5
+ * deals, contacts and companies.
6
+ */
7
+ export declare const crmSharedCommands: () => Command[];
8
+ //# sourceMappingURL=crm-shared.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"crm-shared.d.ts","sourceRoot":"","sources":["../../src/commands/crm-shared.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AAoGnC;;;;GAIG;AACH,eAAO,MAAM,iBAAiB,QAAO,OAAO,EAW3C,CAAA"}
@@ -0,0 +1,109 @@
1
+ import { CliError } from "@wirecat/cli-base";
2
+ import { metaOf } from "@wirecat/cli-base/commands";
3
+ import { outputFor } from "@wirecat/cli-core/cli";
4
+ import { addCrmCommands, openCrmStore } from "@wirecat/cli-core/crm/cli";
5
+ import { Command } from "commander";
6
+ import { crmApiKeys, permissions } from "../config.js";
7
+ import { ACCOUNT_VARIABLE, contextOf, fromEnvironment, hubFor, refuseAccountMismatch, signInOf, storedSignIn, } from "../context.js";
8
+ import { HUBSPOT_WRITES } from "../crm/writer.js";
9
+ import { IDENTITY } from "../identity.js";
10
+ import { accountAnswer } from "../whoami.js";
11
+ /** The account the store saved for this profile after a checked run, read without writing; none when it has none. */
12
+ const savedAccount = async (env, profile) => {
13
+ const { openHubspotStore } = await import("../store.js");
14
+ const store = await openHubspotStore(env, { readOnly: true }).catch(() => undefined);
15
+ if (!store)
16
+ return undefined;
17
+ try {
18
+ return (await store.accounts.profiles())[IDENTITY.command]?.[profile]?.account;
19
+ }
20
+ catch {
21
+ return undefined;
22
+ }
23
+ finally {
24
+ await store.close();
25
+ }
26
+ };
27
+ /** The selected profile's account for one command; cli-core closes the store before the answer prints. */
28
+ const openProfile = async (command, { readOnly }) => {
29
+ const { env, profile, environment } = contextOf(command);
30
+ const [{ openHubspotStore, PROVIDER }, { hubspotCrmSource }, { hubspotCrmWriter }] = await Promise.all([
31
+ import("../store.js"),
32
+ import("../crm/source.js"),
33
+ import("../crm/writer.js"),
34
+ ]);
35
+ // A command that reaches HubSpot with `WCHUBSPOT_TOKEN` first asks whose token it is, once, on a transport of its
36
+ // own; the answer's time zone then counts the daily limit to the account's midnight. A command that stays on this
37
+ // computer asks nothing: it takes the account the store saved for the profile after a checked run.
38
+ const fromToken = fromEnvironment(command);
39
+ // cli-core annotates every CRM command, and refuses --offline before a remote one opens the profile.
40
+ const online = metaOf(command).effects?.remote !== "none";
41
+ let timeZone;
42
+ if (fromToken && online) {
43
+ const { token, portalId } = signInOf(command);
44
+ const who = await accountAnswer(hubFor(command, { token, portalId }));
45
+ refuseAccountMismatch(portalId, who.account);
46
+ timeZone = who.account_info.time_zone;
47
+ }
48
+ const saved = fromToken && !online && !readOnly ? await savedAccount(env, profile) : undefined;
49
+ let transport;
50
+ const hub = () => (transport ??= hubFor(command, { ...signInOf(command), ...(timeZone ? { timeZone } : {}) }));
51
+ const accountOf = () => {
52
+ const signIn = storedSignIn(command) ?? signInOf(command);
53
+ if (fromToken && !online && saved !== signIn.portalId)
54
+ throw new CliError("configuration_error", `run \`${IDENTITY.command} ${profile} sync\` once with ${IDENTITY.envPrefix}_TOKEN first: it checks ` +
55
+ `${ACCOUNT_VARIABLE} against the token before this profile reads a copy`, { reason: "account.unchecked" });
56
+ return { provider: PROVIDER.name, account: signIn.portalId };
57
+ };
58
+ const { store, account } = await openCrmStore({
59
+ app: IDENTITY,
60
+ env,
61
+ profile,
62
+ readOnly,
63
+ provider: PROVIDER.name,
64
+ open: openHubspotStore,
65
+ account: accountOf,
66
+ });
67
+ let source;
68
+ const crm = () => (source ??= hubspotCrmSource(hub, environment.now ? { now: environment.now } : {}));
69
+ return {
70
+ profile,
71
+ account,
72
+ // A service key or a private app token belongs to the account, not a user: the source has no `self`, so the copy
73
+ // is the whole account and every profile reads all of it.
74
+ user: null,
75
+ store,
76
+ env,
77
+ locked: Boolean(env[`${IDENTITY.envPrefix}_PROFILE_LOCK`]),
78
+ source: crm,
79
+ // No `self`: the key is the account's, so every `--owner` gives the record to someone else (crm.assign-others).
80
+ writes: () => ({
81
+ writer: hubspotCrmWriter(hub, crm),
82
+ app: IDENTITY,
83
+ env,
84
+ warn: outputFor(command).renderer.warn,
85
+ alsoChecks: crmApiKeys,
86
+ // contextOf, not resolveSettings: it carries the levels `mcp serve --permission` tightened.
87
+ settings: () => ({ ...contextOf(command).settings, permissionDefaults: permissions.defaults }),
88
+ }),
89
+ close: () => store.close(),
90
+ };
91
+ };
92
+ /**
93
+ * cli-core's shared CRM commands over the account: `sync`, `store status`, `deals`, `leads`, `pipelines`, `stages`,
94
+ * `fields`, `activities`, `changes`, `search all`, `people`, `organizations` and `users` read live, and the writes of
95
+ * deals, contacts and companies.
96
+ */
97
+ export const crmSharedCommands = () => {
98
+ const holder = new Command(IDENTITY.command);
99
+ addCrmCommands(holder, {
100
+ app: IDENTITY,
101
+ open: openProfile,
102
+ leads: true,
103
+ writes: HUBSPOT_WRITES,
104
+ live: ["person", "organization", "user"],
105
+ activities: true,
106
+ });
107
+ return [...holder.commands];
108
+ };
109
+ //# sourceMappingURL=crm-shared.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"crm-shared.js","sourceRoot":"","sources":["../../src/commands/crm-shared.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAA;AAC5C,OAAO,EAAE,MAAM,EAAE,MAAM,4BAA4B,CAAA;AACnD,OAAO,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAA;AAEjD,OAAO,EAAE,cAAc,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAA;AAExE,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AACnC,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,cAAc,CAAA;AACtD,OAAO,EACL,gBAAgB,EAChB,SAAS,EACT,eAAe,EACf,MAAM,EACN,qBAAqB,EACrB,QAAQ,EACR,YAAY,GACb,MAAM,eAAe,CAAA;AACtB,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAA;AAEjD,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAA;AACzC,OAAO,EAAE,aAAa,EAAE,MAAM,cAAc,CAAA;AAE5C,qHAAqH;AACrH,MAAM,YAAY,GAAG,KAAK,EAAE,GAAsB,EAAE,OAAe,EAA+B,EAAE;IAClG,MAAM,EAAE,gBAAgB,EAAE,GAAG,MAAM,MAAM,CAAC,aAAa,CAAC,CAAA;IACxD,MAAM,KAAK,GAAG,MAAM,gBAAgB,CAAC,GAAG,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC,CAAC,KAAK,CAAC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IAC5C,cAAc,CAAC,MAAM,EAAE;QACrB,GAAG,EAAE,QAAQ;QACb,IAAI,EAAE,WAAW;QACjB,KAAK,EAAE,IAAI;QACX,MAAM,EAAE,cAAc;QACtB,IAAI,EAAE,CAAC,QAAQ,EAAE,cAAc,EAAE,MAAM,CAAC;QACxC,UAAU,EAAE,IAAI;KACjB,CAAC,CAAA;IACF,OAAO,CAAC,GAAG,MAAM,CAAC,QAAQ,CAAC,CAAA;AAC7B,CAAC,CAAA"}
@@ -0,0 +1,3 @@
1
+ import type { Command } from "commander";
2
+ export declare const scheduleCommand: () => Command;
3
+ //# sourceMappingURL=schedule.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"schedule.d.ts","sourceRoot":"","sources":["../../src/commands/schedule.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AAWxC,eAAO,MAAM,eAAe,QAAO,OAAoE,CAAA"}
@@ -0,0 +1,9 @@
1
+ import { baseContext, scheduleCommandFor } from "@wirecat/cli-core/cli";
2
+ import { configuration } from "../config.js";
3
+ import { IDENTITY } from "../identity.js";
4
+ const contextOf = (command, resolving) => {
5
+ const base = baseContext(command, (flags, options) => configuration.resolveSettings(flags, { ...options, ...resolving }));
6
+ return { ...base, profile: base.settings.profile };
7
+ };
8
+ export const scheduleCommand = () => scheduleCommandFor({ app: IDENTITY, context: contextOf });
9
+ //# sourceMappingURL=schedule.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"schedule.js","sourceRoot":"","sources":["../../src/commands/schedule.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,kBAAkB,EAAE,MAAM,uBAAuB,CAAA;AAEvE,OAAO,EAAE,aAAa,EAAE,MAAM,cAAc,CAAA;AAC5C,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAA;AAEzC,MAAM,SAAS,GAAG,CAAC,OAAgB,EAAE,SAAsC,EAAE,EAAE;IAC7E,MAAM,IAAI,GAAG,WAAW,CAAC,OAAO,EAAE,CAAC,KAAK,EAAE,OAAO,EAAE,EAAE,CACnD,aAAa,CAAC,eAAe,CAAC,KAAK,EAAE,EAAE,GAAG,OAAO,EAAE,GAAG,SAAS,EAAE,CAAC,CACnE,CAAA;IACD,OAAO,EAAE,GAAG,IAAI,EAAE,OAAO,EAAE,IAAI,CAAC,QAAQ,CAAC,OAAO,EAAE,CAAA;AACpD,CAAC,CAAA;AAED,MAAM,CAAC,MAAM,eAAe,GAAG,GAAY,EAAE,CAAC,kBAAkB,CAAC,EAAE,GAAG,EAAE,QAAQ,EAAE,OAAO,EAAE,SAAS,EAAE,CAAC,CAAA"}
@@ -0,0 +1,14 @@
1
+ import { type KeyringStore } from "@wirecat/cli-base";
2
+ import { Command } from "commander";
3
+ /** The account a profile's saved sign-in reaches; one from `WCHUBSPOT_TOKEN` is no profile's. */
4
+ export declare const signedInTo: (env: NodeJS.ProcessEnv, keyring: KeyringStore | undefined, profile: string) => string | undefined;
5
+ /**
6
+ * A token proven against its account, and what a profile keeps for it: the token with the account beside it.
7
+ * `setup apply` runs the same check.
8
+ */
9
+ export declare const checkedToken: (command: Command, token: string) => Promise<{
10
+ who: import("../whoami.js").AccountAnswer;
11
+ signIn: string;
12
+ }>;
13
+ export declare const sessionCommand: () => Command;
14
+ //# sourceMappingURL=session.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"session.d.ts","sourceRoot":"","sources":["../../src/commands/session.ts"],"names":[],"mappings":"AAAA,OAAO,EAAY,KAAK,YAAY,EAAE,MAAM,mBAAmB,CAAA;AA0B/D,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AA6BnC,iGAAiG;AACjG,eAAO,MAAM,UAAU,QAAS,MAAM,CAAC,UAAU,WAAW,YAAY,GAAG,SAAS,WAAW,MAAM,uBAIpG,CAAA;AA0BD;;;GAGG;AACH,eAAO,MAAM,YAAY,YAAmB,OAAO,SAAS,MAAM;;;EAMjE,CAAA;AA4HD,eAAO,MAAM,cAAc,QAAO,OAMJ,CAAA"}
@@ -0,0 +1,164 @@
1
+ import { CliError } from "@wirecat/cli-base";
2
+ import { annotate } from "@wirecat/cli-base/commands";
3
+ import { readSecret } from "@wirecat/cli-core";
4
+ import { commandWords, environmentOf, FETCH, itemOf, LOCAL_READ, LOCAL_WRITE, listOf, logsInOrOut, outputFor, ProfileTokenStore, profileFree, profilesHere, REMOTE_READ, refuseCommandName, refuseOffline, refuseUnderReadOnly, rememberAccount, renderAnswer, rootOf, secretInputOf, } from "@wirecat/cli-core/cli";
5
+ import { Command } from "commander";
6
+ import { configuration } from "../config.js";
7
+ import { contextOf, decodeSignIn, encodeSignIn, environmentAccount, hubFor, refuseAccountMismatch, storedSignIn, withHub, } from "../context.js";
8
+ import { SERVICE } from "../hubspot/transport.js";
9
+ import { IDENTITY } from "../identity.js";
10
+ import { accountAnswer } from "../whoami.js";
11
+ const HUBSPOT = IDENTITY.command;
12
+ const answer = (command, item) => renderAnswer(command, outputFor(command), itemOf(item));
13
+ const storageOf = (raw) => {
14
+ if (raw === "keyring" || raw === "file")
15
+ return raw;
16
+ throw new CliError("validation_error", `--credential-storage takes keyring or file; got ${raw}`);
17
+ };
18
+ const tokensHere = (env, keyring) => new ProfileTokenStore({ app: IDENTITY, env, ...(keyring ? { keyring } : {}) });
19
+ /** The account a profile's saved sign-in reaches; one from `WCHUBSPOT_TOKEN` is no profile's. */
20
+ export const signedInTo = (env, keyring, profile) => {
21
+ const saved = tokensHere(env, keyring).read(profile);
22
+ if (!saved || saved.source === "environment")
23
+ return undefined;
24
+ return decodeSignIn(saved.secret).portalId;
25
+ };
26
+ /**
27
+ * A second profile on the same account would sync the same copy twice and split its permissions. A key names no user,
28
+ * so the account alone decides.
29
+ */
30
+ const refuseDuplicate = (env, keyring, profile, at) => {
31
+ // biome-ignore lint/plugin/no-own-settings: this check reads every profile, and baseContext names one
32
+ const { configuredProfiles } = configuration.resolveSettings({}, { env, needsProfile: false });
33
+ const other = profilesHere(IDENTITY, configuredProfiles, env).find((one) => {
34
+ if (one === profile)
35
+ return false;
36
+ try {
37
+ return signedInTo(env, keyring, one) === at;
38
+ }
39
+ catch {
40
+ return false;
41
+ }
42
+ });
43
+ if (!other)
44
+ return;
45
+ throw new CliError("conflict", `profile ${other} already signs in to HubSpot account ${at}. Use \`${HUBSPOT} ${other}\`, or end it with ` +
46
+ `\`${HUBSPOT} ${other} session end\` first`, { reason: "session.duplicate", profile: other, account: at });
47
+ };
48
+ /**
49
+ * A token proven against its account, and what a profile keeps for it: the token with the account beside it.
50
+ * `setup apply` runs the same check.
51
+ */
52
+ export const checkedToken = async (command, token) => {
53
+ const { env, profile, keyring, run } = contextOf(command);
54
+ const who = await run((events) => accountAnswer(hubFor(command, { token }, events)));
55
+ refuseDuplicate(env, keyring, profile, who.account);
56
+ const { ui_domain: uiDomain, time_zone: timeZone } = who.account_info;
57
+ return { who, signIn: encodeSignIn({ token, portalId: who.account, uiDomain, timeZone }) };
58
+ };
59
+ const startCommand = () => logsInOrOut(annotate(new Command("start"), {
60
+ effects: FETCH,
61
+ lifetime: "interactive",
62
+ mcp: false,
63
+ examples: [
64
+ `${HUBSPOT} work session start`,
65
+ `${HUBSPOT} work session start --json`,
66
+ `${HUBSPOT} work session start --credential-storage file`,
67
+ ],
68
+ }))
69
+ .summary(`sign in to ${SERVICE} with a service key or a private app token`)
70
+ .description("sign this profile in: a service key (Development → Keys → Service keys) or a legacy private app's access " +
71
+ "token is asked hidden or read from stdin, never taken as an argument, checked against the account, and " +
72
+ "only then kept in the keyring with the account's id, or in a private file. The key reads what its scopes " +
73
+ "allow; hubspot changes nothing in this release")
74
+ .option("--credential-storage <storage>", "where the key is kept: keyring, which falls back to a private file by itself, or file", storageOf, "keyring")
75
+ .action(async function (args) {
76
+ const { env, profile, tokens } = contextOf(this);
77
+ refuseCommandName(profile, commandWords(rootOf(this)), HUBSPOT);
78
+ refuseOffline(this, SERVICE);
79
+ // A secret is never an argument: it would land in shell history and in the run record (WC-SECR-5).
80
+ const token = (await readSecret(`${SERVICE} service key or private app token: `, secretInputOf(this))).trim();
81
+ if (!token)
82
+ throw new CliError("validation_error", "no token was given");
83
+ const { who, signIn } = await checkedToken(this, token);
84
+ const storedIn = tokens.write(profile, signIn, args.credentialStorage);
85
+ rememberAccount(IDENTITY, profile, who.account, env);
86
+ answer(this, { profile, state: "saved", kind: "token", stored_in: storedIn, verified: true, ...who });
87
+ });
88
+ const statusCommand = () => annotate(new Command("status"), {
89
+ effects: REMOTE_READ,
90
+ examples: [`${HUBSPOT} work session status`, `${HUBSPOT} work session status --check --json`],
91
+ })
92
+ .summary("show where this profile's key comes from; --check names the account it reads")
93
+ .description("show which account this profile signs in to and where its key comes from: " +
94
+ `${IDENTITY.envPrefix}_TOKEN, the keyring or a file; never the key`)
95
+ .option("--check", `ask ${SERVICE} whether the key still works and which account it reads`)
96
+ .action(async function (args) {
97
+ const { env, profile, tokens, run } = contextOf(this);
98
+ const saved = tokens.read(profile);
99
+ // WCHUBSPOT_TOKEN alone is enough here: --check is how its owner finds the id WCHUBSPOT_ACCOUNT takes.
100
+ const fromToken = saved?.source === "environment";
101
+ const named = fromToken ? environmentAccount(env) : storedSignIn(this)?.portalId;
102
+ const status = {
103
+ profile,
104
+ state: saved ? "saved" : "missing",
105
+ kind: saved ? "token" : null,
106
+ token_from: saved?.source ?? null,
107
+ account: named ?? null,
108
+ };
109
+ if (!args.check || !saved)
110
+ return answer(this, { ...status, verified: false });
111
+ if (!fromToken)
112
+ return answer(this, { ...status, verified: true, ...(await withHub(this, accountAnswer)) });
113
+ refuseOffline(this, SERVICE);
114
+ const who = await run((events) => accountAnswer(hubFor(this, { token: saved.secret, portalId: named }, events)));
115
+ if (named)
116
+ refuseAccountMismatch(named, who.account);
117
+ answer(this, { ...status, verified: true, ...who });
118
+ });
119
+ const endCommand = () => logsInOrOut(annotate(new Command("end"), {
120
+ effects: LOCAL_WRITE,
121
+ mcp: false,
122
+ examples: [`${HUBSPOT} work session end`],
123
+ }))
124
+ .summary("forget this profile's key on this computer")
125
+ .description(`forget this profile's key and account id on this computer; the key itself stays valid in ${SERVICE}: delete ` +
126
+ "or rotate it where it was made")
127
+ .action(function () {
128
+ refuseUnderReadOnly(this, "session end");
129
+ const { profile, tokens } = contextOf(this);
130
+ answer(this, { profile, ended: tokens.remove(profile) });
131
+ });
132
+ const listCommand = () => profileFree(annotate(new Command("list"), {
133
+ effects: LOCAL_READ,
134
+ examples: [`${HUBSPOT} session list`, `${HUBSPOT} session list --json`],
135
+ }))
136
+ .summary("list the profiles here and whether each is signed in")
137
+ .description("list the profiles on this computer, whether each has a key and for which account; picks none")
138
+ .action(function () {
139
+ const environment = environmentOf(this);
140
+ const env = environment.env ?? process.env;
141
+ // biome-ignore lint/plugin/no-own-settings: baseContext needs a profile, and this local read names none
142
+ const { configuredProfiles } = configuration.resolveSettings({}, { env, needsProfile: false });
143
+ const tokens = tokensHere(env, environment.keyring);
144
+ const items = profilesHere(IDENTITY, configuredProfiles, env).map((profile) => {
145
+ try {
146
+ const saved = tokens.read(profile);
147
+ const account = saved && saved.source !== "environment" ? decodeSignIn(saved.secret).portalId : null;
148
+ return { profile, signed_in: saved !== undefined, token_from: saved?.source ?? null, account };
149
+ }
150
+ catch (error) {
151
+ if (!(error instanceof CliError))
152
+ throw error;
153
+ return { profile, signed_in: null, token_from: null, account: null, error: error.message };
154
+ }
155
+ });
156
+ renderAnswer(this, outputFor(this), listOf("session list", { items, limit: Math.max(1, items.length), has_more: false }));
157
+ });
158
+ export const sessionCommand = () => annotate(new Command("session"), { effects: LOCAL_READ })
159
+ .description(`keep this profile's ${SERVICE} key and account id in the OS keyring`)
160
+ .addCommand(startCommand())
161
+ .addCommand(statusCommand())
162
+ .addCommand(endCommand())
163
+ .addCommand(listCommand());
164
+ //# sourceMappingURL=session.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"session.js","sourceRoot":"","sources":["../../src/commands/session.ts"],"names":[],"mappings":"AAAA,OAAO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C,KAAK,YAAY,QAAQ,CAAC;gBAAE,MAAM,KAAK,CAAA;YAC7C,OAAO,EAAE,OAAO,EAAE,SAAS,EAAE,IAAI,EAAE,UAAU,EAAE,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE,KAAK,EAAE,KAAK,CAAC,OAAO,EAAE,CAAA;QAC5F,CAAC;IACH,CAAC,CAAC,CAAA;IACF,YAAY,CACV,IAAI,EACJ,SAAS,CAAC,IAAI,CAAC,EACf,MAAM,CAAC,cAAc,EAAE,EAAE,KAAK,EAAE,KAAK,EAAE,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,KAAK,CAAC,MAAM,CAAC,EAAE,QAAQ,EAAE,KAAK,EAAE,CAAC,CACrF,CAAA;AACH,CAAC,CAAC,CAAA;AAEN,MAAM,CAAC,MAAM,cAAc,GAAG,GAAY,EAAE,CAC1C,QAAQ,CAAC,IAAI,OAAO,CAAC,SAAS,CAAC,EAAE,EAAE,OAAO,EAAE,UAAU,EAAE,CAAC;KACtD,WAAW,CAAC,uBAAuB,OAAO,uCAAuC,CAAC;KAClF,UAAU,CAAC,YAAY,EAAE,CAAC;KAC1B,UAAU,CAAC,aAAa,EAAE,CAAC;KAC3B,UAAU,CAAC,UAAU,EAAE,CAAC;KACxB,UAAU,CAAC,WAAW,EAAE,CAAC,CAAA"}
@@ -0,0 +1,60 @@
1
+ import type { CrmKind } from "@wirecat/cli-core";
2
+ import { type Configuration } from "@wirecat/cli-core/cli";
3
+ import { type CrmVerb } from "@wirecat/cli-core/crm";
4
+ /**
5
+ * Every operation of HubSpot's CRM specs: reads, writes and deletes. A write checks `api.<command>`, its group's
6
+ * `.write` and the CRM command it does the same as; a delete its group's `.delete`.
7
+ */
8
+ export declare const API: {
9
+ manifest: {
10
+ servers: readonly import("@wirecat/cli-base/codegen").ApiServer[];
11
+ securitySchemes: Readonly<Record<string, import("@wirecat/cli-base/codegen").SecurityScheme>>;
12
+ security: readonly import("@wirecat/cli-base/codegen").SecurityRequirement[];
13
+ operations: {
14
+ id: string;
15
+ command: string;
16
+ binding: import("@wirecat/cli-base/codegen").Binding;
17
+ effect: import("@wirecat/cli-base/codegen").Effect;
18
+ summary?: string;
19
+ description?: string;
20
+ tags: readonly string[];
21
+ deprecated?: boolean;
22
+ parameters: readonly {
23
+ name: string;
24
+ in: "path" | "query" | "header" | "body";
25
+ sensitive?: boolean;
26
+ required: boolean;
27
+ description?: string;
28
+ schema: import("@wirecat/cli-base/codegen").SchemaNode;
29
+ }[];
30
+ request?: {
31
+ required: boolean;
32
+ confidence: import("@wirecat/cli-base/codegen").Confidence;
33
+ schema?: string;
34
+ contentType?: string;
35
+ };
36
+ response?: {
37
+ confidence: import("@wirecat/cli-base/codegen").Confidence;
38
+ schema?: string;
39
+ sensitive?: boolean;
40
+ };
41
+ pagination?: import("@wirecat/cli-base/codegen").Pagination;
42
+ security?: readonly Readonly<Record<string, readonly string[]>>[] | undefined;
43
+ permissions: {
44
+ key: string;
45
+ }[];
46
+ }[];
47
+ };
48
+ service: string;
49
+ bodyPermissions: {
50
+ [k: string]: {
51
+ key: string;
52
+ when: string;
53
+ applies: (body: unknown) => boolean;
54
+ }[];
55
+ };
56
+ };
57
+ export declare const crmApiKeys: (kind: CrmKind, verb: CrmVerb) => string[];
58
+ export declare const permissions: import("@wirecat/cli-core/cli").CommandPermissions;
59
+ export declare const configuration: Configuration;
60
+ //# sourceMappingURL=config.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAA;AAChD,OAAO,EAEL,KAAK,aAAa,EAKnB,MAAM,uBAAuB,CAAA;AAC9B,OAAO,EAIL,KAAK,OAAO,EAEb,MAAM,uBAAuB,CAAA;AA6H9B;;;GAGG;AACH,eAAO,MAAM,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;4BAtCM,OAAO;;;CAyD5B,CAAA;AAID,eAAO,MAAM,UAAU,SAAU,OAAO,QAAQ,OAAO,KAAG,MAAM,EAK/D,CAAA;AAiBD,eAAO,MAAM,WAAW,oDAStB,CAAA;AAEF,eAAO,MAAM,aAAa,EAAE,aAAsD,CAAA"}