@wirecat/hubspot-cli 0.1.0 → 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 (90) hide show
  1. package/CHANGELOG.md +24 -0
  2. package/README.md +40 -16
  3. package/contracts/wirecat.json +1441 -136
  4. package/dist/bin/hubspot.js +2 -2
  5. package/dist/bundle/{app-server-422MCA7S.js → app-server-GXV2OFML.js} +5 -5
  6. package/dist/bundle/chunk-2UOJ7DLZ.js +46 -0
  7. package/dist/bundle/{chunk-BKXDHU3G.js → chunk-3WLYWRGG.js} +1 -1
  8. package/dist/bundle/{chunk-SAKK2YRU.js → chunk-GPYCBYX5.js} +1 -1
  9. package/dist/bundle/chunk-IJADZW42.js +195 -0
  10. package/dist/bundle/{chunk-2TWQIWWG.js → chunk-LXZ66MCH.js} +2 -2
  11. package/dist/bundle/{chunk-WQBX7XYP.js → chunk-MFNMKHML.js} +807 -519
  12. package/dist/bundle/{chunk-HTAN663T.js → chunk-Q2OLOMHL.js} +1 -1
  13. package/dist/bundle/{chunk-LNV33FDC.js → chunk-TLKEPUAV.js} +4 -4
  14. package/dist/bundle/{chunk-JRCPCVPI.js → chunk-URX6YDUL.js} +2 -2
  15. package/dist/bundle/{chunk-ZBDSHFG4.js → chunk-VOH7S5M4.js} +1301 -1271
  16. package/dist/bundle/{chunk-X7XUX7A4.js → chunk-YMCY7VRE.js} +4 -4
  17. package/dist/bundle/{chunk-VIEYMDBR.js → chunk-Z73OL5HV.js} +1 -1
  18. package/dist/bundle/{dist-MYZZKZJ7.js → dist-7TGU56B2.js} +1 -1
  19. package/dist/bundle/{first-run-RPIJZEDT.js → first-run-UWAFSINQ.js} +1 -1
  20. package/dist/bundle/hubspot.js +2 -2
  21. package/dist/bundle/{program-POG5GHUQ.js → program-XA4C44Z4.js} +173 -40
  22. package/dist/bundle/{server-XJSNF3K5.js → server-ATG5KY7K.js} +2 -2
  23. package/dist/bundle/{server-C3ZHA7AZ.js → server-VNWVVH7A.js} +5 -5
  24. package/dist/bundle/{source-A3SBLHC4.js → source-54HR4IWG.js} +68 -341
  25. package/dist/bundle/{store-CCDNUB6A.js → store-DXWYNVVB.js} +2 -2
  26. package/dist/bundle/{store-maintenance-command-BRCG6MNA.js → store-maintenance-command-J57HCJYY.js} +3 -3
  27. package/dist/bundle/writer-NLLI5YRM.js +79 -0
  28. package/dist/commands/api.d.ts +4 -4
  29. package/dist/commands/api.d.ts.map +1 -1
  30. package/dist/commands/api.js +12 -7
  31. package/dist/commands/api.js.map +1 -1
  32. package/dist/commands/crm-shared.d.ts +2 -2
  33. package/dist/commands/crm-shared.d.ts.map +1 -1
  34. package/dist/commands/crm-shared.js +20 -4
  35. package/dist/commands/crm-shared.js.map +1 -1
  36. package/dist/config.d.ts +46 -8
  37. package/dist/config.d.ts.map +1 -1
  38. package/dist/config.js +137 -12
  39. package/dist/config.js.map +1 -1
  40. package/dist/context.d.ts +2 -2
  41. package/dist/context.d.ts.map +1 -1
  42. package/dist/context.js +1 -1
  43. package/dist/context.js.map +1 -1
  44. package/dist/crm/source.d.ts +7 -2
  45. package/dist/crm/source.d.ts.map +1 -1
  46. package/dist/crm/source.js +26 -29
  47. package/dist/crm/source.js.map +1 -1
  48. package/dist/crm/writer.d.ts +15 -0
  49. package/dist/crm/writer.d.ts.map +1 -0
  50. package/dist/crm/writer.js +199 -0
  51. package/dist/crm/writer.js.map +1 -0
  52. package/dist/generated/manifest.d.ts.map +1 -1
  53. package/dist/generated/manifest.js +6 -1
  54. package/dist/generated/manifest.js.map +1 -1
  55. package/dist/hubspot/transport.d.ts +6 -1
  56. package/dist/hubspot/transport.d.ts.map +1 -1
  57. package/dist/hubspot/transport.js +13 -5
  58. package/dist/hubspot/transport.js.map +1 -1
  59. package/dist/identity.js +3 -3
  60. package/dist/identity.js.map +1 -1
  61. package/dist/program.d.ts.map +1 -1
  62. package/dist/program.js +2 -1
  63. package/dist/program.js.map +1 -1
  64. package/dist/setup/texts.en.json +3 -3
  65. package/dist/setup/texts.es.json +3 -3
  66. package/dist/setup/texts.ru.json +3 -3
  67. package/dist/version.d.ts +1 -1
  68. package/dist/version.js +1 -1
  69. package/package.json +2 -2
  70. package/skills/hubspot-cli/SKILL.md +13 -8
  71. package/skills/hubspot-cli/references/api/api-advanced.md +51 -0
  72. package/skills/hubspot-cli/references/api/api-basic.md +602 -0
  73. package/skills/hubspot-cli/references/api/api-batch.md +575 -0
  74. package/skills/hubspot-cli/references/api.md +3 -2
  75. package/dist/commands/comments.d.ts +0 -3
  76. package/dist/commands/comments.d.ts.map +0 -1
  77. package/dist/commands/comments.js +0 -114
  78. package/dist/commands/comments.js.map +0 -1
  79. package/dist/sample/comments.d.ts +0 -61
  80. package/dist/sample/comments.d.ts.map +0 -1
  81. package/dist/sample/comments.js +0 -39
  82. package/dist/sample/comments.js.map +0 -1
  83. package/dist/sample/records.d.ts +0 -16
  84. package/dist/sample/records.d.ts.map +0 -1
  85. package/dist/sample/records.js +0 -22
  86. package/dist/sample/records.js.map +0 -1
  87. package/dist/sample/transport.d.ts +0 -42
  88. package/dist/sample/transport.d.ts.map +0 -1
  89. package/dist/sample/transport.js +0 -153
  90. package/dist/sample/transport.js.map +0 -1
