@wirecat/hubspot-cli 0.0.0-stage → 0.1.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 (269) hide show
  1. package/CHANGELOG.md +29 -0
  2. package/LICENSE +204 -0
  3. package/README.md +256 -2
  4. package/contracts/wirecat.json +1965 -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-422MCA7S.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-2TWQIWWG.js +1328 -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-43EKCUBJ.js +72 -0
  21. package/dist/bundle/chunk-4W6BMH45.js +731 -0
  22. package/dist/bundle/chunk-5A6ZYNAQ.js +2003 -0
  23. package/dist/bundle/chunk-5D4AEUVA.js +24783 -0
  24. package/dist/bundle/chunk-5GBUCHRU.js +274 -0
  25. package/dist/bundle/chunk-5K7QLJMM.js +4072 -0
  26. package/dist/bundle/chunk-65TWQ7BV.js +54 -0
  27. package/dist/bundle/chunk-7ELMWE3P.js +12066 -0
  28. package/dist/bundle/chunk-ADLS6FVG.js +24600 -0
  29. package/dist/bundle/chunk-B3MANLNK.js +602 -0
  30. package/dist/bundle/chunk-BKXDHU3G.js +1395 -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-H3TNVEQX.js +782 -0
  51. package/dist/bundle/chunk-HC5ZWE5X.js +193 -0
  52. package/dist/bundle/chunk-HCAZV5NP.js +95 -0
  53. package/dist/bundle/chunk-HTAN663T.js +4045 -0
  54. package/dist/bundle/chunk-HZRQLAHO.js +16 -0
  55. package/dist/bundle/chunk-IMJQRPLN.js +92 -0
  56. package/dist/bundle/chunk-JLDBMEKZ.js +106 -0
  57. package/dist/bundle/chunk-JRCPCVPI.js +9393 -0
  58. package/dist/bundle/chunk-LNV33FDC.js +786 -0
  59. package/dist/bundle/chunk-LOBVOGOE.js +66 -0
  60. package/dist/bundle/chunk-MVA5HVKL.js +1392 -0
  61. package/dist/bundle/chunk-N2XADGL4.js +76 -0
  62. package/dist/bundle/chunk-NHHJHXMQ.js +58 -0
  63. package/dist/bundle/chunk-NUU4WZVL.js +52 -0
  64. package/dist/bundle/chunk-NWHEHV3K.js +133 -0
  65. package/dist/bundle/chunk-NXERIDPJ.js +319 -0
  66. package/dist/bundle/chunk-O3DYRCIT.js +23 -0
  67. package/dist/bundle/chunk-O55RWNSH.js +161 -0
  68. package/dist/bundle/chunk-P5BHKKBI.js +206 -0
  69. package/dist/bundle/chunk-PPHBRESD.js +82 -0
  70. package/dist/bundle/chunk-PVKF24ZW.js +364 -0
  71. package/dist/bundle/chunk-QGFX5MXL.js +460 -0
  72. package/dist/bundle/chunk-QJW35N5V.js +761 -0
  73. package/dist/bundle/chunk-QU25DA5N.js +360 -0
  74. package/dist/bundle/chunk-RMIYKDUL.js +1068 -0
  75. package/dist/bundle/chunk-RR5MX5TM.js +142 -0
  76. package/dist/bundle/chunk-SAKK2YRU.js +218 -0
  77. package/dist/bundle/chunk-SDQGB4KB.js +185 -0
  78. package/dist/bundle/chunk-TBJYLC5K.js +2788 -0
  79. package/dist/bundle/chunk-TI46WQXQ.js +1197 -0
  80. package/dist/bundle/chunk-TKVL2C3B.js +170 -0
  81. package/dist/bundle/chunk-TOSCB4SO.js +1227 -0
  82. package/dist/bundle/chunk-TP7GDWVF.js +6848 -0
  83. package/dist/bundle/chunk-UUMUL4L3.js +72 -0
  84. package/dist/bundle/chunk-VIEYMDBR.js +41 -0
  85. package/dist/bundle/chunk-W53EJOFQ.js +63 -0
  86. package/dist/bundle/chunk-W7HM2VGO.js +24 -0
  87. package/dist/bundle/chunk-WE4UFASG.js +88 -0
  88. package/dist/bundle/chunk-WQBX7XYP.js +26174 -0
  89. package/dist/bundle/chunk-X2M6NIQG.js +18 -0
  90. package/dist/bundle/chunk-X7XUX7A4.js +1846 -0
  91. package/dist/bundle/chunk-XRREFEIW.js +372 -0
  92. package/dist/bundle/chunk-Y5E2WNWB.js +35 -0
  93. package/dist/bundle/chunk-ZBDSHFG4.js +40933 -0
  94. package/dist/bundle/chunk-ZVVMGPBJ.js +50 -0
  95. package/dist/bundle/command-contract-C6CBFXZF.js +40 -0
  96. package/dist/bundle/command-server-entry-DJKVVZCQ.js +169 -0
  97. package/dist/bundle/decode-FC65Y4IV.js +297 -0
  98. package/dist/bundle/definitions-MVPICAWV.js +2991 -0
  99. package/dist/bundle/dispatch-KOISQ5QJ.js +411 -0
  100. package/dist/bundle/dist-MYZZKZJ7.js +7577 -0
  101. package/dist/bundle/echarts-FVTUDXDU.js +42501 -0
  102. package/dist/bundle/embed-VNBZFPYH.js +38 -0
  103. package/dist/bundle/embedder-6U4NOFRO.js +111 -0
  104. package/dist/bundle/failure-FZ6VYKEQ.js +25 -0
  105. package/dist/bundle/first-run-RPIJZEDT.js +29 -0
  106. package/dist/bundle/first-screen-RTVMGHAE.js +40 -0
  107. package/dist/bundle/hubspot.js +198 -0
  108. package/dist/bundle/instructions-HET7BCYK.js +11 -0
  109. package/dist/bundle/mcp-RGNRW77S.js +167 -0
  110. package/dist/bundle/meeting-combined-L5AGBPYX.js +25 -0
  111. package/dist/bundle/meeting-model-NTB4RK3F.js +25 -0
  112. package/dist/bundle/meeting-semantic-JY3OGCBS.js +22 -0
  113. package/dist/bundle/node-CXZIFHZC.js +176 -0
  114. package/dist/bundle/node-P4E63KXA.js +2340 -0
  115. package/dist/bundle/node-TLZSIHIJ.js +21 -0
  116. package/dist/bundle/node-sqlite-P3O7XN7Q.js +74 -0
  117. package/dist/bundle/oauth-HNCY4B2S.js +20 -0
  118. package/dist/bundle/open-F4P6YV54.js +23 -0
  119. package/dist/bundle/openai-4AICLIK3.js +238 -0
  120. package/dist/bundle/process-5RUXWGYS.js +91 -0
  121. package/dist/bundle/program-POG5GHUQ.js +9241 -0
  122. package/dist/bundle/prompt-NFMDVBZ4.js +17 -0
  123. package/dist/bundle/recognize-DKN3RY4V.js +26 -0
  124. package/dist/bundle/remote-6QHAGQWY.js +31 -0
  125. package/dist/bundle/rerank-M4KHEHUZ.js +52 -0
  126. package/dist/bundle/schemas-JRL3DLMP.js +952 -0
  127. package/dist/bundle/serve-DNU43ND6.js +199 -0
  128. package/dist/bundle/server-C3ZHA7AZ.js +77 -0
  129. package/dist/bundle/server-XJSNF3K5.js +207 -0
  130. package/dist/bundle/source-A3SBLHC4.js +934 -0
  131. package/dist/bundle/sqlite-runtime-EMQAC63N.js +20 -0
  132. package/dist/bundle/state-T45CX7VY.js +36 -0
  133. package/dist/bundle/store-6LCEVBAZ.js +176 -0
  134. package/dist/bundle/store-6TZ2FCVA.js +295 -0
  135. package/dist/bundle/store-CCDNUB6A.js +32 -0
  136. package/dist/bundle/store-maintenance-command-BRCG6MNA.js +68 -0
  137. package/dist/commands/account.d.ts +3 -0
  138. package/dist/commands/account.d.ts.map +1 -0
  139. package/dist/commands/account.js +87 -0
  140. package/dist/commands/account.js.map +1 -0
  141. package/dist/commands/api.d.ts +9 -0
  142. package/dist/commands/api.d.ts.map +1 -0
  143. package/dist/commands/api.js +65 -0
  144. package/dist/commands/api.js.map +1 -0
  145. package/dist/commands/comments.d.ts +3 -0
  146. package/dist/commands/comments.d.ts.map +1 -0
  147. package/dist/commands/comments.js +114 -0
  148. package/dist/commands/comments.js.map +1 -0
  149. package/dist/commands/crm-shared.d.ts +8 -0
  150. package/dist/commands/crm-shared.d.ts.map +1 -0
  151. package/dist/commands/crm-shared.js +93 -0
  152. package/dist/commands/crm-shared.js.map +1 -0
  153. package/dist/commands/schedule.d.ts +3 -0
  154. package/dist/commands/schedule.d.ts.map +1 -0
  155. package/dist/commands/schedule.js +9 -0
  156. package/dist/commands/schedule.js.map +1 -0
  157. package/dist/commands/session.d.ts +14 -0
  158. package/dist/commands/session.d.ts.map +1 -0
  159. package/dist/commands/session.js +164 -0
  160. package/dist/commands/session.js.map +1 -0
  161. package/dist/config.d.ts +22 -0
  162. package/dist/config.d.ts.map +1 -0
  163. package/dist/config.js +28 -0
  164. package/dist/config.js.map +1 -0
  165. package/dist/context.d.ts +88 -0
  166. package/dist/context.d.ts.map +1 -0
  167. package/dist/context.js +137 -0
  168. package/dist/context.js.map +1 -0
  169. package/dist/crm/activities.d.ts +24 -0
  170. package/dist/crm/activities.d.ts.map +1 -0
  171. package/dist/crm/activities.js +214 -0
  172. package/dist/crm/activities.js.map +1 -0
  173. package/dist/crm/associations.d.ts +20 -0
  174. package/dist/crm/associations.d.ts.map +1 -0
  175. package/dist/crm/associations.js +47 -0
  176. package/dist/crm/associations.js.map +1 -0
  177. package/dist/crm/records.d.ts +63 -0
  178. package/dist/crm/records.d.ts.map +1 -0
  179. package/dist/crm/records.js +333 -0
  180. package/dist/crm/records.js.map +1 -0
  181. package/dist/crm/search.d.ts +57 -0
  182. package/dist/crm/search.d.ts.map +1 -0
  183. package/dist/crm/search.js +47 -0
  184. package/dist/crm/search.js.map +1 -0
  185. package/dist/crm/source.d.ts +32 -0
  186. package/dist/crm/source.d.ts.map +1 -0
  187. package/dist/crm/source.js +369 -0
  188. package/dist/crm/source.js.map +1 -0
  189. package/dist/generated/definitions.d.ts +3 -0
  190. package/dist/generated/definitions.d.ts.map +1 -0
  191. package/dist/generated/definitions.js +2987 -0
  192. package/dist/generated/definitions.js.map +1 -0
  193. package/dist/generated/manifest.d.ts +6 -0
  194. package/dist/generated/manifest.d.ts.map +1 -0
  195. package/dist/generated/manifest.js +6499 -0
  196. package/dist/generated/manifest.js.map +1 -0
  197. package/dist/generated/schemas.d.ts +205 -0
  198. package/dist/generated/schemas.d.ts.map +1 -0
  199. package/dist/generated/schemas.js +810 -0
  200. package/dist/generated/schemas.js.map +1 -0
  201. package/dist/generated/types.d.ts +1114 -0
  202. package/dist/generated/types.d.ts.map +1 -0
  203. package/dist/generated/types.js +5 -0
  204. package/dist/generated/types.js.map +1 -0
  205. package/dist/hubspot/account.d.ts +12 -0
  206. package/dist/hubspot/account.d.ts.map +1 -0
  207. package/dist/hubspot/account.js +23 -0
  208. package/dist/hubspot/account.js.map +1 -0
  209. package/dist/hubspot/transport.d.ts +76 -0
  210. package/dist/hubspot/transport.d.ts.map +1 -0
  211. package/dist/hubspot/transport.js +346 -0
  212. package/dist/hubspot/transport.js.map +1 -0
  213. package/dist/identity.d.ts +7 -0
  214. package/dist/identity.d.ts.map +1 -0
  215. package/dist/identity.js +32 -0
  216. package/dist/identity.js.map +1 -0
  217. package/dist/index.d.ts +3 -0
  218. package/dist/index.d.ts.map +1 -0
  219. package/dist/index.js +3 -0
  220. package/dist/index.js.map +1 -0
  221. package/dist/program.d.ts +6 -0
  222. package/dist/program.d.ts.map +1 -0
  223. package/dist/program.js +77 -0
  224. package/dist/program.js.map +1 -0
  225. package/dist/reasons.d.ts +10 -0
  226. package/dist/reasons.d.ts.map +1 -0
  227. package/dist/reasons.js +33 -0
  228. package/dist/reasons.js.map +1 -0
  229. package/dist/sample/comments.d.ts +61 -0
  230. package/dist/sample/comments.d.ts.map +1 -0
  231. package/dist/sample/comments.js +39 -0
  232. package/dist/sample/comments.js.map +1 -0
  233. package/dist/sample/records.d.ts +16 -0
  234. package/dist/sample/records.d.ts.map +1 -0
  235. package/dist/sample/records.js +22 -0
  236. package/dist/sample/records.js.map +1 -0
  237. package/dist/sample/transport.d.ts +42 -0
  238. package/dist/sample/transport.d.ts.map +1 -0
  239. package/dist/sample/transport.js +153 -0
  240. package/dist/sample/transport.js.map +1 -0
  241. package/dist/setup/flow.d.ts +2 -0
  242. package/dist/setup/flow.d.ts.map +1 -0
  243. package/dist/setup/flow.js +97 -0
  244. package/dist/setup/flow.js.map +1 -0
  245. package/dist/setup/texts.en.json +19 -0
  246. package/dist/setup/texts.es.json +19 -0
  247. package/dist/setup/texts.ru.json +19 -0
  248. package/dist/store.d.ts +16 -0
  249. package/dist/store.d.ts.map +1 -0
  250. package/dist/store.js +34 -0
  251. package/dist/store.js.map +1 -0
  252. package/dist/version.d.ts +2 -0
  253. package/dist/version.d.ts.map +1 -0
  254. package/dist/version.js +2 -0
  255. package/dist/version.js.map +1 -0
  256. package/dist/wcat.d.ts +3 -0
  257. package/dist/wcat.d.ts.map +1 -0
  258. package/dist/wcat.js +4 -0
  259. package/dist/wcat.js.map +1 -0
  260. package/dist/whoami.d.ts +19 -0
  261. package/dist/whoami.d.ts.map +1 -0
  262. package/dist/whoami.js +15 -0
  263. package/dist/whoami.js.map +1 -0
  264. package/package.json +98 -4
  265. package/skills/hubspot-cli/SKILL.md +97 -0
  266. package/skills/hubspot-cli/references/api/api-basic.md +462 -0
  267. package/skills/hubspot-cli/references/api/api-batch.md +149 -0
  268. package/skills/hubspot-cli/references/api/api-search.md +147 -0
  269. package/skills/hubspot-cli/references/api.md +15 -0
