@wirecat/amo-cli 0.0.0-stage → 0.1.1
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 +70 -0
- package/LICENSE +204 -0
- package/README.md +265 -2
- package/contracts/wirecat.json +1356 -0
- package/dist/amo/account.d.ts +18 -0
- package/dist/amo/account.d.ts.map +1 -0
- package/dist/amo/account.js +48 -0
- package/dist/amo/account.js.map +1 -0
- package/dist/amo/allow-list.d.ts +31 -0
- package/dist/amo/allow-list.d.ts.map +1 -0
- package/dist/amo/allow-list.js +106 -0
- package/dist/amo/allow-list.js.map +1 -0
- package/dist/amo/errors.d.ts +12 -0
- package/dist/amo/errors.d.ts.map +1 -0
- package/dist/amo/errors.js +72 -0
- package/dist/amo/errors.js.map +1 -0
- package/dist/amo/json.d.ts +3 -0
- package/dist/amo/json.d.ts.map +1 -0
- package/dist/amo/json.js +3 -0
- package/dist/amo/json.js.map +1 -0
- package/dist/amo/oauth.d.ts +55 -0
- package/dist/amo/oauth.d.ts.map +1 -0
- package/dist/amo/oauth.js +189 -0
- package/dist/amo/oauth.js.map +1 -0
- package/dist/amo/operation.d.ts +45 -0
- package/dist/amo/operation.d.ts.map +1 -0
- package/dist/amo/operation.js +119 -0
- package/dist/amo/operation.js.map +1 -0
- package/dist/amo/operations.d.ts +3 -0
- package/dist/amo/operations.d.ts.map +1 -0
- package/dist/amo/operations.js +1407 -0
- package/dist/amo/operations.js.map +1 -0
- package/dist/amo/routes.d.ts +67 -0
- package/dist/amo/routes.d.ts.map +1 -0
- package/dist/amo/routes.js +65 -0
- package/dist/amo/routes.js.map +1 -0
- package/dist/amo/transport.d.ts +62 -0
- package/dist/amo/transport.d.ts.map +1 -0
- package/dist/amo/transport.js +282 -0
- package/dist/amo/transport.js.map +1 -0
- package/dist/api-keys.d.ts +47 -0
- package/dist/api-keys.d.ts.map +1 -0
- package/dist/api-keys.js +224 -0
- package/dist/api-keys.js.map +1 -0
- package/dist/bin/amo.d.ts +3 -0
- package/dist/bin/amo.d.ts.map +1 -0
- package/dist/bin/amo.js +40 -0
- package/dist/bin/amo.js.map +1 -0
- package/dist/bundle/all-profiles-3KQVWDV4.js +278 -0
- package/dist/bundle/amo.js +198 -0
- package/dist/bundle/anthropic-N5NOX7K7.js +90 -0
- package/dist/bundle/app-server-2MST5EZ5.js +245 -0
- package/dist/bundle/bun-4NHWOFX2.js +169 -0
- package/dist/bundle/bun-sqlite-DRSXPWPR.js +75 -0
- package/dist/bundle/chunk-2B24PDH7.js +1718 -0
- package/dist/bundle/chunk-2I5UVMLW.js +3232 -0
- package/dist/bundle/chunk-3IRJDH2U.js +731 -0
- package/dist/bundle/chunk-4ZAK773N.js +100 -0
- package/dist/bundle/chunk-5D4AEUVA.js +24783 -0
- package/dist/bundle/chunk-5D4Z2B5B.js +334 -0
- package/dist/bundle/chunk-5E5R65CA.js +54 -0
- package/dist/bundle/chunk-5HGGG3QO.js +73 -0
- package/dist/bundle/chunk-5RLUHTK6.js +23 -0
- package/dist/bundle/chunk-5SBLU7D7.js +63 -0
- package/dist/bundle/chunk-5Z5PEEKP.js +206 -0
- package/dist/bundle/chunk-63F65DHU.js +29 -0
- package/dist/bundle/chunk-6RS7OYTD.js +64 -0
- package/dist/bundle/chunk-73CXFE36.js +88 -0
- package/dist/bundle/chunk-7GTUZY7M.js +170 -0
- package/dist/bundle/chunk-7PKFYX7V.js +189 -0
- package/dist/bundle/chunk-7U5HJEPZ.js +1400 -0
- package/dist/bundle/chunk-A33TIM5D.js +4172 -0
- package/dist/bundle/chunk-ADEWU4P4.js +38 -0
- package/dist/bundle/chunk-ADLS6FVG.js +24600 -0
- package/dist/bundle/chunk-AHJ4W2IL.js +106 -0
- package/dist/bundle/chunk-AUBB72VF.js +2572 -0
- package/dist/bundle/chunk-BVMNXI53.js +1266 -0
- package/dist/bundle/chunk-CDY2NJFE.js +136 -0
- package/dist/bundle/chunk-CHUKWON6.js +244 -0
- package/dist/bundle/chunk-CUZRHF34.js +230 -0
- package/dist/bundle/chunk-D72URWJE.js +532 -0
- package/dist/bundle/chunk-DAY6TSPF.js +786 -0
- package/dist/bundle/chunk-DFDN6AUB.js +21 -0
- package/dist/bundle/chunk-DJD7TBYG.js +2791 -0
- package/dist/bundle/chunk-DOSJONCX.js +1197 -0
- package/dist/bundle/chunk-DQV2IKCF.js +72 -0
- package/dist/bundle/chunk-DXGGCGRP.js +218 -0
- package/dist/bundle/chunk-EH6ZEJGT.js +932 -0
- package/dist/bundle/chunk-EPOV5UIO.js +185 -0
- package/dist/bundle/chunk-EQ7A6NA6.js +53 -0
- package/dist/bundle/chunk-EQUKVVHX.js +353 -0
- package/dist/bundle/chunk-EROSAUNP.js +133 -0
- package/dist/bundle/chunk-ESZSMZKT.js +82 -0
- package/dist/bundle/chunk-FKR3M62D.js +407 -0
- package/dist/bundle/chunk-GNTJMB6X.js +142 -0
- package/dist/bundle/chunk-GQ7VFIYM.js +316 -0
- package/dist/bundle/chunk-JH3UOHRE.js +161 -0
- package/dist/bundle/chunk-JMDLPBXK.js +1068 -0
- package/dist/bundle/chunk-JR6TSMFX.js +9435 -0
- package/dist/bundle/chunk-L6AFE73L.js +18 -0
- package/dist/bundle/chunk-LDEBZ3IX.js +238 -0
- package/dist/bundle/chunk-LGQXGOPJ.js +58 -0
- package/dist/bundle/chunk-LJQUYECN.js +6848 -0
- package/dist/bundle/chunk-LRBPT7LQ.js +95 -0
- package/dist/bundle/chunk-LSND5QYI.js +460 -0
- package/dist/bundle/chunk-NC76INB2.js +27955 -0
- package/dist/bundle/chunk-NHXJYS4R.js +1334 -0
- package/dist/bundle/chunk-NJYAL3UW.js +92 -0
- package/dist/bundle/chunk-O2UCU52O.js +4065 -0
- package/dist/bundle/chunk-ODNQU7DH.js +1028 -0
- package/dist/bundle/chunk-P3WQRTYZ.js +24 -0
- package/dist/bundle/chunk-P5LYZRKW.js +63373 -0
- package/dist/bundle/chunk-PFO76YFP.js +2003 -0
- package/dist/bundle/chunk-PM77PRB6.js +12269 -0
- package/dist/bundle/chunk-Q2VNBY4Y.js +38109 -0
- package/dist/bundle/chunk-QDMXZZG4.js +604 -0
- package/dist/bundle/chunk-QRQYUHCZ.js +761 -0
- package/dist/bundle/chunk-RPWAJYI6.js +2336 -0
- package/dist/bundle/chunk-SMSTGO2G.js +58 -0
- package/dist/bundle/chunk-SZ2V62HB.js +72 -0
- package/dist/bundle/chunk-T2UDLX76.js +259 -0
- package/dist/bundle/chunk-TGEQNS6G.js +16 -0
- package/dist/bundle/chunk-TNUFLULO.js +2333 -0
- package/dist/bundle/chunk-TZSUZGWM.js +25 -0
- package/dist/bundle/chunk-U7RLVJ34.js +274 -0
- package/dist/bundle/chunk-UBRREVLJ.js +72 -0
- package/dist/bundle/chunk-ULXQ5MJM.js +76 -0
- package/dist/bundle/chunk-UMVRT7VQ.js +46 -0
- package/dist/bundle/chunk-V77XNPXG.js +360 -0
- package/dist/bundle/chunk-VVHRQ46X.js +193 -0
- package/dist/bundle/chunk-VX37MPTJ.js +7 -0
- package/dist/bundle/chunk-WCYCUTSK.js +362 -0
- package/dist/bundle/chunk-XEFAMLSD.js +288 -0
- package/dist/bundle/chunk-XQL7FEF4.js +721 -0
- package/dist/bundle/chunk-XRTD2GCU.js +627 -0
- package/dist/bundle/chunk-Y37A3232.js +804 -0
- package/dist/bundle/chunk-Y5E2WNWB.js +35 -0
- package/dist/bundle/chunk-ZM7I52EP.js +78 -0
- package/dist/bundle/chunk-ZVVMGPBJ.js +50 -0
- package/dist/bundle/cli-QVWTXADI.js +1193 -0
- package/dist/bundle/command-contract-QBUQBXH7.js +39 -0
- package/dist/bundle/command-server-entry-5VL5U5EE.js +168 -0
- package/dist/bundle/decode-SQ5WGNDX.js +296 -0
- package/dist/bundle/dispatch-LA4DFXJD.js +411 -0
- package/dist/bundle/dist-T54K3FJV.js +7577 -0
- package/dist/bundle/echarts-25Z3RINX.js +42501 -0
- package/dist/bundle/embed-BNOTNXMA.js +37 -0
- package/dist/bundle/embedder-BCUT7KKV.js +110 -0
- package/dist/bundle/failure-PKAC6XCT.js +24 -0
- package/dist/bundle/first-run-EO5K5GME.js +28 -0
- package/dist/bundle/first-screen-GMN3T6RW.js +39 -0
- package/dist/bundle/instructions-VLM3QAYB.js +11 -0
- package/dist/bundle/mcp-7ILNMJH5.js +167 -0
- package/dist/bundle/meeting-combined-LAMF7S2B.js +24 -0
- package/dist/bundle/meeting-model-GHMMUQ34.js +24 -0
- package/dist/bundle/meeting-semantic-BMP6323L.js +21 -0
- package/dist/bundle/node-CT3N3TNL.js +176 -0
- package/dist/bundle/node-P4E63KXA.js +2340 -0
- package/dist/bundle/node-TLZSIHIJ.js +21 -0
- package/dist/bundle/node-sqlite-MELD2SBX.js +73 -0
- package/dist/bundle/oauth-YBH5OKC2.js +19 -0
- package/dist/bundle/open-WNSBWTAG.js +22 -0
- package/dist/bundle/openai-XSNMNLW6.js +237 -0
- package/dist/bundle/process-I2QKOMM7.js +91 -0
- package/dist/bundle/program-DV73CIGP.js +4940 -0
- package/dist/bundle/prompt-SOG4AKPM.js +16 -0
- package/dist/bundle/recognize-WMQLWMXH.js +25 -0
- package/dist/bundle/remote-4BTFOLFY.js +30 -0
- package/dist/bundle/rerank-LJ3TWRNV.js +51 -0
- package/dist/bundle/serve-B6UANKXN.js +198 -0
- package/dist/bundle/server-S6XD6V6E.js +77 -0
- package/dist/bundle/server-YRH6GJ5Z.js +206 -0
- package/dist/bundle/source-DGFTA2TN.js +42 -0
- package/dist/bundle/sqlite-runtime-R7QFWFE7.js +19 -0
- package/dist/bundle/state-DIJ5YUOE.js +35 -0
- package/dist/bundle/store-6WFWW7EC.js +294 -0
- package/dist/bundle/store-FJCNZULV.js +32 -0
- package/dist/bundle/store-MYTYDV6A.js +177 -0
- package/dist/bundle/store-maintenance-command-B5TMKFMG.js +68 -0
- package/dist/bundle/writer-GP7VIMAU.js +44 -0
- package/dist/commands/account.d.ts +3 -0
- package/dist/commands/account.d.ts.map +1 -0
- package/dist/commands/account.js +86 -0
- package/dist/commands/account.js.map +1 -0
- package/dist/commands/api.d.ts +3 -0
- package/dist/commands/api.d.ts.map +1 -0
- package/dist/commands/api.js +224 -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 +111 -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 +18 -0
- package/dist/commands/session.d.ts.map +1 -0
- package/dist/commands/session.js +265 -0
- package/dist/commands/session.js.map +1 -0
- package/dist/commands/write.d.ts +14 -0
- package/dist/commands/write.d.ts.map +1 -0
- package/dist/commands/write.js +36 -0
- package/dist/commands/write.js.map +1 -0
- package/dist/config.d.ts +4 -0
- package/dist/config.d.ts.map +1 -0
- package/dist/config.js +29 -0
- package/dist/config.js.map +1 -0
- package/dist/context.d.ts +62 -0
- package/dist/context.d.ts.map +1 -0
- package/dist/context.js +97 -0
- package/dist/context.js.map +1 -0
- package/dist/crm/activities.d.ts +32 -0
- package/dist/crm/activities.d.ts.map +1 -0
- package/dist/crm/activities.js +196 -0
- package/dist/crm/activities.js.map +1 -0
- package/dist/crm/records.d.ts +20 -0
- package/dist/crm/records.d.ts.map +1 -0
- package/dist/crm/records.js +175 -0
- package/dist/crm/records.js.map +1 -0
- package/dist/crm/source.d.ts +41 -0
- package/dist/crm/source.d.ts.map +1 -0
- package/dist/crm/source.js +673 -0
- package/dist/crm/source.js.map +1 -0
- package/dist/crm/writer.d.ts +14 -0
- package/dist/crm/writer.d.ts.map +1 -0
- package/dist/crm/writer.js +247 -0
- package/dist/crm/writer.js.map +1 -0
- package/dist/identity.d.ts +7 -0
- package/dist/identity.d.ts.map +1 -0
- package/dist/identity.js +33 -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 +91 -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 +35 -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 +127 -0
- package/dist/setup/flow.js.map +1 -0
- package/dist/setup/texts.en.json +25 -0
- package/dist/setup/texts.es.json +25 -0
- package/dist/setup/texts.ru.json +25 -0
- package/dist/store.d.ts +15 -0
- package/dist/store.d.ts.map +1 -0
- package/dist/store.js +16 -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 +24 -0
- package/dist/whoami.d.ts.map +1 -0
- package/dist/whoami.js +33 -0
- package/dist/whoami.js.map +1 -0
- package/package.json +85 -4
- package/skills/amo-cli/SKILL.md +116 -0
- package/skills/amo-cli/references/mcp.md +38 -0
- package/skills/amo-cli/references/output.md +42 -0
- package/skills/amo-cli/references/reading.md +77 -0
- package/skills/amo-cli/references/setup.md +59 -0
- package/skills/amo-cli/references/writing.md +86 -0
|
@@ -0,0 +1,18 @@
|
|
|
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.691.0_@wirecat+cli-base@0.113.0_commander@15.0.0_esbuild@0.28.2_typ_9a2e508bb6f63e7e29f0d776540ec8fd/node_modules/@wirecat/cli-core/dist/cli/stdin-field.js
|
|
8
|
+
var fields = /* @__PURE__ */ new WeakMap();
|
|
9
|
+
var readsStdin = /* @__PURE__ */ __name((command, field) => {
|
|
10
|
+
fields.set(command, field);
|
|
11
|
+
return command;
|
|
12
|
+
}, "readsStdin");
|
|
13
|
+
var stdinFieldOf = /* @__PURE__ */ __name((command) => fields.get(command), "stdinFieldOf");
|
|
14
|
+
|
|
15
|
+
export {
|
|
16
|
+
readsStdin,
|
|
17
|
+
stdinFieldOf
|
|
18
|
+
};
|
|
@@ -0,0 +1,238 @@
|
|
|
1
|
+
import { createRequire as __bundleRequire } from "node:module";
|
|
2
|
+
const require = __bundleRequire(import.meta.url);
|
|
3
|
+
import {
|
|
4
|
+
values_exports
|
|
5
|
+
} from "./chunk-2I5UVMLW.js";
|
|
6
|
+
import {
|
|
7
|
+
__name
|
|
8
|
+
} from "./chunk-ZVVMGPBJ.js";
|
|
9
|
+
|
|
10
|
+
// dist/amo/routes.js
|
|
11
|
+
var ROUTES = {
|
|
12
|
+
account: "GET /api/v4/account",
|
|
13
|
+
user: "GET /api/v4/users/{id}",
|
|
14
|
+
users: "GET /api/v4/users",
|
|
15
|
+
pipelines: "GET /api/v4/leads/pipelines",
|
|
16
|
+
lossReasons: "GET /api/v4/leads/loss_reasons",
|
|
17
|
+
events: "GET /api/v4/events",
|
|
18
|
+
tasks: "GET /api/v4/tasks",
|
|
19
|
+
leadNotes: "GET /api/v4/leads/notes",
|
|
20
|
+
contactNotes: "GET /api/v4/contacts/notes",
|
|
21
|
+
companyNotes: "GET /api/v4/companies/notes",
|
|
22
|
+
leads: "GET /api/v4/leads",
|
|
23
|
+
lead: "GET /api/v4/leads/{id}",
|
|
24
|
+
leadFields: "GET /api/v4/leads/custom_fields",
|
|
25
|
+
createLeads: "POST /api/v4/leads",
|
|
26
|
+
updateLeads: "PATCH /api/v4/leads",
|
|
27
|
+
contacts: "GET /api/v4/contacts",
|
|
28
|
+
contact: "GET /api/v4/contacts/{id}",
|
|
29
|
+
contactFields: "GET /api/v4/contacts/custom_fields",
|
|
30
|
+
createContacts: "POST /api/v4/contacts",
|
|
31
|
+
updateContacts: "PATCH /api/v4/contacts",
|
|
32
|
+
companies: "GET /api/v4/companies",
|
|
33
|
+
company: "GET /api/v4/companies/{id}",
|
|
34
|
+
companyFields: "GET /api/v4/companies/custom_fields",
|
|
35
|
+
createCompanies: "POST /api/v4/companies",
|
|
36
|
+
updateCompanies: "PATCH /api/v4/companies"
|
|
37
|
+
};
|
|
38
|
+
var ENTITIES = {
|
|
39
|
+
deal: {
|
|
40
|
+
list: ROUTES.leads,
|
|
41
|
+
one: ROUTES.lead,
|
|
42
|
+
fields: ROUTES.leadFields,
|
|
43
|
+
create: ROUTES.createLeads,
|
|
44
|
+
update: ROUTES.updateLeads,
|
|
45
|
+
name: "leads",
|
|
46
|
+
event: "lead"
|
|
47
|
+
},
|
|
48
|
+
person: {
|
|
49
|
+
list: ROUTES.contacts,
|
|
50
|
+
one: ROUTES.contact,
|
|
51
|
+
fields: ROUTES.contactFields,
|
|
52
|
+
create: ROUTES.createContacts,
|
|
53
|
+
update: ROUTES.updateContacts,
|
|
54
|
+
name: "contacts",
|
|
55
|
+
event: "contact"
|
|
56
|
+
},
|
|
57
|
+
organization: {
|
|
58
|
+
list: ROUTES.companies,
|
|
59
|
+
one: ROUTES.company,
|
|
60
|
+
fields: ROUTES.companyFields,
|
|
61
|
+
create: ROUTES.createCompanies,
|
|
62
|
+
update: ROUTES.updateCompanies,
|
|
63
|
+
name: "companies",
|
|
64
|
+
event: "company"
|
|
65
|
+
}
|
|
66
|
+
};
|
|
67
|
+
|
|
68
|
+
// dist/crm/records.js
|
|
69
|
+
var { amountOf, epoch, fieldOf, id, isRaw, rawsOf, text } = values_exports;
|
|
70
|
+
var WON = "142";
|
|
71
|
+
var LOST = "143";
|
|
72
|
+
var LISTS = /* @__PURE__ */ new Set(["select", "multiselect", "radiobutton"]);
|
|
73
|
+
var MULTIPLE = /* @__PURE__ */ new Set(["multiselect", "multitext"]);
|
|
74
|
+
var HOLDS = { PHONE: "phone", EMAIL: "email" };
|
|
75
|
+
var holdsOf = /* @__PURE__ */ __name((raw) => raw.type === "multitext" ? HOLDS[String(raw.code ?? raw.field_code ?? "")] : void 0, "holdsOf");
|
|
76
|
+
var fieldOfRaw = /* @__PURE__ */ __name((raw) => {
|
|
77
|
+
const code = id(raw.id);
|
|
78
|
+
const type = text(raw.type);
|
|
79
|
+
if (!code || !type)
|
|
80
|
+
return null;
|
|
81
|
+
const options = LISTS.has(type) ? rawsOf(raw.enums).flatMap((one) => {
|
|
82
|
+
const option = id(one.id);
|
|
83
|
+
return option ? [{ id: option, label: text(one.value) ?? option }] : [];
|
|
84
|
+
}) : void 0;
|
|
85
|
+
const holds = holdsOf(raw);
|
|
86
|
+
return {
|
|
87
|
+
code,
|
|
88
|
+
label: text(raw.name),
|
|
89
|
+
type,
|
|
90
|
+
multiple: MULTIPLE.has(type),
|
|
91
|
+
// Filtering by a custom field is the paid add-on's `filter[custom_fields_values]` (filters-api); amo does not ask it.
|
|
92
|
+
filterable: false,
|
|
93
|
+
...options ? { options } : {},
|
|
94
|
+
...holds ? { holds } : {}
|
|
95
|
+
};
|
|
96
|
+
}, "fieldOfRaw");
|
|
97
|
+
var valuesOf = /* @__PURE__ */ __name((raw) => {
|
|
98
|
+
const phones = [];
|
|
99
|
+
const emails = [];
|
|
100
|
+
const contactTypes = {};
|
|
101
|
+
const custom = {};
|
|
102
|
+
for (const field of rawsOf(raw.custom_fields_values)) {
|
|
103
|
+
const code = id(field.field_id);
|
|
104
|
+
const values = rawsOf(field.values);
|
|
105
|
+
const holds = holdsOf({ type: field.field_type, code: field.field_code });
|
|
106
|
+
if (holds) {
|
|
107
|
+
for (const one of values) {
|
|
108
|
+
const value = text(one.value);
|
|
109
|
+
if (!value)
|
|
110
|
+
continue;
|
|
111
|
+
(holds === "phone" ? phones : emails).push(value);
|
|
112
|
+
const kind = text(one.enum_code);
|
|
113
|
+
if (kind)
|
|
114
|
+
contactTypes[value] = kind;
|
|
115
|
+
}
|
|
116
|
+
continue;
|
|
117
|
+
}
|
|
118
|
+
if (!code)
|
|
119
|
+
continue;
|
|
120
|
+
const list = LISTS.has(String(field.field_type));
|
|
121
|
+
const read = values.map((one) => list ? id(one.enum_id) : one.value).filter((one) => one !== null);
|
|
122
|
+
custom[code] = MULTIPLE.has(String(field.field_type)) ? read : read[0] ?? null;
|
|
123
|
+
}
|
|
124
|
+
return { phones, emails, contactTypes, custom };
|
|
125
|
+
}, "valuesOf");
|
|
126
|
+
var metadataOf = /* @__PURE__ */ __name((custom, fields) => Object.keys(custom).length ? { metadata: values_exports.crmValuesOf(custom, fields) } : {}, "metadataOf");
|
|
127
|
+
var embedded = /* @__PURE__ */ __name((raw, key) => rawsOf(fieldOf(raw._embedded, key)), "embedded");
|
|
128
|
+
var day = /* @__PURE__ */ __name((at, timeZone) => {
|
|
129
|
+
const ms = epoch(at);
|
|
130
|
+
if (ms === null)
|
|
131
|
+
return null;
|
|
132
|
+
try {
|
|
133
|
+
if (timeZone)
|
|
134
|
+
return new Intl.DateTimeFormat("en-CA", { timeZone }).format(ms);
|
|
135
|
+
} catch {
|
|
136
|
+
}
|
|
137
|
+
return new Date(ms).toISOString().slice(0, 10);
|
|
138
|
+
}, "day");
|
|
139
|
+
var toDeal = /* @__PURE__ */ __name((raw, fields, currency, timeZone = null) => {
|
|
140
|
+
const { custom } = valuesOf(raw);
|
|
141
|
+
const contacts = fieldOf(raw._embedded, "contacts");
|
|
142
|
+
const stage = id(raw.status_id) ?? "";
|
|
143
|
+
return {
|
|
144
|
+
externalId: id(raw.id) ?? "",
|
|
145
|
+
title: text(raw.name) ?? "",
|
|
146
|
+
pipeline: id(raw.pipeline_id) ?? "",
|
|
147
|
+
stage,
|
|
148
|
+
...amountOf(raw.price, currency),
|
|
149
|
+
closedDate: stage === WON || stage === LOST ? day(raw.closed_at, timeZone) : null,
|
|
150
|
+
closedReason: stage === LOST ? text(embedded(raw, "loss_reason")[0]?.name) : null,
|
|
151
|
+
organization: id(embedded(raw, "companies")[0]?.id),
|
|
152
|
+
// `with=contacts` lists them with `is_main`; without it amoCRM did not say, and the stored ones stay.
|
|
153
|
+
...Array.isArray(contacts) ? {
|
|
154
|
+
people: rawsOf(contacts).flatMap((one) => {
|
|
155
|
+
const externalId = id(one.id);
|
|
156
|
+
return externalId ? [{ externalId, role: "contact", primary: one.is_main === true }] : [];
|
|
157
|
+
})
|
|
158
|
+
} : {},
|
|
159
|
+
createdAt: epoch(raw.created_at),
|
|
160
|
+
updatedAt: epoch(raw.updated_at),
|
|
161
|
+
assignee: id(raw.responsible_user_id),
|
|
162
|
+
...metadataOf(custom, fields)
|
|
163
|
+
};
|
|
164
|
+
}, "toDeal");
|
|
165
|
+
var toPerson = /* @__PURE__ */ __name((raw, fields) => {
|
|
166
|
+
const { phones, emails, contactTypes, custom } = valuesOf(raw);
|
|
167
|
+
return {
|
|
168
|
+
externalId: id(raw.id) ?? "",
|
|
169
|
+
name: text(raw.name),
|
|
170
|
+
firstName: text(raw.first_name),
|
|
171
|
+
lastName: text(raw.last_name),
|
|
172
|
+
email: emails[0] ?? null,
|
|
173
|
+
phone: phones[0] ?? null,
|
|
174
|
+
phones,
|
|
175
|
+
emails,
|
|
176
|
+
...Object.keys(contactTypes).length ? { contactTypes } : {},
|
|
177
|
+
organizations: embedded(raw, "companies").flatMap((one, at) => {
|
|
178
|
+
const externalId = id(one.id);
|
|
179
|
+
return externalId ? [{ externalId, primary: at === 0 }] : [];
|
|
180
|
+
}),
|
|
181
|
+
assignee: id(raw.responsible_user_id),
|
|
182
|
+
createdAt: epoch(raw.created_at),
|
|
183
|
+
updatedAt: epoch(raw.updated_at),
|
|
184
|
+
...metadataOf(custom, fields)
|
|
185
|
+
};
|
|
186
|
+
}, "toPerson");
|
|
187
|
+
var toOrganization = /* @__PURE__ */ __name((raw, fields) => {
|
|
188
|
+
const { phones, emails, contactTypes, custom } = valuesOf(raw);
|
|
189
|
+
const people = fieldOf(raw._embedded, "contacts");
|
|
190
|
+
return {
|
|
191
|
+
externalId: id(raw.id) ?? "",
|
|
192
|
+
name: text(raw.name) ?? "",
|
|
193
|
+
...phones.length ? { phones } : {},
|
|
194
|
+
...emails.length ? { emails } : {},
|
|
195
|
+
...Object.keys(contactTypes).length ? { contactTypes } : {},
|
|
196
|
+
...Array.isArray(people) ? { people: rawsOf(people).flatMap((one) => id(one.id) ?? []) } : {},
|
|
197
|
+
assignee: id(raw.responsible_user_id),
|
|
198
|
+
createdAt: epoch(raw.created_at),
|
|
199
|
+
updatedAt: epoch(raw.updated_at),
|
|
200
|
+
...metadataOf(custom, fields)
|
|
201
|
+
};
|
|
202
|
+
}, "toOrganization");
|
|
203
|
+
var toUser = /* @__PURE__ */ __name((raw) => {
|
|
204
|
+
const externalId = id(raw.id);
|
|
205
|
+
if (!externalId)
|
|
206
|
+
return null;
|
|
207
|
+
const rights = isRaw(raw.rights) ? raw.rights : {};
|
|
208
|
+
return { externalId, name: text(raw.name), email: text(raw.email), active: rights.is_active !== false };
|
|
209
|
+
}, "toUser");
|
|
210
|
+
var toPipeline = /* @__PURE__ */ __name((raw) => {
|
|
211
|
+
const externalId = id(raw.id);
|
|
212
|
+
if (!externalId)
|
|
213
|
+
return null;
|
|
214
|
+
return {
|
|
215
|
+
externalId,
|
|
216
|
+
name: text(raw.name) ?? externalId,
|
|
217
|
+
stages: embedded(raw, "statuses").flatMap((one) => {
|
|
218
|
+
const stage = id(one.id);
|
|
219
|
+
if (!stage)
|
|
220
|
+
return [];
|
|
221
|
+
const outcome = stage === WON ? "won" : stage === LOST ? "lost" : "open";
|
|
222
|
+
return [{ externalId: stage, name: text(one.name) ?? stage, position: Number(one.sort) || 0, outcome }];
|
|
223
|
+
})
|
|
224
|
+
};
|
|
225
|
+
}, "toPipeline");
|
|
226
|
+
|
|
227
|
+
export {
|
|
228
|
+
ROUTES,
|
|
229
|
+
ENTITIES,
|
|
230
|
+
WON,
|
|
231
|
+
LOST,
|
|
232
|
+
fieldOfRaw,
|
|
233
|
+
toDeal,
|
|
234
|
+
toPerson,
|
|
235
|
+
toOrganization,
|
|
236
|
+
toUser,
|
|
237
|
+
toPipeline
|
|
238
|
+
};
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { createRequire as __bundleRequire } from "node:module";
|
|
2
|
+
const require = __bundleRequire(import.meta.url);
|
|
3
|
+
import {
|
|
4
|
+
importFrom
|
|
5
|
+
} from "./chunk-Y5E2WNWB.js";
|
|
6
|
+
import {
|
|
7
|
+
CliError
|
|
8
|
+
} from "./chunk-SZ2V62HB.js";
|
|
9
|
+
import {
|
|
10
|
+
__name
|
|
11
|
+
} from "./chunk-ZVVMGPBJ.js";
|
|
12
|
+
|
|
13
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.691.0_@wirecat+cli-base@0.113.0_commander@15.0.0_esbuild@0.28.2_typ_9a2e508bb6f63e7e29f0d776540ec8fd/node_modules/@wirecat/cli-core/dist/store/vector-extension.js
|
|
14
|
+
import { readFileSync } from "node:fs";
|
|
15
|
+
var musl = /* @__PURE__ */ __name(() => {
|
|
16
|
+
if (process.platform !== "linux")
|
|
17
|
+
return false;
|
|
18
|
+
try {
|
|
19
|
+
return readFileSync("/proc/self/maps", "utf8").includes("ld-musl");
|
|
20
|
+
} catch {
|
|
21
|
+
return false;
|
|
22
|
+
}
|
|
23
|
+
}, "musl");
|
|
24
|
+
var found;
|
|
25
|
+
var vectorExtension = /* @__PURE__ */ __name(() => {
|
|
26
|
+
found ??= locate();
|
|
27
|
+
return found;
|
|
28
|
+
}, "vectorExtension");
|
|
29
|
+
var locate = /* @__PURE__ */ __name(async () => {
|
|
30
|
+
const onMusl = musl();
|
|
31
|
+
const target = `${process.platform}-${process.arch}${onMusl ? "-musl" : ""}`;
|
|
32
|
+
let path;
|
|
33
|
+
try {
|
|
34
|
+
const { extensionFor } = await importFrom(new URL("store/vector-extension.js", import.meta.resolve("@wirecat/cli-core")).href, "@wirecat/cli-core-sqlite");
|
|
35
|
+
path = extensionFor({ musl: onMusl });
|
|
36
|
+
} catch {
|
|
37
|
+
path = void 0;
|
|
38
|
+
}
|
|
39
|
+
if (path === void 0) {
|
|
40
|
+
found = void 0;
|
|
41
|
+
throw new CliError("configuration_error", `the message store needs the sqlite-vec extension, and @wirecat/cli-core-sqlite has none for ${target} \u2014 reinstall the CLI so its dependencies install with it (an install that skips optional or native packages leaves it out)`, { reason: "store.vector-extension-missing", target });
|
|
42
|
+
}
|
|
43
|
+
return path;
|
|
44
|
+
}, "locate");
|
|
45
|
+
var loadVectorExtension = /* @__PURE__ */ __name((database, path) => {
|
|
46
|
+
try {
|
|
47
|
+
database.loadExtension(path);
|
|
48
|
+
} catch (error) {
|
|
49
|
+
throw new CliError("configuration_error", `the sqlite-vec extension did not load on ${process.platform}-${process.arch} \u2014 reinstall the CLI; on macOS under Bun, @wirecat/cli-core-sqlite's SQLite must be installed, since the system's cannot load extensions`, { reason: "store.vector-extension-failed", cause: error instanceof Error ? error.message : String(error) });
|
|
50
|
+
} finally {
|
|
51
|
+
database.enableLoadExtension?.(false);
|
|
52
|
+
}
|
|
53
|
+
}, "loadVectorExtension");
|
|
54
|
+
|
|
55
|
+
export {
|
|
56
|
+
vectorExtension,
|
|
57
|
+
loadVectorExtension
|
|
58
|
+
};
|