@wirecat/bitrix24-cli 0.1.0 → 0.3.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 +18 -0
- package/dist/bin/b24.js +2 -2
- package/dist/bundle/b24.js +2 -2
- package/dist/bundle/{chunk-CZ23EVP4.js → chunk-W5YAO5G5.js} +1 -1
- package/dist/bundle/{dist-PII6Z6X3.js → dist-6Y64DTOE.js} +1 -1
- package/dist/bundle/{mcp-WALJM6QX.js → mcp-5RSWNTHS.js} +1 -1
- package/dist/bundle/{program-GO3RVP2H.js → program-H3TGGRQ6.js} +69 -51
- package/dist/commands/api.d.ts.map +1 -1
- package/dist/commands/api.js +3 -2
- package/dist/commands/api.js.map +1 -1
- package/dist/commands/crm.d.ts.map +1 -1
- package/dist/commands/crm.js +5 -3
- package/dist/commands/crm.js.map +1 -1
- package/dist/commands/session.js +4 -4
- package/dist/commands/session.js.map +1 -1
- package/dist/commands/write.d.ts.map +1 -1
- package/dist/commands/write.js +5 -5
- package/dist/commands/write.js.map +1 -1
- package/dist/crm/deal.d.ts +7 -4
- package/dist/crm/deal.d.ts.map +1 -1
- package/dist/crm/deal.js +6 -8
- package/dist/crm/deal.js.map +1 -1
- package/dist/crm/items.d.ts +2 -2
- package/dist/crm/items.d.ts.map +1 -1
- package/dist/crm/items.js +22 -3
- package/dist/crm/items.js.map +1 -1
- package/dist/crm/lead.d.ts +6 -3
- package/dist/crm/lead.d.ts.map +1 -1
- package/dist/crm/lead.js +4 -5
- package/dist/crm/lead.js.map +1 -1
- package/dist/crm/organization.d.ts +6 -3
- package/dist/crm/organization.d.ts.map +1 -1
- package/dist/crm/organization.js +5 -6
- package/dist/crm/organization.js.map +1 -1
- package/dist/crm/person.d.ts +6 -3
- package/dist/crm/person.d.ts.map +1 -1
- package/dist/crm/person.js +4 -5
- package/dist/crm/person.js.map +1 -1
- package/dist/crm/values.d.ts +10 -2
- package/dist/crm/values.d.ts.map +1 -1
- package/dist/crm/values.js +8 -3
- package/dist/crm/values.js.map +1 -1
- package/dist/portal.d.ts +20 -6
- package/dist/portal.d.ts.map +1 -1
- package/dist/portal.js +16 -10
- package/dist/portal.js.map +1 -1
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,24 @@
|
|
|
2
2
|
|
|
3
3
|
Notable changes to `@wirecat/bitrix24-cli`. One section per version, newest first.
|
|
4
4
|
|
|
5
|
+
## 0.3.0 — 06.11.2026
|
|
6
|
+
|
|
7
|
+
### Changed — may break callers
|
|
8
|
+
|
|
9
|
+
- `show` for deals, leads, people and organizations gives each custom field its title on the portal:
|
|
10
|
+
`provider_metadata` maps the field's code to `{ "label", "value" }`. `label` is `null` when the portal has no title
|
|
11
|
+
for it or does not answer the request for titles; `show` still answers then.
|
|
12
|
+
|
|
13
|
+
## 0.2.0 — 06.11.2026
|
|
14
|
+
|
|
15
|
+
### Fixed
|
|
16
|
+
|
|
17
|
+
- Commands that call the portal now run inside cli-core's run: each answer's `meta.run_id` names a run `runs show`
|
|
18
|
+
finds, with the portal requests in it, `meta.duration_ms` measures the command, and `--timeout` stops a stuck
|
|
19
|
+
command. An MCP agent's permission overrides now reach these commands too.
|
|
20
|
+
- `show` for deals, leads, people and organizations no longer lists the portal's custom fields that hold no value:
|
|
21
|
+
`provider_metadata` leaves out `null`, `""` and `[]`, and is left out when nothing is left.
|
|
22
|
+
|
|
5
23
|
## 0.1.0 — 06.11.2026
|
|
6
24
|
|
|
7
25
|
### Fixed
|
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.3.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-QJ444GSX.js","../bundle/anthropic-RHRAVHC2.js","../bundle/app-server-QIT6S7AZ.js","../bundle/bun-H6RSODZ3.js","../bundle/bun-sqlite-BO4LTQHX.js","../bundle/decode-5ZPLTYV6.js","../bundle/dist-
|
|
31
|
+
const chunks = ["../bundle/all-profiles-QJ444GSX.js","../bundle/anthropic-RHRAVHC2.js","../bundle/app-server-QIT6S7AZ.js","../bundle/bun-H6RSODZ3.js","../bundle/bun-sqlite-BO4LTQHX.js","../bundle/decode-5ZPLTYV6.js","../bundle/dist-6Y64DTOE.js","../bundle/echarts-J6LAPIX7.js","../bundle/embed-YG5LDHME.js","../bundle/embedder-7FNUA5OZ.js","../bundle/first-screen-VQM4MTS7.js","../bundle/instructions-AXWTQHMR.js","../bundle/mcp-5RSWNTHS.js","../bundle/mcp-7F46P6AM.js","../bundle/mcp-J5R5A65I.js","../bundle/node-CWKAIOEM.js","../bundle/node-P4E63KXA.js","../bundle/node-TLZSIHIJ.js","../bundle/node-sqlite-LSEKVRDA.js","../bundle/oauth-THYNLRLD.js","../bundle/open-E47QYKFC.js","../bundle/openai-EWSGC3BC.js","../bundle/process-WKTEA3WE.js","../bundle/program-H3TGGRQ6.js","../bundle/prompt-CAQ7QR3U.js","../bundle/recognize-6KGHNZC3.js","../bundle/remote-3UO2WDC3.js","../bundle/rerank-2JVDPZBX.js","../bundle/serve-ES7AG5IK.js","../bundle/server-5LE5LNUQ.js","../bundle/server-BU4VBM6S.js","../bundle/state-7NH5G4XJ.js","../bundle/store-7O4JQD2Z.js","../bundle/store-maintenance-command-UDVGEY2D.js"]
|
|
32
32
|
if (((words) => words
|
|
33
33
|
.filter((word) => !word.startsWith("-"))
|
|
34
34
|
.slice(0, 2)
|
package/dist/bundle/b24.js
CHANGED
|
@@ -3,7 +3,7 @@ import { createRequire as __bundleRequire } from "node:module";
|
|
|
3
3
|
const require = __bundleRequire(import.meta.url);
|
|
4
4
|
import {
|
|
5
5
|
IDENTITY
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-W5YAO5G5.js";
|
|
7
7
|
import "./chunk-QSNROIJL.js";
|
|
8
8
|
import "./chunk-PH5FZX6E.js";
|
|
9
9
|
import "./chunk-BCF7P4FZ.js";
|
|
@@ -24,7 +24,7 @@ import "./chunk-ZVVMGPBJ.js";
|
|
|
24
24
|
import { enableCompileCache } from "node:module";
|
|
25
25
|
enableCompileCache();
|
|
26
26
|
var stopCatching = catchCrashes({ cli: IDENTITY.command, interactive: process.stdout.isTTY === true });
|
|
27
|
-
var { run } = await import("./program-
|
|
27
|
+
var { run } = await import("./program-H3TGGRQ6.js");
|
|
28
28
|
try {
|
|
29
29
|
process.exitCode = await run(process.argv.slice(2));
|
|
30
30
|
} finally {
|
|
@@ -1665,7 +1665,7 @@ var REASONS2 = defineReasons(ENTRIES.map(([reason, code, message]) => ({ reason,
|
|
|
1665
1665
|
var DETAILS2 = ["fields"];
|
|
1666
1666
|
|
|
1667
1667
|
// dist/version.js
|
|
1668
|
-
var VERSION = "0.
|
|
1668
|
+
var VERSION = "0.3.0";
|
|
1669
1669
|
|
|
1670
1670
|
// dist/identity.js
|
|
1671
1671
|
var PACKAGE = "@wirecat/bitrix24-cli";
|
|
@@ -7509,7 +7509,7 @@ var require_dist = __commonJS({
|
|
|
7509
7509
|
}
|
|
7510
7510
|
});
|
|
7511
7511
|
|
|
7512
|
-
// common-js-names:/home/
|
|
7512
|
+
// common-js-names:/home/runner/work/bitrix24-cli/bitrix24-cli/node_modules/.pnpm/yaml@2.9.1/node_modules/yaml/dist/index.js
|
|
7513
7513
|
var cjs = require_dist();
|
|
7514
7514
|
var n0 = cjs["Alias"];
|
|
7515
7515
|
var n1 = cjs["CST"];
|
|
@@ -564,7 +564,7 @@ import {
|
|
|
564
564
|
IDENTITY,
|
|
565
565
|
PACKAGE,
|
|
566
566
|
SKILL
|
|
567
|
-
} from "./chunk-
|
|
567
|
+
} from "./chunk-W5YAO5G5.js";
|
|
568
568
|
import {
|
|
569
569
|
INPUT_FIELD_REASONS,
|
|
570
570
|
failureContext
|
|
@@ -7371,7 +7371,7 @@ var parseScenario = /* @__PURE__ */ __name(async (file, content) => {
|
|
|
7371
7371
|
const match = FRONT_MATTER.exec(content);
|
|
7372
7372
|
if (!match)
|
|
7373
7373
|
return { problems: [at2("needs front matter between --- lines")] };
|
|
7374
|
-
const { parseDocument } = await import("./dist-
|
|
7374
|
+
const { parseDocument } = await import("./dist-6Y64DTOE.js");
|
|
7375
7375
|
const yaml = parseDocument(match[1] ?? "", { uniqueKeys: true });
|
|
7376
7376
|
if (yaml.errors.length > 0)
|
|
7377
7377
|
return { problems: [at2("front matter is not valid YAML")] };
|
|
@@ -12407,13 +12407,13 @@ var exportCommand = /* @__PURE__ */ __name((messenger) => destroysNothing(annota
|
|
|
12407
12407
|
const title2 = password2 === void 0 ? named2 : null;
|
|
12408
12408
|
const before = manifest.chats[id4];
|
|
12409
12409
|
const changes = await services.archive.changes(id4, before?.mark);
|
|
12410
|
-
const
|
|
12410
|
+
const empty2 = changes.messages.length === 0 && changes.deleted.length === 0;
|
|
12411
12411
|
let file = null;
|
|
12412
12412
|
if (password2 !== void 0) {
|
|
12413
12413
|
yield* linesOf(id4, changes, account2);
|
|
12414
|
-
if (!
|
|
12414
|
+
if (!empty2)
|
|
12415
12415
|
file = run3;
|
|
12416
|
-
} else if (before === void 0 || !
|
|
12416
|
+
} else if (before === void 0 || !empty2)
|
|
12417
12417
|
file = writeChanges(dir, id4, changes.mark, changes, account2);
|
|
12418
12418
|
manifest.chats[id4] = {
|
|
12419
12419
|
title: title2,
|
|
@@ -19485,11 +19485,14 @@ var tokens = /* @__PURE__ */ __name((env, keyring) => {
|
|
|
19485
19485
|
// dist/portal.js
|
|
19486
19486
|
var PORTAL_PACE = { perMinute: 120, burst: 50 };
|
|
19487
19487
|
var contextOf = /* @__PURE__ */ __name((command) => {
|
|
19488
|
-
const
|
|
19489
|
-
|
|
19490
|
-
|
|
19491
|
-
|
|
19492
|
-
|
|
19488
|
+
const base = baseContext(command, configuration.resolveSettings);
|
|
19489
|
+
return {
|
|
19490
|
+
...base,
|
|
19491
|
+
environment: environmentOf(command),
|
|
19492
|
+
flags: command.optsWithGlobals(),
|
|
19493
|
+
profile: base.settings.profile,
|
|
19494
|
+
tokens: tokens(base.env, base.keyring)
|
|
19495
|
+
};
|
|
19493
19496
|
}, "contextOf");
|
|
19494
19497
|
var signInWords = /* @__PURE__ */ __name((profile) => `\`${IDENTITY.command} ${profile} session start\``, "signInWords");
|
|
19495
19498
|
var refuseOffline = /* @__PURE__ */ __name((flags) => {
|
|
@@ -19498,17 +19501,18 @@ var refuseOffline = /* @__PURE__ */ __name((flags) => {
|
|
|
19498
19501
|
reason: "offline.refused"
|
|
19499
19502
|
});
|
|
19500
19503
|
}, "refuseOffline");
|
|
19501
|
-
var transportFor = /* @__PURE__ */ __name((command, webhook) => {
|
|
19504
|
+
var transportFor = /* @__PURE__ */ __name((command, webhook, events) => {
|
|
19502
19505
|
const { environment, env, profile } = contextOf(command);
|
|
19503
19506
|
return new BitrixTransport({
|
|
19504
19507
|
webhook,
|
|
19508
|
+
...events ? { events } : {},
|
|
19505
19509
|
...environment.fetch ? { fetch: environment.fetch } : {},
|
|
19506
19510
|
...environment.signal ? { signal: environment.signal } : {},
|
|
19507
19511
|
...environment.sleep ? { sleep: environment.sleep } : {},
|
|
19508
19512
|
pacer: new Pacer(pacePathFor(IDENTITY, profile, env), PORTAL_PACE)
|
|
19509
19513
|
});
|
|
19510
19514
|
}, "transportFor");
|
|
19511
|
-
var
|
|
19515
|
+
var webhookOf = /* @__PURE__ */ __name((command) => {
|
|
19512
19516
|
const { flags, profile, tokens: tokens2 } = contextOf(command);
|
|
19513
19517
|
refuseOffline(flags);
|
|
19514
19518
|
const stored2 = tokens2.read(profile);
|
|
@@ -19516,8 +19520,9 @@ var portalOf = /* @__PURE__ */ __name((command) => {
|
|
|
19516
19520
|
throw new CliError("authentication_error", `profile ${profile} is not signed in \u2014 run ${signInWords(profile)}`, {
|
|
19517
19521
|
reason: "webhook.missing"
|
|
19518
19522
|
});
|
|
19519
|
-
return
|
|
19520
|
-
}, "
|
|
19523
|
+
return parseWebhook(stored2.secret);
|
|
19524
|
+
}, "webhookOf");
|
|
19525
|
+
var withPortal = /* @__PURE__ */ __name((command, body) => contextOf(command).run((events) => body(transportFor(command, webhookOf(command), events))), "withPortal");
|
|
19521
19526
|
|
|
19522
19527
|
// dist/commands/write.js
|
|
19523
19528
|
var OPERATION_ID = /^[\x21-\x7e]{1,255}$/;
|
|
@@ -19529,13 +19534,13 @@ var operationIdOf = /* @__PURE__ */ __name((given2) => {
|
|
|
19529
19534
|
return given2 ?? newOperationId();
|
|
19530
19535
|
}, "operationIdOf");
|
|
19531
19536
|
var write = /* @__PURE__ */ __name(async (command, { key, assignee, extra: also = [], keyed = true, operationId: given2, act }) => {
|
|
19532
|
-
const { env, settings } = contextOf(command);
|
|
19537
|
+
const { env, settings, run: run3 } = contextOf(command);
|
|
19533
19538
|
const lock = readOnlyLockOf(IDENTITY, env);
|
|
19534
19539
|
if (lock)
|
|
19535
19540
|
throw readOnlyRefusal(lock, "change the Bitrix24 portal");
|
|
19536
19541
|
const operationId = operationIdOf(given2);
|
|
19537
|
-
const
|
|
19538
|
-
const self =
|
|
19542
|
+
const webhook = webhookOf(command);
|
|
19543
|
+
const self = webhook.userId;
|
|
19539
19544
|
const extra = [...also, ...assignee !== void 0 && assignee !== self ? [ASSIGN_KEY] : []];
|
|
19540
19545
|
const levelOf = /* @__PURE__ */ __name((one) => levelFor(settings.permissions, one, permissions.defaults).level, "levelOf");
|
|
19541
19546
|
const guard = keyedGuard((ask) => guardFor(
|
|
@@ -19550,7 +19555,7 @@ var write = /* @__PURE__ */ __name(async (command, { key, assignee, extra: also
|
|
|
19550
19555
|
guard.refuse(request);
|
|
19551
19556
|
let done;
|
|
19552
19557
|
try {
|
|
19553
|
-
done = await guardedWrite(guard, request, () => act(
|
|
19558
|
+
done = await guardedWrite(guard, request, () => run3((events) => act(transportFor(command, webhook, events), operationId)));
|
|
19554
19559
|
} catch (error) {
|
|
19555
19560
|
if (keyed && error instanceof CliError && error.code === "outcome_unknown")
|
|
19556
19561
|
throw new CliError("outcome_unknown", `${error.message} \u2014 repeat it with --operation-id ${operationId}: Bitrix24 answers a repeat from its record instead of running it again`, { ...error.details, operation_id: operationId });
|
|
@@ -19631,11 +19636,11 @@ var callCommand = /* @__PURE__ */ __name(() => annotate(new Command("call"), {
|
|
|
19631
19636
|
const method = methodOf(methodName(raw));
|
|
19632
19637
|
const body = bodyOf(options.body);
|
|
19633
19638
|
const key = apiKey(method.name);
|
|
19634
|
-
const shown4 = /* @__PURE__ */ __name((
|
|
19639
|
+
const shown4 = /* @__PURE__ */ __name((answer4) => ({
|
|
19635
19640
|
method: method.name,
|
|
19636
|
-
result:
|
|
19637
|
-
...
|
|
19638
|
-
...
|
|
19641
|
+
result: answer4.result,
|
|
19642
|
+
...answer4.total === void 0 ? {} : { total: answer4.total },
|
|
19643
|
+
...answer4.next === void 0 ? {} : { next: answer4.next },
|
|
19639
19644
|
untrusted: UNTRUSTED2
|
|
19640
19645
|
}), "shown");
|
|
19641
19646
|
if (method.effect !== "read") {
|
|
@@ -19655,7 +19660,8 @@ var callCommand = /* @__PURE__ */ __name(() => annotate(new Command("call"), {
|
|
|
19655
19660
|
throw new CliError("permission_error", `profile ${settings.profile} denies ${key} (permissions.${named2} is deny)`, {
|
|
19656
19661
|
permission: key
|
|
19657
19662
|
});
|
|
19658
|
-
|
|
19663
|
+
const answer3 = await withPortal(this, (portal) => portal.call(method.name, body));
|
|
19664
|
+
renderAnswer(this, outputFor(this), itemOf(shown4(answer3)));
|
|
19659
19665
|
}), "callCommand");
|
|
19660
19666
|
var apiCommand = /* @__PURE__ */ __name(() => annotate(new Command("api"), { effects: LOCAL_READ }).description("see and call the Bitrix24 REST methods directly").addCommand(listCommand4()).addCommand(showCommand3()).addCommand(callCommand()), "apiCommand");
|
|
19661
19667
|
|
|
@@ -19694,10 +19700,11 @@ var contacts = /* @__PURE__ */ __name((value2) => Array.isArray(value2) ? value2
|
|
|
19694
19700
|
return found === null ? [] : [{ type: text2(one?.valueTypeId)?.toLowerCase() ?? null, value: found }];
|
|
19695
19701
|
}) : [], "contacts");
|
|
19696
19702
|
var CUSTOM = /^(UF_CRM_|ufCrm)/;
|
|
19697
|
-
var
|
|
19703
|
+
var empty = /* @__PURE__ */ __name((value2) => value2 === null || value2 === "" || Array.isArray(value2) && value2.length === 0, "empty");
|
|
19704
|
+
var customFields = /* @__PURE__ */ __name((raw) => Object.fromEntries(Object.entries(raw ?? {}).filter(([key, value2]) => CUSTOM.test(key) && !key.endsWith("_data") && !empty(value2))), "customFields");
|
|
19698
19705
|
var contactSchema = strictObject({ type: nullable(string()), value: string() });
|
|
19699
19706
|
var nullableTime = nullable(isoTime);
|
|
19700
|
-
var metadataSchema = optional(record(string(), unknown()));
|
|
19707
|
+
var metadataSchema = optional(record(string(), strictObject({ label: nullable(string()), value: unknown() })));
|
|
19701
19708
|
|
|
19702
19709
|
// dist/crm/conditions.js
|
|
19703
19710
|
var bare = /* @__PURE__ */ __name((value2) => value2.replace(/^\*+|\*+$/g, ""), "bare");
|
|
@@ -19798,7 +19805,7 @@ var DEAL_FIELDS = {
|
|
|
19798
19805
|
created_at: { field: "createdTime", kind: "time" },
|
|
19799
19806
|
updated_at: { field: "updatedTime", kind: "time" }
|
|
19800
19807
|
};
|
|
19801
|
-
var fromBitrixDeal = /* @__PURE__ */ __name((raw,
|
|
19808
|
+
var fromBitrixDeal = /* @__PURE__ */ __name((raw, metadata) => ({
|
|
19802
19809
|
id: id3(raw.id) ?? "",
|
|
19803
19810
|
title: text2(raw.title),
|
|
19804
19811
|
pipeline_id: text2(raw.categoryId),
|
|
@@ -19808,12 +19815,12 @@ var fromBitrixDeal = /* @__PURE__ */ __name((raw, custom) => ({
|
|
|
19808
19815
|
currency: text2(raw.currencyId),
|
|
19809
19816
|
assigned_to: id3(raw.assignedById),
|
|
19810
19817
|
organization_id: id3(raw.companyId),
|
|
19811
|
-
person_ids: ids(raw.contactsId
|
|
19812
|
-
closes_on: text2(raw.closeTime
|
|
19818
|
+
person_ids: ids(raw.contactsId),
|
|
19819
|
+
closes_on: text2(raw.closeTime)?.slice(0, 10) ?? null,
|
|
19813
19820
|
created_at: time(raw.createdTime),
|
|
19814
19821
|
updated_at: time(raw.updatedTime),
|
|
19815
19822
|
url: text2(raw.url),
|
|
19816
|
-
...
|
|
19823
|
+
...metadata ? { provider_metadata: metadata } : {}
|
|
19817
19824
|
}), "fromBitrixDeal");
|
|
19818
19825
|
var DEAL = {
|
|
19819
19826
|
type: "deal",
|
|
@@ -19830,9 +19837,7 @@ var DEAL = {
|
|
|
19830
19837
|
"assignedById",
|
|
19831
19838
|
"companyId",
|
|
19832
19839
|
"contactsId",
|
|
19833
|
-
"contactIds",
|
|
19834
19840
|
"closeTime",
|
|
19835
|
-
"closedate",
|
|
19836
19841
|
"createdTime",
|
|
19837
19842
|
"updatedTime",
|
|
19838
19843
|
"url"
|
|
@@ -19900,8 +19905,22 @@ var getItem = /* @__PURE__ */ __name(async (portal, type, id4) => {
|
|
|
19900
19905
|
id: Number(id4),
|
|
19901
19906
|
useOriginalUfNames: "Y"
|
|
19902
19907
|
});
|
|
19903
|
-
|
|
19908
|
+
const custom = customFields(full.result?.item);
|
|
19909
|
+
if (!Object.keys(custom).length)
|
|
19910
|
+
return type.map(item);
|
|
19911
|
+
const labels = await labelsOf(portal, type.type);
|
|
19912
|
+
return type.map(item, Object.fromEntries(Object.entries(custom).map(([code, value2]) => [code, { label: labels.get(code) ?? null, value: value2 }])));
|
|
19904
19913
|
}, "getItem");
|
|
19914
|
+
var labelsOf = /* @__PURE__ */ __name(async (portal, type) => {
|
|
19915
|
+
try {
|
|
19916
|
+
const answer3 = await portal.call(`crm.${type}.field.list`, { select: ["name", "title"] });
|
|
19917
|
+
return new Map(itemsOf(answer3.result).map((field) => [String(field.name), text2(field.title)]));
|
|
19918
|
+
} catch (error) {
|
|
19919
|
+
if (isCliError(error) && error.code === "cancelled")
|
|
19920
|
+
throw error;
|
|
19921
|
+
return /* @__PURE__ */ new Map();
|
|
19922
|
+
}
|
|
19923
|
+
}, "labelsOf");
|
|
19905
19924
|
var folded = /* @__PURE__ */ __name((value2) => value2?.trim().toLocaleLowerCase() ?? "", "folded");
|
|
19906
19925
|
var resolveItem = /* @__PURE__ */ __name(async (portal, type, reference) => {
|
|
19907
19926
|
if (/^[1-9]\d*$/.test(reference))
|
|
@@ -19959,7 +19978,7 @@ var LEAD_FIELDS = {
|
|
|
19959
19978
|
created_at: { field: "createdTime", kind: "time" },
|
|
19960
19979
|
updated_at: { field: "updatedTime", kind: "time" }
|
|
19961
19980
|
};
|
|
19962
|
-
var fromBitrixLead = /* @__PURE__ */ __name((raw,
|
|
19981
|
+
var fromBitrixLead = /* @__PURE__ */ __name((raw, metadata) => ({
|
|
19963
19982
|
id: id3(raw.id) ?? "",
|
|
19964
19983
|
title: text2(raw.title),
|
|
19965
19984
|
name: fullName(raw.name, raw.secondName, raw.lastName),
|
|
@@ -19970,14 +19989,14 @@ var fromBitrixLead = /* @__PURE__ */ __name((raw, custom) => ({
|
|
|
19970
19989
|
currency: text2(raw.currencyId),
|
|
19971
19990
|
assigned_to: id3(raw.assignedById),
|
|
19972
19991
|
organization_id: id3(raw.companyId),
|
|
19973
|
-
person_ids: ids(raw.contactsId
|
|
19992
|
+
person_ids: ids(raw.contactsId),
|
|
19974
19993
|
...Array.isArray(raw.phone) ? { phones: contacts(raw.phone) } : {},
|
|
19975
19994
|
...Array.isArray(raw.email) ? { emails: contacts(raw.email) } : {},
|
|
19976
19995
|
source_id: text2(raw.sourceId),
|
|
19977
19996
|
created_at: time(raw.createdTime),
|
|
19978
19997
|
updated_at: time(raw.updatedTime),
|
|
19979
19998
|
url: text2(raw.url),
|
|
19980
|
-
...
|
|
19999
|
+
...metadata ? { provider_metadata: metadata } : {}
|
|
19981
20000
|
}), "fromBitrixLead");
|
|
19982
20001
|
var LEAD = {
|
|
19983
20002
|
type: "lead",
|
|
@@ -19997,7 +20016,6 @@ var LEAD = {
|
|
|
19997
20016
|
"assignedById",
|
|
19998
20017
|
"companyId",
|
|
19999
20018
|
"contactsId",
|
|
20000
|
-
"contactIds",
|
|
20001
20019
|
"phone",
|
|
20002
20020
|
"email",
|
|
20003
20021
|
"sourceId",
|
|
@@ -20035,21 +20053,21 @@ var ORGANIZATION_FIELDS = {
|
|
|
20035
20053
|
created_at: { field: "createdTime", kind: "time" },
|
|
20036
20054
|
updated_at: { field: "updatedTime", kind: "time" }
|
|
20037
20055
|
};
|
|
20038
|
-
var fromBitrixOrganization = /* @__PURE__ */ __name((raw,
|
|
20056
|
+
var fromBitrixOrganization = /* @__PURE__ */ __name((raw, metadata) => ({
|
|
20039
20057
|
id: id3(raw.id) ?? "",
|
|
20040
20058
|
name: text2(raw.title),
|
|
20041
20059
|
type_id: text2(raw.typeId),
|
|
20042
|
-
industry_id: text2(raw.industryId
|
|
20060
|
+
industry_id: text2(raw.industryId),
|
|
20043
20061
|
revenue: number2(raw.revenue),
|
|
20044
20062
|
currency: text2(raw.currencyId),
|
|
20045
|
-
person_ids: ids(raw.contactsId
|
|
20063
|
+
person_ids: ids(raw.contactsId),
|
|
20046
20064
|
...Array.isArray(raw.phone) ? { phones: contacts(raw.phone) } : {},
|
|
20047
20065
|
...Array.isArray(raw.email) ? { emails: contacts(raw.email) } : {},
|
|
20048
20066
|
assigned_to: id3(raw.assignedById),
|
|
20049
20067
|
created_at: time(raw.createdTime),
|
|
20050
20068
|
updated_at: time(raw.updatedTime),
|
|
20051
20069
|
url: text2(raw.url),
|
|
20052
|
-
...
|
|
20070
|
+
...metadata ? { provider_metadata: metadata } : {}
|
|
20053
20071
|
}), "fromBitrixOrganization");
|
|
20054
20072
|
var ORGANIZATION = {
|
|
20055
20073
|
type: "company",
|
|
@@ -20063,7 +20081,6 @@ var ORGANIZATION = {
|
|
|
20063
20081
|
"revenue",
|
|
20064
20082
|
"currencyId",
|
|
20065
20083
|
"contactsId",
|
|
20066
|
-
"contactIds",
|
|
20067
20084
|
"phone",
|
|
20068
20085
|
"email",
|
|
20069
20086
|
"assignedById",
|
|
@@ -20098,8 +20115,8 @@ var PERSON_FIELDS = {
|
|
|
20098
20115
|
created_at: { field: "createdTime", kind: "time" },
|
|
20099
20116
|
updated_at: { field: "updatedTime", kind: "time" }
|
|
20100
20117
|
};
|
|
20101
|
-
var fromBitrixPerson = /* @__PURE__ */ __name((raw,
|
|
20102
|
-
const companies = ids(raw.companiesId
|
|
20118
|
+
var fromBitrixPerson = /* @__PURE__ */ __name((raw, metadata) => {
|
|
20119
|
+
const companies = ids(raw.companiesId);
|
|
20103
20120
|
const first2 = id3(raw.companyId);
|
|
20104
20121
|
return {
|
|
20105
20122
|
id: id3(raw.id) ?? "",
|
|
@@ -20114,7 +20131,7 @@ var fromBitrixPerson = /* @__PURE__ */ __name((raw, custom) => {
|
|
|
20114
20131
|
created_at: time(raw.createdTime),
|
|
20115
20132
|
updated_at: time(raw.updatedTime),
|
|
20116
20133
|
url: text2(raw.url),
|
|
20117
|
-
...
|
|
20134
|
+
...metadata ? { provider_metadata: metadata } : {}
|
|
20118
20135
|
};
|
|
20119
20136
|
}, "fromBitrixPerson");
|
|
20120
20137
|
var PERSON3 = {
|
|
@@ -20129,7 +20146,6 @@ var PERSON3 = {
|
|
|
20129
20146
|
"post",
|
|
20130
20147
|
"companyId",
|
|
20131
20148
|
"companiesId",
|
|
20132
|
-
"companyIds",
|
|
20133
20149
|
"phone",
|
|
20134
20150
|
"email",
|
|
20135
20151
|
"assignedById",
|
|
@@ -20344,7 +20360,8 @@ var listCommand5 = /* @__PURE__ */ __name((noun) => withPaging(withQuery(answerE
|
|
|
20344
20360
|
const path = commandPath(this);
|
|
20345
20361
|
const terms = nativeTerms(listQuery(typedQuery(words3), noun.query, path, noun.word ? { defaultField: noun.word } : {}), path);
|
|
20346
20362
|
const { settings } = contextOf(this);
|
|
20347
|
-
const
|
|
20363
|
+
const window2 = windowOf2(this);
|
|
20364
|
+
const found = await withPortal(this, (portal) => noun.list(portal, terms, window2));
|
|
20348
20365
|
renderAnswer(this, outputFor(this), pagedList(path, settings, found));
|
|
20349
20366
|
}), "listCommand");
|
|
20350
20367
|
var showCommand4 = /* @__PURE__ */ __name((noun) => answerEntity(annotate(new Command("show"), {
|
|
@@ -20352,7 +20369,8 @@ var showCommand4 = /* @__PURE__ */ __name((noun) => answerEntity(annotate(new Co
|
|
|
20352
20369
|
offline: false,
|
|
20353
20370
|
examples: [`${B242} work ${noun.noun} show 42`, `${B242} work ${noun.noun} show 42 --json`]
|
|
20354
20371
|
}), noun.entity, noun.schema).description(`show one of the ${noun.what} on the portal`).argument(`<${noun.reference}>`, `the ${noun.reference} as list prints it`).action(async function(reference) {
|
|
20355
|
-
|
|
20372
|
+
const item = await withPortal(this, (portal) => noun.show(portal, reference));
|
|
20373
|
+
renderAnswer(this, outputFor(this), itemOf(item));
|
|
20356
20374
|
}), "showCommand");
|
|
20357
20375
|
var nounCommand = /* @__PURE__ */ __name((noun, description) => annotate(new Command(noun.noun), { effects: REMOTE_READ }).description(description).addCommand(listCommand5(noun)).addCommand(showCommand4(noun)), "nounCommand");
|
|
20358
20376
|
var itemNoun = /* @__PURE__ */ __name((type, shape, examples, listExamples) => {
|
|
@@ -20687,7 +20705,7 @@ var serveCommand3 = /* @__PURE__ */ __name(() => annotate(new Command("serve"),
|
|
|
20687
20705
|
run: run3,
|
|
20688
20706
|
...environment.signal ? { signal: environment.signal } : {}
|
|
20689
20707
|
};
|
|
20690
|
-
const { serveMcp, serveMcpOverHttp } = await import("./mcp-
|
|
20708
|
+
const { serveMcp, serveMcpOverHttp } = await import("./mcp-5RSWNTHS.js");
|
|
20691
20709
|
if (!flags.http)
|
|
20692
20710
|
return serveMcp(options);
|
|
20693
20711
|
const { portOf: portOf2, publicUrlOf: publicUrlOf2 } = await import("./mcp-J5R5A65I.js");
|
|
@@ -20751,14 +20769,14 @@ var startCommand = /* @__PURE__ */ __name(() => logsInOrOut(annotate(new Command
|
|
|
20751
20769
|
const storage = args.credentialStorage;
|
|
20752
20770
|
if (storage !== "keyring" && storage !== "file")
|
|
20753
20771
|
throw new CliError("validation_error", "--credential-storage takes keyring or file");
|
|
20754
|
-
const { env, flags, profile, tokens: tokens2 } = contextOf(this);
|
|
20772
|
+
const { env, flags, profile, tokens: tokens2, run: run3 } = contextOf(this);
|
|
20755
20773
|
refuseCommandName(profile, commandWords(rootOf(this)), IDENTITY.command);
|
|
20756
20774
|
refuseOffline(flags);
|
|
20757
20775
|
const address = (await readSecret("Bitrix24 webhook address: ", secretInputOf(this))).trim();
|
|
20758
20776
|
if (!address)
|
|
20759
20777
|
throw new CliError("validation_error", "no webhook address was given");
|
|
20760
20778
|
const webhook = parseWebhook(address);
|
|
20761
|
-
const user = await webhookUser(transportFor(this, webhook));
|
|
20779
|
+
const user = await run3((events) => webhookUser(transportFor(this, webhook, events)));
|
|
20762
20780
|
const portal = new URL(webhook.origin).host;
|
|
20763
20781
|
const stored2 = tokens2.write(profile, address, storage);
|
|
20764
20782
|
rememberAccount(IDENTITY, profile, `${portal}:${webhook.userId}`, env);
|
|
@@ -20774,7 +20792,7 @@ var statusCommand3 = /* @__PURE__ */ __name(() => annotate(new Command("status")
|
|
|
20774
20792
|
const status = { profile, state: stored2 ? "saved" : "missing", token_from: stored2?.source ?? null, portal };
|
|
20775
20793
|
if (!args.check || !stored2)
|
|
20776
20794
|
return answer2(this, { ...status, verified: false });
|
|
20777
|
-
answer2(this, { ...status, verified: true, user: await
|
|
20795
|
+
answer2(this, { ...status, verified: true, user: await withPortal(this, webhookUser) });
|
|
20778
20796
|
}), "statusCommand");
|
|
20779
20797
|
var endCommand = /* @__PURE__ */ __name(() => logsInOrOut(annotate(new Command("end"), {
|
|
20780
20798
|
effects: LOCAL_WRITE,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"api.d.ts","sourceRoot":"","sources":["../../src/commands/api.ts"],"names":[],"mappings":"AAiBA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;
|
|
1
|
+
{"version":3,"file":"api.d.ts","sourceRoot":"","sources":["../../src/commands/api.ts"],"names":[],"mappings":"AAiBA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AAyJnC,eAAO,MAAM,UAAU,QAAO,OAKA,CAAA"}
|
package/dist/commands/api.js
CHANGED
|
@@ -8,7 +8,7 @@ import { apiDefault, apiKey, commandKeysOf } from "../api-keys.js";
|
|
|
8
8
|
import { KNOWN_METHODS, methodOf } from "../bitrix/methods.js";
|
|
9
9
|
import { permissions } from "../config.js";
|
|
10
10
|
import { IDENTITY } from "../identity.js";
|
|
11
|
-
import { contextOf,
|
|
11
|
+
import { contextOf, withPortal } from "../portal.js";
|
|
12
12
|
import { write } from "./write.js";
|
|
13
13
|
const B24 = IDENTITY.command;
|
|
14
14
|
const METHOD = /^[a-z][a-z0-9]*(\.[a-z0-9_]+)*$/i;
|
|
@@ -120,7 +120,8 @@ const callCommand = () => annotate(new Command("call"), {
|
|
|
120
120
|
throw new CliError("permission_error", `profile ${settings.profile} denies ${key} (permissions.${named} is deny)`, {
|
|
121
121
|
permission: key,
|
|
122
122
|
});
|
|
123
|
-
|
|
123
|
+
const answer = await withPortal(this, (portal) => portal.call(method.name, body));
|
|
124
|
+
renderAnswer(this, outputFor(this), itemOf(shown(answer)));
|
|
124
125
|
});
|
|
125
126
|
export const apiCommand = () => annotate(new Command("api"), { effects: LOCAL_READ })
|
|
126
127
|
.description("see and call the Bitrix24 REST methods directly")
|
package/dist/commands/api.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"api.js","sourceRoot":"","sources":["../../src/commands/api.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAA;AAC5C,OAAO,EAAE,QAAQ,EAAE,MAAM,4BAA4B,CAAA;AAErD,OAAO,EACL,YAAY,EACZ,MAAM,EACN,UAAU,EACV,MAAM,EACN,UAAU,EACV,SAAS,EACT,UAAU,EACV,YAAY,EACZ,YAAY,EACZ,SAAS,EACT,SAAS,GACV,MAAM,uBAAuB,CAAA;AAC9B,OAAO,EAAE,QAAQ,EAAE,MAAM,yBAAyB,CAAA;AAClD,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AACnC,OAAO,KAAK,CAAC,MAAM,SAAS,CAAA;AAC5B,OAAO,EAAE,UAAU,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAA;AAClE,OAAO,EAAE,aAAa,EAAe,QAAQ,EAAE,MAAM,sBAAsB,CAAA;AAC3E,OAAO,EAAE,WAAW,EAAE,MAAM,cAAc,CAAA;AAC1C,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAA;AACzC,OAAO,EAAE,SAAS,EAAE,
|
|
1
|
+
{"version":3,"file":"api.js","sourceRoot":"","sources":["../../src/commands/api.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAA;AAC5C,OAAO,EAAE,QAAQ,EAAE,MAAM,4BAA4B,CAAA;AAErD,OAAO,EACL,YAAY,EACZ,MAAM,EACN,UAAU,EACV,MAAM,EACN,UAAU,EACV,SAAS,EACT,UAAU,EACV,YAAY,EACZ,YAAY,EACZ,SAAS,EACT,SAAS,GACV,MAAM,uBAAuB,CAAA;AAC9B,OAAO,EAAE,QAAQ,EAAE,MAAM,yBAAyB,CAAA;AAClD,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AACnC,OAAO,KAAK,CAAC,MAAM,SAAS,CAAA;AAC5B,OAAO,EAAE,UAA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AQ,CAAC,QAAQ,CAAC,WAAW,EAAE,GAAG,EAAE,WAAW,CAAC,QAAQ,CAAC,CAAA;IACvF,IAAI,KAAK,KAAK,MAAM;QAClB,MAAM,IAAI,QAAQ,CAChB,kBAAkB,EAClB,WAAW,QAAQ,CAAC,OAAO,WAAW,GAAG,iBAAiB,KAAK,WAAW,EAC1E;YACE,UAAU,EAAE,GAAG;SAChB,CACF,CAAA;IACH,MAAM,MAAM,GAAG,MAAM,UAAU,CAAC,IAAI,EAAE,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC,CAAA;IACjF,YAAY,CAAC,IAAI,EAAE,SAAS,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,CAAA;AAC5D,CAAC,CAAC,CAAA;AAEN,MAAM,CAAC,MAAM,UAAU,GAAG,GAAY,EAAE,CACtC,QAAQ,CAAC,IAAI,OAAO,CAAC,KAAK,CAAC,EAAE,EAAE,OAAO,EAAE,UAAU,EAAE,CAAC;KAClD,WAAW,CAAC,iDAAiD,CAAC;KAC9D,UAAU,CAAC,WAAW,EAAE,CAAC;KACzB,UAAU,CAAC,WAAW,EAAE,CAAC;KACzB,UAAU,CAAC,WAAW,EAAE,CAAC,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"crm.d.ts","sourceRoot":"","sources":["../../src/commands/crm.ts"],"names":[],"mappings":"AAiBA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;
|
|
1
|
+
{"version":3,"file":"crm.d.ts","sourceRoot":"","sources":["../../src/commands/crm.ts"],"names":[],"mappings":"AAiBA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AAiJnC,eAAO,MAAM,WAAW,QAAO,OAAO,EAoGrC,CAAA"}
|
package/dist/commands/crm.js
CHANGED
|
@@ -13,7 +13,7 @@ import { getProduct, listProducts, PRODUCT_FIELDS, productSchema } from "../crm/
|
|
|
13
13
|
import { directoryOf, findStage, listStages, stageSchema } from "../crm/stage.js";
|
|
14
14
|
import { getUser, listUsers, USER_FIELDS, userSchema } from "../crm/user.js";
|
|
15
15
|
import { IDENTITY } from "../identity.js";
|
|
16
|
-
import { contextOf,
|
|
16
|
+
import { contextOf, withPortal } from "../portal.js";
|
|
17
17
|
const B24 = IDENTITY.command;
|
|
18
18
|
const nativeQuery = (entity, schema, fields, examples = {}) => defineQuery({
|
|
19
19
|
entity,
|
|
@@ -37,7 +37,8 @@ const listCommand = (noun) => withPaging(withQuery(answerEntity(annotate(new Com
|
|
|
37
37
|
const path = commandPath(this);
|
|
38
38
|
const terms = nativeTerms(listQuery(typedQuery(words), noun.query, path, noun.word ? { defaultField: noun.word } : {}), path);
|
|
39
39
|
const { settings } = contextOf(this);
|
|
40
|
-
const
|
|
40
|
+
const window = windowOf(this);
|
|
41
|
+
const found = await withPortal(this, (portal) => noun.list(portal, terms, window));
|
|
41
42
|
renderAnswer(this, outputFor(this), pagedList(path, settings, found));
|
|
42
43
|
});
|
|
43
44
|
const showCommand = (noun) => answerEntity(annotate(new Command("show"), {
|
|
@@ -48,7 +49,8 @@ const showCommand = (noun) => answerEntity(annotate(new Command("show"), {
|
|
|
48
49
|
.description(`show one of the ${noun.what} on the portal`)
|
|
49
50
|
.argument(`<${noun.reference}>`, `the ${noun.reference} as list prints it`)
|
|
50
51
|
.action(async function (reference) {
|
|
51
|
-
|
|
52
|
+
const item = await withPortal(this, (portal) => noun.show(portal, reference));
|
|
53
|
+
renderAnswer(this, outputFor(this), itemOf(item));
|
|
52
54
|
});
|
|
53
55
|
const nounCommand = (noun, description) => annotate(new Command(noun.noun), { effects: REMOTE_READ })
|
|
54
56
|
.description(description)
|
package/dist/commands/crm.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"crm.js","sourceRoot":"","sources":["../../src/commands/crm.ts"],"names":[],"mapp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,IAAI,EAAE,CAAC,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,EAAE,CAAC,SAAS,CAAC,MAAM,EAAE,YAAY,CAAC,KAAK,EAAE,WAAW,CAAC,EAAE,MAAM,CAAC;QAC5F,IAAI,EAAE,OAAO;KACd,EACD,6BAA6B,CAC9B;CACF,CAAA"}
|
package/dist/commands/session.js
CHANGED
|
@@ -6,7 +6,7 @@ import { Command } from "commander";
|
|
|
6
6
|
import { parseWebhook } from "../bitrix/webhook.js";
|
|
7
7
|
import { configuration } from "../config.js";
|
|
8
8
|
import { IDENTITY } from "../identity.js";
|
|
9
|
-
import { contextOf,
|
|
9
|
+
import { contextOf, refuseOffline, transportFor, withPortal } from "../portal.js";
|
|
10
10
|
import { TOKEN_VARIABLE, tokens } from "../token.js";
|
|
11
11
|
import { webhookUser } from "../whoami.js";
|
|
12
12
|
const answer = (command, item) => renderAnswer(command, outputFor(command), itemOf(item));
|
|
@@ -26,14 +26,14 @@ const startCommand = () => logsInOrOut(annotate(new Command("start"), {
|
|
|
26
26
|
const storage = args.credentialStorage;
|
|
27
27
|
if (storage !== "keyring" && storage !== "file")
|
|
28
28
|
throw new CliError("validation_error", "--credential-storage takes keyring or file");
|
|
29
|
-
const { env, flags, profile, tokens } = contextOf(this);
|
|
29
|
+
const { env, flags, profile, tokens, run } = contextOf(this);
|
|
30
30
|
refuseCommandName(profile, commandWords(rootOf(this)), IDENTITY.command);
|
|
31
31
|
refuseOffline(flags);
|
|
32
32
|
const address = (await readSecret("Bitrix24 webhook address: ", secretInputOf(this))).trim();
|
|
33
33
|
if (!address)
|
|
34
34
|
throw new CliError("validation_error", "no webhook address was given");
|
|
35
35
|
const webhook = parseWebhook(address);
|
|
36
|
-
const user = await webhookUser(transportFor(this, webhook));
|
|
36
|
+
const user = await run((events) => webhookUser(transportFor(this, webhook, events)));
|
|
37
37
|
const portal = new URL(webhook.origin).host;
|
|
38
38
|
const stored = tokens.write(profile, address, storage);
|
|
39
39
|
rememberAccount(IDENTITY, profile, `${portal}:${webhook.userId}`, env);
|
|
@@ -54,7 +54,7 @@ const statusCommand = () => annotate(new Command("status"), {
|
|
|
54
54
|
const status = { profile, state: stored ? "saved" : "missing", token_from: stored?.source ?? null, portal };
|
|
55
55
|
if (!args.check || !stored)
|
|
56
56
|
return answer(this, { ...status, verified: false });
|
|
57
|
-
answer(this, { ...status, verified: true, user: await
|
|
57
|
+
answer(this, { ...status, verified: true, user: await withPortal(this, webhookUser) });
|
|
58
58
|
});
|
|
59
59
|
const endCommand = () => logsInOrOut(annotate(new Command("end"), {
|
|
60
60
|
effects: LOCAL_WRITE,
|