@wirecat/hubspot-cli 0.0.0-stage → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +53 -0
- package/LICENSE +204 -0
- package/README.md +280 -2
- package/contracts/wirecat.json +3270 -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-GXV2OFML.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-2UOJ7DLZ.js +46 -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-3WLYWRGG.js +1395 -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-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-GPYCBYX5.js +218 -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-HZRQLAHO.js +16 -0
- package/dist/bundle/chunk-IJADZW42.js +195 -0
- package/dist/bundle/chunk-IMJQRPLN.js +92 -0
- package/dist/bundle/chunk-JLDBMEKZ.js +106 -0
- package/dist/bundle/chunk-LOBVOGOE.js +66 -0
- package/dist/bundle/chunk-LXZ66MCH.js +1328 -0
- package/dist/bundle/chunk-MFNMKHML.js +26462 -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-Q2OLOMHL.js +4045 -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-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-TLKEPUAV.js +786 -0
- package/dist/bundle/chunk-TOSCB4SO.js +1227 -0
- package/dist/bundle/chunk-TP7GDWVF.js +6848 -0
- package/dist/bundle/chunk-URX6YDUL.js +9393 -0
- package/dist/bundle/chunk-UUMUL4L3.js +72 -0
- package/dist/bundle/chunk-VOH7S5M4.js +40963 -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-X2M6NIQG.js +18 -0
- package/dist/bundle/chunk-XRREFEIW.js +372 -0
- package/dist/bundle/chunk-Y5E2WNWB.js +35 -0
- package/dist/bundle/chunk-YMCY7VRE.js +1846 -0
- package/dist/bundle/chunk-Z73OL5HV.js +41 -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-7TGU56B2.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-UWAFSINQ.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-XA4C44Z4.js +9374 -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-ATG5KY7K.js +207 -0
- package/dist/bundle/server-VNWVVH7A.js +77 -0
- package/dist/bundle/source-54HR4IWG.js +661 -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-DXWYNVVB.js +32 -0
- package/dist/bundle/store-maintenance-command-J57HCJYY.js +68 -0
- package/dist/bundle/writer-NLLI5YRM.js +79 -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 +70 -0
- package/dist/commands/api.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 +109 -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 +60 -0
- package/dist/config.d.ts.map +1 -0
- package/dist/config.js +153 -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 +37 -0
- package/dist/crm/source.d.ts.map +1 -0
- package/dist/crm/source.js +366 -0
- package/dist/crm/source.js.map +1 -0
- package/dist/crm/writer.d.ts +15 -0
- package/dist/crm/writer.d.ts.map +1 -0
- package/dist/crm/writer.js +199 -0
- package/dist/crm/writer.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 +6504 -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 +81 -0
- package/dist/hubspot/transport.d.ts.map +1 -0
- package/dist/hubspot/transport.js +354 -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 +78 -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/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 +102 -0
- package/skills/hubspot-cli/references/api/api-advanced.md +51 -0
- package/skills/hubspot-cli/references/api/api-basic.md +1064 -0
- package/skills/hubspot-cli/references/api/api-batch.md +724 -0
- package/skills/hubspot-cli/references/api/api-search.md +147 -0
- package/skills/hubspot-cli/references/api.md +16 -0
|
@@ -0,0 +1,193 @@
|
|
|
1
|
+
import { createRequire as __bundleRequire } from "node:module";
|
|
2
|
+
const require = __bundleRequire(import.meta.url);
|
|
3
|
+
import {
|
|
4
|
+
stringWidth,
|
|
5
|
+
wrapAnsi
|
|
6
|
+
} from "./chunk-EH6ZEJGT.js";
|
|
7
|
+
import {
|
|
8
|
+
singleLine,
|
|
9
|
+
visibleControls
|
|
10
|
+
} from "./chunk-DB2XKHI4.js";
|
|
11
|
+
import {
|
|
12
|
+
__name
|
|
13
|
+
} from "./chunk-ZVVMGPBJ.js";
|
|
14
|
+
|
|
15
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.687.0_@wirecat+cli-base@0.109.0_commander@15.0.0_esbuild@0.28.2_typ_3e6248e31e5b79d53006284373ddef70/node_modules/@wirecat/cli-core/dist/render/messages.js
|
|
16
|
+
import { styleText } from "node:util";
|
|
17
|
+
var TIME_WIDTH = 8;
|
|
18
|
+
var INDENT = " ".repeat(TIME_WIDTH + 2);
|
|
19
|
+
var MIN_WIDTH = 40;
|
|
20
|
+
var SENDER_COLOURS = ["green", "yellow", "magenta", "blue", "red"];
|
|
21
|
+
var renderMessages = /* @__PURE__ */ __name((messages, options = {}) => {
|
|
22
|
+
if (messages.length === 0)
|
|
23
|
+
return "(nothing)";
|
|
24
|
+
const day = dayFormatter(options);
|
|
25
|
+
const paint = painter(options);
|
|
26
|
+
let previous;
|
|
27
|
+
const blocks = [];
|
|
28
|
+
for (const message of messages) {
|
|
29
|
+
const date = day(message.timestamp);
|
|
30
|
+
if (date !== previous)
|
|
31
|
+
blocks.push(paint("dim", `\u2500\u2500 ${date} \u2500\u2500`));
|
|
32
|
+
previous = date;
|
|
33
|
+
blocks.push(renderMessage(message, options));
|
|
34
|
+
}
|
|
35
|
+
return blocks.join("\n\n");
|
|
36
|
+
}, "renderMessages");
|
|
37
|
+
var renderMessage = /* @__PURE__ */ __name((message, options = {}) => {
|
|
38
|
+
const paint = painter(options);
|
|
39
|
+
const width = Math.max(MIN_WIDTH, options.width ?? 80);
|
|
40
|
+
const room = width - INDENT.length;
|
|
41
|
+
const time = timeFormatter(options);
|
|
42
|
+
const verbosity = options.verbosity ?? 0;
|
|
43
|
+
const chat = "chatTitle" in message ? paint("dim", ` \xB7 ${singleLine(message.chatTitle ?? message.chatId)}`) : "";
|
|
44
|
+
const mark = "anchor" in message && message.anchor ? paint("bold", " \u25C0") : "";
|
|
45
|
+
const lines = [`${paint("dim", time(message.timestamp))} ${senderOf(message, options)}${chat}${mark}`];
|
|
46
|
+
const body = /* @__PURE__ */ __name((text) => wrapAnsi(visibleControls(text), room, { hard: true }).split("\n"), "body");
|
|
47
|
+
const email = message.email;
|
|
48
|
+
if (email)
|
|
49
|
+
lines.push(paint("dim", mailLine(email)));
|
|
50
|
+
if (message.replyTo)
|
|
51
|
+
lines.push(paint("dim", preview("\u21B3", message.replyTo, room, options)));
|
|
52
|
+
if (message.forwardedFrom) {
|
|
53
|
+
lines.push(paint("dim", `\u21AA ${nameOf(message.forwardedFrom, options)}`));
|
|
54
|
+
if (message.forwardedFrom.text)
|
|
55
|
+
for (const line of body(message.forwardedFrom.text))
|
|
56
|
+
lines.push(line);
|
|
57
|
+
lines.push(...attachmentLines(message.forwardedFrom.attachments, paint, options));
|
|
58
|
+
}
|
|
59
|
+
if (message.text)
|
|
60
|
+
for (const line of body(message.text))
|
|
61
|
+
lines.push(line);
|
|
62
|
+
lines.push(...attachmentLines(message.attachments, paint, options));
|
|
63
|
+
if (message.reactions && message.reactions.total > 0)
|
|
64
|
+
lines.push(paint("dim", reactionLine(message.reactions)));
|
|
65
|
+
if (message.editedAt)
|
|
66
|
+
lines.push(paint("dim", `edited ${editedAt(message, options)}`));
|
|
67
|
+
if (verbosity >= 1) {
|
|
68
|
+
const fields = [
|
|
69
|
+
["message", message.id],
|
|
70
|
+
["sender", message.senderId],
|
|
71
|
+
["chat", message.chatId],
|
|
72
|
+
["reply to", message.replyTo?.id ?? message.replyToId],
|
|
73
|
+
["thread", message.threadId],
|
|
74
|
+
["forward of", message.forwardedFrom?.id],
|
|
75
|
+
...message.attachments.map((a) => ["link", a.url])
|
|
76
|
+
];
|
|
77
|
+
if (verbosity >= 2) {
|
|
78
|
+
fields.push(["provider", options.provider], ["profile", options.profile], ["sent", message.timestamp], ["edited", message.editedAt], ["outgoing", message.outgoing === null ? "unknown" : String(message.outgoing)], ...message.attachments.map((a) => ["attachment", JSON.stringify(a)]), ["metadata", message.providerMetadata && JSON.stringify(message.providerMetadata)]);
|
|
79
|
+
}
|
|
80
|
+
const shown = fields.filter((field) => typeof field[1] === "string");
|
|
81
|
+
const label = Math.max(...shown.map(([key]) => key.length));
|
|
82
|
+
lines.push("", ...shown.map(([key, value]) => paint("dim", `${key.padEnd(label)} ${singleLine(value)}`)));
|
|
83
|
+
}
|
|
84
|
+
return lines.map((line, index) => index === 0 || line === "" ? line : `${INDENT}${line}`).join("\n");
|
|
85
|
+
}, "renderMessage");
|
|
86
|
+
var mailLine = /* @__PURE__ */ __name(({ to, cc, labels }) => {
|
|
87
|
+
const names = /* @__PURE__ */ __name((people) => people.map(({ name, address }) => singleLine(name ?? address)).join(", "), "names");
|
|
88
|
+
return [to.length ? `to ${names(to)}` : "", cc.length ? `cc ${names(cc)}` : "", labels.join(", ")].filter(Boolean).join(" \xB7 ");
|
|
89
|
+
}, "mailLine");
|
|
90
|
+
var painter = /* @__PURE__ */ __name(({ color = false }) => (style, text) => color ? styleText(style, text, { validateStream: false }) : text, "painter");
|
|
91
|
+
var senderOf = /* @__PURE__ */ __name((message, options) => {
|
|
92
|
+
const paint = painter(options);
|
|
93
|
+
if (message.outgoing === true)
|
|
94
|
+
return paint(["bold", "cyan"], you(options));
|
|
95
|
+
const name = nameOf(message, options);
|
|
96
|
+
if (!options.senderColors)
|
|
97
|
+
return paint("bold", name);
|
|
98
|
+
const colour = SENDER_COLOURS[hash(message.senderId ?? name) % SENDER_COLOURS.length] ?? "green";
|
|
99
|
+
return paint(["bold", colour], name);
|
|
100
|
+
}, "senderOf");
|
|
101
|
+
var nameOf = /* @__PURE__ */ __name(({ senderName, senderId, outgoing }, options) => outgoing === true ? you(options) : singleLine(senderName ?? senderId ?? "unknown"), "nameOf");
|
|
102
|
+
var DEFAULT_LOCALE = "ru-RU";
|
|
103
|
+
var you = /* @__PURE__ */ __name(({ locale = DEFAULT_LOCALE }) => locale.startsWith("ru") ? "\u0432\u044B" : "you", "you");
|
|
104
|
+
var hash = /* @__PURE__ */ __name((value) => [...value].reduce((sum, char) => sum * 31 + char.charCodeAt(0) >>> 0, 7), "hash");
|
|
105
|
+
var preview = /* @__PURE__ */ __name((mark, quoted, room, options) => {
|
|
106
|
+
const text = singleLine(quoted.text.split("\n")[0] ?? "") || (quoted.attachments[0] ? `\u{1F4CE} ${quoted.attachments[0].kind}` : "");
|
|
107
|
+
const line = text ? `${mark} ${nameOf(quoted, options)}: ${text}` : `${mark} message ${quoted.id}`;
|
|
108
|
+
if (stringWidth(line) <= room)
|
|
109
|
+
return line;
|
|
110
|
+
return `${wrapAnsi(line, room - 1, { hard: true }).split("\n")[0]}\u2026`;
|
|
111
|
+
}, "preview");
|
|
112
|
+
var attachmentLines = /* @__PURE__ */ __name((attachments, paint, options) => {
|
|
113
|
+
const link = /* @__PURE__ */ __name((label, raw) => {
|
|
114
|
+
if (raw === void 0)
|
|
115
|
+
return label;
|
|
116
|
+
const url = singleLine(raw);
|
|
117
|
+
return options.color ? `\x1B]8;;${url}\x07${label}\x1B]8;;\x07` : `${label} ${url}`;
|
|
118
|
+
}, "link");
|
|
119
|
+
let number = 0;
|
|
120
|
+
const keyboard = attachments.flatMap((attachment) => attachment.buttons ?? []).map((row) => paint("dim", row.map((button) => link(`[${++number} ${singleLine(button.text)}]`, button.url)).join(" ")));
|
|
121
|
+
const polls = attachments.flatMap((attachment) => attachment.poll ? pollLines(attachment.poll) : []);
|
|
122
|
+
const cards = attachments.flatMap(({ contact }) => contact ? [
|
|
123
|
+
paint("dim", `\u{1F464} ${[contact.name, contact.phone].flatMap((part) => part ? [singleLine(part)] : []).join(" \xB7 ")}`)
|
|
124
|
+
] : []);
|
|
125
|
+
const groups = /* @__PURE__ */ new Map();
|
|
126
|
+
for (const attachment of attachments) {
|
|
127
|
+
if (attachment.buttons || attachment.poll || attachment.contact)
|
|
128
|
+
continue;
|
|
129
|
+
const key = singleLine(attachment.name ?? attachment.title ?? attachment.kind);
|
|
130
|
+
groups.set(key, [...groups.get(key) ?? [], attachment]);
|
|
131
|
+
}
|
|
132
|
+
const files = [...groups].map(([label, same]) => {
|
|
133
|
+
const first = same[0];
|
|
134
|
+
const size = first?.size === void 0 ? "" : ` \xB7 ${megabytes(first.size)}`;
|
|
135
|
+
if (same.length === 1)
|
|
136
|
+
return paint("dim", `\u{1F4CE} ${link(`${label}${size}`, first?.url)}`);
|
|
137
|
+
const each = same.map((attachment, index) => link(String(index + 1), attachment.url)).join(" ");
|
|
138
|
+
return paint("dim", `\u{1F4CE} ${label} \xD7${same.length} ${each}`);
|
|
139
|
+
});
|
|
140
|
+
return [...polls, ...cards, ...files, ...keyboard];
|
|
141
|
+
}, "attachmentLines");
|
|
142
|
+
var pollLines = /* @__PURE__ */ __name((poll) => {
|
|
143
|
+
const kind = [
|
|
144
|
+
poll.closed ? "closed" : "",
|
|
145
|
+
poll.multiple ? "several answers" : "",
|
|
146
|
+
poll.anonymous ? "anonymous" : "",
|
|
147
|
+
poll.quiz ? "quiz" : ""
|
|
148
|
+
].filter(Boolean);
|
|
149
|
+
const count = /* @__PURE__ */ __name((voters) => voters === null ? "?" : String(voters), "count");
|
|
150
|
+
return [
|
|
151
|
+
`\u{1F4CA} ${visibleControls(poll.question)}`,
|
|
152
|
+
...poll.answers.map((answer) => ` [${answer.id}] ${visibleControls(answer.text)} \u2014 ${count(answer.voters)}${answer.chosen ? " \u2713" : ""}`),
|
|
153
|
+
` ${[`${count(poll.voters)} voted`, ...kind].join(" \xB7 ")}`
|
|
154
|
+
];
|
|
155
|
+
}, "pollLines");
|
|
156
|
+
var megabytes = /* @__PURE__ */ __name((bytes) => bytes >= 1e6 ? `${Math.round(bytes / 1e6)} MB` : `${Math.max(1, Math.round(bytes / 1e3))} KB`, "megabytes");
|
|
157
|
+
var parts = /* @__PURE__ */ __name((format, iso) => Object.fromEntries(format.formatToParts(new Date(iso)).map(({ type, value }) => [type, value])), "parts");
|
|
158
|
+
var timeFormatter = /* @__PURE__ */ __name(({ timeZone }) => {
|
|
159
|
+
const format = new Intl.DateTimeFormat("en-GB", {
|
|
160
|
+
hour: "2-digit",
|
|
161
|
+
minute: "2-digit",
|
|
162
|
+
second: "2-digit",
|
|
163
|
+
hourCycle: "h23",
|
|
164
|
+
...timeZone ? { timeZone } : {}
|
|
165
|
+
});
|
|
166
|
+
return (iso) => {
|
|
167
|
+
const { hour, minute, second } = parts(format, iso);
|
|
168
|
+
return `${hour}:${minute}:${second}`;
|
|
169
|
+
};
|
|
170
|
+
}, "timeFormatter");
|
|
171
|
+
var dayFormatter = /* @__PURE__ */ __name(({ locale = DEFAULT_LOCALE, timeZone }) => {
|
|
172
|
+
const format = new Intl.DateTimeFormat(locale, {
|
|
173
|
+
day: "numeric",
|
|
174
|
+
month: "long",
|
|
175
|
+
year: "numeric",
|
|
176
|
+
...timeZone ? { timeZone } : {}
|
|
177
|
+
});
|
|
178
|
+
return (iso) => format.format(new Date(iso)).replace(/\s*г\.$/, "");
|
|
179
|
+
}, "dayFormatter");
|
|
180
|
+
var reactionLine = /* @__PURE__ */ __name(({ counts, mine }) => {
|
|
181
|
+
const shown = counts.map(({ reaction, count }) => `${singleLine(reaction)} ${count}`).join(" ");
|
|
182
|
+
return mine ? `${shown} (you: ${singleLine(mine)})` : shown;
|
|
183
|
+
}, "reactionLine");
|
|
184
|
+
var editedAt = /* @__PURE__ */ __name((message, options) => {
|
|
185
|
+
const edited = message.editedAt ?? message.timestamp;
|
|
186
|
+
const time = timeFormatter(options)(edited);
|
|
187
|
+
const day = dayFormatter(options);
|
|
188
|
+
return day(edited) === day(message.timestamp) ? time : `${day(edited)} ${time}`;
|
|
189
|
+
}, "editedAt");
|
|
190
|
+
|
|
191
|
+
export {
|
|
192
|
+
renderMessages
|
|
193
|
+
};
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
import { createRequire as __bundleRequire } from "node:module";
|
|
2
|
+
const require = __bundleRequire(import.meta.url);
|
|
3
|
+
import {
|
|
4
|
+
PRAGMAS
|
|
5
|
+
} from "./chunk-DFCHHR5M.js";
|
|
6
|
+
import {
|
|
7
|
+
CliError
|
|
8
|
+
} from "./chunk-DB2XKHI4.js";
|
|
9
|
+
import {
|
|
10
|
+
__name
|
|
11
|
+
} from "./chunk-ZVVMGPBJ.js";
|
|
12
|
+
|
|
13
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.687.0_@wirecat+cli-base@0.109.0_commander@15.0.0_esbuild@0.28.2_typ_3e6248e31e5b79d53006284373ddef70/node_modules/@wirecat/cli-core/dist/store/sqlite-warning.js
|
|
14
|
+
var SQLITE_WARNING = "SQLite is an experimental feature";
|
|
15
|
+
var quieted = /* @__PURE__ */ new WeakSet();
|
|
16
|
+
var quietSqliteWarning = /* @__PURE__ */ __name((host = process) => {
|
|
17
|
+
if (quieted.has(host))
|
|
18
|
+
return;
|
|
19
|
+
quieted.add(host);
|
|
20
|
+
const emit = host.emitWarning;
|
|
21
|
+
host.emitWarning = function(warning, ...rest) {
|
|
22
|
+
if (isSqliteWarning(warning, rest[0]))
|
|
23
|
+
return;
|
|
24
|
+
return Reflect.apply(emit, this, [warning, ...rest]);
|
|
25
|
+
};
|
|
26
|
+
}, "quietSqliteWarning");
|
|
27
|
+
var isSqliteWarning = /* @__PURE__ */ __name((warning, options) => {
|
|
28
|
+
const type = typeof options === "string" ? options : options?.type;
|
|
29
|
+
const name = typeof warning === "string" ? type : warning.name;
|
|
30
|
+
const message = typeof warning === "string" ? warning : warning.message;
|
|
31
|
+
return name === "ExperimentalWarning" && message.startsWith(SQLITE_WARNING);
|
|
32
|
+
}, "isSqliteWarning");
|
|
33
|
+
|
|
34
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.687.0_@wirecat+cli-base@0.109.0_commander@15.0.0_esbuild@0.28.2_typ_3e6248e31e5b79d53006284373ddef70/node_modules/@wirecat/cli-core/dist/store/open.js
|
|
35
|
+
var openCache = /* @__PURE__ */ __name(async (path) => {
|
|
36
|
+
const database = await openFile(path);
|
|
37
|
+
try {
|
|
38
|
+
database.exec(PRAGMAS);
|
|
39
|
+
} catch (error) {
|
|
40
|
+
database.close();
|
|
41
|
+
throw error;
|
|
42
|
+
}
|
|
43
|
+
return database;
|
|
44
|
+
}, "openCache");
|
|
45
|
+
var openFile = /* @__PURE__ */ __name((path) => "Bun" in globalThis ? openUnderBun(path) : openUnderNode(path), "openFile");
|
|
46
|
+
var openUnderBun = /* @__PURE__ */ __name(async (path) => {
|
|
47
|
+
const { openWithBunSqlite } = await import("./bun-sqlite-IX3XYA5F.js");
|
|
48
|
+
return await openWithBunSqlite(path);
|
|
49
|
+
}, "openUnderBun");
|
|
50
|
+
var openUnderNode = /* @__PURE__ */ __name(async (path) => {
|
|
51
|
+
quietSqliteWarning();
|
|
52
|
+
const { openWithNodeSqlite } = await import("./node-sqlite-P3O7XN7Q.js");
|
|
53
|
+
return openWithNodeSqlite(path);
|
|
54
|
+
}, "openUnderNode");
|
|
55
|
+
var runtime = /* @__PURE__ */ __name(() => {
|
|
56
|
+
const bun = globalThis.Bun;
|
|
57
|
+
return bun ? `Bun ${bun.version}` : `Node ${process.versions.node}`;
|
|
58
|
+
}, "runtime");
|
|
59
|
+
var CAPABILITY_STATEMENTS = [
|
|
60
|
+
`CREATE VIRTUAL TABLE temp.capability_words USING fts5(a, content = '', contentless_delete = 1,
|
|
61
|
+
tokenize = 'unicode61 remove_diacritics 2')`,
|
|
62
|
+
"CREATE VIRTUAL TABLE temp.capability_text USING fts5(a, tokenize = 'trigram')",
|
|
63
|
+
"DROP TABLE temp.capability_words",
|
|
64
|
+
"DROP TABLE temp.capability_text"
|
|
65
|
+
];
|
|
66
|
+
var assertStoreCapable = /* @__PURE__ */ __name((database, on = runtime()) => {
|
|
67
|
+
try {
|
|
68
|
+
for (const statement of CAPABILITY_STATEMENTS)
|
|
69
|
+
database.exec(statement);
|
|
70
|
+
} catch (error) {
|
|
71
|
+
const version = String(database.prepare("SELECT sqlite_version() AS version").get()?.version);
|
|
72
|
+
const remedy = on.startsWith("Bun") ? "Run it under Node 22.16 or newer instead" : "Update Node to 22.16 or newer, or run it under Bun";
|
|
73
|
+
throw new CliError("configuration_error", `the message store needs full-text search that this SQLite (${version}, ${on}) does not have. ${remedy}.`, { sqlite: version, runtime: on, cause: error instanceof Error ? error.message : String(error) });
|
|
74
|
+
}
|
|
75
|
+
}, "assertStoreCapable");
|
|
76
|
+
var capable;
|
|
77
|
+
var storeCapable = /* @__PURE__ */ __name(() => {
|
|
78
|
+
capable ??= openCache(":memory:").then((database) => {
|
|
79
|
+
try {
|
|
80
|
+
assertStoreCapable(database);
|
|
81
|
+
} finally {
|
|
82
|
+
database.close();
|
|
83
|
+
}
|
|
84
|
+
});
|
|
85
|
+
return capable;
|
|
86
|
+
}, "storeCapable");
|
|
87
|
+
|
|
88
|
+
export {
|
|
89
|
+
quietSqliteWarning,
|
|
90
|
+
openCache,
|
|
91
|
+
openFile,
|
|
92
|
+
CAPABILITY_STATEMENTS,
|
|
93
|
+
assertStoreCapable,
|
|
94
|
+
storeCapable
|
|
95
|
+
};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { createRequire as __bundleRequire } from "node:module";
|
|
2
|
+
const require = __bundleRequire(import.meta.url);
|
|
3
|
+
import {
|
|
4
|
+
__name
|
|
5
|
+
} from "./chunk-ZVVMGPBJ.js";
|
|
6
|
+
|
|
7
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.687.0_@wirecat+cli-base@0.109.0_commander@15.0.0_esbuild@0.28.2_typ_3e6248e31e5b79d53006284373ddef70/node_modules/@wirecat/cli-core/dist/store/normalize.js
|
|
8
|
+
var NORMALIZER_VERSION = 1;
|
|
9
|
+
var fold = /* @__PURE__ */ __name((text) => text.normalize("NFKD").replace(new RegExp("\\p{M}+", "gu"), "").normalize("NFC").toLowerCase(), "fold");
|
|
10
|
+
var normalize = /* @__PURE__ */ __name((text) => fold(text).replace(new RegExp("\\p{Cc}", "gu"), " ").replace(/\s+/gu, " ").trim(), "normalize");
|
|
11
|
+
|
|
12
|
+
export {
|
|
13
|
+
NORMALIZER_VERSION,
|
|
14
|
+
fold,
|
|
15
|
+
normalize
|
|
16
|
+
};
|
|
@@ -0,0 +1,195 @@
|
|
|
1
|
+
import { createRequire as __bundleRequire } from "node:module";
|
|
2
|
+
const require = __bundleRequire(import.meta.url);
|
|
3
|
+
import {
|
|
4
|
+
OBJECTS,
|
|
5
|
+
SERVICE,
|
|
6
|
+
segment
|
|
7
|
+
} from "./chunk-MFNMKHML.js";
|
|
8
|
+
import {
|
|
9
|
+
foldFieldName,
|
|
10
|
+
values_exports
|
|
11
|
+
} from "./chunk-VOH7S5M4.js";
|
|
12
|
+
import {
|
|
13
|
+
CliError,
|
|
14
|
+
isCliError
|
|
15
|
+
} from "./chunk-DB2XKHI4.js";
|
|
16
|
+
import {
|
|
17
|
+
__name
|
|
18
|
+
} from "./chunk-ZVVMGPBJ.js";
|
|
19
|
+
|
|
20
|
+
// dist/crm/writer.js
|
|
21
|
+
var HUBSPOT_WRITES = {
|
|
22
|
+
kinds: ["deal", "person", "organization"],
|
|
23
|
+
verbs: ["create", "update", "move", "close", "remove"],
|
|
24
|
+
idempotent: false
|
|
25
|
+
};
|
|
26
|
+
var OWN = {
|
|
27
|
+
deal: new Set(["dealname", "pipeline", "dealstage", "amount", "deal_currency_code", "closedate", "hubspot_owner_id"].map(foldFieldName)),
|
|
28
|
+
person: new Set(["firstname", "lastname", "email", "phone", "mobilephone", "jobtitle", "hubspot_owner_id"].map(foldFieldName)),
|
|
29
|
+
organization: new Set(["name", "phone", "hubspot_owner_id"].map(foldFieldName))
|
|
30
|
+
};
|
|
31
|
+
var refused = /* @__PURE__ */ __name((message, param) => new CliError("validation_error", message, { reason: "crm.record-field", sent: false, ...param ? { param } : {} }), "refused");
|
|
32
|
+
var ID = /^\d{1,20}$/;
|
|
33
|
+
var idOf = /* @__PURE__ */ __name((value, param) => {
|
|
34
|
+
if (!ID.test(value))
|
|
35
|
+
throw refused(`${param} takes ${SERVICE}'s numeric id`, param);
|
|
36
|
+
return value;
|
|
37
|
+
}, "idOf");
|
|
38
|
+
var cleared = /* @__PURE__ */ __name((value) => value ?? "", "cleared");
|
|
39
|
+
var customOf = /* @__PURE__ */ __name((kind, custom) => {
|
|
40
|
+
const properties = {};
|
|
41
|
+
for (const [code, value] of Object.entries(custom ?? {})) {
|
|
42
|
+
if (OWN[kind].has(foldFieldName(code)))
|
|
43
|
+
throw refused(`${code} is one of ${SERVICE}'s own properties; set it with its own option, not --field`, "--field");
|
|
44
|
+
properties[code] = Array.isArray(value) ? value.join(";") : cleared(value);
|
|
45
|
+
}
|
|
46
|
+
return properties;
|
|
47
|
+
}, "customOf");
|
|
48
|
+
var listOf = /* @__PURE__ */ __name((values) => values?.map((one) => one.trim()).filter(Boolean), "listOf");
|
|
49
|
+
var dealOf = /* @__PURE__ */ __name((given) => {
|
|
50
|
+
if (given.people !== void 0 || given.organization !== void 0)
|
|
51
|
+
throw refused(`set a deal's contacts and company with ${SERVICE}'s associations, through api`);
|
|
52
|
+
const properties = customOf("deal", given.custom);
|
|
53
|
+
if (given.title !== void 0)
|
|
54
|
+
properties.dealname = given.title;
|
|
55
|
+
if (given.pipeline !== void 0)
|
|
56
|
+
properties.pipeline = given.pipeline;
|
|
57
|
+
if (given.stage !== void 0)
|
|
58
|
+
properties.dealstage = given.stage;
|
|
59
|
+
if (given.amount !== void 0)
|
|
60
|
+
properties.amount = cleared(given.amount);
|
|
61
|
+
if (given.currency !== void 0)
|
|
62
|
+
properties.deal_currency_code = cleared(given.currency);
|
|
63
|
+
if (given.closeDate !== void 0)
|
|
64
|
+
properties.closedate = given.closeDate ? `${given.closeDate}T12:00:00.000Z` : "";
|
|
65
|
+
if (given.owner !== void 0)
|
|
66
|
+
properties.hubspot_owner_id = given.owner === null ? "" : idOf(given.owner, "--owner");
|
|
67
|
+
return properties;
|
|
68
|
+
}, "dealOf");
|
|
69
|
+
var personOf = /* @__PURE__ */ __name((given) => {
|
|
70
|
+
const properties = customOf("person", given.custom);
|
|
71
|
+
if (given.name !== void 0 && given.firstName === void 0 && given.lastName === void 0) {
|
|
72
|
+
const [first, ...rest] = given.name.trim().split(/\s+/);
|
|
73
|
+
properties.firstname = first ?? "";
|
|
74
|
+
properties.lastname = rest.join(" ");
|
|
75
|
+
}
|
|
76
|
+
if (given.firstName !== void 0)
|
|
77
|
+
properties.firstname = cleared(given.firstName);
|
|
78
|
+
if (given.lastName !== void 0)
|
|
79
|
+
properties.lastname = cleared(given.lastName);
|
|
80
|
+
if (given.position !== void 0)
|
|
81
|
+
properties.jobtitle = cleared(given.position);
|
|
82
|
+
const emails = listOf(given.emails);
|
|
83
|
+
if (emails) {
|
|
84
|
+
if (emails.length > 1)
|
|
85
|
+
throw refused(`${SERVICE} keeps one e-mail per contact here; give one --email`, "--email");
|
|
86
|
+
properties.email = emails[0] ?? "";
|
|
87
|
+
}
|
|
88
|
+
const phones = listOf(given.phones);
|
|
89
|
+
if (phones) {
|
|
90
|
+
if (phones.length > 2)
|
|
91
|
+
throw refused(`${SERVICE} keeps two numbers per contact, phone and mobile; give at most two --phone`, "--phone");
|
|
92
|
+
properties.phone = phones[0] ?? "";
|
|
93
|
+
properties.mobilephone = phones[1] ?? "";
|
|
94
|
+
}
|
|
95
|
+
if (given.owner !== void 0)
|
|
96
|
+
properties.hubspot_owner_id = given.owner === null ? "" : idOf(given.owner, "--owner");
|
|
97
|
+
return properties;
|
|
98
|
+
}, "personOf");
|
|
99
|
+
var organizationOf = /* @__PURE__ */ __name((given) => {
|
|
100
|
+
const properties = customOf("organization", given.custom);
|
|
101
|
+
if (given.name !== void 0)
|
|
102
|
+
properties.name = given.name;
|
|
103
|
+
if (listOf(given.emails)?.length)
|
|
104
|
+
throw refused(`a ${SERVICE} company has no e-mail property; set the contacts' e-mails instead`, "--email");
|
|
105
|
+
const phones = listOf(given.phones);
|
|
106
|
+
if (phones) {
|
|
107
|
+
if (phones.length > 1)
|
|
108
|
+
throw refused(`a ${SERVICE} company keeps one number; give one --phone`, "--phone");
|
|
109
|
+
properties.phone = phones[0] ?? "";
|
|
110
|
+
}
|
|
111
|
+
if (given.owner !== void 0)
|
|
112
|
+
properties.hubspot_owner_id = given.owner === null ? "" : idOf(given.owner, "--owner");
|
|
113
|
+
return properties;
|
|
114
|
+
}, "organizationOf");
|
|
115
|
+
var propertiesFor = /* @__PURE__ */ __name((kind, given) => {
|
|
116
|
+
if (kind === "deal")
|
|
117
|
+
return dealOf(given);
|
|
118
|
+
if (kind === "person")
|
|
119
|
+
return personOf(given);
|
|
120
|
+
if (kind === "organization")
|
|
121
|
+
return organizationOf(given);
|
|
122
|
+
throw new CliError("validation_error", `${SERVICE} leads are written through api leads-create and leads-update`, {
|
|
123
|
+
reason: "crm.write-unsupported",
|
|
124
|
+
sent: false
|
|
125
|
+
});
|
|
126
|
+
}, "propertiesFor");
|
|
127
|
+
var pathOf = /* @__PURE__ */ __name((kind, externalId) => `/crm/objects/2026-03/${OBJECTS[kind].path}${externalId === void 0 ? "" : `/${segment(idOf(externalId, `<${kind}>`))}`}`, "pathOf");
|
|
128
|
+
var hubspotCrmWriter = /* @__PURE__ */ __name((hub, source) => {
|
|
129
|
+
const readBack = /* @__PURE__ */ __name(async (kind, externalId, options) => {
|
|
130
|
+
try {
|
|
131
|
+
const found = await source().record(kind, externalId);
|
|
132
|
+
if (!found)
|
|
133
|
+
throw new CliError("not_found", `${SERVICE} has no ${kind} ${externalId}`);
|
|
134
|
+
return found;
|
|
135
|
+
} catch (error) {
|
|
136
|
+
throw new CliError("invalid_response", `${SERVICE} made the change to ${kind} ${externalId}, but reading it back failed${isCliError(error) ? ` (${error.code})` : ""}; run sync to store it \u2014 do not write it again`, { operation_id: options.operationId, external_id: externalId, sent: true });
|
|
137
|
+
}
|
|
138
|
+
}, "readBack");
|
|
139
|
+
const update = /* @__PURE__ */ __name(async (kind, externalId, properties, options) => {
|
|
140
|
+
if (Object.keys(properties).length === 0)
|
|
141
|
+
throw refused("nothing to change: name a field");
|
|
142
|
+
await hub().patch(pathOf(kind, externalId), { properties });
|
|
143
|
+
return readBack(kind, externalId, options);
|
|
144
|
+
}, "update");
|
|
145
|
+
const closingStage = /* @__PURE__ */ __name(async (externalId, outcome) => {
|
|
146
|
+
const deal = await source().record("deal", externalId);
|
|
147
|
+
if (!deal)
|
|
148
|
+
throw new CliError("not_found", `${SERVICE} has no deal ${externalId}`, { sent: false });
|
|
149
|
+
const pipeline = (await source().pipelines("deal")).find((one) => one.externalId === deal.pipeline);
|
|
150
|
+
const stage = pipeline?.stages.find((one) => one.outcome === outcome);
|
|
151
|
+
if (!stage)
|
|
152
|
+
throw refused(`the deal's pipeline ${deal.pipeline} has no closed ${outcome} stage in ${SERVICE}`, "<outcome>");
|
|
153
|
+
return stage.externalId;
|
|
154
|
+
}, "closingStage");
|
|
155
|
+
return {
|
|
156
|
+
provider: "hubspot",
|
|
157
|
+
capabilities: HUBSPOT_WRITES,
|
|
158
|
+
async create(kind, draft, options) {
|
|
159
|
+
const properties = propertiesFor(kind, draft);
|
|
160
|
+
const answer = await hub().post(pathOf(kind), { properties, associations: [] });
|
|
161
|
+
const externalId = values_exports.id(values_exports.fieldOf(answer, "id"));
|
|
162
|
+
if (externalId === null)
|
|
163
|
+
throw new CliError("invalid_response", `${SERVICE} answered the new ${kind} without its id; run sync first`, {
|
|
164
|
+
operation_id: options.operationId,
|
|
165
|
+
sent: true
|
|
166
|
+
});
|
|
167
|
+
return readBack(kind, externalId, options);
|
|
168
|
+
},
|
|
169
|
+
async update(kind, externalId, patch, options) {
|
|
170
|
+
return update(kind, externalId, propertiesFor(kind, patch), options);
|
|
171
|
+
},
|
|
172
|
+
async move(kind, externalId, stage, options) {
|
|
173
|
+
return update(kind, externalId, propertiesFor(kind, { stage }), options);
|
|
174
|
+
},
|
|
175
|
+
async close(kind, externalId, outcome, options) {
|
|
176
|
+
const properties = propertiesFor(kind, { stage: await closingStage(externalId, outcome) });
|
|
177
|
+
if (options.reason !== void 0)
|
|
178
|
+
properties[`closed_${outcome}_reason`] = options.reason;
|
|
179
|
+
return update(kind, externalId, properties, options);
|
|
180
|
+
},
|
|
181
|
+
async remove(kind, externalId) {
|
|
182
|
+
if (kind !== "deal")
|
|
183
|
+
throw new CliError("validation_error", `${SERVICE} ${kind}s are deleted through api`, {
|
|
184
|
+
reason: "crm.write-unsupported",
|
|
185
|
+
sent: false
|
|
186
|
+
});
|
|
187
|
+
await hub().delete(pathOf(kind, externalId));
|
|
188
|
+
}
|
|
189
|
+
};
|
|
190
|
+
}, "hubspotCrmWriter");
|
|
191
|
+
|
|
192
|
+
export {
|
|
193
|
+
HUBSPOT_WRITES,
|
|
194
|
+
hubspotCrmWriter
|
|
195
|
+
};
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
import { createRequire as __bundleRequire } from "node:module";
|
|
2
|
+
const require = __bundleRequire(import.meta.url);
|
|
3
|
+
import {
|
|
4
|
+
__name
|
|
5
|
+
} from "./chunk-ZVVMGPBJ.js";
|
|
6
|
+
|
|
7
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.687.0_@wirecat+cli-base@0.109.0_commander@15.0.0_esbuild@0.28.2_typ_3e6248e31e5b79d53006284373ddef70/node_modules/@wirecat/cli-core/dist/runs/secrets.js
|
|
8
|
+
var SECRET_WORDS = /* @__PURE__ */ new Set([
|
|
9
|
+
"authorization",
|
|
10
|
+
"cookie",
|
|
11
|
+
"credential",
|
|
12
|
+
"credentials",
|
|
13
|
+
"passphrase",
|
|
14
|
+
"password",
|
|
15
|
+
"passwd",
|
|
16
|
+
"pwd",
|
|
17
|
+
"pass",
|
|
18
|
+
"passcode",
|
|
19
|
+
"pin",
|
|
20
|
+
"otp",
|
|
21
|
+
"2fa",
|
|
22
|
+
"secret",
|
|
23
|
+
"token",
|
|
24
|
+
"contrase\xF1a",
|
|
25
|
+
"contrasena",
|
|
26
|
+
"clave",
|
|
27
|
+
"\u043F\u0430\u0440\u043E\u043B\u044C",
|
|
28
|
+
"\u043F\u0438\u043D",
|
|
29
|
+
"\u043A\u043E\u0434",
|
|
30
|
+
...["api", "auth", "service", "account", "db", "database", "priv", "private", "client"].map((word) => `${word}key`),
|
|
31
|
+
...["db", "database", "key"].map((word) => `${word}pass`)
|
|
32
|
+
]);
|
|
33
|
+
var secretNamed = /* @__PURE__ */ __name((name) => {
|
|
34
|
+
const words = name.replace(/([a-z0-9])([A-Z])/g, "$1 $2").split(/[\s_.-]+/).map((word) => word.toLowerCase());
|
|
35
|
+
return words.some((word, at) => SECRET_WORDS.has(word) || SECRET_WORDS.has(word + (words[at + 1] ?? "")));
|
|
36
|
+
}, "secretNamed");
|
|
37
|
+
var START = "(?<![A-Za-z0-9_-])";
|
|
38
|
+
var END = "(?![A-Za-z0-9_-])";
|
|
39
|
+
var KNOWN_TOKENS = new RegExp(`${[
|
|
40
|
+
"gh[pousr]_[A-Za-z0-9]{36,}",
|
|
41
|
+
"github_pat_[A-Za-z0-9_]{22,}",
|
|
42
|
+
"sk-[A-Za-z0-9_-]{20,}",
|
|
43
|
+
"xox[abprs]-[A-Za-z0-9-]{10,}",
|
|
44
|
+
"(?:AKIA|ASIA)[A-Z0-9]{16}",
|
|
45
|
+
"AIza[A-Za-z0-9_-]{35}",
|
|
46
|
+
"(?:sk|rk)_(?:live|test)_[A-Za-z0-9]{10,}",
|
|
47
|
+
"npm_[A-Za-z0-9]{36}",
|
|
48
|
+
"eyJ[A-Za-z0-9_-]{5,}\\.eyJ[A-Za-z0-9_-]{5,}\\.[A-Za-z0-9_-]*"
|
|
49
|
+
].map((pattern) => `${START}${pattern}${END}`).join("|")}|(?<!\\d)\\d{8,10}:[A-Za-z0-9_-]{35}${END}`, "g");
|
|
50
|
+
var WEBHOOK_PATH = /(\/rest\/\d+\/)[^/\s?#"']+/g;
|
|
51
|
+
var PRIVATE_KEY = /-----BEGIN[A-Z ]* PRIVATE KEY-----[\s\S]*?(?:-----END[A-Z ]* PRIVATE KEY-----|$)/g;
|
|
52
|
+
var SCHEME = /(?<![A-Za-z])(Bearer|Basic)(\s+)(?![A-Z]?[a-z]+(?![A-Za-z0-9]))[A-Za-z0-9._~+/=-]{8,}/g;
|
|
53
|
+
var NAMED_PAIR = /(?<![\p{L}\p{N}])([\p{L}\p{N}_.-]*(?:token|pass|pwd|pin|otp|2fa|secret|credential|cookie|authorization|key|contrase|clave|пароль|пин|код)[\p{L}\p{N}_.-]*)(["']?\s*(?:=>|[:=])\s*["']?|\s+(?![\p{L}]+(?![\p{L}\p{N}])))((?:Bearer\s+|Basic\s+)?)([^\s"'&,;]+)/giu;
|
|
54
|
+
var looksRandom = /* @__PURE__ */ __name((run) => {
|
|
55
|
+
if (run.length < 20)
|
|
56
|
+
return false;
|
|
57
|
+
const classes = [/[a-z]/, /[A-Z]/, /\d/, /[^A-Za-z0-9]/].filter((kind) => kind.test(run)).length;
|
|
58
|
+
if (classes < 3)
|
|
59
|
+
return false;
|
|
60
|
+
let switches = 0;
|
|
61
|
+
for (let at = 1; at < run.length; at++) {
|
|
62
|
+
const [before, after] = [run[at - 1], run[at]];
|
|
63
|
+
if (/[a-z]/.test(before) && /[A-Z]/.test(after) || /[A-Z]/.test(before) && /[a-z]/.test(after))
|
|
64
|
+
switches += 1;
|
|
65
|
+
}
|
|
66
|
+
if (switches / run.length < 0.15)
|
|
67
|
+
return false;
|
|
68
|
+
const pieces = run.match(/[A-Z]?[a-z]+|[A-Z]+(?![a-z])|\d+/g) ?? [];
|
|
69
|
+
if (pieces.join("").length / Math.max(pieces.length, 1) >= 2.75)
|
|
70
|
+
return false;
|
|
71
|
+
return entropy(run) >= 3.5;
|
|
72
|
+
}, "looksRandom");
|
|
73
|
+
var entropy = /* @__PURE__ */ __name((text) => {
|
|
74
|
+
const counts = /* @__PURE__ */ new Map();
|
|
75
|
+
for (const char of text)
|
|
76
|
+
counts.set(char, (counts.get(char) ?? 0) + 1);
|
|
77
|
+
let bits = 0;
|
|
78
|
+
for (const count of counts.values())
|
|
79
|
+
bits -= count / text.length * Math.log2(count / text.length);
|
|
80
|
+
return bits;
|
|
81
|
+
}, "entropy");
|
|
82
|
+
var withoutSecrets = /* @__PURE__ */ __name((text, mark = "[redacted]") => text.replace(WEBHOOK_PATH, `$1${mark}`).replace(PRIVATE_KEY, mark).replace(KNOWN_TOKENS, mark).replace(SCHEME, `$1$2${mark}`).replace(NAMED_PAIR, (whole, name, separator, scheme) => secretNamed(name) ? `${name}${separator}${scheme}${mark}` : whole).replace(/[!-~]{20,}/g, (token) => (
|
|
83
|
+
// A URL or a path is somebody's address, not a key; a credential in one is caught by the rules above.
|
|
84
|
+
token.includes("://") || /^(?:\/|~\/|\.\.?\/)/.test(token) ? token : token.replace(RUN, (run) => looksRandom(run) ? mark : run.replace(HEX, (hex) => entropy(hex) >= 3 ? mark : hex))
|
|
85
|
+
)), "withoutSecrets");
|
|
86
|
+
var RUN = /(?<![A-Za-z0-9_+/-])[A-Za-z0-9_+/-]{20,}/g;
|
|
87
|
+
var HEX = /(?<![A-Za-z0-9])(?=[0-9]*[a-f])[0-9a-f]{20,}(?![A-Za-z0-9])/g;
|
|
88
|
+
|
|
89
|
+
export {
|
|
90
|
+
secretNamed,
|
|
91
|
+
withoutSecrets
|
|
92
|
+
};
|