@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.
- package/CHANGELOG.md +29 -0
- package/LICENSE +204 -0
- package/README.md +256 -2
- package/contracts/wirecat.json +1965 -0
- package/dist/bin/hubspot.d.ts +3 -0
- package/dist/bin/hubspot.d.ts.map +1 -0
- package/dist/bin/hubspot.js +40 -0
- package/dist/bin/hubspot.js.map +1 -0
- package/dist/bundle/all-profiles-64JAUYW4.js +279 -0
- package/dist/bundle/anthropic-VJOS4OUM.js +91 -0
- package/dist/bundle/app-server-422MCA7S.js +245 -0
- package/dist/bundle/bun-M3J2QTR3.js +169 -0
- package/dist/bundle/bun-sqlite-IX3XYA5F.js +76 -0
- package/dist/bundle/chunk-24ERVFJP.js +73 -0
- package/dist/bundle/chunk-2QZK5BEP.js +392 -0
- package/dist/bundle/chunk-2TWQIWWG.js +1328 -0
- package/dist/bundle/chunk-2VGD63G6.js +604 -0
- package/dist/bundle/chunk-2VGZRYEH.js +334 -0
- package/dist/bundle/chunk-36ITRDYY.js +63116 -0
- package/dist/bundle/chunk-43EKCUBJ.js +72 -0
- package/dist/bundle/chunk-4W6BMH45.js +731 -0
- package/dist/bundle/chunk-5A6ZYNAQ.js +2003 -0
- package/dist/bundle/chunk-5D4AEUVA.js +24783 -0
- package/dist/bundle/chunk-5GBUCHRU.js +274 -0
- package/dist/bundle/chunk-5K7QLJMM.js +4072 -0
- package/dist/bundle/chunk-65TWQ7BV.js +54 -0
- package/dist/bundle/chunk-7ELMWE3P.js +12066 -0
- package/dist/bundle/chunk-ADLS6FVG.js +24600 -0
- package/dist/bundle/chunk-B3MANLNK.js +602 -0
- package/dist/bundle/chunk-BKXDHU3G.js +1395 -0
- package/dist/bundle/chunk-C32AKHTY.js +2310 -0
- package/dist/bundle/chunk-CLAN3FES.js +1246 -0
- package/dist/bundle/chunk-CWXOXIWS.js +46 -0
- package/dist/bundle/chunk-D72URWJE.js +532 -0
- package/dist/bundle/chunk-DB2XKHI4.js +72 -0
- package/dist/bundle/chunk-DBEQI5YM.js +100 -0
- package/dist/bundle/chunk-DFCHHR5M.js +38 -0
- package/dist/bundle/chunk-DFDN6AUB.js +21 -0
- package/dist/bundle/chunk-DRWWJLI6.js +188 -0
- package/dist/bundle/chunk-DSP36YHQ.js +29 -0
- package/dist/bundle/chunk-E52JAS35.js +1028 -0
- package/dist/bundle/chunk-E5WLE7BM.js +78 -0
- package/dist/bundle/chunk-ECEZOLOD.js +230 -0
- package/dist/bundle/chunk-EH6ZEJGT.js +932 -0
- package/dist/bundle/chunk-FBCCBCFH.js +288 -0
- package/dist/bundle/chunk-FKA7DOCK.js +53 -0
- package/dist/bundle/chunk-FOZYMDRL.js +259 -0
- package/dist/bundle/chunk-FPUGMDJV.js +7 -0
- package/dist/bundle/chunk-FTFV3HFW.js +721 -0
- package/dist/bundle/chunk-H3TNVEQX.js +782 -0
- package/dist/bundle/chunk-HC5ZWE5X.js +193 -0
- package/dist/bundle/chunk-HCAZV5NP.js +95 -0
- package/dist/bundle/chunk-HTAN663T.js +4045 -0
- package/dist/bundle/chunk-HZRQLAHO.js +16 -0
- package/dist/bundle/chunk-IMJQRPLN.js +92 -0
- package/dist/bundle/chunk-JLDBMEKZ.js +106 -0
- package/dist/bundle/chunk-JRCPCVPI.js +9393 -0
- package/dist/bundle/chunk-LNV33FDC.js +786 -0
- package/dist/bundle/chunk-LOBVOGOE.js +66 -0
- package/dist/bundle/chunk-MVA5HVKL.js +1392 -0
- package/dist/bundle/chunk-N2XADGL4.js +76 -0
- package/dist/bundle/chunk-NHHJHXMQ.js +58 -0
- package/dist/bundle/chunk-NUU4WZVL.js +52 -0
- package/dist/bundle/chunk-NWHEHV3K.js +133 -0
- package/dist/bundle/chunk-NXERIDPJ.js +319 -0
- package/dist/bundle/chunk-O3DYRCIT.js +23 -0
- package/dist/bundle/chunk-O55RWNSH.js +161 -0
- package/dist/bundle/chunk-P5BHKKBI.js +206 -0
- package/dist/bundle/chunk-PPHBRESD.js +82 -0
- package/dist/bundle/chunk-PVKF24ZW.js +364 -0
- package/dist/bundle/chunk-QGFX5MXL.js +460 -0
- package/dist/bundle/chunk-QJW35N5V.js +761 -0
- package/dist/bundle/chunk-QU25DA5N.js +360 -0
- package/dist/bundle/chunk-RMIYKDUL.js +1068 -0
- package/dist/bundle/chunk-RR5MX5TM.js +142 -0
- package/dist/bundle/chunk-SAKK2YRU.js +218 -0
- package/dist/bundle/chunk-SDQGB4KB.js +185 -0
- package/dist/bundle/chunk-TBJYLC5K.js +2788 -0
- package/dist/bundle/chunk-TI46WQXQ.js +1197 -0
- package/dist/bundle/chunk-TKVL2C3B.js +170 -0
- package/dist/bundle/chunk-TOSCB4SO.js +1227 -0
- package/dist/bundle/chunk-TP7GDWVF.js +6848 -0
- package/dist/bundle/chunk-UUMUL4L3.js +72 -0
- package/dist/bundle/chunk-VIEYMDBR.js +41 -0
- package/dist/bundle/chunk-W53EJOFQ.js +63 -0
- package/dist/bundle/chunk-W7HM2VGO.js +24 -0
- package/dist/bundle/chunk-WE4UFASG.js +88 -0
- package/dist/bundle/chunk-WQBX7XYP.js +26174 -0
- package/dist/bundle/chunk-X2M6NIQG.js +18 -0
- package/dist/bundle/chunk-X7XUX7A4.js +1846 -0
- package/dist/bundle/chunk-XRREFEIW.js +372 -0
- package/dist/bundle/chunk-Y5E2WNWB.js +35 -0
- package/dist/bundle/chunk-ZBDSHFG4.js +40933 -0
- package/dist/bundle/chunk-ZVVMGPBJ.js +50 -0
- package/dist/bundle/command-contract-C6CBFXZF.js +40 -0
- package/dist/bundle/command-server-entry-DJKVVZCQ.js +169 -0
- package/dist/bundle/decode-FC65Y4IV.js +297 -0
- package/dist/bundle/definitions-MVPICAWV.js +2991 -0
- package/dist/bundle/dispatch-KOISQ5QJ.js +411 -0
- package/dist/bundle/dist-MYZZKZJ7.js +7577 -0
- package/dist/bundle/echarts-FVTUDXDU.js +42501 -0
- package/dist/bundle/embed-VNBZFPYH.js +38 -0
- package/dist/bundle/embedder-6U4NOFRO.js +111 -0
- package/dist/bundle/failure-FZ6VYKEQ.js +25 -0
- package/dist/bundle/first-run-RPIJZEDT.js +29 -0
- package/dist/bundle/first-screen-RTVMGHAE.js +40 -0
- package/dist/bundle/hubspot.js +198 -0
- package/dist/bundle/instructions-HET7BCYK.js +11 -0
- package/dist/bundle/mcp-RGNRW77S.js +167 -0
- package/dist/bundle/meeting-combined-L5AGBPYX.js +25 -0
- package/dist/bundle/meeting-model-NTB4RK3F.js +25 -0
- package/dist/bundle/meeting-semantic-JY3OGCBS.js +22 -0
- package/dist/bundle/node-CXZIFHZC.js +176 -0
- package/dist/bundle/node-P4E63KXA.js +2340 -0
- package/dist/bundle/node-TLZSIHIJ.js +21 -0
- package/dist/bundle/node-sqlite-P3O7XN7Q.js +74 -0
- package/dist/bundle/oauth-HNCY4B2S.js +20 -0
- package/dist/bundle/open-F4P6YV54.js +23 -0
- package/dist/bundle/openai-4AICLIK3.js +238 -0
- package/dist/bundle/process-5RUXWGYS.js +91 -0
- package/dist/bundle/program-POG5GHUQ.js +9241 -0
- package/dist/bundle/prompt-NFMDVBZ4.js +17 -0
- package/dist/bundle/recognize-DKN3RY4V.js +26 -0
- package/dist/bundle/remote-6QHAGQWY.js +31 -0
- package/dist/bundle/rerank-M4KHEHUZ.js +52 -0
- package/dist/bundle/schemas-JRL3DLMP.js +952 -0
- package/dist/bundle/serve-DNU43ND6.js +199 -0
- package/dist/bundle/server-C3ZHA7AZ.js +77 -0
- package/dist/bundle/server-XJSNF3K5.js +207 -0
- package/dist/bundle/source-A3SBLHC4.js +934 -0
- package/dist/bundle/sqlite-runtime-EMQAC63N.js +20 -0
- package/dist/bundle/state-T45CX7VY.js +36 -0
- package/dist/bundle/store-6LCEVBAZ.js +176 -0
- package/dist/bundle/store-6TZ2FCVA.js +295 -0
- package/dist/bundle/store-CCDNUB6A.js +32 -0
- package/dist/bundle/store-maintenance-command-BRCG6MNA.js +68 -0
- package/dist/commands/account.d.ts +3 -0
- package/dist/commands/account.d.ts.map +1 -0
- package/dist/commands/account.js +87 -0
- package/dist/commands/account.js.map +1 -0
- package/dist/commands/api.d.ts +9 -0
- package/dist/commands/api.d.ts.map +1 -0
- package/dist/commands/api.js +65 -0
- package/dist/commands/api.js.map +1 -0
- package/dist/commands/comments.d.ts +3 -0
- package/dist/commands/comments.d.ts.map +1 -0
- package/dist/commands/comments.js +114 -0
- package/dist/commands/comments.js.map +1 -0
- package/dist/commands/crm-shared.d.ts +8 -0
- package/dist/commands/crm-shared.d.ts.map +1 -0
- package/dist/commands/crm-shared.js +93 -0
- package/dist/commands/crm-shared.js.map +1 -0
- package/dist/commands/schedule.d.ts +3 -0
- package/dist/commands/schedule.d.ts.map +1 -0
- package/dist/commands/schedule.js +9 -0
- package/dist/commands/schedule.js.map +1 -0
- package/dist/commands/session.d.ts +14 -0
- package/dist/commands/session.d.ts.map +1 -0
- package/dist/commands/session.js +164 -0
- package/dist/commands/session.js.map +1 -0
- package/dist/config.d.ts +22 -0
- package/dist/config.d.ts.map +1 -0
- package/dist/config.js +28 -0
- package/dist/config.js.map +1 -0
- package/dist/context.d.ts +88 -0
- package/dist/context.d.ts.map +1 -0
- package/dist/context.js +137 -0
- package/dist/context.js.map +1 -0
- package/dist/crm/activities.d.ts +24 -0
- package/dist/crm/activities.d.ts.map +1 -0
- package/dist/crm/activities.js +214 -0
- package/dist/crm/activities.js.map +1 -0
- package/dist/crm/associations.d.ts +20 -0
- package/dist/crm/associations.d.ts.map +1 -0
- package/dist/crm/associations.js +47 -0
- package/dist/crm/associations.js.map +1 -0
- package/dist/crm/records.d.ts +63 -0
- package/dist/crm/records.d.ts.map +1 -0
- package/dist/crm/records.js +333 -0
- package/dist/crm/records.js.map +1 -0
- package/dist/crm/search.d.ts +57 -0
- package/dist/crm/search.d.ts.map +1 -0
- package/dist/crm/search.js +47 -0
- package/dist/crm/search.js.map +1 -0
- package/dist/crm/source.d.ts +32 -0
- package/dist/crm/source.d.ts.map +1 -0
- package/dist/crm/source.js +369 -0
- package/dist/crm/source.js.map +1 -0
- package/dist/generated/definitions.d.ts +3 -0
- package/dist/generated/definitions.d.ts.map +1 -0
- package/dist/generated/definitions.js +2987 -0
- package/dist/generated/definitions.js.map +1 -0
- package/dist/generated/manifest.d.ts +6 -0
- package/dist/generated/manifest.d.ts.map +1 -0
- package/dist/generated/manifest.js +6499 -0
- package/dist/generated/manifest.js.map +1 -0
- package/dist/generated/schemas.d.ts +205 -0
- package/dist/generated/schemas.d.ts.map +1 -0
- package/dist/generated/schemas.js +810 -0
- package/dist/generated/schemas.js.map +1 -0
- package/dist/generated/types.d.ts +1114 -0
- package/dist/generated/types.d.ts.map +1 -0
- package/dist/generated/types.js +5 -0
- package/dist/generated/types.js.map +1 -0
- package/dist/hubspot/account.d.ts +12 -0
- package/dist/hubspot/account.d.ts.map +1 -0
- package/dist/hubspot/account.js +23 -0
- package/dist/hubspot/account.js.map +1 -0
- package/dist/hubspot/transport.d.ts +76 -0
- package/dist/hubspot/transport.d.ts.map +1 -0
- package/dist/hubspot/transport.js +346 -0
- package/dist/hubspot/transport.js.map +1 -0
- package/dist/identity.d.ts +7 -0
- package/dist/identity.d.ts.map +1 -0
- package/dist/identity.js +32 -0
- package/dist/identity.js.map +1 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +3 -0
- package/dist/index.js.map +1 -0
- package/dist/program.d.ts +6 -0
- package/dist/program.d.ts.map +1 -0
- package/dist/program.js +77 -0
- package/dist/program.js.map +1 -0
- package/dist/reasons.d.ts +10 -0
- package/dist/reasons.d.ts.map +1 -0
- package/dist/reasons.js +33 -0
- package/dist/reasons.js.map +1 -0
- package/dist/sample/comments.d.ts +61 -0
- package/dist/sample/comments.d.ts.map +1 -0
- package/dist/sample/comments.js +39 -0
- package/dist/sample/comments.js.map +1 -0
- package/dist/sample/records.d.ts +16 -0
- package/dist/sample/records.d.ts.map +1 -0
- package/dist/sample/records.js +22 -0
- package/dist/sample/records.js.map +1 -0
- package/dist/sample/transport.d.ts +42 -0
- package/dist/sample/transport.d.ts.map +1 -0
- package/dist/sample/transport.js +153 -0
- package/dist/sample/transport.js.map +1 -0
- package/dist/setup/flow.d.ts +2 -0
- package/dist/setup/flow.d.ts.map +1 -0
- package/dist/setup/flow.js +97 -0
- package/dist/setup/flow.js.map +1 -0
- package/dist/setup/texts.en.json +19 -0
- package/dist/setup/texts.es.json +19 -0
- package/dist/setup/texts.ru.json +19 -0
- package/dist/store.d.ts +16 -0
- package/dist/store.d.ts.map +1 -0
- package/dist/store.js +34 -0
- package/dist/store.js.map +1 -0
- package/dist/version.d.ts +2 -0
- package/dist/version.d.ts.map +1 -0
- package/dist/version.js +2 -0
- package/dist/version.js.map +1 -0
- package/dist/wcat.d.ts +3 -0
- package/dist/wcat.d.ts.map +1 -0
- package/dist/wcat.js +4 -0
- package/dist/wcat.js.map +1 -0
- package/dist/whoami.d.ts +19 -0
- package/dist/whoami.d.ts.map +1 -0
- package/dist/whoami.js +15 -0
- package/dist/whoami.js.map +1 -0
- package/package.json +98 -4
- package/skills/hubspot-cli/SKILL.md +97 -0
- package/skills/hubspot-cli/references/api/api-basic.md +462 -0
- package/skills/hubspot-cli/references/api/api-batch.md +149 -0
- package/skills/hubspot-cli/references/api/api-search.md +147 -0
- package/skills/hubspot-cli/references/api.md +15 -0
|
@@ -0,0 +1,934 @@
|
|
|
1
|
+
import { createRequire as __bundleRequire } from "node:module";
|
|
2
|
+
const require = __bundleRequire(import.meta.url);
|
|
3
|
+
import {
|
|
4
|
+
SERVICE,
|
|
5
|
+
accountDetails,
|
|
6
|
+
segment
|
|
7
|
+
} from "./chunk-WQBX7XYP.js";
|
|
8
|
+
import "./chunk-DRWWJLI6.js";
|
|
9
|
+
import "./chunk-2TWQIWWG.js";
|
|
10
|
+
import "./chunk-X2M6NIQG.js";
|
|
11
|
+
import "./chunk-W7HM2VGO.js";
|
|
12
|
+
import "./chunk-B3MANLNK.js";
|
|
13
|
+
import "./chunk-JRCPCVPI.js";
|
|
14
|
+
import "./chunk-BKXDHU3G.js";
|
|
15
|
+
import {
|
|
16
|
+
crmWindowOf,
|
|
17
|
+
values_exports,
|
|
18
|
+
walk
|
|
19
|
+
} from "./chunk-ZBDSHFG4.js";
|
|
20
|
+
import "./chunk-2QZK5BEP.js";
|
|
21
|
+
import "./chunk-NXERIDPJ.js";
|
|
22
|
+
import "./chunk-WE4UFASG.js";
|
|
23
|
+
import "./chunk-SAKK2YRU.js";
|
|
24
|
+
import "./chunk-RR5MX5TM.js";
|
|
25
|
+
import "./chunk-CWXOXIWS.js";
|
|
26
|
+
import "./chunk-JLDBMEKZ.js";
|
|
27
|
+
import "./chunk-E5WLE7BM.js";
|
|
28
|
+
import "./chunk-N2XADGL4.js";
|
|
29
|
+
import "./chunk-FOZYMDRL.js";
|
|
30
|
+
import "./chunk-QU25DA5N.js";
|
|
31
|
+
import "./chunk-TKVL2C3B.js";
|
|
32
|
+
import "./chunk-O55RWNSH.js";
|
|
33
|
+
import "./chunk-24ERVFJP.js";
|
|
34
|
+
import "./chunk-NWHEHV3K.js";
|
|
35
|
+
import "./chunk-7ELMWE3P.js";
|
|
36
|
+
import "./chunk-PVKF24ZW.js";
|
|
37
|
+
import "./chunk-NUU4WZVL.js";
|
|
38
|
+
import "./chunk-2VGZRYEH.js";
|
|
39
|
+
import "./chunk-W53EJOFQ.js";
|
|
40
|
+
import "./chunk-RMIYKDUL.js";
|
|
41
|
+
import "./chunk-LOBVOGOE.js";
|
|
42
|
+
import "./chunk-36ITRDYY.js";
|
|
43
|
+
import "./chunk-C32AKHTY.js";
|
|
44
|
+
import "./chunk-FTFV3HFW.js";
|
|
45
|
+
import "./chunk-CLAN3FES.js";
|
|
46
|
+
import "./chunk-UUMUL4L3.js";
|
|
47
|
+
import "./chunk-SDQGB4KB.js";
|
|
48
|
+
import "./chunk-XRREFEIW.js";
|
|
49
|
+
import "./chunk-TI46WQXQ.js";
|
|
50
|
+
import "./chunk-E52JAS35.js";
|
|
51
|
+
import "./chunk-5GBUCHRU.js";
|
|
52
|
+
import "./chunk-X7XUX7A4.js";
|
|
53
|
+
import "./chunk-H3TNVEQX.js";
|
|
54
|
+
import "./chunk-HC5ZWE5X.js";
|
|
55
|
+
import "./chunk-QGFX5MXL.js";
|
|
56
|
+
import "./chunk-EH6ZEJGT.js";
|
|
57
|
+
import "./chunk-O3DYRCIT.js";
|
|
58
|
+
import "./chunk-2VGD63G6.js";
|
|
59
|
+
import "./chunk-5A6ZYNAQ.js";
|
|
60
|
+
import "./chunk-43EKCUBJ.js";
|
|
61
|
+
import "./chunk-HZRQLAHO.js";
|
|
62
|
+
import "./chunk-QJW35N5V.js";
|
|
63
|
+
import "./chunk-IMJQRPLN.js";
|
|
64
|
+
import "./chunk-DSP36YHQ.js";
|
|
65
|
+
import "./chunk-5K7QLJMM.js";
|
|
66
|
+
import "./chunk-FPUGMDJV.js";
|
|
67
|
+
import "./chunk-D72URWJE.js";
|
|
68
|
+
import "./chunk-DBEQI5YM.js";
|
|
69
|
+
import "./chunk-PPHBRESD.js";
|
|
70
|
+
import "./chunk-65TWQ7BV.js";
|
|
71
|
+
import "./chunk-HCAZV5NP.js";
|
|
72
|
+
import "./chunk-DFCHHR5M.js";
|
|
73
|
+
import "./chunk-TBJYLC5K.js";
|
|
74
|
+
import "./chunk-TOSCB4SO.js";
|
|
75
|
+
import "./chunk-MVA5HVKL.js";
|
|
76
|
+
import "./chunk-Y5E2WNWB.js";
|
|
77
|
+
import {
|
|
78
|
+
CliError,
|
|
79
|
+
isCliError
|
|
80
|
+
} from "./chunk-DB2XKHI4.js";
|
|
81
|
+
import "./chunk-TP7GDWVF.js";
|
|
82
|
+
import {
|
|
83
|
+
__name
|
|
84
|
+
} from "./chunk-ZVVMGPBJ.js";
|
|
85
|
+
|
|
86
|
+
// dist/crm/associations.js
|
|
87
|
+
var { fieldOf, id, number, rawsOf, text } = values_exports;
|
|
88
|
+
var associationsOf = /* @__PURE__ */ __name(async (post, from, to, ids) => {
|
|
89
|
+
const found = /* @__PURE__ */ new Map();
|
|
90
|
+
if (!ids.length)
|
|
91
|
+
return found;
|
|
92
|
+
const body = await post(`/crm/associations/2026-03/${from}/${to}/batch/read`, {
|
|
93
|
+
inputs: ids.map((one) => ({ id: one }))
|
|
94
|
+
});
|
|
95
|
+
for (const result of rawsOf(fieldOf(body, "results"))) {
|
|
96
|
+
const owner = id(fieldOf(result.from, "id"));
|
|
97
|
+
if (!owner)
|
|
98
|
+
continue;
|
|
99
|
+
const held = new Map((found.get(owner) ?? []).map((one) => [one.id, one]));
|
|
100
|
+
for (const one of rawsOf(result.to)) {
|
|
101
|
+
const linked = id(one.toObjectId);
|
|
102
|
+
if (!linked)
|
|
103
|
+
continue;
|
|
104
|
+
const types = rawsOf(one.associationTypes);
|
|
105
|
+
const kept = held.get(linked) ?? { id: linked, typeIds: [], labels: [] };
|
|
106
|
+
held.set(linked, {
|
|
107
|
+
id: linked,
|
|
108
|
+
typeIds: [.../* @__PURE__ */ new Set([...kept.typeIds, ...types.flatMap((type) => number(type.typeId) ?? [])])],
|
|
109
|
+
labels: [.../* @__PURE__ */ new Set([...kept.labels, ...types.flatMap((type) => text(type.label) ?? [])])]
|
|
110
|
+
});
|
|
111
|
+
}
|
|
112
|
+
found.set(owner, [...held.values()]);
|
|
113
|
+
}
|
|
114
|
+
return found;
|
|
115
|
+
}, "associationsOf");
|
|
116
|
+
var withAssociations = /* @__PURE__ */ __name((rows, to, found) => rows.map((raw) => ({
|
|
117
|
+
...raw,
|
|
118
|
+
associations: {
|
|
119
|
+
...typeof raw.associations === "object" && raw.associations !== null ? raw.associations : {},
|
|
120
|
+
[to]: { results: (found.get(String(raw.id)) ?? []).map((one) => ({ ...one, type: to })) }
|
|
121
|
+
}
|
|
122
|
+
})), "withAssociations");
|
|
123
|
+
|
|
124
|
+
// dist/crm/records.js
|
|
125
|
+
var { amountOf, crmValuesOf, epoch, fieldOf: fieldOf2, fullName, id: id2, isRaw, rawsOf: rawsOf2, text: text2 } = values_exports;
|
|
126
|
+
var OBJECTS = {
|
|
127
|
+
organization: {
|
|
128
|
+
path: "companies",
|
|
129
|
+
name: "companies",
|
|
130
|
+
modified: "hs_lastmodifieddate",
|
|
131
|
+
created: "createdate",
|
|
132
|
+
properties: ["name", "domain", "website", "phone", "hubspot_owner_id", "createdate", "hs_lastmodifieddate"],
|
|
133
|
+
associations: [],
|
|
134
|
+
linked: [],
|
|
135
|
+
scope: "crm.objects.companies.read"
|
|
136
|
+
},
|
|
137
|
+
person: {
|
|
138
|
+
path: "contacts",
|
|
139
|
+
name: "contacts",
|
|
140
|
+
modified: "lastmodifieddate",
|
|
141
|
+
created: "createdate",
|
|
142
|
+
properties: [
|
|
143
|
+
"firstname",
|
|
144
|
+
"lastname",
|
|
145
|
+
"email",
|
|
146
|
+
"hs_additional_emails",
|
|
147
|
+
"phone",
|
|
148
|
+
"mobilephone",
|
|
149
|
+
"jobtitle",
|
|
150
|
+
"associatedcompanyid",
|
|
151
|
+
"hubspot_owner_id",
|
|
152
|
+
"createdate",
|
|
153
|
+
"lastmodifieddate"
|
|
154
|
+
],
|
|
155
|
+
associations: ["companies"],
|
|
156
|
+
linked: [],
|
|
157
|
+
scope: "crm.objects.contacts.read"
|
|
158
|
+
},
|
|
159
|
+
deal: {
|
|
160
|
+
path: "0-3",
|
|
161
|
+
name: "deals",
|
|
162
|
+
modified: "hs_lastmodifieddate",
|
|
163
|
+
created: "createdate",
|
|
164
|
+
properties: [
|
|
165
|
+
"dealname",
|
|
166
|
+
"pipeline",
|
|
167
|
+
"dealstage",
|
|
168
|
+
"amount",
|
|
169
|
+
"deal_currency_code",
|
|
170
|
+
"closedate",
|
|
171
|
+
"closed_lost_reason",
|
|
172
|
+
"closed_won_reason",
|
|
173
|
+
"hubspot_owner_id",
|
|
174
|
+
"createdate",
|
|
175
|
+
"hs_lastmodifieddate"
|
|
176
|
+
],
|
|
177
|
+
associations: ["contacts"],
|
|
178
|
+
linked: ["companies"],
|
|
179
|
+
scope: "crm.objects.deals.read"
|
|
180
|
+
},
|
|
181
|
+
lead: {
|
|
182
|
+
path: "leads",
|
|
183
|
+
name: "leads",
|
|
184
|
+
modified: "hs_lastmodifieddate",
|
|
185
|
+
// The leads guide names no created-time property (https://developers.hubspot.com/docs/api-reference/latest/crm/objects/leads/guide);
|
|
186
|
+
// HubSpot's other objects use `hs_createdate` or `createdate`, so both are asked and either is read.
|
|
187
|
+
created: "hs_createdate",
|
|
188
|
+
properties: [
|
|
189
|
+
"hs_lead_name",
|
|
190
|
+
"hs_pipeline",
|
|
191
|
+
"hs_pipeline_stage",
|
|
192
|
+
"hubspot_owner_id",
|
|
193
|
+
"hs_createdate",
|
|
194
|
+
"createdate",
|
|
195
|
+
"hs_lastmodifieddate"
|
|
196
|
+
],
|
|
197
|
+
associations: ["contacts"],
|
|
198
|
+
linked: ["companies"],
|
|
199
|
+
scope: "crm.objects.leads.read"
|
|
200
|
+
}
|
|
201
|
+
};
|
|
202
|
+
var resultsOf = /* @__PURE__ */ __name((body) => {
|
|
203
|
+
const results = fieldOf2(body, "results");
|
|
204
|
+
if (!Array.isArray(results))
|
|
205
|
+
throw new CliError("invalid_response", `${SERVICE} answered a list without its results`);
|
|
206
|
+
return results.filter(isRaw);
|
|
207
|
+
}, "resultsOf");
|
|
208
|
+
var nextOf = /* @__PURE__ */ __name((body) => text2(fieldOf2(fieldOf2(fieldOf2(body, "paging"), "next"), "after")), "nextOf");
|
|
209
|
+
var propertiesOf = /* @__PURE__ */ __name((raw) => isRaw(raw.properties) ? raw.properties : {}, "propertiesOf");
|
|
210
|
+
var msOf = /* @__PURE__ */ __name((value) => {
|
|
211
|
+
if (typeof value === "string" && /^\d{10,16}$/.test(value))
|
|
212
|
+
return Number(value);
|
|
213
|
+
return epoch(value);
|
|
214
|
+
}, "msOf");
|
|
215
|
+
var PRIMARY_COMPANY = { deals: 5, contacts: 1, leads: 580 };
|
|
216
|
+
var primaryCompanyOf = /* @__PURE__ */ __name((raw, from) => {
|
|
217
|
+
const results = rawsOf2(fieldOf2(fieldOf2(raw.associations, "companies"), "results"));
|
|
218
|
+
const marked = results.find((one) => Array.isArray(one.typeIds) && one.typeIds.includes(PRIMARY_COMPANY[from] ?? Number.NaN));
|
|
219
|
+
return id2(marked?.id) ?? id2(results[0]?.id);
|
|
220
|
+
}, "primaryCompanyOf");
|
|
221
|
+
var associatedOf = /* @__PURE__ */ __name((raw, type) => {
|
|
222
|
+
const group = fieldOf2(raw.associations, type);
|
|
223
|
+
if (group === void 0)
|
|
224
|
+
return void 0;
|
|
225
|
+
return [...new Set(rawsOf2(fieldOf2(group, "results")).flatMap((one) => id2(one.id) ?? []))];
|
|
226
|
+
}, "associatedOf");
|
|
227
|
+
var siteOf = /* @__PURE__ */ __name((properties) => {
|
|
228
|
+
for (const value of [properties.website, properties.domain]) {
|
|
229
|
+
const raw = text2(value);
|
|
230
|
+
if (!raw)
|
|
231
|
+
continue;
|
|
232
|
+
try {
|
|
233
|
+
const url = new URL(/^https?:\/\//i.test(raw) ? raw : `https://${raw}`);
|
|
234
|
+
if ((url.protocol === "https:" || url.protocol === "http:") && !url.username && !url.password)
|
|
235
|
+
return `${url.protocol}//${url.host}`;
|
|
236
|
+
} catch {
|
|
237
|
+
}
|
|
238
|
+
}
|
|
239
|
+
return null;
|
|
240
|
+
}, "siteOf");
|
|
241
|
+
var DAY = /^(\d{4}-\d{2}-\d{2})/;
|
|
242
|
+
var dayOf = /* @__PURE__ */ __name((value) => {
|
|
243
|
+
const ms = msOf(value);
|
|
244
|
+
if (ms !== null)
|
|
245
|
+
return new Date(ms).toISOString().slice(0, 10);
|
|
246
|
+
return DAY.exec(text2(value) ?? "")?.[1] ?? null;
|
|
247
|
+
}, "dayOf");
|
|
248
|
+
var uniq = /* @__PURE__ */ __name((values) => [...new Set(values.filter((one) => !!one))], "uniq");
|
|
249
|
+
var valuesOf = /* @__PURE__ */ __name((properties, defined) => {
|
|
250
|
+
const values = {};
|
|
251
|
+
for (const field of defined) {
|
|
252
|
+
const value = properties[field.code];
|
|
253
|
+
if (value === null || value === void 0 || value === "")
|
|
254
|
+
continue;
|
|
255
|
+
values[field.code] = field.multiple && typeof value === "string" ? value.split(";") : value;
|
|
256
|
+
}
|
|
257
|
+
return Object.keys(values).length ? crmValuesOf(values, defined) : void 0;
|
|
258
|
+
}, "valuesOf");
|
|
259
|
+
var timesOf = /* @__PURE__ */ __name((raw, type) => {
|
|
260
|
+
const properties = propertiesOf(raw);
|
|
261
|
+
return {
|
|
262
|
+
createdAt: msOf(properties[type.created]) ?? msOf(properties.createdate) ?? msOf(raw.createdAt),
|
|
263
|
+
updatedAt: msOf(properties[type.modified]) ?? msOf(raw.updatedAt)
|
|
264
|
+
};
|
|
265
|
+
}, "timesOf");
|
|
266
|
+
var toPerson = /* @__PURE__ */ __name((raw, defined = []) => {
|
|
267
|
+
const properties = propertiesOf(raw);
|
|
268
|
+
const phones = uniq([text2(properties.phone), text2(properties.mobilephone)]);
|
|
269
|
+
const emails = uniq([
|
|
270
|
+
text2(properties.email),
|
|
271
|
+
...(text2(properties.hs_additional_emails) ?? "").split(";").map((one) => text2(one))
|
|
272
|
+
]);
|
|
273
|
+
const companies = associatedOf(raw, "companies");
|
|
274
|
+
const primary = id2(properties.associatedcompanyid) ?? (companies?.length ? primaryCompanyOf(raw, "contacts") : null);
|
|
275
|
+
const metadata = valuesOf(properties, defined);
|
|
276
|
+
return {
|
|
277
|
+
externalId: id2(raw.id) ?? "",
|
|
278
|
+
name: fullName(properties.firstname, properties.lastname),
|
|
279
|
+
firstName: text2(properties.firstname),
|
|
280
|
+
lastName: text2(properties.lastname),
|
|
281
|
+
email: emails[0] ?? null,
|
|
282
|
+
phone: phones[0] ?? null,
|
|
283
|
+
phones,
|
|
284
|
+
emails,
|
|
285
|
+
position: text2(properties.jobtitle),
|
|
286
|
+
assignee: id2(properties.hubspot_owner_id),
|
|
287
|
+
...timesOf(raw, OBJECTS.person),
|
|
288
|
+
...companies ? {
|
|
289
|
+
organizations: uniq([primary && companies.includes(primary) ? primary : null, ...companies]).map((externalId) => ({ externalId, primary: externalId === primary }))
|
|
290
|
+
} : {},
|
|
291
|
+
...metadata ? { metadata } : {}
|
|
292
|
+
};
|
|
293
|
+
}, "toPerson");
|
|
294
|
+
var toOrganization = /* @__PURE__ */ __name((raw, defined = []) => {
|
|
295
|
+
const properties = propertiesOf(raw);
|
|
296
|
+
const metadata = valuesOf(properties, defined);
|
|
297
|
+
const phones = uniq([text2(properties.phone)]);
|
|
298
|
+
return {
|
|
299
|
+
externalId: id2(raw.id) ?? "",
|
|
300
|
+
name: text2(properties.name) ?? text2(properties.domain) ?? "",
|
|
301
|
+
url: siteOf(properties),
|
|
302
|
+
phones,
|
|
303
|
+
assignee: id2(properties.hubspot_owner_id),
|
|
304
|
+
...timesOf(raw, OBJECTS.organization),
|
|
305
|
+
...metadata ? { metadata } : {}
|
|
306
|
+
};
|
|
307
|
+
}, "toOrganization");
|
|
308
|
+
var linksOf = /* @__PURE__ */ __name((raw, from) => {
|
|
309
|
+
const contacts = associatedOf(raw, "contacts");
|
|
310
|
+
const companies = associatedOf(raw, "companies");
|
|
311
|
+
return {
|
|
312
|
+
...contacts ? { people: contacts.map((externalId) => ({ externalId, role: "contact" })) } : {},
|
|
313
|
+
...companies ? { organization: primaryCompanyOf(raw, from) } : {}
|
|
314
|
+
};
|
|
315
|
+
}, "linksOf");
|
|
316
|
+
var toDeal = /* @__PURE__ */ __name((raw, defined = [], currency = null) => {
|
|
317
|
+
const properties = propertiesOf(raw);
|
|
318
|
+
const money = amountOf(properties.amount, text2(properties.deal_currency_code) ?? currency);
|
|
319
|
+
const metadata = valuesOf(properties, defined);
|
|
320
|
+
return {
|
|
321
|
+
externalId: id2(raw.id) ?? "",
|
|
322
|
+
title: text2(properties.dealname) ?? "",
|
|
323
|
+
pipeline: text2(properties.pipeline) ?? "",
|
|
324
|
+
stage: text2(properties.dealstage) ?? "",
|
|
325
|
+
...money,
|
|
326
|
+
closeDate: dayOf(properties.closedate),
|
|
327
|
+
closedReason: text2(properties.closed_won_reason) ?? text2(properties.closed_lost_reason),
|
|
328
|
+
assignee: id2(properties.hubspot_owner_id),
|
|
329
|
+
...timesOf(raw, OBJECTS.deal),
|
|
330
|
+
...linksOf(raw, "deals"),
|
|
331
|
+
...metadata ? { metadata } : {}
|
|
332
|
+
};
|
|
333
|
+
}, "toDeal");
|
|
334
|
+
var toLead = /* @__PURE__ */ __name((raw, defined = []) => {
|
|
335
|
+
const properties = propertiesOf(raw);
|
|
336
|
+
const metadata = valuesOf(properties, defined);
|
|
337
|
+
return {
|
|
338
|
+
externalId: id2(raw.id) ?? "",
|
|
339
|
+
title: text2(properties.hs_lead_name) ?? "",
|
|
340
|
+
pipeline: text2(properties.hs_pipeline) ?? "",
|
|
341
|
+
stage: text2(properties.hs_pipeline_stage) ?? "",
|
|
342
|
+
assignee: id2(properties.hubspot_owner_id),
|
|
343
|
+
...timesOf(raw, OBJECTS.lead),
|
|
344
|
+
...linksOf(raw, "leads"),
|
|
345
|
+
...metadata ? { metadata } : {}
|
|
346
|
+
};
|
|
347
|
+
}, "toLead");
|
|
348
|
+
var LEAD_STAGE_IDS = { "qualified-stage-id": "won", "unqualified-stage-id": "lost" };
|
|
349
|
+
var LEAD_STAGE_LABELS = { qualified: "won", disqualified: "lost" };
|
|
350
|
+
var outcomeOf = /* @__PURE__ */ __name((metadata, kind = "deal", stage = {}) => {
|
|
351
|
+
if (text2(fieldOf2(metadata, "isClosed")) !== "true")
|
|
352
|
+
return { outcome: "open" };
|
|
353
|
+
const probability = text2(fieldOf2(metadata, "probability"));
|
|
354
|
+
if (kind === "deal" || probability !== null)
|
|
355
|
+
return { outcome: Number(probability) === 1 ? "won" : "lost" };
|
|
356
|
+
const known = LEAD_STAGE_IDS[stage.id ?? ""] ?? LEAD_STAGE_LABELS[stage.label?.trim().toLowerCase() ?? ""];
|
|
357
|
+
return known ? { outcome: known } : { outcome: "lost", unknown: true };
|
|
358
|
+
}, "outcomeOf");
|
|
359
|
+
var toPipeline = /* @__PURE__ */ __name((raw, kind = "deal", unknown = () => {
|
|
360
|
+
}) => {
|
|
361
|
+
const externalId = id2(raw.id);
|
|
362
|
+
if (!externalId)
|
|
363
|
+
return null;
|
|
364
|
+
return {
|
|
365
|
+
externalId,
|
|
366
|
+
name: text2(raw.label) ?? externalId,
|
|
367
|
+
stages: rawsOf2(raw.stages).flatMap((stage, at) => {
|
|
368
|
+
const stageId = id2(stage.id);
|
|
369
|
+
if (!stageId)
|
|
370
|
+
return [];
|
|
371
|
+
const order = Number(stage.displayOrder);
|
|
372
|
+
const name = text2(stage.label) ?? stageId;
|
|
373
|
+
const { outcome, unknown: guessed } = outcomeOf(stage.metadata, kind, { id: stageId, label: text2(stage.label) });
|
|
374
|
+
if (guessed)
|
|
375
|
+
unknown(name);
|
|
376
|
+
return [{ externalId: stageId, name, position: Number.isFinite(order) ? order : at, outcome }];
|
|
377
|
+
})
|
|
378
|
+
};
|
|
379
|
+
}, "toPipeline");
|
|
380
|
+
var toUser = /* @__PURE__ */ __name((raw) => {
|
|
381
|
+
const externalId = id2(raw.id);
|
|
382
|
+
if (!externalId)
|
|
383
|
+
return null;
|
|
384
|
+
return {
|
|
385
|
+
externalId,
|
|
386
|
+
name: fullName(raw.firstName, raw.lastName) ?? text2(raw.email),
|
|
387
|
+
email: text2(raw.email),
|
|
388
|
+
active: raw.archived !== true
|
|
389
|
+
};
|
|
390
|
+
}, "toUser");
|
|
391
|
+
var toField = /* @__PURE__ */ __name((raw) => {
|
|
392
|
+
const code = text2(raw.name);
|
|
393
|
+
if (!code || raw.hubspotDefined === true || raw.archived === true)
|
|
394
|
+
return null;
|
|
395
|
+
const type = text2(raw.type) ?? "string";
|
|
396
|
+
const fieldType = text2(raw.fieldType);
|
|
397
|
+
const options = type === "enumeration" && fieldType !== "booleancheckbox" ? [
|
|
398
|
+
...new Map(rawsOf2(raw.options).filter((one) => one.hidden !== true).flatMap((one) => {
|
|
399
|
+
const value = text2(one.value);
|
|
400
|
+
return value ? [[value, { id: value, label: text2(one.label) ?? value }]] : [];
|
|
401
|
+
})).values()
|
|
402
|
+
] : void 0;
|
|
403
|
+
return {
|
|
404
|
+
code,
|
|
405
|
+
label: text2(raw.label),
|
|
406
|
+
type,
|
|
407
|
+
multiple: type === "enumeration" && fieldType === "checkbox",
|
|
408
|
+
filterable: true,
|
|
409
|
+
...options ? { options } : {},
|
|
410
|
+
...fieldType === "phonenumber" ? { holds: "phone" } : {}
|
|
411
|
+
};
|
|
412
|
+
}, "toField");
|
|
413
|
+
|
|
414
|
+
// dist/crm/search.js
|
|
415
|
+
var SEARCH_PAGE = 200;
|
|
416
|
+
var SEARCH_CAP = 1e4;
|
|
417
|
+
var MAX_FILTERS_PER_GROUP = 6;
|
|
418
|
+
var search = /* @__PURE__ */ __name(async (post, path, request) => {
|
|
419
|
+
if (request.filters.length > MAX_FILTERS_PER_GROUP)
|
|
420
|
+
throw new CliError("validation_error", `${SERVICE} search takes at most ${MAX_FILTERS_PER_GROUP} conditions together; drop some`, { reason: "hubspot.too-many-filters" });
|
|
421
|
+
if (request.offset + request.limit > SEARCH_CAP)
|
|
422
|
+
throw new CliError("validation_error", `${SERVICE} search reaches only its first ${SEARCH_CAP} results; narrow the query`, { reason: "hubspot.search-cap" });
|
|
423
|
+
const body = await post(`/crm/objects/2026-03/${path}/search`, {
|
|
424
|
+
filterGroups: request.filters.length ? [{ filters: request.filters }] : [],
|
|
425
|
+
sorts: [request.sort],
|
|
426
|
+
properties: [...request.properties],
|
|
427
|
+
limit: request.limit,
|
|
428
|
+
...request.offset ? { after: String(request.offset) } : {},
|
|
429
|
+
...request.query ? { query: request.query } : {}
|
|
430
|
+
});
|
|
431
|
+
return { rows: resultsOf(body), more: nextOf(body) !== null };
|
|
432
|
+
}, "search");
|
|
433
|
+
var nextSpot = /* @__PURE__ */ __name((spot, rows, modified, limit) => {
|
|
434
|
+
const last = rows.at(-1);
|
|
435
|
+
const at = last ? msOf(propertiesOf(last)[modified]) ?? msOf(last.updatedAt) : null;
|
|
436
|
+
if (at !== null && at > spot.from)
|
|
437
|
+
return { from: at, offset: 0 };
|
|
438
|
+
const offset = spot.offset + rows.length;
|
|
439
|
+
return offset + limit > SEARCH_CAP ? null : { from: spot.from, offset };
|
|
440
|
+
}, "nextSpot");
|
|
441
|
+
var modifiedSince = /* @__PURE__ */ __name((modified, spot, limit, properties) => ({
|
|
442
|
+
filters: [{ propertyName: modified, operator: "GTE", value: String(spot.from) }],
|
|
443
|
+
sort: { propertyName: modified, direction: "ASCENDING" },
|
|
444
|
+
properties,
|
|
445
|
+
limit,
|
|
446
|
+
offset: spot.offset
|
|
447
|
+
}), "modifiedSince");
|
|
448
|
+
|
|
449
|
+
// dist/crm/activities.js
|
|
450
|
+
var { id: id3, text: text3 } = values_exports;
|
|
451
|
+
var OVERLAP_MS = 10 * 6e4;
|
|
452
|
+
var CALL_OPEN = ["CALLING_CRM_USER", "CONNECTING", "IN_PROGRESS", "QUEUED", "RINGING"];
|
|
453
|
+
var EMAIL_OPEN = ["SCHEDULED", "SENDING"];
|
|
454
|
+
var COMMON = ["hubspot_owner_id", "hs_timestamp", "hs_createdate", "hs_lastmodifieddate"];
|
|
455
|
+
var plain = /* @__PURE__ */ __name((value) => {
|
|
456
|
+
const html = text3(value);
|
|
457
|
+
if (html === null)
|
|
458
|
+
return null;
|
|
459
|
+
return text3(html.replace(/<br\s*\/?>|<\/p>|<\/div>|<\/li>/gi, "\n").replace(/<[^>]*>/g, "").replace(/ /g, " ").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, '"').replace(/'/g, "'").replace(/&/g, "&"));
|
|
460
|
+
}, "plain");
|
|
461
|
+
var CONTACTS_SCOPE = "crm.objects.contacts.read";
|
|
462
|
+
var ENGAGEMENTS = [
|
|
463
|
+
{
|
|
464
|
+
type: "notes",
|
|
465
|
+
kind: "comment",
|
|
466
|
+
scope: CONTACTS_SCOPE,
|
|
467
|
+
properties: ["hs_note_body", ...COMMON],
|
|
468
|
+
subject: /* @__PURE__ */ __name(() => "", "subject"),
|
|
469
|
+
body: /* @__PURE__ */ __name((properties) => plain(properties.hs_note_body), "body"),
|
|
470
|
+
dueAt: /* @__PURE__ */ __name(() => null, "dueAt"),
|
|
471
|
+
done: /* @__PURE__ */ __name(() => true, "done")
|
|
472
|
+
},
|
|
473
|
+
{
|
|
474
|
+
type: "calls",
|
|
475
|
+
kind: "call",
|
|
476
|
+
scope: CONTACTS_SCOPE,
|
|
477
|
+
properties: ["hs_call_title", "hs_call_direction", "hs_call_status", ...COMMON],
|
|
478
|
+
subject: /* @__PURE__ */ __name((properties) => text3(properties.hs_call_title) ?? (text3(properties.hs_call_direction) === "INBOUND" ? "incoming call" : "outgoing call"), "subject"),
|
|
479
|
+
body: /* @__PURE__ */ __name(() => null, "body"),
|
|
480
|
+
dueAt: /* @__PURE__ */ __name(() => null, "dueAt"),
|
|
481
|
+
done: /* @__PURE__ */ __name((properties) => !CALL_OPEN.includes(text3(properties.hs_call_status) ?? ""), "done")
|
|
482
|
+
},
|
|
483
|
+
{
|
|
484
|
+
type: "emails",
|
|
485
|
+
kind: "email",
|
|
486
|
+
scope: "sales-email-read",
|
|
487
|
+
properties: ["hs_email_subject", "hs_email_text", "hs_email_direction", "hs_email_status", ...COMMON],
|
|
488
|
+
subject: /* @__PURE__ */ __name((properties) => text3(properties.hs_email_subject), "subject"),
|
|
489
|
+
body: /* @__PURE__ */ __name((properties) => text3(properties.hs_email_text), "body"),
|
|
490
|
+
dueAt: /* @__PURE__ */ __name(() => null, "dueAt"),
|
|
491
|
+
done: /* @__PURE__ */ __name((properties) => !EMAIL_OPEN.includes(text3(properties.hs_email_status) ?? ""), "done")
|
|
492
|
+
},
|
|
493
|
+
{
|
|
494
|
+
type: "meetings",
|
|
495
|
+
kind: "meeting",
|
|
496
|
+
scope: CONTACTS_SCOPE,
|
|
497
|
+
properties: ["hs_meeting_title", "hs_meeting_body", "hs_meeting_start_time", "hs_meeting_outcome", ...COMMON],
|
|
498
|
+
subject: /* @__PURE__ */ __name((properties) => text3(properties.hs_meeting_title), "subject"),
|
|
499
|
+
body: /* @__PURE__ */ __name((properties) => plain(properties.hs_meeting_body), "body"),
|
|
500
|
+
dueAt: /* @__PURE__ */ __name((properties) => msOf(properties.hs_meeting_start_time), "dueAt"),
|
|
501
|
+
// "scheduled, completed, rescheduled, no show, and canceled", in prose and lower case
|
|
502
|
+
// (https://developers.hubspot.com/docs/api-reference/latest/crm/activities/meetings/guide).
|
|
503
|
+
done: /* @__PURE__ */ __name((properties) => text3(properties.hs_meeting_outcome)?.toUpperCase() === "COMPLETED", "done")
|
|
504
|
+
},
|
|
505
|
+
{
|
|
506
|
+
type: "tasks",
|
|
507
|
+
kind: "task",
|
|
508
|
+
scope: CONTACTS_SCOPE,
|
|
509
|
+
properties: ["hs_task_subject", "hs_task_body", "hs_task_status", ...COMMON],
|
|
510
|
+
subject: /* @__PURE__ */ __name((properties) => text3(properties.hs_task_subject), "subject"),
|
|
511
|
+
body: /* @__PURE__ */ __name((properties) => plain(properties.hs_task_body), "body"),
|
|
512
|
+
dueAt: /* @__PURE__ */ __name((properties) => msOf(properties.hs_timestamp), "dueAt"),
|
|
513
|
+
// COMPLETED or NOT_STARTED (https://developers.hubspot.com/docs/api-reference/latest/crm/activities/tasks/guide).
|
|
514
|
+
done: /* @__PURE__ */ __name((properties) => text3(properties.hs_task_status) === "COMPLETED", "done")
|
|
515
|
+
}
|
|
516
|
+
];
|
|
517
|
+
var ON = [
|
|
518
|
+
["deals", "deal"],
|
|
519
|
+
["leads", "lead"],
|
|
520
|
+
["contacts", "person"],
|
|
521
|
+
["companies", "organization"]
|
|
522
|
+
];
|
|
523
|
+
var toActivity = /* @__PURE__ */ __name((engagement, raw, on) => {
|
|
524
|
+
const externalId = id3(raw.id);
|
|
525
|
+
const properties = propertiesOf(raw);
|
|
526
|
+
const updatedAt = msOf(properties.hs_lastmodifieddate) ?? msOf(raw.updatedAt);
|
|
527
|
+
if (!externalId || updatedAt === null)
|
|
528
|
+
return null;
|
|
529
|
+
return {
|
|
530
|
+
// One id space for every kind: a note and a call may share a number.
|
|
531
|
+
externalId: `${engagement.type}:${externalId}`,
|
|
532
|
+
kind: engagement.kind,
|
|
533
|
+
subject: engagement.subject(properties) ?? "",
|
|
534
|
+
body: engagement.body(properties),
|
|
535
|
+
dueAt: engagement.dueAt(properties),
|
|
536
|
+
done: engagement.done(properties),
|
|
537
|
+
assignee: id3(properties.hubspot_owner_id),
|
|
538
|
+
createdAt: msOf(properties.hs_createdate) ?? msOf(raw.createdAt) ?? updatedAt,
|
|
539
|
+
updatedAt,
|
|
540
|
+
on
|
|
541
|
+
};
|
|
542
|
+
}, "toActivity");
|
|
543
|
+
var pageOf = /* @__PURE__ */ __name((page, since, now) => {
|
|
544
|
+
const fresh = { at: 0, spot: { from: since - OVERLAP_MS, offset: 0 }, after: void 0, started: now };
|
|
545
|
+
const cut = (page ?? "").lastIndexOf("@");
|
|
546
|
+
const started = Number(page?.slice(cut + 1));
|
|
547
|
+
const found = /^(\d+)\.(-?\d+)\.(?:(\d+)|L(.*))$/s.exec(page?.slice(0, cut) ?? "");
|
|
548
|
+
if (cut < 0 || !found || !Number.isSafeInteger(started))
|
|
549
|
+
return fresh;
|
|
550
|
+
return {
|
|
551
|
+
at: Number(found[1]),
|
|
552
|
+
spot: { from: Number(found[2]), offset: Number(found[3] ?? 0) },
|
|
553
|
+
after: found[4] === void 0 ? void 0 : found[4] || "",
|
|
554
|
+
started
|
|
555
|
+
};
|
|
556
|
+
}, "pageOf");
|
|
557
|
+
var readActivities = /* @__PURE__ */ __name(async (caller, since, page, context, now, sizes = { search: SEARCH_PAGE, list: 100 }) => {
|
|
558
|
+
const { at, spot, after, started } = pageOf(page, since, now());
|
|
559
|
+
const engagement = ENGAGEMENTS[at];
|
|
560
|
+
const last = { hasMore: false, cursor: String(started) };
|
|
561
|
+
if (!engagement)
|
|
562
|
+
return { items: [], ...last };
|
|
563
|
+
const following = /* @__PURE__ */ __name((items2, next2) => {
|
|
564
|
+
if (next2)
|
|
565
|
+
return { items: items2, hasMore: true, nextCursor: `${at}.${next2}@${started}` };
|
|
566
|
+
if (at + 1 >= ENGAGEMENTS.length)
|
|
567
|
+
return { items: items2, ...last };
|
|
568
|
+
return { items: items2, hasMore: true, nextCursor: `${at + 1}.${since - OVERLAP_MS}.0@${started}` };
|
|
569
|
+
}, "following");
|
|
570
|
+
let rows;
|
|
571
|
+
let more;
|
|
572
|
+
let listedNext = null;
|
|
573
|
+
try {
|
|
574
|
+
if (after === void 0)
|
|
575
|
+
({ rows, more } = await search(caller.post, engagement.type, modifiedSince("hs_lastmodifieddate", spot, sizes.search, engagement.properties)));
|
|
576
|
+
else {
|
|
577
|
+
const body = await caller.get(`/crm/objects/2026-03/${engagement.type}`, {
|
|
578
|
+
limit: sizes.list,
|
|
579
|
+
properties: engagement.properties.join(","),
|
|
580
|
+
archived: false,
|
|
581
|
+
...after ? { after } : {}
|
|
582
|
+
});
|
|
583
|
+
listedNext = nextOf(body);
|
|
584
|
+
more = listedNext !== null;
|
|
585
|
+
rows = resultsOf(body).filter((raw) => {
|
|
586
|
+
const changed = msOf(propertiesOf(raw).hs_lastmodifieddate) ?? msOf(raw.updatedAt);
|
|
587
|
+
return changed === null || changed >= spot.from;
|
|
588
|
+
});
|
|
589
|
+
}
|
|
590
|
+
} catch (error) {
|
|
591
|
+
if (!isCliError(error) || error.code !== "permission_error")
|
|
592
|
+
throw error;
|
|
593
|
+
context?.gap({
|
|
594
|
+
kind: "activities",
|
|
595
|
+
scope: engagement.scope,
|
|
596
|
+
message: `HubSpot refused the ${engagement.type} (${engagement.scope} scope missing); the other activities are read`
|
|
597
|
+
});
|
|
598
|
+
return following([]);
|
|
599
|
+
}
|
|
600
|
+
const ids = rows.flatMap((raw) => id3(raw.id) ?? []);
|
|
601
|
+
const on = /* @__PURE__ */ new Map();
|
|
602
|
+
for (const [to, kind] of ON) {
|
|
603
|
+
let found;
|
|
604
|
+
try {
|
|
605
|
+
found = await associationsOf(caller.post, engagement.type, to, ids);
|
|
606
|
+
} catch (error) {
|
|
607
|
+
if (isCliError(error) && error.code === "permission_error")
|
|
608
|
+
continue;
|
|
609
|
+
throw error;
|
|
610
|
+
}
|
|
611
|
+
for (const [owner, linked] of found)
|
|
612
|
+
on.set(owner, [...on.get(owner) ?? [], ...linked.map((one) => ({ kind, externalId: one.id }))]);
|
|
613
|
+
}
|
|
614
|
+
const items = rows.flatMap((raw) => toActivity(engagement, raw, on.get(String(raw.id)) ?? []) ?? []);
|
|
615
|
+
if (!more)
|
|
616
|
+
return following(items);
|
|
617
|
+
if (after !== void 0)
|
|
618
|
+
return following(items, `${spot.from}.L${listedNext}`);
|
|
619
|
+
const next = nextSpot(spot, rows, "hs_lastmodifieddate", sizes.search);
|
|
620
|
+
return following(items, next ? `${next.from}.${next.offset}` : `${spot.from}.L`);
|
|
621
|
+
}, "readActivities");
|
|
622
|
+
|
|
623
|
+
// dist/crm/source.js
|
|
624
|
+
var { id: id4, text: text4 } = values_exports;
|
|
625
|
+
var OVERLAP_MS2 = 10 * 6e4;
|
|
626
|
+
var LIST_PAGE = 100;
|
|
627
|
+
var PIPELINES = { deal: "deals", lead: "leads" };
|
|
628
|
+
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");
|
|
629
|
+
var refused = /* @__PURE__ */ __name((error) => isCliError(error) && error.code === "permission_error", "refused");
|
|
630
|
+
var unseen = /* @__PURE__ */ __name((error) => isCliError(error) && (error.code === "not_found" || refused(error)), "unseen");
|
|
631
|
+
var pageOf2 = /* @__PURE__ */ __name((page, now) => {
|
|
632
|
+
const cut = (page ?? "").lastIndexOf("@");
|
|
633
|
+
const head = page?.slice(0, cut) ?? "";
|
|
634
|
+
const started = Number(page?.slice(cut + 1));
|
|
635
|
+
if (cut < 0 || !Number.isSafeInteger(started))
|
|
636
|
+
return { after: void 0, spot: void 0, started: now };
|
|
637
|
+
if (head.startsWith("l"))
|
|
638
|
+
return { after: head.slice(1) || void 0, spot: void 0, started };
|
|
639
|
+
const found = /^s(-?\d+)\.(\d+)$/.exec(head);
|
|
640
|
+
if (!found)
|
|
641
|
+
return { after: void 0, spot: void 0, started: now };
|
|
642
|
+
return { after: void 0, spot: { from: Number(found[1]), offset: Number(found[2]) }, started };
|
|
643
|
+
}, "pageOf");
|
|
644
|
+
var asked = /* @__PURE__ */ __name((raw, types) => {
|
|
645
|
+
const held = typeof raw.associations === "object" && raw.associations !== null ? raw.associations : {};
|
|
646
|
+
return {
|
|
647
|
+
...raw,
|
|
648
|
+
associations: { ...Object.fromEntries(types.map((type) => [type, { results: [] }])), ...held }
|
|
649
|
+
};
|
|
650
|
+
}, "asked");
|
|
651
|
+
var liveField = /* @__PURE__ */ __name((kind, field) => ({
|
|
652
|
+
assigned_to: "hubspot_owner_id",
|
|
653
|
+
created_at: OBJECTS[kind].created,
|
|
654
|
+
updated_at: OBJECTS[kind].modified,
|
|
655
|
+
// A company's own `type` property (Prospect, Partner…), as b24 maps `type` to its company type.
|
|
656
|
+
...kind === "organization" ? { type: "type" } : {}
|
|
657
|
+
})[field], "liveField");
|
|
658
|
+
var MAX_PROPERTIES_CHARS = 6e3;
|
|
659
|
+
var fitted = /* @__PURE__ */ __name((own, custom) => {
|
|
660
|
+
const kept = [...own];
|
|
661
|
+
let length = kept.join(",").length;
|
|
662
|
+
const dropped = [];
|
|
663
|
+
for (const name of custom) {
|
|
664
|
+
if (kept.includes(name))
|
|
665
|
+
continue;
|
|
666
|
+
if (length + name.length + 1 > MAX_PROPERTIES_CHARS)
|
|
667
|
+
dropped.push(name);
|
|
668
|
+
else {
|
|
669
|
+
kept.push(name);
|
|
670
|
+
length += name.length + 1;
|
|
671
|
+
}
|
|
672
|
+
}
|
|
673
|
+
return { properties: kept.join(","), dropped };
|
|
674
|
+
}, "fitted");
|
|
675
|
+
var OPERATORS = {
|
|
676
|
+
"=": "EQ",
|
|
677
|
+
"!=": "NEQ",
|
|
678
|
+
">": "GT",
|
|
679
|
+
">=": "GTE",
|
|
680
|
+
"<": "LT",
|
|
681
|
+
"<=": "LTE",
|
|
682
|
+
in: "IN"
|
|
683
|
+
};
|
|
684
|
+
var filtersOf = /* @__PURE__ */ __name((kind, conditions, defined) => conditions.map(({ field, op, value }) => {
|
|
685
|
+
const propertyName = liveField(kind, field) ?? defined.find((one) => one.code === field)?.code;
|
|
686
|
+
if (!propertyName)
|
|
687
|
+
throw new CliError("validation_error", `${SERVICE} cannot filter ${OBJECTS[kind].name} by ${field}`, {
|
|
688
|
+
reason: "query.unsupported-field"
|
|
689
|
+
});
|
|
690
|
+
if (Array.isArray(value))
|
|
691
|
+
return { propertyName, operator: op === "!=" ? "NOT_IN" : "IN", values: value.map(String) };
|
|
692
|
+
return { propertyName, operator: OPERATORS[op], value: String(value) };
|
|
693
|
+
}), "filtersOf");
|
|
694
|
+
var hubspotCrmSource = /* @__PURE__ */ __name((hub, options = {}) => {
|
|
695
|
+
const now = options.now ?? Date.now;
|
|
696
|
+
const listPage = options.page ?? LIST_PAGE;
|
|
697
|
+
const searchPage = options.searchPage ?? SEARCH_PAGE;
|
|
698
|
+
const metered = /* @__PURE__ */ __name((context) => {
|
|
699
|
+
let paid = false;
|
|
700
|
+
const pay = /* @__PURE__ */ __name(() => {
|
|
701
|
+
if (paid)
|
|
702
|
+
context?.spend();
|
|
703
|
+
paid = true;
|
|
704
|
+
}, "pay");
|
|
705
|
+
return {
|
|
706
|
+
get: /* @__PURE__ */ __name((path, query) => {
|
|
707
|
+
pay();
|
|
708
|
+
return hub().get(path, query);
|
|
709
|
+
}, "get"),
|
|
710
|
+
post: /* @__PURE__ */ __name((path, body) => {
|
|
711
|
+
pay();
|
|
712
|
+
return hub().post(path, body);
|
|
713
|
+
}, "post")
|
|
714
|
+
};
|
|
715
|
+
}, "metered");
|
|
716
|
+
const loaded = /* @__PURE__ */ new Map();
|
|
717
|
+
const fields = /* @__PURE__ */ __name((kind, caller) => {
|
|
718
|
+
let found = loaded.get(kind);
|
|
719
|
+
if (!found) {
|
|
720
|
+
found = caller.get(`/crm/properties/2026-03/${OBJECTS[kind].name}`).then((body) => resultsOf(body).flatMap((raw) => toField(raw) ?? [])).catch((error) => {
|
|
721
|
+
if (refused(error))
|
|
722
|
+
return [];
|
|
723
|
+
loaded.delete(kind);
|
|
724
|
+
throw error;
|
|
725
|
+
});
|
|
726
|
+
loaded.set(kind, found);
|
|
727
|
+
}
|
|
728
|
+
return found;
|
|
729
|
+
}, "fields");
|
|
730
|
+
let currency;
|
|
731
|
+
const currencyOf = /* @__PURE__ */ __name((caller) => {
|
|
732
|
+
currency ??= accountDetails(caller).then((details) => details.companyCurrency ?? null, (error) => {
|
|
733
|
+
currency = void 0;
|
|
734
|
+
throw error;
|
|
735
|
+
});
|
|
736
|
+
return currency;
|
|
737
|
+
}, "currencyOf");
|
|
738
|
+
const mapped = /* @__PURE__ */ __name(async (kind, rows, defined, caller) => {
|
|
739
|
+
if (kind === "deal") {
|
|
740
|
+
const bare = rows.some((raw) => {
|
|
741
|
+
const properties = propertiesOf(raw);
|
|
742
|
+
return text4(properties.amount) !== null && text4(properties.deal_currency_code) === null;
|
|
743
|
+
});
|
|
744
|
+
const fallback = bare ? await currencyOf(caller) : null;
|
|
745
|
+
return rows.map((raw) => toDeal(raw, defined, fallback));
|
|
746
|
+
}
|
|
747
|
+
const map = { lead: toLead, person: toPerson, organization: toOrganization }[kind];
|
|
748
|
+
return rows.map((raw) => map(raw, defined));
|
|
749
|
+
}, "mapped");
|
|
750
|
+
const synced = /* @__PURE__ */ __name((kind, caller) => kind === "person" ? Promise.resolve([]) : fields(kind, caller), "synced");
|
|
751
|
+
const propertiesFor = /* @__PURE__ */ __name((type, defined) => [
|
|
752
|
+
.../* @__PURE__ */ new Set([...type.properties, ...defined.map(({ code }) => code)])
|
|
753
|
+
], "propertiesFor");
|
|
754
|
+
const associate = /* @__PURE__ */ __name(async (type, rows, caller, types) => {
|
|
755
|
+
let linked = rows;
|
|
756
|
+
const ids = rows.flatMap((raw) => id4(raw.id) ?? []);
|
|
757
|
+
for (const to of types)
|
|
758
|
+
linked = withAssociations(linked, to, await associationsOf(caller.post, type.name, to, ids));
|
|
759
|
+
return linked;
|
|
760
|
+
}, "associate");
|
|
761
|
+
const everyLink = /* @__PURE__ */ __name((type) => [...type.associations, ...type.linked], "everyLink");
|
|
762
|
+
const getProperties = /* @__PURE__ */ __name((kind, defined, context) => {
|
|
763
|
+
const { properties, dropped } = fitted(OBJECTS[kind].properties, defined.map(({ code }) => code));
|
|
764
|
+
if (dropped.length)
|
|
765
|
+
context?.gap({
|
|
766
|
+
kind,
|
|
767
|
+
message: `${dropped.length} of the account's own ${OBJECTS[kind].name} properties do not fit one request and were not read`
|
|
768
|
+
});
|
|
769
|
+
return properties;
|
|
770
|
+
}, "getProperties");
|
|
771
|
+
const readChanges = /* @__PURE__ */ __name(async (kind, cursor, page, caller, context) => {
|
|
772
|
+
const type = OBJECTS[kind];
|
|
773
|
+
const since = cursor === null ? null : Date.parse(cursor);
|
|
774
|
+
if (since !== null && Number.isNaN(since))
|
|
775
|
+
return { reset: true };
|
|
776
|
+
const { after, spot: saved, started } = pageOf2(page, now());
|
|
777
|
+
const defined = await synced(kind, caller);
|
|
778
|
+
const properties = propertiesFor(type, defined);
|
|
779
|
+
const ended = { hasMore: false, cursor: new Date(started).toISOString() };
|
|
780
|
+
if (since === null) {
|
|
781
|
+
const query = {
|
|
782
|
+
limit: listPage,
|
|
783
|
+
properties: getProperties(kind, defined, context),
|
|
784
|
+
archived: false,
|
|
785
|
+
...type.associations.length ? { associations: type.associations.join(",") } : {},
|
|
786
|
+
...after ? { after } : {}
|
|
787
|
+
};
|
|
788
|
+
const body = await caller.get(`/crm/objects/2026-03/${type.path}`, query);
|
|
789
|
+
const rows2 = await associate(type, resultsOf(body).map((raw) => asked(raw, type.associations)), caller, type.linked);
|
|
790
|
+
const items2 = await mapped(kind, rows2, defined, caller);
|
|
791
|
+
const next2 = nextOf(body);
|
|
792
|
+
return next2 ? { items: items2, hasMore: true, nextCursor: `l${next2}@${started}` } : { items: items2, ...ended };
|
|
793
|
+
}
|
|
794
|
+
const spot = saved ?? { from: since - OVERLAP_MS2, offset: 0 };
|
|
795
|
+
const { rows, more } = await search(caller.post, type.path, modifiedSince(type.modified, spot, searchPage, properties));
|
|
796
|
+
const items = await mapped(kind, await associate(type, rows, caller, everyLink(type)), defined, caller);
|
|
797
|
+
if (!more)
|
|
798
|
+
return { items, ...ended };
|
|
799
|
+
const next = nextSpot(spot, rows, type.modified, searchPage);
|
|
800
|
+
if (next === null)
|
|
801
|
+
return { reset: true };
|
|
802
|
+
return { items, hasMore: true, nextCursor: `s${next.from}.${next.offset}@${started}` };
|
|
803
|
+
}, "readChanges");
|
|
804
|
+
const known = /* @__PURE__ */ __name(async (kind, caller) => fields(kind, caller), "known");
|
|
805
|
+
return {
|
|
806
|
+
provider: "hubspot",
|
|
807
|
+
traits: { kinds: ["organization", "person", "deal", "lead"], removedInChanges: false },
|
|
808
|
+
async pipelines(kind, context) {
|
|
809
|
+
try {
|
|
810
|
+
const body = await metered(context).get(`/crm/pipelines/2026-03/${PIPELINES[kind]}`);
|
|
811
|
+
return resultsOf(body).flatMap((raw) => {
|
|
812
|
+
const pipeline = toPipeline(raw, kind, (stage) => context?.gap({
|
|
813
|
+
kind,
|
|
814
|
+
message: `closed lead stage ${stage}: HubSpot gives no outcome; counted as lost`
|
|
815
|
+
}));
|
|
816
|
+
return pipeline ? [pipeline] : [];
|
|
817
|
+
});
|
|
818
|
+
} catch (error) {
|
|
819
|
+
if (kind === "lead" && refused(error)) {
|
|
820
|
+
context?.gap({ kind: "lead", scope: OBJECTS.lead.scope, message: leadsRefused });
|
|
821
|
+
return [];
|
|
822
|
+
}
|
|
823
|
+
throw scoped(error, OBJECTS[kind].scope);
|
|
824
|
+
}
|
|
825
|
+
},
|
|
826
|
+
async changes(kind, cursor, page, context) {
|
|
827
|
+
try {
|
|
828
|
+
return await readChanges(kind, cursor, page, metered(context), context);
|
|
829
|
+
} catch (error) {
|
|
830
|
+
if (kind === "lead" && refused(error)) {
|
|
831
|
+
context?.gap({ kind: "lead", scope: OBJECTS.lead.scope, message: leadsRefused });
|
|
832
|
+
return { items: [], hasMore: false, cursor: null };
|
|
833
|
+
}
|
|
834
|
+
throw scoped(error, OBJECTS[kind].scope);
|
|
835
|
+
}
|
|
836
|
+
},
|
|
837
|
+
// Any other refusal fails the pass rather than answer no ids, which would mark every stored row deleted
|
|
838
|
+
// (WC-DATA-7). Leads are the exception: an account without Sales Hub Pro never has any, and core holds back a pass
|
|
839
|
+
// that would delete most of a kind until --rescan.
|
|
840
|
+
async ids(kind, page, context) {
|
|
841
|
+
const type = OBJECTS[kind];
|
|
842
|
+
try {
|
|
843
|
+
const body = await metered(context).get(`/crm/objects/2026-03/${type.path}`, {
|
|
844
|
+
limit: listPage,
|
|
845
|
+
properties: "hs_object_id",
|
|
846
|
+
archived: false,
|
|
847
|
+
...page ? { after: page } : {}
|
|
848
|
+
});
|
|
849
|
+
const items = resultsOf(body).flatMap((raw) => id4(raw.id) ?? []);
|
|
850
|
+
const next = nextOf(body);
|
|
851
|
+
return next ? { items, hasMore: true, nextCursor: next } : { items, hasMore: false };
|
|
852
|
+
} catch (error) {
|
|
853
|
+
if (kind === "lead" && refused(error)) {
|
|
854
|
+
context?.gap({ kind: "lead", scope: type.scope, message: leadsRefused });
|
|
855
|
+
return { items: [], hasMore: false };
|
|
856
|
+
}
|
|
857
|
+
throw scoped(error, type.scope);
|
|
858
|
+
}
|
|
859
|
+
},
|
|
860
|
+
async fields(kind, context) {
|
|
861
|
+
return fields(kind, metered(context));
|
|
862
|
+
},
|
|
863
|
+
// Active owners, then the deactivated ones, which `archived=true` lists alone (owners guide).
|
|
864
|
+
async users(context) {
|
|
865
|
+
const caller = metered(context);
|
|
866
|
+
const users = [];
|
|
867
|
+
for (const archived of [false, true]) {
|
|
868
|
+
let after = null;
|
|
869
|
+
do {
|
|
870
|
+
const body = await caller.get("/crm/owners/2026-03", { limit: LIST_PAGE, archived, ...after ? { after } : {} }).catch((error) => {
|
|
871
|
+
throw scoped(error, "crm.objects.owners.read");
|
|
872
|
+
});
|
|
873
|
+
for (const raw of resultsOf(body)) {
|
|
874
|
+
const user = toUser(raw);
|
|
875
|
+
if (user)
|
|
876
|
+
users.push(user);
|
|
877
|
+
}
|
|
878
|
+
after = nextOf(body);
|
|
879
|
+
} while (after);
|
|
880
|
+
}
|
|
881
|
+
return [...new Map(users.map((user) => [user.externalId, user])).values()];
|
|
882
|
+
},
|
|
883
|
+
async list(kind, query, context) {
|
|
884
|
+
const caller = metered(context);
|
|
885
|
+
const type = OBJECTS[kind];
|
|
886
|
+
const defined = await known(kind, caller);
|
|
887
|
+
const filters = filtersOf(kind, query.conditions, defined);
|
|
888
|
+
const properties = propertiesFor(type, defined);
|
|
889
|
+
const page = await walk(crmWindowOf(query), SEARCH_PAGE, async (offset, limit) => {
|
|
890
|
+
const { rows, more } = await search(caller.post, type.path, {
|
|
891
|
+
filters,
|
|
892
|
+
sort: { propertyName: type.created, direction: "DESCENDING" },
|
|
893
|
+
properties,
|
|
894
|
+
limit,
|
|
895
|
+
offset,
|
|
896
|
+
...query.text ? { query: query.text } : {}
|
|
897
|
+
});
|
|
898
|
+
return { rows: await associate(type, rows, caller, everyLink(type)), more };
|
|
899
|
+
});
|
|
900
|
+
return { items: await mapped(kind, page.items, defined, caller), hasMore: page.hasMore };
|
|
901
|
+
},
|
|
902
|
+
async get(kind, externalId, context) {
|
|
903
|
+
if (!/^\d{1,20}$/.test(externalId))
|
|
904
|
+
return null;
|
|
905
|
+
const caller = metered(context);
|
|
906
|
+
const type = OBJECTS[kind];
|
|
907
|
+
const defined = await known(kind, caller);
|
|
908
|
+
let body;
|
|
909
|
+
try {
|
|
910
|
+
body = await caller.get(`/crm/objects/2026-03/${type.path}/${segment(externalId)}`, {
|
|
911
|
+
properties: getProperties(kind, defined, context),
|
|
912
|
+
...type.associations.length ? { associations: type.associations.join(",") } : {}
|
|
913
|
+
});
|
|
914
|
+
} catch (error) {
|
|
915
|
+
if (unseen(error))
|
|
916
|
+
return null;
|
|
917
|
+
throw error;
|
|
918
|
+
}
|
|
919
|
+
if (typeof body !== "object" || body === null)
|
|
920
|
+
return null;
|
|
921
|
+
const rows = await associate(type, [asked(body, type.associations)], caller, type.linked);
|
|
922
|
+
const [record] = await mapped(kind, rows, defined, caller);
|
|
923
|
+
return record ?? null;
|
|
924
|
+
},
|
|
925
|
+
activities: /* @__PURE__ */ __name((since, page, context) => readActivities(metered(context), since, page, context, now, { search: searchPage, list: listPage }), "activities")
|
|
926
|
+
};
|
|
927
|
+
}, "hubspotCrmSource");
|
|
928
|
+
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";
|
|
929
|
+
export {
|
|
930
|
+
MAX_PROPERTIES_CHARS,
|
|
931
|
+
OVERLAP_MS2 as OVERLAP_MS,
|
|
932
|
+
fitted,
|
|
933
|
+
hubspotCrmSource
|
|
934
|
+
};
|