@wirecat/bitrix24-cli 0.2.0 → 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +60 -0
- package/dist/api-keys.d.ts +30 -8
- package/dist/api-keys.d.ts.map +1 -1
- package/dist/api-keys.js +81 -18
- package/dist/api-keys.js.map +1 -1
- package/dist/bin/b24.js +2 -2
- package/dist/bitrix/methods.d.ts.map +1 -1
- package/dist/bitrix/methods.js +7 -3
- package/dist/bitrix/methods.js.map +1 -1
- package/dist/bitrix/transport.d.ts +4 -7
- package/dist/bitrix/transport.d.ts.map +1 -1
- package/dist/bitrix/transport.js +12 -16
- package/dist/bitrix/transport.js.map +1 -1
- package/dist/bundle/{all-profiles-QJ444GSX.js → all-profiles-MBQZCOVK.js} +6 -6
- package/dist/bundle/{anthropic-RHRAVHC2.js → anthropic-QCYLKSJJ.js} +4 -4
- package/dist/bundle/{app-server-QIT6S7AZ.js → app-server-FSLZ2Y6N.js} +42 -42
- package/dist/bundle/b24.js +12 -12
- package/dist/bundle/{bun-H6RSODZ3.js → bun-UYRQXF33.js} +2 -2
- package/dist/bundle/{bun-sqlite-BO4LTQHX.js → bun-sqlite-GXME7EMT.js} +3 -3
- package/dist/bundle/{chunk-MBDK4YXG.js → chunk-2D5W4LWL.js} +1 -1
- package/dist/bundle/{chunk-U5ACMCAQ.js → chunk-2IZ6GGU2.js} +151 -151
- package/dist/bundle/{chunk-VEWWAGTD.js → chunk-4OVK5XW2.js} +8 -8
- package/dist/bundle/{chunk-45AKJVKV.js → chunk-66QLBRIT.js} +1 -1
- package/dist/bundle/{chunk-P364PLIK.js → chunk-6BLVBGRK.js} +9 -9
- package/dist/bundle/{chunk-FOTREPNS.js → chunk-6ERX33NC.js} +8 -8
- package/dist/bundle/{chunk-LRGYKOCP.js → chunk-AMVRNYD6.js} +1 -1
- package/dist/bundle/{chunk-YZ5LHE5Q.js → chunk-AOUNT22U.js} +2 -2
- package/dist/bundle/{chunk-ZDQQCXFG.js → chunk-B252WFK7.js} +13 -13
- package/dist/bundle/{chunk-WKRQ44EH.js → chunk-BHZ5VDDY.js} +13 -13
- package/dist/bundle/{chunk-ZIAQPTUS.js → chunk-COOOXDKZ.js} +3 -3
- package/dist/bundle/{chunk-GDFNH33E.js → chunk-CR3TLGM4.js} +9 -4
- package/dist/bundle/{chunk-D5S6QV6R.js → chunk-D2IRPC5I.js} +6 -6
- package/dist/bundle/{chunk-POC3V3AO.js → chunk-DQIQIZQS.js} +297 -256
- package/dist/bundle/{chunk-QGMDQ2PM.js → chunk-EIGPMMGC.js} +3 -3
- package/dist/bundle/{chunk-WTPMJYMD.js → chunk-ELBOQHJA.js} +45 -45
- package/dist/bundle/{chunk-LSPIOT6Z.js → chunk-EQLWU6ZB.js} +7 -7
- package/dist/bundle/{chunk-WII44RXN.js → chunk-F5NH3UJQ.js} +2 -2
- package/dist/bundle/{chunk-HAXNUIGQ.js → chunk-GTDOUP6L.js} +26 -23
- package/dist/bundle/{chunk-QQXH2OPB.js → chunk-GTFRSYYJ.js} +17 -12
- package/dist/bundle/{chunk-H2ADPPSH.js → chunk-GTMCLOYY.js} +670 -465
- package/dist/bundle/{chunk-7GRZAKBB.js → chunk-IF27EQN6.js} +2 -2
- package/dist/bundle/{chunk-FZL7F5NR.js → chunk-IWEWDVZ6.js} +22 -22
- package/dist/bundle/{program-UYX5362I.js → chunk-J7OMY6EO.js} +16672 -18336
- package/dist/bundle/{chunk-QIPTIUMJ.js → chunk-JAS3OZSP.js} +4 -4
- package/dist/bundle/{chunk-OTD2ZRXD.js → chunk-JB7OXYAU.js} +4 -4
- package/dist/bundle/{chunk-ZEW4P6AH.js → chunk-K7XWCZF6.js} +8 -8
- package/dist/bundle/{chunk-YYO7D2MO.js → chunk-LAYH344Y.js} +28 -28
- package/dist/bundle/{chunk-K3UIB6ZF.js → chunk-M5XMAUGZ.js} +2 -2
- package/dist/bundle/{chunk-2KCZ7BKW.js → chunk-MPI2FDJ4.js} +11 -11
- package/dist/bundle/{chunk-HGL63O5V.js → chunk-MY6FAZRA.js} +2 -2
- package/dist/bundle/{chunk-QC53QBNC.js → chunk-NDSOBIR3.js} +3 -3
- package/dist/bundle/{chunk-XRFJWHY5.js → chunk-NEK7LKC6.js} +4 -4
- package/dist/bundle/{chunk-2SNUMZ7S.js → chunk-NKLLI4B2.js} +6 -6
- package/dist/bundle/{chunk-QMPN6WKD.js → chunk-NWKXMMON.js} +100 -81
- package/dist/bundle/{chunk-P33NDCDI.js → chunk-O7FVOICH.js} +1 -1
- package/dist/bundle/{chunk-SFRNX2TI.js → chunk-OCRCVLZQ.js} +1 -1
- package/dist/bundle/{chunk-TE3FR6MI.js → chunk-OKDC6CLH.js} +5 -5
- package/dist/bundle/{chunk-DTXERR44.js → chunk-OWILUBCI.js} +2 -2
- package/dist/bundle/{chunk-CXL33BFL.js → chunk-OYLJHX74.js} +1 -1
- package/dist/bundle/{chunk-6WY72XVQ.js → chunk-POUSZWMP.js} +4 -4
- package/dist/bundle/{chunk-N6FLBXZS.js → chunk-Q4ILKTV4.js} +3 -3
- package/dist/bundle/{chunk-FLUEXJ4X.js → chunk-Q7Z5IMVY.js} +1 -1
- package/dist/bundle/{chunk-XJXONOB5.js → chunk-QVZSLBR6.js} +1 -1
- package/dist/bundle/{chunk-IRV2PCQ2.js → chunk-SBW2Y7AZ.js} +26 -26
- package/dist/bundle/{chunk-XNHSPHUN.js → chunk-UCLWWSQK.js} +2 -2
- package/dist/bundle/{chunk-BCF7P4FZ.js → chunk-UH56WLDS.js} +8 -8
- package/dist/bundle/{chunk-ZGZT5S6B.js → chunk-VMQL4GNH.js} +55 -55
- package/dist/bundle/{chunk-XD4FRDSL.js → chunk-VTIUWHZ3.js} +5 -5
- package/dist/bundle/{chunk-SGRYYE4X.js → chunk-WJRBX5QB.js} +4 -4
- package/dist/bundle/{chunk-VL6SPMZV.js → chunk-XG6QKS7L.js} +5 -5
- package/dist/bundle/{chunk-RRJNNPR4.js → chunk-XKQZLR2X.js} +1 -1
- package/dist/bundle/{chunk-QSNROIJL.js → chunk-XOPMSWFC.js} +9 -9
- package/dist/bundle/{chunk-EVYSBZ3I.js → chunk-XR5SUCAC.js} +4 -4
- package/dist/bundle/{chunk-PH5FZX6E.js → chunk-Y5PPMGCS.js} +2 -2
- package/dist/bundle/{chunk-EXOOKUEA.js → chunk-YFZXI3NN.js} +2 -2
- package/dist/bundle/{chunk-CNNEA2M4.js → chunk-ZU4HXKEW.js} +3 -3
- package/dist/bundle/command-contract-UON4EIC4.js +30 -0
- package/dist/bundle/{decode-5ZPLTYV6.js → decode-IF2F2SFC.js} +3 -3
- package/dist/bundle/{echarts-J6LAPIX7.js → echarts-WDDVEJO2.js} +2 -2
- package/dist/bundle/{embed-YG5LDHME.js → embed-VDUGYEAR.js} +4 -4
- package/dist/bundle/{embedder-7FNUA5OZ.js → embedder-DUN62H3Z.js} +7 -7
- package/dist/bundle/{first-run-JPZNWIJN.js → first-run-NDGYBQEN.js} +8 -8
- package/dist/bundle/first-screen-QAVKP5RF.js +28 -0
- package/dist/bundle/{instructions-AXWTQHMR.js → instructions-JIIKWS7X.js} +1 -1
- package/dist/bundle/{mcp-7F46P6AM.js → mcp-33JX6KP4.js} +2 -2
- package/dist/bundle/{mcp-HUD6UH5X.js → mcp-57EQ6QJO.js} +58 -47
- package/dist/bundle/mcp-PFJER2DE.js +87 -0
- package/dist/bundle/{node-CWKAIOEM.js → node-K57WT42O.js} +2 -2
- package/dist/bundle/{node-sqlite-LSEKVRDA.js → node-sqlite-KS6ORRIG.js} +4 -4
- package/dist/bundle/{oauth-THYNLRLD.js → oauth-SLSANN37.js} +5 -5
- package/dist/bundle/{open-E47QYKFC.js → open-WJPHADEX.js} +3 -3
- package/dist/bundle/{openai-EWSGC3BC.js → openai-HXB3GTOD.js} +12 -12
- package/dist/bundle/{process-WKTEA3WE.js → process-P73TFAXT.js} +1 -1
- package/dist/bundle/program-7BMG5NIN.js +2250 -0
- package/dist/bundle/{prompt-CAQ7QR3U.js → prompt-WDPV37R4.js} +3 -3
- package/dist/bundle/{recognize-6KGHNZC3.js → recognize-CXIFL6IV.js} +2 -2
- package/dist/bundle/{remote-3UO2WDC3.js → remote-Q4VJ4OQW.js} +5 -5
- package/dist/bundle/{rerank-2JVDPZBX.js → rerank-SUFYK63I.js} +5 -5
- package/dist/bundle/{serve-ES7AG5IK.js → serve-B7PGFOC2.js} +7 -7
- package/dist/bundle/server-4DBNJWW6.js +58 -0
- package/dist/bundle/server-OKE7SXJ2.js +45 -0
- package/dist/bundle/{state-7NH5G4XJ.js → state-EZCCXQV7.js} +4 -4
- package/dist/bundle/{store-7O4JQD2Z.js → store-MZ7JBYR6.js} +12 -12
- package/dist/bundle/store-maintenance-command-T5QZMENJ.js +47 -0
- package/dist/commands/api.d.ts.map +1 -1
- package/dist/commands/api.js +57 -7
- package/dist/commands/api.js.map +1 -1
- package/dist/commands/crm-writes.d.ts.map +1 -1
- package/dist/commands/crm-writes.js +24 -8
- package/dist/commands/crm-writes.js.map +1 -1
- package/dist/commands/crm.d.ts.map +1 -1
- package/dist/commands/crm.js +29 -3
- package/dist/commands/crm.js.map +1 -1
- package/dist/commands/fields.d.ts +3 -0
- package/dist/commands/fields.d.ts.map +1 -0
- package/dist/commands/fields.js +45 -0
- package/dist/commands/fields.js.map +1 -0
- package/dist/commands/write.d.ts +6 -1
- package/dist/commands/write.d.ts.map +1 -1
- package/dist/commands/write.js +7 -5
- package/dist/commands/write.js.map +1 -1
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +2 -1
- package/dist/config.js.map +1 -1
- package/dist/crm/conditions.js +1 -1
- package/dist/crm/conditions.js.map +1 -1
- package/dist/crm/custom-query.d.ts +19 -0
- package/dist/crm/custom-query.d.ts.map +1 -0
- package/dist/crm/custom-query.js +79 -0
- package/dist/crm/custom-query.js.map +1 -0
- package/dist/crm/deal.d.ts +7 -3
- package/dist/crm/deal.d.ts.map +1 -1
- package/dist/crm/deal.js +3 -3
- package/dist/crm/deal.js.map +1 -1
- package/dist/crm/fields.d.ts +44 -0
- package/dist/crm/fields.d.ts.map +1 -0
- package/dist/crm/fields.js +143 -0
- package/dist/crm/fields.js.map +1 -0
- package/dist/crm/items.d.ts +9 -3
- package/dist/crm/items.d.ts.map +1 -1
- package/dist/crm/items.js +27 -6
- package/dist/crm/items.js.map +1 -1
- package/dist/crm/lead.d.ts +7 -3
- package/dist/crm/lead.d.ts.map +1 -1
- package/dist/crm/lead.js +3 -3
- package/dist/crm/lead.js.map +1 -1
- package/dist/crm/organization.d.ts +7 -3
- package/dist/crm/organization.d.ts.map +1 -1
- package/dist/crm/organization.js +3 -3
- package/dist/crm/organization.js.map +1 -1
- package/dist/crm/person.d.ts +7 -3
- package/dist/crm/person.d.ts.map +1 -1
- package/dist/crm/person.js +3 -3
- package/dist/crm/person.js.map +1 -1
- package/dist/crm/values.d.ts +12 -1
- package/dist/crm/values.d.ts.map +1 -1
- package/dist/crm/values.js +12 -2
- package/dist/crm/values.js.map +1 -1
- package/dist/mcp.d.ts.map +1 -1
- package/dist/mcp.js +4 -1
- package/dist/mcp.js.map +1 -1
- package/dist/program.d.ts.map +1 -1
- package/dist/program.js +4 -1
- package/dist/program.js.map +1 -1
- package/dist/reasons.d.ts.map +1 -1
- package/dist/reasons.js +6 -1
- package/dist/reasons.js.map +1 -1
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +3 -3
- package/skills/bitrix24-cli/SKILL.md +8 -3
- package/dist/bundle/command-contract-OKQOE6G4.js +0 -30
- package/dist/bundle/first-screen-VQM4MTS7.js +0 -28
- package/dist/bundle/mcp-J5R5A65I.js +0 -87
- package/dist/bundle/server-5LE5LNUQ.js +0 -45
- package/dist/bundle/server-BU4VBM6S.js +0 -58
- package/dist/bundle/store-maintenance-command-UDVGEY2D.js +0 -47
- /package/dist/bundle/{chunk-4PDYYS5K.js → chunk-NDTJE6JQ.js} +0 -0
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,66 @@
|
|
|
2
2
|
|
|
3
3
|
Notable changes to `@wirecat/bitrix24-cli`. One section per version, newest first.
|
|
4
4
|
|
|
5
|
+
## 0.4.0 — 06.11.2026
|
|
6
|
+
|
|
7
|
+
### Added
|
|
8
|
+
|
|
9
|
+
- `create` and `update` for deals, leads, people and organizations take `--field "<label or code>=<value>"`, repeated
|
|
10
|
+
for more fields or for each value of a multiple field. The label is looked up on the portal; two fields with that
|
|
11
|
+
label are refused with their codes. A list field takes its option's label or id. `--field` wins over `--body` for the
|
|
12
|
+
same field, and `--title`, `--name`, `--first-name` and `--last-name` win over both. Other values go to the portal as
|
|
13
|
+
typed. `--dry-run` does not look the names up.
|
|
14
|
+
- `list` for deals, leads, people and organizations filters by the portal's own fields: `<code or label>:<value>`,
|
|
15
|
+
for the fields the portal can filter by; a list field takes its option's label or id. A label with spaces is
|
|
16
|
+
written `lead_source:web` or `Lead\ source:web`.
|
|
17
|
+
- `list --json=…,provider_metadata.<code>` adds that custom field to each item, as `show` gives it;
|
|
18
|
+
`--json=…,provider_metadata` adds every one. Only codes the portal lists are asked for.
|
|
19
|
+
- `fields list <deals|leads|people|organizations>` lists the portal's custom fields of that kind: code, label, type,
|
|
20
|
+
whether it holds several values, whether a list can filter by it, and a list field's options with their ids.
|
|
21
|
+
|
|
22
|
+
### Changed — may break callers
|
|
23
|
+
|
|
24
|
+
- `show` gives a list field's value by its option's label, not its id; the id moves to `option_id` beside it. A field
|
|
25
|
+
that holds several options gives both as arrays.
|
|
26
|
+
- `api call` works from an allow list. The CRM, catalog and user reads and the four CRM types' writes are allowed as
|
|
27
|
+
before. Any other method asks, so it needs `--yes` without a terminal, and the families that message people, publish
|
|
28
|
+
or send data out are denied: `imconnector`, `log.blogpost`, public file links and `event.bind` join `im`,
|
|
29
|
+
`imopenlines` and the rest. `api show` names each method's level.
|
|
30
|
+
|
|
31
|
+
### Fixed
|
|
32
|
+
|
|
33
|
+
- A `deny` in a profile stops a read command again. `b24` handed cli-core only `resolveSettings`, so cli-core never
|
|
34
|
+
saw b24's permission table: `deals.list: deny` did not stop `deals list`, over MCP too, and with any b24 key in the
|
|
35
|
+
config every `--dry-run` failed with "names no command".
|
|
36
|
+
- `api.crm.<type>.add` and `api.crm.<type>.update` now hold on `deals`, `leads`, `people` and `organizations`
|
|
37
|
+
`create`, `update` and `move`, as the command keys already held on `api call`. `--dry-run` names them beside the
|
|
38
|
+
command's own key.
|
|
39
|
+
- `api call --dry-run` names every key the call checks with its level, such as `api.crm.deal.delete` at `ask`, instead
|
|
40
|
+
of "no key, allowed".
|
|
41
|
+
- `api call crm.item.add|update|delete` with `entityTypeId` 1 to 4 checks the lead, deal, contact or company command
|
|
42
|
+
key, as `crm.deal.update` already did: `deals.delete: deny` now stops `crm.item.delete` for a deal.
|
|
43
|
+
- Every method whose name ends in `delete` asks, not only the listed ones. A method name in capitals or with a `.json`
|
|
44
|
+
suffix is read as its plain name, so it no longer gets round a key.
|
|
45
|
+
- A write that sets a stage checks `deals.move` or `leads.move`: `update` and `create` with `stageId` in `--body`, over
|
|
46
|
+
MCP too, and `api call` with `STAGE_ID` or a lead's `STATUS_ID`. `ASSIGNED_BY_ID` checks `crm.assign-others` like
|
|
47
|
+
`assignedById`.
|
|
48
|
+
- A write is sent once. A REST 3.0 write that got no answer was sent up to three more times with the same
|
|
49
|
+
`Idempotency-Key`, which is not yet checked on a live portal; it is now `outcome_unknown` at once, and its message
|
|
50
|
+
names `--operation-id` once.
|
|
51
|
+
- `pipeline_id:0`, the default pipeline, is accepted by `deals list` and `stages list`.
|
|
52
|
+
- The allow list keeps the denied families' reads refused, as before it: `crm.activity.list`, `im.*`, `tasks.*` and
|
|
53
|
+
the rest are `deny`, and `api show` says so.
|
|
54
|
+
- The MCP server applies b24's permission table (WC-PERM-23): a command the profile denies is listed by tools search
|
|
55
|
+
as unavailable, not offered as available.
|
|
56
|
+
|
|
57
|
+
## 0.3.0 — 06.11.2026
|
|
58
|
+
|
|
59
|
+
### Changed — may break callers
|
|
60
|
+
|
|
61
|
+
- `show` for deals, leads, people and organizations gives each custom field its title on the portal:
|
|
62
|
+
`provider_metadata` maps the field's code to `{ "label", "value" }`. `label` is `null` when the portal has no title
|
|
63
|
+
for it or does not answer the request for titles; `show` still answers then.
|
|
64
|
+
|
|
5
65
|
## 0.2.0 — 06.11.2026
|
|
6
66
|
|
|
7
67
|
### Fixed
|
package/dist/api-keys.d.ts
CHANGED
|
@@ -2,19 +2,41 @@ import type { Level } from "@wirecat/cli-core/sends";
|
|
|
2
2
|
import { type Effect } from "./bitrix/methods.js";
|
|
3
3
|
export declare const apiKey: (method: string) => string;
|
|
4
4
|
/**
|
|
5
|
-
* Families whose writes reach people or start the portal's own automation: messages and notifications (im,
|
|
6
|
-
* imopenlines, imbot; read-only for now, NEED-2278 A),
|
|
7
|
-
* (an e-mail activity sends the mail), tasks (the assignee is told),
|
|
8
|
-
*
|
|
5
|
+
* Families whose writes reach people, publish, or start the portal's own automation: messages and notifications (im,
|
|
6
|
+
* imopenlines, imbot, imconnector's Open Lines; read-only for now, NEED-2278 A), Live Feed posts, SMS and mail
|
|
7
|
+
* services, telephony, workflows, CRM activities (an e-mail activity sends the mail), tasks (the assignee is told),
|
|
8
|
+
* invitations (`user.add` mails one), public file links, event handlers that send portal data to a URL, and `batch`,
|
|
9
|
+
* which can hold any of them. Denied until the owner allows them, reads too: they hold messages, e-mails and tasks.
|
|
9
10
|
*/
|
|
10
11
|
export declare const DENIED_FAMILIES: string[];
|
|
11
|
-
/**
|
|
12
|
-
export declare const
|
|
12
|
+
/** Bitrix24 takes a method in any letter case and with a `.json` suffix; one name keeps the keys from being dodged. */
|
|
13
|
+
export declare const normalMethod: (raw: string) => string;
|
|
14
|
+
/** A field in any letter case, with or without underscores: Bitrix24 takes both `stageId` and `STAGE_ID`. */
|
|
15
|
+
export declare const fieldOf: (record: Record<string, unknown>, name: string) => unknown;
|
|
16
|
+
export declare const fieldsOf: (body: Record<string, unknown>) => Record<string, unknown>;
|
|
17
|
+
/** The employee a write assigns the record to, by any spelling of `assignedById`. */
|
|
18
|
+
export declare const assigneeOf: (fields: Record<string, unknown>) => string | undefined;
|
|
19
|
+
/** Whether a write changes a deal's or a lead's stage: `stageId`, or a lead's REST 2 `STATUS_ID`. */
|
|
20
|
+
export declare const setsStage: (type: string, fields: Record<string, unknown>) => boolean;
|
|
13
21
|
/**
|
|
14
|
-
* The command
|
|
15
|
-
*
|
|
22
|
+
* The command keys a raw call does the same as, so `api call` cannot get round `deals.update: deny` (gcal-cli's
|
|
23
|
+
* `WRITE_METHODS`). A create or update that sets a stage is a move too.
|
|
16
24
|
*/
|
|
17
25
|
export declare const commandKeysOf: (method: string, body?: Record<string, unknown>) => string[];
|
|
26
|
+
/** The command keys a CRM write command checks beside its own: `.move` when its fields set a stage. */
|
|
27
|
+
export declare const stageKeysOf: (noun: string, fields: Record<string, unknown>) => string[];
|
|
28
|
+
/**
|
|
29
|
+
* A method's default, as WC-PERM-22 has it, from an allow list: the reads `b24` makes and the CRM writes the command
|
|
30
|
+
* keys govern are allowed, a delete and anything else asks, and the families that reach people are denied, reads too.
|
|
31
|
+
*/
|
|
32
|
+
export declare const apiDefault: (method: string, effect?: Effect, body?: Record<string, unknown>) => Level;
|
|
33
|
+
/** The built-in levels with this call's own key, which the static table cannot list for every method. */
|
|
34
|
+
export declare const callDefaults: (method: string, effect: Effect, body: Record<string, unknown>, defaults: Readonly<Record<string, Level>>) => Record<string, Level>;
|
|
35
|
+
/**
|
|
36
|
+
* The other way round: the `api.*` key a CRM write command's own request checks, so `api.crm.deal.update: deny` holds
|
|
37
|
+
* on `deals update` too. Both the run and its `--dry-run` preview read it.
|
|
38
|
+
*/
|
|
39
|
+
export declare const apiKeysOf: (path: readonly string[]) => string[];
|
|
18
40
|
/** The keys `permissions` may name for `api`: the known methods and the denied families. */
|
|
19
41
|
export declare const API_KEYS: string[];
|
|
20
42
|
export declare const API_DEFAULTS: Record<string, Level>;
|
package/dist/api-keys.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"api-keys.d.ts","sourceRoot":"","sources":["../src/api-keys.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,yBAAyB,CAAA;AACpD,OAAO,EAAE,KAAK,MAAM,EAA2B,MAAM,qBAAqB,CAAA;AAE1E,eAAO,MAAM,MAAM,WAAY,MAAM,KAAG,MAAyB,CAAA;AAEjE
|
|
1
|
+
{"version":3,"file":"api-keys.d.ts","sourceRoot":"","sources":["../src/api-keys.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,yBAAyB,CAAA;AACpD,OAAO,EAAE,KAAK,MAAM,EAA2B,MAAM,qBAAqB,CAAA;AAE1E,eAAO,MAAM,MAAM,WAAY,MAAM,KAAG,MAAyB,CAAA;AAEjE;;;;;;GAMG;AACH,eAAO,MAAM,eAAe,UAoB3B,CAAA;AAQD,uHAAuH;AACvH,eAAO,MAAM,YAAY,QAAS,MAAM,KAAG,MAAkD,CAAA;AAE7F,6GAA6G;AAC7G,eAAO,MAAM,OAAO,WAAY,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,QAAQ,MAAM,KAAG,OAIvE,CAAA;AAED,eAAO,MAAM,QAAQ,SAAU,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,KAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAG9E,CAAA;AAED,qFAAqF;AACrF,eAAO,MAAM,UAAU,WAAY,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,KAAG,MAAM,GAAG,SAGrE,CAAA;AAED,qGAAqG;AACrG,eAAO,MAAM,SAAS,SAAU,MAAM,UAAU,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,KAAG,OAEoC,CAAA;AAgB9G;;;GAGG;AACH,eAAO,MAAM,aAAa,WAAY,MAAM,SAAQ,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,KAAQ,MAAM,EAOxF,CAAA;AAED,uGAAuG;AACvG,eAAO,MAAM,WAAW,SAAU,MAAM,UAAU,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,KAAG,MAAM,EAGjF,CAAA;AAED;;;GAGG;AACH,eAAO,MAAM,UAAU,WACb,MAAM,WACN,MAAM,SACR,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,KAC5B,KAKF,CAAA;AAED,yGAAyG;AACzG,eAAO,MAAM,YAAY,WACf,MAAM,UACN,MAAM,QACR,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,YACnB,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC,KACxC,MAAM,CAAC,MAAM,EAAE,KAAK,CAA0E,CAAA;AAIjG;;;GAGG;AACH,eAAO,MAAM,SAAS,SAAU,SAAS,MAAM,EAAE,KAAG,MAAM,EAKzD,CAAA;AAED,4FAA4F;AAC5F,eAAO,MAAM,QAAQ,UAAoF,CAAA;AAEzG,eAAO,MAAM,YAAY,EAAE,MAAM,CAAC,MAAM,EAAE,KAAK,CAQ9C,CAAA"}
|
package/dist/api-keys.js
CHANGED
|
@@ -1,15 +1,18 @@
|
|
|
1
1
|
import { KNOWN_METHODS, methodOf } from "./bitrix/methods.js";
|
|
2
2
|
export const apiKey = (method) => `api.${method}`;
|
|
3
3
|
/**
|
|
4
|
-
* Families whose writes reach people or start the portal's own automation: messages and notifications (im,
|
|
5
|
-
* imopenlines, imbot; read-only for now, NEED-2278 A),
|
|
6
|
-
* (an e-mail activity sends the mail), tasks (the assignee is told),
|
|
7
|
-
*
|
|
4
|
+
* Families whose writes reach people, publish, or start the portal's own automation: messages and notifications (im,
|
|
5
|
+
* imopenlines, imbot, imconnector's Open Lines; read-only for now, NEED-2278 A), Live Feed posts, SMS and mail
|
|
6
|
+
* services, telephony, workflows, CRM activities (an e-mail activity sends the mail), tasks (the assignee is told),
|
|
7
|
+
* invitations (`user.add` mails one), public file links, event handlers that send portal data to a URL, and `batch`,
|
|
8
|
+
* which can hold any of them. Denied until the owner allows them, reads too: they hold messages, e-mails and tasks.
|
|
8
9
|
*/
|
|
9
10
|
export const DENIED_FAMILIES = [
|
|
10
11
|
"im",
|
|
11
12
|
"imopenlines",
|
|
12
13
|
"imbot",
|
|
14
|
+
"imconnector",
|
|
15
|
+
"log.blogpost",
|
|
13
16
|
"messageservice",
|
|
14
17
|
"mailservice",
|
|
15
18
|
"telephony",
|
|
@@ -20,32 +23,92 @@ export const DENIED_FAMILIES = [
|
|
|
20
23
|
"tasks",
|
|
21
24
|
"task",
|
|
22
25
|
"user.add",
|
|
26
|
+
"disk.file.getexternallink",
|
|
27
|
+
"disk.folder.getexternallink",
|
|
28
|
+
"event.bind",
|
|
23
29
|
"batch",
|
|
24
30
|
];
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
+
/** The families `b24` reads itself: a read outside them asks, since it may hold what the owner keeps from agents. */
|
|
32
|
+
const READ_FAMILIES = ["crm", "catalog", "user", "profile", "methods", "method", "scope", "server.time", "app.info"];
|
|
33
|
+
const inFamily = (families, method) => families.some((family) => method === family || method.startsWith(`${family}.`));
|
|
34
|
+
/** Bitrix24 takes a method in any letter case and with a `.json` suffix; one name keeps the keys from being dodged. */
|
|
35
|
+
export const normalMethod = (raw) => raw.toLowerCase().replace(/\.json$/, "");
|
|
36
|
+
/** A field in any letter case, with or without underscores: Bitrix24 takes both `stageId` and `STAGE_ID`. */
|
|
37
|
+
export const fieldOf = (record, name) => {
|
|
38
|
+
const wanted = name.toLowerCase();
|
|
39
|
+
const found = Object.keys(record).find((one) => one.replaceAll("_", "").toLowerCase() === wanted);
|
|
40
|
+
return found === undefined ? undefined : record[found];
|
|
41
|
+
};
|
|
42
|
+
export const fieldsOf = (body) => {
|
|
43
|
+
const fields = fieldOf(body, "fields");
|
|
44
|
+
return typeof fields === "object" && fields !== null ? fields : {};
|
|
45
|
+
};
|
|
46
|
+
/** The employee a write assigns the record to, by any spelling of `assignedById`. */
|
|
47
|
+
export const assigneeOf = (fields) => {
|
|
48
|
+
const found = fieldOf(fields, "assignedById");
|
|
49
|
+
return found === undefined || found === null ? undefined : String(found);
|
|
31
50
|
};
|
|
51
|
+
/** Whether a write changes a deal's or a lead's stage: `stageId`, or a lead's REST 2 `STATUS_ID`. */
|
|
52
|
+
export const setsStage = (type, fields) => (type === "deal" || type === "lead") &&
|
|
53
|
+
(fieldOf(fields, "stageId") !== undefined || (type === "lead" && fieldOf(fields, "statusId") !== undefined));
|
|
32
54
|
const NOUNS = { deal: "deals", lead: "leads", contact: "people", company: "organizations" };
|
|
33
55
|
const ACTIONS = { add: "create", update: "update", delete: "delete" };
|
|
56
|
+
/** `crm.item.*`'s `entityTypeId` for the four types the commands cover (apidocs "crm.item.add"). */
|
|
57
|
+
const ENTITY_TYPES = { "1": "lead", "2": "deal", "3": "contact", "4": "company" };
|
|
58
|
+
/** The CRM type and action a raw write does, whether named `crm.deal.update` or `crm.item.update` with its type id. */
|
|
59
|
+
const crmWriteOf = (method, body) => {
|
|
60
|
+
const named = /^crm\.(deal|lead|contact|company)\.(add|update|delete)$/.exec(method);
|
|
61
|
+
if (named?.[1] && named[2])
|
|
62
|
+
return { type: named[1], action: named[2] };
|
|
63
|
+
const item = /^crm\.item\.(add|update|delete)$/.exec(method);
|
|
64
|
+
const type = ENTITY_TYPES[String(fieldOf(body, "entityTypeId"))];
|
|
65
|
+
return item?.[1] && type ? { type, action: item[1] } : undefined;
|
|
66
|
+
};
|
|
34
67
|
/**
|
|
35
|
-
* The command
|
|
36
|
-
*
|
|
68
|
+
* The command keys a raw call does the same as, so `api call` cannot get round `deals.update: deny` (gcal-cli's
|
|
69
|
+
* `WRITE_METHODS`). A create or update that sets a stage is a move too.
|
|
37
70
|
*/
|
|
38
71
|
export const commandKeysOf = (method, body = {}) => {
|
|
39
|
-
const
|
|
40
|
-
if (!
|
|
72
|
+
const write = crmWriteOf(method, body);
|
|
73
|
+
if (!write)
|
|
41
74
|
return [];
|
|
42
|
-
const noun = NOUNS[type];
|
|
43
|
-
const keys = [`${noun}.${ACTIONS[action]}`];
|
|
44
|
-
|
|
45
|
-
if (action === "update" && fields.stageId !== undefined && (type === "deal" || type === "lead"))
|
|
75
|
+
const noun = NOUNS[write.type];
|
|
76
|
+
const keys = [`${noun}.${ACTIONS[write.action]}`];
|
|
77
|
+
if (write.action !== "delete" && setsStage(write.type, fieldsOf(body)))
|
|
46
78
|
keys.push(`${noun}.move`);
|
|
47
79
|
return keys;
|
|
48
80
|
};
|
|
81
|
+
/** The command keys a CRM write command checks beside its own: `.move` when its fields set a stage. */
|
|
82
|
+
export const stageKeysOf = (noun, fields) => {
|
|
83
|
+
const type = Object.keys(NOUNS).find((one) => NOUNS[one] === noun) ?? "";
|
|
84
|
+
return setsStage(type, fields) ? [`${noun}.move`] : [];
|
|
85
|
+
};
|
|
86
|
+
/**
|
|
87
|
+
* A method's default, as WC-PERM-22 has it, from an allow list: the reads `b24` makes and the CRM writes the command
|
|
88
|
+
* keys govern are allowed, a delete and anything else asks, and the families that reach people are denied, reads too.
|
|
89
|
+
*/
|
|
90
|
+
export const apiDefault = (method, effect = methodOf(method).effect, body = {}) => {
|
|
91
|
+
if (inFamily(DENIED_FAMILIES, method))
|
|
92
|
+
return "deny";
|
|
93
|
+
if (effect === "destructive")
|
|
94
|
+
return "ask";
|
|
95
|
+
if (effect === "read")
|
|
96
|
+
return inFamily(READ_FAMILIES, method) ? "allow" : "ask";
|
|
97
|
+
return crmWriteOf(method, body) ? "allow" : "ask";
|
|
98
|
+
};
|
|
99
|
+
/** The built-in levels with this call's own key, which the static table cannot list for every method. */
|
|
100
|
+
export const callDefaults = (method, effect, body, defaults) => ({ ...defaults, [apiKey(method)]: apiDefault(method, effect, body) });
|
|
101
|
+
const METHODS_OF_COMMANDS = { create: "add", update: "update", move: "update" };
|
|
102
|
+
/**
|
|
103
|
+
* The other way round: the `api.*` key a CRM write command's own request checks, so `api.crm.deal.update: deny` holds
|
|
104
|
+
* on `deals update` too. Both the run and its `--dry-run` preview read it.
|
|
105
|
+
*/
|
|
106
|
+
export const apiKeysOf = (path) => {
|
|
107
|
+
const [noun, command, ...rest] = path;
|
|
108
|
+
const type = Object.keys(NOUNS).find((one) => NOUNS[one] === noun);
|
|
109
|
+
const method = METHODS_OF_COMMANDS[command ?? ""];
|
|
110
|
+
return type && method && rest.length === 0 ? [apiKey(`crm.${type}.${method}`)] : [];
|
|
111
|
+
};
|
|
49
112
|
/** The keys `permissions` may name for `api`: the known methods and the denied families. */
|
|
50
113
|
export const API_KEYS = [...KNOWN_METHODS.map((one) => apiKey(one.name)), ...DENIED_FAMILIES.map(apiKey)];
|
|
51
114
|
export const API_DEFAULTS = {
|
package/dist/api-keys.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"api-keys.js","sourceRoot":"","sources":["../src/api-keys.ts"],"names":[],"mappings":"AACA,OAAO,EAAe,aAAa,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAA;AAE1E,MAAM,CAAC,MAAM,MAAM,GAAG,CAAC,MAAc,EAAU,EAAE,CAAC,OAAO,MAAM,EAAE,CAAA;AAEjE
|
|
1
|
+
{"version":3,"file":"api-keys.js","sourceRoot":"","sources":["../src/api-keys.ts"],"names":[],"mappings":"AACA,OAAO,EAAe,aAAa,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAA;AAE1E,MAAM,CAAC,MAAM,MAAM,GAAG,CAAC,MAAc,EAAU,EAAE,CAAC,OAAO,MAAM,EAAE,CAAA;AAEjE;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,eAAe,GAAG;IAC7B,IAAI;IACJ,aAAa;IACb,OAAO;IACP,aAAa;IACb,cAAc;IACd,gBAAgB;IAChB,aAAa;IACb,WAAW;IACX,YAAY;IACZ,SAAS;IACT,gBAAgB;IAChB,cAAc;IACd,OAAO;IACP,MAAM;IACN,UAAU;IACV,2BAA2B;IAC3B,6BAA6B;IAC7B,YAAY;IACZ,O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CAAC,CAAC;CAC1F,CAAA"}
|
package/dist/bin/b24.js
CHANGED
|
@@ -9,7 +9,7 @@ if (
|
|
|
9
9
|
(words[0] === "--version" || words[0] === "-V") &&
|
|
10
10
|
!Object.keys(process.env).some((key) => key.endsWith("_TEST_ARGV_LOG"))
|
|
11
11
|
) {
|
|
12
|
-
process.stdout.write("0.
|
|
12
|
+
process.stdout.write("0.4.0\n")
|
|
13
13
|
} else {
|
|
14
14
|
// Before the bundle compiles: the bundle's own call comes after its chunks.
|
|
15
15
|
module.enableCompileCache()
|
|
@@ -28,7 +28,7 @@ if (
|
|
|
28
28
|
: next(specifier, context),
|
|
29
29
|
})
|
|
30
30
|
}
|
|
31
|
-
const chunks = ["../bundle/all-profiles-
|
|
31
|
+
const chunks = ["../bundle/all-profiles-MBQZCOVK.js","../bundle/anthropic-QCYLKSJJ.js","../bundle/app-server-FSLZ2Y6N.js","../bundle/bun-UYRQXF33.js","../bundle/bun-sqlite-GXME7EMT.js","../bundle/decode-IF2F2SFC.js","../bundle/dist-6Y64DTOE.js","../bundle/echarts-WDDVEJO2.js","../bundle/embed-VDUGYEAR.js","../bundle/embedder-DUN62H3Z.js","../bundle/first-screen-QAVKP5RF.js","../bundle/instructions-JIIKWS7X.js","../bundle/mcp-33JX6KP4.js","../bundle/mcp-57EQ6QJO.js","../bundle/mcp-PFJER2DE.js","../bundle/node-K57WT42O.js","../bundle/node-P4E63KXA.js","../bundle/node-TLZSIHIJ.js","../bundle/node-sqlite-KS6ORRIG.js","../bundle/oauth-SLSANN37.js","../bundle/open-WJPHADEX.js","../bundle/openai-HXB3GTOD.js","../bundle/process-P73TFAXT.js","../bundle/program-7BMG5NIN.js","../bundle/prompt-WDPV37R4.js","../bundle/recognize-CXIFL6IV.js","../bundle/remote-Q4VJ4OQW.js","../bundle/rerank-SUFYK63I.js","../bundle/serve-B7PGFOC2.js","../bundle/server-4DBNJWW6.js","../bundle/server-OKE7SXJ2.js","../bundle/state-EZCCXQV7.js","../bundle/store-MZ7JBYR6.js","../bundle/store-maintenance-command-T5QZMENJ.js"]
|
|
32
32
|
if (((words) => words
|
|
33
33
|
.filter((word) => !word.startsWith("-"))
|
|
34
34
|
.slice(0, 2)
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"methods.d.ts","sourceRoot":"","sources":["../../src/bitrix/methods.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,WAAW,GAAG,CAAC,GAAG,CAAC,CAAA;AAC/B,MAAM,MAAM,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,aAAa,CAAA;AAErD,MAAM,WAAW,MAAM;IACrB,IAAI,EAAE,MAAM,CAAA;IACZ,GAAG,EAAE,WAAW,CAAA;IAChB,MAAM,EAAE,MAAM,CAAA;IACd,KAAK,EAAE,MAAM,CAAA;CACd;
|
|
1
|
+
{"version":3,"file":"methods.d.ts","sourceRoot":"","sources":["../../src/bitrix/methods.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,WAAW,GAAG,CAAC,GAAG,CAAC,CAAA;AAC/B,MAAM,MAAM,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,aAAa,CAAA;AAErD,MAAM,WAAW,MAAM;IACrB,IAAI,EAAE,MAAM,CAAA;IACZ,GAAG,EAAE,WAAW,CAAA;IAChB,MAAM,EAAE,MAAM,CAAA;IACd,KAAK,EAAE,MAAM,CAAA;CACd;AA2BD,qHAAqH;AACrH,eAAO,MAAM,QAAQ,SAAU,MAAM,KAAG,MAKtC,CAAA;AAEF,sEAAsE;AACtE,eAAO,MAAM,aAAa,EAAE,SAAS,MAAM,EAQ1C,CAAA"}
|
package/dist/bitrix/methods.js
CHANGED
|
@@ -4,12 +4,16 @@
|
|
|
4
4
|
* keeps the outcome rule in one place.
|
|
5
5
|
*/
|
|
6
6
|
const REST3_TYPES = /^crm\.(deal|lead|contact|company|quote|smartinvoice|smartprocess\d+)\./;
|
|
7
|
+
/** `crm.<type>.userfield.*` is REST 2 only; REST 3.0's own is `crm.<type>.field.custom.*`. */
|
|
8
|
+
const REST2_ONLY = /^crm\.[a-z]+\.userfield\./;
|
|
7
9
|
const READ_ACTIONS = new Set(["list", "get", "fields", "current", "search", "aggregate", "admin", "access"]);
|
|
10
|
+
/** Reads whose names end in no read action. */
|
|
11
|
+
const READ_METHODS = new Set(["profile", "methods", "scope", "server.time", "app.info"]);
|
|
8
12
|
const effectOf = (name) => {
|
|
9
13
|
const action = name.slice(name.lastIndexOf(".") + 1);
|
|
10
14
|
if (action === "delete" || action === "deletefieldvalue")
|
|
11
15
|
return "destructive";
|
|
12
|
-
if (READ_ACTIONS.has(action) || name.endsWith(".field.list"))
|
|
16
|
+
if (READ_ACTIONS.has(action) || READ_METHODS.has(name) || name.endsWith(".field.list"))
|
|
13
17
|
return "read";
|
|
14
18
|
return "write";
|
|
15
19
|
};
|
|
@@ -20,13 +24,13 @@ const scopeOf = (name) => {
|
|
|
20
24
|
/** Which REST version answers a method, what it does, and its scope; unknown methods go to REST 2, the older API. */
|
|
21
25
|
export const methodOf = (name) => ({
|
|
22
26
|
name,
|
|
23
|
-
api: REST3_TYPES.test(name) ? 3 : 2,
|
|
27
|
+
api: REST3_TYPES.test(name) && !REST2_ONLY.test(name) ? 3 : 2,
|
|
24
28
|
effect: effectOf(name),
|
|
25
29
|
scope: scopeOf(name),
|
|
26
30
|
});
|
|
27
31
|
/** Methods `b24`'s own commands call; `api list` starts from them. */
|
|
28
32
|
export const KNOWN_METHODS = [
|
|
29
|
-
...["deal", "lead", "contact", "company"].flatMap((type) => ["list", "get", "add", "update", "delete"].map((action) => methodOf(`crm.${type}.${action}`))),
|
|
33
|
+
...["deal", "lead", "contact", "company"].flatMap((type) => ["list", "get", "add", "update", "delete", "field.list", "userfield.list"].map((action) => methodOf(`crm.${type}.${action}`))),
|
|
30
34
|
...["crm.item.list", "crm.category.list", "crm.status.list", "crm.product.list", "crm.product.get"].map(methodOf),
|
|
31
35
|
...["user.current", "user.get", "user.admin"].map(methodOf),
|
|
32
36
|
];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"methods.js","sourceRoot":"","sources":["../../src/bitrix/methods.ts"],"names":[],"mappings":"AAUA;;;;GAIG;AACH,MAAM,WAAW,GAAG,wEAAwE,CAAA;
|
|
1
|
+
{"version":3,"file":"methods.js","sourceRoot":"","sources":["../../src/bitrix/methods.ts"],"names":[],"mappings":"AAUA;;;;GAIG;AACH,MAAM,WAAW,GAAG,wEAAwE,CAAA;AAC5F,8FAA8F;AAC9F,MAAM,UAAU,GAAG,2BAA2B,CAAA;AAE9C,MAAM,YAAY,GAAG,IAAI,GAAG,CAAC,CAAC,MAAM,EAAE,KAAK,EAAE,QAAQ,EAAE,SAAS,EAAE,QAAQ,EAAE,WAAW,EAAE,OAAO,EAAE,QAAQ,CAAC,CAAC,CAAA;AAC5G,+CAA+C;AAC/C,MAAM,YAAY,GAAG,IAAI,GAAG,CAAC,CAAC,SAAS,EAAE,SAAS,EAAE,OAAO,EAAE,aAAa,EAAE,UAAU,CAAC,CAAC,CAAA;AAExF,MAAM,QAAQ,GAAG,CAAC,IAAY,EAAU,EAAE;IACxC,MAAM,MAAM,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,WAAW,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,CAAA;IACpD,IAAI,MAAM,KAAK,QAAQ,IAAI,MAAM,KAAK,kBAAkB;QAAE,OAAO,aAAa,CAAA;IAC9E,IAAI,YAAY,CAAC,GAAG,CAAC,MAAM,CAAC,IAAI,YAAY,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,IAAI,CAAC,QAAQ,CAAC,aAAa,CAAC;QAAE,OAAO,MAAM,CAAA;IACrG,OAAO,OAAO,CAAA;AAChB,CAAC,CAAA;AAED,MAAM,OAAO,GAAG,CAAC,IAAY,EAAE,EAAE;IAC/B,MAAM,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC,EAAE,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,CAA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|
3
3
|
import type { Pacer } from "@wirecat/cli-core/sends";
|
|
4
|
-
import { type RestVersion } from "./methods.js";
|
|
5
4
|
import { type Webhook } from "./webhook.js";
|
|
6
5
|
export type FetchLike = (url: string, init: RequestInit) => Promise<Response>;
|
|
7
6
|
export interface BitrixTransportOptions {
|
|
@@ -17,10 +16,8 @@ export interface BitrixTransportOptions {
|
|
|
17
16
|
random?: () => number;
|
|
18
17
|
}
|
|
19
18
|
export interface CallOptions {
|
|
20
|
-
/** A write's operation id, sent as REST 3.0's `Idempotency-Key`,
|
|
19
|
+
/** A write's operation id, sent as REST 3.0's `Idempotency-Key`, so the owner can repeat it by hand. */
|
|
21
20
|
idempotencyKey?: string;
|
|
22
|
-
/** Overrides the method table, for `api call --rest`. */
|
|
23
|
-
api?: RestVersion;
|
|
24
21
|
}
|
|
25
22
|
/** REST 2 lists carry `total` and `next` beside `result`; REST 3.0 answers carry neither. */
|
|
26
23
|
export interface BitrixAnswer {
|
|
@@ -41,9 +38,9 @@ export declare class BitrixTransport {
|
|
|
41
38
|
/** The employee the webhook acts as. */
|
|
42
39
|
get userId(): string;
|
|
43
40
|
/**
|
|
44
|
-
* Reads are tried again on a refused rate or a lost answer. A write is
|
|
45
|
-
* `Idempotency-Key
|
|
46
|
-
*
|
|
41
|
+
* Reads are tried again on a refused rate or a lost answer. A write is sent once: whether Bitrix24 honours
|
|
42
|
+
* `Idempotency-Key` is not checked on a live portal, so a write that got no answer is `outcome_unknown` and the
|
|
43
|
+
* owner repeats it by hand.
|
|
47
44
|
*/
|
|
48
45
|
call(method: string, params?: Record<string, unknown>, options?: CallOptions): Promise<BitrixAnswer>;
|
|
49
46
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"transport.d.ts","sourceRoot":"","sources":["../../src/bitrix/transport.ts"],"names":[],"mappings":"AAAA,OAAO,EAML,KAAK,SAAS,EAEf,MAAM,mBAAmB,CAAA;AAE1B,OAAO,EAA2B,KAAK,SAAS,EAAkC,MA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B;IAED;;;;OAIG;IACG,IAAI,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,GAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAM,EAAE,OAAO,GAAE,WAAgB,GAAG,OAAO,CAAC,YAAY,CAAC,CAqBjH;CA0HF"}
|
package/dist/bitrix/transport.js
CHANGED
|
@@ -9,10 +9,6 @@ const LARGEST_ANSWER = 16 * 1024 * 1024;
|
|
|
9
9
|
const RETRY = { retries: 3, baseDelayMs: 1_000, maxDelayMs: 10_000, maxRetryAfterMs: 30_000 };
|
|
10
10
|
/** A pace wait longer than this ends the run instead of sitting in it, as cli-core's messenger pacing does. */
|
|
11
11
|
const LONGEST_PACE_WAIT_MS = 60_000;
|
|
12
|
-
/** A keyed write that never got an answer may have run: the caller repeats it with the same operation id. */
|
|
13
|
-
const lastOf = (method, error, reads) => reads || (error.code !== "timeout" && error.code !== "network_error")
|
|
14
|
-
? error
|
|
15
|
-
: new CliError("outcome_unknown", `${method} got no answer; repeat it with the same --operation-id, which Bitrix24 will not run twice`, { operation: method, retryable: true });
|
|
16
12
|
/**
|
|
17
13
|
* Bitrix24's REST API over an incoming webhook, method by method.
|
|
18
14
|
*
|
|
@@ -46,16 +42,15 @@ export class BitrixTransport {
|
|
|
46
42
|
return this.#webhook.userId;
|
|
47
43
|
}
|
|
48
44
|
/**
|
|
49
|
-
* Reads are tried again on a refused rate or a lost answer. A write is
|
|
50
|
-
* `Idempotency-Key
|
|
51
|
-
*
|
|
45
|
+
* Reads are tried again on a refused rate or a lost answer. A write is sent once: whether Bitrix24 honours
|
|
46
|
+
* `Idempotency-Key` is not checked on a live portal, so a write that got no answer is `outcome_unknown` and the
|
|
47
|
+
* owner repeats it by hand.
|
|
52
48
|
*/
|
|
53
49
|
async call(method, params = {}, options = {}) {
|
|
54
50
|
const known = methodOf(method);
|
|
55
|
-
const api =
|
|
51
|
+
const api = known.api;
|
|
56
52
|
const reads = known.effect === "read";
|
|
57
53
|
const key = api === 3 && !reads ? options.idempotencyKey : undefined;
|
|
58
|
-
const repeatable = reads || key !== undefined;
|
|
59
54
|
let waited;
|
|
60
55
|
for (let attempt = 1;; attempt++) {
|
|
61
56
|
try {
|
|
@@ -63,13 +58,13 @@ export class BitrixTransport {
|
|
|
63
58
|
return await this.#once(method, params, { api, reads, key, attempt, waited });
|
|
64
59
|
}
|
|
65
60
|
catch (error) {
|
|
66
|
-
if (!isCliError(error) || !
|
|
61
|
+
if (!isCliError(error) || !reads)
|
|
67
62
|
throw error;
|
|
68
63
|
const asked = error.details.retry_after_ms;
|
|
69
64
|
const wait = typeof asked === "number" ? asked : backoffMs(attempt, RETRY, this.#random);
|
|
70
65
|
const again = error.code === "rate_limited" || error.details.retryable === true;
|
|
71
66
|
if (!again || wait > RETRY.maxRetryAfterMs || attempt > RETRY.retries)
|
|
72
|
-
throw
|
|
67
|
+
throw error;
|
|
73
68
|
if (error.code === "rate_limited")
|
|
74
69
|
await this.#pacer?.holdFor(wait);
|
|
75
70
|
await this.#wait(wait, method);
|
|
@@ -131,7 +126,7 @@ export class BitrixTransport {
|
|
|
131
126
|
});
|
|
132
127
|
}
|
|
133
128
|
catch (error) {
|
|
134
|
-
const failure = this.#unanswered(method, error, run
|
|
129
|
+
const failure = this.#unanswered(method, error, run);
|
|
135
130
|
end({ errorCode: failure.code });
|
|
136
131
|
throw failure;
|
|
137
132
|
}
|
|
@@ -141,7 +136,7 @@ export class BitrixTransport {
|
|
|
141
136
|
}
|
|
142
137
|
catch (error) {
|
|
143
138
|
if (signal.aborted) {
|
|
144
|
-
const failure = this.#unanswered(method, error, run
|
|
139
|
+
const failure = this.#unanswered(method, error, run);
|
|
145
140
|
end({ status: response.status, errorCode: failure.code });
|
|
146
141
|
throw failure;
|
|
147
142
|
}
|
|
@@ -177,11 +172,12 @@ export class BitrixTransport {
|
|
|
177
172
|
clearTimeout(timer);
|
|
178
173
|
}
|
|
179
174
|
}
|
|
180
|
-
#unanswered(method, error,
|
|
175
|
+
#unanswered(method, error, run) {
|
|
181
176
|
if (this.#signal?.aborted && this.#signal.reason?.name !== "TimeoutError")
|
|
182
177
|
return new CliError("cancelled", `${method} was cancelled`, { operation: method });
|
|
183
|
-
|
|
184
|
-
|
|
178
|
+
// A keyed write's caller names how to repeat it; a REST 2 write has no key to repeat it safely with.
|
|
179
|
+
if (!run.reads)
|
|
180
|
+
return new CliError("outcome_unknown", `${method} got no answer; Bitrix24 may or may not have carried it out${run.key ? "" : " — check before repeating it"}`, { operation: method, retryable: false });
|
|
185
181
|
const timedOut = error?.name === "TimeoutError";
|
|
186
182
|
return new CliError(timedOut ? "timeout" : "network_error", timedOut ? `${method} got no answer within ${this.#timeoutMs} ms` : `${method} could not reach Bitrix24`, { operation: method, retryable: true });
|
|
187
183
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"transport.js","sourceRoot":"","sources":["../../src/bitrix/transport.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,SAAS,EACT,QAAQ,EACR,UAAU,EAEV,SAAS,EAET,SAAS,GACV,MAAM,mBAAmB,CAAA;AAC1B,OAAO,EAAE,cAAc,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAA;AACzE,OAAO,EAAE,OAAO,EAAE,cAAc,EAAkB,aAAa,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAA;AAE/G,OAAO,EAAsB,WAAW,EAAE,MAAM,aAAa,CAAA;AAC7D,OAAO,EAAE,QAAQ,EAAoB,MAAM,cAAc,CAAA;AACzD,OAAO,EAAE,SAAS,EAAgB,MAAM,cAAc,CAAA;AAEtD,MAAM,kBAAkB,GAAG,MAAM,CAAA;AACjC,MAAM,cAAc,GAAG,EAAE,GAAG,IAAI,GAAG,IAAI,CAAA;AACvC,MAAM,KAAK,GAAgB,EAAE,OAAO,EAAE,CAAC,EAAE,WAAW,EAAE,KAAK,EAAE,UAAU,EAAE,MAAM,EAAE,eAAe,EAAE,MAAM,EAAE,CAAA;AAC1G,+GAA+G;AAC/G,MAAM,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C,CAAC,SAAS,CAAC,CAAC,CAAC,eAAe,EACtC,QAAQ,CAAC,CAAC,CAAC,GAAG,MAAM,yBAAyB,IAAI,CAAC,UAAU,KAAK,CAAC,CAAC,CAAC,GAAG,MAAM,2BAA2B,EACxG,EAAE,SAAS,EAAE,MAAM,EAAE,SAAS,EAAE,IAAI,EAAE,CACvC,CAAA;IACH,CAAC;CACF"}
|
|
@@ -6,13 +6,13 @@ import {
|
|
|
6
6
|
serveAllProfilesOverHttp,
|
|
7
7
|
serveAllProfilesOverStdio,
|
|
8
8
|
withProfile
|
|
9
|
-
} from "./chunk-
|
|
10
|
-
import "./chunk-
|
|
11
|
-
import "./chunk-
|
|
12
|
-
import "./chunk-
|
|
9
|
+
} from "./chunk-JAS3OZSP.js";
|
|
10
|
+
import "./chunk-XKQZLR2X.js";
|
|
11
|
+
import "./chunk-IF27EQN6.js";
|
|
12
|
+
import "./chunk-6ERX33NC.js";
|
|
13
13
|
import "./chunk-5D4AEUVA.js";
|
|
14
|
-
import "./chunk-
|
|
15
|
-
import "./chunk-
|
|
14
|
+
import "./chunk-AMVRNYD6.js";
|
|
15
|
+
import "./chunk-SBW2Y7AZ.js";
|
|
16
16
|
import "./chunk-Y5E2WNWB.js";
|
|
17
17
|
import "./chunk-ZVVMGPBJ.js";
|
|
18
18
|
export {
|
|
@@ -2,11 +2,11 @@ import { createRequire as __bundleRequire } from "node:module";
|
|
|
2
2
|
const require = __bundleRequire(import.meta.url);
|
|
3
3
|
import {
|
|
4
4
|
checkedOptions
|
|
5
|
-
} from "./chunk-
|
|
5
|
+
} from "./chunk-AOUNT22U.js";
|
|
6
6
|
import {
|
|
7
7
|
messagesFor,
|
|
8
8
|
systemFor
|
|
9
|
-
} from "./chunk-
|
|
9
|
+
} from "./chunk-M5XMAUGZ.js";
|
|
10
10
|
import {
|
|
11
11
|
Anthropic
|
|
12
12
|
} from "./chunk-ADLS6FVG.js";
|
|
@@ -15,13 +15,13 @@ import {
|
|
|
15
15
|
optional,
|
|
16
16
|
strictObject,
|
|
17
17
|
string
|
|
18
|
-
} from "./chunk-
|
|
18
|
+
} from "./chunk-SBW2Y7AZ.js";
|
|
19
19
|
import "./chunk-Y5E2WNWB.js";
|
|
20
20
|
import {
|
|
21
21
|
__name
|
|
22
22
|
} from "./chunk-ZVVMGPBJ.js";
|
|
23
23
|
|
|
24
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
24
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.590.0_@wirecat+cli-base@0.80.1_commander@15.0.0_esbuild@0.28.2_type_4c7167080feb2ba6356a64767981f5fd/node_modules/@wirecat/cli-core/dist/models/anthropic.js
|
|
25
25
|
var options = strictObject({
|
|
26
26
|
stop_sequences: optional(array(string()))
|
|
27
27
|
});
|