@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,2336 @@
|
|
|
1
|
+
import { createRequire as __bundleRequire } from "node:module";
|
|
2
|
+
const require = __bundleRequire(import.meta.url);
|
|
3
|
+
import {
|
|
4
|
+
ENTITIES,
|
|
5
|
+
ROUTES,
|
|
6
|
+
fieldOfRaw,
|
|
7
|
+
toDeal,
|
|
8
|
+
toOrganization,
|
|
9
|
+
toPerson,
|
|
10
|
+
toPipeline,
|
|
11
|
+
toUser
|
|
12
|
+
} from "./chunk-LDEBZ3IX.js";
|
|
13
|
+
import {
|
|
14
|
+
values_exports
|
|
15
|
+
} from "./chunk-2I5UVMLW.js";
|
|
16
|
+
import {
|
|
17
|
+
CliError,
|
|
18
|
+
isCliError
|
|
19
|
+
} from "./chunk-SZ2V62HB.js";
|
|
20
|
+
import {
|
|
21
|
+
__name
|
|
22
|
+
} from "./chunk-ZVVMGPBJ.js";
|
|
23
|
+
|
|
24
|
+
// dist/amo/allow-list.js
|
|
25
|
+
var LINKS = "https://www.amocrm.ru/developers/content/crm_platform/entity-links-api";
|
|
26
|
+
var ENTITY_TYPES = {
|
|
27
|
+
values: ["leads", "contacts", "companies", "customers"],
|
|
28
|
+
sources: [
|
|
29
|
+
LINKS,
|
|
30
|
+
"https://www.amocrm.ru/developers/content/crm_platform/custom-fields",
|
|
31
|
+
"https://www.amocrm.ru/developers/content/crm_platform/tags-api",
|
|
32
|
+
"https://www.amocrm.ru/developers/content/crm_platform/events-and-notes"
|
|
33
|
+
]
|
|
34
|
+
};
|
|
35
|
+
var EXTRA_OPERATIONS = [
|
|
36
|
+
{
|
|
37
|
+
// The mass form beside the spec's `/{entity}/{entity_id}/links`: the links of many records in one call.
|
|
38
|
+
name: "GET /api/v4/{entity_type}/links",
|
|
39
|
+
effect: "read",
|
|
40
|
+
summary: "Get the links of many entities",
|
|
41
|
+
source: LINKS,
|
|
42
|
+
path: { entity_type: { type: "string" } },
|
|
43
|
+
query: ["filter[entity_id][]", "filter[to_entity_id]", "filter[to_entity_type]", "filter[to_catalog_id]"],
|
|
44
|
+
body: false
|
|
45
|
+
}
|
|
46
|
+
];
|
|
47
|
+
var WITH_VALUES = Object.fromEntries([
|
|
48
|
+
[
|
|
49
|
+
["GET /api/v4/account"],
|
|
50
|
+
"amojo_id,version,drive_url,task_types,users_groups,datetime_settings,entity_names,is_api_filter_enabled",
|
|
51
|
+
"https://www.amocrm.ru/developers/content/crm_platform/account-info"
|
|
52
|
+
],
|
|
53
|
+
[
|
|
54
|
+
["GET /api/v4/leads", "GET /api/v4/leads/{id}"],
|
|
55
|
+
"catalog_elements,is_price_modified_by_robot,loss_reason,contacts,only_deleted,source_id,source",
|
|
56
|
+
"https://www.amocrm.ru/developers/content/crm_platform/leads-api"
|
|
57
|
+
],
|
|
58
|
+
[
|
|
59
|
+
["GET /api/v4/contacts", "GET /api/v4/contacts/{id}"],
|
|
60
|
+
"catalog_elements,leads,customers",
|
|
61
|
+
"https://www.amocrm.ru/developers/content/crm_platform/contacts-api"
|
|
62
|
+
],
|
|
63
|
+
[
|
|
64
|
+
["GET /api/v4/companies", "GET /api/v4/companies/{id}"],
|
|
65
|
+
"catalog_elements,leads,customers,contacts",
|
|
66
|
+
"https://www.amocrm.ru/developers/content/crm_platform/companies-api"
|
|
67
|
+
],
|
|
68
|
+
[
|
|
69
|
+
["GET /api/v4/events"],
|
|
70
|
+
"contact_name,lead_name,company_name,catalog_element_name,customer_name,catalog_name",
|
|
71
|
+
"https://www.amocrm.ru/developers/content/crm_platform/events-and-notes"
|
|
72
|
+
],
|
|
73
|
+
[
|
|
74
|
+
["GET /api/v4/users", "GET /api/v4/users/{id}"],
|
|
75
|
+
"role,group,uuid,amojo_id,user_rank,phone_number",
|
|
76
|
+
"https://www.amocrm.ru/developers/content/crm_platform/users-api"
|
|
77
|
+
]
|
|
78
|
+
].flatMap(([names, values, source]) => names.map((name) => [name, { values: values.split(","), source }])));
|
|
79
|
+
|
|
80
|
+
// dist/amo/operations.js
|
|
81
|
+
var SPEC_OPERATIONS = [
|
|
82
|
+
{
|
|
83
|
+
name: "DELETE /api/v4/{entity_type}/custom_fields/groups/{id}",
|
|
84
|
+
effect: "destructive",
|
|
85
|
+
summary: "",
|
|
86
|
+
source: "https://developers.kommo.com/reference/delete-a-field-group",
|
|
87
|
+
path: { entity_type: { type: "string" }, id: { type: "string" } },
|
|
88
|
+
query: [],
|
|
89
|
+
body: false
|
|
90
|
+
},
|
|
91
|
+
{
|
|
92
|
+
name: "DELETE /api/v4/{entity}/{entity_id}/files",
|
|
93
|
+
effect: "destructive",
|
|
94
|
+
summary: "Detach files from an entity",
|
|
95
|
+
source: "https://developers.kommo.com/reference/detach-files",
|
|
96
|
+
path: { entity: { type: "string" }, entity_id: { type: "integer" } },
|
|
97
|
+
query: [],
|
|
98
|
+
body: true
|
|
99
|
+
},
|
|
100
|
+
{
|
|
101
|
+
name: "DELETE /api/v4/{entity}/custom_fields/{id}",
|
|
102
|
+
effect: "destructive",
|
|
103
|
+
summary: "Deleting a custom field",
|
|
104
|
+
source: "https://developers.kommo.com/reference/delete-custom-field",
|
|
105
|
+
path: { entity: { type: "string" }, id: { type: "integer" } },
|
|
106
|
+
query: [],
|
|
107
|
+
body: false
|
|
108
|
+
},
|
|
109
|
+
{
|
|
110
|
+
name: "DELETE /api/v4/chats/templates",
|
|
111
|
+
effect: "destructive",
|
|
112
|
+
summary: "Delete templates",
|
|
113
|
+
source: "https://developers.kommo.com/reference/delete-templates",
|
|
114
|
+
path: {},
|
|
115
|
+
query: [],
|
|
116
|
+
body: true
|
|
117
|
+
},
|
|
118
|
+
{
|
|
119
|
+
name: "DELETE /api/v4/chats/templates/{id}",
|
|
120
|
+
effect: "destructive",
|
|
121
|
+
summary: "Delete a template",
|
|
122
|
+
source: "https://developers.kommo.com/reference/delete-template",
|
|
123
|
+
path: { id: { type: "integer" } },
|
|
124
|
+
query: [],
|
|
125
|
+
body: false
|
|
126
|
+
},
|
|
127
|
+
{
|
|
128
|
+
name: "DELETE /api/v4/leads/pipelines/{id}",
|
|
129
|
+
effect: "destructive",
|
|
130
|
+
summary: "Delete pipeline",
|
|
131
|
+
source: "https://developers.kommo.com/reference/delete-pipeline",
|
|
132
|
+
path: { id: { type: "integer" } },
|
|
133
|
+
query: [],
|
|
134
|
+
body: false
|
|
135
|
+
},
|
|
136
|
+
{
|
|
137
|
+
name: "DELETE /api/v4/leads/pipelines/{pipeline_id}/statuses/{id}",
|
|
138
|
+
effect: "destructive",
|
|
139
|
+
summary: "Delete pipeline stage",
|
|
140
|
+
source: "https://developers.kommo.com/reference/deleting-stage",
|
|
141
|
+
path: { pipeline_id: { type: "integer" }, id: { type: "integer" } },
|
|
142
|
+
query: [],
|
|
143
|
+
body: false
|
|
144
|
+
},
|
|
145
|
+
{
|
|
146
|
+
name: "DELETE /api/v4/leads/unsorted/{uid}/decline",
|
|
147
|
+
effect: "destructive",
|
|
148
|
+
summary: "Declining incoming leads",
|
|
149
|
+
source: "https://developers.kommo.com/reference/declining-incoming-leads",
|
|
150
|
+
path: { uid: { type: "string" } },
|
|
151
|
+
query: [],
|
|
152
|
+
body: true
|
|
153
|
+
},
|
|
154
|
+
{
|
|
155
|
+
name: "DELETE /api/v4/roles/{id}",
|
|
156
|
+
effect: "destructive",
|
|
157
|
+
summary: "Delete role",
|
|
158
|
+
source: "https://developers.kommo.com/reference/deleting-role",
|
|
159
|
+
path: { id: { type: "integer" } },
|
|
160
|
+
query: [],
|
|
161
|
+
body: false
|
|
162
|
+
},
|
|
163
|
+
{
|
|
164
|
+
name: "DELETE /api/v4/sources",
|
|
165
|
+
effect: "destructive",
|
|
166
|
+
summary: "Delete sources",
|
|
167
|
+
source: "https://developers.kommo.com/reference/delete-sources",
|
|
168
|
+
path: {},
|
|
169
|
+
query: [],
|
|
170
|
+
body: true
|
|
171
|
+
},
|
|
172
|
+
{
|
|
173
|
+
name: "DELETE /api/v4/sources/{id}",
|
|
174
|
+
effect: "destructive",
|
|
175
|
+
summary: "Delete source",
|
|
176
|
+
source: "https://developers.kommo.com/reference/delete-source",
|
|
177
|
+
path: { id: { type: "integer" } },
|
|
178
|
+
query: [],
|
|
179
|
+
body: false
|
|
180
|
+
},
|
|
181
|
+
{
|
|
182
|
+
name: "DELETE /api/v4/webhooks",
|
|
183
|
+
effect: "destructive",
|
|
184
|
+
summary: "Delete webhook",
|
|
185
|
+
source: "https://developers.kommo.com/reference/delete-webhook",
|
|
186
|
+
path: {},
|
|
187
|
+
query: [],
|
|
188
|
+
body: true
|
|
189
|
+
},
|
|
190
|
+
{
|
|
191
|
+
name: "DELETE /api/v4/widgets/{widget_code}",
|
|
192
|
+
effect: "destructive",
|
|
193
|
+
summary: "Uninstalling widget",
|
|
194
|
+
source: "https://developers.kommo.com/reference/uninstall-widget",
|
|
195
|
+
path: { widget_code: { type: "string" } },
|
|
196
|
+
query: [],
|
|
197
|
+
body: false
|
|
198
|
+
},
|
|
199
|
+
{
|
|
200
|
+
name: "GET /api/v4/{entity_type}/{entity_id}/notes",
|
|
201
|
+
effect: "read",
|
|
202
|
+
summary: "Get notes list of entity",
|
|
203
|
+
source: "https://developers.kommo.com/reference/notes-by-entity-id",
|
|
204
|
+
path: { entity_type: { type: "string" }, entity_id: { type: "integer" } },
|
|
205
|
+
query: [
|
|
206
|
+
"page",
|
|
207
|
+
"limit",
|
|
208
|
+
"filter[id][]",
|
|
209
|
+
"filter[note_type][]",
|
|
210
|
+
"filter[updated_at][from]",
|
|
211
|
+
"filter[updated_at][to]",
|
|
212
|
+
"order[updated_at]",
|
|
213
|
+
"order[id]",
|
|
214
|
+
"with"
|
|
215
|
+
],
|
|
216
|
+
body: false
|
|
217
|
+
},
|
|
218
|
+
{
|
|
219
|
+
name: "GET /api/v4/{entity_type}/custom_fields",
|
|
220
|
+
effect: "read",
|
|
221
|
+
summary: "Custom fields list",
|
|
222
|
+
source: "https://developers.kommo.com/reference/custom-field-by-entity",
|
|
223
|
+
path: { entity_type: { type: "string", enum: ["leads", "companies", "contacts"] } },
|
|
224
|
+
query: ["page", "limit", "order[sort]", "order[id]", "filter[type][0]"],
|
|
225
|
+
body: false
|
|
226
|
+
},
|
|
227
|
+
{
|
|
228
|
+
name: "GET /api/v4/{entity_type}/custom_fields/{id}",
|
|
229
|
+
effect: "read",
|
|
230
|
+
summary: "Get entity field by ID",
|
|
231
|
+
source: "https://developers.kommo.com/reference/custom-fields-by-id",
|
|
232
|
+
path: { entity_type: { type: "string", enum: ["leads", "companies", "contacts"] }, id: { type: "integer" } },
|
|
233
|
+
query: [],
|
|
234
|
+
body: false
|
|
235
|
+
},
|
|
236
|
+
{
|
|
237
|
+
name: "GET /api/v4/{entity_type}/custom_fields/groups",
|
|
238
|
+
effect: "read",
|
|
239
|
+
summary: "",
|
|
240
|
+
source: "https://developers.kommo.com/reference/list-of-entity-field-groups",
|
|
241
|
+
path: { entity_type: { type: "string" } },
|
|
242
|
+
query: [],
|
|
243
|
+
body: false
|
|
244
|
+
},
|
|
245
|
+
{
|
|
246
|
+
name: "GET /api/v4/{entity_type}/custom_fields/groups/{id}",
|
|
247
|
+
effect: "read",
|
|
248
|
+
summary: "",
|
|
249
|
+
source: "https://developers.kommo.com/reference/get-a-fields-group-by-id",
|
|
250
|
+
path: { entity_type: { type: "string" }, id: { type: "string" } },
|
|
251
|
+
query: [],
|
|
252
|
+
body: false
|
|
253
|
+
},
|
|
254
|
+
{
|
|
255
|
+
name: "GET /api/v4/{entity_type}/notes",
|
|
256
|
+
effect: "read",
|
|
257
|
+
summary: "Get notes list by entity type",
|
|
258
|
+
source: "https://developers.kommo.com/reference/notes-list-entity",
|
|
259
|
+
path: { entity_type: { type: "string", enum: ["leads", "contacts", "companies"] } },
|
|
260
|
+
query: [
|
|
261
|
+
"page",
|
|
262
|
+
"limit",
|
|
263
|
+
"filter[id][]",
|
|
264
|
+
"filter[note_type][]",
|
|
265
|
+
"filter[updated_at][from]",
|
|
266
|
+
"filter[updated_at][to]",
|
|
267
|
+
"order[updated_at]",
|
|
268
|
+
"order[id]",
|
|
269
|
+
"with"
|
|
270
|
+
],
|
|
271
|
+
body: false
|
|
272
|
+
},
|
|
273
|
+
{
|
|
274
|
+
name: "GET /api/v4/{entity_type}/notes/{id}",
|
|
275
|
+
effect: "read",
|
|
276
|
+
summary: "Get note by ID",
|
|
277
|
+
source: "https://developers.kommo.com/reference/note-by-id",
|
|
278
|
+
path: { entity_type: { type: "string" }, id: { type: "integer" } },
|
|
279
|
+
query: [],
|
|
280
|
+
body: false
|
|
281
|
+
},
|
|
282
|
+
{
|
|
283
|
+
name: "GET /api/v4/{entity_type}/tags",
|
|
284
|
+
effect: "read",
|
|
285
|
+
summary: "List of entity tags",
|
|
286
|
+
source: "https://developers.kommo.com/reference/list-of-entity-tags",
|
|
287
|
+
path: { entity_type: { type: "string", enum: ["leads", "contacts", "companies"] } },
|
|
288
|
+
query: ["page", "limit", "query", "filter[id][]", "filter[name]"],
|
|
289
|
+
body: false
|
|
290
|
+
},
|
|
291
|
+
{
|
|
292
|
+
name: "GET /api/v4/{entity}/{entity_id}/files",
|
|
293
|
+
effect: "read",
|
|
294
|
+
summary: "Get files attached to an entity",
|
|
295
|
+
source: "https://developers.kommo.com/reference/get-files-entity",
|
|
296
|
+
path: { entity: { type: "string" }, entity_id: { type: "integer" } },
|
|
297
|
+
query: ["limit", "before_id"],
|
|
298
|
+
body: false
|
|
299
|
+
},
|
|
300
|
+
{
|
|
301
|
+
name: "GET /api/v4/{entity}/{entity_id}/links",
|
|
302
|
+
effect: "read",
|
|
303
|
+
summary: "Linked entities list",
|
|
304
|
+
source: "https://developers.kommo.com/reference/linked-entities",
|
|
305
|
+
path: { entity: { type: "string", enum: ["leads", "contacts", "companies"] }, entity_id: { type: "integer" } },
|
|
306
|
+
query: ["filter[to_entity_id]", "filter[to_entity_type]", "filter[to_catalog_id]"],
|
|
307
|
+
body: false
|
|
308
|
+
},
|
|
309
|
+
{
|
|
310
|
+
name: "GET /api/v4/account",
|
|
311
|
+
effect: "read",
|
|
312
|
+
summary: "Account parameters",
|
|
313
|
+
source: "https://developers.kommo.com/reference/account-parameters",
|
|
314
|
+
path: {},
|
|
315
|
+
query: ["with"],
|
|
316
|
+
body: false
|
|
317
|
+
},
|
|
318
|
+
{
|
|
319
|
+
name: "GET /api/v4/bots",
|
|
320
|
+
effect: "read",
|
|
321
|
+
summary: "Salesbots list",
|
|
322
|
+
source: "https://developers.kommo.com/reference/salesbots-list",
|
|
323
|
+
path: {},
|
|
324
|
+
query: ["page", "limit", "filter[type_functionality][]", "filter[id][]", "with"],
|
|
325
|
+
body: false
|
|
326
|
+
},
|
|
327
|
+
{
|
|
328
|
+
name: "GET /api/v4/bots/{id}",
|
|
329
|
+
effect: "read",
|
|
330
|
+
summary: "Get a Salesbot by ID",
|
|
331
|
+
source: "https://developers.kommo.com/reference/get-salesbot-by-id",
|
|
332
|
+
path: { id: { type: "integer" } },
|
|
333
|
+
query: ["with"],
|
|
334
|
+
body: false
|
|
335
|
+
},
|
|
336
|
+
{
|
|
337
|
+
name: "GET /api/v4/catalogs",
|
|
338
|
+
effect: "read",
|
|
339
|
+
summary: "Get lists",
|
|
340
|
+
source: "https://developers.kommo.com/reference/get-lists",
|
|
341
|
+
path: {},
|
|
342
|
+
query: ["page", "limit"],
|
|
343
|
+
body: false
|
|
344
|
+
},
|
|
345
|
+
{
|
|
346
|
+
name: "GET /api/v4/catalogs/{id}",
|
|
347
|
+
effect: "read",
|
|
348
|
+
summary: "Get list",
|
|
349
|
+
source: "https://developers.kommo.com/reference/get-list",
|
|
350
|
+
path: { id: { type: "integer" } },
|
|
351
|
+
query: [],
|
|
352
|
+
body: false
|
|
353
|
+
},
|
|
354
|
+
{
|
|
355
|
+
name: "GET /api/v4/catalogs/{list_id}/custom_fields",
|
|
356
|
+
effect: "read",
|
|
357
|
+
summary: "Custom fields list of a list",
|
|
358
|
+
source: "https://developers.kommo.com/reference/custom-fields-list-of-list",
|
|
359
|
+
path: { list_id: { type: "integer" } },
|
|
360
|
+
query: ["page", "limit", "order[sort]", "order[id]", "filter[type][0]"],
|
|
361
|
+
body: false
|
|
362
|
+
},
|
|
363
|
+
{
|
|
364
|
+
name: "GET /api/v4/catalogs/{list_id}/custom_fields/{custom_field_id}",
|
|
365
|
+
effect: "read",
|
|
366
|
+
summary: "Getting a list field by its ID",
|
|
367
|
+
source: "https://developers.kommo.com/reference/get-list-custom-field",
|
|
368
|
+
path: { list_id: { type: "integer" }, custom_field_id: { type: "integer" } },
|
|
369
|
+
query: [],
|
|
370
|
+
body: false
|
|
371
|
+
},
|
|
372
|
+
{
|
|
373
|
+
name: "GET /api/v4/catalogs/{list_id}/elements",
|
|
374
|
+
effect: "read",
|
|
375
|
+
summary: "Get list elements",
|
|
376
|
+
source: "https://developers.kommo.com/reference/get-list-elements",
|
|
377
|
+
path: { list_id: { type: "integer" } },
|
|
378
|
+
query: ["page", "limit", "query", "filter[id][]"],
|
|
379
|
+
body: false
|
|
380
|
+
},
|
|
381
|
+
{
|
|
382
|
+
name: "GET /api/v4/catalogs/{list_id}/elements/{element_id}",
|
|
383
|
+
effect: "read",
|
|
384
|
+
summary: "Get list element",
|
|
385
|
+
source: "https://developers.kommo.com/reference/get-list-element",
|
|
386
|
+
path: { list_id: { type: "integer" }, element_id: { type: "integer" } },
|
|
387
|
+
query: [],
|
|
388
|
+
body: false
|
|
389
|
+
},
|
|
390
|
+
{
|
|
391
|
+
name: "GET /api/v4/chats/templates",
|
|
392
|
+
effect: "read",
|
|
393
|
+
summary: "Get list of templates",
|
|
394
|
+
source: "https://developers.kommo.com/reference/get-templates",
|
|
395
|
+
path: {},
|
|
396
|
+
query: ["page", "limit", "filter[external_id]", "with"],
|
|
397
|
+
body: false
|
|
398
|
+
},
|
|
399
|
+
{
|
|
400
|
+
name: "GET /api/v4/chats/templates/{id}",
|
|
401
|
+
effect: "read",
|
|
402
|
+
summary: "Get template by ID",
|
|
403
|
+
source: "https://developers.kommo.com/reference/get-template",
|
|
404
|
+
path: { id: { type: "integer" } },
|
|
405
|
+
query: ["with"],
|
|
406
|
+
body: false
|
|
407
|
+
},
|
|
408
|
+
{
|
|
409
|
+
name: "GET /api/v4/companies",
|
|
410
|
+
effect: "read",
|
|
411
|
+
summary: "Companies list",
|
|
412
|
+
source: "https://developers.kommo.com/reference/companies-list",
|
|
413
|
+
path: {},
|
|
414
|
+
query: [
|
|
415
|
+
"with",
|
|
416
|
+
"page",
|
|
417
|
+
"limit",
|
|
418
|
+
"query",
|
|
419
|
+
"order[updated_at]",
|
|
420
|
+
"order[id]",
|
|
421
|
+
"filter[id][]",
|
|
422
|
+
"filter[name][]",
|
|
423
|
+
"filter[created_by][]",
|
|
424
|
+
"filter[updated_by][]",
|
|
425
|
+
"filter[responsible_user_id][]",
|
|
426
|
+
"filter[created_at][from]",
|
|
427
|
+
"filter[created_at][to]",
|
|
428
|
+
"filter[updated_at][from]",
|
|
429
|
+
"filter[updated_at][to]",
|
|
430
|
+
"filter[closest_task_at][from]",
|
|
431
|
+
"filter[closest_task_at][to]"
|
|
432
|
+
],
|
|
433
|
+
body: false
|
|
434
|
+
},
|
|
435
|
+
{
|
|
436
|
+
name: "GET /api/v4/companies/{id}",
|
|
437
|
+
effect: "read",
|
|
438
|
+
summary: "Get company by ID",
|
|
439
|
+
source: "https://developers.kommo.com/reference/get-company",
|
|
440
|
+
path: { id: { type: "integer" } },
|
|
441
|
+
query: ["with"],
|
|
442
|
+
body: false
|
|
443
|
+
},
|
|
444
|
+
{
|
|
445
|
+
name: "GET /api/v4/contacts",
|
|
446
|
+
effect: "read",
|
|
447
|
+
summary: "Contacts List",
|
|
448
|
+
source: "https://developers.kommo.com/reference/contacts-list",
|
|
449
|
+
path: {},
|
|
450
|
+
query: [
|
|
451
|
+
"with",
|
|
452
|
+
"page",
|
|
453
|
+
"limit",
|
|
454
|
+
"query",
|
|
455
|
+
"order[updated_at]",
|
|
456
|
+
"order[id]",
|
|
457
|
+
"filter[id][]",
|
|
458
|
+
"filter[name][]",
|
|
459
|
+
"filter[created_by][]",
|
|
460
|
+
"filter[updated_by][]",
|
|
461
|
+
"filter[responsible_user_id][]",
|
|
462
|
+
"filter[updated_at][from]",
|
|
463
|
+
"filter[updated_at][to]",
|
|
464
|
+
"filter[closest_task_at][from]",
|
|
465
|
+
"filter[closest_task_at][to]"
|
|
466
|
+
],
|
|
467
|
+
body: false
|
|
468
|
+
},
|
|
469
|
+
{
|
|
470
|
+
name: "GET /api/v4/contacts/{id}",
|
|
471
|
+
effect: "read",
|
|
472
|
+
summary: "Get contact by ID",
|
|
473
|
+
source: "https://developers.kommo.com/reference/get-contact",
|
|
474
|
+
path: { id: { type: "integer" } },
|
|
475
|
+
query: ["with"],
|
|
476
|
+
body: false
|
|
477
|
+
},
|
|
478
|
+
{
|
|
479
|
+
name: "GET /api/v4/contacts/chats",
|
|
480
|
+
effect: "read",
|
|
481
|
+
summary: "Get contact chats",
|
|
482
|
+
source: "https://developers.kommo.com/reference/get-contact-chats",
|
|
483
|
+
path: {},
|
|
484
|
+
query: ["contact_id", "chat_id"],
|
|
485
|
+
body: false
|
|
486
|
+
},
|
|
487
|
+
{
|
|
488
|
+
name: "GET /api/v4/events",
|
|
489
|
+
effect: "read",
|
|
490
|
+
summary: "Events list",
|
|
491
|
+
source: "https://developers.kommo.com/reference/events-list",
|
|
492
|
+
path: {},
|
|
493
|
+
query: [
|
|
494
|
+
"with",
|
|
495
|
+
"page",
|
|
496
|
+
"limit",
|
|
497
|
+
"filter[id]",
|
|
498
|
+
"filter[created_at][from]",
|
|
499
|
+
"filter[created_at][to]",
|
|
500
|
+
"filter[created_by]",
|
|
501
|
+
"filter[entity]",
|
|
502
|
+
"filter[entity_id]",
|
|
503
|
+
"filter[type]"
|
|
504
|
+
],
|
|
505
|
+
body: false
|
|
506
|
+
},
|
|
507
|
+
{
|
|
508
|
+
name: "GET /api/v4/events/{id}",
|
|
509
|
+
effect: "read",
|
|
510
|
+
summary: "Get event by ID",
|
|
511
|
+
source: "https://developers.kommo.com/reference/get-event",
|
|
512
|
+
path: { id: { type: "string" } },
|
|
513
|
+
query: ["with"],
|
|
514
|
+
body: false
|
|
515
|
+
},
|
|
516
|
+
{
|
|
517
|
+
name: "GET /api/v4/events/types",
|
|
518
|
+
effect: "read",
|
|
519
|
+
summary: "Getting events types",
|
|
520
|
+
source: "https://developers.kommo.com/reference/get-events-types",
|
|
521
|
+
path: {},
|
|
522
|
+
query: ["language_code"],
|
|
523
|
+
body: false
|
|
524
|
+
},
|
|
525
|
+
{
|
|
526
|
+
name: "GET /api/v4/files/{file_uuid}/links",
|
|
527
|
+
effect: "read",
|
|
528
|
+
summary: "Get entities associated with a file",
|
|
529
|
+
source: "https://developers.kommo.com/reference/get-entities-with-file",
|
|
530
|
+
path: { file_uuid: { type: "string" } },
|
|
531
|
+
query: [],
|
|
532
|
+
body: false
|
|
533
|
+
},
|
|
534
|
+
{
|
|
535
|
+
name: "GET /api/v4/leads",
|
|
536
|
+
effect: "read",
|
|
537
|
+
summary: "Get leads",
|
|
538
|
+
source: "https://developers.kommo.com/reference/leads-list",
|
|
539
|
+
path: {},
|
|
540
|
+
query: [
|
|
541
|
+
"with",
|
|
542
|
+
"page",
|
|
543
|
+
"limit",
|
|
544
|
+
"query",
|
|
545
|
+
"order[created_at]",
|
|
546
|
+
"order[updated_at]",
|
|
547
|
+
"order[id]",
|
|
548
|
+
"filter[id][]",
|
|
549
|
+
"filter[name][]",
|
|
550
|
+
"filter[price]",
|
|
551
|
+
"filter[created_by][]",
|
|
552
|
+
"filter[updated_by][]",
|
|
553
|
+
"filter[responsible_user_id][]",
|
|
554
|
+
"filter[created_at][from]",
|
|
555
|
+
"filter[created_at][to]",
|
|
556
|
+
"filter[updated_at][from]",
|
|
557
|
+
"filter[updated_at][to]",
|
|
558
|
+
"filter[closed_at][from]",
|
|
559
|
+
"filter[closed_at][to]",
|
|
560
|
+
"filter[closest_task_at][from]",
|
|
561
|
+
"filter[closest_task_at][to]",
|
|
562
|
+
"filter[pipeline_id][]",
|
|
563
|
+
"filter[statuses][0][pipeline_id]",
|
|
564
|
+
"filter[statuses][0][status_id]"
|
|
565
|
+
],
|
|
566
|
+
body: false
|
|
567
|
+
},
|
|
568
|
+
{
|
|
569
|
+
name: "GET /api/v4/leads/{id}",
|
|
570
|
+
effect: "read",
|
|
571
|
+
summary: "Get lead by ID",
|
|
572
|
+
source: "https://developers.kommo.com/reference/getting-a-lead-by-its-id",
|
|
573
|
+
path: { id: { type: "integer" } },
|
|
574
|
+
query: ["with"],
|
|
575
|
+
body: false
|
|
576
|
+
},
|
|
577
|
+
{
|
|
578
|
+
name: "GET /api/v4/leads/{id}/subscriptions",
|
|
579
|
+
effect: "read",
|
|
580
|
+
summary: "Get lead subscribers",
|
|
581
|
+
source: "https://developers.kommo.com/reference/get-lead-subscribers",
|
|
582
|
+
path: { id: { type: "integer" } },
|
|
583
|
+
query: ["page", "limit"],
|
|
584
|
+
body: false
|
|
585
|
+
},
|
|
586
|
+
{
|
|
587
|
+
name: "GET /api/v4/leads/loss_reasons",
|
|
588
|
+
effect: "read",
|
|
589
|
+
summary: "Get loss reasons",
|
|
590
|
+
source: "https://developers.kommo.com/reference/loss-reasons",
|
|
591
|
+
path: {},
|
|
592
|
+
query: [],
|
|
593
|
+
body: false
|
|
594
|
+
},
|
|
595
|
+
{
|
|
596
|
+
name: "GET /api/v4/leads/loss_reasons/{id}",
|
|
597
|
+
effect: "read",
|
|
598
|
+
summary: "Get loss reason by ID",
|
|
599
|
+
source: "https://developers.kommo.com/reference/loss-reason-by-id",
|
|
600
|
+
path: { id: { type: "string" } },
|
|
601
|
+
query: [],
|
|
602
|
+
body: false
|
|
603
|
+
},
|
|
604
|
+
{
|
|
605
|
+
name: "GET /api/v4/leads/pipelines",
|
|
606
|
+
effect: "read",
|
|
607
|
+
summary: "Get pipelines",
|
|
608
|
+
source: "https://developers.kommo.com/reference/pipelines-list",
|
|
609
|
+
path: {},
|
|
610
|
+
query: [],
|
|
611
|
+
body: false
|
|
612
|
+
},
|
|
613
|
+
{
|
|
614
|
+
name: "GET /api/v4/leads/pipelines/{id}",
|
|
615
|
+
effect: "read",
|
|
616
|
+
summary: "Get pipeline by ID",
|
|
617
|
+
source: "https://developers.kommo.com/reference/get-pipeline-by-id",
|
|
618
|
+
path: { id: { type: "integer" } },
|
|
619
|
+
query: [],
|
|
620
|
+
body: false
|
|
621
|
+
},
|
|
622
|
+
{
|
|
623
|
+
name: "GET /api/v4/leads/pipelines/{pipeline_id}/statuses",
|
|
624
|
+
effect: "read",
|
|
625
|
+
summary: "Pipeline stages list",
|
|
626
|
+
source: "https://developers.kommo.com/reference/stages-list",
|
|
627
|
+
path: { pipeline_id: { type: "integer" } },
|
|
628
|
+
query: ["with"],
|
|
629
|
+
body: false
|
|
630
|
+
},
|
|
631
|
+
{
|
|
632
|
+
name: "GET /api/v4/leads/pipelines/{pipeline_id}/statuses/{id}",
|
|
633
|
+
effect: "read",
|
|
634
|
+
summary: "Get pipeline stage by ID",
|
|
635
|
+
source: "https://developers.kommo.com/reference/get-stage",
|
|
636
|
+
path: { pipeline_id: { type: "integer" }, id: { type: "integer" } },
|
|
637
|
+
query: ["with"],
|
|
638
|
+
body: false
|
|
639
|
+
},
|
|
640
|
+
{
|
|
641
|
+
name: "GET /api/v4/leads/unsorted",
|
|
642
|
+
effect: "read",
|
|
643
|
+
summary: "Incoming leads list",
|
|
644
|
+
source: "https://developers.kommo.com/reference/incoming-leads-list",
|
|
645
|
+
path: {},
|
|
646
|
+
query: ["page", "limit", "filter[uid]", "filter[category]", "filter[pipeline_id]", "order[created_at]"],
|
|
647
|
+
body: false
|
|
648
|
+
},
|
|
649
|
+
{
|
|
650
|
+
name: "GET /api/v4/leads/unsorted/{uid}",
|
|
651
|
+
effect: "read",
|
|
652
|
+
summary: "Get incoming lead by UID",
|
|
653
|
+
source: "https://developers.kommo.com/reference/incoming-lead-uid",
|
|
654
|
+
path: { uid: { type: "string" } },
|
|
655
|
+
query: [],
|
|
656
|
+
body: false
|
|
657
|
+
},
|
|
658
|
+
{
|
|
659
|
+
name: "GET /api/v4/leads/unsorted/summary",
|
|
660
|
+
effect: "read",
|
|
661
|
+
summary: "Incoming leads summary information",
|
|
662
|
+
source: "https://developers.kommo.com/reference/incoming-leads-summary",
|
|
663
|
+
path: {},
|
|
664
|
+
query: [
|
|
665
|
+
"filter[uid]",
|
|
666
|
+
"filter[created_at]",
|
|
667
|
+
"filter[created_at][from]",
|
|
668
|
+
"filter[created_at][to]",
|
|
669
|
+
"filter[pipeline_id]"
|
|
670
|
+
],
|
|
671
|
+
body: false
|
|
672
|
+
},
|
|
673
|
+
{
|
|
674
|
+
name: "GET /api/v4/roles",
|
|
675
|
+
effect: "read",
|
|
676
|
+
summary: "User roles list",
|
|
677
|
+
source: "https://developers.kommo.com/reference/user-roles-list",
|
|
678
|
+
path: {},
|
|
679
|
+
query: ["with", "page", "limit"],
|
|
680
|
+
body: false
|
|
681
|
+
},
|
|
682
|
+
{
|
|
683
|
+
name: "GET /api/v4/roles/{id}",
|
|
684
|
+
effect: "read",
|
|
685
|
+
summary: "Get role by ID",
|
|
686
|
+
source: "https://developers.kommo.com/reference/get-role-data-by-id",
|
|
687
|
+
path: { id: { type: "integer" } },
|
|
688
|
+
query: ["with"],
|
|
689
|
+
body: false
|
|
690
|
+
},
|
|
691
|
+
{
|
|
692
|
+
name: "GET /api/v4/sources",
|
|
693
|
+
effect: "read",
|
|
694
|
+
summary: "Get sources",
|
|
695
|
+
source: "https://developers.kommo.com/reference/get-sources",
|
|
696
|
+
path: {},
|
|
697
|
+
query: ["filter[external_id]"],
|
|
698
|
+
body: false
|
|
699
|
+
},
|
|
700
|
+
{
|
|
701
|
+
name: "GET /api/v4/sources/{id}",
|
|
702
|
+
effect: "read",
|
|
703
|
+
summary: "Get source by ID",
|
|
704
|
+
source: "https://developers.kommo.com/reference/get-source",
|
|
705
|
+
path: { id: { type: "integer" } },
|
|
706
|
+
query: [],
|
|
707
|
+
body: false
|
|
708
|
+
},
|
|
709
|
+
{
|
|
710
|
+
name: "GET /api/v4/talks",
|
|
711
|
+
effect: "read",
|
|
712
|
+
summary: "Get conversations",
|
|
713
|
+
source: "https://developers.kommo.com/reference/get-talks",
|
|
714
|
+
path: {},
|
|
715
|
+
query: [
|
|
716
|
+
"page",
|
|
717
|
+
"limit",
|
|
718
|
+
"filter[talk_id][]",
|
|
719
|
+
"filter[contact_id][]",
|
|
720
|
+
"filter[entity_id][]",
|
|
721
|
+
"filter[entity_type]",
|
|
722
|
+
"filter[only_in_work]"
|
|
723
|
+
],
|
|
724
|
+
body: false
|
|
725
|
+
},
|
|
726
|
+
{
|
|
727
|
+
name: "GET /api/v4/talks/{id}",
|
|
728
|
+
effect: "read",
|
|
729
|
+
summary: "Get conversation by ID",
|
|
730
|
+
source: "https://developers.kommo.com/reference/get-conversation",
|
|
731
|
+
path: { id: { type: "integer" } },
|
|
732
|
+
query: [],
|
|
733
|
+
body: false
|
|
734
|
+
},
|
|
735
|
+
{
|
|
736
|
+
name: "GET /api/v4/talks/{talk_id}/messages",
|
|
737
|
+
effect: "read",
|
|
738
|
+
summary: "Get conversation messages",
|
|
739
|
+
source: "https://developers.kommo.com/reference/get-conversation-messages",
|
|
740
|
+
path: { talk_id: { type: "integer" } },
|
|
741
|
+
query: ["page", "limit", "filter[created_at][from]", "filter[created_at][to]"],
|
|
742
|
+
body: false
|
|
743
|
+
},
|
|
744
|
+
{
|
|
745
|
+
name: "GET /api/v4/tasks",
|
|
746
|
+
effect: "read",
|
|
747
|
+
summary: "Tasks list",
|
|
748
|
+
source: "https://developers.kommo.com/reference/tasks-list",
|
|
749
|
+
path: {},
|
|
750
|
+
query: [
|
|
751
|
+
"page",
|
|
752
|
+
"limit",
|
|
753
|
+
"filter[responsible_user_id][]",
|
|
754
|
+
"filter[is_completed]",
|
|
755
|
+
"filter[task_type][]",
|
|
756
|
+
"filter[entity_type]",
|
|
757
|
+
"filter[entity_id][]",
|
|
758
|
+
"filter[id][]",
|
|
759
|
+
"filter[updated_at]",
|
|
760
|
+
"filter[updated_at][from]",
|
|
761
|
+
"filter[updated_at][to]",
|
|
762
|
+
"order[complete_till]",
|
|
763
|
+
"order[created_at]",
|
|
764
|
+
"order[id]"
|
|
765
|
+
],
|
|
766
|
+
body: false
|
|
767
|
+
},
|
|
768
|
+
{
|
|
769
|
+
name: "GET /api/v4/tasks/{id}",
|
|
770
|
+
effect: "read",
|
|
771
|
+
summary: "Get task by ID",
|
|
772
|
+
source: "https://developers.kommo.com/reference/task-id",
|
|
773
|
+
path: { id: { type: "integer" } },
|
|
774
|
+
query: [],
|
|
775
|
+
body: false
|
|
776
|
+
},
|
|
777
|
+
{
|
|
778
|
+
name: "GET /api/v4/users",
|
|
779
|
+
effect: "read",
|
|
780
|
+
summary: "Users list",
|
|
781
|
+
source: "https://developers.kommo.com/reference/users-list",
|
|
782
|
+
path: {},
|
|
783
|
+
query: ["with", "page", "limit"],
|
|
784
|
+
body: false
|
|
785
|
+
},
|
|
786
|
+
{
|
|
787
|
+
name: "GET /api/v4/users/{id}",
|
|
788
|
+
effect: "read",
|
|
789
|
+
summary: "Get user by ID",
|
|
790
|
+
source: "https://developers.kommo.com/reference/get-user-by-id",
|
|
791
|
+
path: { id: { type: "integer" } },
|
|
792
|
+
query: ["with"],
|
|
793
|
+
body: false
|
|
794
|
+
},
|
|
795
|
+
{
|
|
796
|
+
name: "GET /api/v4/webhooks",
|
|
797
|
+
effect: "read",
|
|
798
|
+
summary: "List of webhooks",
|
|
799
|
+
source: "https://developers.kommo.com/reference/list-webhooks",
|
|
800
|
+
path: {},
|
|
801
|
+
query: ["filter[destination]"],
|
|
802
|
+
body: false
|
|
803
|
+
},
|
|
804
|
+
{
|
|
805
|
+
name: "GET /api/v4/website_buttons",
|
|
806
|
+
effect: "read",
|
|
807
|
+
summary: "Get list of Website chat buttons",
|
|
808
|
+
source: "https://developers.kommo.com/reference/get-list-crm-plugin",
|
|
809
|
+
path: {},
|
|
810
|
+
query: ["with", "page", "limit"],
|
|
811
|
+
body: false
|
|
812
|
+
},
|
|
813
|
+
{
|
|
814
|
+
name: "GET /api/v4/website_buttons/{source_id}",
|
|
815
|
+
effect: "read",
|
|
816
|
+
summary: "Get Website chat button",
|
|
817
|
+
source: "https://developers.kommo.com/reference/get-crm-plugin",
|
|
818
|
+
path: { source_id: { type: "integer" } },
|
|
819
|
+
query: ["with"],
|
|
820
|
+
body: false
|
|
821
|
+
},
|
|
822
|
+
{
|
|
823
|
+
name: "GET /api/v4/widgets",
|
|
824
|
+
effect: "read",
|
|
825
|
+
summary: "Widgets List",
|
|
826
|
+
source: "https://developers.kommo.com/reference/widgets-list",
|
|
827
|
+
path: {},
|
|
828
|
+
query: ["page", "limit"],
|
|
829
|
+
body: false
|
|
830
|
+
},
|
|
831
|
+
{
|
|
832
|
+
name: "GET /api/v4/widgets/{widget_code}",
|
|
833
|
+
effect: "read",
|
|
834
|
+
summary: "Getting the widget info by its code",
|
|
835
|
+
source: "https://developers.kommo.com/reference/widget-by-code",
|
|
836
|
+
path: { widget_code: { type: "string" } },
|
|
837
|
+
query: [],
|
|
838
|
+
body: false
|
|
839
|
+
},
|
|
840
|
+
{
|
|
841
|
+
name: "PATCH /api/v4/{entity_type}",
|
|
842
|
+
effect: "write",
|
|
843
|
+
summary: "Adding tags to entities",
|
|
844
|
+
source: "https://developers.kommo.com/reference/update-tags",
|
|
845
|
+
path: { entity_type: { type: "string", enum: ["leads", "contacts", "companies"] } },
|
|
846
|
+
query: [],
|
|
847
|
+
body: true
|
|
848
|
+
},
|
|
849
|
+
{
|
|
850
|
+
name: "PATCH /api/v4/{entity_type}/{id}",
|
|
851
|
+
effect: "write",
|
|
852
|
+
summary: "Adding tags to a single entity",
|
|
853
|
+
source: "https://developers.kommo.com/reference/update-tags-single-entity",
|
|
854
|
+
path: { entity_type: { type: "string", enum: ["leads", "contacts", "companies"] }, id: { type: "integer" } },
|
|
855
|
+
query: [],
|
|
856
|
+
body: true
|
|
857
|
+
},
|
|
858
|
+
{
|
|
859
|
+
name: "PATCH /api/v4/{entity_type}/custom_fields",
|
|
860
|
+
effect: "write",
|
|
861
|
+
summary: "Update custom fields",
|
|
862
|
+
source: "https://developers.kommo.com/reference/update-custom-fields",
|
|
863
|
+
path: { entity_type: { type: "string" } },
|
|
864
|
+
query: [],
|
|
865
|
+
body: true
|
|
866
|
+
},
|
|
867
|
+
{
|
|
868
|
+
name: "PATCH /api/v4/{entity_type}/custom_fields/{id}",
|
|
869
|
+
effect: "write",
|
|
870
|
+
summary: "Update custom field",
|
|
871
|
+
source: "https://developers.kommo.com/reference/update-custom-field",
|
|
872
|
+
path: { entity_type: { type: "string", enum: ["leads", "contacts", "companies"] }, id: { type: "integer" } },
|
|
873
|
+
query: [],
|
|
874
|
+
body: true
|
|
875
|
+
},
|
|
876
|
+
{
|
|
877
|
+
name: "PATCH /api/v4/{entity_type}/custom_fields/groups/{id}",
|
|
878
|
+
effect: "write",
|
|
879
|
+
summary: "",
|
|
880
|
+
source: "https://developers.kommo.com/reference/edit-field-groups",
|
|
881
|
+
path: { entity_type: { type: "string" }, id: { type: "string" } },
|
|
882
|
+
query: [],
|
|
883
|
+
body: true
|
|
884
|
+
},
|
|
885
|
+
{
|
|
886
|
+
name: "PATCH /api/v4/{entity_type}/notes",
|
|
887
|
+
effect: "write",
|
|
888
|
+
summary: "Edit notes",
|
|
889
|
+
source: "https://developers.kommo.com/reference/edit-notes",
|
|
890
|
+
path: { entity_type: { type: "string" } },
|
|
891
|
+
query: [],
|
|
892
|
+
body: true
|
|
893
|
+
},
|
|
894
|
+
{
|
|
895
|
+
name: "PATCH /api/v4/{entity_type}/notes/{id}",
|
|
896
|
+
effect: "write",
|
|
897
|
+
summary: "Edit note",
|
|
898
|
+
source: "https://developers.kommo.com/reference/edit-note",
|
|
899
|
+
path: { entity_type: { type: "string" }, id: { type: "integer" } },
|
|
900
|
+
query: [],
|
|
901
|
+
body: true
|
|
902
|
+
},
|
|
903
|
+
{
|
|
904
|
+
name: "PATCH /api/v4/catalogs",
|
|
905
|
+
effect: "write",
|
|
906
|
+
summary: "Editing lists",
|
|
907
|
+
source: "https://developers.kommo.com/reference/editing-lists",
|
|
908
|
+
path: {},
|
|
909
|
+
query: [],
|
|
910
|
+
body: true
|
|
911
|
+
},
|
|
912
|
+
{
|
|
913
|
+
name: "PATCH /api/v4/catalogs/{id}",
|
|
914
|
+
effect: "write",
|
|
915
|
+
summary: "Edit list",
|
|
916
|
+
source: "https://developers.kommo.com/reference/editing-list",
|
|
917
|
+
path: { id: { type: "integer" } },
|
|
918
|
+
query: [],
|
|
919
|
+
body: true
|
|
920
|
+
},
|
|
921
|
+
{
|
|
922
|
+
name: "PATCH /api/v4/catalogs/{id}/custom_fields",
|
|
923
|
+
effect: "write",
|
|
924
|
+
summary: "Update custom fields of a catalog",
|
|
925
|
+
source: "https://developers.kommo.com/reference/update-custom-fields-list",
|
|
926
|
+
path: { id: { type: "integer" } },
|
|
927
|
+
query: [],
|
|
928
|
+
body: true
|
|
929
|
+
},
|
|
930
|
+
{
|
|
931
|
+
name: "PATCH /api/v4/catalogs/{list_id}/custom_fields/{cf_id}",
|
|
932
|
+
effect: "write",
|
|
933
|
+
summary: "Update a custom field of a catalog",
|
|
934
|
+
source: "https://developers.kommo.com/reference/updating-custom-field-list",
|
|
935
|
+
path: { list_id: { type: "integer" }, cf_id: { type: "integer" } },
|
|
936
|
+
query: [],
|
|
937
|
+
body: true
|
|
938
|
+
},
|
|
939
|
+
{
|
|
940
|
+
name: "PATCH /api/v4/catalogs/{list_id}/elements",
|
|
941
|
+
effect: "write",
|
|
942
|
+
summary: "Editing list elements",
|
|
943
|
+
source: "https://developers.kommo.com/reference/edit-list-elements",
|
|
944
|
+
path: { list_id: { type: "integer" } },
|
|
945
|
+
query: [],
|
|
946
|
+
body: true
|
|
947
|
+
},
|
|
948
|
+
{
|
|
949
|
+
name: "PATCH /api/v4/catalogs/{list_id}/elements/{element_id}",
|
|
950
|
+
effect: "write",
|
|
951
|
+
summary: "Edit list element",
|
|
952
|
+
source: "https://developers.kommo.com/reference/edit-list-element",
|
|
953
|
+
path: { list_id: { type: "integer" }, element_id: { type: "integer" } },
|
|
954
|
+
query: [],
|
|
955
|
+
body: true
|
|
956
|
+
},
|
|
957
|
+
{
|
|
958
|
+
name: "PATCH /api/v4/chats/templates",
|
|
959
|
+
effect: "write",
|
|
960
|
+
summary: "Edit templates",
|
|
961
|
+
source: "https://developers.kommo.com/reference/edit-templates",
|
|
962
|
+
path: {},
|
|
963
|
+
query: [],
|
|
964
|
+
body: true
|
|
965
|
+
},
|
|
966
|
+
{
|
|
967
|
+
name: "PATCH /api/v4/companies",
|
|
968
|
+
effect: "write",
|
|
969
|
+
summary: "Updating companies",
|
|
970
|
+
source: "https://developers.kommo.com/reference/update-companies",
|
|
971
|
+
path: {},
|
|
972
|
+
query: [],
|
|
973
|
+
body: true
|
|
974
|
+
},
|
|
975
|
+
{
|
|
976
|
+
name: "PATCH /api/v4/companies/{id}",
|
|
977
|
+
effect: "write",
|
|
978
|
+
summary: "Update company",
|
|
979
|
+
source: "https://developers.kommo.com/reference/updating-company",
|
|
980
|
+
path: { id: { type: "integer" } },
|
|
981
|
+
query: [],
|
|
982
|
+
body: true
|
|
983
|
+
},
|
|
984
|
+
{
|
|
985
|
+
name: "PATCH /api/v4/contacts",
|
|
986
|
+
effect: "write",
|
|
987
|
+
summary: "Updating Contacts",
|
|
988
|
+
source: "https://developers.kommo.com/reference/update-contacts",
|
|
989
|
+
path: {},
|
|
990
|
+
query: [],
|
|
991
|
+
body: true
|
|
992
|
+
},
|
|
993
|
+
{
|
|
994
|
+
name: "PATCH /api/v4/contacts/{id}",
|
|
995
|
+
effect: "write",
|
|
996
|
+
summary: "Update contact",
|
|
997
|
+
source: "https://developers.kommo.com/reference/update-contact",
|
|
998
|
+
path: { id: { type: "integer" } },
|
|
999
|
+
query: [],
|
|
1000
|
+
body: true
|
|
1001
|
+
},
|
|
1002
|
+
{
|
|
1003
|
+
name: "PATCH /api/v4/leads",
|
|
1004
|
+
effect: "write",
|
|
1005
|
+
summary: "Update leads",
|
|
1006
|
+
source: "https://developers.kommo.com/reference/updating-leads",
|
|
1007
|
+
path: {},
|
|
1008
|
+
query: [],
|
|
1009
|
+
body: true
|
|
1010
|
+
},
|
|
1011
|
+
{
|
|
1012
|
+
name: "PATCH /api/v4/leads/{id}",
|
|
1013
|
+
effect: "write",
|
|
1014
|
+
summary: "Update lead",
|
|
1015
|
+
source: "https://developers.kommo.com/reference/updating-single-lead",
|
|
1016
|
+
path: { id: { type: "integer" } },
|
|
1017
|
+
query: [],
|
|
1018
|
+
body: true
|
|
1019
|
+
},
|
|
1020
|
+
{
|
|
1021
|
+
name: "PATCH /api/v4/leads/pipelines/{id}",
|
|
1022
|
+
effect: "write",
|
|
1023
|
+
summary: "Edit pipeline",
|
|
1024
|
+
source: "https://developers.kommo.com/reference/edit-pipeline",
|
|
1025
|
+
path: { id: { type: "integer" } },
|
|
1026
|
+
query: [],
|
|
1027
|
+
body: true
|
|
1028
|
+
},
|
|
1029
|
+
{
|
|
1030
|
+
name: "PATCH /api/v4/leads/pipelines/{pipeline_id}/statuses/{id}",
|
|
1031
|
+
effect: "write",
|
|
1032
|
+
summary: "Pipeline stage edit",
|
|
1033
|
+
source: "https://developers.kommo.com/reference/edit-stage",
|
|
1034
|
+
path: { pipeline_id: { type: "integer" }, id: { type: "integer" } },
|
|
1035
|
+
query: [],
|
|
1036
|
+
body: true
|
|
1037
|
+
},
|
|
1038
|
+
{
|
|
1039
|
+
name: "PATCH /api/v4/roles/{id}",
|
|
1040
|
+
effect: "write",
|
|
1041
|
+
summary: "Editing roles",
|
|
1042
|
+
source: "https://developers.kommo.com/reference/edit-roles",
|
|
1043
|
+
path: { id: { type: "string" } },
|
|
1044
|
+
query: [],
|
|
1045
|
+
body: true
|
|
1046
|
+
},
|
|
1047
|
+
{
|
|
1048
|
+
name: "PATCH /api/v4/sources",
|
|
1049
|
+
effect: "write",
|
|
1050
|
+
summary: "Update sources",
|
|
1051
|
+
source: "https://developers.kommo.com/reference/update-sources",
|
|
1052
|
+
path: {},
|
|
1053
|
+
query: [],
|
|
1054
|
+
body: true
|
|
1055
|
+
},
|
|
1056
|
+
{
|
|
1057
|
+
name: "PATCH /api/v4/sources/{id}",
|
|
1058
|
+
effect: "write",
|
|
1059
|
+
summary: "Update source",
|
|
1060
|
+
source: "https://developers.kommo.com/reference/update-source",
|
|
1061
|
+
path: { id: { type: "integer" } },
|
|
1062
|
+
query: [],
|
|
1063
|
+
body: true
|
|
1064
|
+
},
|
|
1065
|
+
{
|
|
1066
|
+
name: "PATCH /api/v4/tasks",
|
|
1067
|
+
effect: "write",
|
|
1068
|
+
summary: "Edit tasks",
|
|
1069
|
+
source: "https://developers.kommo.com/reference/edit-tasks",
|
|
1070
|
+
path: {},
|
|
1071
|
+
query: [],
|
|
1072
|
+
body: true
|
|
1073
|
+
},
|
|
1074
|
+
{
|
|
1075
|
+
name: "PATCH /api/v4/tasks/{id}",
|
|
1076
|
+
effect: "write",
|
|
1077
|
+
summary: "Edit task",
|
|
1078
|
+
source: "https://developers.kommo.com/reference/edit-task",
|
|
1079
|
+
path: { id: { type: "integer" } },
|
|
1080
|
+
query: [],
|
|
1081
|
+
body: true
|
|
1082
|
+
},
|
|
1083
|
+
{
|
|
1084
|
+
name: "PATCH /api/v4/website_buttons/{source_id}",
|
|
1085
|
+
effect: "write",
|
|
1086
|
+
summary: "Update CRM Plugin",
|
|
1087
|
+
source: "https://developers.kommo.com/reference/update-crm-plugin",
|
|
1088
|
+
path: { source_id: { type: "integer" } },
|
|
1089
|
+
query: [],
|
|
1090
|
+
body: true
|
|
1091
|
+
},
|
|
1092
|
+
{
|
|
1093
|
+
name: "POST /api/v4/{bot}/{bot_id}/continue/{continue_id}",
|
|
1094
|
+
effect: "write",
|
|
1095
|
+
summary: "SalesBot widget block execution confirmation",
|
|
1096
|
+
source: "https://developers.kommo.com/reference/salesbot-widget-block-execution-confirmation",
|
|
1097
|
+
path: {
|
|
1098
|
+
bot_id: { type: "integer" },
|
|
1099
|
+
continue_id: { type: "integer" },
|
|
1100
|
+
bot: { type: "string", enum: ["marketingbot", "salesbot"] }
|
|
1101
|
+
},
|
|
1102
|
+
query: [],
|
|
1103
|
+
body: true
|
|
1104
|
+
},
|
|
1105
|
+
{
|
|
1106
|
+
name: "POST /api/v4/{entity_type}/custom_fields",
|
|
1107
|
+
effect: "write",
|
|
1108
|
+
summary: "Add custom fields",
|
|
1109
|
+
source: "https://developers.kommo.com/reference/add-custom-fields",
|
|
1110
|
+
path: { entity_type: { type: "string", enum: ["leads", "companies", "contacts"] } },
|
|
1111
|
+
query: [],
|
|
1112
|
+
body: true
|
|
1113
|
+
},
|
|
1114
|
+
{
|
|
1115
|
+
name: "POST /api/v4/{entity_type}/custom_fields/groups",
|
|
1116
|
+
effect: "write",
|
|
1117
|
+
summary: "",
|
|
1118
|
+
source: "https://developers.kommo.com/reference/add-field-groups",
|
|
1119
|
+
path: { entity_type: { type: "string" } },
|
|
1120
|
+
query: [],
|
|
1121
|
+
body: true
|
|
1122
|
+
},
|
|
1123
|
+
{
|
|
1124
|
+
name: "POST /api/v4/{entity_type}/notes",
|
|
1125
|
+
effect: "write",
|
|
1126
|
+
summary: "Add notes",
|
|
1127
|
+
source: "https://developers.kommo.com/reference/add-notes",
|
|
1128
|
+
path: { entity_type: { type: "string", enum: ["leads", "contacts", "companies"] } },
|
|
1129
|
+
query: [],
|
|
1130
|
+
body: true
|
|
1131
|
+
},
|
|
1132
|
+
{
|
|
1133
|
+
name: "POST /api/v4/{entity_type}/notes/{id}/pin",
|
|
1134
|
+
effect: "write",
|
|
1135
|
+
summary: "Pin note",
|
|
1136
|
+
source: "https://developers.kommo.com/reference/pin-note",
|
|
1137
|
+
path: { entity_type: { type: "string", enum: ["leads", "contacts", "companies"] }, id: { type: "integer" } },
|
|
1138
|
+
query: [],
|
|
1139
|
+
body: false
|
|
1140
|
+
},
|
|
1141
|
+
{
|
|
1142
|
+
name: "POST /api/v4/{entity_type}/notes/{id}/unpin",
|
|
1143
|
+
effect: "write",
|
|
1144
|
+
summary: "Unpin note",
|
|
1145
|
+
source: "https://developers.kommo.com/reference/unpin-note",
|
|
1146
|
+
path: { entity_type: { type: "string", enum: ["leads", "contacts", "companies"] }, id: { type: "integer" } },
|
|
1147
|
+
query: [],
|
|
1148
|
+
body: false
|
|
1149
|
+
},
|
|
1150
|
+
{
|
|
1151
|
+
name: "POST /api/v4/{entity_type}/tags",
|
|
1152
|
+
effect: "write",
|
|
1153
|
+
summary: "Creating tags for a particular entity type",
|
|
1154
|
+
source: "https://developers.kommo.com/reference/add-tags",
|
|
1155
|
+
path: { entity_type: { type: "string", enum: ["leads", "contacts", "companies"] } },
|
|
1156
|
+
query: [],
|
|
1157
|
+
body: true
|
|
1158
|
+
},
|
|
1159
|
+
{
|
|
1160
|
+
name: "POST /api/v4/{entity}/{entity_id}/link",
|
|
1161
|
+
effect: "write",
|
|
1162
|
+
summary: "Linking entities",
|
|
1163
|
+
source: "https://developers.kommo.com/reference/linking-entities",
|
|
1164
|
+
path: { entity: { type: "string", enum: ["leads", "contacts", "companies"] }, entity_id: { type: "integer" } },
|
|
1165
|
+
query: [],
|
|
1166
|
+
body: true
|
|
1167
|
+
},
|
|
1168
|
+
{
|
|
1169
|
+
name: "POST /api/v4/{entity}/{entity_id}/unlink",
|
|
1170
|
+
effect: "write",
|
|
1171
|
+
summary: "Unlinking entities",
|
|
1172
|
+
source: "https://developers.kommo.com/reference/unlinking-entities",
|
|
1173
|
+
path: { entity: { type: "string", enum: ["leads", "contacts", "companies"] }, entity_id: { type: "integer" } },
|
|
1174
|
+
query: [],
|
|
1175
|
+
body: true
|
|
1176
|
+
},
|
|
1177
|
+
{
|
|
1178
|
+
name: "POST /api/v4/bots/{id}/run",
|
|
1179
|
+
effect: "write",
|
|
1180
|
+
summary: "Launch Salesbot",
|
|
1181
|
+
source: "https://developers.kommo.com/reference/launch-a-salesbot",
|
|
1182
|
+
path: { id: { type: "integer" } },
|
|
1183
|
+
query: [],
|
|
1184
|
+
body: true
|
|
1185
|
+
},
|
|
1186
|
+
{
|
|
1187
|
+
name: "POST /api/v4/bots/{id}/stop",
|
|
1188
|
+
effect: "write",
|
|
1189
|
+
summary: "Stop a Salesbot",
|
|
1190
|
+
source: "https://developers.kommo.com/reference/stop-salesbot",
|
|
1191
|
+
path: { id: { type: "integer" } },
|
|
1192
|
+
query: [],
|
|
1193
|
+
body: true
|
|
1194
|
+
},
|
|
1195
|
+
{
|
|
1196
|
+
name: "POST /api/v4/bots/run",
|
|
1197
|
+
effect: "write",
|
|
1198
|
+
summary: "Launch Salesbots",
|
|
1199
|
+
source: "https://developers.kommo.com/reference/launch-salesbots",
|
|
1200
|
+
path: {},
|
|
1201
|
+
query: [],
|
|
1202
|
+
body: true
|
|
1203
|
+
},
|
|
1204
|
+
{
|
|
1205
|
+
name: "POST /api/v4/calls",
|
|
1206
|
+
effect: "write",
|
|
1207
|
+
summary: "Add call note",
|
|
1208
|
+
source: "https://developers.kommo.com/reference/add-calls",
|
|
1209
|
+
path: {},
|
|
1210
|
+
query: [],
|
|
1211
|
+
body: true
|
|
1212
|
+
},
|
|
1213
|
+
{
|
|
1214
|
+
name: "POST /api/v4/catalogs",
|
|
1215
|
+
effect: "write",
|
|
1216
|
+
summary: "Add lists",
|
|
1217
|
+
source: "https://developers.kommo.com/reference/add-lists",
|
|
1218
|
+
path: {},
|
|
1219
|
+
query: [],
|
|
1220
|
+
body: true
|
|
1221
|
+
},
|
|
1222
|
+
{
|
|
1223
|
+
name: "POST /api/v4/catalogs/{list_id}/custom_fields",
|
|
1224
|
+
effect: "write",
|
|
1225
|
+
summary: "Adding a custom field to a list",
|
|
1226
|
+
source: "https://developers.kommo.com/reference/adding-custom-field",
|
|
1227
|
+
path: { list_id: { type: "integer" } },
|
|
1228
|
+
query: [],
|
|
1229
|
+
body: true
|
|
1230
|
+
},
|
|
1231
|
+
{
|
|
1232
|
+
name: "POST /api/v4/catalogs/{list_id}/elements",
|
|
1233
|
+
effect: "write",
|
|
1234
|
+
summary: "Adding list elements",
|
|
1235
|
+
source: "https://developers.kommo.com/reference/add-list-elements",
|
|
1236
|
+
path: { list_id: { type: "integer" } },
|
|
1237
|
+
query: [],
|
|
1238
|
+
body: true
|
|
1239
|
+
},
|
|
1240
|
+
{
|
|
1241
|
+
name: "POST /api/v4/chats/templates",
|
|
1242
|
+
effect: "write",
|
|
1243
|
+
summary: "Add templates",
|
|
1244
|
+
source: "https://developers.kommo.com/reference/add-templates",
|
|
1245
|
+
path: {},
|
|
1246
|
+
query: [],
|
|
1247
|
+
body: true
|
|
1248
|
+
},
|
|
1249
|
+
{
|
|
1250
|
+
name: "POST /api/v4/chats/templates/{id}/review",
|
|
1251
|
+
effect: "write",
|
|
1252
|
+
summary: "Submit a WhatsApp template for moderation",
|
|
1253
|
+
source: "https://developers.kommo.com/reference/submit-a-whatsapp-template-for-moderation",
|
|
1254
|
+
path: { id: { type: "integer" } },
|
|
1255
|
+
query: [],
|
|
1256
|
+
body: false
|
|
1257
|
+
},
|
|
1258
|
+
{
|
|
1259
|
+
name: "POST /api/v4/chats/templates/{id}/review/{review_id}",
|
|
1260
|
+
effect: "write",
|
|
1261
|
+
summary: "Edit a WhatsApp template status",
|
|
1262
|
+
source: "https://developers.kommo.com/reference/edit-template-status",
|
|
1263
|
+
path: { id: { type: "integer" }, review_id: { type: "integer" } },
|
|
1264
|
+
query: [],
|
|
1265
|
+
body: true
|
|
1266
|
+
},
|
|
1267
|
+
{
|
|
1268
|
+
name: "POST /api/v4/companies",
|
|
1269
|
+
effect: "write",
|
|
1270
|
+
summary: "Add companies",
|
|
1271
|
+
source: "https://developers.kommo.com/reference/add-companies",
|
|
1272
|
+
path: {},
|
|
1273
|
+
query: [],
|
|
1274
|
+
body: true
|
|
1275
|
+
},
|
|
1276
|
+
{
|
|
1277
|
+
name: "POST /api/v4/contacts",
|
|
1278
|
+
effect: "write",
|
|
1279
|
+
summary: "Adding contacts",
|
|
1280
|
+
source: "https://developers.kommo.com/reference/add-contacts",
|
|
1281
|
+
path: {},
|
|
1282
|
+
query: [],
|
|
1283
|
+
body: true
|
|
1284
|
+
},
|
|
1285
|
+
{
|
|
1286
|
+
name: "POST /api/v4/contacts/chats",
|
|
1287
|
+
effect: "write",
|
|
1288
|
+
summary: "Step 4: Link chat to contact",
|
|
1289
|
+
source: "https://developers.kommo.com/reference/link-chat-contact",
|
|
1290
|
+
path: {},
|
|
1291
|
+
query: [],
|
|
1292
|
+
body: true
|
|
1293
|
+
},
|
|
1294
|
+
{
|
|
1295
|
+
name: "POST /api/v4/leads",
|
|
1296
|
+
effect: "write",
|
|
1297
|
+
summary: "Add leads",
|
|
1298
|
+
source: "https://developers.kommo.com/reference/adding-leads",
|
|
1299
|
+
path: {},
|
|
1300
|
+
query: [],
|
|
1301
|
+
body: true
|
|
1302
|
+
},
|
|
1303
|
+
{
|
|
1304
|
+
name: "POST /api/v4/leads/complex",
|
|
1305
|
+
effect: "write",
|
|
1306
|
+
summary: "Complex addition of leads with contact and company",
|
|
1307
|
+
source: "https://developers.kommo.com/reference/complex-leads",
|
|
1308
|
+
path: {},
|
|
1309
|
+
query: [],
|
|
1310
|
+
body: true
|
|
1311
|
+
},
|
|
1312
|
+
{
|
|
1313
|
+
name: "POST /api/v4/leads/pipelines",
|
|
1314
|
+
effect: "write",
|
|
1315
|
+
summary: "Adding pipelines",
|
|
1316
|
+
source: "https://developers.kommo.com/reference/add-pipelines",
|
|
1317
|
+
path: {},
|
|
1318
|
+
query: [],
|
|
1319
|
+
body: true
|
|
1320
|
+
},
|
|
1321
|
+
{
|
|
1322
|
+
name: "POST /api/v4/leads/pipelines/{pipeline_id}/statuses",
|
|
1323
|
+
effect: "write",
|
|
1324
|
+
summary: "Add stages to pipeline",
|
|
1325
|
+
source: "https://developers.kommo.com/reference/add-stages",
|
|
1326
|
+
path: { pipeline_id: { type: "integer" } },
|
|
1327
|
+
query: [],
|
|
1328
|
+
body: true
|
|
1329
|
+
},
|
|
1330
|
+
{
|
|
1331
|
+
name: "POST /api/v4/leads/unsorted/{uid}/accept",
|
|
1332
|
+
effect: "write",
|
|
1333
|
+
summary: "Accepting incoming leads",
|
|
1334
|
+
source: "https://developers.kommo.com/reference/accepting-incoming-leads",
|
|
1335
|
+
path: { uid: { type: "string" } },
|
|
1336
|
+
query: [],
|
|
1337
|
+
body: true
|
|
1338
|
+
},
|
|
1339
|
+
{
|
|
1340
|
+
name: "POST /api/v4/leads/unsorted/{uid}/link",
|
|
1341
|
+
effect: "write",
|
|
1342
|
+
summary: "Linking incoming leads",
|
|
1343
|
+
source: "https://developers.kommo.com/reference/linking-incoming-leads",
|
|
1344
|
+
path: { uid: { type: "string" } },
|
|
1345
|
+
query: [],
|
|
1346
|
+
body: true
|
|
1347
|
+
},
|
|
1348
|
+
{
|
|
1349
|
+
name: "POST /api/v4/leads/unsorted/forms",
|
|
1350
|
+
effect: "write",
|
|
1351
|
+
summary: "Adding incoming leads from the type form",
|
|
1352
|
+
source: "https://developers.kommo.com/reference/incoming-leads-form",
|
|
1353
|
+
path: {},
|
|
1354
|
+
query: [],
|
|
1355
|
+
body: true
|
|
1356
|
+
},
|
|
1357
|
+
{
|
|
1358
|
+
name: "POST /api/v4/leads/unsorted/sip",
|
|
1359
|
+
effect: "write",
|
|
1360
|
+
summary: "Adding incoming leads from the type sip (call)",
|
|
1361
|
+
source: "https://developers.kommo.com/reference/incoming-leads-call",
|
|
1362
|
+
path: {},
|
|
1363
|
+
query: [],
|
|
1364
|
+
body: true
|
|
1365
|
+
},
|
|
1366
|
+
{
|
|
1367
|
+
name: "POST /api/v4/roles",
|
|
1368
|
+
effect: "write",
|
|
1369
|
+
summary: "Adding roles",
|
|
1370
|
+
source: "https://developers.kommo.com/reference/adding-roles",
|
|
1371
|
+
path: {},
|
|
1372
|
+
query: [],
|
|
1373
|
+
body: true
|
|
1374
|
+
},
|
|
1375
|
+
{
|
|
1376
|
+
name: "POST /api/v4/sources",
|
|
1377
|
+
effect: "write",
|
|
1378
|
+
summary: "Add sources",
|
|
1379
|
+
source: "https://developers.kommo.com/reference/add-sources",
|
|
1380
|
+
path: {},
|
|
1381
|
+
query: [],
|
|
1382
|
+
body: true
|
|
1383
|
+
},
|
|
1384
|
+
{
|
|
1385
|
+
name: "POST /api/v4/talks/{id}/close",
|
|
1386
|
+
effect: "write",
|
|
1387
|
+
summary: "Close conversation",
|
|
1388
|
+
source: "https://developers.kommo.com/reference/close-conversation",
|
|
1389
|
+
path: { id: { type: "integer" } },
|
|
1390
|
+
query: [],
|
|
1391
|
+
body: true
|
|
1392
|
+
},
|
|
1393
|
+
{
|
|
1394
|
+
name: "POST /api/v4/talks/{talk_id}/send_message",
|
|
1395
|
+
effect: "write",
|
|
1396
|
+
summary: "Send message to conversation",
|
|
1397
|
+
source: "https://developers.kommo.com/reference/send-message-to-conversation",
|
|
1398
|
+
path: { talk_id: { type: "integer" } },
|
|
1399
|
+
query: [],
|
|
1400
|
+
body: true
|
|
1401
|
+
},
|
|
1402
|
+
{
|
|
1403
|
+
name: "POST /api/v4/tasks",
|
|
1404
|
+
effect: "write",
|
|
1405
|
+
summary: "Add tasks",
|
|
1406
|
+
source: "https://developers.kommo.com/reference/add-tasks",
|
|
1407
|
+
path: {},
|
|
1408
|
+
query: [],
|
|
1409
|
+
body: true
|
|
1410
|
+
},
|
|
1411
|
+
{
|
|
1412
|
+
name: "POST /api/v4/users",
|
|
1413
|
+
effect: "write",
|
|
1414
|
+
summary: "Add users",
|
|
1415
|
+
source: "https://developers.kommo.com/reference/add-users",
|
|
1416
|
+
path: {},
|
|
1417
|
+
query: [],
|
|
1418
|
+
body: true
|
|
1419
|
+
},
|
|
1420
|
+
{
|
|
1421
|
+
name: "POST /api/v4/users/activate",
|
|
1422
|
+
effect: "write",
|
|
1423
|
+
summary: "Activate users",
|
|
1424
|
+
source: "https://developers.kommo.com/reference/activate-users",
|
|
1425
|
+
path: {},
|
|
1426
|
+
query: [],
|
|
1427
|
+
body: true
|
|
1428
|
+
},
|
|
1429
|
+
{
|
|
1430
|
+
name: "POST /api/v4/users/deactivate",
|
|
1431
|
+
effect: "write",
|
|
1432
|
+
summary: "Deactivate users",
|
|
1433
|
+
source: "https://developers.kommo.com/reference/deactivate-users",
|
|
1434
|
+
path: {},
|
|
1435
|
+
query: [],
|
|
1436
|
+
body: true
|
|
1437
|
+
},
|
|
1438
|
+
{
|
|
1439
|
+
name: "POST /api/v4/webhooks",
|
|
1440
|
+
effect: "write",
|
|
1441
|
+
summary: "Add webhook",
|
|
1442
|
+
source: "https://developers.kommo.com/reference/add-webhooks",
|
|
1443
|
+
path: {},
|
|
1444
|
+
query: [],
|
|
1445
|
+
body: true
|
|
1446
|
+
},
|
|
1447
|
+
{
|
|
1448
|
+
name: "POST /api/v4/website_buttons",
|
|
1449
|
+
effect: "write",
|
|
1450
|
+
summary: "Add CRM Plugin",
|
|
1451
|
+
source: "https://developers.kommo.com/reference/add-crm-plugin",
|
|
1452
|
+
path: {},
|
|
1453
|
+
query: [],
|
|
1454
|
+
body: true
|
|
1455
|
+
},
|
|
1456
|
+
{
|
|
1457
|
+
name: "POST /api/v4/website_buttons/{source_id}/online_chat",
|
|
1458
|
+
effect: "write",
|
|
1459
|
+
summary: "Connect online chat to CRM Plugin",
|
|
1460
|
+
source: "https://developers.kommo.com/reference/connect-online-chat-to-crm-plugin",
|
|
1461
|
+
path: { source_id: { type: "string" } },
|
|
1462
|
+
query: [],
|
|
1463
|
+
body: false
|
|
1464
|
+
},
|
|
1465
|
+
{
|
|
1466
|
+
name: "POST /api/v4/widgets/{widget_code}",
|
|
1467
|
+
effect: "write",
|
|
1468
|
+
summary: "Install widget into account",
|
|
1469
|
+
source: "https://developers.kommo.com/reference/installing-the-widget-into-the-account",
|
|
1470
|
+
path: { widget_code: { type: "string" } },
|
|
1471
|
+
query: [],
|
|
1472
|
+
body: true
|
|
1473
|
+
},
|
|
1474
|
+
{
|
|
1475
|
+
name: "PUT /api/v4/{entity}/{entity_id}/files",
|
|
1476
|
+
effect: "write",
|
|
1477
|
+
summary: "Attach files to an entity",
|
|
1478
|
+
source: "https://developers.kommo.com/reference/attached-to-entity",
|
|
1479
|
+
path: { entity: { type: "string", enum: ["leads", "contacts", "companies"] }, entity_id: { type: "integer" } },
|
|
1480
|
+
query: [],
|
|
1481
|
+
body: true
|
|
1482
|
+
}
|
|
1483
|
+
];
|
|
1484
|
+
|
|
1485
|
+
// dist/amo/operation.js
|
|
1486
|
+
var PREFIX = "/api/v4/";
|
|
1487
|
+
var split = /* @__PURE__ */ __name((name) => {
|
|
1488
|
+
const space = name.indexOf(" ");
|
|
1489
|
+
return { method: name.slice(0, space), template: name.slice(space + 1) };
|
|
1490
|
+
}, "split");
|
|
1491
|
+
var expansions = /* @__PURE__ */ __name((name, path) => {
|
|
1492
|
+
const free = Object.entries(path).find(([key2, param2]) => param2.type === "string" && (param2.enum !== void 0 || key2 === "entity_type" || key2 === "entity"));
|
|
1493
|
+
if (!free)
|
|
1494
|
+
return [name];
|
|
1495
|
+
const [key, param] = free;
|
|
1496
|
+
const values = param.type === "string" && param.enum ? param.enum : ENTITY_TYPES.values;
|
|
1497
|
+
return values.flatMap((value) => expansions(name.replace(`{${key}}`, value), Object.fromEntries(Object.entries(path).filter(([one]) => one !== key))));
|
|
1498
|
+
}, "expansions");
|
|
1499
|
+
var build = /* @__PURE__ */ __name(() => {
|
|
1500
|
+
const byName = /* @__PURE__ */ new Map();
|
|
1501
|
+
const literal = /* @__PURE__ */ __name((one) => !/\{(entity_type|entity|bot)\}/.test(one.name), "literal");
|
|
1502
|
+
const ordered = [...SPEC_OPERATIONS, ...EXTRA_OPERATIONS].sort((a, b) => Number(literal(b)) - Number(literal(a)));
|
|
1503
|
+
for (const one of ordered)
|
|
1504
|
+
for (const name of expansions(one.name, one.path)) {
|
|
1505
|
+
if (byName.has(name))
|
|
1506
|
+
continue;
|
|
1507
|
+
const { method, template } = split(name);
|
|
1508
|
+
const path = Object.fromEntries(Object.entries(one.path).filter(([key]) => template.includes(`{${key}}`)));
|
|
1509
|
+
byName.set(name, {
|
|
1510
|
+
...one,
|
|
1511
|
+
name,
|
|
1512
|
+
spec: one.name,
|
|
1513
|
+
path,
|
|
1514
|
+
method,
|
|
1515
|
+
template,
|
|
1516
|
+
family: template.slice(PREFIX.length).split("/")[0] ?? ""
|
|
1517
|
+
});
|
|
1518
|
+
}
|
|
1519
|
+
return [...byName.values()].sort((a, b) => a.name.localeCompare(b.name));
|
|
1520
|
+
}, "build");
|
|
1521
|
+
var OPERATIONS = build();
|
|
1522
|
+
var BY_NAME = new Map(OPERATIONS.map((one) => [one.name, one]));
|
|
1523
|
+
var SEGMENT = /^[A-Za-z0-9_-]+$/;
|
|
1524
|
+
var VERBS = /* @__PURE__ */ new Set(["GET", "POST", "PATCH", "PUT", "DELETE"]);
|
|
1525
|
+
var unknownMethod = /* @__PURE__ */ __name((message) => new CliError("validation_error", message, { reason: "api.unknown-method", param: "<method>" }), "unknownMethod");
|
|
1526
|
+
var fits = /* @__PURE__ */ __name((value, param) => param?.type === "integer" ? /^[0-9]+$/.test(value) : param?.enum ? param.enum.includes(value) : SEGMENT.test(value), "fits");
|
|
1527
|
+
var moreLiteral = /* @__PURE__ */ __name((a, b) => {
|
|
1528
|
+
const left = a.template.split("/");
|
|
1529
|
+
const right = b.template.split("/");
|
|
1530
|
+
for (let at = 0; at < left.length; at++) {
|
|
1531
|
+
const x = left[at]?.startsWith("{") ?? false;
|
|
1532
|
+
const y = right[at]?.startsWith("{") ?? false;
|
|
1533
|
+
if (x !== y)
|
|
1534
|
+
return x ? 1 : -1;
|
|
1535
|
+
}
|
|
1536
|
+
return 0;
|
|
1537
|
+
}, "moreLiteral");
|
|
1538
|
+
var matchOperation = /* @__PURE__ */ __name((raw) => {
|
|
1539
|
+
const text3 = raw.trim().replace(/\s+/g, " ");
|
|
1540
|
+
const space = text3.indexOf(" ");
|
|
1541
|
+
const method = text3.slice(0, space).toUpperCase();
|
|
1542
|
+
const path = text3.slice(space + 1).replace(/\/$/, "");
|
|
1543
|
+
if (space < 0 || !VERBS.has(method) || !path.startsWith(PREFIX))
|
|
1544
|
+
throw unknownMethod('a method is an HTTP verb and an /api/v4/ path, such as "GET /api/v4/leads", as api list prints it');
|
|
1545
|
+
const exact = BY_NAME.get(`${method} ${path}`);
|
|
1546
|
+
if (exact)
|
|
1547
|
+
return { operation: exact, ids: {} };
|
|
1548
|
+
const segments = path.split("/").slice(1);
|
|
1549
|
+
if (segments.some((one) => !SEGMENT.test(one)))
|
|
1550
|
+
throw unknownMethod(`${method} ${PREFIX}\u2026: each part of the path is letters, digits, _ or -`);
|
|
1551
|
+
const found = OPERATIONS.flatMap((operation) => {
|
|
1552
|
+
if (operation.method !== method)
|
|
1553
|
+
return [];
|
|
1554
|
+
const parts = operation.template.split("/").slice(1);
|
|
1555
|
+
if (parts.length !== segments.length)
|
|
1556
|
+
return [];
|
|
1557
|
+
const ids = {};
|
|
1558
|
+
for (const [at, part] of parts.entries()) {
|
|
1559
|
+
const value = segments[at] ?? "";
|
|
1560
|
+
const name = /^\{(\w+)\}$/.exec(part)?.[1];
|
|
1561
|
+
if (name === void 0) {
|
|
1562
|
+
if (part !== value)
|
|
1563
|
+
return [];
|
|
1564
|
+
} else if (fits(value, operation.path[name]))
|
|
1565
|
+
ids[name] = value;
|
|
1566
|
+
else
|
|
1567
|
+
return [];
|
|
1568
|
+
}
|
|
1569
|
+
return [{ operation, ids }];
|
|
1570
|
+
}).sort((a, b) => moreLiteral(a.operation, b.operation));
|
|
1571
|
+
const first = found[0];
|
|
1572
|
+
if (!first)
|
|
1573
|
+
throw new CliError("validation_error", `${method} ${path} is not in the Kommo API reference; see api list`, {
|
|
1574
|
+
reason: "api.unknown-method",
|
|
1575
|
+
param: "<method>"
|
|
1576
|
+
});
|
|
1577
|
+
return first;
|
|
1578
|
+
}, "matchOperation");
|
|
1579
|
+
var withEveryId = /* @__PURE__ */ __name((matched) => {
|
|
1580
|
+
const missing = Object.keys(matched.operation.path).filter((name2) => !matched.ids[name2]);
|
|
1581
|
+
if (missing.length === 0)
|
|
1582
|
+
return matched;
|
|
1583
|
+
const { method, template, name } = matched.operation;
|
|
1584
|
+
throw new CliError("validation_error", `${name} needs ${missing.map((one) => `{${one}}`).join(", ")} in the path, such as ${method} ${template.replace(/\{\w+\}/g, "42")}`, { reason: "api.path-id-missing", param: "<method>" });
|
|
1585
|
+
}, "withEveryId");
|
|
1586
|
+
var pathOf = /* @__PURE__ */ __name(({ operation, ids }) => operation.template.replace(/\{(\w+)\}/g, (_, name) => encodeURIComponent(ids[name] ?? "")), "pathOf");
|
|
1587
|
+
|
|
1588
|
+
// dist/crm/activities.js
|
|
1589
|
+
var { fieldOf, id, isRaw, text } = values_exports;
|
|
1590
|
+
var OVERLAP_MS = 10 * 6e4;
|
|
1591
|
+
var seconds = /* @__PURE__ */ __name((ms) => Math.floor(ms / 1e3), "seconds");
|
|
1592
|
+
var msOf = /* @__PURE__ */ __name((value) => typeof value === "number" && value > 0 ? value * 1e3 : null, "msOf");
|
|
1593
|
+
var ON = { leads: "deal", contacts: "person", companies: "organization" };
|
|
1594
|
+
var TASK_KINDS = { "1": "call", "2": "meeting" };
|
|
1595
|
+
var taskOf = /* @__PURE__ */ __name((raw) => {
|
|
1596
|
+
const externalId = id(raw.id);
|
|
1597
|
+
const entity = id(raw.entity_id);
|
|
1598
|
+
const kind = ON[String(raw.entity_type)];
|
|
1599
|
+
const updatedAt = msOf(raw.updated_at);
|
|
1600
|
+
if (!externalId || !entity || entity === "0" || !kind || updatedAt === null)
|
|
1601
|
+
return null;
|
|
1602
|
+
const result = isRaw(raw.result) ? text(fieldOf(raw.result, "text")) : null;
|
|
1603
|
+
return {
|
|
1604
|
+
externalId: `task:${externalId}`,
|
|
1605
|
+
kind: TASK_KINDS[String(raw.task_type_id)] ?? "task",
|
|
1606
|
+
subject: text(raw.text) ?? "",
|
|
1607
|
+
body: result,
|
|
1608
|
+
dueAt: msOf(raw.complete_till),
|
|
1609
|
+
done: raw.is_completed === true,
|
|
1610
|
+
assignee: id(raw.responsible_user_id),
|
|
1611
|
+
createdAt: msOf(raw.created_at) ?? updatedAt,
|
|
1612
|
+
updatedAt,
|
|
1613
|
+
on: [{ kind, externalId: entity }]
|
|
1614
|
+
};
|
|
1615
|
+
}, "taskOf");
|
|
1616
|
+
var NOTE_KINDS = {
|
|
1617
|
+
common: { kind: "comment", subject: "", body: true },
|
|
1618
|
+
call_in: { kind: "call", subject: "incoming call", body: false },
|
|
1619
|
+
call_out: { kind: "call", subject: "outgoing call", body: false }
|
|
1620
|
+
};
|
|
1621
|
+
var noteOf = /* @__PURE__ */ __name((entity) => (raw) => {
|
|
1622
|
+
const externalId = id(raw.id);
|
|
1623
|
+
const on = id(raw.entity_id);
|
|
1624
|
+
const type = NOTE_KINDS[String(raw.note_type)];
|
|
1625
|
+
const updatedAt = msOf(raw.updated_at);
|
|
1626
|
+
if (!externalId || !on || !type || updatedAt === null)
|
|
1627
|
+
return null;
|
|
1628
|
+
return {
|
|
1629
|
+
externalId: `note:${entity}:${externalId}`,
|
|
1630
|
+
kind: type.kind,
|
|
1631
|
+
subject: type.subject,
|
|
1632
|
+
body: type.body ? text(fieldOf(raw.params, "text")) : null,
|
|
1633
|
+
dueAt: null,
|
|
1634
|
+
done: true,
|
|
1635
|
+
assignee: id(raw.responsible_user_id),
|
|
1636
|
+
createdAt: msOf(raw.created_at) ?? updatedAt,
|
|
1637
|
+
updatedAt,
|
|
1638
|
+
on: [{ kind: ON[entity], externalId: on }]
|
|
1639
|
+
};
|
|
1640
|
+
}, "noteOf");
|
|
1641
|
+
var LISTS = [
|
|
1642
|
+
{ phase: "t", route: ROUTES.tasks, name: "tasks", of: taskOf },
|
|
1643
|
+
{ phase: "l", route: ROUTES.leadNotes, name: "notes", of: noteOf("leads") },
|
|
1644
|
+
{ phase: "c", route: ROUTES.contactNotes, name: "notes", of: noteOf("contacts") },
|
|
1645
|
+
{ phase: "o", route: ROUTES.companyNotes, name: "notes", of: noteOf("companies") }
|
|
1646
|
+
];
|
|
1647
|
+
var DELETIONS = "e";
|
|
1648
|
+
var PHASES = [...LISTS.map((one) => one.phase), DELETIONS];
|
|
1649
|
+
var LARGEST = 250;
|
|
1650
|
+
var EVENTS_PAGE = 100;
|
|
1651
|
+
var deletedTask = /* @__PURE__ */ __name((raw) => {
|
|
1652
|
+
const externalId = id(raw.entity_id);
|
|
1653
|
+
const at = msOf(raw.created_at);
|
|
1654
|
+
if (!externalId || at === null)
|
|
1655
|
+
return null;
|
|
1656
|
+
return {
|
|
1657
|
+
externalId: `task:${externalId}`,
|
|
1658
|
+
kind: "task",
|
|
1659
|
+
subject: "",
|
|
1660
|
+
done: true,
|
|
1661
|
+
createdAt: at,
|
|
1662
|
+
updatedAt: at,
|
|
1663
|
+
on: []
|
|
1664
|
+
};
|
|
1665
|
+
}, "deletedTask");
|
|
1666
|
+
var refusedList = /* @__PURE__ */ __name((error) => isCliError(error) && (error.code === "permission_error" && error.details?.reason !== "amo.blocked" || error.code === "validation_error" && (Array.isArray(error.details?.fields) ? error.details.fields : []).some((field) => String(field).startsWith("filter["))), "refusedList");
|
|
1667
|
+
var widthAfter = /* @__PURE__ */ __name((width, rows, size) => Math.max(0, Math.min(4 * (width + 1), Math.floor((width + 1) * size * 0.85 / Math.max(rows, 1))) - 1), "widthAfter");
|
|
1668
|
+
var once = /* @__PURE__ */ __name((items) => [...new Map(items.map((one) => [one.externalId, one])).values()], "once");
|
|
1669
|
+
var readActivities = /* @__PURE__ */ __name(async (list, { since, page, now, size, types }, context) => {
|
|
1670
|
+
const parsed = /^([a-z])(\d+)\.(\d+)\.(\d+)@(\d+)$/.exec(page ?? "");
|
|
1671
|
+
const found = parsed && PHASES.includes(parsed[1] ?? "") ? parsed : null;
|
|
1672
|
+
const started = found ? Number(found[5]) : now;
|
|
1673
|
+
const end = seconds(started);
|
|
1674
|
+
const first = seconds(since - OVERLAP_MS);
|
|
1675
|
+
const at = found ? PHASES.indexOf(found[1] ?? "") : 0;
|
|
1676
|
+
const spot = found ? { x: Number(found[2]), w: Number(found[3]), p: Number(found[4]) } : { x: first, w: Math.max(0, end - first), p: 1 };
|
|
1677
|
+
const cursorOf = /* @__PURE__ */ __name((index, x, w, p) => `${PHASES[index]}${x}.${Math.max(0, Math.min(w, end - x))}.${p}@${started}`, "cursorOf");
|
|
1678
|
+
const next = /* @__PURE__ */ __name((items, index, x, w) => {
|
|
1679
|
+
if (index < LISTS.length && x <= end)
|
|
1680
|
+
return { items: once(items), hasMore: true, nextCursor: cursorOf(index, x, w, 1) };
|
|
1681
|
+
if (index + 1 < LISTS.length)
|
|
1682
|
+
return next(items, index + 1, first, Math.max(0, end - first));
|
|
1683
|
+
if (index + 1 === LISTS.length)
|
|
1684
|
+
return { items: once(items), hasMore: true, nextCursor: cursorOf(LISTS.length, first, 0, 1) };
|
|
1685
|
+
return { items: once(items), hasMore: false, cursor: String(started) };
|
|
1686
|
+
}, "next");
|
|
1687
|
+
const gap = /* @__PURE__ */ __name((route) => context?.gap({ kind: "activities", message: `amoCRM refused the ${route} list to this sign-in: none was read` }), "gap");
|
|
1688
|
+
if (PHASES[at] === DELETIONS) {
|
|
1689
|
+
try {
|
|
1690
|
+
const { rows, more } = await list(ROUTES.events, "events", {
|
|
1691
|
+
...types(["task_deleted"]),
|
|
1692
|
+
"filter[created_at][from]": first - 1,
|
|
1693
|
+
"filter[created_at][to]": end + 1,
|
|
1694
|
+
limit: EVENTS_PAGE,
|
|
1695
|
+
page: spot.p
|
|
1696
|
+
});
|
|
1697
|
+
const items = once(rows.flatMap((raw) => deletedTask(raw) ?? []));
|
|
1698
|
+
if (more && rows.length > 0)
|
|
1699
|
+
return { items, hasMore: true, nextCursor: cursorOf(at, first, 0, spot.p + 1) };
|
|
1700
|
+
return { items, hasMore: false, cursor: String(started) };
|
|
1701
|
+
} catch (error) {
|
|
1702
|
+
if (!refusedList(error))
|
|
1703
|
+
throw error;
|
|
1704
|
+
gap(ROUTES.events);
|
|
1705
|
+
return { items: [], hasMore: false, cursor: String(started) };
|
|
1706
|
+
}
|
|
1707
|
+
}
|
|
1708
|
+
const one = LISTS[at];
|
|
1709
|
+
const to = Math.min(spot.x + spot.w, end);
|
|
1710
|
+
const query = /* @__PURE__ */ __name((limit, number) => ({
|
|
1711
|
+
"filter[updated_at][from]": spot.x - 1,
|
|
1712
|
+
"filter[updated_at][to]": to + 1,
|
|
1713
|
+
"order[id]": "asc",
|
|
1714
|
+
limit,
|
|
1715
|
+
page: number
|
|
1716
|
+
}), "query");
|
|
1717
|
+
try {
|
|
1718
|
+
if (spot.w > 0) {
|
|
1719
|
+
const { rows, more } = await list(one.route, one.name, query(size, 1));
|
|
1720
|
+
const items2 = rows.flatMap((raw) => one.of(raw) ?? []);
|
|
1721
|
+
if (more && rows.length > 0)
|
|
1722
|
+
return next(items2, at, spot.x, Math.floor(spot.w / 2));
|
|
1723
|
+
return next(items2, at, to + 1, widthAfter(spot.w, rows.length, size));
|
|
1724
|
+
}
|
|
1725
|
+
const items = [];
|
|
1726
|
+
for (let number = 1; ; number++) {
|
|
1727
|
+
const { rows, more } = await list(one.route, one.name, query(LARGEST, number));
|
|
1728
|
+
for (const raw of rows) {
|
|
1729
|
+
const item = one.of(raw);
|
|
1730
|
+
if (item)
|
|
1731
|
+
items.push(item);
|
|
1732
|
+
}
|
|
1733
|
+
if (!more || rows.length === 0)
|
|
1734
|
+
return next(items, at, to + 1, 1);
|
|
1735
|
+
}
|
|
1736
|
+
} catch (error) {
|
|
1737
|
+
if (!refusedList(error))
|
|
1738
|
+
throw error;
|
|
1739
|
+
gap(one.route);
|
|
1740
|
+
return next([], at, end + 1, 0);
|
|
1741
|
+
}
|
|
1742
|
+
}, "readActivities");
|
|
1743
|
+
|
|
1744
|
+
// dist/crm/source.js
|
|
1745
|
+
var { fieldOf: fieldOf2, id: id2, isRaw: isRaw2, rawsOf, text: text2 } = values_exports;
|
|
1746
|
+
var OVERLAP_MS2 = 10 * 6e4;
|
|
1747
|
+
var PAGE = 250;
|
|
1748
|
+
var EVENTS_PAGE2 = 100;
|
|
1749
|
+
var CHUNK = 50;
|
|
1750
|
+
var seconds2 = /* @__PURE__ */ __name((ms) => Math.floor(ms / 1e3), "seconds");
|
|
1751
|
+
var listPage = /* @__PURE__ */ __name(async (caller, route, name, query) => {
|
|
1752
|
+
const { body } = await caller.request({ route, query });
|
|
1753
|
+
if (body === void 0)
|
|
1754
|
+
return { rows: [], more: false };
|
|
1755
|
+
const rows = fieldOf2(fieldOf2(body, "_embedded"), name);
|
|
1756
|
+
if (!Array.isArray(rows))
|
|
1757
|
+
throw new CliError("invalid_response", `amoCRM answered ${route} without its ${name}`);
|
|
1758
|
+
return { rows: rows.filter(isRaw2), more: fieldOf2(fieldOf2(body, "_links"), "next") !== void 0 };
|
|
1759
|
+
}, "listPage");
|
|
1760
|
+
var readAll = /* @__PURE__ */ __name(async (caller, route, name, query = {}) => {
|
|
1761
|
+
const all = [];
|
|
1762
|
+
for (let page = 1; ; page++) {
|
|
1763
|
+
const { rows, more } = await listPage(caller, route, name, { ...query, limit: PAGE, page });
|
|
1764
|
+
for (const raw of rows)
|
|
1765
|
+
all.push(raw);
|
|
1766
|
+
if (!more || rows.length === 0)
|
|
1767
|
+
return all;
|
|
1768
|
+
}
|
|
1769
|
+
}, "readAll");
|
|
1770
|
+
var readOne = /* @__PURE__ */ __name(async (caller, route, externalId, query = {}) => {
|
|
1771
|
+
if (!/^\d{1,20}$/.test(externalId))
|
|
1772
|
+
return null;
|
|
1773
|
+
try {
|
|
1774
|
+
const { body } = await caller.request({ route, ids: { id: externalId }, query });
|
|
1775
|
+
return isRaw2(body) ? body : null;
|
|
1776
|
+
} catch (error) {
|
|
1777
|
+
if (isCliError(error) && error.code === "not_found")
|
|
1778
|
+
return null;
|
|
1779
|
+
throw error;
|
|
1780
|
+
}
|
|
1781
|
+
}, "readOne");
|
|
1782
|
+
var spotOf = /* @__PURE__ */ __name((page, now) => {
|
|
1783
|
+
const found = /^([a-z])(\d+)\.(\d+)(?:\.(\d+))?(?:~(\d+))?@(\d+)$/.exec(page ?? "");
|
|
1784
|
+
if (!found)
|
|
1785
|
+
return { spot: null, started: now };
|
|
1786
|
+
const spot = { ph: found[1] ?? "", p: Number(found[2]), o: Number(found[3]) };
|
|
1787
|
+
if (found[4] !== void 0)
|
|
1788
|
+
spot.l = Number(found[4]);
|
|
1789
|
+
if (found[5] !== void 0)
|
|
1790
|
+
spot.k = found[5];
|
|
1791
|
+
return { spot, started: Number(found[6]) };
|
|
1792
|
+
}, "spotOf");
|
|
1793
|
+
var keyOf = /* @__PURE__ */ __name((spot) => `${spot.ph}${spot.p}.${spot.o}${spot.l === void 0 ? "" : `.${spot.l}`}${spot.k === void 0 ? "" : `~${spot.k}`}`, "keyOf");
|
|
1794
|
+
var byNumber = /* @__PURE__ */ __name((ids) => [...new Set(ids)].sort((a, b) => Number(a) - Number(b)), "byNumber");
|
|
1795
|
+
var Cut = class extends Error {
|
|
1796
|
+
static {
|
|
1797
|
+
__name(this, "Cut");
|
|
1798
|
+
}
|
|
1799
|
+
};
|
|
1800
|
+
var chosenOf = /* @__PURE__ */ __name((context) => {
|
|
1801
|
+
const scope = context?.scope;
|
|
1802
|
+
if (scope?.mode !== "mine")
|
|
1803
|
+
return null;
|
|
1804
|
+
return [...scope.also.length ? scope.also : [scope.self]];
|
|
1805
|
+
}, "chosenOf");
|
|
1806
|
+
var ownerOf = /* @__PURE__ */ __name((raw) => id2(raw.responsible_user_id) ?? "", "ownerOf");
|
|
1807
|
+
var linkedIds = /* @__PURE__ */ __name((raw, key) => rawsOf(fieldOf2(raw._embedded, key)).flatMap((one) => id2(one.id) ?? []), "linkedIds");
|
|
1808
|
+
var WITH = { deal: "contacts,loss_reason", person: "leads", organization: "leads,contacts" };
|
|
1809
|
+
var filtersOf = /* @__PURE__ */ __name((kind, conditions, self) => {
|
|
1810
|
+
const declared = new Set(matchOperation(ENTITIES[kind].list).operation.query);
|
|
1811
|
+
const query = {};
|
|
1812
|
+
const set = /* @__PURE__ */ __name((name, value) => {
|
|
1813
|
+
if (!declared.has(name))
|
|
1814
|
+
throw new CliError("validation_error", `amoCRM cannot filter ${ENTITIES[kind].name} by ${name}`, {
|
|
1815
|
+
reason: "crm.record-field"
|
|
1816
|
+
});
|
|
1817
|
+
query[name] = value;
|
|
1818
|
+
}, "set");
|
|
1819
|
+
for (const { field, op, value } of conditions) {
|
|
1820
|
+
if (field === "assigned_to" && (op === "=" || op === "in")) {
|
|
1821
|
+
const users = (Array.isArray(value) ? value : [value]).map((one) => one === "me" ? self : String(one));
|
|
1822
|
+
for (const user of users)
|
|
1823
|
+
if (!user || !/^[1-9][0-9]*$/.test(user))
|
|
1824
|
+
throw new CliError("validation_error", "assigned_to takes me or an amoCRM user id, such as 7", {
|
|
1825
|
+
reason: "crm.owner-unknown"
|
|
1826
|
+
});
|
|
1827
|
+
set("filter[responsible_user_id][]", users.map(Number));
|
|
1828
|
+
continue;
|
|
1829
|
+
}
|
|
1830
|
+
if ((field === "created_at" || field === "updated_at") && typeof value === "number" && op !== "!=" && op !== "in") {
|
|
1831
|
+
const ms = value;
|
|
1832
|
+
if (op === "=" || op === ">=" || op === ">")
|
|
1833
|
+
set(`filter[${field}][from]`, op === ">" ? seconds2(ms) + 1 : op === "=" ? seconds2(ms) : Math.ceil(ms / 1e3));
|
|
1834
|
+
if (op === "=" || op === "<=" || op === "<")
|
|
1835
|
+
set(`filter[${field}][to]`, op === "<" ? Math.ceil(ms / 1e3) - 1 : seconds2(ms));
|
|
1836
|
+
continue;
|
|
1837
|
+
}
|
|
1838
|
+
throw new CliError("validation_error", `amoCRM cannot filter ${ENTITIES[kind].name} by ${field} ${op}`, {
|
|
1839
|
+
reason: "crm.record-field"
|
|
1840
|
+
});
|
|
1841
|
+
}
|
|
1842
|
+
return query;
|
|
1843
|
+
}, "filtersOf");
|
|
1844
|
+
var amoCrmSource = /* @__PURE__ */ __name((account, options = {}) => {
|
|
1845
|
+
const now = options.now ?? Date.now;
|
|
1846
|
+
const size = options.page ?? PAGE;
|
|
1847
|
+
const asked = options.asked ?? (async () => ({ mode: "mine", setting: "scope", chosen: "unassigned" }));
|
|
1848
|
+
const metered = /* @__PURE__ */ __name((context, cut = false) => {
|
|
1849
|
+
let paid = false;
|
|
1850
|
+
let spent;
|
|
1851
|
+
const caller = {
|
|
1852
|
+
request: /* @__PURE__ */ __name((request) => {
|
|
1853
|
+
if (paid && context)
|
|
1854
|
+
try {
|
|
1855
|
+
context.spend();
|
|
1856
|
+
} catch (error) {
|
|
1857
|
+
if (!cut)
|
|
1858
|
+
throw error;
|
|
1859
|
+
spent = error;
|
|
1860
|
+
throw new Cut();
|
|
1861
|
+
}
|
|
1862
|
+
paid = true;
|
|
1863
|
+
return account().request(request);
|
|
1864
|
+
}, "request")
|
|
1865
|
+
};
|
|
1866
|
+
return Object.assign(caller, { spent: /* @__PURE__ */ __name(() => spent, "spent") });
|
|
1867
|
+
}, "metered");
|
|
1868
|
+
let about;
|
|
1869
|
+
const accountOf = /* @__PURE__ */ __name((caller = account()) => about ??= caller.request({ route: ROUTES.account, query: { with: "is_api_filter_enabled,datetime_settings" } }).then(({ body }) => ({
|
|
1870
|
+
userId: id2(fieldOf2(body, "current_user_id")) ?? "",
|
|
1871
|
+
filters: fieldOf2(body, "is_api_filter_enabled") === true,
|
|
1872
|
+
currency: text2(fieldOf2(body, "currency")),
|
|
1873
|
+
timeZone: text2(fieldOf2(fieldOf2(fieldOf2(body, "_embedded"), "datetime_settings"), "timezone"))
|
|
1874
|
+
})), "accountOf");
|
|
1875
|
+
const loaded = /* @__PURE__ */ new Map();
|
|
1876
|
+
const fields = /* @__PURE__ */ __name((kind, caller = account()) => {
|
|
1877
|
+
let found = loaded.get(kind);
|
|
1878
|
+
if (!found) {
|
|
1879
|
+
if (kind === "lead")
|
|
1880
|
+
return Promise.resolve([]);
|
|
1881
|
+
found = readAll(caller, ENTITIES[kind].fields, "custom_fields").then((rows) => rows.map(fieldOfRaw).filter((one) => one !== null));
|
|
1882
|
+
found.catch(() => loaded.delete(kind));
|
|
1883
|
+
loaded.set(kind, found);
|
|
1884
|
+
}
|
|
1885
|
+
return found;
|
|
1886
|
+
}, "fields");
|
|
1887
|
+
const mapped = /* @__PURE__ */ __name(async (kind, rows, caller) => {
|
|
1888
|
+
const defined = await fields(kind, caller);
|
|
1889
|
+
const { currency, timeZone } = await accountOf(caller);
|
|
1890
|
+
const map = { deal: toDeal, lead: toDeal, person: toPerson, organization: toOrganization }[kind];
|
|
1891
|
+
return rows.map((raw) => map(raw, defined, currency, timeZone));
|
|
1892
|
+
}, "mapped");
|
|
1893
|
+
const owners = /* @__PURE__ */ new Map();
|
|
1894
|
+
const remember = /* @__PURE__ */ __name((rows) => {
|
|
1895
|
+
for (const raw of rows) {
|
|
1896
|
+
const lead = id2(raw.id);
|
|
1897
|
+
if (lead)
|
|
1898
|
+
owners.set(lead, ownerOf(raw));
|
|
1899
|
+
}
|
|
1900
|
+
}, "remember");
|
|
1901
|
+
const byIds = /* @__PURE__ */ __name(async (caller, kind, ids, query) => {
|
|
1902
|
+
const { filters } = await accountOf(caller);
|
|
1903
|
+
const rows = [];
|
|
1904
|
+
for (let at = 0; at < ids.length; at += CHUNK) {
|
|
1905
|
+
const chunk = ids.slice(at, at + CHUNK);
|
|
1906
|
+
if (filters) {
|
|
1907
|
+
const page = await listPage(caller, ENTITIES[kind].list, ENTITIES[kind].name, {
|
|
1908
|
+
...query,
|
|
1909
|
+
"filter[id][]": chunk.map(Number),
|
|
1910
|
+
limit: CHUNK
|
|
1911
|
+
});
|
|
1912
|
+
for (const raw of page.rows)
|
|
1913
|
+
rows.push(raw);
|
|
1914
|
+
} else
|
|
1915
|
+
for (const externalId of chunk) {
|
|
1916
|
+
const raw = await readOne(caller, ENTITIES[kind].one, externalId, query);
|
|
1917
|
+
if (raw)
|
|
1918
|
+
rows.push(raw);
|
|
1919
|
+
}
|
|
1920
|
+
}
|
|
1921
|
+
return rows;
|
|
1922
|
+
}, "byIds");
|
|
1923
|
+
const ownersOf = /* @__PURE__ */ __name(async (caller, leads) => {
|
|
1924
|
+
const missing = [...new Set(leads)].filter((lead) => !owners.has(lead));
|
|
1925
|
+
remember(await byIds(caller, "deal", missing, {}));
|
|
1926
|
+
for (const lead of missing)
|
|
1927
|
+
if (!owners.has(lead))
|
|
1928
|
+
owners.set(lead, "");
|
|
1929
|
+
}, "ownersOf");
|
|
1930
|
+
const readSome = /* @__PURE__ */ __name(async (caller, kind, ids, query) => {
|
|
1931
|
+
const { filters } = await accountOf(caller);
|
|
1932
|
+
const chunk = ids.slice(0, filters ? CHUNK : 1);
|
|
1933
|
+
return { read: chunk.length, rows: await byIds(caller, kind, chunk, query) };
|
|
1934
|
+
}, "readSome");
|
|
1935
|
+
const resolveOwners = /* @__PURE__ */ __name(async (caller, leads) => {
|
|
1936
|
+
const missing = [...new Set(leads)].filter((lead) => !owners.has(lead));
|
|
1937
|
+
if (missing.length === 0)
|
|
1938
|
+
return false;
|
|
1939
|
+
const { read, rows } = await readSome(caller, "deal", missing, {});
|
|
1940
|
+
remember(rows);
|
|
1941
|
+
for (const lead of missing.slice(0, read))
|
|
1942
|
+
if (!owners.has(lead))
|
|
1943
|
+
owners.set(lead, "");
|
|
1944
|
+
return true;
|
|
1945
|
+
}, "resolveOwners");
|
|
1946
|
+
const round = /* @__PURE__ */ __name(async (caller, kind, at, from, extra = {}) => {
|
|
1947
|
+
const { filters } = await accountOf(caller);
|
|
1948
|
+
const base = { with: WITH[kind], limit: size, page: at, ...extra };
|
|
1949
|
+
const entity = ENTITIES[kind];
|
|
1950
|
+
if (from === null || filters) {
|
|
1951
|
+
const query = from === null ? base : { ...base, "filter[updated_at][from]": from };
|
|
1952
|
+
return listPage(caller, entity.list, entity.name, { ...query, "order[id]": "asc" });
|
|
1953
|
+
}
|
|
1954
|
+
const { rows, more } = await listPage(caller, entity.list, entity.name, { ...base, "order[updated_at]": "desc" });
|
|
1955
|
+
const recent = rows.filter((raw) => Number(raw.updated_at) >= from);
|
|
1956
|
+
return { rows: recent, more: more && recent.length === rows.length };
|
|
1957
|
+
}, "round");
|
|
1958
|
+
const overlapped = /* @__PURE__ */ __name(async (read, at) => {
|
|
1959
|
+
const page = await read(at);
|
|
1960
|
+
if (at === 1)
|
|
1961
|
+
return page;
|
|
1962
|
+
const on = new Set(page.rows.map((raw) => id2(raw.id)));
|
|
1963
|
+
const before = (await read(at - 1)).rows.filter((raw) => !on.has(id2(raw.id)));
|
|
1964
|
+
return { rows: [...before, ...page.rows], more: page.more };
|
|
1965
|
+
}, "overlapped");
|
|
1966
|
+
const leadPages = /* @__PURE__ */ new Map();
|
|
1967
|
+
const leadPage = /* @__PURE__ */ __name((caller, at, from, chosen) => {
|
|
1968
|
+
const key = `${at}|${from ?? ""}|${chosen?.join(",") ?? ""}`;
|
|
1969
|
+
const kept = leadPages.get(key);
|
|
1970
|
+
if (kept && now() - kept.at < OVERLAP_MS2)
|
|
1971
|
+
return kept.page;
|
|
1972
|
+
const page = (async () => {
|
|
1973
|
+
const { filters } = await accountOf(caller);
|
|
1974
|
+
const narrow = from === null && chosen && filters ? { "filter[responsible_user_id][]": chosen.map(Number) } : {};
|
|
1975
|
+
const { rows, more } = await overlapped((one) => round(caller, "deal", one, from, narrow), at);
|
|
1976
|
+
remember(rows);
|
|
1977
|
+
return { rows: from === null && chosen ? rows.filter((raw) => chosen.includes(ownerOf(raw))) : rows, more };
|
|
1978
|
+
})();
|
|
1979
|
+
page.catch(() => leadPages.delete(key));
|
|
1980
|
+
leadPages.set(key, { at: now(), page });
|
|
1981
|
+
return page;
|
|
1982
|
+
}, "leadPage");
|
|
1983
|
+
const seen = /* @__PURE__ */ new Map();
|
|
1984
|
+
const seenOf = /* @__PURE__ */ __name((kind, started) => {
|
|
1985
|
+
const key = `${kind}@${started}`;
|
|
1986
|
+
const found = seen.get(key) ?? /* @__PURE__ */ new Set();
|
|
1987
|
+
seen.set(key, found);
|
|
1988
|
+
return found;
|
|
1989
|
+
}, "seenOf");
|
|
1990
|
+
const typesOf = /* @__PURE__ */ __name((types) => new URL(account().origin).hostname.endsWith(".amocrm.ru") ? { "filter[type][]": types } : { "filter[type]": types.join(",") }, "typesOf");
|
|
1991
|
+
const isAdmin = /* @__PURE__ */ __name(() => account().isAdmin(), "isAdmin");
|
|
1992
|
+
return {
|
|
1993
|
+
provider: "amocrm",
|
|
1994
|
+
traits: { kinds: ["organization", "person", "deal"], removedInChanges: true },
|
|
1995
|
+
account: /* @__PURE__ */ __name(() => accountOf(), "account"),
|
|
1996
|
+
// As b24 (owner's ruling 2026-11-10): a copy is never the whole account, an administrator's included.
|
|
1997
|
+
async self() {
|
|
1998
|
+
const { mode, setting, chosen } = await asked();
|
|
1999
|
+
if (mode === "mine")
|
|
2000
|
+
return (await accountOf()).userId;
|
|
2001
|
+
throw new CliError("configuration_error", `${setting} is all, and amo never copies the whole CRM: "config set ${setting} mine" copies the deals of the users you choose in ${chosen}, and their clients. Find any other client with "people list" or "organizations list"`, { setting, reason: "amo.scope-all-refused" });
|
|
2002
|
+
},
|
|
2003
|
+
// Only an administrator may copy a colleague's deals: anyone else cannot list the users to tell who is who.
|
|
2004
|
+
async unassigned(users) {
|
|
2005
|
+
if (await isAdmin())
|
|
2006
|
+
return { kept: [...users] };
|
|
2007
|
+
const self = (await accountOf()).userId;
|
|
2008
|
+
return {
|
|
2009
|
+
kept: users.filter((user) => user === self),
|
|
2010
|
+
message: "another user; only an amoCRM administrator may copy a colleague's deals"
|
|
2011
|
+
};
|
|
2012
|
+
},
|
|
2013
|
+
async pipelines(_kind, context) {
|
|
2014
|
+
const rows = await listPage(metered(context), ROUTES.pipelines, "pipelines", {});
|
|
2015
|
+
return rows.rows.map(toPipeline).filter((one) => one !== null);
|
|
2016
|
+
},
|
|
2017
|
+
fields: /* @__PURE__ */ __name((kind, context) => fields(kind, metered(context)), "fields"),
|
|
2018
|
+
async changes(kind, cursor, page, context) {
|
|
2019
|
+
const since = cursor === null ? null : Date.parse(cursor);
|
|
2020
|
+
if (since !== null && Number.isNaN(since))
|
|
2021
|
+
return { reset: true };
|
|
2022
|
+
if (kind === "lead")
|
|
2023
|
+
return { items: [], hasMore: false, cursor: null };
|
|
2024
|
+
const amoKind = kind;
|
|
2025
|
+
const caller = metered(context, true);
|
|
2026
|
+
const { spot: given, started } = spotOf(page, now());
|
|
2027
|
+
const from = since === null ? null : seconds2(since - OVERLAP_MS2);
|
|
2028
|
+
const chosen = chosenOf(context);
|
|
2029
|
+
const client = amoKind === "deal" ? null : amoKind;
|
|
2030
|
+
const first = { ph: client === null ? "d" : !chosen ? "a" : from === null ? "w" : "c", p: 1, o: 0 };
|
|
2031
|
+
let spot = given ?? first;
|
|
2032
|
+
let progressed = false;
|
|
2033
|
+
const rows = [];
|
|
2034
|
+
const removed = /* @__PURE__ */ new Set();
|
|
2035
|
+
const kept = seenOf(kind, started);
|
|
2036
|
+
const answered = seenOf(`${kind} answered`, started);
|
|
2037
|
+
const fresh = /* @__PURE__ */ __name((found) => found.filter((raw) => {
|
|
2038
|
+
const one = id2(raw.id) ?? "";
|
|
2039
|
+
if (answered.has(one))
|
|
2040
|
+
return false;
|
|
2041
|
+
answered.add(one);
|
|
2042
|
+
return true;
|
|
2043
|
+
}), "fresh");
|
|
2044
|
+
const window = { "filter[created_at][from]": from ?? 0, "filter[created_at][to]": seconds2(started) };
|
|
2045
|
+
const answer = /* @__PURE__ */ __name(async (done) => ({
|
|
2046
|
+
items: await mapped(kind, rows, caller),
|
|
2047
|
+
...removed.size ? { removed: [...removed] } : {},
|
|
2048
|
+
hasMore: !done,
|
|
2049
|
+
...done ? { cursor: new Date(started).toISOString() } : { nextCursor: `${keyOf(spot)}@${started}` }
|
|
2050
|
+
}), "answer");
|
|
2051
|
+
const after = /* @__PURE__ */ __name((more, next) => {
|
|
2052
|
+
spot = more ? { ph: spot.ph, p: spot.p + 1, o: 0 } : { ph: next, p: 1, o: 0 };
|
|
2053
|
+
progressed = true;
|
|
2054
|
+
return more;
|
|
2055
|
+
}, "after");
|
|
2056
|
+
let from_page;
|
|
2057
|
+
const settle = /* @__PURE__ */ __name((ids) => {
|
|
2058
|
+
if (spot.k === void 0)
|
|
2059
|
+
return true;
|
|
2060
|
+
const at = ids.indexOf(spot.k);
|
|
2061
|
+
if (at >= 0) {
|
|
2062
|
+
spot = spot.l === void 0 ? { ph: spot.ph, p: spot.p, o: at + 1, k: spot.k } : { ...spot, o: at };
|
|
2063
|
+
return true;
|
|
2064
|
+
}
|
|
2065
|
+
from_page ??= spot.p;
|
|
2066
|
+
progressed = true;
|
|
2067
|
+
if (spot.p > 1) {
|
|
2068
|
+
spot = { ...spot, p: spot.p - 1, o: 0 };
|
|
2069
|
+
return false;
|
|
2070
|
+
}
|
|
2071
|
+
const restart = Math.max(1, from_page - 1);
|
|
2072
|
+
spot = { ph: spot.ph, p: restart, o: 0 };
|
|
2073
|
+
return restart === 1;
|
|
2074
|
+
}, "settle");
|
|
2075
|
+
const subOf = /* @__PURE__ */ __name((externalId) => spot.k === externalId && spot.l !== void 0 ? spot.l : 0, "subOf");
|
|
2076
|
+
try {
|
|
2077
|
+
for (; ; ) {
|
|
2078
|
+
if (spot.ph === "")
|
|
2079
|
+
return await answer(true);
|
|
2080
|
+
if (spot.ph === "d") {
|
|
2081
|
+
const { rows: leads, more } = await leadPage(caller, spot.p, from, chosen);
|
|
2082
|
+
for (const raw of fresh(leads))
|
|
2083
|
+
rows.push(raw);
|
|
2084
|
+
if (after(more, from === null ? "" : "r"))
|
|
2085
|
+
return await answer(false);
|
|
2086
|
+
continue;
|
|
2087
|
+
}
|
|
2088
|
+
if (spot.ph === "a" && client) {
|
|
2089
|
+
const { rows: found, more } = await overlapped((one) => round(caller, client, one, from), spot.p);
|
|
2090
|
+
for (const raw of fresh(found))
|
|
2091
|
+
rows.push(raw);
|
|
2092
|
+
if (after(more && found.length > 0, from === null ? "" : "r"))
|
|
2093
|
+
return await answer(false);
|
|
2094
|
+
continue;
|
|
2095
|
+
}
|
|
2096
|
+
if ((spot.ph === "w" || spot.ph === "n") && client && chosen) {
|
|
2097
|
+
const { rows: leads, more } = await leadPage(caller, spot.p, from, chosen);
|
|
2098
|
+
const own = leads.filter((raw) => chosen.includes(ownerOf(raw)));
|
|
2099
|
+
if (!settle(own.map((raw) => id2(raw.id) ?? "")))
|
|
2100
|
+
continue;
|
|
2101
|
+
while (spot.o < own.length) {
|
|
2102
|
+
const lead = own[spot.o];
|
|
2103
|
+
const leadId = id2(lead.id) ?? "";
|
|
2104
|
+
const names = byNumber(linkedIds(lead, client === "person" ? "contacts" : "companies"));
|
|
2105
|
+
let done = subOf(leadId);
|
|
2106
|
+
for (; ; ) {
|
|
2107
|
+
const left = names.filter((one) => Number(one) > done && !kept.has(one));
|
|
2108
|
+
if (left.length === 0)
|
|
2109
|
+
break;
|
|
2110
|
+
spot = { ...spot, l: done, k: leadId };
|
|
2111
|
+
const { read, rows: found } = await readSome(caller, client, left, { with: WITH[client] });
|
|
2112
|
+
for (const raw of found)
|
|
2113
|
+
rows.push(raw);
|
|
2114
|
+
for (const one of left.slice(0, read))
|
|
2115
|
+
kept.add(one);
|
|
2116
|
+
done = Number(left[read - 1]);
|
|
2117
|
+
spot = { ...spot, l: done, k: leadId };
|
|
2118
|
+
progressed = true;
|
|
2119
|
+
if (rows.length >= CHUNK)
|
|
2120
|
+
return await answer(false);
|
|
2121
|
+
}
|
|
2122
|
+
spot = { ph: spot.ph, p: spot.p, o: spot.o + 1, k: leadId };
|
|
2123
|
+
progressed = true;
|
|
2124
|
+
}
|
|
2125
|
+
if (after(more, spot.ph === "w" ? "" : "r"))
|
|
2126
|
+
return await answer(false);
|
|
2127
|
+
continue;
|
|
2128
|
+
}
|
|
2129
|
+
if (spot.ph === "c" && client && chosen && from !== null) {
|
|
2130
|
+
const { rows: changed, more } = await round(caller, client, spot.p, from);
|
|
2131
|
+
if (!settle(changed.map((raw) => id2(raw.id) ?? "")))
|
|
2132
|
+
continue;
|
|
2133
|
+
while (spot.o < changed.length) {
|
|
2134
|
+
const raw = changed[spot.o];
|
|
2135
|
+
const externalId = id2(raw.id) ?? "";
|
|
2136
|
+
const leads = byNumber(linkedIds(raw, "leads"));
|
|
2137
|
+
const ours = /* @__PURE__ */ __name(() => chosen.includes(ownerOf(raw)) || leads.some((lead) => chosen.includes(owners.get(lead) ?? "")), "ours");
|
|
2138
|
+
let done = subOf(externalId);
|
|
2139
|
+
for (const lead of leads) {
|
|
2140
|
+
if (ours())
|
|
2141
|
+
break;
|
|
2142
|
+
if (Number(lead) <= done)
|
|
2143
|
+
continue;
|
|
2144
|
+
if (!owners.has(lead)) {
|
|
2145
|
+
spot = { ...spot, l: done, k: externalId };
|
|
2146
|
+
await resolveOwners(caller, leads.filter((one) => Number(one) >= Number(lead)));
|
|
2147
|
+
progressed = true;
|
|
2148
|
+
}
|
|
2149
|
+
done = Number(lead);
|
|
2150
|
+
}
|
|
2151
|
+
if (ours()) {
|
|
2152
|
+
rows.push(raw);
|
|
2153
|
+
kept.add(externalId);
|
|
2154
|
+
}
|
|
2155
|
+
spot = { ph: spot.ph, p: spot.p, o: spot.o + 1, k: externalId };
|
|
2156
|
+
progressed = true;
|
|
2157
|
+
}
|
|
2158
|
+
if (after(more, "n"))
|
|
2159
|
+
return await answer(false);
|
|
2160
|
+
continue;
|
|
2161
|
+
}
|
|
2162
|
+
if (spot.ph === "r" && from !== null) {
|
|
2163
|
+
const { rows: events, more } = await listPage(caller, ROUTES.events, "events", {
|
|
2164
|
+
...typesOf([`${ENTITIES[amoKind].event}_deleted`]),
|
|
2165
|
+
...window,
|
|
2166
|
+
limit: EVENTS_PAGE2,
|
|
2167
|
+
page: spot.p
|
|
2168
|
+
});
|
|
2169
|
+
for (const raw of events) {
|
|
2170
|
+
const entity = id2(raw.entity_id);
|
|
2171
|
+
if (entity)
|
|
2172
|
+
removed.add(entity);
|
|
2173
|
+
}
|
|
2174
|
+
after(more && events.length > 0, "s");
|
|
2175
|
+
return await answer(false);
|
|
2176
|
+
}
|
|
2177
|
+
if (spot.ph === "s" && from !== null) {
|
|
2178
|
+
const { rows: events, more } = await listPage(caller, ROUTES.events, "events", {
|
|
2179
|
+
...typesOf([`${ENTITIES[amoKind].event}_restored`]),
|
|
2180
|
+
...window,
|
|
2181
|
+
limit: EVENTS_PAGE2,
|
|
2182
|
+
page: spot.p
|
|
2183
|
+
});
|
|
2184
|
+
const back = byNumber(events.flatMap((raw) => id2(raw.entity_id) ?? []));
|
|
2185
|
+
let done = Number(spot.k ?? 0);
|
|
2186
|
+
for (; ; ) {
|
|
2187
|
+
const left = back.filter((one) => Number(one) > done);
|
|
2188
|
+
if (left.length === 0)
|
|
2189
|
+
break;
|
|
2190
|
+
const { read, rows: found } = await readSome(caller, amoKind, left, { with: WITH[amoKind] });
|
|
2191
|
+
const alive = /* @__PURE__ */ new Set();
|
|
2192
|
+
for (const raw of found) {
|
|
2193
|
+
if (raw.is_deleted === true)
|
|
2194
|
+
continue;
|
|
2195
|
+
alive.add(id2(raw.id) ?? "");
|
|
2196
|
+
if (!client || !chosen || chosen.includes(ownerOf(raw)))
|
|
2197
|
+
rows.push(raw);
|
|
2198
|
+
}
|
|
2199
|
+
for (const one of left.slice(0, read))
|
|
2200
|
+
if (!alive.has(one))
|
|
2201
|
+
removed.add(one);
|
|
2202
|
+
done = Number(left[read - 1]);
|
|
2203
|
+
spot = { ...spot, k: String(done) };
|
|
2204
|
+
progressed = true;
|
|
2205
|
+
}
|
|
2206
|
+
if (after(more && events.length > 0, ""))
|
|
2207
|
+
return await answer(false);
|
|
2208
|
+
continue;
|
|
2209
|
+
}
|
|
2210
|
+
return { reset: true };
|
|
2211
|
+
}
|
|
2212
|
+
} catch (error) {
|
|
2213
|
+
if (!(error instanceof Cut))
|
|
2214
|
+
throw error;
|
|
2215
|
+
if (!progressed)
|
|
2216
|
+
throw caller.spent();
|
|
2217
|
+
return answer(false);
|
|
2218
|
+
}
|
|
2219
|
+
},
|
|
2220
|
+
async stageHistory(_kind, since, after, context) {
|
|
2221
|
+
const caller = metered(context, true);
|
|
2222
|
+
const chosen = chosenOf(context);
|
|
2223
|
+
const inside = /^h(\d+)\.(\d+)\.(\d+)\.(\d+)$/.exec(after ?? "");
|
|
2224
|
+
const resumed = inside ? 0 : Number(after ?? 0) || 0;
|
|
2225
|
+
const from = inside ? Number(inside[1]) : resumed ? resumed - seconds2(OVERLAP_MS2) : seconds2(since);
|
|
2226
|
+
let at = inside ? { p: Number(inside[2]), o: Number(inside[3]) } : { p: 1, o: 0 };
|
|
2227
|
+
let last = inside ? Number(inside[4]) : resumed || from;
|
|
2228
|
+
const start = `${at.p}.${at.o}`;
|
|
2229
|
+
const items = [];
|
|
2230
|
+
const named = /* @__PURE__ */ new Set();
|
|
2231
|
+
const answer = /* @__PURE__ */ __name((done) => {
|
|
2232
|
+
items.sort((a, b) => a.at - b.at);
|
|
2233
|
+
return done ? { items, hasMore: false, cursor: String(last) } : { items, hasMore: true, nextCursor: `h${from}.${at.p}.${at.o}.${last}` };
|
|
2234
|
+
}, "answer");
|
|
2235
|
+
try {
|
|
2236
|
+
for (; ; ) {
|
|
2237
|
+
const { rows, more } = await listPage(caller, ROUTES.events, "events", {
|
|
2238
|
+
...typesOf(["lead_status_changed"]),
|
|
2239
|
+
"filter[created_at][from]": from,
|
|
2240
|
+
limit: EVENTS_PAGE2,
|
|
2241
|
+
page: at.p
|
|
2242
|
+
});
|
|
2243
|
+
while (at.o < rows.length) {
|
|
2244
|
+
const raw = rows[at.o];
|
|
2245
|
+
const status = fieldOf2(rawsOf(raw.value_after)[0], "lead_status");
|
|
2246
|
+
const externalId = text2(raw.id);
|
|
2247
|
+
const item = id2(raw.entity_id);
|
|
2248
|
+
const stage = id2(fieldOf2(status, "id"));
|
|
2249
|
+
const pipeline = id2(fieldOf2(status, "pipeline_id"));
|
|
2250
|
+
const when = Number(raw.created_at);
|
|
2251
|
+
if (chosen && item)
|
|
2252
|
+
while (await resolveOwners(caller, [item])) {
|
|
2253
|
+
}
|
|
2254
|
+
if (externalId && item && stage && pipeline && when > 0 && (!chosen || chosen.includes(owners.get(item) ?? "")) && !named.has(externalId)) {
|
|
2255
|
+
named.add(externalId);
|
|
2256
|
+
items.push({ externalId, kind: "deal", item, pipeline, stage, at: when * 1e3 });
|
|
2257
|
+
}
|
|
2258
|
+
if (when > 0)
|
|
2259
|
+
last = Math.max(last, when);
|
|
2260
|
+
at = { ...at, o: at.o + 1 };
|
|
2261
|
+
}
|
|
2262
|
+
if (!more || rows.length === 0)
|
|
2263
|
+
return answer(true);
|
|
2264
|
+
at = { p: at.p + 1, o: 0 };
|
|
2265
|
+
return answer(false);
|
|
2266
|
+
}
|
|
2267
|
+
} catch (error) {
|
|
2268
|
+
if (!(error instanceof Cut))
|
|
2269
|
+
throw error;
|
|
2270
|
+
if (`${at.p}.${at.o}` === start)
|
|
2271
|
+
throw caller.spent();
|
|
2272
|
+
return answer(false);
|
|
2273
|
+
}
|
|
2274
|
+
},
|
|
2275
|
+
// Read only when the account's activities setting is on; core keeps those on the deals and clients the copy holds.
|
|
2276
|
+
activities(since, page, context) {
|
|
2277
|
+
const caller = metered(context);
|
|
2278
|
+
return readActivities((route, name, query) => listPage(caller, route, name, query), { since, now: now(), size, types: typesOf, ...page === void 0 ? {} : { page } }, context);
|
|
2279
|
+
},
|
|
2280
|
+
async users(context) {
|
|
2281
|
+
return (await readAll(metered(context), ROUTES.users, "users")).flatMap((raw) => toUser(raw) ?? []);
|
|
2282
|
+
},
|
|
2283
|
+
async list(kind, query, context) {
|
|
2284
|
+
const caller = metered(context);
|
|
2285
|
+
const me = query.conditions.some((one) => one.field === "assigned_to" && [one.value].flat().includes("me"));
|
|
2286
|
+
const filters = filtersOf(kind, query.conditions, me ? (await accountOf(caller)).userId : void 0);
|
|
2287
|
+
if (Object.keys(filters).length && !(await accountOf(caller)).filters)
|
|
2288
|
+
throw new CliError("validation_error", "this account has no API filter add-on (is_api_filter_enabled is off), so amoCRM cannot narrow the list by owner or time; search by name instead", { reason: "amo.filters-off" });
|
|
2289
|
+
const entity = ENTITIES[kind];
|
|
2290
|
+
const { rows, more } = await listPage(caller, entity.list, entity.name, {
|
|
2291
|
+
...filters,
|
|
2292
|
+
...query.text ? { query: query.text } : {},
|
|
2293
|
+
...kind === "organization" ? { with: "contacts" } : {},
|
|
2294
|
+
"order[updated_at]": "desc",
|
|
2295
|
+
limit: query.limit,
|
|
2296
|
+
page: query.page ?? 1
|
|
2297
|
+
});
|
|
2298
|
+
return { items: await mapped(kind, rows, caller), hasMore: more && rows.length > 0 };
|
|
2299
|
+
},
|
|
2300
|
+
async get(kind, externalId, context) {
|
|
2301
|
+
const caller = metered(context);
|
|
2302
|
+
const raw = await readOne(caller, ENTITIES[kind].one, externalId, kind === "organization" ? { with: "contacts" } : {});
|
|
2303
|
+
return raw ? (await mapped(kind, [raw], caller))[0] ?? null : null;
|
|
2304
|
+
},
|
|
2305
|
+
isAdmin,
|
|
2306
|
+
// A client is the sign-in's own when it is assigned to its user or on one of its user's leads.
|
|
2307
|
+
async ownClients(kind, ids) {
|
|
2308
|
+
const caller = account();
|
|
2309
|
+
const self = (await accountOf(caller)).userId;
|
|
2310
|
+
const rows = await byIds(caller, kind, ids, { with: "leads" });
|
|
2311
|
+
await ownersOf(caller, rows.flatMap((raw) => linkedIds(raw, "leads")));
|
|
2312
|
+
return new Set(rows.filter((raw) => ownerOf(raw) === self || linkedIds(raw, "leads").some((lead) => owners.get(lead) === self)).flatMap((raw) => id2(raw.id) ?? []));
|
|
2313
|
+
},
|
|
2314
|
+
async item(externalId) {
|
|
2315
|
+
const raw = await readOne(account(), ROUTES.lead, externalId, { with: WITH.deal });
|
|
2316
|
+
if (!raw)
|
|
2317
|
+
throw new CliError("not_found", `amoCRM has no deal ${externalId}`);
|
|
2318
|
+
return (await mapped("deal", [raw], account()))[0];
|
|
2319
|
+
},
|
|
2320
|
+
async lossReasons() {
|
|
2321
|
+
const { rows } = await listPage(account(), ROUTES.lossReasons, "loss_reasons", {});
|
|
2322
|
+
return rows.flatMap((raw) => {
|
|
2323
|
+
const reason = id2(raw.id);
|
|
2324
|
+
return reason ? [{ id: reason, name: text2(raw.name) ?? reason }] : [];
|
|
2325
|
+
});
|
|
2326
|
+
}
|
|
2327
|
+
};
|
|
2328
|
+
}, "amoCrmSource");
|
|
2329
|
+
|
|
2330
|
+
export {
|
|
2331
|
+
OPERATIONS,
|
|
2332
|
+
matchOperation,
|
|
2333
|
+
withEveryId,
|
|
2334
|
+
pathOf,
|
|
2335
|
+
amoCrmSource
|
|
2336
|
+
};
|