@@ -1,26 +1,40 @@
1
1
  import { createRequire as __bundleRequire } from "node:module";
2
2
  const require = __bundleRequire(import.meta.url);
3
3
  import {
4
+ accountDetails
5
+ } from "./chunk-2UOJ7DLZ.js";
6
+ import {
7
+ OBJECTS,
4
8
  SERVICE,
5
- accountDetails,
6
- segment
7
- } from "./chunk-WQBX7XYP.js";
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";
8
22
  import "./chunk-DRWWJLI6.js";
9
- import "./chunk-2TWQIWWG.js";
23
+ import "./chunk-LXZ66MCH.js";
10
24
  import "./chunk-X2M6NIQG.js";
11
25
  import "./chunk-W7HM2VGO.js";
12
26
  import "./chunk-B3MANLNK.js";
13
- import "./chunk-JRCPCVPI.js";
14
- import "./chunk-BKXDHU3G.js";
27
+ import "./chunk-URX6YDUL.js";
28
+ import "./chunk-3WLYWRGG.js";
15
29
  import {
16
30
  crmWindowOf,
17
31
  values_exports,
18
32
  walk
19
- } from "./chunk-ZBDSHFG4.js";
33
+ } from "./chunk-VOH7S5M4.js";
20
34
  import "./chunk-2QZK5BEP.js";
21
35
  import "./chunk-NXERIDPJ.js";
22
36
  import "./chunk-WE4UFASG.js";
23
- import "./chunk-SAKK2YRU.js";
37
+ import "./chunk-GPYCBYX5.js";
24
38
  import "./chunk-RR5MX5TM.js";
25
39
  import "./chunk-CWXOXIWS.js";
26
40
  import "./chunk-JLDBMEKZ.js";
@@ -49,7 +63,7 @@ import "./chunk-XRREFEIW.js";
49
63
  import "./chunk-TI46WQXQ.js";
50
64
  import "./chunk-E52JAS35.js";
