@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,661 @@
1
+ import { createRequire as __bundleRequire } from "node:module";
2
+ const require = __bundleRequire(import.meta.url);
3
+ import {
4
+ accountDetails
5
+ } from "./chunk-2UOJ7DLZ.js";
6
+ import {
7
+ OBJECTS,
8
+ SERVICE,
9
+ msOf,
10
+ nextOf,
11
+ propertiesOf,
12
+ resultsOf,
13
+ segment,
14
+ toDeal,
15
+ toField,
16
+ toLead,
17
+ toOrganization,
18
+ toPerson,
19
+ toPipeline,
20
+ toUser
21
+ } from "./chunk-MFNMKHML.js";
22
+ import "./chunk-DRWWJLI6.js";
23
+ import "./chunk-LXZ66MCH.js";
24
+ import "./chunk-X2M6NIQG.js";
25
+ import "./chunk-W7HM2VGO.js";
26
+ import "./chunk-B3MANLNK.js";
27
+ import "./chunk-URX6YDUL.js";
28
+ import "./chunk-3WLYWRGG.js";
29
+ import {
30
+ crmWindowOf,
31
+ values_exports,
32
+ walk
33
+ } from "./chunk-VOH7S5M4.js";
34
+ import "./chunk-2QZK5BEP.js";
35
+ import "./chunk-NXERIDPJ.js";
36
+ import "./chunk-WE4UFASG.js";
37
+ import "./chunk-GPYCBYX5.js";
38
+ import "./chunk-RR5MX5TM.js";
39
+ import "./chunk-CWXOXIWS.js";
40
+ import "./chunk-JLDBMEKZ.js";
41
+ import "./chunk-E5WLE7BM.js";
42
+ import "./chunk-N2XADGL4.js";
43
+ import "./chunk-FOZYMDRL.js";
44
+ import "./chunk-QU25DA5N.js";
45
+ import "./chunk-TKVL2C3B.js";
46
+ import "./chunk-O55RWNSH.js";
47
+ import "./chunk-24ERVFJP.js";
48
+ import "./chunk-NWHEHV3K.js";
49
+ import "./chunk-7ELMWE3P.js";
50
+ import "./chunk-PVKF24ZW.js";
51
+ import "./chunk-NUU4WZVL.js";
52
+ import "./chunk-2VGZRYEH.js";
53
+ import "./chunk-W53EJOFQ.js";
54
+ import "./chunk-RMIYKDUL.js";
55
+ import "./chunk-LOBVOGOE.js";
56
+ import "./chunk-36ITRDYY.js";
57
+ import "./chunk-C32AKHTY.js";
58
+ import "./chunk-FTFV3HFW.js";
59
+ import "./chunk-CLAN3FES.js";
60
+ import "./chunk-UUMUL4L3.js";
61
+ import "./chunk-SDQGB4KB.js";
62
+ import "./chunk-XRREFEIW.js";
63
+ import "./chunk-TI46WQXQ.js";
64
+ import "./chunk-E52JAS35.js";
65
+ import "./chunk-5GBUCHRU.js";
66
+ import "./chunk-YMCY7VRE.js";
67
+ import "./chunk-H3TNVEQX.js";
68
+ import "./chunk-HC5ZWE5X.js";
69
+ import "./chunk-QGFX5MXL.js";
70
+ import "./chunk-EH6ZEJGT.js";
71
+ import "./chunk-O3DYRCIT.js";
72
+ import "./chunk-2VGD63G6.js";
73
+ import "./chunk-5A6ZYNAQ.js";
74
+ import "./chunk-43EKCUBJ.js";
75
+ import "./chunk-HZRQLAHO.js";
76
+ import "./chunk-QJW35N5V.js";
77
+ import "./chunk-IMJQRPLN.js";
78
+ import "./chunk-DSP36YHQ.js";
79
+ import "./chunk-5K7QLJMM.js";
80
+ import "./chunk-FPUGMDJV.js";
81
+ import "./chunk-D72URWJE.js";
82
+ import "./chunk-DBEQI5YM.js";
83
+ import "./chunk-PPHBRESD.js";
84
+ import "./chunk-65TWQ7BV.js";
85
+ import "./chunk-HCAZV5NP.js";
86
+ import "./chunk-DFCHHR5M.js";
87
+ import "./chunk-TBJYLC5K.js";
88
+ import "./chunk-TOSCB4SO.js";
89
+ import "./chunk-MVA5HVKL.js";
90
+ import "./chunk-Y5E2WNWB.js";
91
+ import {
92
+ CliError,
93
+ isCliError
94
+ } from "./chunk-DB2XKHI4.js";
95
+ import "./chunk-TP7GDWVF.js";
96
+ import {
97
+ __name
98
+ } from "./chunk-ZVVMGPBJ.js";
99
+
100
+ // dist/crm/associations.js
101
+ var { fieldOf, id, number, rawsOf, text } = values_exports;
102
+ var associationsOf = /* @__PURE__ */ __name(async (post, from, to, ids) => {
103
+ const found = /* @__PURE__ */ new Map();
104
+ if (!ids.length)
105
+ return found;
106
+ const body = await post(`/crm/associations/2026-03/${from}/${to}/batch/read`, {
107
+ inputs: ids.map((one) => ({ id: one }))
108
+ });
109
+ for (const result of rawsOf(fieldOf(body, "results"))) {
110
+ const owner = id(fieldOf(result.from, "id"));
111
+ if (!owner)
112
+ continue;
113
+ const held = new Map((found.get(owner) ?? []).map((one) => [one.id, one]));
114
+ for (const one of rawsOf(result.to)) {
115
+ const linked = id(one.toObjectId);
116
+ if (!linked)
117
+ continue;
118
+ const types = rawsOf(one.associationTypes);
119
+ const kept = held.get(linked) ?? { id: linked, typeIds: [], labels: [] };
120
+ held.set(linked, {
121
+ id: linked,
122
+ typeIds: [.../* @__PURE__ */ new Set([...kept.typeIds, ...types.flatMap((type) => number(type.typeId) ?? [])])],
123
+ labels: [.../* @__PURE__ */ new Set([...kept.labels, ...types.flatMap((type) => text(type.label) ?? [])])]
124
+ });
125
+ }
126
+ found.set(owner, [...held.values()]);
127
+ }
128
+ return found;
129
+ }, "associationsOf");
130
+ var withAssociations = /* @__PURE__ */ __name((rows, to, found) => rows.map((raw) => ({
131
+ ...raw,
132
+ associations: {
133
+ ...typeof raw.associations === "object" && raw.associations !== null ? raw.associations : {},
134
+ [to]: { results: (found.get(String(raw.id)) ?? []).map((one) => ({ ...one, type: to })) }
135
+ }
136
+ })), "withAssociations");
137
+
138
+ // dist/crm/search.js
139
+ var SEARCH_PAGE = 200;
140
+ var SEARCH_CAP = 1e4;
141
+ var MAX_FILTERS_PER_GROUP = 6;
142
+ var search = /* @__PURE__ */ __name(async (post, path, request) => {
143
+ if (request.filters.length > MAX_FILTERS_PER_GROUP)
144
+ throw new CliError("validation_error", `${SERVICE} search takes at most ${MAX_FILTERS_PER_GROUP} conditions together; drop some`, { reason: "hubspot.too-many-filters" });
145
+ if (request.offset + request.limit > SEARCH_CAP)
146
+ throw new CliError("validation_error", `${SERVICE} search reaches only its first ${SEARCH_CAP} results; narrow the query`, { reason: "hubspot.search-cap" });
147
+ const body = await post(`/crm/objects/2026-03/${path}/search`, {
148
+ filterGroups: request.filters.length ? [{ filters: request.filters }] : [],
149
+ sorts: [request.sort],
150
+ properties: [...request.properties],
151
+ limit: request.limit,
152
+ ...request.offset ? { after: String(request.offset) } : {},
153
+ ...request.query ? { query: request.query } : {}
154
+ });
155
+ return { rows: resultsOf(body), more: nextOf(body) !== null };
156
+ }, "search");
157
+ var nextSpot = /* @__PURE__ */ __name((spot, rows, modified, limit) => {
158
+ const last = rows.at(-1);
159
+ const at = last ? msOf(propertiesOf(last)[modified]) ?? msOf(last.updatedAt) : null;
160
+ if (at !== null && at > spot.from)
161
+ return { from: at, offset: 0 };
162
+ const offset = spot.offset + rows.length;
163
+ return offset + limit > SEARCH_CAP ? null : { from: spot.from, offset };
164
+ }, "nextSpot");
165
+ var modifiedSince = /* @__PURE__ */ __name((modified, spot, limit, properties) => ({
166
+ filters: [{ propertyName: modified, operator: "GTE", value: String(spot.from) }],
167
+ sort: { propertyName: modified, direction: "ASCENDING" },
168
+ properties,
169
+ limit,
170
+ offset: spot.offset
171
+ }), "modifiedSince");
172
+
173
+ // dist/crm/activities.js
174
+ var { id: id2, text: text2 } = values_exports;
175
+ var OVERLAP_MS = 10 * 6e4;
176
+ var CALL_OPEN = ["CALLING_CRM_USER", "CONNECTING", "IN_PROGRESS", "QUEUED", "RINGING"];
177
+ var EMAIL_OPEN = ["SCHEDULED", "SENDING"];
178
+ var COMMON = ["hubspot_owner_id", "hs_timestamp", "hs_createdate", "hs_lastmodifieddate"];
179
+ var plain = /* @__PURE__ */ __name((value) => {
180
+ const html = text2(value);
181
+ if (html === null)
182
+ return null;
183
+ return text2(html.replace(/<br\s*\/?>|<\/p>|<\/div>|<\/li>/gi, "\n").replace(/<[^>]*>/g, "").replace(/&nbsp;/g, " ").replace(/&lt;/g, "<").replace(/&gt;/g, ">").replace(/&quot;/g, '"').replace(/&#39;/g, "'").replace(/&amp;/g, "&"));
184
+ }, "plain");
185
+ var CONTACTS_SCOPE = "crm.objects.contacts.read";
186
+ var ENGAGEMENTS = [
187
+ {
188
+ type: "notes",
189
+ kind: "comment",
190
+ scope: CONTACTS_SCOPE,
191
+ properties: ["hs_note_body", ...COMMON],
192
+ subject: /* @__PURE__ */ __name(() => "", "subject"),
193
+ body: /* @__PURE__ */ __name((properties) => plain(properties.hs_note_body), "body"),
194
+ dueAt: /* @__PURE__ */ __name(() => null, "dueAt"),
195
+ done: /* @__PURE__ */ __name(() => true, "done")
196
+ },
197
+ {
198
+ type: "calls",
199
+ kind: "call",
200
+ scope: CONTACTS_SCOPE,
201
+ properties: ["hs_call_title", "hs_call_direction", "hs_call_status", ...COMMON],
202
+ subject: /* @__PURE__ */ __name((properties) => text2(properties.hs_call_title) ?? (text2(properties.hs_call_direction) === "INBOUND" ? "incoming call" : "outgoing call"), "subject"),
203
+ body: /* @__PURE__ */ __name(() => null, "body"),
204
+ dueAt: /* @__PURE__ */ __name(() => null, "dueAt"),
205
+ done: /* @__PURE__ */ __name((properties) => !CALL_OPEN.includes(text2(properties.hs_call_status) ?? ""), "done")
206
+ },
207
+ {
208
+ type: "emails",
209
+ kind: "email",
210
+ scope: "sales-email-read",
211
+ properties: ["hs_email_subject", "hs_email_text", "hs_email_direction", "hs_email_status", ...COMMON],
212
+ subject: /* @__PURE__ */ __name((properties) => text2(properties.hs_email_subject), "subject"),
213
+ body: /* @__PURE__ */ __name((properties) => text2(properties.hs_email_text), "body"),
214
+ dueAt: /* @__PURE__ */ __name(() => null, "dueAt"),
215
+ done: /* @__PURE__ */ __name((properties) => !EMAIL_OPEN.includes(text2(properties.hs_email_status) ?? ""), "done")
216
+ },
217
+ {
218
+ type: "meetings",
219
+ kind: "meeting",
220
+ scope: CONTACTS_SCOPE,
221
+ properties: ["hs_meeting_title", "hs_meeting_body", "hs_meeting_start_time", "hs_meeting_outcome", ...COMMON],
222
+ subject: /* @__PURE__ */ __name((properties) => text2(properties.hs_meeting_title), "subject"),
223
+ body: /* @__PURE__ */ __name((properties) => plain(properties.hs_meeting_body), "body"),
224
+ dueAt: /* @__PURE__ */ __name((properties) => msOf(properties.hs_meeting_start_time), "dueAt"),
225
+ // "scheduled, completed, rescheduled, no show, and canceled", in prose and lower case
226
+ // (https://developers.hubspot.com/docs/api-reference/latest/crm/activities/meetings/guide).
227
+ done: /* @__PURE__ */ __name((properties) => text2(properties.hs_meeting_outcome)?.toUpperCase() === "COMPLETED", "done")
228
+ },
229
+ {
230
+ type: "tasks",
231
+ kind: "task",
232
+ scope: CONTACTS_SCOPE,
233
+ properties: ["hs_task_subject", "hs_task_body", "hs_task_status", ...COMMON],
234
+ subject: /* @__PURE__ */ __name((properties) => text2(properties.hs_task_subject), "subject"),
235
+ body: /* @__PURE__ */ __name((properties) => plain(properties.hs_task_body), "body"),
236
+ dueAt: /* @__PURE__ */ __name((properties) => msOf(properties.hs_timestamp), "dueAt"),
237
+ // COMPLETED or NOT_STARTED (https://developers.hubspot.com/docs/api-reference/latest/crm/activities/tasks/guide).
238
+ done: /* @__PURE__ */ __name((properties) => text2(properties.hs_task_status) === "COMPLETED", "done")
239
+ }
240
+ ];
241
+ var ON = [
242
+ ["deals", "deal"],
243
+ ["leads", "lead"],
244
+ ["contacts", "person"],
245
+ ["companies", "organization"]
246
+ ];
247
+ var toActivity = /* @__PURE__ */ __name((engagement, raw, on) => {
248
+ const externalId = id2(raw.id);
249
+ const properties = propertiesOf(raw);
250
+ const updatedAt = msOf(properties.hs_lastmodifieddate) ?? msOf(raw.updatedAt);
251
+ if (!externalId || updatedAt === null)
252
+ return null;
253
+ return {
254
+ // One id space for every kind: a note and a call may share a number.
255
+ externalId: `${engagement.type}:${externalId}`,
256
+ kind: engagement.kind,
257
+ subject: engagement.subject(properties) ?? "",
258
+ body: engagement.body(properties),
259
+ dueAt: engagement.dueAt(properties),
260
+ done: engagement.done(properties),
261
+ assignee: id2(properties.hubspot_owner_id),
262
+ createdAt: msOf(properties.hs_createdate) ?? msOf(raw.createdAt) ?? updatedAt,
263
+ updatedAt,
264
+ on
265
+ };
266
+ }, "toActivity");
267
+ var pageOf = /* @__PURE__ */ __name((page, since, now) => {
268
+ const fresh = { at: 0, spot: { from: since - OVERLAP_MS, offset: 0 }, after: void 0, started: now };
269
+ const cut = (page ?? "").lastIndexOf("@");
270
+ const started = Number(page?.slice(cut + 1));
271
+ const found = /^(\d+)\.(-?\d+)\.(?:(\d+)|L(.*))$/s.exec(page?.slice(0, cut) ?? "");
272
+ if (cut < 0 || !found || !Number.isSafeInteger(started))
273
+ return fresh;
274
+ return {
275
+ at: Number(found[1]),
276
+ spot: { from: Number(found[2]), offset: Number(found[3] ?? 0) },
277
+ after: found[4] === void 0 ? void 0 : found[4] || "",
278
+ started
279
+ };
280
+ }, "pageOf");
281
+ var readActivities = /* @__PURE__ */ __name(async (caller, since, page, context, now, sizes = { search: SEARCH_PAGE, list: 100 }) => {
282
+ const { at, spot, after, started } = pageOf(page, since, now());
283
+ const engagement = ENGAGEMENTS[at];
284
+ const last = { hasMore: false, cursor: String(started) };
285
+ if (!engagement)
286
+ return { items: [], ...last };
287
+ const following = /* @__PURE__ */ __name((items2, next2) => {
288
+ if (next2)
289
+ return { items: items2, hasMore: true, nextCursor: `${at}.${next2}@${started}` };
290
+ if (at + 1 >= ENGAGEMENTS.length)
291
+ return { items: items2, ...last };
292
+ return { items: items2, hasMore: true, nextCursor: `${at + 1}.${since - OVERLAP_MS}.0@${started}` };
293
+ }, "following");
294
+ let rows;
295
+ let more;
296
+ let listedNext = null;
297
+ try {
298
+ if (after === void 0)
299
+ ({ rows, more } = await search(caller.post, engagement.type, modifiedSince("hs_lastmodifieddate", spot, sizes.search, engagement.properties)));
300
+ else {
301
+ const body = await caller.get(`/crm/objects/2026-03/${engagement.type}`, {
302
+ limit: sizes.list,
303
+ properties: engagement.properties.join(","),
304
+ archived: false,
305
+ ...after ? { after } : {}
306
+ });
307
+ listedNext = nextOf(body);
308
+ more = listedNext !== null;
309
+ rows = resultsOf(body).filter((raw) => {
310
+ const changed = msOf(propertiesOf(raw).hs_lastmodifieddate) ?? msOf(raw.updatedAt);
311
+ return changed === null || changed >= spot.from;
312
+ });
313
+ }
314
+ } catch (error) {
315
+ if (!isCliError(error) || error.code !== "permission_error")
316
+ throw error;
317
+ context?.gap({
318
+ kind: "activities",
319
+ scope: engagement.scope,
320
+ message: `HubSpot refused the ${engagement.type} (${engagement.scope} scope missing); the other activities are read`
321
+ });
322
+ return following([]);
323
+ }
324
+ const ids = rows.flatMap((raw) => id2(raw.id) ?? []);
325
+ const on = /* @__PURE__ */ new Map();
326
+ for (const [to, kind] of ON) {
327
+ let found;
328
+ try {
329
+ found = await associationsOf(caller.post, engagement.type, to, ids);
330
+ } catch (error) {
331
+ if (isCliError(error) && error.code === "permission_error")
332
+ continue;
333
+ throw error;
334
+ }
335
+ for (const [owner, linked] of found)
336
+ on.set(owner, [...on.get(owner) ?? [], ...linked.map((one) => ({ kind, externalId: one.id }))]);
337
+ }
338
+ const items = rows.flatMap((raw) => toActivity(engagement, raw, on.get(String(raw.id)) ?? []) ?? []);
339
+ if (!more)
340
+ return following(items);
341
+ if (after !== void 0)
342
+ return following(items, `${spot.from}.L${listedNext}`);
343
+ const next = nextSpot(spot, rows, "hs_lastmodifieddate", sizes.search);
344
+ return following(items, next ? `${next.from}.${next.offset}` : `${spot.from}.L`);
345
+ }, "readActivities");
346
+
347
+ // dist/crm/source.js
348
+ var { id: id3, text: text3 } = values_exports;
349
+ var OVERLAP_MS2 = 10 * 6e4;
350
+ var LIST_PAGE = 100;
351
+ var PIPELINES = { deal: "deals", lead: "leads" };
352
+ var scoped = /* @__PURE__ */ __name((error, scope) => isCliError(error) && error.code === "permission_error" && typeof error.details.scope !== "string" ? new CliError(error.code, error.message, { ...error.details, scope }) : error, "scoped");
353
+ var refused = /* @__PURE__ */ __name((error) => isCliError(error) && error.code === "permission_error", "refused");
354
+ var unseen = /* @__PURE__ */ __name((error) => isCliError(error) && (error.code === "not_found" || refused(error)), "unseen");
355
+ var pageOf2 = /* @__PURE__ */ __name((page, now) => {
356
+ const cut = (page ?? "").lastIndexOf("@");
357
+ const head = page?.slice(0, cut) ?? "";
358
+ const started = Number(page?.slice(cut + 1));
359
+ if (cut < 0 || !Number.isSafeInteger(started))
360
+ return { after: void 0, spot: void 0, started: now };
361
+ if (head.startsWith("l"))
362
+ return { after: head.slice(1) || void 0, spot: void 0, started };
363
+ const found = /^s(-?\d+)\.(\d+)$/.exec(head);
364
+ if (!found)
365
+ return { after: void 0, spot: void 0, started: now };
366
+ return { after: void 0, spot: { from: Number(found[1]), offset: Number(found[2]) }, started };
367
+ }, "pageOf");
368
+ var asked = /* @__PURE__ */ __name((raw, types) => {
369
+ const held = typeof raw.associations === "object" && raw.associations !== null ? raw.associations : {};
370
+ return {
371
+ ...raw,
372
+ associations: { ...Object.fromEntries(types.map((type) => [type, { results: [] }])), ...held }
373
+ };
374
+ }, "asked");
375
+ var liveField = /* @__PURE__ */ __name((kind, field) => ({
376
+ assigned_to: "hubspot_owner_id",
377
+ created_at: OBJECTS[kind].created,
378
+ updated_at: OBJECTS[kind].modified,
379
+ // A company's own `type` property (Prospect, Partner…), as b24 maps `type` to its company type.
380
+ ...kind === "organization" ? { type: "type" } : {}
381
+ })[field], "liveField");
382
+ var MAX_PROPERTIES_CHARS = 6e3;
383
+ var fitted = /* @__PURE__ */ __name((own, custom) => {
384
+ const kept = [...own];
385
+ let length = kept.join(",").length;
386
+ const dropped = [];
387
+ for (const name of custom) {
388
+ if (kept.includes(name))
389
+ continue;
390
+ if (length + name.length + 1 > MAX_PROPERTIES_CHARS)
391
+ dropped.push(name);
392
+ else {
393
+ kept.push(name);
394
+ length += name.length + 1;
395
+ }
396
+ }
397
+ return { properties: kept.join(","), dropped };
398
+ }, "fitted");
399
+ var OPERATORS = {
400
+ "=": "EQ",
401
+ "!=": "NEQ",
402
+ ">": "GT",
403
+ ">=": "GTE",
404
+ "<": "LT",
405
+ "<=": "LTE",
406
+ in: "IN"
407
+ };
408
+ var filtersOf = /* @__PURE__ */ __name((kind, conditions, defined) => conditions.map(({ field, op, value }) => {
409
+ const propertyName = liveField(kind, field) ?? defined.find((one) => one.code === field)?.code;
410
+ if (!propertyName)
411
+ throw new CliError("validation_error", `${SERVICE} cannot filter ${OBJECTS[kind].name} by ${field}`, {
412
+ reason: "query.unsupported-field"
413
+ });
414
+ if (Array.isArray(value))
415
+ return { propertyName, operator: op === "!=" ? "NOT_IN" : "IN", values: value.map(String) };
416
+ return { propertyName, operator: OPERATORS[op], value: String(value) };
417
+ }), "filtersOf");
418
+ var hubspotCrmSource = /* @__PURE__ */ __name((hub, options = {}) => {
419
+ const now = options.now ?? Date.now;
420
+ const listPage = options.page ?? LIST_PAGE;
421
+ const searchPage = options.searchPage ?? SEARCH_PAGE;
422
+ const metered = /* @__PURE__ */ __name((context) => {
423
+ let paid = false;
424
+ const pay = /* @__PURE__ */ __name(() => {
425
+ if (paid)
426
+ context?.spend();
427
+ paid = true;
428
+ }, "pay");
429
+ return {
430
+ get: /* @__PURE__ */ __name((path, query) => {
431
+ pay();
432
+ return hub().get(path, query);
433
+ }, "get"),
434
+ post: /* @__PURE__ */ __name((path, body) => {
435
+ pay();
436
+ return hub().post(path, body);
437
+ }, "post")
438
+ };
439
+ }, "metered");
440
+ const loaded = /* @__PURE__ */ new Map();
441
+ const fields = /* @__PURE__ */ __name((kind, caller) => {
442
+ let found = loaded.get(kind);
443
+ if (!found) {
444
+ found = caller.get(`/crm/properties/2026-03/${OBJECTS[kind].name}`).then((body) => resultsOf(body).flatMap((raw) => toField(raw) ?? [])).catch((error) => {
445
+ if (refused(error))
446
+ return [];
447
+ loaded.delete(kind);
448
+ throw error;
449
+ });
450
+ loaded.set(kind, found);
451
+ }
452
+ return found;
453
+ }, "fields");
454
+ let currency;
455
+ const currencyOf = /* @__PURE__ */ __name((caller) => {
456
+ currency ??= accountDetails(caller).then((details) => details.companyCurrency ?? null, (error) => {
457
+ currency = void 0;
458
+ throw error;
459
+ });
460
+ return currency;
461
+ }, "currencyOf");
462
+ const mapped = /* @__PURE__ */ __name(async (kind, rows, defined, caller) => {
463
+ if (kind === "deal") {
464
+ const bare = rows.some((raw) => {
465
+ const properties = propertiesOf(raw);
466
+ return text3(properties.amount) !== null && text3(properties.deal_currency_code) === null;
467
+ });
468
+ const fallback = bare ? await currencyOf(caller) : null;
469
+ return rows.map((raw) => toDeal(raw, defined, fallback));
470
+ }
471
+ const map = { lead: toLead, person: toPerson, organization: toOrganization }[kind];
472
+ return rows.map((raw) => map(raw, defined));
473
+ }, "mapped");
474
+ const synced = /* @__PURE__ */ __name((kind, caller) => kind === "person" ? Promise.resolve([]) : fields(kind, caller), "synced");
475
+ const propertiesFor = /* @__PURE__ */ __name((type, defined) => [
476
+ .../* @__PURE__ */ new Set([...type.properties, ...defined.map(({ code }) => code)])
477
+ ], "propertiesFor");
478
+ const associate = /* @__PURE__ */ __name(async (type, rows, caller, types) => {
479
+ let linked = rows;
480
+ const ids = rows.flatMap((raw) => id3(raw.id) ?? []);
481
+ for (const to of types)
482
+ linked = withAssociations(linked, to, await associationsOf(caller.post, type.name, to, ids));
483
+ return linked;
484
+ }, "associate");
485
+ const everyLink = /* @__PURE__ */ __name((type) => [...type.associations, ...type.linked], "everyLink");
486
+ const getProperties = /* @__PURE__ */ __name((kind, defined, context) => {
487
+ const { properties, dropped } = fitted(OBJECTS[kind].properties, defined.map(({ code }) => code));
488
+ if (dropped.length)
489
+ context?.gap({
490
+ kind,
491
+ message: `${dropped.length} of the account's own ${OBJECTS[kind].name} properties do not fit one request and were not read`
492
+ });
493
+ return properties;
494
+ }, "getProperties");
495
+ const readChanges = /* @__PURE__ */ __name(async (kind, cursor, page, caller, context) => {
496
+ const type = OBJECTS[kind];
497
+ const since = cursor === null ? null : Date.parse(cursor);
498
+ if (since !== null && Number.isNaN(since))
499
+ return { reset: true };
500
+ const { after, spot: saved, started } = pageOf2(page, now());
501
+ const defined = await synced(kind, caller);
502
+ const properties = propertiesFor(type, defined);
503
+ const ended = { hasMore: false, cursor: new Date(started).toISOString() };
504
+ if (since === null) {
505
+ const query = {
506
+ limit: listPage,
507
+ properties: getProperties(kind, defined, context),
508
+ archived: false,
509
+ ...type.associations.length ? { associations: type.associations.join(",") } : {},
510
+ ...after ? { after } : {}
511
+ };
512
+ const body = await caller.get(`/crm/objects/2026-03/${type.path}`, query);
513
+ const rows2 = await associate(type, resultsOf(body).map((raw) => asked(raw, type.associations)), caller, type.linked);
514
+ const items2 = await mapped(kind, rows2, defined, caller);
515
+ const next2 = nextOf(body);
516
+ return next2 ? { items: items2, hasMore: true, nextCursor: `l${next2}@${started}` } : { items: items2, ...ended };
517
+ }
518
+ const spot = saved ?? { from: since - OVERLAP_MS2, offset: 0 };
519
+ const { rows, more } = await search(caller.post, type.path, modifiedSince(type.modified, spot, searchPage, properties));
520
+ const items = await mapped(kind, await associate(type, rows, caller, everyLink(type)), defined, caller);
521
+ if (!more)
522
+ return { items, ...ended };
523
+ const next = nextSpot(spot, rows, type.modified, searchPage);
524
+ if (next === null)
525
+ return { reset: true };
526
+ return { items, hasMore: true, nextCursor: `s${next.from}.${next.offset}@${started}` };
527
+ }, "readChanges");
528
+ const known = /* @__PURE__ */ __name(async (kind, caller) => fields(kind, caller), "known");
529
+ return {
530
+ provider: "hubspot",
531
+ traits: { kinds: ["organization", "person", "deal", "lead"], removedInChanges: false },
532
+ async pipelines(kind, context) {
533
+ try {
534
+ const body = await metered(context).get(`/crm/pipelines/2026-03/${PIPELINES[kind]}`);
535
+ return resultsOf(body).flatMap((raw) => {
536
+ const pipeline = toPipeline(raw, kind, (stage) => context?.gap({
537
+ kind,
538
+ message: `closed lead stage ${stage}: HubSpot gives no outcome; counted as lost`
539
+ }));
540
+ return pipeline ? [pipeline] : [];
541
+ });
542
+ } catch (error) {
543
+ if (kind === "lead" && refused(error)) {
544
+ context?.gap({ kind: "lead", scope: OBJECTS.lead.scope, message: leadsRefused });
545
+ return [];
546
+ }
547
+ throw scoped(error, OBJECTS[kind].scope);
548
+ }
549
+ },
550
+ async changes(kind, cursor, page, context) {
551
+ try {
552
+ return await readChanges(kind, cursor, page, metered(context), context);
553
+ } catch (error) {
554
+ if (kind === "lead" && refused(error)) {
555
+ context?.gap({ kind: "lead", scope: OBJECTS.lead.scope, message: leadsRefused });
556
+ return { items: [], hasMore: false, cursor: null };
557
+ }
558
+ throw scoped(error, OBJECTS[kind].scope);
559
+ }
560
+ },
561
+ // Any other refusal fails the pass rather than answer no ids, which would mark every stored row deleted
562
+ // (WC-DATA-7). Leads are the exception: an account without Sales Hub Pro never has any, and core holds back a pass
563
+ // that would delete most of a kind until --rescan.
564
+ async ids(kind, page, context) {
565
+ const type = OBJECTS[kind];
566
+ try {
567
+ const body = await metered(context).get(`/crm/objects/2026-03/${type.path}`, {
568
+ limit: listPage,
569
+ properties: "hs_object_id",
570
+ archived: false,
571
+ ...page ? { after: page } : {}
572
+ });
573
+ const items = resultsOf(body).flatMap((raw) => id3(raw.id) ?? []);
574
+ const next = nextOf(body);
575
+ return next ? { items, hasMore: true, nextCursor: next } : { items, hasMore: false };
576
+ } catch (error) {
577
+ if (kind === "lead" && refused(error)) {
578
+ context?.gap({ kind: "lead", scope: type.scope, message: leadsRefused });
579
+ return { items: [], hasMore: false };
580
+ }
581
+ throw scoped(error, type.scope);
582
+ }
583
+ },
584
+ async fields(kind, context) {
585
+ return fields(kind, metered(context));
586
+ },
587
+ // Active owners, then the deactivated ones, which `archived=true` lists alone (owners guide).
588
+ async users(context) {
589
+ const caller = metered(context);
590
+ const users = [];
591
+ for (const archived of [false, true]) {
592
+ let after = null;
593
+ do {
594
+ const body = await caller.get("/crm/owners/2026-03", { limit: LIST_PAGE, archived, ...after ? { after } : {} }).catch((error) => {
595
+ throw scoped(error, "crm.objects.owners.read");
596
+ });
597
+ for (const raw of resultsOf(body)) {
598
+ const user = toUser(raw);
599
+ if (user)
600
+ users.push(user);
601
+ }
602
+ after = nextOf(body);
603
+ } while (after);
604
+ }
605
+ return [...new Map(users.map((user) => [user.externalId, user])).values()];
606
+ },
607
+ async list(kind, query, context) {
608
+ const caller = metered(context);
609
+ const type = OBJECTS[kind];
610
+ const defined = await known(kind, caller);
611
+ const filters = filtersOf(kind, query.conditions, defined);
612
+ const properties = propertiesFor(type, defined);
613
+ const page = await walk(crmWindowOf(query), SEARCH_PAGE, async (offset, limit) => {
614
+ const { rows, more } = await search(caller.post, type.path, {
615
+ filters,
616
+ sort: { propertyName: type.created, direction: "DESCENDING" },
617
+ properties,
618
+ limit,
619
+ offset,
620
+ ...query.text ? { query: query.text } : {}
621
+ });
622
+ return { rows: await associate(type, rows, caller, everyLink(type)), more };
623
+ });
624
+ return { items: await mapped(kind, page.items, defined, caller), hasMore: page.hasMore };
625
+ },
626
+ get: /* @__PURE__ */ __name((kind, externalId, context) => record(kind, externalId, context), "get"),
627
+ record,
628
+ activities: /* @__PURE__ */ __name((since, page, context) => readActivities(metered(context), since, page, context, now, { search: searchPage, list: listPage }), "activities")
629
+ };
630
+ async function record(kind, externalId, context) {
631
+ if (!/^\d{1,20}$/.test(externalId))
632
+ return null;
633
+ const caller = metered(context);
634
+ const type = OBJECTS[kind];
635
+ const defined = await fields(kind, caller);
636
+ let body;
637
+ try {
638
+ body = await caller.get(`/crm/objects/2026-03/${type.path}/${segment(externalId)}`, {
639
+ properties: getProperties(kind, defined, context),
640
+ ...type.associations.length ? { associations: type.associations.join(",") } : {}
641
+ });
642
+ } catch (error) {
643
+ if (unseen(error))
644
+ return null;
645
+ throw error;
646
+ }
647
+ if (typeof body !== "object" || body === null)
648
+ return null;
649
+ const rows = await associate(type, [asked(body, type.associations)], caller, type.linked);
650
+ const [found] = await mapped(kind, rows, defined, caller);
651
+ return found ?? null;
652
+ }
653
+ __name(record, "record");
654
+ }, "hubspotCrmSource");
655
+ var leadsRefused = "HubSpot refused the leads: they need Sales Hub Professional or Enterprise and the crm.objects.leads.read scope; deals, contacts and companies are copied without them";
656
+ export {
657
+ MAX_PROPERTIES_CHARS,
658
+ OVERLAP_MS2 as OVERLAP_MS,
659
+ fitted,
660
+ hubspotCrmSource
661
+ };
@@ -0,0 +1,20 @@
1
+ import { createRequire as __bundleRequire } from "node:module";
2
+ const require = __bundleRequire(import.meta.url);
3
+ import {
4
+ ensureSqlite,
5
+ nodeRuntime,
6
+ relay
7
+ } from "./chunk-JLDBMEKZ.js";
8
+ import "./chunk-HCAZV5NP.js";
9
+ import "./chunk-DFCHHR5M.js";
10
+ import "./chunk-TBJYLC5K.js";
11
+ import "./chunk-TOSCB4SO.js";
12
+ import "./chunk-MVA5HVKL.js";
13
+ import "./chunk-Y5E2WNWB.js";
14
+ import "./chunk-DB2XKHI4.js";
15
+ import "./chunk-ZVVMGPBJ.js";
16
+ export {
17
+ ensureSqlite,
18
+ nodeRuntime,
19
+ relay
20
+ };