@wirecat/amo-cli 0.1.1 → 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 +36 -0
- package/README.md +15 -10
- package/contracts/wirecat.json +55 -6
- package/dist/amo/button.d.ts +53 -0
- package/dist/amo/button.d.ts.map +1 -0
- package/dist/amo/button.js +234 -0
- package/dist/amo/button.js.map +1 -0
- package/dist/amo/oauth.d.ts +12 -3
- package/dist/amo/oauth.d.ts.map +1 -1
- package/dist/amo/oauth.js +19 -6
- package/dist/amo/oauth.js.map +1 -1
- package/dist/bin/amo.js +2 -2
- package/dist/bundle/agent-FDNP27SW.js +40 -0
- package/dist/bundle/{all-profiles-3KQVWDV4.js → all-profiles-PPUN52SP.js} +63 -21
- package/dist/bundle/amo.js +28 -26
- package/dist/bundle/{anthropic-N5NOX7K7.js → anthropic-RDNDT6ZP.js} +5 -5
- package/dist/bundle/{app-server-2MST5EZ5.js → app-server-MMALJDBP.js} +79 -68
- package/dist/bundle/{bun-4NHWOFX2.js → bun-Y4FRPURU.js} +2 -2
- package/dist/bundle/{bun-sqlite-DRSXPWPR.js → bun-sqlite-7NXJGZCO.js} +6 -6
- package/dist/bundle/{chunk-GNTJMB6X.js → chunk-2YEDK2XV.js} +4 -4
- package/dist/bundle/chunk-3NDMVXGS.js +80 -0
- package/dist/bundle/{chunk-Y37A3232.js → chunk-3RP57VDS.js} +114 -7
- package/dist/bundle/{chunk-ODNQU7DH.js → chunk-3YOZTGZ6.js} +43 -64
- package/dist/bundle/{chunk-ESZSMZKT.js → chunk-4EYPFFTN.js} +2 -2
- package/dist/bundle/{chunk-TZSUZGWM.js → chunk-4MVTSMWP.js} +2 -2
- package/dist/bundle/{chunk-LJQUYECN.js → chunk-5DPMNYQT.js} +1 -1
- package/dist/bundle/{chunk-7PKFYX7V.js → chunk-5POLHHDZ.js} +8 -8
- package/dist/bundle/{chunk-A33TIM5D.js → chunk-5RXH35ZA.js} +225 -225
- package/dist/bundle/{chunk-BVMNXI53.js → chunk-77FP6AWC.js} +25 -25
- package/dist/bundle/{chunk-L6AFE73L.js → chunk-7E6QSIRQ.js} +1 -1
- package/dist/bundle/chunk-7SBAHYZW.js +734 -0
- package/dist/bundle/{chunk-GQ7VFIYM.js → chunk-7USADF2W.js} +23 -7
- package/dist/bundle/{chunk-AHJ4W2IL.js → chunk-7VSYOMEH.js} +2 -2
- package/dist/bundle/chunk-7Z6NYSAN.js +52 -0
- package/dist/bundle/chunk-AYR6FIXN.js +30 -0
- package/dist/bundle/{chunk-ADEWU4P4.js → chunk-B4ITT55D.js} +1 -1
- package/dist/bundle/{chunk-AUBB72VF.js → chunk-BKTLAXUK.js} +41 -10
- package/dist/bundle/{chunk-63F65DHU.js → chunk-BYVDMPLX.js} +2 -2
- package/dist/bundle/{chunk-V77XNPXG.js → chunk-CQ472K6W.js} +11 -11
- package/dist/bundle/{chunk-FKR3M62D.js → chunk-CUZISGWH.js} +13 -13
- package/dist/bundle/{chunk-LDEBZ3IX.js → chunk-D6UPCAPD.js} +1 -1
- package/dist/bundle/{chunk-P3WQRTYZ.js → chunk-E2DLRLJ5.js} +1 -1
- package/dist/bundle/{chunk-NJYAL3UW.js → chunk-EHULZEXQ.js} +1 -1
- package/dist/bundle/chunk-EKNP326Q.js +108 -0
- package/dist/bundle/{chunk-DJD7TBYG.js → chunk-ELJGALVX.js} +76 -74
- package/dist/bundle/{chunk-RPWAJYI6.js → chunk-FI2TP6TY.js} +3 -3
- package/dist/bundle/{chunk-CDY2NJFE.js → chunk-FPDTIQOK.js} +2 -2
- package/dist/bundle/{chunk-NC76INB2.js → chunk-FPIUFSWK.js} +3099 -2266
- package/dist/bundle/{chunk-SZ2V62HB.js → chunk-GCUFGDKE.js} +2 -2
- package/dist/bundle/{chunk-LRBPT7LQ.js → chunk-GKP7CKW2.js} +6 -6
- package/dist/bundle/chunk-H34RBRS3.js +209 -0
- package/dist/bundle/{chunk-O2UCU52O.js → chunk-HQH4YPO5.js} +134 -569
- package/dist/bundle/{chunk-TNUFLULO.js → chunk-I4QCJZW7.js} +8 -8
- package/dist/bundle/{chunk-DXGGCGRP.js → chunk-IDQ7BNCZ.js} +14 -14
- package/dist/bundle/{chunk-JMDLPBXK.js → chunk-IEAPNTHT.js} +17 -17
- package/dist/bundle/{chunk-XQL7FEF4.js → chunk-ILUREFWJ.js} +9 -9
- package/dist/bundle/{chunk-QRQYUHCZ.js → chunk-IYUWVMGP.js} +12 -12
- package/dist/bundle/chunk-JTFAG3BX.js +338 -0
- package/dist/bundle/{chunk-CHUKWON6.js → chunk-JZ2AITOE.js} +3 -3
- package/dist/bundle/{chunk-JR6TSMFX.js → chunk-KEOKH2OZ.js} +103 -70
- package/dist/bundle/{chunk-UMVRT7VQ.js → chunk-KKXF6TSS.js} +1 -1
- package/dist/bundle/{chunk-5E5R65CA.js → chunk-KTLCQ7GC.js} +2 -2
- package/dist/bundle/{chunk-QDMXZZG4.js → chunk-KZDBO2FT.js} +18 -8
- package/dist/bundle/{chunk-VX37MPTJ.js → chunk-L2ZQDTDU.js} +1 -1
- package/dist/bundle/{chunk-CUZRHF34.js → chunk-L3JDQNBC.js} +4 -4
- package/dist/bundle/{chunk-3IRJDH2U.js → chunk-L72UALL5.js} +2 -100
- package/dist/bundle/{chunk-XRTD2GCU.js → chunk-LOSOWTAZ.js} +19 -258
- package/dist/bundle/{chunk-LGQXGOPJ.js → chunk-LYRICHEK.js} +2 -2
- package/dist/bundle/{chunk-UBRREVLJ.js → chunk-MMOEAH5G.js} +2 -2
- package/dist/bundle/{chunk-EQ7A6NA6.js → chunk-MPXKBF37.js} +1 -1
- package/dist/bundle/{chunk-SMSTGO2G.js → chunk-MYMBPQPQ.js} +4 -4
- package/dist/bundle/chunk-N4A6E2LL.js +559 -0
- package/dist/bundle/{chunk-5HGGG3QO.js → chunk-NJ2LJKNH.js} +16 -3
- package/dist/bundle/{chunk-TGEQNS6G.js → chunk-OMH3WP7F.js} +1 -1
- package/dist/bundle/{chunk-ULXQ5MJM.js → chunk-ORFLQGWH.js} +4 -4
- package/dist/bundle/{chunk-DQV2IKCF.js → chunk-PFZ7WG2B.js} +10 -3
- package/dist/bundle/{chunk-5D4AEUVA.js → chunk-PL5P7UKW.js} +434 -1
- package/dist/bundle/{chunk-6RS7OYTD.js → chunk-Q2YVY7IR.js} +3 -3
- package/dist/bundle/{chunk-DOSJONCX.js → chunk-QHA33ZS6.js} +7 -7
- package/dist/bundle/{chunk-JH3UOHRE.js → chunk-QQT7WUR4.js} +4 -4
- package/dist/bundle/{chunk-EROSAUNP.js → chunk-R23DRW2T.js} +5 -5
- package/dist/bundle/{chunk-WCYCUTSK.js → chunk-SBQ5MFHM.js} +7 -7
- package/dist/bundle/{chunk-DAY6TSPF.js → chunk-SJYVKR54.js} +62 -50
- package/dist/bundle/{chunk-T2UDLX76.js → chunk-SJZ52MZE.js} +6 -6
- package/dist/bundle/{chunk-ZM7I52EP.js → chunk-T6D34X5S.js} +3 -4
- package/dist/bundle/{chunk-P5LYZRKW.js → chunk-TCDER3G7.js} +1586 -749
- package/dist/bundle/{chunk-2I5UVMLW.js → chunk-TWZF7VO6.js} +1726 -1159
- package/dist/bundle/{chunk-VVHRQ46X.js → chunk-UA7C57IB.js} +2 -2
- package/dist/bundle/{chunk-5SBLU7D7.js → chunk-UM6SDFB6.js} +1 -1
- package/dist/bundle/{chunk-7U5HJEPZ.js → chunk-UOPP6ORQ.js} +21 -19
- package/dist/bundle/{chunk-U7RLVJ34.js → chunk-UT3ODJMI.js} +4 -4
- package/dist/bundle/{chunk-7GTUZY7M.js → chunk-UZLT6VSP.js} +3 -3
- package/dist/bundle/{chunk-5RLUHTK6.js → chunk-V3ZWYMXT.js} +1 -1
- package/dist/bundle/{chunk-LSND5QYI.js → chunk-VD7HD25M.js} +9 -9
- package/dist/bundle/{chunk-PFO76YFP.js → chunk-VEGNZPQU.js} +18 -18
- package/dist/bundle/{chunk-5Z5PEEKP.js → chunk-VFU25P57.js} +4 -4
- package/dist/bundle/{chunk-4ZAK773N.js → chunk-VJHOBOJR.js} +3 -3
- package/dist/bundle/{chunk-PM77PRB6.js → chunk-VPBSZ4HQ.js} +185 -162
- package/dist/bundle/{chunk-Q2VNBY4Y.js → chunk-VY27K2SH.js} +746 -1205
- package/dist/bundle/{chunk-XEFAMLSD.js → chunk-W4KY5JF5.js} +3 -3
- package/dist/bundle/{chunk-73CXFE36.js → chunk-WBWVBEHH.js} +29 -1
- package/dist/bundle/{chunk-NHXJYS4R.js → chunk-XDT74W5P.js} +32 -28
- package/dist/bundle/{chunk-EPOV5UIO.js → chunk-XI75EKLG.js} +11 -11
- package/dist/bundle/{chunk-2B24PDH7.js → chunk-XM2G62YF.js} +8 -6
- package/dist/bundle/{chunk-5D4Z2B5B.js → chunk-YSOGGUK3.js} +9 -9
- package/dist/bundle/chunk-YVO2YGML.js +353 -0
- package/dist/bundle/{chunk-EQUKVVHX.js → chunk-ZIFEIJRK.js} +7 -7
- package/dist/bundle/{cli-QVWTXADI.js → cli-GAO7LDDA.js} +150 -103
- package/dist/bundle/command-contract-RLIBGIDT.js +39 -0
- package/dist/bundle/{command-server-entry-5VL5U5EE.js → command-server-entry-BCDJP7XE.js} +28 -28
- package/dist/bundle/{decode-SQ5WGNDX.js → decode-OY2GR442.js} +5 -5
- package/dist/bundle/{dispatch-LA4DFXJD.js → dispatch-JWEJCBTF.js} +8 -8
- package/dist/bundle/dist-PAKDDIBT.js +191 -0
- package/dist/bundle/{echarts-25Z3RINX.js → echarts-AHEPEA5P.js} +2 -2
- package/dist/bundle/{embed-BNOTNXMA.js → embed-RVSUV54Z.js} +6 -6
- package/dist/bundle/{embedder-BCUT7KKV.js → embedder-GRZXZUXR.js} +9 -9
- package/dist/bundle/{failure-PKAC6XCT.js → failure-DDCSR54L.js} +2 -2
- package/dist/bundle/{first-run-EO5K5GME.js → first-run-G3WI4DH4.js} +12 -12
- package/dist/bundle/first-screen-6MLCMW2U.js +39 -0
- package/dist/bundle/{instructions-VLM3QAYB.js → instructions-NWQC5IP4.js} +1 -1
- package/dist/bundle/{mcp-7ILNMJH5.js → mcp-KGWT6TGO.js} +2 -2
- package/dist/bundle/meeting-combined-SVTFVZNJ.js +24 -0
- package/dist/bundle/{meeting-model-GHMMUQ34.js → meeting-model-I6T5HIZ5.js} +11 -11
- package/dist/bundle/{meeting-semantic-BMP6323L.js → meeting-semantic-47UA5JBF.js} +6 -6
- package/dist/bundle/{node-CT3N3TNL.js → node-7VXN7F4B.js} +2 -2
- package/dist/bundle/{node-sqlite-MELD2SBX.js → node-sqlite-BSEON57L.js} +7 -7
- package/dist/bundle/{oauth-YBH5OKC2.js → oauth-V6UAT4YD.js} +8 -8
- package/dist/bundle/{open-WNSBWTAG.js → open-7LVAY7ZU.js} +5 -5
- package/dist/bundle/{openai-XSNMNLW6.js → openai-OIEH342H.js} +15 -15
- package/dist/bundle/{process-I2QKOMM7.js → process-PTUCNLZ7.js} +1 -1
- package/dist/bundle/{program-DV73CIGP.js → program-S5WY5IZP.js} +643 -852
- package/dist/bundle/{prompt-SOG4AKPM.js → prompt-7XWTEQ62.js} +5 -5
- package/dist/bundle/{recognize-WMQLWMXH.js → recognize-HGIAJXDR.js} +4 -4
- package/dist/bundle/{remote-4BTFOLFY.js → remote-X4SVEMHS.js} +9 -9
- package/dist/bundle/{rerank-LJ3TWRNV.js → rerank-QWM3DQMU.js} +7 -7
- package/dist/bundle/{serve-B6UANKXN.js → serve-VVG3TXYT.js} +10 -10
- package/dist/bundle/{server-YRH6GJ5Z.js → server-EHYK62BJ.js} +73 -61
- package/dist/bundle/server-WRPTBVNW.js +86 -0
- package/dist/bundle/source-YISMYLBQ.js +44 -0
- package/dist/bundle/{sqlite-runtime-R7QFWFE7.js → sqlite-runtime-MCKXDNYC.js} +6 -6
- package/dist/bundle/{state-DIJ5YUOE.js → state-MYNYQJCT.js} +6 -6
- package/dist/bundle/store-A7R2SZVD.js +34 -0
- package/dist/bundle/{store-MYTYDV6A.js → store-B7O3F3QB.js} +28 -21
- package/dist/bundle/{store-6WFWW7EC.js → store-FPIU2546.js} +24 -23
- package/dist/bundle/store-maintenance-command-D55FRTIK.js +73 -0
- package/dist/bundle/surface-3EX6IGHW.js +72 -0
- package/dist/bundle/writer-XDHZ54JD.js +46 -0
- package/dist/commands/session.d.ts +23 -0
- package/dist/commands/session.d.ts.map +1 -1
- package/dist/commands/session.js +115 -45
- package/dist/commands/session.js.map +1 -1
- package/dist/identity.js +1 -1
- package/dist/identity.js.map +1 -1
- package/dist/program.d.ts.map +1 -1
- package/dist/program.js +3 -1
- package/dist/program.js.map +1 -1
- package/dist/reasons.d.ts.map +1 -1
- package/dist/reasons.js +2 -0
- package/dist/reasons.js.map +1 -1
- package/dist/setup/flow.d.ts.map +1 -1
- package/dist/setup/flow.js +74 -4
- package/dist/setup/flow.js.map +1 -1
- package/dist/setup/texts.en.json +22 -1
- package/dist/setup/texts.es.json +22 -1
- package/dist/setup/texts.ru.json +22 -1
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +5 -3
- package/scenarios/first-sync.md +23 -0
- package/scenarios/keep-in-sync.md +18 -0
- package/scenarios/safe-agent-writes.md +21 -0
- package/skills/amo-cli/SKILL.md +1 -1
- package/skills/amo-cli/references/mcp.md +1 -1
- package/skills/amo-cli/references/setup.md +9 -3
- package/dist/bundle/command-contract-QBUQBXH7.js +0 -39
- package/dist/bundle/first-screen-GMN3T6RW.js +0 -39
- package/dist/bundle/meeting-combined-LAMF7S2B.js +0 -24
- package/dist/bundle/server-S6XD6V6E.js +0 -77
- package/dist/bundle/source-DGFTA2TN.js +0 -42
- package/dist/bundle/store-FJCNZULV.js +0 -32
- package/dist/bundle/store-maintenance-command-B5TMKFMG.js +0 -68
- package/dist/bundle/writer-GP7VIMAU.js +0 -44
|
@@ -1,23 +1,27 @@
|
|
|
1
1
|
import { createRequire as __bundleRequire } from "node:module";
|
|
2
2
|
const require = __bundleRequire(import.meta.url);
|
|
3
|
+
import {
|
|
4
|
+
AMO_WRITES
|
|
5
|
+
} from "./chunk-JZ2AITOE.js";
|
|
3
6
|
import {
|
|
4
7
|
ProfileTokenStore,
|
|
5
8
|
REPORT_FORMAT,
|
|
6
|
-
SECTION_CAPS,
|
|
7
9
|
accountRemoveCommand,
|
|
8
|
-
|
|
10
|
+
accountTokenCodec,
|
|
9
11
|
appDoctorCommand,
|
|
10
12
|
appMcpCommand,
|
|
11
13
|
commandLevel,
|
|
12
14
|
commandsCommand,
|
|
13
15
|
configCommand,
|
|
14
16
|
createProgram,
|
|
17
|
+
credentialStorage,
|
|
15
18
|
defineSetup,
|
|
16
19
|
deniedKinds,
|
|
20
|
+
guideCommand,
|
|
17
21
|
honoursDryRun,
|
|
22
|
+
oauthAccount,
|
|
18
23
|
openBrowser,
|
|
19
24
|
ownerLanguageOf,
|
|
20
|
-
parseApiJson,
|
|
21
25
|
providerEvent,
|
|
22
26
|
providerRequest,
|
|
23
27
|
run,
|
|
@@ -27,45 +31,51 @@ import {
|
|
|
27
31
|
setupCommand,
|
|
28
32
|
signInSteps,
|
|
29
33
|
skillCommand,
|
|
34
|
+
tokenKeeper,
|
|
30
35
|
upgradeCommand,
|
|
31
36
|
writeCsv
|
|
32
|
-
} from "./chunk-
|
|
37
|
+
} from "./chunk-FPIUFSWK.js";
|
|
38
|
+
import "./chunk-E2DLRLJ5.js";
|
|
33
39
|
import {
|
|
34
40
|
PROVIDER
|
|
35
|
-
} from "./chunk-
|
|
41
|
+
} from "./chunk-4MVTSMWP.js";
|
|
36
42
|
import {
|
|
37
43
|
OPERATIONS,
|
|
38
44
|
amoCrmSource,
|
|
39
45
|
matchOperation,
|
|
40
46
|
pathOf,
|
|
41
47
|
withEveryId
|
|
42
|
-
} from "./chunk-
|
|
43
|
-
import {
|
|
44
|
-
AMO_WRITES
|
|
45
|
-
} from "./chunk-CHUKWON6.js";
|
|
48
|
+
} from "./chunk-FI2TP6TY.js";
|
|
46
49
|
import {
|
|
47
50
|
ENTITIES,
|
|
48
51
|
ROUTES
|
|
49
|
-
} from "./chunk-
|
|
50
|
-
import "./chunk-
|
|
52
|
+
} from "./chunk-D6UPCAPD.js";
|
|
53
|
+
import "./chunk-T6D34X5S.js";
|
|
51
54
|
import {
|
|
52
55
|
SOURCE_SEARCHED,
|
|
53
56
|
allAnswer,
|
|
54
57
|
historySkipsOf,
|
|
55
58
|
offsetOf,
|
|
56
59
|
refuseOffline
|
|
57
|
-
} from "./chunk-
|
|
58
|
-
import "./chunk-
|
|
59
|
-
import "./chunk-
|
|
60
|
-
import "./chunk-
|
|
60
|
+
} from "./chunk-XDT74W5P.js";
|
|
61
|
+
import "./chunk-LOSOWTAZ.js";
|
|
62
|
+
import "./chunk-5POLHHDZ.js";
|
|
63
|
+
import "./chunk-7E6QSIRQ.js";
|
|
61
64
|
import {
|
|
62
65
|
addStoreMaintenanceCommands
|
|
63
|
-
} from "./chunk-
|
|
66
|
+
} from "./chunk-KEOKH2OZ.js";
|
|
64
67
|
import {
|
|
65
68
|
commandPathKey,
|
|
66
69
|
commandPermissions,
|
|
67
70
|
terminalAsker
|
|
68
|
-
} from "./chunk-
|
|
71
|
+
} from "./chunk-UOPP6ORQ.js";
|
|
72
|
+
import "./chunk-YVO2YGML.js";
|
|
73
|
+
import "./chunk-ZIFEIJRK.js";
|
|
74
|
+
import "./chunk-IDQ7BNCZ.js";
|
|
75
|
+
import "./chunk-7VSYOMEH.js";
|
|
76
|
+
import "./chunk-7Z6NYSAN.js";
|
|
77
|
+
import "./chunk-JTFAG3BX.js";
|
|
78
|
+
import "./chunk-H34RBRS3.js";
|
|
69
79
|
import {
|
|
70
80
|
crmAccounts,
|
|
71
81
|
extractText,
|
|
@@ -74,13 +84,11 @@ import {
|
|
|
74
84
|
personMeetings,
|
|
75
85
|
readableAccounts,
|
|
76
86
|
searchAll,
|
|
77
|
-
taskAccount
|
|
78
|
-
|
|
79
|
-
} from "./chunk-Q2VNBY4Y.js";
|
|
87
|
+
taskAccount
|
|
88
|
+
} from "./chunk-VY27K2SH.js";
|
|
80
89
|
import {
|
|
81
|
-
acquireLock,
|
|
82
90
|
safeName
|
|
83
|
-
} from "./chunk-
|
|
91
|
+
} from "./chunk-CUZISGWH.js";
|
|
84
92
|
import {
|
|
85
93
|
CRM_ASSIGN_OTHERS_KEY,
|
|
86
94
|
CRM_WRITE_DEFAULTS,
|
|
@@ -89,8 +97,8 @@ import {
|
|
|
89
97
|
RECORD_ID,
|
|
90
98
|
SYNCED_FROM,
|
|
91
99
|
SYNC_FAILED,
|
|
100
|
+
apiJson,
|
|
92
101
|
closeCrmItem,
|
|
93
|
-
commandPath,
|
|
94
102
|
conditionsOf,
|
|
95
103
|
createCrmItem,
|
|
96
104
|
createCrmRecord,
|
|
@@ -99,62 +107,64 @@ import {
|
|
|
99
107
|
crmViewerOf,
|
|
100
108
|
customConditions,
|
|
101
109
|
customNames,
|
|
102
|
-
dateWindow,
|
|
103
110
|
fieldPairsOf,
|
|
104
111
|
filterableFields,
|
|
105
112
|
foreignContacts,
|
|
106
113
|
foreignContactsPathFor,
|
|
107
114
|
guardFor,
|
|
108
115
|
keyedGuard,
|
|
109
|
-
listQuery,
|
|
110
116
|
moveCrmItem,
|
|
111
|
-
nativeField,
|
|
112
|
-
nativeTerms,
|
|
113
117
|
newOperationId,
|
|
114
118
|
ownerOf,
|
|
115
119
|
pacePathFor,
|
|
120
|
+
parseApiJson,
|
|
116
121
|
parseCrmFileId,
|
|
117
122
|
pipelineOf,
|
|
118
123
|
providerCall,
|
|
119
|
-
queryTerms,
|
|
120
124
|
refuseForeignClientReads,
|
|
121
125
|
removeCrmItem,
|
|
122
|
-
searchText,
|
|
123
126
|
selectedCodes,
|
|
124
127
|
shortened,
|
|
125
128
|
syncRecorded,
|
|
126
|
-
termField,
|
|
127
|
-
timeBounds,
|
|
128
|
-
typedQuery,
|
|
129
|
-
unfilteredQuery,
|
|
130
129
|
updateCrmItem,
|
|
131
130
|
updateCrmRecord,
|
|
132
131
|
values_exports,
|
|
133
132
|
viewerOf,
|
|
134
133
|
wantedCodes,
|
|
135
134
|
withCustomFields,
|
|
136
|
-
withQuery,
|
|
137
135
|
withReadableDeal,
|
|
138
136
|
withoutFileLinks
|
|
139
|
-
} from "./chunk-
|
|
140
|
-
import "./chunk-
|
|
141
|
-
import "./chunk-73CXFE36.js";
|
|
142
|
-
import "./chunk-DXGGCGRP.js";
|
|
137
|
+
} from "./chunk-TWZF7VO6.js";
|
|
138
|
+
import "./chunk-WBWVBEHH.js";
|
|
143
139
|
import {
|
|
144
140
|
latestVersion,
|
|
145
141
|
runUpdate,
|
|
146
142
|
updateNotice
|
|
147
|
-
} from "./chunk-
|
|
148
|
-
import "./chunk-
|
|
149
|
-
import "./chunk-
|
|
150
|
-
import
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
143
|
+
} from "./chunk-2YEDK2XV.js";
|
|
144
|
+
import "./chunk-KKXF6TSS.js";
|
|
145
|
+
import "./chunk-AYR6FIXN.js";
|
|
146
|
+
import {
|
|
147
|
+
commandPath,
|
|
148
|
+
dateWindow,
|
|
149
|
+
listQuery,
|
|
150
|
+
nativeField,
|
|
151
|
+
nativeTerms,
|
|
152
|
+
queryTerms,
|
|
153
|
+
searchText,
|
|
154
|
+
termField,
|
|
155
|
+
timeBounds,
|
|
156
|
+
typedQuery,
|
|
157
|
+
unfilteredQuery,
|
|
158
|
+
withQuery,
|
|
159
|
+
withWords
|
|
160
|
+
} from "./chunk-7SBAHYZW.js";
|
|
161
|
+
import "./chunk-ORFLQGWH.js";
|
|
162
|
+
import "./chunk-SJZ52MZE.js";
|
|
163
|
+
import "./chunk-CQ472K6W.js";
|
|
164
|
+
import "./chunk-UZLT6VSP.js";
|
|
165
|
+
import "./chunk-QQT7WUR4.js";
|
|
166
|
+
import "./chunk-NJ2LJKNH.js";
|
|
167
|
+
import "./chunk-R23DRW2T.js";
|
|
158
168
|
import {
|
|
159
169
|
Argument,
|
|
160
170
|
Command,
|
|
@@ -201,13 +211,13 @@ import {
|
|
|
201
211
|
sharedCommand,
|
|
202
212
|
snakeKeys,
|
|
203
213
|
snakeKeysKeeping
|
|
204
|
-
} from "./chunk-
|
|
205
|
-
import "./chunk-
|
|
206
|
-
import "./chunk-
|
|
207
|
-
import "./chunk-
|
|
208
|
-
import "./chunk-
|
|
209
|
-
import "./chunk-
|
|
210
|
-
import "./chunk-
|
|
214
|
+
} from "./chunk-VPBSZ4HQ.js";
|
|
215
|
+
import "./chunk-SBQ5MFHM.js";
|
|
216
|
+
import "./chunk-MYMBPQPQ.js";
|
|
217
|
+
import "./chunk-YSOGGUK3.js";
|
|
218
|
+
import "./chunk-UM6SDFB6.js";
|
|
219
|
+
import "./chunk-IEAPNTHT.js";
|
|
220
|
+
import "./chunk-Q2YVY7IR.js";
|
|
211
221
|
import {
|
|
212
222
|
CRM_CHANGES,
|
|
213
223
|
CRM_SCOPES,
|
|
@@ -215,53 +225,54 @@ import {
|
|
|
215
225
|
attachmentMaxBytes,
|
|
216
226
|
crmIdentityId,
|
|
217
227
|
crmSettingKey,
|
|
218
|
-
dayIn,
|
|
219
228
|
seenBy,
|
|
220
229
|
viewerSql
|
|
221
|
-
} from "./chunk-
|
|
222
|
-
import "./chunk-
|
|
223
|
-
import
|
|
230
|
+
} from "./chunk-TCDER3G7.js";
|
|
231
|
+
import "./chunk-I4QCJZW7.js";
|
|
232
|
+
import {
|
|
233
|
+
dayIn
|
|
234
|
+
} from "./chunk-3NDMVXGS.js";
|
|
235
|
+
import "./chunk-ILUREFWJ.js";
|
|
224
236
|
import {
|
|
225
237
|
count,
|
|
226
238
|
createTaskService,
|
|
227
239
|
currentAttempt,
|
|
228
240
|
text,
|
|
229
241
|
time
|
|
230
|
-
} from "./chunk-
|
|
231
|
-
import "./chunk-
|
|
232
|
-
import "./chunk-
|
|
242
|
+
} from "./chunk-77FP6AWC.js";
|
|
243
|
+
import "./chunk-MMOEAH5G.js";
|
|
244
|
+
import "./chunk-XI75EKLG.js";
|
|
233
245
|
import {
|
|
234
246
|
hostFetch,
|
|
235
247
|
providerWaitMs,
|
|
236
248
|
readJsonResponse,
|
|
237
249
|
retryableStatus,
|
|
238
250
|
statusToCode
|
|
239
|
-
} from "./chunk-
|
|
240
|
-
import "./chunk-
|
|
241
|
-
import "./chunk-
|
|
242
|
-
import "./chunk-U7RLVJ34.js";
|
|
251
|
+
} from "./chunk-7USADF2W.js";
|
|
252
|
+
import "./chunk-3YOZTGZ6.js";
|
|
253
|
+
import "./chunk-UT3ODJMI.js";
|
|
243
254
|
import {
|
|
244
255
|
IDENTITY,
|
|
245
256
|
PACKAGE,
|
|
246
257
|
SKILL
|
|
247
|
-
} from "./chunk-
|
|
248
|
-
import "./chunk-
|
|
249
|
-
import "./chunk-
|
|
250
|
-
import "./chunk-VVHRQ46X.js";
|
|
251
|
-
import "./chunk-LSND5QYI.js";
|
|
258
|
+
} from "./chunk-XM2G62YF.js";
|
|
259
|
+
import "./chunk-FPDTIQOK.js";
|
|
260
|
+
import "./chunk-UA7C57IB.js";
|
|
252
261
|
import "./chunk-EH6ZEJGT.js";
|
|
262
|
+
import "./chunk-3RP57VDS.js";
|
|
263
|
+
import "./chunk-VD7HD25M.js";
|
|
253
264
|
import {
|
|
254
265
|
installerOf
|
|
255
|
-
} from "./chunk-
|
|
266
|
+
} from "./chunk-V3ZWYMXT.js";
|
|
256
267
|
import {
|
|
257
268
|
fieldsOf,
|
|
258
269
|
levelFor
|
|
259
|
-
} from "./chunk-
|
|
270
|
+
} from "./chunk-KZDBO2FT.js";
|
|
260
271
|
import {
|
|
261
272
|
foldName
|
|
262
|
-
} from "./chunk-
|
|
263
|
-
import "./chunk-
|
|
264
|
-
import "./chunk-
|
|
273
|
+
} from "./chunk-VEGNZPQU.js";
|
|
274
|
+
import "./chunk-PFZ7WG2B.js";
|
|
275
|
+
import "./chunk-OMH3WP7F.js";
|
|
265
276
|
import {
|
|
266
277
|
CRM_ACTIVITY_KINDS,
|
|
267
278
|
CRM_KINDS,
|
|
@@ -272,34 +283,35 @@ import {
|
|
|
272
283
|
normalCrmUserId,
|
|
273
284
|
parseDecimal,
|
|
274
285
|
scaleOf
|
|
275
|
-
} from "./chunk-
|
|
276
|
-
import "./chunk-
|
|
277
|
-
import "./chunk-
|
|
286
|
+
} from "./chunk-IYUWVMGP.js";
|
|
287
|
+
import "./chunk-EHULZEXQ.js";
|
|
288
|
+
import "./chunk-BYVDMPLX.js";
|
|
278
289
|
import {
|
|
279
290
|
SAVE_HELP,
|
|
280
291
|
defineQuery,
|
|
281
292
|
queryFieldsOf,
|
|
282
293
|
timezoneOf,
|
|
283
294
|
zonedMoment
|
|
284
|
-
} from "./chunk-
|
|
285
|
-
import "./chunk-
|
|
295
|
+
} from "./chunk-5RXH35ZA.js";
|
|
296
|
+
import "./chunk-L2ZQDTDU.js";
|
|
297
|
+
import "./chunk-QHA33ZS6.js";
|
|
286
298
|
import "./chunk-D72URWJE.js";
|
|
287
299
|
import {
|
|
288
300
|
readSecret
|
|
289
|
-
} from "./chunk-
|
|
290
|
-
import "./chunk-
|
|
291
|
-
import "./chunk-
|
|
292
|
-
import "./chunk-
|
|
293
|
-
import "./chunk-
|
|
301
|
+
} from "./chunk-VJHOBOJR.js";
|
|
302
|
+
import "./chunk-4EYPFFTN.js";
|
|
303
|
+
import "./chunk-KTLCQ7GC.js";
|
|
304
|
+
import "./chunk-GKP7CKW2.js";
|
|
305
|
+
import "./chunk-B4ITT55D.js";
|
|
294
306
|
import {
|
|
295
307
|
Credentials,
|
|
296
308
|
isMovedRun,
|
|
297
|
-
|
|
309
|
+
monotonic,
|
|
298
310
|
realSleep,
|
|
299
311
|
renderPretty,
|
|
300
312
|
resolvePaths,
|
|
301
313
|
systemKeyring
|
|
302
|
-
} from "./chunk-
|
|
314
|
+
} from "./chunk-ELJGALVX.js";
|
|
303
315
|
import {
|
|
304
316
|
array,
|
|
305
317
|
boolean,
|
|
@@ -318,21 +330,22 @@ import {
|
|
|
318
330
|
union,
|
|
319
331
|
unknown,
|
|
320
332
|
variant
|
|
321
|
-
} from "./chunk-
|
|
333
|
+
} from "./chunk-BKTLAXUK.js";
|
|
322
334
|
import "./chunk-Y5E2WNWB.js";
|
|
323
335
|
import {
|
|
324
336
|
CliError,
|
|
325
337
|
isCliError
|
|
326
|
-
} from "./chunk-
|
|
327
|
-
import "./chunk-
|
|
338
|
+
} from "./chunk-GCUFGDKE.js";
|
|
339
|
+
import "./chunk-5DPMNYQT.js";
|
|
328
340
|
import {
|
|
329
341
|
__name
|
|
330
342
|
} from "./chunk-ZVVMGPBJ.js";
|
|
331
343
|
|
|
332
344
|
// dist/program.js
|
|
333
|
-
import { join as
|
|
345
|
+
import { join as join4 } from "node:path";
|
|
346
|
+
import { fileURLToPath as fileURLToPath2 } from "node:url";
|
|
334
347
|
|
|
335
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
348
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.720.0_@wirecat+cli-base@0.126.1_commander@15.0.0_esbuild@0.28.2_typ_891204b7e0cfbcc49dd71e2850e8663f/node_modules/@wirecat/cli-core/dist/update/index.js
|
|
336
349
|
import { realpathSync } from "node:fs";
|
|
337
350
|
import { fileURLToPath } from "node:url";
|
|
338
351
|
var npmRegistry = /* @__PURE__ */ __name(() => hostFetch({ hosts: ["registry.npmjs.org"] }), "npmRegistry");
|
|
@@ -397,643 +410,6 @@ var appUpdate = /* @__PURE__ */ __name((app) => {
|
|
|
397
410
|
};
|
|
398
411
|
}, "appUpdate");
|
|
399
412
|
|
|
400
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.691.0_@wirecat+cli-base@0.113.0_commander@15.0.0_esbuild@0.28.2_typ_9a2e508bb6f63e7e29f0d776540ec8fd/node_modules/@wirecat/cli-core/dist/oauth/authorize.js
|
|
401
|
-
import { createHash, randomBytes } from "node:crypto";
|
|
402
|
-
import { createServer } from "node:http";
|
|
403
|
-
var DEFAULT_TIMEOUT_MS = 3e5;
|
|
404
|
-
var pkce = /* @__PURE__ */ __name(() => {
|
|
405
|
-
const codeVerifier = randomBytes(48).toString("base64url");
|
|
406
|
-
return { codeVerifier, codeChallenge: createHash("sha256").update(codeVerifier).digest("base64url") };
|
|
407
|
-
}, "pkce");
|
|
408
|
-
var queryOf = /* @__PURE__ */ __name((text4) => {
|
|
409
|
-
const trimmed = text4.trim();
|
|
410
|
-
const start = trimmed.indexOf("?");
|
|
411
|
-
return new URLSearchParams(start >= 0 ? trimmed.slice(start + 1).split("#")[0] : trimmed);
|
|
412
|
-
}, "queryOf");
|
|
413
|
-
var authorize = /* @__PURE__ */ __name(async (options) => {
|
|
414
|
-
const { provider } = options;
|
|
415
|
-
const cancelled = /* @__PURE__ */ __name(() => isCliError(options.signal?.reason) ? options.signal.reason : new CliError("cancelled", `${provider.name} sign-in was cancelled`), "cancelled");
|
|
416
|
-
if (options.signal?.aborted)
|
|
417
|
-
throw cancelled();
|
|
418
|
-
const { codeVerifier, codeChallenge } = pkce();
|
|
419
|
-
const paste = new AbortController();
|
|
420
|
-
let state = "";
|
|
421
|
-
let settled = false;
|
|
422
|
-
let accept = /* @__PURE__ */ __name(() => {
|
|
423
|
-
}, "accept");
|
|
424
|
-
let fail = /* @__PURE__ */ __name(() => {
|
|
425
|
-
}, "fail");
|
|
426
|
-
const code = new Promise((resolve2, reject) => {
|
|
427
|
-
accept = /* @__PURE__ */ __name((value) => {
|
|
428
|
-
settled = true;
|
|
429
|
-
resolve2(value);
|
|
430
|
-
}, "accept");
|
|
431
|
-
fail = /* @__PURE__ */ __name((error) => {
|
|
432
|
-
settled = true;
|
|
433
|
-
reject(error);
|
|
434
|
-
}, "fail");
|
|
435
|
-
});
|
|
436
|
-
void code.catch(() => {
|
|
437
|
-
});
|
|
438
|
-
const settle = /* @__PURE__ */ __name((query) => {
|
|
439
|
-
const value = query.get("code");
|
|
440
|
-
if (value)
|
|
441
|
-
accept(value);
|
|
442
|
-
else
|
|
443
|
-
fail(new CliError("authentication_error", `${provider.name} sign-in was declined`, { reason: "oauth.declined" }));
|
|
444
|
-
}, "settle");
|
|
445
|
-
const handler = /* @__PURE__ */ __name((request, response) => {
|
|
446
|
-
let url;
|
|
447
|
-
try {
|
|
448
|
-
url = new URL(request.url ?? "/", "http://127.0.0.1");
|
|
449
|
-
} catch {
|
|
450
|
-
response.writeHead(400).end();
|
|
451
|
-
return;
|
|
452
|
-
}
|
|
453
|
-
if (request.method !== "GET" || url.pathname !== "/callback") {
|
|
454
|
-
response.writeHead(404).end();
|
|
455
|
-
return;
|
|
456
|
-
}
|
|
457
|
-
if (settled || !state || url.searchParams.get("state") !== state) {
|
|
458
|
-
response.writeHead(400).end("This sign-in link does not belong to the waiting sign-in");
|
|
459
|
-
return;
|
|
460
|
-
}
|
|
461
|
-
if (!url.searchParams.get("code") && !url.searchParams.get("error")) {
|
|
462
|
-
response.writeHead(400).end("Missing sign-in result");
|
|
463
|
-
return;
|
|
464
|
-
}
|
|
465
|
-
response.end("Sign-in received; you can close this tab");
|
|
466
|
-
settle(url.searchParams);
|
|
467
|
-
}, "handler");
|
|
468
|
-
const server = createServer(handler);
|
|
469
|
-
const localhost = provider.redirect.kind === "loopback" && provider.redirect.host === "localhost";
|
|
470
|
-
const server6 = localhost ? createServer(handler) : void 0;
|
|
471
|
-
const onAbort = /* @__PURE__ */ __name(() => fail(cancelled()), "onAbort");
|
|
472
|
-
options.signal?.addEventListener("abort", onAbort, { once: true });
|
|
473
|
-
const timer = setTimeout(() => fail(new CliError("timeout", `${provider.name} sign-in timed out`, { reason: "oauth.timeout" })), options.timeoutMs ?? DEFAULT_TIMEOUT_MS);
|
|
474
|
-
try {
|
|
475
|
-
await new Promise((resolve2, reject) => {
|
|
476
|
-
server.once("error", reject);
|
|
477
|
-
server.listen(0, "127.0.0.1", resolve2);
|
|
478
|
-
});
|
|
479
|
-
const address = server.address();
|
|
480
|
-
if (!address || typeof address === "string")
|
|
481
|
-
throw new CliError("configuration_error", "could not start the local sign-in listener");
|
|
482
|
-
if (server6) {
|
|
483
|
-
server6.on("error", () => {
|
|
484
|
-
});
|
|
485
|
-
await new Promise((resolve2) => {
|
|
486
|
-
server6.once("error", () => resolve2());
|
|
487
|
-
server6.listen(address.port, "::1", () => resolve2());
|
|
488
|
-
});
|
|
489
|
-
}
|
|
490
|
-
const random = randomBytes(32).toString("base64url");
|
|
491
|
-
const relay = provider.redirect.kind === "relay";
|
|
492
|
-
state = relay ? `${address.port}.${random}` : random;
|
|
493
|
-
const redirectUri = provider.redirect.kind === "relay" ? provider.redirect.url : `http://${localhost ? "localhost" : "127.0.0.1"}:${address.port}/callback`;
|
|
494
|
-
const url = new URL(provider.authorizeUrl);
|
|
495
|
-
for (const [key, value] of Object.entries({
|
|
496
|
-
...provider.authorizeParams,
|
|
497
|
-
response_type: "code",
|
|
498
|
-
client_id: provider.client.clientId,
|
|
499
|
-
redirect_uri: redirectUri,
|
|
500
|
-
...options.scopes.length ? { scope: options.scopes.join(" ") } : {},
|
|
501
|
-
state,
|
|
502
|
-
code_challenge: codeChallenge,
|
|
503
|
-
code_challenge_method: "S256"
|
|
504
|
-
}))
|
|
505
|
-
url.searchParams.set(key, value);
|
|
506
|
-
options.showUrl?.(url.toString());
|
|
507
|
-
options.readPaste?.(paste.signal).then((text4) => {
|
|
508
|
-
if (settled)
|
|
509
|
-
return;
|
|
510
|
-
const query = queryOf(text4);
|
|
511
|
-
if (query.get("state") !== state || !query.get("code") && !query.get("error"))
|
|
512
|
-
fail(new CliError("authentication_error", "the pasted sign-in result does not match this sign-in", {
|
|
513
|
-
reason: "oauth.mismatch"
|
|
514
|
-
}));
|
|
515
|
-
else
|
|
516
|
-
settle(query);
|
|
517
|
-
}).catch(() => {
|
|
518
|
-
});
|
|
519
|
-
void Promise.resolve().then(() => options.openBrowser(url.toString())).catch(() => {
|
|
520
|
-
if (!options.readPaste && !options.showUrl)
|
|
521
|
-
fail(new CliError("configuration_error", "could not open the browser, and no sign-in link can be shown"));
|
|
522
|
-
});
|
|
523
|
-
return { code: await code, redirectUri, codeVerifier };
|
|
524
|
-
} finally {
|
|
525
|
-
clearTimeout(timer);
|
|
526
|
-
options.signal?.removeEventListener("abort", onAbort);
|
|
527
|
-
paste.abort();
|
|
528
|
-
for (const each of server6 ? [server, server6] : [server]) {
|
|
529
|
-
each.closeAllConnections();
|
|
530
|
-
if (each.listening)
|
|
531
|
-
await new Promise((resolve2) => each.close(() => resolve2()));
|
|
532
|
-
}
|
|
533
|
-
}
|
|
534
|
-
}, "authorize");
|
|
535
|
-
|
|
536
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.691.0_@wirecat+cli-base@0.113.0_commander@15.0.0_esbuild@0.28.2_typ_9a2e508bb6f63e7e29f0d776540ec8fd/node_modules/@wirecat/cli-core/dist/oauth/keeper.js
|
|
537
|
-
import { createHash as createHash2 } from "node:crypto";
|
|
538
|
-
import { join } from "node:path";
|
|
539
|
-
import { setTimeout as delay } from "node:timers/promises";
|
|
540
|
-
|
|
541
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.691.0_@wirecat+cli-base@0.113.0_commander@15.0.0_esbuild@0.28.2_typ_9a2e508bb6f63e7e29f0d776540ec8fd/node_modules/@wirecat/cli-core/dist/oauth/requests.js
|
|
542
|
-
var REQUEST_LIMIT_MS = 3e4;
|
|
543
|
-
var TOKEN_LOG_EVENT = "oauth.token";
|
|
544
|
-
var object = /* @__PURE__ */ __name((value) => {
|
|
545
|
-
if (typeof value !== "object" || value === null || Array.isArray(value))
|
|
546
|
-
throw new Error("not an object");
|
|
547
|
-
return value;
|
|
548
|
-
}, "object");
|
|
549
|
-
var requestSignal = /* @__PURE__ */ __name((deadline, signal) => signal ? AbortSignal.any([signal, deadline]) : deadline, "requestSignal");
|
|
550
|
-
var cancelledBy = /* @__PURE__ */ __name((signal) => {
|
|
551
|
-
if (!signal?.aborted)
|
|
552
|
-
return;
|
|
553
|
-
throw isCliError(signal.reason) ? signal.reason : new CliError("cancelled", "sign-in was cancelled");
|
|
554
|
-
}, "cancelledBy");
|
|
555
|
-
var TRANSIENT = /* @__PURE__ */ new Set([
|
|
556
|
-
"EAI_AGAIN",
|
|
557
|
-
"ENOTFOUND",
|
|
558
|
-
"ECONNRESET",
|
|
559
|
-
"ECONNREFUSED",
|
|
560
|
-
"ETIMEDOUT",
|
|
561
|
-
"EPIPE",
|
|
562
|
-
"UND_ERR_SOCKET"
|
|
563
|
-
]);
|
|
564
|
-
var ATTEMPTS = 3;
|
|
565
|
-
var transientNetworkError = /* @__PURE__ */ __name((error) => {
|
|
566
|
-
if (isCliError(error))
|
|
567
|
-
return error.code === "network_error";
|
|
568
|
-
for (let at2 = error, depth = 0; at2 instanceof Error && depth < 4; at2 = at2.cause, depth++) {
|
|
569
|
-
const code = at2.code;
|
|
570
|
-
if (typeof code === "string" && TRANSIENT.has(code))
|
|
571
|
-
return true;
|
|
572
|
-
}
|
|
573
|
-
return false;
|
|
574
|
-
}, "transientNetworkError");
|
|
575
|
-
var post = /* @__PURE__ */ __name(async (url, body, context, deadline) => {
|
|
576
|
-
const signal = requestSignal(deadline, context.signal);
|
|
577
|
-
for (let attempt = 1; ; attempt++) {
|
|
578
|
-
cancelledBy(context.signal);
|
|
579
|
-
try {
|
|
580
|
-
return await context.fetch(url, {
|
|
581
|
-
method: "POST",
|
|
582
|
-
headers: { "content-type": "application/x-www-form-urlencoded", accept: "application/json" },
|
|
583
|
-
body,
|
|
584
|
-
signal,
|
|
585
|
-
redirect: "error"
|
|
586
|
-
});
|
|
587
|
-
} catch (error) {
|
|
588
|
-
cancelledBy(context.signal);
|
|
589
|
-
if (attempt >= ATTEMPTS || signal.aborted || !transientNetworkError(error))
|
|
590
|
-
return void 0;
|
|
591
|
-
const waited = await realSleep(500 * attempt, signal).then(() => true, () => false);
|
|
592
|
-
cancelledBy(context.signal);
|
|
593
|
-
if (!waited)
|
|
594
|
-
return void 0;
|
|
595
|
-
}
|
|
596
|
-
}
|
|
597
|
-
}, "post");
|
|
598
|
-
var clientFields = /* @__PURE__ */ __name(({ client }) => ({
|
|
599
|
-
client_id: client.clientId,
|
|
600
|
-
...client.clientSecret ? { client_secret: client.clientSecret } : {}
|
|
601
|
-
}), "clientFields");
|
|
602
|
-
var requestTokens = /* @__PURE__ */ __name((provider, params, context) => withTimeLimit(REQUEST_LIMIT_MS, (deadline) => exchangeTokens(provider, params, context, deadline)), "requestTokens");
|
|
603
|
-
var exchangeTokens = /* @__PURE__ */ __name(async (provider, params, context, deadline) => {
|
|
604
|
-
const operation = params.grant_type ?? "unknown";
|
|
605
|
-
const record2 = /* @__PURE__ */ __name((level, fields) => context.log?.[level]({ event: TOKEN_LOG_EVENT, provider: provider.id, operation, pid: process.pid, ...fields }), "record");
|
|
606
|
-
const again = `run ${context.signInCommand} again`;
|
|
607
|
-
const response = await post(provider.tokenUrl, new URLSearchParams({ ...params, ...clientFields(context) }), context, deadline);
|
|
608
|
-
if (!response) {
|
|
609
|
-
record2("warn", { outcome: "no_response" });
|
|
610
|
-
throw new CliError("outcome_unknown", `${provider.name} token request did not finish; ${again} if it keeps failing`, {
|
|
611
|
-
reason: "oauth.no-response"
|
|
612
|
-
});
|
|
613
|
-
}
|
|
614
|
-
if (!response.ok) {
|
|
615
|
-
record2("warn", { outcome: "rejected", status: response.status });
|
|
616
|
-
if (response.status === 429 || response.status >= 500)
|
|
617
|
-
throw new CliError("provider_unavailable", `${provider.name} token request failed (HTTP ${response.status})`, {
|
|
618
|
-
status: response.status,
|
|
619
|
-
retryable: true,
|
|
620
|
-
reason: "oauth.unavailable"
|
|
621
|
-
});
|
|
622
|
-
throw new CliError("authentication_error", `${provider.name} sign-in was refused (HTTP ${response.status}); ${again}`, {
|
|
623
|
-
status: response.status,
|
|
624
|
-
reason: "oauth.expired"
|
|
625
|
-
});
|
|
626
|
-
}
|
|
627
|
-
let body;
|
|
628
|
-
try {
|
|
629
|
-
body = object(await response.json());
|
|
630
|
-
} catch {
|
|
631
|
-
record2("error", { outcome: "unreadable_response", status: response.status });
|
|
632
|
-
throw new CliError("invalid_response", `${provider.name} returned an unreadable token response; ${again}`, {
|
|
633
|
-
reason: "oauth.invalid-response"
|
|
634
|
-
});
|
|
635
|
-
}
|
|
636
|
-
const previous = context.previous;
|
|
637
|
-
const refreshToken = typeof body.refresh_token === "string" && body.refresh_token ? body.refresh_token : previous?.refreshToken;
|
|
638
|
-
const expiresIn = body.expires_in;
|
|
639
|
-
if (typeof body.access_token !== "string" || !body.access_token || expiresIn !== void 0 && (typeof expiresIn !== "number" || !Number.isFinite(expiresIn) || expiresIn <= 0) || body.scope !== void 0 && typeof body.scope !== "string" || body.token_type !== void 0 && typeof body.token_type !== "string") {
|
|
640
|
-
record2("error", { outcome: "invalid_response", status: response.status });
|
|
641
|
-
throw new CliError("invalid_response", `${provider.name} returned an invalid token response; ${again}`, {
|
|
642
|
-
reason: "oauth.invalid-response"
|
|
643
|
-
});
|
|
644
|
-
}
|
|
645
|
-
if (!refreshToken) {
|
|
646
|
-
record2("error", { outcome: "no_refresh_token", status: response.status });
|
|
647
|
-
throw new CliError("authentication_error", `${provider.name} returned no offline refresh token; ${again}`, {
|
|
648
|
-
reason: "oauth.failed"
|
|
649
|
-
});
|
|
650
|
-
}
|
|
651
|
-
const scopes = typeof body.scope === "string" ? body.scope.split(/\s+/).filter(Boolean) : previous?.scopes ?? [];
|
|
652
|
-
const tokenType = typeof body.token_type === "string" ? body.token_type : previous?.tokenType;
|
|
653
|
-
record2("info", {
|
|
654
|
-
outcome: "received",
|
|
655
|
-
status: response.status,
|
|
656
|
-
...previous ? { rotated: refreshToken !== previous.refreshToken } : {}
|
|
657
|
-
});
|
|
658
|
-
return {
|
|
659
|
-
accessToken: body.access_token,
|
|
660
|
-
refreshToken,
|
|
661
|
-
...typeof expiresIn === "number" ? { expiresAt: context.now() + expiresIn * 1e3 } : {},
|
|
662
|
-
scopes,
|
|
663
|
-
...tokenType ? { tokenType } : {}
|
|
664
|
-
};
|
|
665
|
-
}, "exchangeTokens");
|
|
666
|
-
var alreadyRevoked = /* @__PURE__ */ __name(async (response) => {
|
|
667
|
-
if (response.status !== 400)
|
|
668
|
-
return false;
|
|
669
|
-
try {
|
|
670
|
-
return object(JSON.parse(await response.text())).error === "invalid_token";
|
|
671
|
-
} catch {
|
|
672
|
-
return false;
|
|
673
|
-
}
|
|
674
|
-
}, "alreadyRevoked");
|
|
675
|
-
var revokeToken = /* @__PURE__ */ __name(async (provider, tokens, context) => {
|
|
676
|
-
if (provider.revoke)
|
|
677
|
-
return provider.revoke(tokens, context);
|
|
678
|
-
if (!provider.revokeUrl)
|
|
679
|
-
throw new CliError("validation_error", `${provider.name} declares no way to revoke a sign-in`);
|
|
680
|
-
const { revokeUrl } = provider;
|
|
681
|
-
const form = new URLSearchParams({ token: tokens.refreshToken, ...clientFields(context) });
|
|
682
|
-
const { response, gone } = await withTimeLimit(REQUEST_LIMIT_MS, async (deadline) => {
|
|
683
|
-
const response2 = await post(revokeUrl, form, context, deadline);
|
|
684
|
-
return { response: response2, gone: response2 ? await alreadyRevoked(response2) : false };
|
|
685
|
-
});
|
|
686
|
-
const done = response?.ok || gone;
|
|
687
|
-
context.log?.[done ? "info" : "warn"]({
|
|
688
|
-
event: TOKEN_LOG_EVENT,
|
|
689
|
-
provider: provider.id,
|
|
690
|
-
operation: "revoke",
|
|
691
|
-
pid: process.pid,
|
|
692
|
-
outcome: response?.ok ? "revoked" : gone ? "already_revoked" : response ? "rejected" : "no_response",
|
|
693
|
-
...response ? { status: response.status } : {}
|
|
694
|
-
});
|
|
695
|
-
if (!done)
|
|
696
|
-
throw new CliError("outcome_unknown", `${provider.name} did not confirm the revoke`, {
|
|
697
|
-
reason: "oauth.revoke-failed",
|
|
698
|
-
...response ? { status: response.status } : {}
|
|
699
|
-
});
|
|
700
|
-
}, "revokeToken");
|
|
701
|
-
|
|
702
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.691.0_@wirecat+cli-base@0.113.0_commander@15.0.0_esbuild@0.28.2_typ_9a2e508bb6f63e7e29f0d776540ec8fd/node_modules/@wirecat/cli-core/dist/oauth/keeper.js
|
|
703
|
-
var inFlight = /* @__PURE__ */ new Map();
|
|
704
|
-
var refreshedInMemory = /* @__PURE__ */ new Map();
|
|
705
|
-
var tokenKeeper = /* @__PURE__ */ __name((options) => {
|
|
706
|
-
const { provider, storage, signal, log } = options;
|
|
707
|
-
const now = options.now ?? Date.now;
|
|
708
|
-
const fresh = /* @__PURE__ */ __name((tokens2) => Boolean(tokens2.accessToken) && tokens2.expiresAt !== void 0 && tokens2.expiresAt > now() + (options.freshForMs ?? 6e4), "fresh");
|
|
709
|
-
const lockPath = join(options.lockDir, `oauth-${createHash2("sha256").update(storage.key).digest("hex").slice(0, 16)}.lock`);
|
|
710
|
-
const clientOf = /* @__PURE__ */ __name((stored) => {
|
|
711
|
-
const saved = stored?.client;
|
|
712
|
-
if (!saved || saved.clientSecret || saved.clientId !== provider.client.clientId)
|
|
713
|
-
return saved ?? provider.client;
|
|
714
|
-
return provider.client;
|
|
715
|
-
}, "clientOf");
|
|
716
|
-
const context = /* @__PURE__ */ __name((client, previous) => ({
|
|
717
|
-
fetch: options.fetch,
|
|
718
|
-
client,
|
|
719
|
-
now,
|
|
720
|
-
signInCommand: options.signInCommand,
|
|
721
|
-
...signal ? { signal } : {},
|
|
722
|
-
...log ? { log } : {},
|
|
723
|
-
...previous ? { previous } : {}
|
|
724
|
-
}), "context");
|
|
725
|
-
const exchange2 = /* @__PURE__ */ __name((params, ctx) => provider.exchange ? provider.exchange(params, ctx) : requestTokens(provider, params, ctx), "exchange");
|
|
726
|
-
const notSignedIn = /* @__PURE__ */ __name(() => new CliError("authentication_error", `not signed in to ${provider.name}; run ${options.signInCommand}`, {
|
|
727
|
-
reason: "session.missing"
|
|
728
|
-
}), "notSignedIn");
|
|
729
|
-
const busy = /* @__PURE__ */ __name((error) => isCliError(error) && error.details.reason === "file.locked", "busy");
|
|
730
|
-
const acquire = /* @__PURE__ */ __name(async () => {
|
|
731
|
-
const started = performance.now();
|
|
732
|
-
let waiting = false;
|
|
733
|
-
for (; ; ) {
|
|
734
|
-
try {
|
|
735
|
-
return await acquireLock(lockPath, signal ? { signal } : {});
|
|
736
|
-
} catch (error) {
|
|
737
|
-
if (!busy(error))
|
|
738
|
-
throw error;
|
|
739
|
-
if (!waiting) {
|
|
740
|
-
waiting = true;
|
|
741
|
-
log?.info({
|
|
742
|
-
event: TOKEN_LOG_EVENT,
|
|
743
|
-
provider: provider.id,
|
|
744
|
-
operation: "lock",
|
|
745
|
-
outcome: "waiting",
|
|
746
|
-
pid: process.pid
|
|
747
|
-
});
|
|
748
|
-
}
|
|
749
|
-
if (performance.now() - started > (options.lockWaitMs ?? 45e3))
|
|
750
|
-
throw new CliError("provider_unavailable", `another process holds this ${provider.name} sign-in; retry`, {
|
|
751
|
-
reason: "oauth.locked",
|
|
752
|
-
retryable: true
|
|
753
|
-
});
|
|
754
|
-
await delay(options.lockRetryMs ?? 50, void 0, signal ? { signal } : {}).catch(() => {
|
|
755
|
-
throw new CliError("cancelled", `${provider.name} sign-in was cancelled`);
|
|
756
|
-
});
|
|
757
|
-
}
|
|
758
|
-
}
|
|
759
|
-
}, "acquire");
|
|
760
|
-
const locked = /* @__PURE__ */ __name(async (work) => {
|
|
761
|
-
const lock = await acquire();
|
|
762
|
-
try {
|
|
763
|
-
return await work();
|
|
764
|
-
} finally {
|
|
765
|
-
await lock.release().catch(() => {
|
|
766
|
-
});
|
|
767
|
-
}
|
|
768
|
-
}, "locked");
|
|
769
|
-
const shared2 = /* @__PURE__ */ __name((work) => {
|
|
770
|
-
const running = inFlight.get(lockPath);
|
|
771
|
-
if (running)
|
|
772
|
-
return running;
|
|
773
|
-
const started = locked(work).finally(() => inFlight.delete(lockPath));
|
|
774
|
-
inFlight.set(lockPath, started);
|
|
775
|
-
return started;
|
|
776
|
-
}, "shared");
|
|
777
|
-
const remembered = /* @__PURE__ */ __name((saved) => {
|
|
778
|
-
const kept = refreshedInMemory.get(lockPath);
|
|
779
|
-
return kept && fresh(kept) && kept.refreshToken === saved.refreshToken ? kept : void 0;
|
|
780
|
-
}, "remembered");
|
|
781
|
-
const forget = /* @__PURE__ */ __name(() => refreshedInMemory.delete(lockPath), "forget");
|
|
782
|
-
let answered;
|
|
783
|
-
const answer2 = /* @__PURE__ */ __name((given) => {
|
|
784
|
-
answered = given;
|
|
785
|
-
return given;
|
|
786
|
-
}, "answer");
|
|
787
|
-
const tokens = /* @__PURE__ */ __name(async ({ refresh = false } = {}) => {
|
|
788
|
-
const seen = storage.read();
|
|
789
|
-
if (!seen)
|
|
790
|
-
throw notSignedIn();
|
|
791
|
-
if (!refresh) {
|
|
792
|
-
const kept = remembered(seen.tokens);
|
|
793
|
-
if (kept)
|
|
794
|
-
return answer2(kept);
|
|
795
|
-
if (fresh(seen.tokens))
|
|
796
|
-
return answer2(seen.tokens);
|
|
797
|
-
}
|
|
798
|
-
const refused2 = answered ?? remembered(seen.tokens) ?? seen.tokens;
|
|
799
|
-
return answer2(await shared2(async () => {
|
|
800
|
-
const current = storage.read();
|
|
801
|
-
if (!current)
|
|
802
|
-
throw notSignedIn();
|
|
803
|
-
const latest = remembered(current.tokens) ?? current.tokens;
|
|
804
|
-
if (refresh) {
|
|
805
|
-
if (latest.accessToken !== refused2.accessToken && fresh(latest))
|
|
806
|
-
return latest;
|
|
807
|
-
} else {
|
|
808
|
-
if (latest !== current.tokens)
|
|
809
|
-
return latest;
|
|
810
|
-
if (fresh(current.tokens) || current.tokens.refreshToken !== seen.tokens.refreshToken)
|
|
811
|
-
return current.tokens;
|
|
812
|
-
}
|
|
813
|
-
if (storage.moved && storage.rotating)
|
|
814
|
-
throw new CliError("authentication_error", `the sign-in to ${provider.name} needs a refresh, which a run with moved folders never makes: the provider rotates its refresh token, and the owner's own sign-in would keep a dead one; run this in the normal run, or sign in again there`, { reason: "oauth.moved-rotating" });
|
|
815
|
-
const client = clientOf(current);
|
|
816
|
-
const refreshed = await exchange2({ grant_type: "refresh_token", refresh_token: current.tokens.refreshToken }, context(client, current.tokens));
|
|
817
|
-
if (storage.moved && refreshed.refreshToken === current.tokens.refreshToken)
|
|
818
|
-
refreshedInMemory.set(lockPath, refreshed);
|
|
819
|
-
else
|
|
820
|
-
storage.write({ tokens: refreshed, client });
|
|
821
|
-
return refreshed;
|
|
822
|
-
}));
|
|
823
|
-
}, "tokens");
|
|
824
|
-
return {
|
|
825
|
-
tokens,
|
|
826
|
-
accessToken: /* @__PURE__ */ __name(async (tokensOptions) => {
|
|
827
|
-
const current = await tokens(tokensOptions);
|
|
828
|
-
if (!current.accessToken)
|
|
829
|
-
throw notSignedIn();
|
|
830
|
-
return current.accessToken;
|
|
831
|
-
}, "accessToken"),
|
|
832
|
-
signIn: /* @__PURE__ */ __name(async ({ accept, ...authorizeOptions }) => {
|
|
833
|
-
storage.probe();
|
|
834
|
-
const authorization = await authorize({ ...authorizeOptions, provider, ...signal ? { signal } : {} });
|
|
835
|
-
const client = provider.client;
|
|
836
|
-
const received = await exchange2({
|
|
837
|
-
grant_type: "authorization_code",
|
|
838
|
-
code: authorization.code,
|
|
839
|
-
redirect_uri: authorization.redirectUri,
|
|
840
|
-
code_verifier: authorization.codeVerifier
|
|
841
|
-
}, context(client));
|
|
842
|
-
const extra = await accept?.(received) ?? void 0;
|
|
843
|
-
await locked(async () => {
|
|
844
|
-
forget();
|
|
845
|
-
storage.write({ tokens: received, client, ...extra ? { extra } : {} }, { signIn: true });
|
|
846
|
-
});
|
|
847
|
-
return { scopes: received.scopes };
|
|
848
|
-
}, "signIn"),
|
|
849
|
-
save: /* @__PURE__ */ __name((saved, extra) => locked(async () => {
|
|
850
|
-
forget();
|
|
851
|
-
storage.write({ tokens: saved, client: clientOf(storage.read()), ...extra ? { extra } : {} }, { signIn: true });
|
|
852
|
-
}), "save"),
|
|
853
|
-
signOut: /* @__PURE__ */ __name(({ revoke = false } = {}) => locked(async () => {
|
|
854
|
-
forget();
|
|
855
|
-
const current = storage.read();
|
|
856
|
-
let revoked = false;
|
|
857
|
-
if (revoke && current) {
|
|
858
|
-
await revokeToken(provider, current.tokens, context(clientOf(current)));
|
|
859
|
-
revoked = true;
|
|
860
|
-
}
|
|
861
|
-
return { revoked, removed: storage.remove() };
|
|
862
|
-
}), "signOut")
|
|
863
|
-
};
|
|
864
|
-
}, "tokenKeeper");
|
|
865
|
-
|
|
866
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.691.0_@wirecat+cli-base@0.113.0_commander@15.0.0_esbuild@0.28.2_typ_9a2e508bb6f63e7e29f0d776540ec8fd/node_modules/@wirecat/cli-core/dist/oauth/storage.js
|
|
867
|
-
var invalid = /* @__PURE__ */ __name(() => new CliError("authentication_error", "the saved sign-in cannot be read; sign in again", { reason: "oauth.invalid" }), "invalid");
|
|
868
|
-
var parse = /* @__PURE__ */ __name((raw) => {
|
|
869
|
-
let value;
|
|
870
|
-
try {
|
|
871
|
-
value = JSON.parse(raw);
|
|
872
|
-
} catch {
|
|
873
|
-
throw invalid();
|
|
874
|
-
}
|
|
875
|
-
if (typeof value !== "object" || value === null || Array.isArray(value))
|
|
876
|
-
throw invalid();
|
|
877
|
-
return value;
|
|
878
|
-
}, "parse");
|
|
879
|
-
var text2 = /* @__PURE__ */ __name((value) => typeof value === "string" && value ? value : void 0, "text");
|
|
880
|
-
var finite = /* @__PURE__ */ __name((value) => typeof value === "number" && Number.isFinite(value) ? value : void 0, "finite");
|
|
881
|
-
var previousOf = /* @__PURE__ */ __name((raw) => {
|
|
882
|
-
if (raw === void 0)
|
|
883
|
-
return {};
|
|
884
|
-
try {
|
|
885
|
-
return parse(raw);
|
|
886
|
-
} catch {
|
|
887
|
-
return {};
|
|
888
|
-
}
|
|
889
|
-
}, "previousOf");
|
|
890
|
-
var defined = /* @__PURE__ */ __name((value) => Object.fromEntries(Object.entries(value).filter(([, field]) => field !== void 0)), "defined");
|
|
891
|
-
var oauthAccount = /* @__PURE__ */ __name((providerId, profile) => {
|
|
892
|
-
if (!profile.trim())
|
|
893
|
-
throw new CliError("validation_error", "name a profile: a sign-in always belongs to one", {
|
|
894
|
-
reason: "profile.missing"
|
|
895
|
-
});
|
|
896
|
-
return `oauth:${providerId}:${profile}`;
|
|
897
|
-
}, "oauthAccount");
|
|
898
|
-
var standardCodec = /* @__PURE__ */ __name((providerId) => ({
|
|
899
|
-
decode: /* @__PURE__ */ __name((raw) => {
|
|
900
|
-
const value = parse(raw);
|
|
901
|
-
const refreshToken = text2(value.refreshToken);
|
|
902
|
-
const clientId = text2(value.clientId);
|
|
903
|
-
if (value.version !== 1 || value.provider !== providerId || !refreshToken || !clientId)
|
|
904
|
-
throw invalid();
|
|
905
|
-
if (!Array.isArray(value.scopes) || !value.scopes.every((scope) => typeof scope === "string"))
|
|
906
|
-
throw invalid();
|
|
907
|
-
const source = text2(value.clientSource);
|
|
908
|
-
return {
|
|
909
|
-
client: defined({ clientId, clientSecret: text2(value.clientSecret), source }),
|
|
910
|
-
tokens: defined({
|
|
911
|
-
accessToken: text2(value.accessToken),
|
|
912
|
-
refreshToken,
|
|
913
|
-
expiresAt: finite(value.expiresAt),
|
|
914
|
-
scopes: value.scopes,
|
|
915
|
-
tokenType: text2(value.tokenType)
|
|
916
|
-
})
|
|
917
|
-
};
|
|
918
|
-
}, "decode"),
|
|
919
|
-
encode: /* @__PURE__ */ __name(({ tokens, client, previous, extra }) => JSON.stringify(defined({
|
|
920
|
-
...previousOf(previous),
|
|
921
|
-
...extra,
|
|
922
|
-
version: 1,
|
|
923
|
-
provider: providerId,
|
|
924
|
-
clientId: client.clientId,
|
|
925
|
-
// Only WireCat's secret, which is public: a later release may ship another default app, and a refresh needs
|
|
926
|
-
// the secret of the app that signed in. An owner's own secret stays where the owner keeps it.
|
|
927
|
-
clientSecret: client.source === "constants" ? client.clientSecret : void 0,
|
|
928
|
-
clientSource: client.source,
|
|
929
|
-
accessToken: tokens.accessToken,
|
|
930
|
-
refreshToken: tokens.refreshToken,
|
|
931
|
-
expiresAt: tokens.expiresAt,
|
|
932
|
-
scopes: tokens.scopes,
|
|
933
|
-
tokenType: tokens.tokenType
|
|
934
|
-
})), "encode")
|
|
935
|
-
}), "standardCodec");
|
|
936
|
-
var googleStandard = standardCodec("google");
|
|
937
|
-
var accountTokenCodec = /* @__PURE__ */ __name((providerId) => {
|
|
938
|
-
const standard = standardCodec(providerId);
|
|
939
|
-
return {
|
|
940
|
-
rotating: true,
|
|
941
|
-
decode: /* @__PURE__ */ __name((raw) => {
|
|
942
|
-
const stored = standard.decode(raw);
|
|
943
|
-
const value = parse(raw);
|
|
944
|
-
const clientSecret = text2(value.clientSecret);
|
|
945
|
-
const host = text2(value.host);
|
|
946
|
-
const userId = text2(value.userId);
|
|
947
|
-
if (!host || !userId || !clientSecret)
|
|
948
|
-
throw invalid();
|
|
949
|
-
return { ...stored, client: { ...stored.client, clientSecret }, account: { host, userId } };
|
|
950
|
-
}, "decode"),
|
|
951
|
-
encode: /* @__PURE__ */ __name((input) => {
|
|
952
|
-
const entry = parse(standard.encode(input));
|
|
953
|
-
const from = input.signIn ? input.extra ?? {} : entry;
|
|
954
|
-
if (!input.client.clientSecret || typeof from.host !== "string" || typeof from.userId !== "string")
|
|
955
|
-
throw new CliError("configuration_error", "an account-bound sign-in needs the app's secret, its host and user");
|
|
956
|
-
entry.clientSecret = input.client.clientSecret;
|
|
957
|
-
return JSON.stringify(entry);
|
|
958
|
-
}, "encode")
|
|
959
|
-
};
|
|
960
|
-
}, "accountTokenCodec");
|
|
961
|
-
var keyringFailure = /* @__PURE__ */ __name((thrown, secret) => {
|
|
962
|
-
const failure = new CliError("configuration_error", "could not reach the saved sign-in; use an available keyring or file storage", { reason: "oauth.not-saved" });
|
|
963
|
-
const words = thrown instanceof Error ? thrown.message : String(thrown);
|
|
964
|
-
failure.cause = new Error(secret ? words.replaceAll(secret, "[secret]") : words);
|
|
965
|
-
return failure;
|
|
966
|
-
}, "keyringFailure");
|
|
967
|
-
var credentialStorage = /* @__PURE__ */ __name((options) => {
|
|
968
|
-
if (!options.credentials.keyring)
|
|
969
|
-
throw new CliError("configuration_error", "a sign-in store needs its keyring passed in, never a default");
|
|
970
|
-
const credentials = new Credentials(options.credentials);
|
|
971
|
-
const { account: account2, codec } = options;
|
|
972
|
-
const moved = options.credentials.isolated === true || options.credentials.keyring === systemKeyring && isMovedRun({ appName: options.credentials.service, env: options.credentials.env ?? process.env });
|
|
973
|
-
const service = keyringService(options.credentials.service, options.credentials.configDir, options.credentials.isolated);
|
|
974
|
-
const raw = /* @__PURE__ */ __name((name) => {
|
|
975
|
-
try {
|
|
976
|
-
return credentials.read(name)?.secret;
|
|
977
|
-
} catch (error) {
|
|
978
|
-
if (error instanceof CliError)
|
|
979
|
-
throw error;
|
|
980
|
-
throw keyringFailure(error);
|
|
981
|
-
}
|
|
982
|
-
}, "raw");
|
|
983
|
-
const fallsBack = options.credentials.storage !== "keyring";
|
|
984
|
-
const replaced = /* @__PURE__ */ __name((name) => {
|
|
985
|
-
try {
|
|
986
|
-
return raw(name);
|
|
987
|
-
} catch (error) {
|
|
988
|
-
if (fallsBack && error instanceof CliError && error.details.reason === "keyring.unreachable")
|
|
989
|
-
return void 0;
|
|
990
|
-
throw error;
|
|
991
|
-
}
|
|
992
|
-
}, "replaced");
|
|
993
|
-
const save = /* @__PURE__ */ __name((value, writeOptions) => {
|
|
994
|
-
try {
|
|
995
|
-
credentials.write(account2, value, writeOptions);
|
|
996
|
-
} catch (error) {
|
|
997
|
-
throw keyringFailure(error, value);
|
|
998
|
-
}
|
|
999
|
-
}, "save");
|
|
1000
|
-
const current = /* @__PURE__ */ __name(() => {
|
|
1001
|
-
const own = raw(account2);
|
|
1002
|
-
if (own !== void 0)
|
|
1003
|
-
return own;
|
|
1004
|
-
for (const legacy of options.legacyAccounts ?? []) {
|
|
1005
|
-
const found = raw(legacy);
|
|
1006
|
-
if (found === void 0)
|
|
1007
|
-
continue;
|
|
1008
|
-
codec.decode(found);
|
|
1009
|
-
if (!moved)
|
|
1010
|
-
save(found);
|
|
1011
|
-
return found;
|
|
1012
|
-
}
|
|
1013
|
-
return void 0;
|
|
1014
|
-
}, "current");
|
|
1015
|
-
return {
|
|
1016
|
-
key: `${service}\0${account2}`,
|
|
1017
|
-
moved,
|
|
1018
|
-
...codec.rotating ? { rotating: true } : {},
|
|
1019
|
-
probe: /* @__PURE__ */ __name(() => {
|
|
1020
|
-
replaced(account2);
|
|
1021
|
-
}, "probe"),
|
|
1022
|
-
read: /* @__PURE__ */ __name(() => {
|
|
1023
|
-
const value = current();
|
|
1024
|
-
return value === void 0 ? void 0 : codec.decode(value);
|
|
1025
|
-
}, "read"),
|
|
1026
|
-
write: /* @__PURE__ */ __name((input, writeOptions) => save(codec.encode({ ...input, previous: replaced(account2), ...writeOptions?.signIn ? { signIn: true } : {} }), writeOptions), "write"),
|
|
1027
|
-
remove: /* @__PURE__ */ __name(() => {
|
|
1028
|
-
try {
|
|
1029
|
-
return credentials.remove(account2);
|
|
1030
|
-
} catch (error) {
|
|
1031
|
-
throw keyringFailure(error);
|
|
1032
|
-
}
|
|
1033
|
-
}, "remove")
|
|
1034
|
-
};
|
|
1035
|
-
}, "credentialStorage");
|
|
1036
|
-
|
|
1037
413
|
// dist/amo/json.js
|
|
1038
414
|
var isRecord = values_exports.isRaw;
|
|
1039
415
|
|
|
@@ -1042,10 +418,10 @@ var ACCOUNT_DOMAINS = ["amocrm.ru", "amocrm.com", "kommo.com"];
|
|
|
1042
418
|
var HOST = new RegExp(`^(?!www\\.)[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?\\.(${ACCOUNT_DOMAINS.join("|").replaceAll(".", "\\.")})$`);
|
|
1043
419
|
var accountOrigin = /* @__PURE__ */ __name((raw) => {
|
|
1044
420
|
const refused2 = /* @__PURE__ */ __name((why) => new CliError("validation_error", `--host takes the account's address, such as https://example.amocrm.ru or https://example.kommo.com: ${why}`, { reason: "account.malformed", param: "--host" }), "refused");
|
|
1045
|
-
const
|
|
421
|
+
const text3 = raw.trim();
|
|
1046
422
|
let url;
|
|
1047
423
|
try {
|
|
1048
|
-
url = new URL(/^[a-z]+:\/\//i.test(
|
|
424
|
+
url = new URL(/^[a-z]+:\/\//i.test(text3) ? text3 : `https://${text3}`);
|
|
1049
425
|
} catch {
|
|
1050
426
|
throw refused2("it is not an address");
|
|
1051
427
|
}
|
|
@@ -1079,6 +455,10 @@ var decodeSignIn = /* @__PURE__ */ __name((secret) => {
|
|
|
1079
455
|
// dist/amo/oauth.js
|
|
1080
456
|
var PROVIDER2 = "amocrm";
|
|
1081
457
|
var RELAY_URL = "https://wirecat.dev/webhooks/apps/amo-callback";
|
|
458
|
+
var CONNECT_ORIGIN = "https://connect.wirecat.dev";
|
|
459
|
+
var BUTTON_RELAY_URL = `${CONNECT_ORIGIN}/webhooks/apps/amo-callback`;
|
|
460
|
+
var CONNECT_PAGE_URL = `${CONNECT_ORIGIN}/connect/amo.html`;
|
|
461
|
+
var CLAIM_URL = `${CONNECT_ORIGIN}/api/amo/claim`;
|
|
1082
462
|
var REQUEST_MS = 3e4;
|
|
1083
463
|
var HINT = /^[\w .,:'`-]{1,200}$/;
|
|
1084
464
|
var account = accountTokenCodec(PROVIDER2);
|
|
@@ -1089,10 +469,11 @@ var appCodec = {
|
|
|
1089
469
|
const stored = account.decode(raw);
|
|
1090
470
|
const entry = JSON.parse(raw);
|
|
1091
471
|
const redirectUri = isRecord(entry) && typeof entry.redirectUri === "string" ? entry.redirectUri : RELAY_URL;
|
|
1092
|
-
return Object.assign(stored, { redirectUri });
|
|
472
|
+
return Object.assign(stored, { redirectUri, browser: isRecord(entry) && entry.browser === true });
|
|
1093
473
|
}, "decode")
|
|
1094
474
|
};
|
|
1095
475
|
var paths = /* @__PURE__ */ __name((env) => resolvePaths({ appName: IDENTITY.appName, prefix: IDENTITY.envPrefix, env }), "paths");
|
|
476
|
+
var lockDirOf = /* @__PURE__ */ __name((env) => paths(env).config, "lockDirOf");
|
|
1096
477
|
var credentialsOf = /* @__PURE__ */ __name((env, keyring, storage) => ({
|
|
1097
478
|
configDir: paths(env).config,
|
|
1098
479
|
service: IDENTITY.appName,
|
|
@@ -1224,7 +605,7 @@ var appAuthOf = /* @__PURE__ */ __name((options) => {
|
|
|
1224
605
|
storage,
|
|
1225
606
|
lockDir: paths(options.env).config,
|
|
1226
607
|
fetch: fetchFor(origin, options.fetch),
|
|
1227
|
-
signInCommand: `${IDENTITY.command} ${options.profile} session start --host ${origin} --client-id ${stored.client.clientId}`,
|
|
608
|
+
signInCommand: `${IDENTITY.command} ${options.profile} session start --host ${origin} ${stored.browser ? "--one-click" : `--client-id ${stored.client.clientId}`}`,
|
|
1228
609
|
...options.signal ? { signal: options.signal } : {}
|
|
1229
610
|
});
|
|
1230
611
|
return { origin, userId: stored.account.userId, accessToken: /* @__PURE__ */ __name((refresh) => keeper.accessToken({ refresh }), "accessToken") };
|
|
@@ -1232,7 +613,7 @@ var appAuthOf = /* @__PURE__ */ __name((options) => {
|
|
|
1232
613
|
|
|
1233
614
|
// dist/commands/account.js
|
|
1234
615
|
import { readFileSync } from "node:fs";
|
|
1235
|
-
import { join
|
|
616
|
+
import { join } from "node:path";
|
|
1236
617
|
|
|
1237
618
|
// dist/api-keys.js
|
|
1238
619
|
var PREFIX = "/api/v4/";
|
|
@@ -1405,9 +786,9 @@ var permissions = commandPermissions({
|
|
|
1405
786
|
extra: [.../* @__PURE__ */ new Set([...CRM_WRITE_KEYS, ...API_KEYS])],
|
|
1406
787
|
defaults: { ...CRM_WRITE_DEFAULTS, ...API_DEFAULTS }
|
|
1407
788
|
});
|
|
1408
|
-
var isAccount = /* @__PURE__ */ __name((
|
|
789
|
+
var isAccount = /* @__PURE__ */ __name((text3) => {
|
|
1409
790
|
try {
|
|
1410
|
-
accountOrigin(
|
|
791
|
+
accountOrigin(text3);
|
|
1411
792
|
return true;
|
|
1412
793
|
} catch {
|
|
1413
794
|
return false;
|
|
@@ -1471,7 +852,7 @@ var amoError = /* @__PURE__ */ __name((operation, status, body, { json, waitMs,
|
|
|
1471
852
|
}, "amoError");
|
|
1472
853
|
|
|
1473
854
|
// dist/amo/transport.js
|
|
1474
|
-
var
|
|
855
|
+
var DEFAULT_TIMEOUT_MS = 1e4;
|
|
1475
856
|
var LARGEST_ANSWER = 16 * 1024 * 1024;
|
|
1476
857
|
var LONGEST_PACE_WAIT_MS = 2e4;
|
|
1477
858
|
var REQUEST_MARGIN_MS = 1e3;
|
|
@@ -1510,7 +891,7 @@ var AmoTransport = class {
|
|
|
1510
891
|
#admin;
|
|
1511
892
|
constructor(options) {
|
|
1512
893
|
this.#signIn = options.signIn;
|
|
1513
|
-
this.#timeoutMs = options.timeoutMs ??
|
|
894
|
+
this.#timeoutMs = options.timeoutMs ?? DEFAULT_TIMEOUT_MS;
|
|
1514
895
|
this.#fetch = hostFetch({
|
|
1515
896
|
hosts: [new URL(options.signIn.origin).hostname],
|
|
1516
897
|
...options.fetch ? { fetch: options.fetch } : {},
|
|
@@ -1794,8 +1175,210 @@ var transportFor = /* @__PURE__ */ __name((command, signIn, events) => {
|
|
|
1794
1175
|
}, "transportFor");
|
|
1795
1176
|
var withAccount = /* @__PURE__ */ __name((command, body) => contextOf(command).run((events) => body(transportFor(command, signInOf(command), events))), "withAccount");
|
|
1796
1177
|
|
|
1178
|
+
// dist/amo/button.js
|
|
1179
|
+
import { randomBytes } from "node:crypto";
|
|
1180
|
+
import { createServer } from "node:http";
|
|
1181
|
+
var CONNECT_VARIABLE = `${IDENTITY.envPrefix}_CONNECT_URL`;
|
|
1182
|
+
var CALLBACK_MS = 6e5;
|
|
1183
|
+
var CLAIM_MS = 6e4;
|
|
1184
|
+
var CLAIM_PAUSES_MS = [500, 1e3, 2e3, 4e3];
|
|
1185
|
+
var REQUEST_MS2 = 3e4;
|
|
1186
|
+
var AMOCRM_HOST = /^[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?\.amocrm\.ru$/;
|
|
1187
|
+
var connectUrls = /* @__PURE__ */ __name((env) => {
|
|
1188
|
+
const given = env[CONNECT_VARIABLE]?.trim();
|
|
1189
|
+
if (!given)
|
|
1190
|
+
return { page: CONNECT_PAGE_URL, claim: CLAIM_URL };
|
|
1191
|
+
let url;
|
|
1192
|
+
try {
|
|
1193
|
+
url = new URL(given);
|
|
1194
|
+
} catch {
|
|
1195
|
+
url = void 0;
|
|
1196
|
+
}
|
|
1197
|
+
if (url?.protocol !== "https:" || url.username || url.password)
|
|
1198
|
+
throw new CliError("configuration_error", `${CONNECT_VARIABLE} must be an https address, such as https://connect.wirecat.dev`, {
|
|
1199
|
+
reason: "connect.url-invalid"
|
|
1200
|
+
});
|
|
1201
|
+
const { origin } = url;
|
|
1202
|
+
const moved = /* @__PURE__ */ __name((address) => `${origin}${new URL(address).pathname}`, "moved");
|
|
1203
|
+
return { page: moved(CONNECT_PAGE_URL), claim: moved(CLAIM_URL) };
|
|
1204
|
+
}, "connectUrls");
|
|
1205
|
+
var refuseKommo = /* @__PURE__ */ __name((origin) => {
|
|
1206
|
+
if (AMOCRM_HOST.test(new URL(origin).hostname))
|
|
1207
|
+
return;
|
|
1208
|
+
throw new CliError("validation_error", "the browser sign-in works only for amoCRM accounts at amocrm.ru for now; sign in to Kommo with a long-lived token or --client-id", { reason: "oauth.browser-amocrm-only", param: "--host" });
|
|
1209
|
+
}, "refuseKommo");
|
|
1210
|
+
var queryOf = /* @__PURE__ */ __name((text3) => {
|
|
1211
|
+
const trimmed = text3.trim();
|
|
1212
|
+
const start = trimmed.indexOf("?");
|
|
1213
|
+
return new URLSearchParams(start >= 0 ? trimmed.slice(start + 1).split("#")[0] : trimmed);
|
|
1214
|
+
}, "queryOf");
|
|
1215
|
+
var awaitRedirect = /* @__PURE__ */ __name(async (open2, steps, signal) => {
|
|
1216
|
+
if (signal?.aborted)
|
|
1217
|
+
throw new CliError("cancelled", "the amoCRM sign-in was cancelled");
|
|
1218
|
+
const paste = new AbortController();
|
|
1219
|
+
let state = "";
|
|
1220
|
+
let settled = false;
|
|
1221
|
+
let accept = /* @__PURE__ */ __name(() => {
|
|
1222
|
+
}, "accept");
|
|
1223
|
+
let fail = /* @__PURE__ */ __name(() => {
|
|
1224
|
+
}, "fail");
|
|
1225
|
+
const redirect = new Promise((resolve2, reject) => {
|
|
1226
|
+
accept = /* @__PURE__ */ __name((query) => {
|
|
1227
|
+
settled = true;
|
|
1228
|
+
resolve2(query);
|
|
1229
|
+
}, "accept");
|
|
1230
|
+
fail = /* @__PURE__ */ __name((error) => {
|
|
1231
|
+
settled = true;
|
|
1232
|
+
reject(error);
|
|
1233
|
+
}, "fail");
|
|
1234
|
+
});
|
|
1235
|
+
void redirect.catch(() => {
|
|
1236
|
+
});
|
|
1237
|
+
const handler = /* @__PURE__ */ __name((request, response) => {
|
|
1238
|
+
const url = new URL(request.url ?? "/", "http://localhost");
|
|
1239
|
+
if (request.method !== "GET" || url.pathname !== "/callback")
|
|
1240
|
+
return void response.writeHead(404).end();
|
|
1241
|
+
if (settled || !state || url.searchParams.get("state") !== state)
|
|
1242
|
+
return void response.writeHead(400).end("This sign-in link does not belong to the waiting sign-in");
|
|
1243
|
+
response.end("Sign-in received; you can close this tab");
|
|
1244
|
+
accept(url.searchParams);
|
|
1245
|
+
}, "handler");
|
|
1246
|
+
const server = createServer(handler);
|
|
1247
|
+
const onAbort = /* @__PURE__ */ __name(() => fail(new CliError("cancelled", "the amoCRM sign-in was cancelled")), "onAbort");
|
|
1248
|
+
signal?.addEventListener("abort", onAbort, { once: true });
|
|
1249
|
+
const timer = setTimeout(() => fail(new CliError("timeout", "the amoCRM sign-in timed out", { reason: "oauth.timeout" })), CALLBACK_MS);
|
|
1250
|
+
timer.unref();
|
|
1251
|
+
try {
|
|
1252
|
+
await new Promise((resolve2, reject) => {
|
|
1253
|
+
server.once("error", reject);
|
|
1254
|
+
server.listen(0, "127.0.0.1", resolve2);
|
|
1255
|
+
});
|
|
1256
|
+
const address = server.address();
|
|
1257
|
+
if (!address || typeof address === "string")
|
|
1258
|
+
throw new CliError("configuration_error", "could not start the local sign-in listener");
|
|
1259
|
+
state = `${address.port}.${randomBytes(32).toString("base64url")}`;
|
|
1260
|
+
const url = open2(state);
|
|
1261
|
+
steps.showUrl(url);
|
|
1262
|
+
steps.readPaste?.(paste.signal).then((text3) => {
|
|
1263
|
+
if (settled)
|
|
1264
|
+
return;
|
|
1265
|
+
const query = queryOf(text3);
|
|
1266
|
+
if (query.get("state") !== state)
|
|
1267
|
+
fail(new CliError("authentication_error", "the pasted sign-in result does not match this sign-in", {
|
|
1268
|
+
reason: "oauth.mismatch"
|
|
1269
|
+
}));
|
|
1270
|
+
else
|
|
1271
|
+
accept(query);
|
|
1272
|
+
}).catch(() => {
|
|
1273
|
+
});
|
|
1274
|
+
void Promise.resolve().then(() => steps.openBrowser(url)).catch(() => {
|
|
1275
|
+
});
|
|
1276
|
+
return { state, query: await redirect };
|
|
1277
|
+
} finally {
|
|
1278
|
+
clearTimeout(timer);
|
|
1279
|
+
signal?.removeEventListener("abort", onAbort);
|
|
1280
|
+
paste.abort();
|
|
1281
|
+
server.closeAllConnections();
|
|
1282
|
+
if (server.listening)
|
|
1283
|
+
await new Promise((resolve2) => server.close(() => resolve2()));
|
|
1284
|
+
}
|
|
1285
|
+
}, "awaitRedirect");
|
|
1286
|
+
var refuseOtherAccount = /* @__PURE__ */ __name((origin, query) => {
|
|
1287
|
+
const given = (query.get("referer") ?? "").trim().toLowerCase();
|
|
1288
|
+
const host = given.replace(/^https?:\/\//, "").replace(/\/.*$/, "");
|
|
1289
|
+
const expected = new URL(origin).hostname;
|
|
1290
|
+
if (host === expected)
|
|
1291
|
+
return;
|
|
1292
|
+
const named = AMOCRM_HOST.test(host) ? host : void 0;
|
|
1293
|
+
throw new CliError("authentication_error", named ? `access was allowed in ${named}, not in ${expected}; run this again with --host https://${named}, or choose ${expected} in amoCRM's window` : `amoCRM did not say which account access was allowed in, so nothing was sent to ${expected}; run this again`, { reason: "oauth.mismatch", ...named ? { account: named } : {} });
|
|
1294
|
+
}, "refuseOtherAccount");
|
|
1295
|
+
var claimKeys = /* @__PURE__ */ __name(async (options) => {
|
|
1296
|
+
const host = new URL(options.claim).hostname;
|
|
1297
|
+
const request = hostFetch({
|
|
1298
|
+
hosts: [host],
|
|
1299
|
+
timeoutMs: REQUEST_MS2,
|
|
1300
|
+
...options.fetch ? { fetch: options.fetch } : {}
|
|
1301
|
+
});
|
|
1302
|
+
const again = "start the browser sign-in again";
|
|
1303
|
+
const deadline = options.now() + CLAIM_MS;
|
|
1304
|
+
for (let attempt = 0; ; attempt += 1) {
|
|
1305
|
+
let response;
|
|
1306
|
+
try {
|
|
1307
|
+
response = await request(options.claim, {
|
|
1308
|
+
method: "POST",
|
|
1309
|
+
headers: { accept: "application/json", "content-type": "application/json" },
|
|
1310
|
+
body: JSON.stringify({ state: options.state }),
|
|
1311
|
+
redirect: "error",
|
|
1312
|
+
...options.signal ? { signal: options.signal } : {}
|
|
1313
|
+
});
|
|
1314
|
+
} catch (error) {
|
|
1315
|
+
if (options.signal?.aborted)
|
|
1316
|
+
throw new CliError("cancelled", "the amoCRM sign-in was cancelled");
|
|
1317
|
+
if (isCliError(error))
|
|
1318
|
+
throw error;
|
|
1319
|
+
throw new CliError("provider_unavailable", `could not reach ${host} for the integration's keys; ${again}`, {
|
|
1320
|
+
retryable: true,
|
|
1321
|
+
reason: "oauth.unavailable"
|
|
1322
|
+
});
|
|
1323
|
+
}
|
|
1324
|
+
const answer2 = await response.json().catch(() => void 0);
|
|
1325
|
+
if (response.ok) {
|
|
1326
|
+
const id = isRecord(answer2) ? answer2.client_id : void 0;
|
|
1327
|
+
const secret = isRecord(answer2) ? answer2.client_secret : void 0;
|
|
1328
|
+
if (typeof id !== "string" || !id || typeof secret !== "string" || !secret)
|
|
1329
|
+
throw new CliError("invalid_response", `${host} returned keys amo cannot use; ${again}`, {
|
|
1330
|
+
reason: "oauth.invalid-response"
|
|
1331
|
+
});
|
|
1332
|
+
return { clientId: id, clientSecret: secret };
|
|
1333
|
+
}
|
|
1334
|
+
const notReady = response.status === 404 && isRecord(answer2) && answer2.error === "not_ready";
|
|
1335
|
+
if (!notReady)
|
|
1336
|
+
throw new CliError("provider_unavailable", `${host} did not hand over the integration's keys (HTTP ${response.status}); ${again}`, { status: response.status, reason: "oauth.unavailable" });
|
|
1337
|
+
if (options.now() >= deadline)
|
|
1338
|
+
throw new CliError("timeout", `amoCRM did not send the integration's keys to ${host} within a minute; ${again}`, {
|
|
1339
|
+
reason: "oauth.timeout"
|
|
1340
|
+
});
|
|
1341
|
+
await options.sleep(CLAIM_PAUSES_MS[Math.min(attempt, CLAIM_PAUSES_MS.length - 1)] ?? 4e3, options.signal, "retry");
|
|
1342
|
+
}
|
|
1343
|
+
}, "claimKeys");
|
|
1344
|
+
var browserSignIn = /* @__PURE__ */ __name(async (options) => {
|
|
1345
|
+
const { origin } = options;
|
|
1346
|
+
refuseKommo(origin);
|
|
1347
|
+
const connect = connectUrls(options.env);
|
|
1348
|
+
const storage = appStorage(options.env, options.profile, options.keyring, options.storage === "file" ? "file" : "auto");
|
|
1349
|
+
storage.probe();
|
|
1350
|
+
const { state, query } = await awaitRedirect((made) => `${connect.page}#state=${made}`, options.steps, options.signal);
|
|
1351
|
+
if (!query.get("code"))
|
|
1352
|
+
throw new CliError("authentication_error", "amoCRM sign-in was declined", { reason: "oauth.declined" });
|
|
1353
|
+
refuseOtherAccount(origin, query);
|
|
1354
|
+
const client = await claimKeys({
|
|
1355
|
+
claim: connect.claim,
|
|
1356
|
+
state,
|
|
1357
|
+
fetch: options.fetch,
|
|
1358
|
+
sleep: options.sleep,
|
|
1359
|
+
now: options.now,
|
|
1360
|
+
signal: options.signal
|
|
1361
|
+
});
|
|
1362
|
+
const signInCommand = `${IDENTITY.command} ${options.profile} session start --host ${origin} --one-click`;
|
|
1363
|
+
const provider = appProvider(origin, client, BUTTON_RELAY_URL);
|
|
1364
|
+
const fetch = fetchFor(origin, options.fetch);
|
|
1365
|
+
const tokens = await provider.exchange?.({ grant_type: "authorization_code", code: query.get("code") ?? "" }, { fetch, client, now: Date.now, signInCommand, ...options.signal ? { signal: options.signal } : {} });
|
|
1366
|
+
if (!tokens)
|
|
1367
|
+
throw new CliError("authentication_error", "amoCRM did not answer the sign-in");
|
|
1368
|
+
const access = tokens.accessToken ?? "";
|
|
1369
|
+
const user = await options.check({ origin, userId: "", accessToken: /* @__PURE__ */ __name(async () => access, "accessToken") });
|
|
1370
|
+
storage.remove();
|
|
1371
|
+
await tokenKeeper({ provider, storage, lockDir: lockDirOf(options.env), fetch, signInCommand }).save(tokens, {
|
|
1372
|
+
host: origin,
|
|
1373
|
+
userId: user.id,
|
|
1374
|
+
redirectUri: BUTTON_RELAY_URL,
|
|
1375
|
+
browser: true
|
|
1376
|
+
});
|
|
1377
|
+
return user;
|
|
1378
|
+
}, "browserSignIn");
|
|
1379
|
+
|
|
1797
1380
|
// dist/whoami.js
|
|
1798
|
-
var { text:
|
|
1381
|
+
var { text: text2 } = values_exports;
|
|
1799
1382
|
var accountUser = /* @__PURE__ */ __name(async (account2) => {
|
|
1800
1383
|
const { body } = await account2.request({ route: ROUTES.account });
|
|
1801
1384
|
const about = isRecord(body) ? body : {};
|
|
@@ -1813,8 +1396,8 @@ var accountUser = /* @__PURE__ */ __name(async (account2) => {
|
|
|
1813
1396
|
const admin = typeof rights.is_admin === "boolean" ? rights.is_admin : null;
|
|
1814
1397
|
return {
|
|
1815
1398
|
account: new URL(account2.origin).host,
|
|
1816
|
-
account_info: { id: String(about.id ?? ""), name:
|
|
1817
|
-
user: { id: userId, name:
|
|
1399
|
+
account_info: { id: String(about.id ?? ""), name: text2(about.name), subdomain: text2(about.subdomain) },
|
|
1400
|
+
user: { id: userId, name: text2(user.name), admin, manager: admin }
|
|
1818
1401
|
};
|
|
1819
1402
|
}, "accountUser");
|
|
1820
1403
|
|
|
@@ -1868,24 +1451,84 @@ var keepHost = /* @__PURE__ */ __name((command, origin) => {
|
|
|
1868
1451
|
configuration.changeSetting(settings.configPath, { profile, setting: "host", value: JSON.stringify(origin) });
|
|
1869
1452
|
}, "keepHost");
|
|
1870
1453
|
var PASTE = "If the browser did not come back here, paste the address it ended on: ";
|
|
1871
|
-
var
|
|
1872
|
-
const { env,
|
|
1873
|
-
const clientId = (args.clientId ?? env[CLIENT_ID] ?? "").trim();
|
|
1874
|
-
const clientSecret = env[CLIENT_SECRET]?.trim() || (await readSecret("amoCRM integration secret key: ", secretInputOf(command))).trim();
|
|
1875
|
-
if (!clientSecret)
|
|
1876
|
-
throw new CliError("validation_error", "no secret key was given");
|
|
1454
|
+
var browserStepsOf = /* @__PURE__ */ __name((command, steps, purpose) => {
|
|
1455
|
+
const { env, environment } = contextOf(command);
|
|
1877
1456
|
const flags = command.optsWithGlobals();
|
|
1878
1457
|
const machine = flags.json === true || flags.jsonl === true;
|
|
1879
1458
|
const person = !machine && flags.input !== false && !env.CI && (environment.tty ?? process.stdout.isTTY) === true;
|
|
1880
1459
|
const { streams } = outputFor(command);
|
|
1881
|
-
const
|
|
1460
|
+
const input = secretInputOf(command).input ?? process.stdin;
|
|
1461
|
+
const given = environment.answer;
|
|
1462
|
+
return {
|
|
1463
|
+
openBrowser: /* @__PURE__ */ __name(async (url) => {
|
|
1464
|
+
if (environment.openBrowser)
|
|
1465
|
+
return environment.openBrowser(url);
|
|
1466
|
+
if (person)
|
|
1467
|
+
await openBrowser(url);
|
|
1468
|
+
}, "openBrowser"),
|
|
1469
|
+
showUrl: /* @__PURE__ */ __name((url) => {
|
|
1470
|
+
steps.openUrl(url, purpose);
|
|
1471
|
+
streams.diagnostic(`Open the amoCRM sign-in: ${url}
|
|
1472
|
+
`);
|
|
1473
|
+
}, "showUrl"),
|
|
1474
|
+
// A pipe was the secret, and an empty answer would end the sign-in before the browser came back.
|
|
1475
|
+
...given ? {
|
|
1476
|
+
readPaste: /* @__PURE__ */ __name(async () => {
|
|
1477
|
+
const text3 = await given(PASTE);
|
|
1478
|
+
if (text3 === null)
|
|
1479
|
+
throw new CliError("cancelled", "nobody is at a terminal to paste");
|
|
1480
|
+
return text3;
|
|
1481
|
+
}, "readPaste")
|
|
1482
|
+
} : input.isTTY && !machine ? {
|
|
1483
|
+
readPaste: /* @__PURE__ */ __name((signal) => readSecret(PASTE, { ...secretInputOf(command), echo: true, signal }), "readPaste")
|
|
1484
|
+
} : {}
|
|
1485
|
+
};
|
|
1486
|
+
}, "browserStepsOf");
|
|
1487
|
+
var stepsOf = /* @__PURE__ */ __name((command) => {
|
|
1488
|
+
const { environment } = contextOf(command);
|
|
1489
|
+
const flags = command.optsWithGlobals();
|
|
1490
|
+
const machine = flags.json === true || flags.jsonl === true;
|
|
1491
|
+
const { streams } = outputFor(command);
|
|
1492
|
+
return signInSteps({
|
|
1882
1493
|
diagnostic: /* @__PURE__ */ __name((line) => streams.diagnostic(`${line}
|
|
1883
1494
|
`), "diagnostic"),
|
|
1884
1495
|
json: machine || environment.tty === false,
|
|
1885
1496
|
answers: false
|
|
1886
1497
|
});
|
|
1887
|
-
|
|
1888
|
-
|
|
1498
|
+
}, "stepsOf");
|
|
1499
|
+
var checkedUser = /* @__PURE__ */ __name((command, events) => async (auth) => {
|
|
1500
|
+
const { env, keyring, profile } = contextOf(command);
|
|
1501
|
+
const found = await accountUser(transportFor(command, auth, events));
|
|
1502
|
+
refuseDuplicate(env, keyring, profile, { host: found.account, userId: found.user.id });
|
|
1503
|
+
return { ...found, id: found.user.id };
|
|
1504
|
+
}, "checkedUser");
|
|
1505
|
+
var signInWithButton = /* @__PURE__ */ __name(async (command, origin, steps, storage = "keyring") => {
|
|
1506
|
+
const { env, profile, tokens, keyring, run: run3, environment } = contextOf(command);
|
|
1507
|
+
refuseKommo(origin);
|
|
1508
|
+
const who = await run3((events) => browserSignIn({
|
|
1509
|
+
env,
|
|
1510
|
+
profile,
|
|
1511
|
+
origin,
|
|
1512
|
+
storage,
|
|
1513
|
+
keyring,
|
|
1514
|
+
fetch: environment.fetch,
|
|
1515
|
+
sleep: environment.sleep ?? realSleep,
|
|
1516
|
+
now: environment.now ?? monotonic,
|
|
1517
|
+
signal: environment.signal,
|
|
1518
|
+
steps: browserStepsOf(command, steps, "Choose the amoCRM account and allow WireCat's integration"),
|
|
1519
|
+
check: checkedUser(command, events)
|
|
1520
|
+
}));
|
|
1521
|
+
tokens.remove(profile);
|
|
1522
|
+
rememberAccount(IDENTITY, profile, `${who.account}:${who.user.id}`, env);
|
|
1523
|
+
const { id: _id, ...found } = who;
|
|
1524
|
+
return { found, storedIn: appSourceOf(env, profile, keyring) ?? storage };
|
|
1525
|
+
}, "signInWithButton");
|
|
1526
|
+
var startWithApp = /* @__PURE__ */ __name(async (command, args, origin) => {
|
|
1527
|
+
const { env, profile, tokens, keyring, run: run3, environment } = contextOf(command);
|
|
1528
|
+
const clientId = (args.clientId ?? env[CLIENT_ID] ?? "").trim();
|
|
1529
|
+
const clientSecret = env[CLIENT_SECRET]?.trim() || (await readSecret("amoCRM integration secret key: ", secretInputOf(command))).trim();
|
|
1530
|
+
if (!clientSecret)
|
|
1531
|
+
throw new CliError("validation_error", "no secret key was given");
|
|
1889
1532
|
const signInCommand = `${AMO} ${profile} session start --host ${origin} --client-id ${clientId}`;
|
|
1890
1533
|
const who = await run3((events) => appSignIn({
|
|
1891
1534
|
env,
|
|
@@ -1897,35 +1540,8 @@ var startWithApp = /* @__PURE__ */ __name(async (command, args, origin) => {
|
|
|
1897
1540
|
fetch: environment.fetch,
|
|
1898
1541
|
signal: environment.signal,
|
|
1899
1542
|
signInCommand,
|
|
1900
|
-
steps:
|
|
1901
|
-
|
|
1902
|
-
if (environment.openBrowser)
|
|
1903
|
-
return environment.openBrowser(url);
|
|
1904
|
-
if (person)
|
|
1905
|
-
await openBrowser(url);
|
|
1906
|
-
}, "openBrowser"),
|
|
1907
|
-
showUrl: /* @__PURE__ */ __name((url) => {
|
|
1908
|
-
steps.openUrl(url, "Sign in to amoCRM and allow the integration");
|
|
1909
|
-
streams.diagnostic(`Open the amoCRM sign-in: ${url}
|
|
1910
|
-
`);
|
|
1911
|
-
}, "showUrl"),
|
|
1912
|
-
// A pipe was the secret, and an empty answer would end the sign-in before the browser came back.
|
|
1913
|
-
...given ? {
|
|
1914
|
-
readPaste: /* @__PURE__ */ __name(async () => {
|
|
1915
|
-
const text4 = await given(PASTE);
|
|
1916
|
-
if (text4 === null)
|
|
1917
|
-
throw new CliError("cancelled", "nobody is at a terminal to paste");
|
|
1918
|
-
return text4;
|
|
1919
|
-
}, "readPaste")
|
|
1920
|
-
} : input.isTTY && !machine ? {
|
|
1921
|
-
readPaste: /* @__PURE__ */ __name((signal) => readSecret(PASTE, { ...secretInputOf(command), echo: true, signal }), "readPaste")
|
|
1922
|
-
} : {}
|
|
1923
|
-
},
|
|
1924
|
-
check: /* @__PURE__ */ __name(async (auth) => {
|
|
1925
|
-
const found2 = await accountUser(transportFor(command, auth, events));
|
|
1926
|
-
refuseDuplicate(env, keyring, profile, { host: found2.account, userId: found2.user.id });
|
|
1927
|
-
return { ...found2, id: found2.user.id };
|
|
1928
|
-
}, "check")
|
|
1543
|
+
steps: browserStepsOf(command, stepsOf(command), "Sign in to amoCRM and allow the integration"),
|
|
1544
|
+
check: checkedUser(command, events)
|
|
1929
1545
|
}));
|
|
1930
1546
|
tokens.remove(profile);
|
|
1931
1547
|
keepHost(command, origin);
|
|
@@ -1940,6 +1556,18 @@ var startWithApp = /* @__PURE__ */ __name(async (command, args, origin) => {
|
|
|
1940
1556
|
...found
|
|
1941
1557
|
};
|
|
1942
1558
|
}, "startWithApp");
|
|
1559
|
+
var startWithButton = /* @__PURE__ */ __name(async (command, args, origin) => {
|
|
1560
|
+
const { found, storedIn } = await signInWithButton(command, origin, stepsOf(command), args.credentialStorage);
|
|
1561
|
+
keepHost(command, origin);
|
|
1562
|
+
return {
|
|
1563
|
+
profile: contextOf(command).profile,
|
|
1564
|
+
state: "saved",
|
|
1565
|
+
kind: "app",
|
|
1566
|
+
stored_in: storedIn,
|
|
1567
|
+
verified: true,
|
|
1568
|
+
...found
|
|
1569
|
+
};
|
|
1570
|
+
}, "startWithButton");
|
|
1943
1571
|
var CLIENT_ID = `${IDENTITY.envPrefix}_AMOCRM_CLIENT_ID`;
|
|
1944
1572
|
var CLIENT_SECRET = `${IDENTITY.envPrefix}_AMOCRM_CLIENT_SECRET`;
|
|
1945
1573
|
var startCommand = /* @__PURE__ */ __name(() => logsInOrOut(annotate(new Command("start"), {
|
|
@@ -1948,14 +1576,21 @@ var startCommand = /* @__PURE__ */ __name(() => logsInOrOut(annotate(new Command
|
|
|
1948
1576
|
mcp: false,
|
|
1949
1577
|
examples: [
|
|
1950
1578
|
`${AMO} work session start --host https://example.amocrm.ru`,
|
|
1951
|
-
`${AMO} work session start --host https://example.
|
|
1579
|
+
`${AMO} work session start --host https://example.amocrm.ru --one-click`,
|
|
1952
1580
|
`${AMO} work session start --host https://example.amocrm.ru --client-id 0123abcd-4567-89ef-0123-456789abcdef`
|
|
1953
1581
|
]
|
|
1954
|
-
})).summary("sign in
|
|
1582
|
+
})).summary("sign in with one click, a long-lived token or your own integration").description(`sign this profile in: --host names the account, and its long-lived token (a private integration \u2192 Keys and scopes \u2192 Generate a long-lived token) is asked hidden or read from stdin, never taken as an argument, checked against the account, and only then kept in the keyring with the address, or in a private file. The token acts with the rights of the administrator who made it. With --client-id it signs in through that integration in the browser instead: its secret key is asked hidden or read from stdin, and the tokens act with the rights of the user who signs in; the integration's Redirect URI must be ${RELAY_URL}. With --one-click, amoCRM's button on connect.wirecat.dev creates a WireCat integration in the account you choose, and nothing is copied by hand: amoCRM sends the integration's secret key to connect.wirecat.dev, which hands it to amo once and keeps no copy; amocrm.ru accounts only for now. amoCRM lets only an account administrator allow either browser sign-in, so a user who is not one signs in with a token an administrator made. Each sign-in forgets the profile's other kind`).requiredOption("--host <address>", "the account's address, such as https://example.amocrm.ru, kept as given").option("--client-id <id>", `the integration's ID (client_id), or ${CLIENT_ID}; its secret key comes from ${CLIENT_SECRET}, a hidden prompt or stdin`).option("--one-click", "sign in with one click in the browser: amoCRM creates WireCat's integration in the account; only an administrator can allow it").option("--credential-storage <storage>", "where the sign-in is kept: keyring, which falls back to a private file by itself, or file", storageOf, "keyring").action(async function(args) {
|
|
1955
1583
|
const { env, profile, tokens, keyring } = contextOf(this);
|
|
1956
1584
|
refuseCommandName(profile, commandWords(rootOf(this)), AMO);
|
|
1957
1585
|
refuseOffline(this, "the amoCRM account");
|
|
1958
1586
|
const origin = accountOrigin(args.host);
|
|
1587
|
+
if (args.oneClick) {
|
|
1588
|
+
if (args.clientId !== void 0)
|
|
1589
|
+
throw new CliError("validation_error", "--one-click makes its own integration; leave out --client-id", {
|
|
1590
|
+
param: "--client-id"
|
|
1591
|
+
});
|
|
1592
|
+
return answer(this, await startWithButton(this, args, origin));
|
|
1593
|
+
}
|
|
1959
1594
|
if (args.clientId !== void 0 || env[CLIENT_ID])
|
|
1960
1595
|
return answer(this, await startWithApp(this, args, origin));
|
|
1961
1596
|
const token = (await readSecret("amoCRM long-lived token: ", secretInputOf(this))).trim();
|
|
@@ -2062,7 +1697,7 @@ var removal = {
|
|
|
2062
1697
|
}
|
|
2063
1698
|
], "secrets"),
|
|
2064
1699
|
stateFiles: /* @__PURE__ */ __name((profile, { env }) => [
|
|
2065
|
-
|
|
1700
|
+
join(resolvePaths({ appName: IDENTITY.appName, prefix: IDENTITY.envPrefix, env }).state, "crm", profile)
|
|
2066
1701
|
], "stateFiles")
|
|
2067
1702
|
};
|
|
2068
1703
|
var refuseSharedDelete = /* @__PURE__ */ __name((command) => {
|
|
@@ -2149,10 +1784,10 @@ var scalar = /* @__PURE__ */ __name((value) => {
|
|
|
2149
1784
|
return String(value.value);
|
|
2150
1785
|
return void 0;
|
|
2151
1786
|
}, "scalar");
|
|
2152
|
-
var queryOf2 = /* @__PURE__ */ __name((
|
|
2153
|
-
if (
|
|
1787
|
+
var queryOf2 = /* @__PURE__ */ __name((text3) => {
|
|
1788
|
+
if (text3 === void 0)
|
|
2154
1789
|
return {};
|
|
2155
|
-
const parsed = parseApiJson(
|
|
1790
|
+
const parsed = parseApiJson(text3);
|
|
2156
1791
|
if (typeof parsed !== "object" || parsed === null || Array.isArray(parsed))
|
|
2157
1792
|
throw refused("--params takes a JSON object of parameter names and values", "--params");
|
|
2158
1793
|
return Object.fromEntries(Object.entries(parsed).map(([name, value]) => {
|
|
@@ -2162,12 +1797,12 @@ var queryOf2 = /* @__PURE__ */ __name((text4) => {
|
|
|
2162
1797
|
return [name, Array.isArray(value) ? values : values[0]];
|
|
2163
1798
|
}));
|
|
2164
1799
|
}, "queryOf");
|
|
2165
|
-
var bodyOf = /* @__PURE__ */ __name((operation,
|
|
2166
|
-
if (
|
|
1800
|
+
var bodyOf = /* @__PURE__ */ __name((operation, text3) => {
|
|
1801
|
+
if (text3 === void 0)
|
|
2167
1802
|
return void 0;
|
|
2168
1803
|
if (!operation.body)
|
|
2169
1804
|
throw refused(`${operation.name} takes no body`, "--body");
|
|
2170
|
-
return parseApiJson(
|
|
1805
|
+
return parseApiJson(text3);
|
|
2171
1806
|
}, "bodyOf");
|
|
2172
1807
|
var listCommand2 = /* @__PURE__ */ __name(() => withQuery(answerEntity(annotate(new Command("list"), {
|
|
2173
1808
|
effects: NO_EFFECTS,
|
|
@@ -2297,7 +1932,7 @@ var callCommand = /* @__PURE__ */ __name(() => annotate(new Command("call"), {
|
|
|
2297
1932
|
}), "callCommand");
|
|
2298
1933
|
var apiCommand = /* @__PURE__ */ __name(() => annotate(new Command("api"), { effects: LOCAL_READ }).description("see and call the amoCRM API v4 operations directly").addCommand(listCommand2()).addCommand(showCommand()).addCommand(callCommand()), "apiCommand");
|
|
2299
1934
|
|
|
2300
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
1935
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.720.0_@wirecat+cli-base@0.126.1_commander@15.0.0_esbuild@0.28.2_typ_891204b7e0cfbcc49dd71e2850e8663f/node_modules/@wirecat/cli-core/dist/crm/stage-tasks.js
|
|
2301
1936
|
var DAY = 864e5;
|
|
2302
1937
|
var openStageTasks = /* @__PURE__ */ __name(async (store, account2, now, { history = false } = {}) => {
|
|
2303
1938
|
const rules = await store.crm.stageTasks(account2);
|
|
@@ -2334,8 +1969,9 @@ var openStageTasks = /* @__PURE__ */ __name(async (store, account2, now, { histo
|
|
|
2334
1969
|
return opened;
|
|
2335
1970
|
}, "openStageTasks");
|
|
2336
1971
|
|
|
2337
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
1972
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.720.0_@wirecat+cli-base@0.126.1_commander@15.0.0_esbuild@0.28.2_typ_891204b7e0cfbcc49dd71e2850e8663f/node_modules/@wirecat/cli-core/dist/crm/digest.js
|
|
2338
1973
|
var HOUR = 36e5;
|
|
1974
|
+
var SHOWN = 7;
|
|
2339
1975
|
var STALE_HOURS = 24;
|
|
2340
1976
|
var WORDS = {
|
|
2341
1977
|
en: {
|
|
@@ -2371,7 +2007,7 @@ var endOfDay = /* @__PURE__ */ __name((now, zone) => {
|
|
|
2371
2007
|
var crmDigest = /* @__PURE__ */ __name(async (store, account2, options) => {
|
|
2372
2008
|
const { since, until, now, zone, viewer } = options;
|
|
2373
2009
|
const words = WORDS[options.language] ?? WORDS.en;
|
|
2374
|
-
const cap =
|
|
2010
|
+
const cap = SHOWN;
|
|
2375
2011
|
const window = { since, until, ...viewer ? { viewer } : {} };
|
|
2376
2012
|
const counts = await store.crm.changeCounts(account2, window);
|
|
2377
2013
|
const changesOf = /* @__PURE__ */ __name(async (kind) => counts[kind] ? (await store.crm.changes(account2, { ...window, changes: [kind], limit: cap, offset: 0 })).items : [], "changesOf");
|
|
@@ -2454,7 +2090,7 @@ var crmDigest = /* @__PURE__ */ __name(async (store, account2, options) => {
|
|
|
2454
2090
|
}, "crmDigest");
|
|
2455
2091
|
var EMAIL = /[\p{L}\p{N}._%+-]+@[\p{L}\p{N}-]+(?:\.[\p{L}\p{N}-]+)+/gu;
|
|
2456
2092
|
var PHONE = /\+?\d[\d\s().-]{5,}\d/g;
|
|
2457
|
-
var maskText = /* @__PURE__ */ __name((
|
|
2093
|
+
var maskText = /* @__PURE__ */ __name((text3) => text3.replace(EMAIL, "[e-mail]").replace(PHONE, (found) => {
|
|
2458
2094
|
const digits = found.replace(/\D/g, "").length;
|
|
2459
2095
|
return digits >= 9 || found.startsWith("+") && digits >= 7 ? "[phone]" : found;
|
|
2460
2096
|
}), "maskText");
|
|
@@ -2477,7 +2113,7 @@ var healthOf = /* @__PURE__ */ __name(async (store, account2, { now, profile })
|
|
|
2477
2113
|
return stale > STALE_HOURS ? [{ ...named, stale_hours: Math.floor(stale) }] : [];
|
|
2478
2114
|
}, "healthOf");
|
|
2479
2115
|
|
|
2480
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
2116
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.720.0_@wirecat+cli-base@0.126.1_commander@15.0.0_esbuild@0.28.2_typ_891204b7e0cfbcc49dd71e2850e8663f/node_modules/@wirecat/cli-core/dist/crm/cli/csv.js
|
|
2481
2117
|
var csvFormatOption = /* @__PURE__ */ __name(() => annotateOption(new Option("--format <format>", "csv: this page as a table for a spreadsheet; --json=a,b picks its columns").choices(["csv"]), { mcp: false }), "csvFormatOption");
|
|
2482
2118
|
var DEAL_CSV_COLUMNS = [
|
|
2483
2119
|
"ref",
|
|
@@ -2599,7 +2235,7 @@ var renderCsv = /* @__PURE__ */ __name((command, open2, read, defaults = DEAL_CS
|
|
|
2599
2235
|
});
|
|
2600
2236
|
}, "renderCsv");
|
|
2601
2237
|
|
|
2602
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
2238
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.720.0_@wirecat+cli-base@0.126.1_commander@15.0.0_esbuild@0.28.2_typ_891204b7e0cfbcc49dd71e2850e8663f/node_modules/@wirecat/cli-core/dist/crm/cli/records.js
|
|
2603
2239
|
var time2 = nullable(isoTime);
|
|
2604
2240
|
var metadata = optional(record(string(), strictObject({
|
|
2605
2241
|
label: nullable(string()),
|
|
@@ -2774,13 +2410,16 @@ var addCrmRecordCommands = /* @__PURE__ */ __name((program, options) => {
|
|
|
2774
2410
|
const stored = await run3.store.crm.fields(run3.account, kind);
|
|
2775
2411
|
return stored.length ? stored : await run3.source().fields?.(kind) ?? [];
|
|
2776
2412
|
}, "liveFields");
|
|
2413
|
+
const words = options.liveQuery === "words";
|
|
2777
2414
|
const records = /* @__PURE__ */ __name((noun) => {
|
|
2778
2415
|
const group = annotate(program.command(noun.noun), { effects: REMOTE_READ }).description(`the CRM's ${noun.what}, read live: the copy holds only your own`);
|
|
2779
|
-
|
|
2416
|
+
const query = words ? { ...noun.query, fields: noun.query.fields.filter(({ name }) => name === "name") } : noun.query;
|
|
2417
|
+
const list = answerEntity(annotate(group.command("list"), { effects: REMOTE_READ, offline: false }), noun.entity, noun.schema);
|
|
2418
|
+
example((words ? withWords(list, query, `words the CRM's own search looks for in ${noun.what}`) : withQuery(list, query).addHelpText("after", CUSTOM_HELP)).description(`${noun.what} in the CRM, newest first; another client is found here, never in the copy`).option("--limit <n>", `${noun.what} per page, 1\u2013${MOST}`, integer(MOST), 50).option("--page <n>", "which page, starting at 1", integer(1e6), 1).addOption(csvFormatOption()), `${noun.noun} list`, words ? `${noun.noun} list anna --json` : `${noun.noun} list name:anna* --json`, `${noun.noun} list --format csv > ${noun.noun}.csv`).action(async (words2, opts, command) => {
|
|
2780
2419
|
const csv = opts.format === "csv";
|
|
2781
2420
|
const path = commandPath(command);
|
|
2782
|
-
const
|
|
2783
|
-
const names = customNames(
|
|
2421
|
+
const text3 = typedQuery(words2);
|
|
2422
|
+
const names = customNames(text3, query, path, "name");
|
|
2784
2423
|
const columns = command.optsWithGlobals().fields;
|
|
2785
2424
|
const wanted = csv && columns === void 0 ? "all" : wantedCodes(columns);
|
|
2786
2425
|
const read = /* @__PURE__ */ __name(async (run3) => {
|
|
@@ -2788,7 +2427,7 @@ var addCrmRecordCommands = /* @__PURE__ */ __name((program, options) => {
|
|
|
2788
2427
|
const fields = names.length || wanted !== void 0 || csv ? await liveFields(run3, noun.kind) : [];
|
|
2789
2428
|
const chosen = filterableFields(fields, names);
|
|
2790
2429
|
selectedCodes(fields, wanted);
|
|
2791
|
-
const terms = nativeTerms(listQuery(
|
|
2430
|
+
const terms = nativeTerms(listQuery(text3, withCustomFields(query, chosen), path, { defaultField: "name" }), path);
|
|
2792
2431
|
const custom = customConditions(terms, chosen);
|
|
2793
2432
|
const name = searchText(terms.get("name"));
|
|
2794
2433
|
terms.delete("name");
|
|
@@ -2813,7 +2452,7 @@ var addCrmRecordCommands = /* @__PURE__ */ __name((program, options) => {
|
|
|
2813
2452
|
limit: opts.limit,
|
|
2814
2453
|
page: opts.page,
|
|
2815
2454
|
has_more: found.hasMore,
|
|
2816
|
-
...
|
|
2455
|
+
...words2.length ? { args: { query: words2 } } : {}
|
|
2817
2456
|
});
|
|
2818
2457
|
});
|
|
2819
2458
|
});
|
|
@@ -2832,9 +2471,18 @@ var addCrmRecordCommands = /* @__PURE__ */ __name((program, options) => {
|
|
|
2832
2471
|
if (options.live.includes("user"))
|
|
2833
2472
|
users(program, options);
|
|
2834
2473
|
}, "addCrmRecordCommands");
|
|
2474
|
+
var byIdOrNone = /* @__PURE__ */ __name(async (run3, noun, id) => {
|
|
2475
|
+
try {
|
|
2476
|
+
return await sourceWith(run3, "get", noun.what).get(noun.kind, id);
|
|
2477
|
+
} catch (error) {
|
|
2478
|
+
if (isCliError(error) && error.code === "validation_error")
|
|
2479
|
+
return null;
|
|
2480
|
+
throw error;
|
|
2481
|
+
}
|
|
2482
|
+
}, "byIdOrNone");
|
|
2835
2483
|
var recordNamed = /* @__PURE__ */ __name(async (run3, noun, given) => {
|
|
2836
2484
|
const id = given.trim();
|
|
2837
|
-
const byId = RECORD_ID.test(id) ? await
|
|
2485
|
+
const byId = RECORD_ID.test(id) ? await byIdOrNone(run3, noun, id) : null;
|
|
2838
2486
|
if (byId)
|
|
2839
2487
|
return byId;
|
|
2840
2488
|
const want = foldName(id);
|
|
@@ -2968,7 +2616,7 @@ var addRecordWrites = /* @__PURE__ */ __name((group, noun, { within, example, wr
|
|
|
2968
2616
|
}, "addRecordWrites");
|
|
2969
2617
|
var idOf = /* @__PURE__ */ __name((opts) => opts.operationId === void 0 ? {} : { operationId: opts.operationId }, "idOf");
|
|
2970
2618
|
|
|
2971
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
2619
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.720.0_@wirecat+cli-base@0.126.1_commander@15.0.0_esbuild@0.28.2_typ_891204b7e0cfbcc49dd71e2850e8663f/node_modules/@wirecat/cli-core/dist/crm/cli/activities.js
|
|
2972
2620
|
var MOST2 = 500;
|
|
2973
2621
|
var nullableText = nullable(text);
|
|
2974
2622
|
var REFS = ["deal", "lead", "person", "organization"];
|
|
@@ -3081,7 +2729,7 @@ var addCrmActivityCommands = /* @__PURE__ */ __name((program, options) => {
|
|
|
3081
2729
|
}, "addCrmActivityCommands");
|
|
3082
2730
|
var refOf = /* @__PURE__ */ __name((kind, value) => value.includes(":") ? value : `${kind}:${value}`, "refOf");
|
|
3083
2731
|
|
|
3084
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
2732
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.720.0_@wirecat+cli-base@0.126.1_commander@15.0.0_esbuild@0.28.2_typ_891204b7e0cfbcc49dd71e2850e8663f/node_modules/@wirecat/cli-core/dist/crm/cli/changes.js
|
|
3085
2733
|
var MOST3 = 500;
|
|
3086
2734
|
var DAY2 = 864e5;
|
|
3087
2735
|
var nullableText2 = nullable(text);
|
|
@@ -3185,10 +2833,11 @@ var positionOf = /* @__PURE__ */ __name((cursor) => {
|
|
|
3185
2833
|
var digestState = /* @__PURE__ */ __name((schedule) => `crm:digest:${schedule}`, "digestState");
|
|
3186
2834
|
var addCrmChangeCommands = /* @__PURE__ */ __name((program, options) => {
|
|
3187
2835
|
const { within, example, now, ownerOf: ownerOf2, pathOf: pathOf3 } = options;
|
|
2836
|
+
const deals = options.leads === false ? "deals" : "deals and leads";
|
|
3188
2837
|
if (options.activities)
|
|
3189
2838
|
addCrmActivityCommands(program, { within, example, now, ownerOf: ownerOf2, pathOf: pathOf3 });
|
|
3190
|
-
const group = annotate(program.command("changes"), { effects: NO_EFFECTS }).description(
|
|
3191
|
-
example(withQuery(answerEntity(annotate(group.command("list"), { effects: LOCAL_READ }), "crm_change", crmChange).description(
|
|
2839
|
+
const group = annotate(program.command("changes"), { effects: NO_EFFECTS }).description(`what changed in the CRM's ${options.leads === false ? "deals" : "deals, leads"}, activities and contacts, as the syncs copied it`);
|
|
2840
|
+
example(withQuery(answerEntity(annotate(group.command("list"), { effects: LOCAL_READ }), "crm_change", crmChange).description(`${deals} made, moved, won, lost and given another owner, activities added and done, and contacts added, newest first; the last day unless at: says otherwise`).option("--limit <n>", `changes per page, 1\u2013${MOST3}`, integer(MOST3), 50).option("--cursor <cursor>", "the next page, as the last answer's page.next gave it").addOption(annotateOption(new Option("--format <format>", "csv: this page as a table; report: the window as a morning digest document, for schedule command. Run by a schedule, the report starts where that schedule's last one ended").choices(["csv", "report"]), { mcp: false })), CHANGES_QUERY), 'changes list "at>=1d"', "changes list change:won at>=7d --json", 'changes list "at>=1d" --format report').action(async (words, opts, command) => {
|
|
3192
2841
|
const name = "changes list";
|
|
3193
2842
|
const terms = queryTerms(words, CHANGES_QUERY, name, ["at"]);
|
|
3194
2843
|
const zone = timezoneOf();
|
|
@@ -3300,11 +2949,11 @@ var pipelineOf2 = /* @__PURE__ */ __name(async (run3, value) => {
|
|
|
3300
2949
|
}) : new CliError("not_found", `no pipeline ${value} in this account`, { reason: "pipeline.not-found" });
|
|
3301
2950
|
}, "pipelineOf");
|
|
3302
2951
|
|
|
3303
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
3304
|
-
import { createHash
|
|
2952
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.720.0_@wirecat+cli-base@0.126.1_commander@15.0.0_esbuild@0.28.2_typ_891204b7e0cfbcc49dd71e2850e8663f/node_modules/@wirecat/cli-core/dist/crm/cli/files.js
|
|
2953
|
+
import { createHash } from "node:crypto";
|
|
3305
2954
|
import { chmodSync, constants, copyFileSync, existsSync, linkSync, mkdirSync, readFileSync as readFileSync2, renameSync, rmSync } from "node:fs";
|
|
3306
2955
|
import { open } from "node:fs/promises";
|
|
3307
|
-
import { join as
|
|
2956
|
+
import { join as join2, resolve, sep } from "node:path";
|
|
3308
2957
|
var MB = 1024 * 1024;
|
|
3309
2958
|
var PAGE = 500;
|
|
3310
2959
|
var DAY3 = 24 * 60 * 60 * 1e3;
|
|
@@ -3353,8 +3002,8 @@ var OWNER_FLAGS = [
|
|
|
3353
3002
|
["organization", "--organization <id>"]
|
|
3354
3003
|
];
|
|
3355
3004
|
var iso4 = /* @__PURE__ */ __name((ms) => ms === null ? null : new Date(ms).toISOString(), "iso");
|
|
3356
|
-
var segment = /* @__PURE__ */ __name((
|
|
3357
|
-
var accountFolder = /* @__PURE__ */ __name((app, run3) =>
|
|
3005
|
+
var segment = /* @__PURE__ */ __name((text3) => text3.replace(/[^\w.-]+/gu, "_"), "segment");
|
|
3006
|
+
var accountFolder = /* @__PURE__ */ __name((app, run3) => join2(resolvePaths({ appName: app.appName, prefix: app.envPrefix, env: run3.env ?? process.env }).state, "crm", "files", segment(`${run3.account.provider}-${run3.account.account}`)), "accountFolder");
|
|
3358
3007
|
var ownFolder = /* @__PURE__ */ __name((top, folder) => {
|
|
3359
3008
|
mkdirSync(folder, { recursive: true, mode: 448 });
|
|
3360
3009
|
for (let at2 = resolve(folder); at2.startsWith(resolve(top)); at2 = resolve(at2, "..")) {
|
|
@@ -3393,7 +3042,7 @@ var placeNew = /* @__PURE__ */ __name((part, target) => {
|
|
|
3393
3042
|
var saveStream = /* @__PURE__ */ __name(async (stream, target, { cap, signal, exclusive }) => {
|
|
3394
3043
|
const part = `${target}.part-${process.pid}`;
|
|
3395
3044
|
const handle = await open(part, "wx", 384);
|
|
3396
|
-
const hash =
|
|
3045
|
+
const hash = createHash("sha256");
|
|
3397
3046
|
const reader = stream.getReader();
|
|
3398
3047
|
let bytes = 0;
|
|
3399
3048
|
try {
|
|
@@ -3471,12 +3120,12 @@ var targetOf = /* @__PURE__ */ __name((folder, file, earlier, held, capped) => {
|
|
|
3471
3120
|
const providerId = segment(parseCrmFileId(file.id).providerId);
|
|
3472
3121
|
const name = safeName(file.name) ?? `file-${providerId}`;
|
|
3473
3122
|
const free = /* @__PURE__ */ __name((path) => path === earlier || !held.has(path) && !existsSync(path), "free");
|
|
3474
|
-
for (const candidate of [
|
|
3123
|
+
for (const candidate of [join2(folder, name), join2(folder, `${providerId}-${name}`)])
|
|
3475
3124
|
if (free(candidate))
|
|
3476
3125
|
return candidate;
|
|
3477
3126
|
if (capped)
|
|
3478
3127
|
for (let at2 = 2; ; at2 += 1) {
|
|
3479
|
-
const candidate =
|
|
3128
|
+
const candidate = join2(folder, `${providerId}-${at2}-${name}`);
|
|
3480
3129
|
if (free(candidate))
|
|
3481
3130
|
return candidate;
|
|
3482
3131
|
}
|
|
@@ -3490,14 +3139,14 @@ var downloadCrmFile = /* @__PURE__ */ __name(async (context, file, assignee, { c
|
|
|
3490
3139
|
if (file.size !== null && file.size > capBytes)
|
|
3491
3140
|
throw tooLarge(file.id, file.size, capMb, flag);
|
|
3492
3141
|
const top = accountFolder(app, run3);
|
|
3493
|
-
const folder = dir ? resolve(dir) :
|
|
3142
|
+
const folder = dir ? resolve(dir) : join2(top, segment(`${file.owner.kind}-${file.owner.id}`));
|
|
3494
3143
|
const setting = `crm.${run3.account.provider}:${run3.account.account}.files.max_total_mb`;
|
|
3495
3144
|
const capped = dir === void 0;
|
|
3496
3145
|
const room = /* @__PURE__ */ __name((need, target2, drop) => roomFor(context, top, { need, capBytes: limits.max_total_mb * MB, own: file.id, target: target2, drop }), "room");
|
|
3497
3146
|
if (capped && !await room(file.size ?? 0, null, false))
|
|
3498
3147
|
throw diskFull(limits, top, setting);
|
|
3499
3148
|
if (capped)
|
|
3500
|
-
ownFolder(
|
|
3149
|
+
ownFolder(join2(top, ".."), folder);
|
|
3501
3150
|
else
|
|
3502
3151
|
mkdirSync(folder, { recursive: true, mode: 448 });
|
|
3503
3152
|
const earlier = await run3.store.crmFiles.get(run3.account, file.id);
|
|
@@ -3660,13 +3309,13 @@ var addCrmFileCommands = /* @__PURE__ */ __name((program, options) => {
|
|
|
3660
3309
|
limits: await run3.store.crmFiles.limits(run3.account),
|
|
3661
3310
|
...opts.dir === void 0 ? {} : { dir: opts.dir }
|
|
3662
3311
|
});
|
|
3663
|
-
const
|
|
3312
|
+
const text3 = done.row.text;
|
|
3664
3313
|
return itemOf({
|
|
3665
3314
|
...itemOfFile(file, done.row),
|
|
3666
3315
|
size: done.row.size,
|
|
3667
3316
|
text_status: done.textStatus,
|
|
3668
|
-
text:
|
|
3669
|
-
text_truncated:
|
|
3317
|
+
text: text3 === null ? null : text3.slice(0, SHOWN_TEXT),
|
|
3318
|
+
text_truncated: text3 !== null && text3.length > SHOWN_TEXT,
|
|
3670
3319
|
untrusted: ["name", "mime", "path", "text"]
|
|
3671
3320
|
});
|
|
3672
3321
|
});
|
|
@@ -3837,7 +3486,7 @@ var syncFiles = /* @__PURE__ */ __name(async (context, outOfTime, deadline = (ms
|
|
|
3837
3486
|
return report;
|
|
3838
3487
|
}, "syncFiles");
|
|
3839
3488
|
|
|
3840
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
3489
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.720.0_@wirecat+cli-base@0.126.1_commander@15.0.0_esbuild@0.28.2_typ_891204b7e0cfbcc49dd71e2850e8663f/node_modules/@wirecat/cli-core/dist/crm/cli/pipeline-view.js
|
|
3841
3490
|
var sumOf = /* @__PURE__ */ __name((amounts) => amounts.map(({ amount, currency }) => `${groupDigits(amount)} ${currency}`).join(", ") || "\u2014", "sumOf");
|
|
3842
3491
|
var percent = /* @__PURE__ */ __name((share) => share === null ? "\u2014" : `${Math.round(share * 100)}%`, "percent");
|
|
3843
3492
|
var openStages = /* @__PURE__ */ __name((stages) => {
|
|
@@ -3883,11 +3532,12 @@ ${outcomes.join("\n")}`
|
|
|
3883
3532
|
].join("\n\n");
|
|
3884
3533
|
}, "pipelineView");
|
|
3885
3534
|
|
|
3886
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
3535
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.720.0_@wirecat+cli-base@0.126.1_commander@15.0.0_esbuild@0.28.2_typ_891204b7e0cfbcc49dd71e2850e8663f/node_modules/@wirecat/cli-core/dist/crm/cli/search-all.js
|
|
3887
3536
|
var SEARCHED = ["crm", ...SOURCE_SEARCHED];
|
|
3888
3537
|
var DEFAULT_LIMIT = 20;
|
|
3889
|
-
var addCrmSearchAll = /* @__PURE__ */ __name((searches, { within, app, example, viewerOf: viewerOf2 }) => {
|
|
3890
|
-
const
|
|
3538
|
+
var addCrmSearchAll = /* @__PURE__ */ __name((searches, { within, app, example, viewerOf: viewerOf2, leads = true }) => {
|
|
3539
|
+
const deals = leads ? "deals and leads" : "deals";
|
|
3540
|
+
const all = annotate(new Command("all"), { effects: LOCAL_READ, partial: true, output: { entity: "hit" } }).summary(`search stored ${deals}, messages, notes, calendar events and meetings`).description(`search the CRM's ${deals} by the words of their title, company, contacts and activities, and the messages, notes, calendar events and meetings other WireCat tools stored \u2014 best match first. Use it when you do not know where something was written`).argument("<query...>", `words and "phrases"; ${deals} match the words of their title, company, contacts and activities`).addHelpText("after", SAVE_HELP);
|
|
3891
3541
|
searches.addCommand(searchAllOptions(all, SEARCHED));
|
|
3892
3542
|
example(all, "search all Example LLC", "search all website --only crm --json");
|
|
3893
3543
|
all.action(async (words, _opts, leaf) => {
|
|
@@ -3930,7 +3580,7 @@ var addCrmSearchAll = /* @__PURE__ */ __name((searches, { within, app, example,
|
|
|
3930
3580
|
...opts.source === void 0 ? {} : { source: opts.source },
|
|
3931
3581
|
...alone ? { scope: { crm: [run3.account] } } : {}
|
|
3932
3582
|
}, { app, hintCommand: commandAt(rootOf2(leaf), "models download") ? app.command : null }, void 0, meaningLane({ env, messenger: { app }, store: /* @__PURE__ */ __name(async () => run3.store, "store") }));
|
|
3933
|
-
const note = /* @__PURE__ */ __name((
|
|
3583
|
+
const note = /* @__PURE__ */ __name((text3) => outputFor(leaf).renderer.note(text3), "note");
|
|
3934
3584
|
for (const { why } of denied)
|
|
3935
3585
|
note(why);
|
|
3936
3586
|
for (const { resource, source, reason } of found.skipped)
|
|
@@ -3949,11 +3599,11 @@ var addCrmSearchAll = /* @__PURE__ */ __name((searches, { within, app, example,
|
|
|
3949
3599
|
});
|
|
3950
3600
|
}, "addCrmSearchAll");
|
|
3951
3601
|
|
|
3952
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
3602
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.720.0_@wirecat+cli-base@0.126.1_commander@15.0.0_esbuild@0.28.2_typ_891204b7e0cfbcc49dd71e2850e8663f/node_modules/@wirecat/cli-core/dist/cli/profile-store.js
|
|
3953
3603
|
import { mkdtempSync, rmSync as rmSync2 } from "node:fs";
|
|
3954
3604
|
import { tmpdir } from "node:os";
|
|
3955
|
-
import { join as
|
|
3956
|
-
var
|
|
3605
|
+
import { join as join3 } from "node:path";
|
|
3606
|
+
var openProfileStore = /* @__PURE__ */ __name(async (options) => {
|
|
3957
3607
|
const { app, env, profile, readOnly, open: open2 } = options;
|
|
3958
3608
|
const locked = readOnly && readOnlyLockOf(app, env) !== void 0;
|
|
3959
3609
|
if (readOnly) {
|
|
@@ -3971,10 +3621,10 @@ var openCrmStore = /* @__PURE__ */ __name(async (options) => {
|
|
|
3971
3621
|
}
|
|
3972
3622
|
if (!locked)
|
|
3973
3623
|
return withProfile(options, env, options.account());
|
|
3974
|
-
const folder = mkdtempSync(
|
|
3624
|
+
const folder = mkdtempSync(join3(tmpdir(), `${app.command}-empty-`));
|
|
3975
3625
|
const removing = /* @__PURE__ */ __name(() => rmSync2(folder, { recursive: true, force: true }), "removing");
|
|
3976
3626
|
try {
|
|
3977
|
-
const empty = await withProfile(options, { ...env, MESSAGING_STORE:
|
|
3627
|
+
const empty = await withProfile(options, { ...env, MESSAGING_STORE: join3(folder, "wirecat.db") }, {
|
|
3978
3628
|
provider: options.provider,
|
|
3979
3629
|
account: profile
|
|
3980
3630
|
});
|
|
@@ -3985,7 +3635,7 @@ var openCrmStore = /* @__PURE__ */ __name(async (options) => {
|
|
|
3985
3635
|
removing();
|
|
3986
3636
|
throw error;
|
|
3987
3637
|
}
|
|
3988
|
-
}, "
|
|
3638
|
+
}, "openProfileStore");
|
|
3989
3639
|
var withProfile = /* @__PURE__ */ __name(async ({ app, profile, open: open2 }, env, account2) => {
|
|
3990
3640
|
const store = await open2(env);
|
|
3991
3641
|
try {
|
|
@@ -3998,7 +3648,10 @@ var withProfile = /* @__PURE__ */ __name(async ({ app, profile, open: open2 }, e
|
|
|
3998
3648
|
}
|
|
3999
3649
|
}, "withProfile");
|
|
4000
3650
|
|
|
4001
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
3651
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.720.0_@wirecat+cli-base@0.126.1_commander@15.0.0_esbuild@0.28.2_typ_891204b7e0cfbcc49dd71e2850e8663f/node_modules/@wirecat/cli-core/dist/crm/cli/store.js
|
|
3652
|
+
var openCrmStore = openProfileStore;
|
|
3653
|
+
|
|
3654
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.720.0_@wirecat+cli-base@0.126.1_commander@15.0.0_esbuild@0.28.2_typ_891204b7e0cfbcc49dd71e2850e8663f/node_modules/@wirecat/cli-core/dist/crm/cli/index.js
|
|
4002
3655
|
var MOST4 = 500;
|
|
4003
3656
|
var STAGE_REF = /^stage:\d+$/;
|
|
4004
3657
|
var timeField = /* @__PURE__ */ __name((name, example, relation) => nativeField({ name, type: "time", operators: ["term", "range"], example, relation }), "timeField");
|
|
@@ -4020,7 +3673,7 @@ var LEADS_QUERY = { entity: "lead", backend: "native", fields: DEAL_FIELDS };
|
|
|
4020
3673
|
var PIPELINES_QUERY = {
|
|
4021
3674
|
entity: "pipeline",
|
|
4022
3675
|
backend: "native",
|
|
4023
|
-
fields: [termField("kind", "enum", "kind:
|
|
3676
|
+
fields: [termField("kind", "enum", "kind:deal", { values: DEAL_KINDS })]
|
|
4024
3677
|
};
|
|
4025
3678
|
var STAGES_QUERY = {
|
|
4026
3679
|
entity: "stage",
|
|
@@ -4166,7 +3819,10 @@ var addCrmCommandsDefinition = /* @__PURE__ */ __name((program, options) => {
|
|
|
4166
3819
|
renderAnswer(command, outputFor(command), body, view);
|
|
4167
3820
|
}), "within");
|
|
4168
3821
|
const example = /* @__PURE__ */ __name((command, ...lines) => annotate(command, { examples: lines.map((line) => `${options.app.command} work ${line}`) }), "example");
|
|
4169
|
-
|
|
3822
|
+
const hasLeads = options.leads !== false;
|
|
3823
|
+
const dealsAndLeads = hasLeads ? "deals and leads" : "deals";
|
|
3824
|
+
example(answerEntity(annotate(program.command("sync"), { effects: FETCH, offline: false, cooperative: true, partial: true }), "crm_sync", crmSync).description(`bring the CRM's copy in the local store up to date: pipelines, companies, contacts, ${dealsAndLeads} that changed since the last sync, or everything with --rescan; a run stops before its deadline or --max-pages and the next one goes on from there`).addHelpText("after", `
|
|
3825
|
+
With the activities setting on, it also copies the activities and tasks on the ${dealsAndLeads} it keeps. Then each ${hasLeads ? "deal or lead" : "deal"} that moved into a stage the stage-tasks setting names opens a local task, once per move.`), "sync", "sync --rescan", "sync --max-pages 20").option("--rescan", "list everything again, every id too, dropping a round in progress").option("--max-pages <pages>", "at most this many requests to the CRM in this run", integer(1e5)).action(async (opts, command) => {
|
|
4170
3826
|
const { signal } = environmentOf(command);
|
|
4171
3827
|
await within(command, async (run3) => {
|
|
4172
3828
|
const source = run3.source();
|
|
@@ -4223,7 +3879,7 @@ var addCrmCommandsDefinition = /* @__PURE__ */ __name((program, options) => {
|
|
|
4223
3879
|
await within(command, async (run3) => {
|
|
4224
3880
|
const status = await crmStatus(run3.store, run3.account, { profile: run3.profile, now: now() });
|
|
4225
3881
|
if (await viewerOf(run3))
|
|
4226
|
-
outputFor(command).renderer.note(
|
|
3882
|
+
outputFor(command).renderer.note(`stored counts the whole copy, more than the ${dealsAndLeads} you may read`);
|
|
4227
3883
|
return listOf(pathOf2(command).join(" "), {
|
|
4228
3884
|
items: status.items,
|
|
4229
3885
|
limit: status.limit,
|
|
@@ -4232,7 +3888,7 @@ var addCrmCommandsDefinition = /* @__PURE__ */ __name((program, options) => {
|
|
|
4232
3888
|
});
|
|
4233
3889
|
});
|
|
4234
3890
|
});
|
|
4235
|
-
example(answerEntity(annotate(store.command("apply"), { effects: LOCAL_WRITE }), "crm_contacts_removed", crmContactsApplied).description(
|
|
3891
|
+
example(answerEntity(annotate(store.command("apply"), { effects: LOCAL_WRITE }), "crm_contacts_removed", crmContactsApplied).description(`apply scope mine to the contacts already stored: remove those no ${hasLeads ? "deal or lead" : "deal"} of the chosen users and no kept company names, and the people they leave empty; counts only unless --yes, under scope all too. A sync that narrows the scope, or sync --rescan under mine, does this itself`), "store apply", "store apply --yes").option("--yes", "remove the contacts it counts; otherwise only count them").action(async (opts, command) => {
|
|
4236
3892
|
const yes = opts.yes === true;
|
|
4237
3893
|
await within(command, async (run3) => {
|
|
4238
3894
|
const scope = crmSettingKey(run3.account, "scope");
|
|
@@ -4407,7 +4063,7 @@ var addCrmCommandsDefinition = /* @__PURE__ */ __name((program, options) => {
|
|
|
4407
4063
|
const run3 = /* @__PURE__ */ __name((command, work) => within(command, (opened) => work(contextOf3(opened, command))), "run");
|
|
4408
4064
|
const create = write2("create", "create", `make a ${kind} in the CRM, then store the CRM's copy of it`);
|
|
4409
4065
|
if (create)
|
|
4410
|
-
example(fields2(create), `${plural} create --title "Example kitchen" --amount 15000 --currency EUR`, `${plural} create --title "Example office" --pipeline Sales --stage "Quote sent" --field
|
|
4066
|
+
example(fields2(create), `${plural} create --title "Example kitchen" --amount 15000 --currency EUR`, `${plural} create --title "Example office" --pipeline Sales --stage "Quote sent" --field Source=web`).action(async (opts, command) => {
|
|
4411
4067
|
await run3(command, async (context) => {
|
|
4412
4068
|
const done = await createCrmItem(context, kind, inputOf(opts), idOf2(opts));
|
|
4413
4069
|
return answered(done.operationId, done.item);
|
|
@@ -4415,7 +4071,7 @@ var addCrmCommandsDefinition = /* @__PURE__ */ __name((program, options) => {
|
|
|
4415
4071
|
});
|
|
4416
4072
|
const update2 = write2("update", "update", `change a ${kind} in the CRM; what is left out keeps its value; the CRM's copy is stored again`);
|
|
4417
4073
|
if (update2)
|
|
4418
|
-
example(fields2(reference(update2)), `${plural} update ${kind}:12 --amount 18000`, `${plural} update ${kind}:12 --field
|
|
4074
|
+
example(fields2(reference(update2)), `${plural} update ${kind}:12 --amount 18000`, `${plural} update ${kind}:12 --field Source=`).action(async (ref, opts, command) => {
|
|
4419
4075
|
await run3(command, async (context) => {
|
|
4420
4076
|
const done = await updateCrmItem(context, kind, ref, inputOf(opts), idOf2(opts));
|
|
4421
4077
|
return answered(done.operationId, done.item);
|
|
@@ -4458,7 +4114,7 @@ var addCrmCommandsDefinition = /* @__PURE__ */ __name((program, options) => {
|
|
|
4458
4114
|
if (options.leads !== false)
|
|
4459
4115
|
items("lead");
|
|
4460
4116
|
const pipelines = annotate(program.command("pipelines"), { effects: NO_EFFECTS }).description("the CRM's pipelines and their stages, as last synced");
|
|
4461
|
-
example(withQuery(annotate(pipelines.command("list"), { effects: LOCAL_READ, output: { entity: "pipeline" } }).description("pipelines copied from the CRM, with their stages in order and how many are open in each"), PIPELINES_QUERY), "pipelines list --json", "pipelines list kind:lead").action(async (words, _opts, command) => {
|
|
4117
|
+
example(withQuery(annotate(pipelines.command("list"), { effects: LOCAL_READ, output: { entity: "pipeline" } }).description("pipelines copied from the CRM, with their stages in order and how many are open in each"), PIPELINES_QUERY), "pipelines list --json", ...hasLeads ? ["pipelines list kind:lead"] : []).action(async (words, _opts, command) => {
|
|
4462
4118
|
const terms = queryTerms(words, PIPELINES_QUERY, "pipelines list");
|
|
4463
4119
|
await within(command, async (run3) => {
|
|
4464
4120
|
const found = await run3.store.deals.pipelines({
|
|
@@ -4493,7 +4149,7 @@ var addCrmCommandsDefinition = /* @__PURE__ */ __name((program, options) => {
|
|
|
4493
4149
|
}, (body) => pipelineView(body, outputFor(command).color));
|
|
4494
4150
|
});
|
|
4495
4151
|
const stages = annotate(program.command("stages"), { effects: NO_EFFECTS }).description("the stages of the CRM's pipelines, as last synced");
|
|
4496
|
-
example(withQuery(annotate(stages.command("list"), { effects: LOCAL_READ, output: { entity: "stage" } }).description("every stage of the CRM's pipelines in order, with its outcome and how many are open in it"), STAGES_QUERY), "stages list --json", "stages list kind:lead").action(async (words, _opts, command) => {
|
|
4152
|
+
example(withQuery(annotate(stages.command("list"), { effects: LOCAL_READ, output: { entity: "stage" } }).description("every stage of the CRM's pipelines in order, with its outcome and how many are open in it"), STAGES_QUERY), "stages list --json", ...hasLeads ? ["stages list kind:lead"] : []).action(async (words, _opts, command) => {
|
|
4497
4153
|
const terms = queryTerms(words, STAGES_QUERY, "stages list");
|
|
4498
4154
|
await within(command, async (run3) => {
|
|
4499
4155
|
const kind = terms.has("kind") ? terms.get("kind") : void 0;
|
|
@@ -4536,6 +4192,7 @@ var addCrmCommandsDefinition = /* @__PURE__ */ __name((program, options) => {
|
|
|
4536
4192
|
open: options.open,
|
|
4537
4193
|
app: options.app,
|
|
4538
4194
|
live: options.live ?? [],
|
|
4195
|
+
...options.liveQuery ? { liveQuery: options.liveQuery } : {},
|
|
4539
4196
|
...writes ? { writes } : {},
|
|
4540
4197
|
now
|
|
4541
4198
|
});
|
|
@@ -4543,7 +4200,7 @@ var addCrmCommandsDefinition = /* @__PURE__ */ __name((program, options) => {
|
|
|
4543
4200
|
if (options.files)
|
|
4544
4201
|
addCrmFileCommands(program, { ...options, within, example, now });
|
|
4545
4202
|
const fieldKinds = Object.keys(FIELD_KINDS).filter((word) => word !== "leads" || options.leads !== false);
|
|
4546
|
-
const fields = annotate(program.command("fields"), { effects: NO_EFFECTS }).description(
|
|
4203
|
+
const fields = annotate(program.command("fields"), { effects: NO_EFFECTS }).description(`the CRM's own fields on ${hasLeads ? "deals, leads" : "deals"}, people and organizations, as last synced`);
|
|
4547
4204
|
example(withQuery(answerEntity(annotate(fields.command("list"), { effects: LOCAL_READ }), "crm_field", crmField).description("the CRM's custom fields of one kind, in its order, with a list field's options").argument("<kind>", fieldKinds.join(", ")).option("--limit <n>", `fields per page, 1\u2013${MOST4}`, integer(MOST4), 50).option("--page <n>", "which page, starting at 1", integer(1e6)).option("--all", "every field, no paging"), FIELDS_QUERY), "fields list deals", "fields list people --json").action(async (kind, words, opts, command) => {
|
|
4548
4205
|
if (!fieldKinds.includes(kind))
|
|
4549
4206
|
throw new CliError("validation_error", `fields are listed for ${fieldKinds.join(", ")}; got ${kind}`, {
|
|
@@ -4566,7 +4223,7 @@ var addCrmCommandsDefinition = /* @__PURE__ */ __name((program, options) => {
|
|
|
4566
4223
|
});
|
|
4567
4224
|
});
|
|
4568
4225
|
const search = program.commands.find((one) => one.name() === "search") ?? annotate(program.command("search"), { effects: NO_EFFECTS }).description("search what the local store holds");
|
|
4569
|
-
addCrmSearchAll(search, { within, app: options.app, example, viewerOf });
|
|
4226
|
+
addCrmSearchAll(search, { within, app: options.app, example, viewerOf, leads: hasLeads });
|
|
4570
4227
|
}, "addCrmCommandsDefinition");
|
|
4571
4228
|
var addCrmCommands = honoursDryRun(sharedCommand(addCrmCommandsDefinition));
|
|
4572
4229
|
|
|
@@ -4591,9 +4248,9 @@ var userOf = /* @__PURE__ */ __name(async (command, amo) => {
|
|
|
4591
4248
|
var openProfile = /* @__PURE__ */ __name(async (command, { readOnly }) => {
|
|
4592
4249
|
const { env, profile } = contextOf(command);
|
|
4593
4250
|
const [{ openAmoStore, PROVIDER: PROVIDER3 }, { amoCrmSource: amoCrmSource2 }, { amoCrmWriter }] = await Promise.all([
|
|
4594
|
-
import("./store-
|
|
4595
|
-
import("./source-
|
|
4596
|
-
import("./writer-
|
|
4251
|
+
import("./store-A7R2SZVD.js"),
|
|
4252
|
+
import("./source-YISMYLBQ.js"),
|
|
4253
|
+
import("./writer-XDHZ54JD.js")
|
|
4597
4254
|
]);
|
|
4598
4255
|
const accountOf = /* @__PURE__ */ __name(() => {
|
|
4599
4256
|
const signIn = storedSignIn(command) ?? signInOf(command);
|
|
@@ -4612,7 +4269,7 @@ var openProfile = /* @__PURE__ */ __name(async (command, { readOnly }) => {
|
|
|
4612
4269
|
const amo = /* @__PURE__ */ __name(() => transport ??= transportFor(command, signInOf(command)), "amo");
|
|
4613
4270
|
let source;
|
|
4614
4271
|
const asked = /* @__PURE__ */ __name(async () => {
|
|
4615
|
-
const { crmSettingKey: crmSettingKey2 } = await import("./store-
|
|
4272
|
+
const { crmSettingKey: crmSettingKey2 } = await import("./store-FPIU2546.js");
|
|
4616
4273
|
const scope = await store.crm.scope(account2);
|
|
4617
4274
|
return {
|
|
4618
4275
|
mode: scope.mode,
|
|
@@ -4690,7 +4347,28 @@ var texts_en_default = {
|
|
|
4690
4347
|
"done.title": "Connected",
|
|
4691
4348
|
"done.body": "The profile is ready. Copy your deals and their clients into WireCat, then list the open ones:",
|
|
4692
4349
|
"done.oauth.title": "Advanced: sign in through the integration instead",
|
|
4693
|
-
"done.oauth": "
|
|
4350
|
+
"done.oauth": "Instead of a token, an administrator can sign in through the integration in the browser, with its ID and secret key, and amo renews that sign-in itself. amoCRM lets only an account's administrators allow access this way. Run this in a terminal; the secret key is asked hidden:",
|
|
4351
|
+
"role.title": "Are you an administrator of this account?",
|
|
4352
|
+
"role.intro": "Only an amoCRM account administrator can create the integration and its token. If you are not one, an administrator makes the token for you.",
|
|
4353
|
+
"role.admin": "Yes, I am an administrator",
|
|
4354
|
+
"role.admin.hint": "You see \u0430\u043C\u043E\u041C\u0430\u0440\u043A\u0435\u0442 in the menu on the left and can create integrations.",
|
|
4355
|
+
"role.member": "No, I am a user",
|
|
4356
|
+
"role.member.hint": "There is no \u0430\u043C\u043E\u041C\u0430\u0440\u043A\u0435\u0442 in your menu. An administrator sends you the token.",
|
|
4357
|
+
"ask.title": "Ask an administrator for the token",
|
|
4358
|
+
"ask.body": "Send an administrator of your account this request:\n\n> Please create a private WireCat integration in \u0430\u043C\u043E\u041C\u0430\u0440\u043A\u0435\u0442 and send me its long-lived token. How: https://wirecat.dev/en/docs/amo/installation\n\nThe administrator creates the integration, clicks **\xAB\u0421\u0433\u0435\u043D\u0435\u0440\u0438\u0440\u043E\u0432\u0430\u0442\u044C \u0442\u043E\u043A\u0435\u043D\xBB** on its **\xAB\u041A\u043B\u044E\u0447\u0438\xBB** tab and passes you the token. The token works like a password: pass it through a password manager, not a group chat.",
|
|
4359
|
+
"ask.rights": "An amoCRM long-lived token acts with the rights of the administrator who made it. With it you see and can change what that administrator can. amo still stops agents' changes with its permissions.",
|
|
4360
|
+
"ask.later": "When you have the token, go on to the next step and paste it.",
|
|
4361
|
+
"token.member": "Paste the token the administrator sent you. If it is lost, the administrator can make a new one on the **\xAB\u041A\u043B\u044E\u0447\u0438\xBB** tab of the same integration.",
|
|
4362
|
+
"done.own": "The token is the administrator's, so a sync copies the administrator's deals at first. Find your own id in the list of users and put it in place of 7001, and your account's address in place of example.amocrm.ru. Only you can change this setting; an agent cannot.",
|
|
4363
|
+
"method.title": "How do you want to sign in?",
|
|
4364
|
+
"method.intro": "Signing in with amoCRM takes one click in the browser and copies nothing by hand. It works for accounts at amocrm.ru; for Kommo, use a token.",
|
|
4365
|
+
"method.browser": "Sign in with amoCRM",
|
|
4366
|
+
"method.browser.hint": "amoCRM creates a WireCat integration in the account, and amo renews the sign-in itself.",
|
|
4367
|
+
"method.token": "With a long-lived token",
|
|
4368
|
+
"method.token.hint": "You create a private integration and paste its token here.",
|
|
4369
|
+
"connect.title": "Allow access in amoCRM",
|
|
4370
|
+
"connect.body": "Open the link below. On connect.wirecat.dev, click amoCRM's button, choose the account and click **\xAB\u0420\u0430\u0437\u0440\u0435\u0448\u0438\u0442\u044C\xBB**. amoCRM creates the WireCat integration in it and sends the integration's secret key to connect.wirecat.dev, which passes it to amo once and keeps no copy. amo saves the sign-in only after the account answers.",
|
|
4371
|
+
"connect.admin": "amoCRM lets only an account administrator allow this. The integration then shows in \u0430\u043C\u043E\u041C\u0430\u0440\u043A\u0435\u0442, where an administrator can switch it off."
|
|
4694
4372
|
};
|
|
4695
4373
|
|
|
4696
4374
|
// dist/setup/texts.es.json
|
|
@@ -4717,7 +4395,28 @@ var texts_es_default = {
|
|
|
4717
4395
|
"done.title": "Conectado",
|
|
4718
4396
|
"done.body": "El perfil est\xE1 listo. Copia tus negocios y sus clientes a WireCat y luego muestra los abiertos:",
|
|
4719
4397
|
"done.oauth.title": "Avanzado: entrar con la integraci\xF3n",
|
|
4720
|
-
"done.oauth": "
|
|
4398
|
+
"done.oauth": "En lugar de un token, un administrador puede iniciar sesi\xF3n con la integraci\xF3n en el navegador, con su ID y su clave secreta, y amo renueva ese acceso solo. amoCRM solo deja dar acceso as\xED a los administradores de la cuenta. Ejecuta esto en una terminal; la clave secreta se pide oculta:",
|
|
4399
|
+
"role.title": "\xBFEres administrador de esta cuenta?",
|
|
4400
|
+
"role.intro": "Solo un administrador de la cuenta de amoCRM puede crear la integraci\xF3n y su token. Si no lo eres, un administrador crea el token para ti.",
|
|
4401
|
+
"role.admin": "S\xED, soy administrador",
|
|
4402
|
+
"role.admin.hint": "Ves \u0430\u043C\u043E\u041C\u0430\u0440\u043A\u0435\u0442 en el men\xFA de la izquierda y puedes crear integraciones.",
|
|
4403
|
+
"role.member": "No, soy usuario",
|
|
4404
|
+
"role.member.hint": "No hay \u0430\u043C\u043E\u041C\u0430\u0440\u043A\u0435\u0442 en tu men\xFA. Un administrador te env\xEDa el token.",
|
|
4405
|
+
"ask.title": "Pide el token a un administrador",
|
|
4406
|
+
"ask.body": "Env\xEDa esta petici\xF3n a un administrador de tu cuenta:\n\n> Crea, por favor, una integraci\xF3n privada WireCat en \u0430\u043C\u043E\u041C\u0430\u0440\u043A\u0435\u0442 y env\xEDame su token de larga duraci\xF3n. C\xF3mo hacerlo: https://wirecat.dev/es/docs/amo/installation\n\nEl administrador crea la integraci\xF3n, pulsa **\xAB\u0421\u0433\u0435\u043D\u0435\u0440\u0438\u0440\u043E\u0432\u0430\u0442\u044C \u0442\u043E\u043A\u0435\u043D\xBB** en su pesta\xF1a **\xAB\u041A\u043B\u044E\u0447\u0438\xBB** y te pasa el token. El token funciona como una contrase\xF1a: p\xE1salo con un gestor de contrase\xF1as, no en un chat de grupo.",
|
|
4407
|
+
"ask.rights": "Un token de larga duraci\xF3n de amoCRM act\xFAa con los permisos del administrador que lo cre\xF3. Con \xE9l ves y puedes cambiar lo mismo que ese administrador. amo sigue limitando los cambios de los agentes con sus permisos.",
|
|
4408
|
+
"ask.later": "Cuando tengas el token, pasa al siguiente paso y p\xE9galo.",
|
|
4409
|
+
"token.member": "Pega el token que te envi\xF3 el administrador. Si se perdi\xF3, el administrador puede crear otro en la pesta\xF1a **\xAB\u041A\u043B\u044E\u0447\u0438\xBB** de la misma integraci\xF3n.",
|
|
4410
|
+
"done.own": "El token es del administrador, as\xED que al principio la sincronizaci\xF3n copia los negocios del administrador. Busca tu id en la lista de usuarios y ponlo en lugar de 7001, y la direcci\xF3n de tu cuenta en lugar de example.amocrm.ru. Solo t\xFA puedes cambiar este ajuste; un agente no.",
|
|
4411
|
+
"method.title": "\xBFC\xF3mo quieres entrar?",
|
|
4412
|
+
"method.intro": "Entrar con amoCRM es un clic en el navegador, sin copiar nada a mano. Funciona con cuentas en amocrm.ru; para Kommo, usa un token.",
|
|
4413
|
+
"method.browser": "Entrar con amoCRM",
|
|
4414
|
+
"method.browser.hint": "amoCRM crea una integraci\xF3n de WireCat en la cuenta, y amo renueva el acceso por s\xED mismo.",
|
|
4415
|
+
"method.token": "Con un token de larga duraci\xF3n",
|
|
4416
|
+
"method.token.hint": "Creas una integraci\xF3n privada y pegas aqu\xED su token.",
|
|
4417
|
+
"connect.title": "Permite el acceso en amoCRM",
|
|
4418
|
+
"connect.body": "Abre el enlace de abajo. En connect.wirecat.dev, pulsa el bot\xF3n de amoCRM, elige la cuenta y pulsa **\xAB\u0420\u0430\u0437\u0440\u0435\u0448\u0438\u0442\u044C\xBB**. amoCRM crea en ella la integraci\xF3n de WireCat y env\xEDa su clave secreta a connect.wirecat.dev, que se la pasa a amo una vez y no guarda copia. amo guarda el acceso solo si la cuenta responde.",
|
|
4419
|
+
"connect.admin": "amoCRM solo deja hacerlo a un administrador de la cuenta. La integraci\xF3n aparece luego en \u0430\u043C\u043E\u041C\u0430\u0440\u043A\u0435\u0442, donde un administrador puede desactivarla."
|
|
4721
4420
|
};
|
|
4722
4421
|
|
|
4723
4422
|
// dist/setup/texts.ru.json
|
|
@@ -4744,14 +4443,39 @@ var texts_ru_default = {
|
|
|
4744
4443
|
"done.title": "\u041F\u043E\u0434\u043A\u043B\u044E\u0447\u0435\u043D\u043E",
|
|
4745
4444
|
"done.body": "\u041F\u0440\u043E\u0444\u0438\u043B\u044C \u0433\u043E\u0442\u043E\u0432. \u0421\u043A\u043E\u043F\u0438\u0440\u0443\u0439\u0442\u0435 \u0441\u0432\u043E\u0438 \u0441\u0434\u0435\u043B\u043A\u0438 \u0438 \u0438\u0445 \u043A\u043B\u0438\u0435\u043D\u0442\u043E\u0432 \u0432 WireCat, \u0437\u0430\u0442\u0435\u043C \u0432\u044B\u0432\u0435\u0434\u0438\u0442\u0435 \u043E\u0442\u043A\u0440\u044B\u0442\u044B\u0435:",
|
|
4746
4445
|
"done.oauth.title": "\u0414\u043B\u044F \u043E\u043F\u044B\u0442\u043D\u044B\u0445: \u0432\u0445\u043E\u0434 \u0447\u0435\u0440\u0435\u0437 \u0438\u043D\u0442\u0435\u0433\u0440\u0430\u0446\u0438\u044E",
|
|
4747
|
-
"done.oauth": "\
|
|
4446
|
+
"done.oauth": "\u0412\u043C\u0435\u0441\u0442\u043E \u0442\u043E\u043A\u0435\u043D\u0430 \u0430\u0434\u043C\u0438\u043D\u0438\u0441\u0442\u0440\u0430\u0442\u043E\u0440 \u043C\u043E\u0436\u0435\u0442 \u0432\u0445\u043E\u0434\u0438\u0442\u044C \u0447\u0435\u0440\u0435\u0437 \u0438\u043D\u0442\u0435\u0433\u0440\u0430\u0446\u0438\u044E \u0432 \u0431\u0440\u0430\u0443\u0437\u0435\u0440\u0435, \u0441 \u0435\u0451 ID \u0438 \u0441\u0435\u043A\u0440\u0435\u0442\u043D\u044B\u043C \u043A\u043B\u044E\u0447\u043E\u043C, \u0438 amo \u0441\u0430\u043C \u043F\u0440\u043E\u0434\u043B\u0435\u0432\u0430\u0435\u0442 \u0442\u0430\u043A\u043E\u0439 \u0432\u0445\u043E\u0434. amoCRM \u0440\u0430\u0437\u0440\u0435\u0448\u0430\u0435\u0442 \u0442\u0430\u043A \u0434\u0430\u0432\u0430\u0442\u044C \u0434\u043E\u0441\u0442\u0443\u043F \u0442\u043E\u043B\u044C\u043A\u043E \u0430\u0434\u043C\u0438\u043D\u0438\u0441\u0442\u0440\u0430\u0442\u043E\u0440\u0430\u043C \u0430\u043A\u043A\u0430\u0443\u043D\u0442\u0430. \u0412\u044B\u043F\u043E\u043B\u043D\u0438\u0442\u0435 \u0432 \u0442\u0435\u0440\u043C\u0438\u043D\u0430\u043B\u0435; \u0441\u0435\u043A\u0440\u0435\u0442\u043D\u044B\u0439 \u043A\u043B\u044E\u0447 \u0441\u043F\u0440\u043E\u0441\u044F\u0442 \u0441\u043A\u0440\u044B\u0442\u043E:",
|
|
4447
|
+
"role.title": "\u0412\u044B \u0430\u0434\u043C\u0438\u043D\u0438\u0441\u0442\u0440\u0430\u0442\u043E\u0440 \u0430\u043A\u043A\u0430\u0443\u043D\u0442\u0430?",
|
|
4448
|
+
"role.intro": "\u0421\u043E\u0437\u0434\u0430\u0442\u044C \u0438\u043D\u0442\u0435\u0433\u0440\u0430\u0446\u0438\u044E \u0438 \u0435\u0451 \u0442\u043E\u043A\u0435\u043D \u0432 amoCRM \u043C\u043E\u0436\u0435\u0442 \u0442\u043E\u043B\u044C\u043A\u043E \u0430\u0434\u043C\u0438\u043D\u0438\u0441\u0442\u0440\u0430\u0442\u043E\u0440 \u0430\u043A\u043A\u0430\u0443\u043D\u0442\u0430. \u0415\u0441\u043B\u0438 \u0432\u044B \u043D\u0435 \u0430\u0434\u043C\u0438\u043D\u0438\u0441\u0442\u0440\u0430\u0442\u043E\u0440, \u0442\u043E\u043A\u0435\u043D \u0434\u043B\u044F \u0432\u0430\u0441 \u0441\u0434\u0435\u043B\u0430\u0435\u0442 \u043E\u043D.",
|
|
4449
|
+
"role.admin": "\u0414\u0430, \u044F \u0430\u0434\u043C\u0438\u043D\u0438\u0441\u0442\u0440\u0430\u0442\u043E\u0440",
|
|
4450
|
+
"role.admin.hint": "\u0412 \u043C\u0435\u043D\u044E \u0441\u043B\u0435\u0432\u0430 \u0435\u0441\u0442\u044C \u0430\u043C\u043E\u041C\u0430\u0440\u043A\u0435\u0442, \u0438 \u0432\u044B \u043C\u043E\u0436\u0435\u0442\u0435 \u0441\u043E\u0437\u0434\u0430\u0432\u0430\u0442\u044C \u0438\u043D\u0442\u0435\u0433\u0440\u0430\u0446\u0438\u0438.",
|
|
4451
|
+
"role.member": "\u041D\u0435\u0442, \u044F \u0441\u043E\u0442\u0440\u0443\u0434\u043D\u0438\u043A",
|
|
4452
|
+
"role.member.hint": "\u0412 \u043C\u0435\u043D\u044E \u043D\u0435\u0442 \u0430\u043C\u043E\u041C\u0430\u0440\u043A\u0435\u0442\u0430. \u0422\u043E\u043A\u0435\u043D \u0432\u0430\u043C \u043F\u0440\u0438\u0448\u043B\u0451\u0442 \u0430\u0434\u043C\u0438\u043D\u0438\u0441\u0442\u0440\u0430\u0442\u043E\u0440.",
|
|
4453
|
+
"ask.title": "\u041F\u043E\u043F\u0440\u043E\u0441\u0438\u0442\u0435 \u0442\u043E\u043A\u0435\u043D \u0443 \u0430\u0434\u043C\u0438\u043D\u0438\u0441\u0442\u0440\u0430\u0442\u043E\u0440\u0430",
|
|
4454
|
+
"ask.body": "\u041E\u0442\u043F\u0440\u0430\u0432\u044C\u0442\u0435 \u0430\u0434\u043C\u0438\u043D\u0438\u0441\u0442\u0440\u0430\u0442\u043E\u0440\u0443 \u0430\u043A\u043A\u0430\u0443\u043D\u0442\u0430 \u0442\u0430\u043A\u0443\u044E \u043F\u0440\u043E\u0441\u044C\u0431\u0443:\n\n> \u0421\u043E\u0437\u0434\u0430\u0439, \u043F\u043E\u0436\u0430\u043B\u0443\u0439\u0441\u0442\u0430, \u043F\u0440\u0438\u0432\u0430\u0442\u043D\u0443\u044E \u0438\u043D\u0442\u0435\u0433\u0440\u0430\u0446\u0438\u044E WireCat \u0432 \u0430\u043C\u043E\u041C\u0430\u0440\u043A\u0435\u0442\u0435 \u0438 \u043F\u0440\u0438\u0448\u043B\u0438 \u043C\u043D\u0435 \u0435\u0451 \u0434\u043E\u043B\u0433\u043E\u0441\u0440\u043E\u0447\u043D\u044B\u0439 \u0442\u043E\u043A\u0435\u043D. \u041A\u0430\u043A \u044D\u0442\u043E \u0441\u0434\u0435\u043B\u0430\u0442\u044C: https://wirecat.dev/ru/docs/amo/installation\n\n\u0410\u0434\u043C\u0438\u043D\u0438\u0441\u0442\u0440\u0430\u0442\u043E\u0440 \u0441\u043E\u0437\u0434\u0430\u0451\u0442 \u0438\u043D\u0442\u0435\u0433\u0440\u0430\u0446\u0438\u044E, \u043D\u0430 \u0435\u0451 \u0432\u043A\u043B\u0430\u0434\u043A\u0435 **\xAB\u041A\u043B\u044E\u0447\u0438\xBB** \u043D\u0430\u0436\u0438\u043C\u0430\u0435\u0442 **\xAB\u0421\u0433\u0435\u043D\u0435\u0440\u0438\u0440\u043E\u0432\u0430\u0442\u044C \u0442\u043E\u043A\u0435\u043D\xBB** \u0438 \u043F\u0435\u0440\u0435\u0434\u0430\u0451\u0442 \u0432\u0430\u043C \u0442\u043E\u043A\u0435\u043D. \u0422\u043E\u043A\u0435\u043D \u0440\u0430\u0431\u043E\u0442\u0430\u0435\u0442 \u043A\u0430\u043A \u043F\u0430\u0440\u043E\u043B\u044C: \u043F\u0435\u0440\u0435\u0434\u0430\u0432\u0430\u0439\u0442\u0435 \u0435\u0433\u043E \u0447\u0435\u0440\u0435\u0437 \u043C\u0435\u043D\u0435\u0434\u0436\u0435\u0440 \u043F\u0430\u0440\u043E\u043B\u0435\u0439, \u0430 \u043D\u0435 \u0432 \u043E\u0431\u0449\u0435\u043C \u0447\u0430\u0442\u0435.",
|
|
4455
|
+
"ask.rights": "\u0414\u043E\u043B\u0433\u043E\u0441\u0440\u043E\u0447\u043D\u044B\u0439 \u0442\u043E\u043A\u0435\u043D amoCRM \u0434\u0435\u0439\u0441\u0442\u0432\u0443\u0435\u0442 \u0441 \u043F\u0440\u0430\u0432\u0430\u043C\u0438 \u0430\u0434\u043C\u0438\u043D\u0438\u0441\u0442\u0440\u0430\u0442\u043E\u0440\u0430, \u043A\u043E\u0442\u043E\u0440\u044B\u0439 \u0435\u0433\u043E \u0441\u043E\u0437\u0434\u0430\u043B. \u0421 \u043D\u0438\u043C \u0432\u044B \u0432\u0438\u0434\u0438\u0442\u0435 \u0438 \u043C\u043E\u0436\u0435\u0442\u0435 \u043C\u0435\u043D\u044F\u0442\u044C \u0442\u043E \u0436\u0435, \u0447\u0442\u043E \u0438 \u043E\u043D. \u0418\u0437\u043C\u0435\u043D\u0435\u043D\u0438\u044F \u0430\u0433\u0435\u043D\u0442\u043E\u0432 amo \u0432\u0441\u0451 \u0440\u0430\u0432\u043D\u043E \u043E\u0433\u0440\u0430\u043D\u0438\u0447\u0438\u0432\u0430\u0435\u0442 \u0440\u0430\u0437\u0440\u0435\u0448\u0435\u043D\u0438\u044F\u043C\u0438.",
|
|
4456
|
+
"ask.later": "\u041A\u043E\u0433\u0434\u0430 \u043F\u043E\u043B\u0443\u0447\u0438\u0442\u0435 \u0442\u043E\u043A\u0435\u043D, \u043F\u0435\u0440\u0435\u0445\u043E\u0434\u0438\u0442\u0435 \u043A \u0441\u043B\u0435\u0434\u0443\u044E\u0449\u0435\u043C\u0443 \u0448\u0430\u0433\u0443 \u0438 \u0432\u0441\u0442\u0430\u0432\u044C\u0442\u0435 \u0435\u0433\u043E.",
|
|
4457
|
+
"token.member": "\u0412\u0441\u0442\u0430\u0432\u044C\u0442\u0435 \u0442\u043E\u043A\u0435\u043D, \u043A\u043E\u0442\u043E\u0440\u044B\u0439 \u043F\u0440\u0438\u0441\u043B\u0430\u043B \u0430\u0434\u043C\u0438\u043D\u0438\u0441\u0442\u0440\u0430\u0442\u043E\u0440. \u0415\u0441\u043B\u0438 \u0442\u043E\u043A\u0435\u043D \u043F\u043E\u0442\u0435\u0440\u044F\u043B\u0441\u044F, \u0430\u0434\u043C\u0438\u043D\u0438\u0441\u0442\u0440\u0430\u0442\u043E\u0440 \u0441\u0434\u0435\u043B\u0430\u0435\u0442 \u043D\u043E\u0432\u044B\u0439 \u043D\u0430 \u0432\u043A\u043B\u0430\u0434\u043A\u0435 **\xAB\u041A\u043B\u044E\u0447\u0438\xBB** \u0442\u043E\u0439 \u0436\u0435 \u0438\u043D\u0442\u0435\u0433\u0440\u0430\u0446\u0438\u0438.",
|
|
4458
|
+
"done.own": "\u0422\u043E\u043A\u0435\u043D \u043F\u0440\u0438\u043D\u0430\u0434\u043B\u0435\u0436\u0438\u0442 \u0430\u0434\u043C\u0438\u043D\u0438\u0441\u0442\u0440\u0430\u0442\u043E\u0440\u0443, \u043F\u043E\u044D\u0442\u043E\u043C\u0443 \u0441\u0438\u043D\u0445\u0440\u043E\u043D\u0438\u0437\u0430\u0446\u0438\u044F \u0441\u043D\u0430\u0447\u0430\u043B\u0430 \u043A\u043E\u043F\u0438\u0440\u0443\u0435\u0442 \u0435\u0433\u043E \u0441\u0434\u0435\u043B\u043A\u0438. \u041D\u0430\u0439\u0434\u0438\u0442\u0435 \u0441\u0432\u043E\u0439 \u043D\u043E\u043C\u0435\u0440 \u0432 \u0441\u043F\u0438\u0441\u043A\u0435 \u043F\u043E\u043B\u044C\u0437\u043E\u0432\u0430\u0442\u0435\u043B\u0435\u0439 \u0438 \u0443\u043A\u0430\u0436\u0438\u0442\u0435 \u0435\u0433\u043E \u0432\u043C\u0435\u0441\u0442\u043E 7001, \u0430 \u0430\u0434\u0440\u0435\u0441 \u0441\u0432\u043E\u0435\u0433\u043E \u0430\u043A\u043A\u0430\u0443\u043D\u0442\u0430 \u0432\u043C\u0435\u0441\u0442\u043E example.amocrm.ru. \u042D\u0442\u0443 \u043D\u0430\u0441\u0442\u0440\u043E\u0439\u043A\u0443 \u043C\u0435\u043D\u044F\u0435\u0442\u0435 \u0442\u043E\u043B\u044C\u043A\u043E \u0432\u044B, \u0430\u0433\u0435\u043D\u0442\u0443 \u0435\u0451 \u043C\u0435\u043D\u044F\u0442\u044C \u043D\u0435\u043B\u044C\u0437\u044F.",
|
|
4459
|
+
"method.title": "\u041A\u0430\u043A \u0432\u043E\u0439\u0442\u0438?",
|
|
4460
|
+
"method.intro": "\u0412\u0445\u043E\u0434 \u0447\u0435\u0440\u0435\u0437 amoCRM \u2014 \u043E\u0434\u0438\u043D \u043A\u043B\u0438\u043A \u0432 \u0431\u0440\u0430\u0443\u0437\u0435\u0440\u0435, \u043D\u0438\u0447\u0435\u0433\u043E \u043D\u0435 \u043D\u0443\u0436\u043D\u043E \u043A\u043E\u043F\u0438\u0440\u043E\u0432\u0430\u0442\u044C. \u041E\u043D \u0440\u0430\u0431\u043E\u0442\u0430\u0435\u0442 \u0434\u043B\u044F \u0430\u043A\u043A\u0430\u0443\u043D\u0442\u043E\u0432 \u043D\u0430 amocrm.ru; \u0434\u043B\u044F Kommo \u0438\u0441\u043F\u043E\u043B\u044C\u0437\u0443\u0439\u0442\u0435 \u0442\u043E\u043A\u0435\u043D.",
|
|
4461
|
+
"method.browser": "\u0412\u043E\u0439\u0442\u0438 \u0447\u0435\u0440\u0435\u0437 amoCRM",
|
|
4462
|
+
"method.browser.hint": "amoCRM \u0441\u043E\u0437\u0434\u0430\u0441\u0442 \u0432 \u0430\u043A\u043A\u0430\u0443\u043D\u0442\u0435 \u0438\u043D\u0442\u0435\u0433\u0440\u0430\u0446\u0438\u044E WireCat, \u0430 amo \u0441\u0430\u043C \u0431\u0443\u0434\u0435\u0442 \u043F\u0440\u043E\u0434\u043B\u0435\u0432\u0430\u0442\u044C \u0432\u0445\u043E\u0434.",
|
|
4463
|
+
"method.token": "\u0414\u043E\u043B\u0433\u043E\u0441\u0440\u043E\u0447\u043D\u044B\u043C \u0442\u043E\u043A\u0435\u043D\u043E\u043C",
|
|
4464
|
+
"method.token.hint": "\u0412\u044B \u0441\u043E\u0437\u0434\u0430\u0451\u0442\u0435 \u043F\u0440\u0438\u0432\u0430\u0442\u043D\u0443\u044E \u0438\u043D\u0442\u0435\u0433\u0440\u0430\u0446\u0438\u044E \u0438 \u0432\u0441\u0442\u0430\u0432\u043B\u044F\u0435\u0442\u0435 \u0441\u044E\u0434\u0430 \u0435\u0451 \u0442\u043E\u043A\u0435\u043D.",
|
|
4465
|
+
"connect.title": "\u0420\u0430\u0437\u0440\u0435\u0448\u0438\u0442\u0435 \u0434\u043E\u0441\u0442\u0443\u043F \u0432 amoCRM",
|
|
4466
|
+
"connect.body": "\u041E\u0442\u043A\u0440\u043E\u0439\u0442\u0435 \u0441\u0441\u044B\u043B\u043A\u0443 \u043D\u0438\u0436\u0435. \u041D\u0430 connect.wirecat.dev \u043D\u0430\u0436\u043C\u0438\u0442\u0435 \u043A\u043D\u043E\u043F\u043A\u0443 amoCRM, \u0432\u044B\u0431\u0435\u0440\u0438\u0442\u0435 \u0430\u043A\u043A\u0430\u0443\u043D\u0442 \u0438 \u043D\u0430\u0436\u043C\u0438\u0442\u0435 **\xAB\u0420\u0430\u0437\u0440\u0435\u0448\u0438\u0442\u044C\xBB**. amoCRM \u0441\u043E\u0437\u0434\u0430\u0441\u0442 \u0432 \u043D\u0451\u043C \u0438\u043D\u0442\u0435\u0433\u0440\u0430\u0446\u0438\u044E WireCat \u0438 \u043E\u0442\u043F\u0440\u0430\u0432\u0438\u0442 \u0435\u0451 \u0441\u0435\u043A\u0440\u0435\u0442\u043D\u044B\u0439 \u043A\u043B\u044E\u0447 \u043D\u0430 connect.wirecat.dev, \u0430 \u0442\u043E\u0442 \u043E\u0434\u0438\u043D \u0440\u0430\u0437 \u043F\u0435\u0440\u0435\u0434\u0430\u0441\u0442 \u0435\u0433\u043E amo \u0438 \u043D\u0435 \u0441\u043E\u0445\u0440\u0430\u043D\u0438\u0442 \u043A\u043E\u043F\u0438\u044E. amo \u0441\u043E\u0445\u0440\u0430\u043D\u0438\u0442 \u0432\u0445\u043E\u0434, \u0442\u043E\u043B\u044C\u043A\u043E \u0435\u0441\u043B\u0438 \u0430\u043A\u043A\u0430\u0443\u043D\u0442 \u043E\u0442\u0432\u0435\u0442\u0438\u0442.",
|
|
4467
|
+
"connect.admin": "amoCRM \u0440\u0430\u0437\u0440\u0435\u0448\u0430\u0435\u0442 \u044D\u0442\u043E \u0442\u043E\u043B\u044C\u043A\u043E \u0430\u0434\u043C\u0438\u043D\u0438\u0441\u0442\u0440\u0430\u0442\u043E\u0440\u0443 \u0430\u043A\u043A\u0430\u0443\u043D\u0442\u0430. \u0418\u043D\u0442\u0435\u0433\u0440\u0430\u0446\u0438\u044F \u043F\u043E\u044F\u0432\u0438\u0442\u0441\u044F \u0432 \u0430\u043C\u043E\u041C\u0430\u0440\u043A\u0435\u0442\u0435, \u0438 \u0430\u0434\u043C\u0438\u043D\u0438\u0441\u0442\u0440\u0430\u0442\u043E\u0440 \u0441\u043C\u043E\u0436\u0435\u0442 \u0435\u0451 \u043E\u0442\u043A\u043B\u044E\u0447\u0438\u0442\u044C."
|
|
4748
4468
|
};
|
|
4749
4469
|
|
|
4750
4470
|
// dist/setup/flow.js
|
|
4751
|
-
var check2 = /* @__PURE__ */ __name(async ({ command, settings, secrets }) => {
|
|
4471
|
+
var check2 = /* @__PURE__ */ __name(async ({ command, settings, secrets, answers, steps }) => {
|
|
4752
4472
|
refuseCommandName(contextOf(command).profile, commandWords(rootOf(command)), IDENTITY.command);
|
|
4753
4473
|
refuseOffline(command, "the amoCRM account");
|
|
4754
4474
|
const origin = accountOrigin(String(settings.configured.host ?? ""));
|
|
4475
|
+
if (answers.method === "browser") {
|
|
4476
|
+
const { found } = await signInWithButton(command, origin, steps);
|
|
4477
|
+
return { ...found, keep: { account: `${found.account}:${found.user.id}` } };
|
|
4478
|
+
}
|
|
4755
4479
|
const typed = secrets.token?.trim();
|
|
4756
4480
|
if (typed) {
|
|
4757
4481
|
const { who: who2, signIn, account: account2 } = await checkedToken(command, origin, typed);
|
|
@@ -4769,6 +4493,9 @@ var check2 = /* @__PURE__ */ __name(async ({ command, settings, secrets }) => {
|
|
|
4769
4493
|
const who = await withAccount(command, accountUser);
|
|
4770
4494
|
return { ...who, keep: { account: `${who.account}:${who.user.id}` } };
|
|
4771
4495
|
}, "check");
|
|
4496
|
+
var MEMBER = { field: "role", is: "member" };
|
|
4497
|
+
var BROWSER = { field: "method", is: "browser" };
|
|
4498
|
+
var OWN_DEALS = "amo <profile> users list\namo <profile> config set crm.amocrm:example.amocrm.ru.unassigned 7001";
|
|
4772
4499
|
var OAUTH_COMMAND = "amo <profile> session start --host https://<subdomain>.amocrm.ru --client-id <integration ID>";
|
|
4773
4500
|
var amoSetup = defineSetup({
|
|
4774
4501
|
app: IDENTITY,
|
|
@@ -4790,7 +4517,66 @@ var amoSetup = defineSetup({
|
|
|
4790
4517
|
placeholder: "account.host.placeholder"
|
|
4791
4518
|
}
|
|
4792
4519
|
],
|
|
4793
|
-
next: "
|
|
4520
|
+
next: "role"
|
|
4521
|
+
},
|
|
4522
|
+
role: {
|
|
4523
|
+
title: "role.title",
|
|
4524
|
+
blocks: [
|
|
4525
|
+
{ type: "text", text: "role.intro" },
|
|
4526
|
+
{
|
|
4527
|
+
type: "choice",
|
|
4528
|
+
id: "role",
|
|
4529
|
+
optional: true,
|
|
4530
|
+
options: [
|
|
4531
|
+
{ value: "admin", label: "role.admin", hint: "role.admin.hint" },
|
|
4532
|
+
{ value: "member", label: "role.member", hint: "role.member.hint" }
|
|
4533
|
+
]
|
|
4534
|
+
}
|
|
4535
|
+
],
|
|
4536
|
+
next: [{ when: MEMBER, to: "ask-admin" }, { to: "method" }]
|
|
4537
|
+
},
|
|
4538
|
+
method: {
|
|
4539
|
+
title: "method.title",
|
|
4540
|
+
blocks: [
|
|
4541
|
+
{ type: "text", text: "method.intro" },
|
|
4542
|
+
{
|
|
4543
|
+
type: "choice",
|
|
4544
|
+
id: "method",
|
|
4545
|
+
optional: true,
|
|
4546
|
+
options: [
|
|
4547
|
+
{ value: "browser", label: "method.browser", hint: "method.browser.hint" },
|
|
4548
|
+
{ value: "token", label: "method.token", hint: "method.token.hint" }
|
|
4549
|
+
]
|
|
4550
|
+
}
|
|
4551
|
+
],
|
|
4552
|
+
next: [{ when: BROWSER, to: "connect" }, { to: "integration" }]
|
|
4553
|
+
},
|
|
4554
|
+
connect: {
|
|
4555
|
+
kind: "run",
|
|
4556
|
+
title: "connect.title",
|
|
4557
|
+
action: "apply",
|
|
4558
|
+
blocks: [
|
|
4559
|
+
{ type: "text", text: "connect.body" },
|
|
4560
|
+
{ type: "note", role: "warning", text: "connect.admin" }
|
|
4561
|
+
],
|
|
4562
|
+
next: [
|
|
4563
|
+
{ when: { result: "connect", is: "ok" }, to: "done" },
|
|
4564
|
+
{ when: { result: "connect", error: "conflict" }, to: "account" },
|
|
4565
|
+
{ when: { result: "connect", error: "authentication_error" }, to: "method" },
|
|
4566
|
+
{ when: { result: "connect", error: "validation_error" }, to: "method" },
|
|
4567
|
+
{ when: { result: "connect", error: "timeout" }, to: "method" },
|
|
4568
|
+
{ to: "failed" }
|
|
4569
|
+
],
|
|
4570
|
+
back: false
|
|
4571
|
+
},
|
|
4572
|
+
"ask-admin": {
|
|
4573
|
+
title: "ask.title",
|
|
4574
|
+
blocks: [
|
|
4575
|
+
{ type: "text", text: "ask.body" },
|
|
4576
|
+
{ type: "note", role: "warning", text: "ask.rights" },
|
|
4577
|
+
{ type: "text", text: "ask.later" }
|
|
4578
|
+
],
|
|
4579
|
+
next: "token"
|
|
4794
4580
|
},
|
|
4795
4581
|
integration: {
|
|
4796
4582
|
title: "integration.title",
|
|
@@ -4809,7 +4595,8 @@ var amoSetup = defineSetup({
|
|
|
4809
4595
|
token: {
|
|
4810
4596
|
title: "token.title",
|
|
4811
4597
|
blocks: [
|
|
4812
|
-
{ type: "text", text: "token.where" },
|
|
4598
|
+
{ type: "text", text: "token.where", when: { not: MEMBER } },
|
|
4599
|
+
{ type: "text", text: "token.member", when: MEMBER },
|
|
4813
4600
|
{ type: "input", id: "token", secret: "token", input: "password", label: "token.label", hint: "token.hint" },
|
|
4814
4601
|
{ type: "note", role: "tip", text: "token.rights" }
|
|
4815
4602
|
],
|
|
@@ -4839,10 +4626,13 @@ var amoSetup = defineSetup({
|
|
|
4839
4626
|
kind: "done",
|
|
4840
4627
|
title: "done.title",
|
|
4841
4628
|
blocks: [
|
|
4629
|
+
{ type: "text", text: "done.own", when: MEMBER },
|
|
4630
|
+
{ type: "code", code: OWN_DEALS, copy: true, when: MEMBER },
|
|
4842
4631
|
{ type: "text", text: "done.body" },
|
|
4843
4632
|
{ type: "code", code: "amo <profile> sync\namo <profile> deals list status:open", copy: true },
|
|
4844
4633
|
{
|
|
4845
4634
|
type: "group",
|
|
4635
|
+
when: { all: [{ not: MEMBER }, { not: BROWSER }] },
|
|
4846
4636
|
role: "details",
|
|
4847
4637
|
title: "done.oauth.title",
|
|
4848
4638
|
blocks: [
|
|
@@ -4862,7 +4652,7 @@ var update = appUpdate({
|
|
|
4862
4652
|
command: IDENTITY.command,
|
|
4863
4653
|
version: IDENTITY.version,
|
|
4864
4654
|
entry: new URL("../program.js", import.meta.url).href,
|
|
4865
|
-
statePath: /* @__PURE__ */ __name((env) =>
|
|
4655
|
+
statePath: /* @__PURE__ */ __name((env) => join4(resolvePaths({ appName: IDENTITY.appName, prefix: IDENTITY.envPrefix, env }).state, "update-check.json"), "statePath"),
|
|
4866
4656
|
// biome-ignore lint/plugin/no-own-settings: the update check runs before any command exists to give baseContext
|
|
4867
4657
|
enabled: /* @__PURE__ */ __name((env) => configuration.resolveSettings({}, { env, needsProfile: false }).updateCheck, "enabled"),
|
|
4868
4658
|
offVariables: [`${IDENTITY.envPrefix}_NO_UPDATE_CHECK`]
|
|
@@ -4919,6 +4709,7 @@ var definition = /* @__PURE__ */ __name(() => ({
|
|
|
4919
4709
|
scheduleCommand(),
|
|
4920
4710
|
appDoctorCommand(IDENTITY, configuration, { packageName: PACKAGE }),
|
|
4921
4711
|
skillCommand(IDENTITY, SKILL),
|
|
4712
|
+
guideCommand(IDENTITY, { directory: fileURLToPath2(new URL("../scenarios", new URL("../program.js", import.meta.url).href)) }),
|
|
4922
4713
|
mcpCommand(),
|
|
4923
4714
|
upgradeCommand(IDENTITY, PACKAGE, (command) => ({
|
|
4924
4715
|
...outputFor(command),
|