51
65
  import "./chunk-5GBUCHRU.js";
52
- import "./chunk-X7XUX7A4.js";
66
+ import "./chunk-YMCY7VRE.js";
53
67
  import "./chunk-H3TNVEQX.js";
54
68
  import "./chunk-HC5ZWE5X.js";
55
69
  import "./chunk-QGFX5MXL.js";
@@ -121,296 +135,6 @@ var withAssociations = /* @__PURE__ */ __name((rows, to, found) => rows.map((raw
121
135
  }
122
136
  })), "withAssociations");
123
137
 
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
138
  // dist/crm/search.js
415
139
  var SEARCH_PAGE = 200;
416
140
  var SEARCH_CAP = 1e4;
@@ -447,16 +171,16 @@ var modifiedSince = /* @__PURE__ */ __name((modified, spot, limit, properties) =
447
171
  }), "modifiedSince");
448
172
 
449
173
  // dist/crm/activities.js
450
- var { id: id3, text: text3 } = values_exports;
174
+ var { id: id2, text: text2 } = values_exports;
451
175
  var OVERLAP_MS = 10 * 6e4;
452
176
  var CALL_OPEN = ["CALLING_CRM_USER", "CONNECTING", "IN_PROGRESS", "QUEUED", "RINGING"];
453
177
  var EMAIL_OPEN = ["SCHEDULED", "SENDING"];
454
178
  var COMMON = ["hubspot_owner_id", "hs_timestamp", "hs_createdate", "hs_lastmodifieddate"];
455
179
  var plain = /* @__PURE__ */ __name((value) => {
456
- const html = text3(value);
180
+ const html = text2(value);
457
181
  if (html === null)
458
182
  return null;
459
- return text3(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, "&"));
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, "&"));
460
184
  }, "plain");
461
185
  var CONTACTS_SCOPE = "crm.objects.contacts.read";
462
186
  var ENGAGEMENTS = [
@@ -475,43 +199,43 @@ var ENGAGEMENTS = [
475
199
  kind: "call",
476
200
  scope: CONTACTS_SCOPE,
477
201
  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"),
202
+ subject: /* @__PURE__ */ __name((properties) => text2(properties.hs_call_title) ?? (text2(properties.hs_call_direction) === "INBOUND" ? "incoming call" : "outgoing call"), "subject"),
479
203
  body: /* @__PURE__ */ __name(() => null, "body"),
480
204
  dueAt: /* @__PURE__ */ __name(() => null, "dueAt"),
481
- done: /* @__PURE__ */ __name((properties) => !CALL_OPEN.includes(text3(properties.hs_call_status) ?? ""), "done")
205
+ done: /* @__PURE__ */ __name((properties) => !CALL_OPEN.includes(text2(properties.hs_call_status) ?? ""), "done")
482
206
  },
483
207
  {
484
208
  type: "emails",
485
209
  kind: "email",
486
210
  scope: "sales-email-read",
487
211
  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"),
212
+ subject: /* @__PURE__ */ __name((properties) => text2(properties.hs_email_subject), "subject"),
213
+ body: /* @__PURE__ */ __name((properties) => text2(properties.hs_email_text), "body"),
490
214
  dueAt: /* @__PURE__ */ __name(() => null, "dueAt"),
491
- done: /* @__PURE__ */ __name((properties) => !EMAIL_OPEN.includes(text3(properties.hs_email_status) ?? ""), "done")
215
+ done: /* @__PURE__ */ __name((properties) => !EMAIL_OPEN.includes(text2(properties.hs_email_status) ?? ""), "done")
492
216
  },
493
217
  {
494
218
  type: "meetings",
495
219
  kind: "meeting",
496
220
  scope: CONTACTS_SCOPE,
497
221
  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"),
222
+ subject: /* @__PURE__ */ __name((properties) => text2(properties.hs_meeting_title), "subject"),
499
223
  body: /* @__PURE__ */ __name((properties) => plain(properties.hs_meeting_body), "body"),
500
224
  dueAt: /* @__PURE__ */ __name((properties) => msOf(properties.hs_meeting_start_time), "dueAt"),
501
225
  // "scheduled, completed, rescheduled, no show, and canceled", in prose and lower case
502
226
  // (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")
227
+ done: /* @__PURE__ */ __name((properties) => text2(properties.hs_meeting_outcome)?.toUpperCase() === "COMPLETED", "done")
504
228
  },
505
229
  {
506
230
  type: "tasks",
507
231
  kind: "task",
508
232
  scope: CONTACTS_SCOPE,
509
233
  properties: ["hs_task_subject", "hs_task_body", "hs_task_status", ...COMMON],
510
- subject: /* @__PURE__ */ __name((properties) => text3(properties.hs_task_subject), "subject"),
234
+ subject: /* @__PURE__ */ __name((properties) => text2(properties.hs_task_subject), "subject"),
511
235
  body: /* @__PURE__ */ __name((properties) => plain(properties.hs_task_body), "body"),
512
236
  dueAt: /* @__PURE__ */ __name((properties) => msOf(properties.hs_timestamp), "dueAt"),
513
237
  // 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")
238
+ done: /* @__PURE__ */ __name((properties) => text2(properties.hs_task_status) === "COMPLETED", "done")
515
239
  }
516
240
  ];