@@ -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,EAAE,QAAQ,EAAqB,MAAM,mBAAmB,CAAA;AAC/D,OAAO,EAAE,QAAQ,EAAE,MAAM,4BAA4B,CAAA;AACrD,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAA;AAC9C,OAAO,EACL,YAAY,EACZ,aAAa,EACb,KAAK,EACL,MAAM,EACN,UAAU,EACV,WAAW,EACX,MAAM,EACN,WAAW,EACX,SAAS,EACT,iBAAiB,EACjB,WAAW,EACX,YAAY,EACZ,WAAW,EACX,iBAAiB,EACjB,aAAa,EACb,mBAAmB,EACnB,eAAe,EACf,YAAY,EACZ,MAAM,EACN,aAAa,GAEd,MAAM,uBAAuB,CAAA;AAC9B,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AACnC,OAAO,EAAE,aAAa,EAAE,MAAM,cAAc,CAAA;AAC5C,OAAO,EACL,SAAS,EACT,YAAY,EACZ,YAAY,EACZ,kBAAkB,EAElB,MAAM,EACN,qBAAqB,EACrB,YAAY,EACZ,OAAO,GACR,MAAM,eAAe,CAAA;AACtB,OAAO,EAAE,OAAO,EAAE,MAAM,yBAAyB,CAAA;AACjD,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAA;AACzC,OAAO,EAAE,aAAa,EAAE,MAAM,cAAc,CAAA;AAE5C,MAAM,OAAO,GAAG,QAAQ,CAAC,OAAO,CAAA;AAEhC,MAAM,MAAM,GAAG,CAAC,OAAgB,EAAE,IAAa,EAAE,EAAE,CAAC,YAAY,CAAC,OAAO,EAAE,SAAS,CAAC,OAAO,CAAC,EAAE,MAAM,CAA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,MAAM,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,IAAI,CAAA;YACpG,OAAO,EAAE,OAAO,EAAE,SAAS,EAAE,KAAK,KAAK,SAAS,EAAE,UAAU,EAAE,KAAK,EAAE,MAAM,IAAI,IAAI,EAAE,OAAO,EAAE,CAAA;QAChG,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,IAAI,CAAC,CAAC,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,22 @@
1
+ import { type Configuration } from "@wirecat/cli-core/cli";
2
+ /**
3
+ * This release only reads (NEED-1): the api group offers only the operations whose effect is `read`. An operation that
4
+ * answers with a credential is left out too: the CLI signs in through `session`.
5
+ */
6
+ export declare const API: {
7
+ manifest: {
8
+ servers: readonly import("@wirecat/cli-base/codegen").ApiServer[];
9
+ securitySchemes: Readonly<Record<string, import("@wirecat/cli-base/codegen").SecurityScheme>>;
10
+ security: readonly import("@wirecat/cli-base/codegen").SecurityRequirement[];
11
+ operations: import("@wirecat/cli-base/codegen").ManifestOperation[];
12
+ };
13
+ service: string;
14
+ };
15
+ /** `api show` names why a write is missing, by its command or its spec id. */
16
+ export declare const API_EXCLUDED: {
17
+ id: string;
18
+ reason: string;
19
+ }[];
20
+ export declare const permissions: import("@wirecat/cli-core/cli").CommandPermissions;
21
+ export declare const configuration: Configuration;
22
+ //# sourceMappingURL=config.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,aAAa,EAKnB,MAAM,uBAAuB,CAAA;AAK9B;;;GAGG;AACH,eAAO,MAAM,GAAG;;;;;;;;CAQf,CAAA;AAID,8EAA8E;AAC9E,eAAO,MAAM,YAAY;;;GAKrB,CAAA;AAMJ,eAAO,MAAM,WAAW,oDAA+D,CAAA;AAEvF,eAAO,MAAM,aAAa,EAAE,aAAsD,CAAA"}
package/dist/config.js ADDED
@@ -0,0 +1,28 @@
1
+ import { commandPathKey, commandPermissions, serviceApiPermissions, settingsFor, } from "@wirecat/cli-core/cli";
2
+ import * as manifest from "./generated/manifest.js";
3
+ import { SERVICE } from "./hubspot/transport.js";
4
+ import { IDENTITY } from "./identity.js";
5
+ /**
6
+ * This release only reads (NEED-1): the api group offers only the operations whose effect is `read`. An operation that
7
+ * answers with a credential is left out too: the CLI signs in through `session`.
8
+ */
9
+ export const API = {
10
+ manifest: {
11
+ ...manifest,
12
+ operations: manifest.operations.filter((operation) => operation.effect === "read" && !operation.response?.sensitive),
13
+ },
14
+ service: SERVICE,
15
+ };
16
+ const LATER = "it changes the HubSpot account, and this release only reads; writes come in a later release";
17
+ /** `api show` names why a write is missing, by its command or its spec id. */
18
+ export const API_EXCLUDED = manifest.operations
19
+ .filter((operation) => operation.effect !== "read")
20
+ .flatMap((operation) => [
21
+ { id: operation.command, reason: LATER },
22
+ { id: operation.id, reason: LATER },
23
+ ]);
24
+ /** `api list` and `api show` never reach the account. */
25
+ const keyOf = (path) => path[0] === "api" && ["list", "show"].includes(path[1] ?? "") ? null : commandPathKey(path);
26
+ export const permissions = commandPermissions({ keyOf, ...serviceApiPermissions(API) });
27
+ export const configuration = settingsFor(IDENTITY, { permissions });
28
+ //# sourceMappingURL=config.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"config.js","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,cAAc,EACd,kBAAkB,EAClB,qBAAqB,EACrB,WAAW,GACZ,MAAM,uBAAuB,CAAA;AAC9B,OAAO,KAAK,QAAQ,MAAM,yBAAyB,CAAA;AACnD,OAAO,EAAE,OAAO,EAAE,MAAM,wBAAwB,CAAA;AAChD,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAA;AAExC;;;GAGG;AACH,MAAM,CAAC,MAAM,GAAG,GAAG;IACjB,QAAQ,EAAE;QACR,GAAG,QAAQ;QACX,UAAU,EAAE,QAAQ,CAAC,UAAU,CAAC,MAAM,CACpC,CAAC,SAAS,EAAE,EAAE,CAAC,SAAS,CAAC,MAAM,KAAK,MAAM,IAAI,CAAC,SAAS,CAAC,QAAQ,EAAE,SAAS,CAC7E;KACF;IACD,OAAO,EAAE,OAAO;CACjB,CAAA;AAED,MAAM,KAAK,GAAG,6FAA6F,CAAA;AAE3G,8EAA8E;AAC9E,MAAM,CAAC,MAAM,YAAY,GAAG,QAAQ,CAAC,UAAU;KAC5C,MAAM,CAAC,CAAC,SAAS,EAAE,EAAE,CAAC,SAAS,CAAC,MAAM,KAAK,MAAM,CAAC;KAClD,OAAO,CAAC,CAAC,SAAS,EAAE,EAAE,CAAC;IACtB,EAAE,EAAE,EAAE,SAAS,CAAC,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE;IACxC,EAAE,EAAE,EAAE,SAAS,CAAC,EAAE,EAAE,MAAM,EAAE,KAAK,EAAE;CACpC,CAAC,CAAA;AAEJ,yDAAyD;AACzD,MAAM,KAAK,GAAG,CAAC,IAAuB,EAAE,EAAE,CACxC,IAAI,CAAC,CAAC,CAAC,KAAK,KAAK,IAAI,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,cAAc,CAAC,IAAI,CAAC,CAAA;AAE7F,MAAM,CAAC,MAAM,WAAW,GAAG,kBAAkB,CAAC,EAAE,KAAK,EAAE,GAAG,qBAAqB,CAAC,GAAG,CAAC,EAAE,CAAC,CAAA;AAEvF,MAAM,CAAC,MAAM,aAAa,GAAkB,WAAW,CAAC,QAAQ,EAAE,EAAE,WAAW,EAAE,CAAC,CAAA"}
@@ -0,0 +1,88 @@
1
+ import { type SleepLike } from "@wirecat/cli-base";
2
+ import { type BaseEnvironment, type EventSink, type GlobalFlags, ProfileTokenStore } from "@wirecat/cli-core/cli";
3
+ import { Pacer } from "@wirecat/cli-core/sends";
4
+ import type { Command } from "commander";
5
+ import { type HubSpotTransport, PACE } from "./hubspot/transport.js";
6
+ export { PACE };
7
+ /** What a test hands `run()` in place of the account and real waiting (WC-ARCH-10). */
8
+ export interface HubspotEnvironment extends BaseEnvironment {
9
+ fetch?: typeof fetch;
10
+ sleep?: SleepLike;
11
+ /** The clock the pace waits on; a test moves it with its `sleep`, so no wait is real. */
12
+ now?: () => number;
13
+ }
14
+ /**
15
+ * Settings, keyring and the run come from cli-core's `baseContext` and nowhere else: a command that resolves settings
16
+ * on its own skips `--timeout`, the run record and the profile's permissions (WC-LIFE-5, WC-LIFE-15).
17
+ */
18
+ export declare const contextOf: (command: Command) => {
19
+ settings: import("@wirecat/cli-core/cli").Settings;
20
+ renderer: import("@wirecat/cli-base").Renderer;
21
+ format: import("@wirecat/cli-base").RenderFormat;
22
+ color: boolean;
23
+ streams: import("@wirecat/cli-base").Streams;
24
+ compact?: boolean;
25
+ full?: boolean;
26
+ env: NodeJS.ProcessEnv;
27
+ keyring?: import("@wirecat/cli-base").KeyringStore;
28
+ run: <T>(body: (events: EventSink) => Promise<T>, options?: {
29
+ unbounded?: boolean;
30
+ name?: string;
31
+ }) => Promise<T>;
32
+ track: (closeable: import("@wirecat/cli-core/cli").Closeable) => void;
33
+ environment: HubspotEnvironment;
34
+ flags: GlobalFlags;
35
+ profile: string;
36
+ tokens: ProfileTokenStore;
37
+ };
38
+ /**
39
+ * What a profile keeps: the token and the account `session start` proved it against. The account is the CRM's key in
40
+ * the shared store, so a read offline knows it without asking HubSpot.
41
+ */
42
+ export interface SignIn {
43
+ token: string;
44
+ portalId: string;
45
+ uiDomain: string | null;
46
+ /** The account's IANA time zone: HubSpot's daily allowance comes back at its midnight. */
47
+ timeZone?: string;
48
+ }
49
+ export declare const encodeSignIn: (signIn: SignIn) => string;
50
+ export declare const decodeSignIn: (secret: string) => SignIn;
51
+ export declare const ACCOUNT_VARIABLE: string;
52
+ /** The account `WCHUBSPOT_ACCOUNT` names, checked for its shape only; `undefined` when it is not set. */
53
+ export declare const environmentAccount: (env: NodeJS.ProcessEnv) => string | undefined;
54
+ /**
55
+ * `WCHUBSPOT_TOKEN` first, as for every token CLI, with `WCHUBSPOT_ACCOUNT` naming its account (the portal id), as
56
+ * amo's token needs `AMO_HOST`; then the saved sign-in. Read with no network: whether the two belong together is
57
+ * `refuseAccountMismatch`'s question. A token from the environment has no time zone, so its daily limit names the
58
+ * earliest UTC time it can be back.
59
+ */
60
+ export declare const storedSignIn: (command: Command) => SignIn | undefined;
61
+ /** Whether this run's key comes from `WCHUBSPOT_TOKEN`, whose account nobody has checked yet. */
62
+ export declare const fromEnvironment: (command: Command) => boolean;
63
+ /**
64
+ * A token's own account against the one `WCHUBSPOT_ACCOUNT` names. A wrong id would file this account's CRM under
65
+ * another's in the shared store, so a mismatch is refused before anything is written. Names both ids, never the token.
66
+ */
67
+ export declare const refuseAccountMismatch: (named: string, actual: string) => void;
68
+ /** The sign-in a request uses, or cli-core's `session.missing` refusal that names the command to sign in. */
69
+ export declare const signInOf: (command: Command) => SignIn;
70
+ /** The bare token, read before any request; the api group sends it as `Authorization: Bearer`. */
71
+ export declare const tokenOf: (command: Command) => string;
72
+ /**
73
+ * HubSpot counts its limits per account, so every process on one account waits in one queue, whichever profile or
74
+ * `WCHUBSPOT_TOKEN` it reads with. Only a first sign-in, whose account is not known yet, paces by the profile.
75
+ */
76
+ export declare const pacerFor: (command: Command, portalId: string | undefined) => Pacer;
77
+ /** The transport for one run, paced with the api group by the account. */
78
+ export declare const hubFor: (command: Command, { token, portalId, timeZone }: {
79
+ token: string;
80
+ portalId?: string;
81
+ timeZone?: string | undefined;
82
+ }, events?: EventSink) => HubSpotTransport;
83
+ /**
84
+ * Every remote call goes through here: inside cli-core's run, so `--timeout` bounds it, a failure or `--record` keeps
85
+ * a run named after the command, and the transport's requests land in that run (WC-LIFE-5, WC-LIFE-15).
86
+ */
87
+ export declare const withHub: <T>(command: Command, body: (hub: HubSpotTransport) => Promise<T>) => Promise<T>;
88
+ //# sourceMappingURL=context.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"context.d.ts","sourceRoot":"","sources":["../src/context.ts"],"names":[],"mappings":"AAAA,OAAO,EAAY,KAAK,SAAS,EAAE,MAAM,mBAAmB,CAAA;AAC5D,OAAO,EACL,KAAK,eAAe,EAEpB,KAAK,SAAS,EAEd,KAAK,WAAW,EAChB,iBAAiB,EAElB,MAAM,uBAAuB,CAAA;AAC9B,OAAO,EAAE,KAAK,EAAe,MAAM,yBAAyB,CAAA;AAC5D,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AAExC,OAAO,EAAE,KAAK,gBAAgB,EAAoB,IAAI,EAAW,MAAM,wBAAwB,CAAA;AA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,MAAM,MAAM,YACR,OAAO,iCACe;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,EAAE,MAAM,GAAG,SAAS,CAAA;CAAE,WACzF,SAAS,KACjB,gBAYF,CAAA;AAED;;;GAGG;AACH,eAAO,MAAM,OAAO,GAAI,CAAC,WAAW,OAAO,QAAQ,CAAC,GAAG,EAAE,gBAAgB,KAAK,OAAO,CAAC,CAAC,CAAC,KAAG,OAAO,CAAC,CAAC,CAGnG,CAAA"}
@@ -0,0 +1,137 @@
1
+ import { CliError } from "@wirecat/cli-base";
2
+ import { baseContext, environmentOf, ProfileTokenStore, refuseOffline, } from "@wirecat/cli-core/cli";
3
+ import { Pacer, pacePathFor } from "@wirecat/cli-core/sends";
4
+ import { configuration } from "./config.js";
5
+ import { hubspotTransport, PACE, SERVICE } from "./hubspot/transport.js";
6
+ import { IDENTITY } from "./identity.js";
7
+ export { PACE };
8
+ /**
9
+ * Settings, keyring and the run come from cli-core's `baseContext` and nowhere else: a command that resolves settings
10
+ * on its own skips `--timeout`, the run record and the profile's permissions (WC-LIFE-5, WC-LIFE-15).
11
+ */
12
+ export const contextOf = (command) => {
13
+ const base = baseContext(command, configuration.resolveSettings);
14
+ return {
15
+ ...base,
16
+ environment: environmentOf(command),
17
+ flags: command.optsWithGlobals(),
18
+ profile: base.settings.profile,
19
+ tokens: new ProfileTokenStore({
20
+ app: IDENTITY,
21
+ env: base.env,
22
+ ...(base.keyring ? { keyring: base.keyring } : {}),
23
+ warn: base.renderer.warn,
24
+ }),
25
+ };
26
+ };
27
+ export const encodeSignIn = (signIn) => JSON.stringify(signIn);
28
+ export const decodeSignIn = (secret) => {
29
+ let parsed;
30
+ try {
31
+ parsed = JSON.parse(secret);
32
+ }
33
+ catch {
34
+ parsed = undefined;
35
+ }
36
+ const found = typeof parsed === "object" && parsed !== null ? parsed : {};
37
+ if (typeof found.token !== "string" || !found.token || typeof found.portalId !== "string" || !found.portalId)
38
+ throw new CliError("configuration_error", "the saved sign-in is not one hubspot wrote; run session start again", {
39
+ reason: "session.unreadable",
40
+ });
41
+ return {
42
+ token: found.token,
43
+ portalId: found.portalId,
44
+ uiDomain: typeof found.uiDomain === "string" ? found.uiDomain : null,
45
+ // An entry written before the time zone was kept holds `utcOffsetMs`, which is ignored.
46
+ ...(typeof found.timeZone === "string" && found.timeZone ? { timeZone: found.timeZone } : {}),
47
+ };
48
+ };
49
+ export const ACCOUNT_VARIABLE = `${IDENTITY.envPrefix}_ACCOUNT`;
50
+ /** The account `WCHUBSPOT_ACCOUNT` names, checked for its shape only; `undefined` when it is not set. */
51
+ export const environmentAccount = (env) => {
52
+ const portalId = env[ACCOUNT_VARIABLE]?.trim();
53
+ if (!portalId)
54
+ return undefined;
55
+ if (!/^\d+$/.test(portalId))
56
+ throw new CliError("configuration_error", `${ACCOUNT_VARIABLE} must be the account's id, digits only`, {
57
+ reason: "account.id-malformed",
58
+ });
59
+ return portalId;
60
+ };
61
+ /**
62
+ * `WCHUBSPOT_TOKEN` first, as for every token CLI, with `WCHUBSPOT_ACCOUNT` naming its account (the portal id), as
63
+ * amo's token needs `AMO_HOST`; then the saved sign-in. Read with no network: whether the two belong together is
64
+ * `refuseAccountMismatch`'s question. A token from the environment has no time zone, so its daily limit names the
65
+ * earliest UTC time it can be back.
66
+ */
67
+ export const storedSignIn = (command) => {
68
+ const { env, profile, tokens } = contextOf(command);
69
+ const stored = tokens.read(profile);
70
+ if (!stored)
71
+ return undefined;
72
+ if (stored.source !== "environment")
73
+ return decodeSignIn(stored.secret);
74
+ const portalId = environmentAccount(env);
75
+ if (!portalId)
76
+ throw new CliError("configuration_error", `${tokens.variable} needs ${ACCOUNT_VARIABLE}, the HubSpot account's id: ` +
77
+ `\`${IDENTITY.command} ${profile} session status --check\` with the token alone prints it`, { reason: "account.id-missing" });
78
+ return { token: stored.secret, portalId, uiDomain: null };
79
+ };
80
+ /** Whether this run's key comes from `WCHUBSPOT_TOKEN`, whose account nobody has checked yet. */
81
+ export const fromEnvironment = (command) => {
82
+ const { profile, tokens } = contextOf(command);
83
+ return tokens.read(profile)?.source === "environment";
84
+ };
85
+ /**
86
+ * A token's own account against the one `WCHUBSPOT_ACCOUNT` names. A wrong id would file this account's CRM under
87
+ * another's in the shared store, so a mismatch is refused before anything is written. Names both ids, never the token.
88
+ */
89
+ export const refuseAccountMismatch = (named, actual) => {
90
+ if (named === actual)
91
+ return;
92
+ throw new CliError("configuration_error", `${ACCOUNT_VARIABLE} names account ${named}, but the token belongs to account ${actual}: ` +
93
+ `set ${ACCOUNT_VARIABLE}=${actual}`, { reason: "account.mismatch", account: actual });
94
+ };
95
+ /** The sign-in a request uses, or cli-core's `session.missing` refusal that names the command to sign in. */
96
+ export const signInOf = (command) => {
97
+ refuseOffline(command, SERVICE);
98
+ const found = storedSignIn(command);
99
+ if (found)
100
+ return found;
101
+ const { profile, tokens } = contextOf(command);
102
+ tokens.need(profile);
103
+ throw new CliError("authentication_error", `profile ${profile} is not signed in`);
104
+ };
105
+ /** The bare token, read before any request; the api group sends it as `Authorization: Bearer`. */
106
+ export const tokenOf = (command) => signInOf(command).token;
107
+ /**
108
+ * HubSpot counts its limits per account, so every process on one account waits in one queue, whichever profile or
109
+ * `WCHUBSPOT_TOKEN` it reads with. Only a first sign-in, whose account is not known yet, paces by the profile.
110
+ */
111
+ export const pacerFor = (command, portalId) => {
112
+ const { environment, env, profile } = contextOf(command);
113
+ return new Pacer(pacePathFor(IDENTITY, portalId ? `account-${portalId}` : profile, env), PACE, environment.now);
114
+ };
115
+ /** The transport for one run, paced with the api group by the account. */
116
+ export const hubFor = (command, { token, portalId, timeZone }, events) => {
117
+ const { environment } = contextOf(command);
118
+ return hubspotTransport({
119
+ token,
120
+ ...(timeZone ? { timeZone } : {}),
121
+ ...(events ? { events } : {}),
122
+ signal: environment.signal,
123
+ ...(environment.fetch ? { fetch: environment.fetch } : {}),
124
+ ...(environment.sleep ? { sleep: environment.sleep } : {}),
125
+ ...(environment.now ? { now: environment.now } : {}),
126
+ pacer: pacerFor(command, portalId),
127
+ });
128
+ };
129
+ /**
130
+ * Every remote call goes through here: inside cli-core's run, so `--timeout` bounds it, a failure or `--record` keeps
131
+ * a run named after the command, and the transport's requests land in that run (WC-LIFE-5, WC-LIFE-15).
132
+ */
133
+ export const withHub = (command, body) => {
134
+ const signIn = signInOf(command);
135
+ return contextOf(command).run((events) => body(hubFor(command, signIn, events)));
136
+ };
137
+ //# sourceMappingURL=context.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"context.js","sourceRoot":"","sources":["../src/context.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAkB,MAAM,mBAAmB,CAAA;AAC5D,OAAO,EAEL,WAAW,EAEX,aAAa,EAEb,iBAAiB,EACjB,aAAa,GACd,MAAM,uBAAuB,CAAA;AAC9B,OAAO,EAAE,KAAK,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAA;AAE5D,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAA;AAC3C,OAAO,EAAyB,gBAAgB,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,wBAAwB,CAAA;AAC/F,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAA;AAExC,OAAO,EAAE,IAAI,EAAE,CAAA;AAUf;;;GAGG;AACH,MAAM,CAAC,MAAM,SAAS,GAAG,CAAC,OAAgB,EAAE,EAAE;IAC5C,MAAM,IAAI,GAAG,WAAW,CAAC,OAAO,EAAE,aAAa,CAAC,eAAe,CAAC,CAAA;IAChE,OAAO;QACL,GAAG,IAAI;QACP,WAAW,EAAE,aAAa,CAAqB,OAAO,CAAC;QACvD,KAAK,EAAE,OAAO,CAAC,eAAe,EAAe;QAC7C,OAAO,EAAE,IAAI,CAAC,QAAQ,CAAC,OAAO;QAC9B,MAAM,EAAE,IAAI,iBAAiB,CAAC;YAC5B,GAAG,EAAE,QAAQ;YACb,GAAG,EAAE,IAAI,CAAC,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,EAAE,CAAC;QAC1D,GAAG,CAAC,WAAW,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,GAAG,EAAE,WAAW,CAAC,GAAG,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;QACpD,KAAK,EAAE,QAAQ,CAAC,OAAO,EAAE,QAAQ,CAAC;KACnC,CAAC,CAAA;AACJ,CAAC,CAAA;AAED;;;GAGG;AACH,MAAM,CAAC,MAAM,OAAO,GAAG,CAAI,OAAgB,EAAE,IAA2C,EAAc,EAAE;IACtG,MAAM,MAAM,GAAG,QAAQ,CAAC,OAAO,CAAC,CAAA;IAChC,OAAO,SAAS,CAAC,OAAO,CAAC,CAAC,GAAG,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,IAAI,CAAC,MAAM,CAAC,OAAO,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC,CAAA;AAClF,CAAC,CAAA"}
@@ -0,0 +1,24 @@
1
+ import type { CrmActivity } from "@wirecat/cli-core";
2
+ import { type CrmCallContext, type CrmPage } from "@wirecat/cli-core/crm";
3
+ import type { HubSpotTransport } from "../hubspot/transport.js";
4
+ /**
5
+ * A call not over yet, of the `hs_call_status` values BUSY, CALLING_CRM_USER, CANCELED, COMPLETED, CONNECTING, FAILED,
6
+ * IN_PROGRESS, NO_ANSWER, QUEUED and RINGING (https://developers.hubspot.com/docs/api-reference/latest/crm/activities/calls/guide).
7
+ */
8
+ export declare const CALL_OPEN: string[];
9
+ export interface ActivityPages {
10
+ /** Rows a search asks per page (search guide: 200 at most). */
11
+ search: number;
12
+ /** Rows a list asks per page (100 at most). */
13
+ list: number;
14
+ }
15
+ /**
16
+ * One page of one engagement type changed since `since`, the types one after another: notes, calls, e-mails,
17
+ * meetings, tasks. A type the token's scopes refuse is a gap naming the scope, and the next type is read.
18
+ *
19
+ * More than the search cap changed at one moment (an import): the type is then listed in full, newest change or not,
20
+ * and only rows changed since the window's start are kept. Not a stop: cli-core resumes a failed activity round
21
+ * from the page it saved, which would hit the same cap on every run.
22
+ */
23
+ export declare const readActivities: (caller: HubSpotTransport, since: number, page: string | undefined, context: CrmCallContext | undefined, now: () => number, sizes?: ActivityPages) => Promise<CrmPage<CrmActivity>>;
24
+ //# sourceMappingURL=activities.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"activities.d.ts","sourceRoot":"","sources":["../../src/crm/activities.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,WAAW,EAA4B,MAAM,mBAAmB,CAAA;AAC9E,OAAO,EAAE,KAAK,cAAc,EAAE,KAAK,OAAO,EAAa,MAAM,uBAAuB,CAAA;AACpF,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAA;AAyB/D;;;GAGG;AACH,eAAO,MAAM,SAAS,UAAyE,CAAA;AAuI/F,MAAM,WAAW,aAAa;IAC5B,+DAA+D;IAC/D,MAAM,EAAE,MAAM,CAAA;IACd,+CAA+C;IAC/C,IAAI,EAAE,MAAM,CAAA;CACb;AAED;;;;;;;GAOG;AACH,eAAO,MAAM,cAAc,WACjB,gBAAgB,SACjB,MAAM,QACP,MAAM,GAAG,SAAS,WACf,cAAc,GAAG,SAAS,OAC9B,MAAM,MAAM,UACV,aAAa,KACnB,OAAO,CAAC,OAAO,CAAC,WAAW,CAAC,CA6D9B,CAAA"}