517
241
  var ON = [
@@ -521,7 +245,7 @@ var ON = [
521
245
  ["companies", "organization"]
522
246
  ];
523
247
  var toActivity = /* @__PURE__ */ __name((engagement, raw, on) => {
524
- const externalId = id3(raw.id);
248
+ const externalId = id2(raw.id);
525
249
  const properties = propertiesOf(raw);
526
250
  const updatedAt = msOf(properties.hs_lastmodifieddate) ?? msOf(raw.updatedAt);
527
251
  if (!externalId || updatedAt === null)
@@ -534,7 +258,7 @@ var toActivity = /* @__PURE__ */ __name((engagement, raw, on) => {
534
258
  body: engagement.body(properties),
535
259
  dueAt: engagement.dueAt(properties),
536
260
  done: engagement.done(properties),
537
- assignee: id3(properties.hubspot_owner_id),
261
+ assignee: id2(properties.hubspot_owner_id),
538
262
  createdAt: msOf(properties.hs_createdate) ?? msOf(raw.createdAt) ?? updatedAt,
539
263
  updatedAt,
540
264
  on
@@ -597,7 +321,7 @@ var readActivities = /* @__PURE__ */ __name(async (caller, since, page, context,
597
321
  });
598
322
  return following([]);
599
323
  }
600
- const ids = rows.flatMap((raw) => id3(raw.id) ?? []);
324
+ const ids = rows.flatMap((raw) => id2(raw.id) ?? []);
601
325
  const on = /* @__PURE__ */ new Map();
602
326
  for (const [to, kind] of ON) {
603
327
  let found;
@@ -621,7 +345,7 @@ var readActivities = /* @__PURE__ */ __name(async (caller, since, page, context,
621
345
  }, "readActivities");
622
346
 
623
347
  // dist/crm/source.js
624
- var { id: id4, text: text4 } = values_exports;
348
+ var { id: id3, text: text3 } = values_exports;
625
349
  var OVERLAP_MS2 = 10 * 6e4;
626
350
  var LIST_PAGE = 100;
627
351
  var PIPELINES = { deal: "deals", lead: "leads" };
@@ -739,7 +463,7 @@ var hubspotCrmSource = /* @__PURE__ */ __name((hub, options = {}) => {
739
463
  if (kind === "deal") {
740
464
  const bare = rows.some((raw) => {
741
465
  const properties = propertiesOf(raw);
742
- return text4(properties.amount) !== null && text4(properties.deal_currency_code) === null;
466
+ return text3(properties.amount) !== null && text3(properties.deal_currency_code) === null;
743
467
  });
744
468
  const fallback = bare ? await currencyOf(caller) : null;
745
469
  return rows.map((raw) => toDeal(raw, defined, fallback));
@@ -753,7 +477,7 @@ var hubspotCrmSource = /* @__PURE__ */ __name((hub, options = {}) => {
753
477
  ], "propertiesFor");
754
478
  const associate = /* @__PURE__ */ __name(async (type, rows, caller, types) => {
755
479
  let linked = rows;
756
- const ids = rows.flatMap((raw) => id4(raw.id) ?? []);
480
+ const ids = rows.flatMap((raw) => id3(raw.id) ?? []);
757
481
  for (const to of types)
758
482
  linked = withAssociations(linked, to, await associationsOf(caller.post, type.name, to, ids));
759
483
  return linked;
@@ -846,7 +570,7 @@ var hubspotCrmSource = /* @__PURE__ */ __name((hub, options = {}) => {
846
570
  archived: false,
847
571
  ...page ? { after: page } : {}
848
572
  });
849
- const items = resultsOf(body).flatMap((raw) => id4(raw.id) ?? []);
573
+ const items = resultsOf(body).flatMap((raw) => id3(raw.id) ?? []);
850
574
  const next = nextOf(body);
851
575
  return next ? { items, hasMore: true, nextCursor: next } : { items, hasMore: false };
852
576
  } catch (error) {
@@ -899,31 +623,34 @@ var hubspotCrmSource = /* @__PURE__ */ __name((hub, options = {}) => {
899
623
  });
900
624
  return { items: await mapped(kind, page.items, defined, caller), hasMore: page.hasMore };
901
625
  },
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
- },
626
+ get: /* @__PURE__ */ __name((kind, externalId, context) => record(kind, externalId, context), "get"),
627
+ record,
925
628
  activities: /* @__PURE__ */ __name((since, page, context) => readActivities(metered(context), since, page, context, now, { search: searchPage, list: listPage }), "activities")
926
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");
927
654
  }, "hubspotCrmSource");
928
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";
929
656
  export {
@@ -3,8 +3,8 @@ const require = __bundleRequire(import.meta.url);
3
3
  import {
4
4
  PROVIDER,
5
5
  openHubspotStore
6
- } from "./chunk-VIEYMDBR.js";
7
- import "./chunk-X7XUX7A4.js";
6
+ } from "./chunk-Z73OL5HV.js";
7
+ import "./chunk-YMCY7VRE.js";
8
8
  import "./chunk-H3TNVEQX.js";
9
9
  import "./chunk-HC5ZWE5X.js";
10
10
  import "./chunk-QGFX5MXL.js";
@@ -5,9 +5,9 @@ import {
5
5
  buildStems,
6
6
  storeMaintenanceCommands,
7
7
  storeSummary
8
- } from "./chunk-JRCPCVPI.js";
9
- import "./chunk-BKXDHU3G.js";
10
- import "./chunk-ZBDSHFG4.js";
8
+ } from "./chunk-URX6YDUL.js";
9
+ import "./chunk-3WLYWRGG.js";
10
+ import "./chunk-VOH7S5M4.js";
11
11
  import "./chunk-2QZK5BEP.js";
12
12
  import "./chunk-WE4UFASG.js";
13
13
  import "./chunk-RR5MX5TM.js";
@@ -0,0 +1,79 @@
1
+ import { createRequire as __bundleRequire } from "node:module";
2
+ const require = __bundleRequire(import.meta.url);
3
+ import {
4
+ HUBSPOT_WRITES,
5
+ hubspotCrmWriter
6
+ } from "./chunk-IJADZW42.js";
7
+ import "./chunk-MFNMKHML.js";
8
+ import "./chunk-DRWWJLI6.js";
9
+ import "./chunk-LXZ66MCH.js";
10
+ import "./chunk-X2M6NIQG.js";
11
+ import "./chunk-W7HM2VGO.js";
12
+ import "./chunk-B3MANLNK.js";
13
+ import "./chunk-URX6YDUL.js";
14
+ import "./chunk-3WLYWRGG.js";
15
+ import "./chunk-VOH7S5M4.js";
16
+ import "./chunk-2QZK5BEP.js";
17
+ import "./chunk-NXERIDPJ.js";
18
+ import "./chunk-WE4UFASG.js";
19
+ import "./chunk-GPYCBYX5.js";
20
+ import "./chunk-RR5MX5TM.js";
21
+ import "./chunk-CWXOXIWS.js";
22
+ import "./chunk-JLDBMEKZ.js";
23
+ import "./chunk-E5WLE7BM.js";
24
+ import "./chunk-N2XADGL4.js";
25
+ import "./chunk-FOZYMDRL.js";
26
+ import "./chunk-QU25DA5N.js";
27
+ import "./chunk-TKVL2C3B.js";
28
+ import "./chunk-O55RWNSH.js";
29
+ import "./chunk-24ERVFJP.js";
30
+ import "./chunk-NWHEHV3K.js";
31
+ import "./chunk-7ELMWE3P.js";
32
+ import "./chunk-PVKF24ZW.js";
33
+ import "./chunk-NUU4WZVL.js";
34
+ import "./chunk-2VGZRYEH.js";
35
+ import "./chunk-W53EJOFQ.js";
36
+ import "./chunk-RMIYKDUL.js";
37
+ import "./chunk-LOBVOGOE.js";
38
+ import "./chunk-36ITRDYY.js";
39
+ import "./chunk-C32AKHTY.js";
40
+ import "./chunk-FTFV3HFW.js";
41
+ import "./chunk-CLAN3FES.js";
42
+ import "./chunk-UUMUL4L3.js";
43
+ import "./chunk-SDQGB4KB.js";
44
+ import "./chunk-XRREFEIW.js";
45
+ import "./chunk-TI46WQXQ.js";
46
+ import "./chunk-E52JAS35.js";
47
+ import "./chunk-5GBUCHRU.js";
48
+ import "./chunk-YMCY7VRE.js";
49
+ import "./chunk-H3TNVEQX.js";
50
+ import "./chunk-HC5ZWE5X.js";
51
+ import "./chunk-QGFX5MXL.js";
52
+ import "./chunk-EH6ZEJGT.js";
53
+ import "./chunk-O3DYRCIT.js";
54
+ import "./chunk-2VGD63G6.js";
55
+ import "./chunk-5A6ZYNAQ.js";
56
+ import "./chunk-43EKCUBJ.js";
57
+ import "./chunk-HZRQLAHO.js";
58
+ import "./chunk-QJW35N5V.js";
59
+ import "./chunk-IMJQRPLN.js";
60
+ import "./chunk-DSP36YHQ.js";
61
+ import "./chunk-5K7QLJMM.js";
62
+ import "./chunk-FPUGMDJV.js";
63
+ import "./chunk-D72URWJE.js";
64
+ import "./chunk-DBEQI5YM.js";
65
+ import "./chunk-PPHBRESD.js";
66
+ import "./chunk-65TWQ7BV.js";
67
+ import "./chunk-HCAZV5NP.js";
68
+ import "./chunk-DFCHHR5M.js";
69
+ import "./chunk-TBJYLC5K.js";
70
+ import "./chunk-TOSCB4SO.js";
71
+ import "./chunk-MVA5HVKL.js";
72
+ import "./chunk-Y5E2WNWB.js";
73
+ import "./chunk-DB2XKHI4.js";
74
+ import "./chunk-TP7GDWVF.js";
75
+ import "./chunk-ZVVMGPBJ.js";
76
+ export {
77
+ HUBSPOT_WRITES,
78
+ hubspotCrmWriter
79
+ };
@@ -1,9 +1,9 @@
1
1
  import type { Command } from "commander";
2
2
  /**
3
- * HubSpot's CRM API from its spec: `api list`, `api show` and one command per read operation, through cli-core's
4
- * shared group. This release only reads, so a write is not offered and `api show` says why. The requests keep the
5
- * account's pace beside the CRM commands, the token is the profile's own, and a refusal reads as the CRM commands'
6
- * do: the scope a 403 names, the daily limit and its midnight.
3
+ * HubSpot's CRM API from its spec: `api list`, `api show` and one command per operation, through cli-core's shared
4
+ * group, each write and delete behind its keys. The requests keep the account's pace beside the CRM commands, the token
5
+ * is the profile's own, and a refusal reads as the CRM commands' do: the scope a 403 names, the daily limit and its
6
+ * midnight, and a write HubSpot failed during as `outcome_unknown`.
7
7
  */
8
8
  export declare const apiCommand: () => Command;
9
9
  //# sourceMappingURL=api.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"api.d.ts","sourceRoot":"","sources":["../../src/commands/api.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AAiCxC;;;;;GAKG;AACH,eAAO,MAAM,UAAU,QAAO,OA8B7B,CAAA"}
1
+ {"version":3,"file":"api.d.ts","sourceRoot":"","sources":["../../src/commands/api.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AAiCxC;;;;;GAKG;AACH,eAAO,MAAM,UAAU,QAAO,OAmC7B,CAAA"}