@wirecat/amo-cli 0.2.0 → 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +47 -0
- package/README.md +19 -14
- package/contracts/wirecat.json +58 -19
- 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-43BMVBX2.js +40 -0
- package/dist/bundle/{all-profiles-3KQVWDV4.js → all-profiles-PRNXEZRH.js} +63 -21
- package/dist/bundle/amo.js +28 -26
- package/dist/bundle/{anthropic-N5NOX7K7.js → anthropic-FDI24DU2.js} +5 -5
- package/dist/bundle/{app-server-2MST5EZ5.js → app-server-WAKJVDLN.js} +79 -68
- package/dist/bundle/{bun-4NHWOFX2.js → bun-YPXUXMBI.js} +2 -2
- package/dist/bundle/{bun-sqlite-DRSXPWPR.js → bun-sqlite-UBQ5M47X.js} +6 -6
- package/dist/bundle/chunk-23AQD7JU.js +559 -0
- package/dist/bundle/{chunk-2I5UVMLW.js → chunk-2AIG2SSJ.js} +1733 -1160
- package/dist/bundle/{chunk-DQV2IKCF.js → chunk-2UJ7ZZZC.js} +10 -3
- package/dist/bundle/{chunk-ODNQU7DH.js → chunk-3K6T2G52.js} +43 -64
- package/dist/bundle/chunk-3PCVQCCV.js +108 -0
- package/dist/bundle/{chunk-UMVRT7VQ.js → chunk-3WG4MTQI.js} +1 -1
- package/dist/bundle/chunk-4PQECIU2.js +30 -0
- package/dist/bundle/{chunk-T2UDLX76.js → chunk-5HZMXHRH.js} +6 -6
- package/dist/bundle/{chunk-P3WQRTYZ.js → chunk-5II6TAJE.js} +1 -1
- package/dist/bundle/{chunk-RPWAJYI6.js → chunk-5SJEJYQZ.js} +3 -3
- package/dist/bundle/{chunk-5QFHNBGB.js → chunk-6PILR4AX.js} +2 -2
- package/dist/bundle/{chunk-TNUFLULO.js → chunk-6QMSKJB4.js} +8 -8
- package/dist/bundle/{chunk-5RLUHTK6.js → chunk-745FMNI5.js} +1 -1
- package/dist/bundle/{chunk-AUBB72VF.js → chunk-7OVTUADG.js} +41 -10
- package/dist/bundle/{chunk-7U5HJEPZ.js → chunk-A4W7J6VN.js} +34 -22
- package/dist/bundle/chunk-ABMPZL2P.js +734 -0
- package/dist/bundle/{chunk-EROSAUNP.js → chunk-AN6IJYH3.js} +5 -5
- package/dist/bundle/{chunk-SZ2V62HB.js → chunk-AP3CWDRK.js} +2 -2
- package/dist/bundle/{chunk-ESZSMZKT.js → chunk-ASU63X5C.js} +2 -2
- package/dist/bundle/{chunk-EPOV5UIO.js → chunk-BCIZAUDV.js} +11 -11
- package/dist/bundle/{chunk-7PKFYX7V.js → chunk-CEBX63XY.js} +8 -8
- package/dist/bundle/{chunk-7GTUZY7M.js → chunk-CYHIM5SL.js} +3 -3
- package/dist/bundle/chunk-DWA5TZMP.js +209 -0
- package/dist/bundle/{chunk-LDEBZ3IX.js → chunk-DWD3KDJA.js} +1 -1
- package/dist/bundle/{chunk-GQ7VFIYM.js → chunk-E3EWS6DF.js} +23 -7
- package/dist/bundle/{chunk-NJYAL3UW.js → chunk-EAX5RO7S.js} +1 -1
- package/dist/bundle/{chunk-LJQUYECN.js → chunk-EBNCUQLV.js} +1 -1
- package/dist/bundle/{chunk-UBRREVLJ.js → chunk-ELAKOEIO.js} +2 -2
- package/dist/bundle/{chunk-DAY6TSPF.js → chunk-FEUNZG7U.js} +62 -50
- package/dist/bundle/{chunk-63F65DHU.js → chunk-FQRP6JWX.js} +2 -2
- package/dist/bundle/{chunk-SMSTGO2G.js → chunk-G3LAYJJJ.js} +4 -4
- package/dist/bundle/{chunk-LGQXGOPJ.js → chunk-GBQ76X6T.js} +2 -2
- package/dist/bundle/{chunk-CHUKWON6.js → chunk-GJBOZAUD.js} +3 -3
- package/dist/bundle/{chunk-A33TIM5D.js → chunk-GMHRPX5M.js} +225 -225
- package/dist/bundle/{chunk-O2UCU52O.js → chunk-GQKEMBM6.js} +171 -569
- package/dist/bundle/{chunk-EQUKVVHX.js → chunk-HDZNSOV5.js} +7 -7
- package/dist/bundle/{chunk-ZM7I52EP.js → chunk-HZZ56JO7.js} +3 -4
- package/dist/bundle/{chunk-XQL7FEF4.js → chunk-IBEHYGG6.js} +9 -9
- package/dist/bundle/{chunk-U7RLVJ34.js → chunk-IPNIF5JE.js} +4 -4
- package/dist/bundle/{chunk-QDMXZZG4.js → chunk-KBAOJISR.js} +18 -8
- package/dist/bundle/{chunk-ADEWU4P4.js → chunk-KORZEYZN.js} +1 -1
- package/dist/bundle/{chunk-JMDLPBXK.js → chunk-KQZTX4LM.js} +17 -17
- package/dist/bundle/{chunk-NHXJYS4R.js → chunk-KRD375P7.js} +32 -28
- package/dist/bundle/{chunk-ULXQ5MJM.js → chunk-LAR2DLTI.js} +4 -4
- package/dist/bundle/{chunk-NC76INB2.js → chunk-LZ4IWN43.js} +3088 -2266
- package/dist/bundle/{chunk-BVMNXI53.js → chunk-M33XHJTM.js} +25 -25
- package/dist/bundle/{chunk-WCYCUTSK.js → chunk-M54YKD3I.js} +7 -7
- package/dist/bundle/{chunk-LSND5QYI.js → chunk-MW7HUD6R.js} +9 -9
- package/dist/bundle/{chunk-AHJ4W2IL.js → chunk-NFWD4QX3.js} +2 -2
- package/dist/bundle/{chunk-PM77PRB6.js → chunk-NKYWQTS2.js} +189 -163
- package/dist/bundle/{chunk-LRBPT7LQ.js → chunk-NXNUCGGO.js} +6 -6
- package/dist/bundle/{chunk-5D4Z2B5B.js → chunk-O3WE5IGP.js} +9 -9
- package/dist/bundle/chunk-OYMHPQF7.js +52 -0
- package/dist/bundle/{chunk-VVHRQ46X.js → chunk-PIOR6PIO.js} +2 -2
- package/dist/bundle/{chunk-5D4AEUVA.js → chunk-PL5P7UKW.js} +434 -1
- package/dist/bundle/{chunk-XEFAMLSD.js → chunk-PL7TNKAY.js} +3 -3
- package/dist/bundle/chunk-PLU2IQXC.js +80 -0
- package/dist/bundle/{chunk-73CXFE36.js → chunk-QGFURWEP.js} +29 -1
- package/dist/bundle/{chunk-CDY2NJFE.js → chunk-RQPB2BSH.js} +2 -2
- package/dist/bundle/{chunk-QRQYUHCZ.js → chunk-S6DTLAOB.js} +12 -12
- package/dist/bundle/{chunk-DJD7TBYG.js → chunk-SCMB4LI6.js} +76 -74
- package/dist/bundle/{chunk-TGEQNS6G.js → chunk-SFZVMKB6.js} +1 -1
- package/dist/bundle/{chunk-PFO76YFP.js → chunk-SHOSFYI7.js} +18 -18
- package/dist/bundle/{chunk-5SBLU7D7.js → chunk-SMM7GS4Q.js} +1 -1
- package/dist/bundle/{chunk-EQ7A6NA6.js → chunk-SNBYFQHT.js} +1 -1
- package/dist/bundle/{chunk-GNTJMB6X.js → chunk-SZX7EPPY.js} +4 -4
- package/dist/bundle/{chunk-VX37MPTJ.js → chunk-TCSVW7BA.js} +1 -1
- package/dist/bundle/{chunk-P5LYZRKW.js → chunk-TEGQVVCZ.js} +1992 -885
- package/dist/bundle/{chunk-Q2VNBY4Y.js → chunk-TIR3AB35.js} +758 -1205
- package/dist/bundle/{chunk-5HGGG3QO.js → chunk-U46RNOEQ.js} +16 -3
- package/dist/bundle/{chunk-Y37A3232.js → chunk-UCM7C773.js} +130 -8
- package/dist/bundle/{chunk-L6AFE73L.js → chunk-UEN5NWNW.js} +1 -1
- package/dist/bundle/{chunk-6RS7OYTD.js → chunk-V2QWX6B3.js} +3 -3
- package/dist/bundle/{chunk-3IRJDH2U.js → chunk-V5SETIQK.js} +2 -100
- package/dist/bundle/{chunk-JR6TSMFX.js → chunk-VEFAYLKX.js} +103 -70
- package/dist/bundle/{chunk-CUZRHF34.js → chunk-VG26HDKH.js} +4 -4
- package/dist/bundle/{chunk-4ZAK773N.js → chunk-VG2ERHFJ.js} +3 -3
- package/dist/bundle/{chunk-CHH42KI4.js → chunk-WAFB3IWJ.js} +8 -8
- package/dist/bundle/{chunk-5Z5PEEKP.js → chunk-WASBOYI2.js} +4 -4
- package/dist/bundle/{chunk-DXGGCGRP.js → chunk-WEWJA42Q.js} +14 -14
- package/dist/bundle/chunk-WR2FPZTE.js +353 -0
- package/dist/bundle/chunk-XEYT2EQT.js +338 -0
- package/dist/bundle/{chunk-DOSJONCX.js → chunk-YFRTEJ6V.js} +7 -7
- package/dist/bundle/{chunk-XRTD2GCU.js → chunk-YHVHDRED.js} +19 -258
- package/dist/bundle/{chunk-JH3UOHRE.js → chunk-YREKMP24.js} +4 -4
- package/dist/bundle/{chunk-V77XNPXG.js → chunk-Z2B3VNRI.js} +11 -11
- package/dist/bundle/{chunk-FKR3M62D.js → chunk-ZJC2XJQC.js} +13 -13
- package/dist/bundle/{chunk-5E5R65CA.js → chunk-ZKRWNL4T.js} +2 -2
- package/dist/bundle/{cli-QVWTXADI.js → cli-QDPKC2HJ.js} +150 -103
- package/dist/bundle/command-contract-KWNCP3MQ.js +39 -0
- package/dist/bundle/{command-server-entry-5VL5U5EE.js → command-server-entry-TX7WNN7G.js} +28 -28
- package/dist/bundle/{decode-SQ5WGNDX.js → decode-BLPC7OYE.js} +5 -5
- package/dist/bundle/{dispatch-LA4DFXJD.js → dispatch-5JUT55CS.js} +8 -8
- package/dist/bundle/dist-PAKDDIBT.js +191 -0
- package/dist/bundle/{echarts-25Z3RINX.js → echarts-54D3FOCL.js} +2 -2
- package/dist/bundle/{embed-BNOTNXMA.js → embed-O7KMDYM7.js} +6 -6
- package/dist/bundle/{embedder-BCUT7KKV.js → embedder-4PE67CLX.js} +9 -9
- package/dist/bundle/{failure-PKAC6XCT.js → failure-NNQYTB3Z.js} +2 -2
- package/dist/bundle/{first-run-EO5K5GME.js → first-run-EAU5SHBI.js} +12 -12
- package/dist/bundle/first-screen-APSNGZYZ.js +39 -0
- package/dist/bundle/{instructions-VLM3QAYB.js → instructions-ONXP5DZQ.js} +1 -1
- package/dist/bundle/{mcp-7ILNMJH5.js → mcp-ZNULRPZ4.js} +2 -2
- package/dist/bundle/meeting-combined-W2XIYXFU.js +24 -0
- package/dist/bundle/{meeting-model-GHMMUQ34.js → meeting-model-FWIZRKVN.js} +11 -11
- package/dist/bundle/{meeting-semantic-BMP6323L.js → meeting-semantic-M4YVJ57W.js} +6 -6
- package/dist/bundle/{node-CT3N3TNL.js → node-UTQCYQF5.js} +2 -2
- package/dist/bundle/{node-sqlite-MELD2SBX.js → node-sqlite-APJG6MGL.js} +7 -7
- package/dist/bundle/{oauth-YBH5OKC2.js → oauth-TY7RMIBL.js} +8 -8
- package/dist/bundle/{open-WNSBWTAG.js → open-WDVEQL75.js} +5 -5
- package/dist/bundle/{openai-XSNMNLW6.js → openai-H5UJHSEZ.js} +15 -15
- package/dist/bundle/{process-I2QKOMM7.js → process-MGMXXPMY.js} +1 -1
- package/dist/bundle/{program-G6O3IJR2.js → program-IF36C6VR.js} +969 -1127
- package/dist/bundle/{prompt-SOG4AKPM.js → prompt-4RLIWLMF.js} +5 -5
- package/dist/bundle/{recognize-WMQLWMXH.js → recognize-UIRTMWM4.js} +4 -4
- package/dist/bundle/{remote-4BTFOLFY.js → remote-L3MNWZQK.js} +9 -9
- package/dist/bundle/{rerank-LJ3TWRNV.js → rerank-F4KZQTY6.js} +7 -7
- package/dist/bundle/{serve-B6UANKXN.js → serve-37AUYTWS.js} +10 -10
- package/dist/bundle/server-CRF4QSZR.js +86 -0
- package/dist/bundle/{server-YRH6GJ5Z.js → server-UBG676ZJ.js} +73 -61
- package/dist/bundle/source-Z7GH7T4B.js +44 -0
- package/dist/bundle/{sqlite-runtime-R7QFWFE7.js → sqlite-runtime-CI3RW7VA.js} +6 -6
- package/dist/bundle/{state-DIJ5YUOE.js → state-JOHLSLUO.js} +6 -6
- package/dist/bundle/{store-MYTYDV6A.js → store-2MBG4IUS.js} +28 -21
- package/dist/bundle/{store-6WFWW7EC.js → store-OSOUXBYL.js} +28 -23
- package/dist/bundle/store-SNW6U32Y.js +34 -0
- package/dist/bundle/store-maintenance-command-W7V54SLT.js +73 -0
- package/dist/bundle/surface-ESJS2FUI.js +72 -0
- package/dist/bundle/writer-BJDQMKUV.js +46 -0
- package/dist/commands/account.d.ts +3 -2
- package/dist/commands/account.d.ts.map +1 -1
- package/dist/commands/account.js +38 -77
- package/dist/commands/account.js.map +1 -1
- package/dist/commands/crm-shared.d.ts.map +1 -1
- package/dist/commands/crm-shared.js +2 -0
- package/dist/commands/crm-shared.js.map +1 -1
- package/dist/commands/session.d.ts +23 -6
- package/dist/commands/session.d.ts.map +1 -1
- package/dist/commands/session.js +122 -77
- 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 +0 -2
- package/dist/program.js.map +1 -1
- package/dist/reasons.js +2 -2
- 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 +3 -3
- package/skills/amo-cli/references/setup.md +8 -2
- 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-CHWY2USQ.js +0 -32
- package/dist/bundle/store-maintenance-command-B5TMKFMG.js +0 -68
- package/dist/bundle/writer-GP7VIMAU.js +0 -44
|
@@ -1,24 +1,27 @@
|
|
|
1
1
|
import { createRequire as __bundleRequire } from "node:module";
|
|
2
2
|
const require = __bundleRequire(import.meta.url);
|
|
3
|
+
import {
|
|
4
|
+
PROVIDER
|
|
5
|
+
} from "./chunk-6PILR4AX.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,
|
|
17
20
|
guideCommand,
|
|
18
21
|
honoursDryRun,
|
|
22
|
+
oauthAccount,
|
|
19
23
|
openBrowser,
|
|
20
24
|
ownerLanguageOf,
|
|
21
|
-
parseApiJson,
|
|
22
25
|
providerEvent,
|
|
23
26
|
providerRequest,
|
|
24
27
|
run,
|
|
@@ -28,45 +31,51 @@ import {
|
|
|
28
31
|
setupCommand,
|
|
29
32
|
signInSteps,
|
|
30
33
|
skillCommand,
|
|
34
|
+
tokenKeeper,
|
|
31
35
|
upgradeCommand,
|
|
32
36
|
writeCsv
|
|
33
|
-
} from "./chunk-
|
|
34
|
-
import
|
|
35
|
-
PROVIDER
|
|
36
|
-
} from "./chunk-5QFHNBGB.js";
|
|
37
|
+
} from "./chunk-LZ4IWN43.js";
|
|
38
|
+
import "./chunk-5II6TAJE.js";
|
|
37
39
|
import {
|
|
38
40
|
OPERATIONS,
|
|
39
41
|
amoCrmSource,
|
|
40
42
|
matchOperation,
|
|
41
43
|
pathOf,
|
|
42
44
|
withEveryId
|
|
43
|
-
} from "./chunk-
|
|
45
|
+
} from "./chunk-5SJEJYQZ.js";
|
|
44
46
|
import {
|
|
45
47
|
AMO_WRITES
|
|
46
|
-
} from "./chunk-
|
|
48
|
+
} from "./chunk-GJBOZAUD.js";
|
|
47
49
|
import {
|
|
48
50
|
ENTITIES,
|
|
49
51
|
ROUTES
|
|
50
|
-
} from "./chunk-
|
|
51
|
-
import "./chunk-
|
|
52
|
+
} from "./chunk-DWD3KDJA.js";
|
|
53
|
+
import "./chunk-HZZ56JO7.js";
|
|
52
54
|
import {
|
|
53
55
|
SOURCE_SEARCHED,
|
|
54
56
|
allAnswer,
|
|
55
57
|
historySkipsOf,
|
|
56
58
|
offsetOf,
|
|
57
59
|
refuseOffline
|
|
58
|
-
} from "./chunk-
|
|
59
|
-
import "./chunk-
|
|
60
|
-
import "./chunk-
|
|
61
|
-
import "./chunk-
|
|
60
|
+
} from "./chunk-KRD375P7.js";
|
|
61
|
+
import "./chunk-YHVHDRED.js";
|
|
62
|
+
import "./chunk-CEBX63XY.js";
|
|
63
|
+
import "./chunk-UEN5NWNW.js";
|
|
62
64
|
import {
|
|
63
65
|
addStoreMaintenanceCommands
|
|
64
|
-
} from "./chunk-
|
|
66
|
+
} from "./chunk-VEFAYLKX.js";
|
|
65
67
|
import {
|
|
66
68
|
commandPathKey,
|
|
67
69
|
commandPermissions,
|
|
68
70
|
terminalAsker
|
|
69
|
-
} from "./chunk-
|
|
71
|
+
} from "./chunk-A4W7J6VN.js";
|
|
72
|
+
import "./chunk-WR2FPZTE.js";
|
|
73
|
+
import "./chunk-HDZNSOV5.js";
|
|
74
|
+
import "./chunk-WEWJA42Q.js";
|
|
75
|
+
import "./chunk-NFWD4QX3.js";
|
|
76
|
+
import "./chunk-OYMHPQF7.js";
|
|
77
|
+
import "./chunk-XEYT2EQT.js";
|
|
78
|
+
import "./chunk-DWA5TZMP.js";
|
|
70
79
|
import {
|
|
71
80
|
crmAccounts,
|
|
72
81
|
extractText,
|
|
@@ -75,23 +84,22 @@ import {
|
|
|
75
84
|
personMeetings,
|
|
76
85
|
readableAccounts,
|
|
77
86
|
searchAll,
|
|
78
|
-
taskAccount
|
|
79
|
-
|
|
80
|
-
} from "./chunk-Q2VNBY4Y.js";
|
|
87
|
+
taskAccount
|
|
88
|
+
} from "./chunk-TIR3AB35.js";
|
|
81
89
|
import {
|
|
82
|
-
acquireLock,
|
|
83
90
|
safeName
|
|
84
|
-
} from "./chunk-
|
|
91
|
+
} from "./chunk-ZJC2XJQC.js";
|
|
85
92
|
import {
|
|
86
93
|
CRM_ASSIGN_OTHERS_KEY,
|
|
94
|
+
CRM_SHARED_FOLDERS,
|
|
87
95
|
CRM_WRITE_DEFAULTS,
|
|
88
96
|
CRM_WRITE_KEYS,
|
|
89
97
|
Pacer,
|
|
90
98
|
RECORD_ID,
|
|
91
99
|
SYNCED_FROM,
|
|
92
100
|
SYNC_FAILED,
|
|
101
|
+
apiJson,
|
|
93
102
|
closeCrmItem,
|
|
94
|
-
commandPath,
|
|
95
103
|
conditionsOf,
|
|
96
104
|
createCrmItem,
|
|
97
105
|
createCrmRecord,
|
|
@@ -100,62 +108,64 @@ import {
|
|
|
100
108
|
crmViewerOf,
|
|
101
109
|
customConditions,
|
|
102
110
|
customNames,
|
|
103
|
-
dateWindow,
|
|
104
111
|
fieldPairsOf,
|
|
105
112
|
filterableFields,
|
|
106
113
|
foreignContacts,
|
|
107
114
|
foreignContactsPathFor,
|
|
108
115
|
guardFor,
|
|
109
116
|
keyedGuard,
|
|
110
|
-
listQuery,
|
|
111
117
|
moveCrmItem,
|
|
112
|
-
nativeField,
|
|
113
|
-
nativeTerms,
|
|
114
118
|
newOperationId,
|
|
115
119
|
ownerOf,
|
|
116
120
|
pacePathFor,
|
|
121
|
+
parseApiJson,
|
|
117
122
|
parseCrmFileId,
|
|
118
123
|
pipelineOf,
|
|
119
124
|
providerCall,
|
|
120
|
-
queryTerms,
|
|
121
125
|
refuseForeignClientReads,
|
|
122
126
|
removeCrmItem,
|
|
123
|
-
searchText,
|
|
124
127
|
selectedCodes,
|
|
125
128
|
shortened,
|
|
126
129
|
syncRecorded,
|
|
127
|
-
termField,
|
|
128
|
-
timeBounds,
|
|
129
|
-
typedQuery,
|
|
130
|
-
unfilteredQuery,
|
|
131
130
|
updateCrmItem,
|
|
132
131
|
updateCrmRecord,
|
|
133
132
|
values_exports,
|
|
134
133
|
viewerOf,
|
|
135
134
|
wantedCodes,
|
|
136
135
|
withCustomFields,
|
|
137
|
-
withQuery,
|
|
138
136
|
withReadableDeal,
|
|
139
137
|
withoutFileLinks
|
|
140
|
-
} from "./chunk-
|
|
141
|
-
import "./chunk-
|
|
142
|
-
import "./chunk-73CXFE36.js";
|
|
143
|
-
import "./chunk-DXGGCGRP.js";
|
|
138
|
+
} from "./chunk-2AIG2SSJ.js";
|
|
139
|
+
import "./chunk-QGFURWEP.js";
|
|
144
140
|
import {
|
|
145
141
|
latestVersion,
|
|
146
142
|
runUpdate,
|
|
147
143
|
updateNotice
|
|
148
|
-
} from "./chunk-
|
|
149
|
-
import "./chunk-
|
|
150
|
-
import "./chunk-
|
|
151
|
-
import
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
144
|
+
} from "./chunk-SZX7EPPY.js";
|
|
145
|
+
import "./chunk-3WG4MTQI.js";
|
|
146
|
+
import "./chunk-4PQECIU2.js";
|
|
147
|
+
import {
|
|
148
|
+
commandPath,
|
|
149
|
+
dateWindow,
|
|
150
|
+
listQuery,
|
|
151
|
+
nativeField,
|
|
152
|
+
nativeTerms,
|
|
153
|
+
queryTerms,
|
|
154
|
+
searchText,
|
|
155
|
+
termField,
|
|
156
|
+
timeBounds,
|
|
157
|
+
typedQuery,
|
|
158
|
+
unfilteredQuery,
|
|
159
|
+
withQuery,
|
|
160
|
+
withWords
|
|
161
|
+
} from "./chunk-ABMPZL2P.js";
|
|
162
|
+
import "./chunk-LAR2DLTI.js";
|
|
163
|
+
import "./chunk-5HZMXHRH.js";
|
|
164
|
+
import "./chunk-Z2B3VNRI.js";
|
|
165
|
+
import "./chunk-CYHIM5SL.js";
|
|
166
|
+
import "./chunk-YREKMP24.js";
|
|
167
|
+
import "./chunk-U46RNOEQ.js";
|
|
168
|
+
import "./chunk-AN6IJYH3.js";
|
|
159
169
|
import {
|
|
160
170
|
Argument,
|
|
161
171
|
Command,
|
|
@@ -167,7 +177,6 @@ import {
|
|
|
167
177
|
Option,
|
|
168
178
|
REMOTE_READ,
|
|
169
179
|
REMOTE_WRITE,
|
|
170
|
-
accountFileFor,
|
|
171
180
|
annotate,
|
|
172
181
|
annotateOption,
|
|
173
182
|
answerEntity,
|
|
@@ -190,6 +199,7 @@ import {
|
|
|
190
199
|
profilesHere,
|
|
191
200
|
readOnlyLockOf,
|
|
192
201
|
readOnlyRefusal,
|
|
202
|
+
recalledAccount,
|
|
193
203
|
refuseCommandName,
|
|
194
204
|
refuseUnderReadOnly,
|
|
195
205
|
rememberAccount,
|
|
@@ -202,13 +212,13 @@ import {
|
|
|
202
212
|
sharedCommand,
|
|
203
213
|
snakeKeys,
|
|
204
214
|
snakeKeysKeeping
|
|
205
|
-
} from "./chunk-
|
|
206
|
-
import "./chunk-
|
|
207
|
-
import "./chunk-
|
|
208
|
-
import "./chunk-
|
|
209
|
-
import "./chunk-
|
|
210
|
-
import "./chunk-
|
|
211
|
-
import "./chunk-
|
|
215
|
+
} from "./chunk-NKYWQTS2.js";
|
|
216
|
+
import "./chunk-M54YKD3I.js";
|
|
217
|
+
import "./chunk-G3LAYJJJ.js";
|
|
218
|
+
import "./chunk-O3WE5IGP.js";
|
|
219
|
+
import "./chunk-SMM7GS4Q.js";
|
|
220
|
+
import "./chunk-KQZTX4LM.js";
|
|
221
|
+
import "./chunk-V2QWX6B3.js";
|
|
212
222
|
import {
|
|
213
223
|
CRM_CHANGES,
|
|
214
224
|
CRM_SCOPES,
|
|
@@ -216,53 +226,54 @@ import {
|
|
|
216
226
|
attachmentMaxBytes,
|
|
217
227
|
crmIdentityId,
|
|
218
228
|
crmSettingKey,
|
|
219
|
-
dayIn,
|
|
220
229
|
seenBy,
|
|
221
230
|
viewerSql
|
|
222
|
-
} from "./chunk-
|
|
223
|
-
import "./chunk-
|
|
224
|
-
import
|
|
231
|
+
} from "./chunk-TEGQVVCZ.js";
|
|
232
|
+
import "./chunk-6QMSKJB4.js";
|
|
233
|
+
import {
|
|
234
|
+
dayIn
|
|
235
|
+
} from "./chunk-PLU2IQXC.js";
|
|
236
|
+
import "./chunk-IBEHYGG6.js";
|
|
225
237
|
import {
|
|
226
238
|
count,
|
|
227
239
|
createTaskService,
|
|
228
240
|
currentAttempt,
|
|
229
241
|
text,
|
|
230
242
|
time
|
|
231
|
-
} from "./chunk-
|
|
232
|
-
import "./chunk-
|
|
233
|
-
import "./chunk-
|
|
243
|
+
} from "./chunk-M33XHJTM.js";
|
|
244
|
+
import "./chunk-ELAKOEIO.js";
|
|
245
|
+
import "./chunk-BCIZAUDV.js";
|
|
234
246
|
import {
|
|
235
247
|
hostFetch,
|
|
236
248
|
providerWaitMs,
|
|
237
249
|
readJsonResponse,
|
|
238
250
|
retryableStatus,
|
|
239
251
|
statusToCode
|
|
240
|
-
} from "./chunk-
|
|
241
|
-
import "./chunk-
|
|
242
|
-
import "./chunk-
|
|
243
|
-
import "./chunk-U7RLVJ34.js";
|
|
252
|
+
} from "./chunk-E3EWS6DF.js";
|
|
253
|
+
import "./chunk-3K6T2G52.js";
|
|
254
|
+
import "./chunk-IPNIF5JE.js";
|
|
244
255
|
import {
|
|
245
256
|
IDENTITY,
|
|
246
257
|
PACKAGE,
|
|
247
258
|
SKILL
|
|
248
|
-
} from "./chunk-
|
|
249
|
-
import "./chunk-
|
|
250
|
-
import "./chunk-
|
|
251
|
-
import "./chunk-VVHRQ46X.js";
|
|
252
|
-
import "./chunk-LSND5QYI.js";
|
|
259
|
+
} from "./chunk-WAFB3IWJ.js";
|
|
260
|
+
import "./chunk-RQPB2BSH.js";
|
|
261
|
+
import "./chunk-PIOR6PIO.js";
|
|
253
262
|
import "./chunk-EH6ZEJGT.js";
|
|
263
|
+
import "./chunk-UCM7C773.js";
|
|
264
|
+
import "./chunk-MW7HUD6R.js";
|
|
254
265
|
import {
|
|
255
266
|
installerOf
|
|
256
|
-
} from "./chunk-
|
|
267
|
+
} from "./chunk-745FMNI5.js";
|
|
257
268
|
import {
|
|
258
269
|
fieldsOf,
|
|
259
270
|
levelFor
|
|
260
|
-
} from "./chunk-
|
|
271
|
+
} from "./chunk-KBAOJISR.js";
|
|
261
272
|
import {
|
|
262
273
|
foldName
|
|
263
|
-
} from "./chunk-
|
|
264
|
-
import "./chunk-
|
|
265
|
-
import "./chunk-
|
|
274
|
+
} from "./chunk-SHOSFYI7.js";
|
|
275
|
+
import "./chunk-2UJ7ZZZC.js";
|
|
276
|
+
import "./chunk-SFZVMKB6.js";
|
|
266
277
|
import {
|
|
267
278
|
CRM_ACTIVITY_KINDS,
|
|
268
279
|
CRM_KINDS,
|
|
@@ -273,34 +284,35 @@ import {
|
|
|
273
284
|
normalCrmUserId,
|
|
274
285
|
parseDecimal,
|
|
275
286
|
scaleOf
|
|
276
|
-
} from "./chunk-
|
|
277
|
-
import "./chunk-
|
|
278
|
-
import "./chunk-
|
|
287
|
+
} from "./chunk-S6DTLAOB.js";
|
|
288
|
+
import "./chunk-EAX5RO7S.js";
|
|
289
|
+
import "./chunk-FQRP6JWX.js";
|
|
279
290
|
import {
|
|
280
291
|
SAVE_HELP,
|
|
281
292
|
defineQuery,
|
|
282
293
|
queryFieldsOf,
|
|
283
294
|
timezoneOf,
|
|
284
295
|
zonedMoment
|
|
285
|
-
} from "./chunk-
|
|
286
|
-
import "./chunk-
|
|
296
|
+
} from "./chunk-GMHRPX5M.js";
|
|
297
|
+
import "./chunk-TCSVW7BA.js";
|
|
298
|
+
import "./chunk-YFRTEJ6V.js";
|
|
287
299
|
import "./chunk-D72URWJE.js";
|
|
288
300
|
import {
|
|
289
301
|
readSecret
|
|
290
|
-
} from "./chunk-
|
|
291
|
-
import "./chunk-
|
|
292
|
-
import "./chunk-
|
|
293
|
-
import "./chunk-
|
|
294
|
-
import "./chunk-
|
|
302
|
+
} from "./chunk-VG2ERHFJ.js";
|
|
303
|
+
import "./chunk-ASU63X5C.js";
|
|
304
|
+
import "./chunk-ZKRWNL4T.js";
|
|
305
|
+
import "./chunk-NXNUCGGO.js";
|
|
306
|
+
import "./chunk-KORZEYZN.js";
|
|
295
307
|
import {
|
|
296
308
|
Credentials,
|
|
297
309
|
isMovedRun,
|
|
298
|
-
|
|
310
|
+
monotonic,
|
|
299
311
|
realSleep,
|
|
300
312
|
renderPretty,
|
|
301
313
|
resolvePaths,
|
|
302
314
|
systemKeyring
|
|
303
|
-
} from "./chunk-
|
|
315
|
+
} from "./chunk-SCMB4LI6.js";
|
|
304
316
|
import {
|
|
305
317
|
array,
|
|
306
318
|
boolean,
|
|
@@ -319,22 +331,22 @@ import {
|
|
|
319
331
|
union,
|
|
320
332
|
unknown,
|
|
321
333
|
variant
|
|
322
|
-
} from "./chunk-
|
|
334
|
+
} from "./chunk-7OVTUADG.js";
|
|
323
335
|
import "./chunk-Y5E2WNWB.js";
|
|
324
336
|
import {
|
|
325
337
|
CliError,
|
|
326
338
|
isCliError
|
|
327
|
-
} from "./chunk-
|
|
328
|
-
import "./chunk-
|
|
339
|
+
} from "./chunk-AP3CWDRK.js";
|
|
340
|
+
import "./chunk-EBNCUQLV.js";
|
|
329
341
|
import {
|
|
330
342
|
__name
|
|
331
343
|
} from "./chunk-ZVVMGPBJ.js";
|
|
332
344
|
|
|
333
345
|
// dist/program.js
|
|
334
|
-
import { join as
|
|
346
|
+
import { join as join4 } from "node:path";
|
|
335
347
|
import { fileURLToPath as fileURLToPath2 } from "node:url";
|
|
336
348
|
|
|
337
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
349
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.722.0_@wirecat+cli-base@0.127.0_commander@15.0.0_esbuild@0.28.2_typ_d2bed0cfbe6b4358c89d465b9e07afcb/node_modules/@wirecat/cli-core/dist/update/index.js
|
|
338
350
|
import { realpathSync } from "node:fs";
|
|
339
351
|
import { fileURLToPath } from "node:url";
|
|
340
352
|
var npmRegistry = /* @__PURE__ */ __name(() => hostFetch({ hosts: ["registry.npmjs.org"] }), "npmRegistry");
|
|
@@ -399,643 +411,6 @@ var appUpdate = /* @__PURE__ */ __name((app) => {
|
|
|
399
411
|
};
|
|
400
412
|
}, "appUpdate");
|
|
401
413
|
|
|
402
|
-
// 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
|
|
403
|
-
import { createHash, randomBytes } from "node:crypto";
|
|
404
|
-
import { createServer } from "node:http";
|
|
405
|
-
var DEFAULT_TIMEOUT_MS = 3e5;
|
|
406
|
-
var pkce = /* @__PURE__ */ __name(() => {
|
|
407
|
-
const codeVerifier = randomBytes(48).toString("base64url");
|
|
408
|
-
return { codeVerifier, codeChallenge: createHash("sha256").update(codeVerifier).digest("base64url") };
|
|
409
|
-
}, "pkce");
|
|
410
|
-
var queryOf = /* @__PURE__ */ __name((text4) => {
|
|
411
|
-
const trimmed = text4.trim();
|
|
412
|
-
const start = trimmed.indexOf("?");
|
|
413
|
-
return new URLSearchParams(start >= 0 ? trimmed.slice(start + 1).split("#")[0] : trimmed);
|
|
414
|
-
}, "queryOf");
|
|
415
|
-
var authorize = /* @__PURE__ */ __name(async (options) => {
|
|
416
|
-
const { provider } = options;
|
|
417
|
-
const cancelled = /* @__PURE__ */ __name(() => isCliError(options.signal?.reason) ? options.signal.reason : new CliError("cancelled", `${provider.name} sign-in was cancelled`), "cancelled");
|
|
418
|
-
if (options.signal?.aborted)
|
|
419
|
-
throw cancelled();
|
|
420
|
-
const { codeVerifier, codeChallenge } = pkce();
|
|
421
|
-
const paste = new AbortController();
|
|
422
|
-
let state = "";
|
|
423
|
-
let settled = false;
|
|
424
|
-
let accept = /* @__PURE__ */ __name(() => {
|
|
425
|
-
}, "accept");
|
|
426
|
-
let fail = /* @__PURE__ */ __name(() => {
|
|
427
|
-
}, "fail");
|
|
428
|
-
const code = new Promise((resolve2, reject) => {
|
|
429
|
-
accept = /* @__PURE__ */ __name((value) => {
|
|
430
|
-
settled = true;
|
|
431
|
-
resolve2(value);
|
|
432
|
-
}, "accept");
|
|
433
|
-
fail = /* @__PURE__ */ __name((error) => {
|
|
434
|
-
settled = true;
|
|
435
|
-
reject(error);
|
|
436
|
-
}, "fail");
|
|
437
|
-
});
|
|
438
|
-
void code.catch(() => {
|
|
439
|
-
});
|
|
440
|
-
const settle = /* @__PURE__ */ __name((query) => {
|
|
441
|
-
const value = query.get("code");
|
|
442
|
-
if (value)
|
|
443
|
-
accept(value);
|
|
444
|
-
else
|
|
445
|
-
fail(new CliError("authentication_error", `${provider.name} sign-in was declined`, { reason: "oauth.declined" }));
|
|
446
|
-
}, "settle");
|
|
447
|
-
const handler = /* @__PURE__ */ __name((request, response) => {
|
|
448
|
-
let url;
|
|
449
|
-
try {
|
|
450
|
-
url = new URL(request.url ?? "/", "http://127.0.0.1");
|
|
451
|
-
} catch {
|
|
452
|
-
response.writeHead(400).end();
|
|
453
|
-
return;
|
|
454
|
-
}
|
|
455
|
-
if (request.method !== "GET" || url.pathname !== "/callback") {
|
|
456
|
-
response.writeHead(404).end();
|
|
457
|
-
return;
|
|
458
|
-
}
|
|
459
|
-
if (settled || !state || url.searchParams.get("state") !== state) {
|
|
460
|
-
response.writeHead(400).end("This sign-in link does not belong to the waiting sign-in");
|
|
461
|
-
return;
|
|
462
|
-
}
|
|
463
|
-
if (!url.searchParams.get("code") && !url.searchParams.get("error")) {
|
|
464
|
-
response.writeHead(400).end("Missing sign-in result");
|
|
465
|
-
return;
|
|
466
|
-
}
|
|
467
|
-
response.end("Sign-in received; you can close this tab");
|
|
468
|
-
settle(url.searchParams);
|
|
469
|
-
}, "handler");
|
|
470
|
-
const server = createServer(handler);
|
|
471
|
-
const localhost = provider.redirect.kind === "loopback" && provider.redirect.host === "localhost";
|
|
472
|
-
const server6 = localhost ? createServer(handler) : void 0;
|
|
473
|
-
const onAbort = /* @__PURE__ */ __name(() => fail(cancelled()), "onAbort");
|
|
474
|
-
options.signal?.addEventListener("abort", onAbort, { once: true });
|
|
475
|
-
const timer = setTimeout(() => fail(new CliError("timeout", `${provider.name} sign-in timed out`, { reason: "oauth.timeout" })), options.timeoutMs ?? DEFAULT_TIMEOUT_MS);
|
|
476
|
-
try {
|
|
477
|
-
await new Promise((resolve2, reject) => {
|
|
478
|
-
server.once("error", reject);
|
|
479
|
-
server.listen(0, "127.0.0.1", resolve2);
|
|
480
|
-
});
|
|
481
|
-
const address = server.address();
|
|
482
|
-
if (!address || typeof address === "string")
|
|
483
|
-
throw new CliError("configuration_error", "could not start the local sign-in listener");
|
|
484
|
-
if (server6) {
|
|
485
|
-
server6.on("error", () => {
|
|
486
|
-
});
|
|
487
|
-
await new Promise((resolve2) => {
|
|
488
|
-
server6.once("error", () => resolve2());
|
|
489
|
-
server6.listen(address.port, "::1", () => resolve2());
|
|
490
|
-
});
|
|
491
|
-
}
|
|
492
|
-
const random = randomBytes(32).toString("base64url");
|
|
493
|
-
const relay = provider.redirect.kind === "relay";
|
|
494
|
-
state = relay ? `${address.port}.${random}` : random;
|
|
495
|
-
const redirectUri = provider.redirect.kind === "relay" ? provider.redirect.url : `http://${localhost ? "localhost" : "127.0.0.1"}:${address.port}/callback`;
|
|
496
|
-
const url = new URL(provider.authorizeUrl);
|
|
497
|
-
for (const [key, value] of Object.entries({
|
|
498
|
-
...provider.authorizeParams,
|
|
499
|
-
response_type: "code",
|
|
500
|
-
client_id: provider.client.clientId,
|
|
501
|
-
redirect_uri: redirectUri,
|
|
502
|
-
...options.scopes.length ? { scope: options.scopes.join(" ") } : {},
|
|
503
|
-
state,
|
|
504
|
-
code_challenge: codeChallenge,
|
|
505
|
-
code_challenge_method: "S256"
|
|
506
|
-
}))
|
|
507
|
-
url.searchParams.set(key, value);
|
|
508
|
-
options.showUrl?.(url.toString());
|
|
509
|
-
options.readPaste?.(paste.signal).then((text4) => {
|
|
510
|
-
if (settled)
|
|
511
|
-
return;
|
|
512
|
-
const query = queryOf(text4);
|
|
513
|
-
if (query.get("state") !== state || !query.get("code") && !query.get("error"))
|
|
514
|
-
fail(new CliError("authentication_error", "the pasted sign-in result does not match this sign-in", {
|
|
515
|
-
reason: "oauth.mismatch"
|
|
516
|
-
}));
|
|
517
|
-
else
|
|
518
|
-
settle(query);
|
|
519
|
-
}).catch(() => {
|
|
520
|
-
});
|
|
521
|
-
void Promise.resolve().then(() => options.openBrowser(url.toString())).catch(() => {
|
|
522
|
-
if (!options.readPaste && !options.showUrl)
|
|
523
|
-
fail(new CliError("configuration_error", "could not open the browser, and no sign-in link can be shown"));
|
|
524
|
-
});
|
|
525
|
-
return { code: await code, redirectUri, codeVerifier };
|
|
526
|
-
} finally {
|
|
527
|
-
clearTimeout(timer);
|
|
528
|
-
options.signal?.removeEventListener("abort", onAbort);
|
|
529
|
-
paste.abort();
|
|
530
|
-
for (const each of server6 ? [server, server6] : [server]) {
|
|
531
|
-
each.closeAllConnections();
|
|
532
|
-
if (each.listening)
|
|
533
|
-
await new Promise((resolve2) => each.close(() => resolve2()));
|
|
534
|
-
}
|
|
535
|
-
}
|
|
536
|
-
}, "authorize");
|
|
537
|
-
|
|
538
|
-
// 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
|
|
539
|
-
import { createHash as createHash2 } from "node:crypto";
|
|
540
|
-
import { join } from "node:path";
|
|
541
|
-
import { setTimeout as delay } from "node:timers/promises";
|
|
542
|
-
|
|
543
|
-
// 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
|
|
544
|
-
var REQUEST_LIMIT_MS = 3e4;
|
|
545
|
-
var TOKEN_LOG_EVENT = "oauth.token";
|
|
546
|
-
var object = /* @__PURE__ */ __name((value) => {
|
|
547
|
-
if (typeof value !== "object" || value === null || Array.isArray(value))
|
|
548
|
-
throw new Error("not an object");
|
|
549
|
-
return value;
|
|
550
|
-
}, "object");
|
|
551
|
-
var requestSignal = /* @__PURE__ */ __name((deadline, signal) => signal ? AbortSignal.any([signal, deadline]) : deadline, "requestSignal");
|
|
552
|
-
var cancelledBy = /* @__PURE__ */ __name((signal) => {
|
|
553
|
-
if (!signal?.aborted)
|
|
554
|
-
return;
|
|
555
|
-
throw isCliError(signal.reason) ? signal.reason : new CliError("cancelled", "sign-in was cancelled");
|
|
556
|
-
}, "cancelledBy");
|
|
557
|
-
var TRANSIENT = /* @__PURE__ */ new Set([
|
|
558
|
-
"EAI_AGAIN",
|
|
559
|
-
"ENOTFOUND",
|
|
560
|
-
"ECONNRESET",
|
|
561
|
-
"ECONNREFUSED",
|
|
562
|
-
"ETIMEDOUT",
|
|
563
|
-
"EPIPE",
|
|
564
|
-
"UND_ERR_SOCKET"
|
|
565
|
-
]);
|
|
566
|
-
var ATTEMPTS = 3;
|
|
567
|
-
var transientNetworkError = /* @__PURE__ */ __name((error) => {
|
|
568
|
-
if (isCliError(error))
|
|
569
|
-
return error.code === "network_error";
|
|
570
|
-
for (let at2 = error, depth = 0; at2 instanceof Error && depth < 4; at2 = at2.cause, depth++) {
|
|
571
|
-
const code = at2.code;
|
|
572
|
-
if (typeof code === "string" && TRANSIENT.has(code))
|
|
573
|
-
return true;
|
|
574
|
-
}
|
|
575
|
-
return false;
|
|
576
|
-
}, "transientNetworkError");
|
|
577
|
-
var post = /* @__PURE__ */ __name(async (url, body, context, deadline) => {
|
|
578
|
-
const signal = requestSignal(deadline, context.signal);
|
|
579
|
-
for (let attempt = 1; ; attempt++) {
|
|
580
|
-
cancelledBy(context.signal);
|
|
581
|
-
try {
|
|
582
|
-
return await context.fetch(url, {
|
|
583
|
-
method: "POST",
|
|
584
|
-
headers: { "content-type": "application/x-www-form-urlencoded", accept: "application/json" },
|
|
585
|
-
body,
|
|
586
|
-
signal,
|
|
587
|
-
redirect: "error"
|
|
588
|
-
});
|
|
589
|
-
} catch (error) {
|
|
590
|
-
cancelledBy(context.signal);
|
|
591
|
-
if (attempt >= ATTEMPTS || signal.aborted || !transientNetworkError(error))
|
|
592
|
-
return void 0;
|
|
593
|
-
const waited = await realSleep(500 * attempt, signal).then(() => true, () => false);
|
|
594
|
-
cancelledBy(context.signal);
|
|
595
|
-
if (!waited)
|
|
596
|
-
return void 0;
|
|
597
|
-
}
|
|
598
|
-
}
|
|
599
|
-
}, "post");
|
|
600
|
-
var clientFields = /* @__PURE__ */ __name(({ client }) => ({
|
|
601
|
-
client_id: client.clientId,
|
|
602
|
-
...client.clientSecret ? { client_secret: client.clientSecret } : {}
|
|
603
|
-
}), "clientFields");
|
|
604
|
-
var requestTokens = /* @__PURE__ */ __name((provider, params, context) => withTimeLimit(REQUEST_LIMIT_MS, (deadline) => exchangeTokens(provider, params, context, deadline)), "requestTokens");
|
|
605
|
-
var exchangeTokens = /* @__PURE__ */ __name(async (provider, params, context, deadline) => {
|
|
606
|
-
const operation = params.grant_type ?? "unknown";
|
|
607
|
-
const record2 = /* @__PURE__ */ __name((level, fields) => context.log?.[level]({ event: TOKEN_LOG_EVENT, provider: provider.id, operation, pid: process.pid, ...fields }), "record");
|
|
608
|
-
const again = `run ${context.signInCommand} again`;
|
|
609
|
-
const response = await post(provider.tokenUrl, new URLSearchParams({ ...params, ...clientFields(context) }), context, deadline);
|
|
610
|
-
if (!response) {
|
|
611
|
-
record2("warn", { outcome: "no_response" });
|
|
612
|
-
throw new CliError("outcome_unknown", `${provider.name} token request did not finish; ${again} if it keeps failing`, {
|
|
613
|
-
reason: "oauth.no-response"
|
|
614
|
-
});
|
|
615
|
-
}
|
|
616
|
-
if (!response.ok) {
|
|
617
|
-
record2("warn", { outcome: "rejected", status: response.status });
|
|
618
|
-
if (response.status === 429 || response.status >= 500)
|
|
619
|
-
throw new CliError("provider_unavailable", `${provider.name} token request failed (HTTP ${response.status})`, {
|
|
620
|
-
status: response.status,
|
|
621
|
-
retryable: true,
|
|
622
|
-
reason: "oauth.unavailable"
|
|
623
|
-
});
|
|
624
|
-
throw new CliError("authentication_error", `${provider.name} sign-in was refused (HTTP ${response.status}); ${again}`, {
|
|
625
|
-
status: response.status,
|
|
626
|
-
reason: "oauth.expired"
|
|
627
|
-
});
|
|
628
|
-
}
|
|
629
|
-
let body;
|
|
630
|
-
try {
|
|
631
|
-
body = object(await response.json());
|
|
632
|
-
} catch {
|
|
633
|
-
record2("error", { outcome: "unreadable_response", status: response.status });
|
|
634
|
-
throw new CliError("invalid_response", `${provider.name} returned an unreadable token response; ${again}`, {
|
|
635
|
-
reason: "oauth.invalid-response"
|
|
636
|
-
});
|
|
637
|
-
}
|
|
638
|
-
const previous = context.previous;
|
|
639
|
-
const refreshToken = typeof body.refresh_token === "string" && body.refresh_token ? body.refresh_token : previous?.refreshToken;
|
|
640
|
-
const expiresIn = body.expires_in;
|
|
641
|
-
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") {
|
|
642
|
-
record2("error", { outcome: "invalid_response", status: response.status });
|
|
643
|
-
throw new CliError("invalid_response", `${provider.name} returned an invalid token response; ${again}`, {
|
|
644
|
-
reason: "oauth.invalid-response"
|
|
645
|
-
});
|
|
646
|
-
}
|
|
647
|
-
if (!refreshToken) {
|
|
648
|
-
record2("error", { outcome: "no_refresh_token", status: response.status });
|
|
649
|
-
throw new CliError("authentication_error", `${provider.name} returned no offline refresh token; ${again}`, {
|
|
650
|
-
reason: "oauth.failed"
|
|
651
|
-
});
|
|
652
|
-
}
|
|
653
|
-
const scopes = typeof body.scope === "string" ? body.scope.split(/\s+/).filter(Boolean) : previous?.scopes ?? [];
|
|
654
|
-
const tokenType = typeof body.token_type === "string" ? body.token_type : previous?.tokenType;
|
|
655
|
-
record2("info", {
|
|
656
|
-
outcome: "received",
|
|
657
|
-
status: response.status,
|
|
658
|
-
...previous ? { rotated: refreshToken !== previous.refreshToken } : {}
|
|
659
|
-
});
|
|
660
|
-
return {
|
|
661
|
-
accessToken: body.access_token,
|
|
662
|
-
refreshToken,
|
|
663
|
-
...typeof expiresIn === "number" ? { expiresAt: context.now() + expiresIn * 1e3 } : {},
|
|
664
|
-
scopes,
|
|
665
|
-
...tokenType ? { tokenType } : {}
|
|
666
|
-
};
|
|
667
|
-
}, "exchangeTokens");
|
|
668
|
-
var alreadyRevoked = /* @__PURE__ */ __name(async (response) => {
|
|
669
|
-
if (response.status !== 400)
|
|
670
|
-
return false;
|
|
671
|
-
try {
|
|
672
|
-
return object(JSON.parse(await response.text())).error === "invalid_token";
|
|
673
|
-
} catch {
|
|
674
|
-
return false;
|
|
675
|
-
}
|
|
676
|
-
}, "alreadyRevoked");
|
|
677
|
-
var revokeToken = /* @__PURE__ */ __name(async (provider, tokens, context) => {
|
|
678
|
-
if (provider.revoke)
|
|
679
|
-
return provider.revoke(tokens, context);
|
|
680
|
-
if (!provider.revokeUrl)
|
|
681
|
-
throw new CliError("validation_error", `${provider.name} declares no way to revoke a sign-in`);
|
|
682
|
-
const { revokeUrl } = provider;
|
|
683
|
-
const form = new URLSearchParams({ token: tokens.refreshToken, ...clientFields(context) });
|
|
684
|
-
const { response, gone } = await withTimeLimit(REQUEST_LIMIT_MS, async (deadline) => {
|
|
685
|
-
const response2 = await post(revokeUrl, form, context, deadline);
|
|
686
|
-
return { response: response2, gone: response2 ? await alreadyRevoked(response2) : false };
|
|
687
|
-
});
|
|
688
|
-
const done = response?.ok || gone;
|
|
689
|
-
context.log?.[done ? "info" : "warn"]({
|
|
690
|
-
event: TOKEN_LOG_EVENT,
|
|
691
|
-
provider: provider.id,
|
|
692
|
-
operation: "revoke",
|
|
693
|
-
pid: process.pid,
|
|
694
|
-
outcome: response?.ok ? "revoked" : gone ? "already_revoked" : response ? "rejected" : "no_response",
|
|
695
|
-
...response ? { status: response.status } : {}
|
|
696
|
-
});
|
|
697
|
-
if (!done)
|
|
698
|
-
throw new CliError("outcome_unknown", `${provider.name} did not confirm the revoke`, {
|
|
699
|
-
reason: "oauth.revoke-failed",
|
|
700
|
-
...response ? { status: response.status } : {}
|
|
701
|
-
});
|
|
702
|
-
}, "revokeToken");
|
|
703
|
-
|
|
704
|
-
// 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
|
|
705
|
-
var inFlight = /* @__PURE__ */ new Map();
|
|
706
|
-
var refreshedInMemory = /* @__PURE__ */ new Map();
|
|
707
|
-
var tokenKeeper = /* @__PURE__ */ __name((options) => {
|
|
708
|
-
const { provider, storage, signal, log } = options;
|
|
709
|
-
const now = options.now ?? Date.now;
|
|
710
|
-
const fresh = /* @__PURE__ */ __name((tokens2) => Boolean(tokens2.accessToken) && tokens2.expiresAt !== void 0 && tokens2.expiresAt > now() + (options.freshForMs ?? 6e4), "fresh");
|
|
711
|
-
const lockPath = join(options.lockDir, `oauth-${createHash2("sha256").update(storage.key).digest("hex").slice(0, 16)}.lock`);
|
|
712
|
-
const clientOf = /* @__PURE__ */ __name((stored) => {
|
|
713
|
-
const saved = stored?.client;
|
|
714
|
-
if (!saved || saved.clientSecret || saved.clientId !== provider.client.clientId)
|
|
715
|
-
return saved ?? provider.client;
|
|
716
|
-
return provider.client;
|
|
717
|
-
}, "clientOf");
|
|
718
|
-
const context = /* @__PURE__ */ __name((client, previous) => ({
|
|
719
|
-
fetch: options.fetch,
|
|
720
|
-
client,
|
|
721
|
-
now,
|
|
722
|
-
signInCommand: options.signInCommand,
|
|
723
|
-
...signal ? { signal } : {},
|
|
724
|
-
...log ? { log } : {},
|
|
725
|
-
...previous ? { previous } : {}
|
|
726
|
-
}), "context");
|
|
727
|
-
const exchange2 = /* @__PURE__ */ __name((params, ctx) => provider.exchange ? provider.exchange(params, ctx) : requestTokens(provider, params, ctx), "exchange");
|
|
728
|
-
const notSignedIn = /* @__PURE__ */ __name(() => new CliError("authentication_error", `not signed in to ${provider.name}; run ${options.signInCommand}`, {
|
|
729
|
-
reason: "session.missing"
|
|
730
|
-
}), "notSignedIn");
|
|
731
|
-
const busy = /* @__PURE__ */ __name((error) => isCliError(error) && error.details.reason === "file.locked", "busy");
|
|
732
|
-
const acquire = /* @__PURE__ */ __name(async () => {
|
|
733
|
-
const started = performance.now();
|
|
734
|
-
let waiting = false;
|
|
735
|
-
for (; ; ) {
|
|
736
|
-
try {
|
|
737
|
-
return await acquireLock(lockPath, signal ? { signal } : {});
|
|
738
|
-
} catch (error) {
|
|
739
|
-
if (!busy(error))
|
|
740
|
-
throw error;
|
|
741
|
-
if (!waiting) {
|
|
742
|
-
waiting = true;
|
|
743
|
-
log?.info({
|
|
744
|
-
event: TOKEN_LOG_EVENT,
|
|
745
|
-
provider: provider.id,
|
|
746
|
-
operation: "lock",
|
|
747
|
-
outcome: "waiting",
|
|
748
|
-
pid: process.pid
|
|
749
|
-
});
|
|
750
|
-
}
|
|
751
|
-
if (performance.now() - started > (options.lockWaitMs ?? 45e3))
|
|
752
|
-
throw new CliError("provider_unavailable", `another process holds this ${provider.name} sign-in; retry`, {
|
|
753
|
-
reason: "oauth.locked",
|
|
754
|
-
retryable: true
|
|
755
|
-
});
|
|
756
|
-
await delay(options.lockRetryMs ?? 50, void 0, signal ? { signal } : {}).catch(() => {
|
|
757
|
-
throw new CliError("cancelled", `${provider.name} sign-in was cancelled`);
|
|
758
|
-
});
|
|
759
|
-
}
|
|
760
|
-
}
|
|
761
|
-
}, "acquire");
|
|
762
|
-
const locked = /* @__PURE__ */ __name(async (work) => {
|
|
763
|
-
const lock = await acquire();
|
|
764
|
-
try {
|
|
765
|
-
return await work();
|
|
766
|
-
} finally {
|
|
767
|
-
await lock.release().catch(() => {
|
|
768
|
-
});
|
|
769
|
-
}
|
|
770
|
-
}, "locked");
|
|
771
|
-
const shared2 = /* @__PURE__ */ __name((work) => {
|
|
772
|
-
const running = inFlight.get(lockPath);
|
|
773
|
-
if (running)
|
|
774
|
-
return running;
|
|
775
|
-
const started = locked(work).finally(() => inFlight.delete(lockPath));
|
|
776
|
-
inFlight.set(lockPath, started);
|
|
777
|
-
return started;
|
|
778
|
-
}, "shared");
|
|
779
|
-
const remembered = /* @__PURE__ */ __name((saved) => {
|
|
780
|
-
const kept = refreshedInMemory.get(lockPath);
|
|
781
|
-
return kept && fresh(kept) && kept.refreshToken === saved.refreshToken ? kept : void 0;
|
|
782
|
-
}, "remembered");
|
|
783
|
-
const forget = /* @__PURE__ */ __name(() => refreshedInMemory.delete(lockPath), "forget");
|
|
784
|
-
let answered;
|
|
785
|
-
const answer2 = /* @__PURE__ */ __name((given) => {
|
|
786
|
-
answered = given;
|
|
787
|
-
return given;
|
|
788
|
-
}, "answer");
|
|
789
|
-
const tokens = /* @__PURE__ */ __name(async ({ refresh = false } = {}) => {
|
|
790
|
-
const seen = storage.read();
|
|
791
|
-
if (!seen)
|
|
792
|
-
throw notSignedIn();
|
|
793
|
-
if (!refresh) {
|
|
794
|
-
const kept = remembered(seen.tokens);
|
|
795
|
-
if (kept)
|
|
796
|
-
return answer2(kept);
|
|
797
|
-
if (fresh(seen.tokens))
|
|
798
|
-
return answer2(seen.tokens);
|
|
799
|
-
}
|
|
800
|
-
const refused2 = answered ?? remembered(seen.tokens) ?? seen.tokens;
|
|
801
|
-
return answer2(await shared2(async () => {
|
|
802
|
-
const current = storage.read();
|
|
803
|
-
if (!current)
|
|
804
|
-
throw notSignedIn();
|
|
805
|
-
const latest = remembered(current.tokens) ?? current.tokens;
|
|
806
|
-
if (refresh) {
|
|
807
|
-
if (latest.accessToken !== refused2.accessToken && fresh(latest))
|
|
808
|
-
return latest;
|
|
809
|
-
} else {
|
|
810
|
-
if (latest !== current.tokens)
|
|
811
|
-
return latest;
|
|
812
|
-
if (fresh(current.tokens) || current.tokens.refreshToken !== seen.tokens.refreshToken)
|
|
813
|
-
return current.tokens;
|
|
814
|
-
}
|
|
815
|
-
if (storage.moved && storage.rotating)
|
|
816
|
-
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" });
|
|
817
|
-
const client = clientOf(current);
|
|
818
|
-
const refreshed = await exchange2({ grant_type: "refresh_token", refresh_token: current.tokens.refreshToken }, context(client, current.tokens));
|
|
819
|
-
if (storage.moved && refreshed.refreshToken === current.tokens.refreshToken)
|
|
820
|
-
refreshedInMemory.set(lockPath, refreshed);
|
|
821
|
-
else
|
|
822
|
-
storage.write({ tokens: refreshed, client });
|
|
823
|
-
return refreshed;
|
|
824
|
-
}));
|
|
825
|
-
}, "tokens");
|
|
826
|
-
return {
|
|
827
|
-
tokens,
|
|
828
|
-
accessToken: /* @__PURE__ */ __name(async (tokensOptions) => {
|
|
829
|
-
const current = await tokens(tokensOptions);
|
|
830
|
-
if (!current.accessToken)
|
|
831
|
-
throw notSignedIn();
|
|
832
|
-
return current.accessToken;
|
|
833
|
-
}, "accessToken"),
|
|
834
|
-
signIn: /* @__PURE__ */ __name(async ({ accept, ...authorizeOptions }) => {
|
|
835
|
-
storage.probe();
|
|
836
|
-
const authorization = await authorize({ ...authorizeOptions, provider, ...signal ? { signal } : {} });
|
|
837
|
-
const client = provider.client;
|
|
838
|
-
const received = await exchange2({
|
|
839
|
-
grant_type: "authorization_code",
|
|
840
|
-
code: authorization.code,
|
|
841
|
-
redirect_uri: authorization.redirectUri,
|
|
842
|
-
code_verifier: authorization.codeVerifier
|
|
843
|
-
}, context(client));
|
|
844
|
-
const extra = await accept?.(received) ?? void 0;
|
|
845
|
-
await locked(async () => {
|
|
846
|
-
forget();
|
|
847
|
-
storage.write({ tokens: received, client, ...extra ? { extra } : {} }, { signIn: true });
|
|
848
|
-
});
|
|
849
|
-
return { scopes: received.scopes };
|
|
850
|
-
}, "signIn"),
|
|
851
|
-
save: /* @__PURE__ */ __name((saved, extra) => locked(async () => {
|
|
852
|
-
forget();
|
|
853
|
-
storage.write({ tokens: saved, client: clientOf(storage.read()), ...extra ? { extra } : {} }, { signIn: true });
|
|
854
|
-
}), "save"),
|
|
855
|
-
signOut: /* @__PURE__ */ __name(({ revoke = false } = {}) => locked(async () => {
|
|
856
|
-
forget();
|
|
857
|
-
const current = storage.read();
|
|
858
|
-
let revoked = false;
|
|
859
|
-
if (revoke && current) {
|
|
860
|
-
await revokeToken(provider, current.tokens, context(clientOf(current)));
|
|
861
|
-
revoked = true;
|
|
862
|
-
}
|
|
863
|
-
return { revoked, removed: storage.remove() };
|
|
864
|
-
}), "signOut")
|
|
865
|
-
};
|
|
866
|
-
}, "tokenKeeper");
|
|
867
|
-
|
|
868
|
-
// 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
|
|
869
|
-
var invalid = /* @__PURE__ */ __name(() => new CliError("authentication_error", "the saved sign-in cannot be read; sign in again", { reason: "oauth.invalid" }), "invalid");
|
|
870
|
-
var parse = /* @__PURE__ */ __name((raw) => {
|
|
871
|
-
let value;
|
|
872
|
-
try {
|
|
873
|
-
value = JSON.parse(raw);
|
|
874
|
-
} catch {
|
|
875
|
-
throw invalid();
|
|
876
|
-
}
|
|
877
|
-
if (typeof value !== "object" || value === null || Array.isArray(value))
|
|
878
|
-
throw invalid();
|
|
879
|
-
return value;
|
|
880
|
-
}, "parse");
|
|
881
|
-
var text2 = /* @__PURE__ */ __name((value) => typeof value === "string" && value ? value : void 0, "text");
|
|
882
|
-
var finite = /* @__PURE__ */ __name((value) => typeof value === "number" && Number.isFinite(value) ? value : void 0, "finite");
|
|
883
|
-
var previousOf = /* @__PURE__ */ __name((raw) => {
|
|
884
|
-
if (raw === void 0)
|
|
885
|
-
return {};
|
|
886
|
-
try {
|
|
887
|
-
return parse(raw);
|
|
888
|
-
} catch {
|
|
889
|
-
return {};
|
|
890
|
-
}
|
|
891
|
-
}, "previousOf");
|
|
892
|
-
var defined = /* @__PURE__ */ __name((value) => Object.fromEntries(Object.entries(value).filter(([, field]) => field !== void 0)), "defined");
|
|
893
|
-
var oauthAccount = /* @__PURE__ */ __name((providerId, profile) => {
|
|
894
|
-
if (!profile.trim())
|
|
895
|
-
throw new CliError("validation_error", "name a profile: a sign-in always belongs to one", {
|
|
896
|
-
reason: "profile.missing"
|
|
897
|
-
});
|
|
898
|
-
return `oauth:${providerId}:${profile}`;
|
|
899
|
-
}, "oauthAccount");
|
|
900
|
-
var standardCodec = /* @__PURE__ */ __name((providerId) => ({
|
|
901
|
-
decode: /* @__PURE__ */ __name((raw) => {
|
|
902
|
-
const value = parse(raw);
|
|
903
|
-
const refreshToken = text2(value.refreshToken);
|
|
904
|
-
const clientId = text2(value.clientId);
|
|
905
|
-
if (value.version !== 1 || value.provider !== providerId || !refreshToken || !clientId)
|
|
906
|
-
throw invalid();
|
|
907
|
-
if (!Array.isArray(value.scopes) || !value.scopes.every((scope) => typeof scope === "string"))
|
|
908
|
-
throw invalid();
|
|
909
|
-
const source = text2(value.clientSource);
|
|
910
|
-
return {
|
|
911
|
-
client: defined({ clientId, clientSecret: text2(value.clientSecret), source }),
|
|
912
|
-
tokens: defined({
|
|
913
|
-
accessToken: text2(value.accessToken),
|
|
914
|
-
refreshToken,
|
|
915
|
-
expiresAt: finite(value.expiresAt),
|
|
916
|
-
scopes: value.scopes,
|
|
917
|
-
tokenType: text2(value.tokenType)
|
|
918
|
-
})
|
|
919
|
-
};
|
|
920
|
-
}, "decode"),
|
|
921
|
-
encode: /* @__PURE__ */ __name(({ tokens, client, previous, extra }) => JSON.stringify(defined({
|
|
922
|
-
...previousOf(previous),
|
|
923
|
-
...extra,
|
|
924
|
-
version: 1,
|
|
925
|
-
provider: providerId,
|
|
926
|
-
clientId: client.clientId,
|
|
927
|
-
// Only WireCat's secret, which is public: a later release may ship another default app, and a refresh needs
|
|
928
|
-
// the secret of the app that signed in. An owner's own secret stays where the owner keeps it.
|
|
929
|
-
clientSecret: client.source === "constants" ? client.clientSecret : void 0,
|
|
930
|
-
clientSource: client.source,
|
|
931
|
-
accessToken: tokens.accessToken,
|
|
932
|
-
refreshToken: tokens.refreshToken,
|
|
933
|
-
expiresAt: tokens.expiresAt,
|
|
934
|
-
scopes: tokens.scopes,
|
|
935
|
-
tokenType: tokens.tokenType
|
|
936
|
-
})), "encode")
|
|
937
|
-
}), "standardCodec");
|
|
938
|
-
var googleStandard = standardCodec("google");
|
|
939
|
-
var accountTokenCodec = /* @__PURE__ */ __name((providerId) => {
|
|
940
|
-
const standard = standardCodec(providerId);
|
|
941
|
-
return {
|
|
942
|
-
rotating: true,
|
|
943
|
-
decode: /* @__PURE__ */ __name((raw) => {
|
|
944
|
-
const stored = standard.decode(raw);
|
|
945
|
-
const value = parse(raw);
|
|
946
|
-
const clientSecret = text2(value.clientSecret);
|
|
947
|
-
const host = text2(value.host);
|
|
948
|
-
const userId = text2(value.userId);
|
|
949
|
-
if (!host || !userId || !clientSecret)
|
|
950
|
-
throw invalid();
|
|
951
|
-
return { ...stored, client: { ...stored.client, clientSecret }, account: { host, userId } };
|
|
952
|
-
}, "decode"),
|
|
953
|
-
encode: /* @__PURE__ */ __name((input) => {
|
|
954
|
-
const entry = parse(standard.encode(input));
|
|
955
|
-
const from = input.signIn ? input.extra ?? {} : entry;
|
|
956
|
-
if (!input.client.clientSecret || typeof from.host !== "string" || typeof from.userId !== "string")
|
|
957
|
-
throw new CliError("configuration_error", "an account-bound sign-in needs the app's secret, its host and user");
|
|
958
|
-
entry.clientSecret = input.client.clientSecret;
|
|
959
|
-
return JSON.stringify(entry);
|
|
960
|
-
}, "encode")
|
|
961
|
-
};
|
|
962
|
-
}, "accountTokenCodec");
|
|
963
|
-
var keyringFailure = /* @__PURE__ */ __name((thrown, secret) => {
|
|
964
|
-
const failure = new CliError("configuration_error", "could not reach the saved sign-in; use an available keyring or file storage", { reason: "oauth.not-saved" });
|
|
965
|
-
const words = thrown instanceof Error ? thrown.message : String(thrown);
|
|
966
|
-
failure.cause = new Error(secret ? words.replaceAll(secret, "[secret]") : words);
|
|
967
|
-
return failure;
|
|
968
|
-
}, "keyringFailure");
|
|
969
|
-
var credentialStorage = /* @__PURE__ */ __name((options) => {
|
|
970
|
-
if (!options.credentials.keyring)
|
|
971
|
-
throw new CliError("configuration_error", "a sign-in store needs its keyring passed in, never a default");
|
|
972
|
-
const credentials = new Credentials(options.credentials);
|
|
973
|
-
const { account: account2, codec } = options;
|
|
974
|
-
const moved = options.credentials.isolated === true || options.credentials.keyring === systemKeyring && isMovedRun({ appName: options.credentials.service, env: options.credentials.env ?? process.env });
|
|
975
|
-
const service = keyringService(options.credentials.service, options.credentials.configDir, options.credentials.isolated);
|
|
976
|
-
const raw = /* @__PURE__ */ __name((name) => {
|
|
977
|
-
try {
|
|
978
|
-
return credentials.read(name)?.secret;
|
|
979
|
-
} catch (error) {
|
|
980
|
-
if (error instanceof CliError)
|
|
981
|
-
throw error;
|
|
982
|
-
throw keyringFailure(error);
|
|
983
|
-
}
|
|
984
|
-
}, "raw");
|
|
985
|
-
const fallsBack = options.credentials.storage !== "keyring";
|
|
986
|
-
const replaced = /* @__PURE__ */ __name((name) => {
|
|
987
|
-
try {
|
|
988
|
-
return raw(name);
|
|
989
|
-
} catch (error) {
|
|
990
|
-
if (fallsBack && error instanceof CliError && error.details.reason === "keyring.unreachable")
|
|
991
|
-
return void 0;
|
|
992
|
-
throw error;
|
|
993
|
-
}
|
|
994
|
-
}, "replaced");
|
|
995
|
-
const save = /* @__PURE__ */ __name((value, writeOptions) => {
|
|
996
|
-
try {
|
|
997
|
-
credentials.write(account2, value, writeOptions);
|
|
998
|
-
} catch (error) {
|
|
999
|
-
throw keyringFailure(error, value);
|
|
1000
|
-
}
|
|
1001
|
-
}, "save");
|
|
1002
|
-
const current = /* @__PURE__ */ __name(() => {
|
|
1003
|
-
const own = raw(account2);
|
|
1004
|
-
if (own !== void 0)
|
|
1005
|
-
return own;
|
|
1006
|
-
for (const legacy of options.legacyAccounts ?? []) {
|
|
1007
|
-
const found = raw(legacy);
|
|
1008
|
-
if (found === void 0)
|
|
1009
|
-
continue;
|
|
1010
|
-
codec.decode(found);
|
|
1011
|
-
if (!moved)
|
|
1012
|
-
save(found);
|
|
1013
|
-
return found;
|
|
1014
|
-
}
|
|
1015
|
-
return void 0;
|
|
1016
|
-
}, "current");
|
|
1017
|
-
return {
|
|
1018
|
-
key: `${service}\0${account2}`,
|
|
1019
|
-
moved,
|
|
1020
|
-
...codec.rotating ? { rotating: true } : {},
|
|
1021
|
-
probe: /* @__PURE__ */ __name(() => {
|
|
1022
|
-
replaced(account2);
|
|
1023
|
-
}, "probe"),
|
|
1024
|
-
read: /* @__PURE__ */ __name(() => {
|
|
1025
|
-
const value = current();
|
|
1026
|
-
return value === void 0 ? void 0 : codec.decode(value);
|
|
1027
|
-
}, "read"),
|
|
1028
|
-
write: /* @__PURE__ */ __name((input, writeOptions) => save(codec.encode({ ...input, previous: replaced(account2), ...writeOptions?.signIn ? { signIn: true } : {} }), writeOptions), "write"),
|
|
1029
|
-
remove: /* @__PURE__ */ __name(() => {
|
|
1030
|
-
try {
|
|
1031
|
-
return credentials.remove(account2);
|
|
1032
|
-
} catch (error) {
|
|
1033
|
-
throw keyringFailure(error);
|
|
1034
|
-
}
|
|
1035
|
-
}, "remove")
|
|
1036
|
-
};
|
|
1037
|
-
}, "credentialStorage");
|
|
1038
|
-
|
|
1039
414
|
// dist/amo/json.js
|
|
1040
415
|
var isRecord = values_exports.isRaw;
|
|
1041
416
|
|
|
@@ -1044,10 +419,10 @@ var ACCOUNT_DOMAINS = ["amocrm.ru", "amocrm.com", "kommo.com"];
|
|
|
1044
419
|
var HOST = new RegExp(`^(?!www\\.)[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?\\.(${ACCOUNT_DOMAINS.join("|").replaceAll(".", "\\.")})$`);
|
|
1045
420
|
var accountOrigin = /* @__PURE__ */ __name((raw) => {
|
|
1046
421
|
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");
|
|
1047
|
-
const
|
|
422
|
+
const text3 = raw.trim();
|
|
1048
423
|
let url;
|
|
1049
424
|
try {
|
|
1050
|
-
url = new URL(/^[a-z]+:\/\//i.test(
|
|
425
|
+
url = new URL(/^[a-z]+:\/\//i.test(text3) ? text3 : `https://${text3}`);
|
|
1051
426
|
} catch {
|
|
1052
427
|
throw refused2("it is not an address");
|
|
1053
428
|
}
|
|
@@ -1081,6 +456,10 @@ var decodeSignIn = /* @__PURE__ */ __name((secret) => {
|
|
|
1081
456
|
// dist/amo/oauth.js
|
|
1082
457
|
var PROVIDER2 = "amocrm";
|
|
1083
458
|
var RELAY_URL = "https://wirecat.dev/webhooks/apps/amo-callback";
|
|
459
|
+
var CONNECT_ORIGIN = "https://connect.wirecat.dev";
|
|
460
|
+
var BUTTON_RELAY_URL = `${CONNECT_ORIGIN}/webhooks/apps/amo-callback`;
|
|
461
|
+
var CONNECT_PAGE_URL = `${CONNECT_ORIGIN}/connect/amo.html`;
|
|
462
|
+
var CLAIM_URL = `${CONNECT_ORIGIN}/api/amo/claim`;
|
|
1084
463
|
var REQUEST_MS = 3e4;
|
|
1085
464
|
var HINT = /^[\w .,:'`-]{1,200}$/;
|
|
1086
465
|
var account = accountTokenCodec(PROVIDER2);
|
|
@@ -1091,10 +470,11 @@ var appCodec = {
|
|
|
1091
470
|
const stored = account.decode(raw);
|
|
1092
471
|
const entry = JSON.parse(raw);
|
|
1093
472
|
const redirectUri = isRecord(entry) && typeof entry.redirectUri === "string" ? entry.redirectUri : RELAY_URL;
|
|
1094
|
-
return Object.assign(stored, { redirectUri });
|
|
473
|
+
return Object.assign(stored, { redirectUri, browser: isRecord(entry) && entry.browser === true });
|
|
1095
474
|
}, "decode")
|
|
1096
475
|
};
|
|
1097
476
|
var paths = /* @__PURE__ */ __name((env) => resolvePaths({ appName: IDENTITY.appName, prefix: IDENTITY.envPrefix, env }), "paths");
|
|
477
|
+
var lockDirOf = /* @__PURE__ */ __name((env) => paths(env).config, "lockDirOf");
|
|
1098
478
|
var credentialsOf = /* @__PURE__ */ __name((env, keyring, storage) => ({
|
|
1099
479
|
configDir: paths(env).config,
|
|
1100
480
|
service: IDENTITY.appName,
|
|
@@ -1226,16 +606,12 @@ var appAuthOf = /* @__PURE__ */ __name((options) => {
|
|
|
1226
606
|
storage,
|
|
1227
607
|
lockDir: paths(options.env).config,
|
|
1228
608
|
fetch: fetchFor(origin, options.fetch),
|
|
1229
|
-
signInCommand: `${IDENTITY.command} ${options.profile} session start --host ${origin} --client-id ${stored.client.clientId}`,
|
|
609
|
+
signInCommand: `${IDENTITY.command} ${options.profile} session start --host ${origin} ${stored.browser ? "--one-click" : `--client-id ${stored.client.clientId}`}`,
|
|
1230
610
|
...options.signal ? { signal: options.signal } : {}
|
|
1231
611
|
});
|
|
1232
612
|
return { origin, userId: stored.account.userId, accessToken: /* @__PURE__ */ __name((refresh) => keeper.accessToken({ refresh }), "accessToken") };
|
|
1233
613
|
}, "appAuthOf");
|
|
1234
614
|
|
|
1235
|
-
// dist/commands/account.js
|
|
1236
|
-
import { readFileSync } from "node:fs";
|
|
1237
|
-
import { join as join2 } from "node:path";
|
|
1238
|
-
|
|
1239
615
|
// dist/api-keys.js
|
|
1240
616
|
var PREFIX = "/api/v4/";
|
|
1241
617
|
var apiKey = /* @__PURE__ */ __name((operation) => [
|
|
@@ -1407,9 +783,9 @@ var permissions = commandPermissions({
|
|
|
1407
783
|
extra: [.../* @__PURE__ */ new Set([...CRM_WRITE_KEYS, ...API_KEYS])],
|
|
1408
784
|
defaults: { ...CRM_WRITE_DEFAULTS, ...API_DEFAULTS }
|
|
1409
785
|
});
|
|
1410
|
-
var isAccount = /* @__PURE__ */ __name((
|
|
786
|
+
var isAccount = /* @__PURE__ */ __name((text3) => {
|
|
1411
787
|
try {
|
|
1412
|
-
accountOrigin(
|
|
788
|
+
accountOrigin(text3);
|
|
1413
789
|
return true;
|
|
1414
790
|
} catch {
|
|
1415
791
|
return false;
|
|
@@ -1473,7 +849,7 @@ var amoError = /* @__PURE__ */ __name((operation, status, body, { json, waitMs,
|
|
|
1473
849
|
}, "amoError");
|
|
1474
850
|
|
|
1475
851
|
// dist/amo/transport.js
|
|
1476
|
-
var
|
|
852
|
+
var DEFAULT_TIMEOUT_MS = 1e4;
|
|
1477
853
|
var LARGEST_ANSWER = 16 * 1024 * 1024;
|
|
1478
854
|
var LONGEST_PACE_WAIT_MS = 2e4;
|
|
1479
855
|
var REQUEST_MARGIN_MS = 1e3;
|
|
@@ -1512,7 +888,7 @@ var AmoTransport = class {
|
|
|
1512
888
|
#admin;
|
|
1513
889
|
constructor(options) {
|
|
1514
890
|
this.#signIn = options.signIn;
|
|
1515
|
-
this.#timeoutMs = options.timeoutMs ??
|
|
891
|
+
this.#timeoutMs = options.timeoutMs ?? DEFAULT_TIMEOUT_MS;
|
|
1516
892
|
this.#fetch = hostFetch({
|
|
1517
893
|
hosts: [new URL(options.signIn.origin).hostname],
|
|
1518
894
|
...options.fetch ? { fetch: options.fetch } : {},
|
|
@@ -1797,7 +1173,7 @@ var transportFor = /* @__PURE__ */ __name((command, signIn, events) => {
|
|
|
1797
1173
|
var withAccount = /* @__PURE__ */ __name((command, body) => contextOf(command).run((events) => body(transportFor(command, signInOf(command), events))), "withAccount");
|
|
1798
1174
|
|
|
1799
1175
|
// dist/whoami.js
|
|
1800
|
-
var { text:
|
|
1176
|
+
var { text: text2 } = values_exports;
|
|
1801
1177
|
var accountUser = /* @__PURE__ */ __name(async (account2) => {
|
|
1802
1178
|
const { body } = await account2.request({ route: ROUTES.account });
|
|
1803
1179
|
const about = isRecord(body) ? body : {};
|
|
@@ -1815,313 +1191,44 @@ var accountUser = /* @__PURE__ */ __name(async (account2) => {
|
|
|
1815
1191
|
const admin = typeof rights.is_admin === "boolean" ? rights.is_admin : null;
|
|
1816
1192
|
return {
|
|
1817
1193
|
account: new URL(account2.origin).host,
|
|
1818
|
-
account_info: { id: String(about.id ?? ""), name:
|
|
1819
|
-
user: { id: userId, name:
|
|
1194
|
+
account_info: { id: String(about.id ?? ""), name: text2(about.name), subdomain: text2(about.subdomain) },
|
|
1195
|
+
user: { id: userId, name: text2(user.name), admin, manager: admin }
|
|
1820
1196
|
};
|
|
1821
1197
|
}, "accountUser");
|
|
1822
1198
|
|
|
1823
|
-
// dist/commands/
|
|
1199
|
+
// dist/commands/write.js
|
|
1200
|
+
var write = /* @__PURE__ */ __name(async (command, { key, extra = [], act }) => {
|
|
1201
|
+
const defaults = permissions.defaults;
|
|
1202
|
+
const { env, settings, run: run3 } = contextOf(command);
|
|
1203
|
+
const lock = readOnlyLockOf(IDENTITY, env);
|
|
1204
|
+
if (lock)
|
|
1205
|
+
throw readOnlyRefusal(lock, "change the amoCRM account");
|
|
1206
|
+
const operationId = newOperationId();
|
|
1207
|
+
const levelOf = /* @__PURE__ */ __name((one) => levelFor(settings.permissions, one, defaults).level, "levelOf");
|
|
1208
|
+
const guard = keyedGuard((ask) => guardFor(
|
|
1209
|
+
IDENTITY,
|
|
1210
|
+
// amoCRM limits its own rate; the guard is here for the levels and the journal, not a send limit.
|
|
1211
|
+
{ ...settings, sendsPerHour: Number.MAX_SAFE_INTEGER, permissionDefaults: defaults },
|
|
1212
|
+
outputFor(command).renderer.warn,
|
|
1213
|
+
environmentOf(command).env ?? process.env,
|
|
1214
|
+
ask
|
|
1215
|
+
), terminalAsker(command), levelOf, extra);
|
|
1216
|
+
const request = { chatId: null, kind: "edit", key, operationId };
|
|
1217
|
+
guard.refuse(request);
|
|
1218
|
+
const signIn = signInOf(command);
|
|
1219
|
+
let done;
|
|
1220
|
+
try {
|
|
1221
|
+
done = await guardedWrite(guard, request, () => run3((events) => act(transportFor(command, signIn, events), operationId)));
|
|
1222
|
+
} catch (error) {
|
|
1223
|
+
if (error instanceof CliError && error.code === "outcome_unknown")
|
|
1224
|
+
throw new CliError("outcome_unknown", `${error.message} \u2014 check the account before you write it again: amoCRM has no idempotency key and would make it a second time`, { ...error.details, operation_id: operationId });
|
|
1225
|
+
throw error;
|
|
1226
|
+
}
|
|
1227
|
+
renderAnswer(command, outputFor(command), itemOf({ operation_id: operationId, ...done }));
|
|
1228
|
+
}, "write");
|
|
1229
|
+
|
|
1230
|
+
// dist/commands/api.js
|
|
1824
1231
|
var AMO = IDENTITY.command;
|
|
1825
|
-
var answer = /* @__PURE__ */ __name((command, item) => renderAnswer(command, outputFor(command), itemOf(item)), "answer");
|
|
1826
|
-
var storageOf = /* @__PURE__ */ __name((raw) => {
|
|
1827
|
-
if (raw === "keyring" || raw === "file")
|
|
1828
|
-
return raw;
|
|
1829
|
-
throw new CliError("validation_error", `--credential-storage takes keyring or file; got ${raw}`);
|
|
1830
|
-
}, "storageOf");
|
|
1831
|
-
var tokensHere = /* @__PURE__ */ __name((env, keyring) => new ProfileTokenStore({ app: IDENTITY, env, ...keyring ? { keyring } : {} }), "tokensHere");
|
|
1832
|
-
var signedInAs = /* @__PURE__ */ __name((env, keyring, profile) => {
|
|
1833
|
-
const app = withoutKeyring(() => appStorage(env, profile, keyring).read()?.account, () => tokensHere(env, keyring).read(profile));
|
|
1834
|
-
if (app)
|
|
1835
|
-
return { host: new URL(app.host).host, userId: app.userId };
|
|
1836
|
-
const saved = tokensHere(env, keyring).read(profile);
|
|
1837
|
-
if (!saved || saved.source === "environment")
|
|
1838
|
-
return void 0;
|
|
1839
|
-
const signIn = decodeSignIn(saved.secret);
|
|
1840
|
-
return { host: new URL(signIn.origin).host, userId: signIn.userId };
|
|
1841
|
-
}, "signedInAs");
|
|
1842
|
-
var refuseDuplicate = /* @__PURE__ */ __name((env, keyring, profile, at2) => {
|
|
1843
|
-
const { configuredProfiles } = configuration.resolveSettings({}, { env, needsProfile: false });
|
|
1844
|
-
const other = profilesHere(IDENTITY, configuredProfiles, env).find((one) => {
|
|
1845
|
-
if (one === profile)
|
|
1846
|
-
return false;
|
|
1847
|
-
try {
|
|
1848
|
-
const found = signedInAs(env, keyring, one);
|
|
1849
|
-
return found?.host === at2.host && found.userId === at2.userId;
|
|
1850
|
-
} catch {
|
|
1851
|
-
return false;
|
|
1852
|
-
}
|
|
1853
|
-
});
|
|
1854
|
-
if (!other)
|
|
1855
|
-
return;
|
|
1856
|
-
throw new CliError("conflict", `profile ${other} already signs in to ${at2.host} as user ${at2.userId}. Use \`${AMO} ${other}\`, sign it in again with \`${AMO} ${other} session start\`, or end it with \`${AMO} ${other} session end\` first`, { reason: "session.duplicate", profile: other, account: at2.host });
|
|
1857
|
-
}, "refuseDuplicate");
|
|
1858
|
-
var checkedToken = /* @__PURE__ */ __name(async (command, origin, token) => {
|
|
1859
|
-
const { env, profile, keyring, run: run3 } = contextOf(command);
|
|
1860
|
-
const who = await run3((events) => accountUser(transportFor(command, { origin, token }, events)));
|
|
1861
|
-
refuseDuplicate(env, keyring, profile, { host: who.account, userId: who.user.id });
|
|
1862
|
-
return {
|
|
1863
|
-
who,
|
|
1864
|
-
signIn: encodeSignIn({ origin, token, userId: who.user.id }),
|
|
1865
|
-
account: `${who.account}:${who.user.id}`
|
|
1866
|
-
};
|
|
1867
|
-
}, "checkedToken");
|
|
1868
|
-
var keepHost = /* @__PURE__ */ __name((command, origin) => {
|
|
1869
|
-
const { profile, settings } = contextOf(command);
|
|
1870
|
-
configuration.changeSetting(settings.configPath, { profile, setting: "host", value: JSON.stringify(origin) });
|
|
1871
|
-
}, "keepHost");
|
|
1872
|
-
var PASTE = "If the browser did not come back here, paste the address it ended on: ";
|
|
1873
|
-
var startWithApp = /* @__PURE__ */ __name(async (command, args, origin) => {
|
|
1874
|
-
const { env, profile, tokens, keyring, run: run3, environment } = contextOf(command);
|
|
1875
|
-
const clientId = (args.clientId ?? env[CLIENT_ID] ?? "").trim();
|
|
1876
|
-
const clientSecret = env[CLIENT_SECRET]?.trim() || (await readSecret("amoCRM integration secret key: ", secretInputOf(command))).trim();
|
|
1877
|
-
if (!clientSecret)
|
|
1878
|
-
throw new CliError("validation_error", "no secret key was given");
|
|
1879
|
-
const flags = command.optsWithGlobals();
|
|
1880
|
-
const machine = flags.json === true || flags.jsonl === true;
|
|
1881
|
-
const person = !machine && flags.input !== false && !env.CI && (environment.tty ?? process.stdout.isTTY) === true;
|
|
1882
|
-
const { streams } = outputFor(command);
|
|
1883
|
-
const steps = signInSteps({
|
|
1884
|
-
diagnostic: /* @__PURE__ */ __name((line) => streams.diagnostic(`${line}
|
|
1885
|
-
`), "diagnostic"),
|
|
1886
|
-
json: machine || environment.tty === false,
|
|
1887
|
-
answers: false
|
|
1888
|
-
});
|
|
1889
|
-
const input = secretInputOf(command).input ?? process.stdin;
|
|
1890
|
-
const given = environment.answer;
|
|
1891
|
-
const signInCommand = `${AMO} ${profile} session start --host ${origin} --client-id ${clientId}`;
|
|
1892
|
-
const who = await run3((events) => appSignIn({
|
|
1893
|
-
env,
|
|
1894
|
-
profile,
|
|
1895
|
-
origin,
|
|
1896
|
-
client: { clientId, clientSecret },
|
|
1897
|
-
storage: args.credentialStorage,
|
|
1898
|
-
keyring,
|
|
1899
|
-
fetch: environment.fetch,
|
|
1900
|
-
signal: environment.signal,
|
|
1901
|
-
signInCommand,
|
|
1902
|
-
steps: {
|
|
1903
|
-
openBrowser: /* @__PURE__ */ __name(async (url) => {
|
|
1904
|
-
if (environment.openBrowser)
|
|
1905
|
-
return environment.openBrowser(url);
|
|
1906
|
-
if (person)
|
|
1907
|
-
await openBrowser(url);
|
|
1908
|
-
}, "openBrowser"),
|
|
1909
|
-
showUrl: /* @__PURE__ */ __name((url) => {
|
|
1910
|
-
steps.openUrl(url, "Sign in to amoCRM and allow the integration");
|
|
1911
|
-
streams.diagnostic(`Open the amoCRM sign-in: ${url}
|
|
1912
|
-
`);
|
|
1913
|
-
}, "showUrl"),
|
|
1914
|
-
// A pipe was the secret, and an empty answer would end the sign-in before the browser came back.
|
|
1915
|
-
...given ? {
|
|
1916
|
-
readPaste: /* @__PURE__ */ __name(async () => {
|
|
1917
|
-
const text4 = await given(PASTE);
|
|
1918
|
-
if (text4 === null)
|
|
1919
|
-
throw new CliError("cancelled", "nobody is at a terminal to paste");
|
|
1920
|
-
return text4;
|
|
1921
|
-
}, "readPaste")
|
|
1922
|
-
} : input.isTTY && !machine ? {
|
|
1923
|
-
readPaste: /* @__PURE__ */ __name((signal) => readSecret(PASTE, { ...secretInputOf(command), echo: true, signal }), "readPaste")
|
|
1924
|
-
} : {}
|
|
1925
|
-
},
|
|
1926
|
-
check: /* @__PURE__ */ __name(async (auth) => {
|
|
1927
|
-
const found2 = await accountUser(transportFor(command, auth, events));
|
|
1928
|
-
refuseDuplicate(env, keyring, profile, { host: found2.account, userId: found2.user.id });
|
|
1929
|
-
return { ...found2, id: found2.user.id };
|
|
1930
|
-
}, "check")
|
|
1931
|
-
}));
|
|
1932
|
-
tokens.remove(profile);
|
|
1933
|
-
keepHost(command, origin);
|
|
1934
|
-
rememberAccount(IDENTITY, profile, `${who.account}:${who.user.id}`, env);
|
|
1935
|
-
const { id: _id, ...found } = who;
|
|
1936
|
-
return {
|
|
1937
|
-
profile,
|
|
1938
|
-
state: "saved",
|
|
1939
|
-
kind: "app",
|
|
1940
|
-
stored_in: appSourceOf(env, profile, keyring) ?? args.credentialStorage,
|
|
1941
|
-
verified: true,
|
|
1942
|
-
...found
|
|
1943
|
-
};
|
|
1944
|
-
}, "startWithApp");
|
|
1945
|
-
var CLIENT_ID = `${IDENTITY.envPrefix}_AMOCRM_CLIENT_ID`;
|
|
1946
|
-
var CLIENT_SECRET = `${IDENTITY.envPrefix}_AMOCRM_CLIENT_SECRET`;
|
|
1947
|
-
var startCommand = /* @__PURE__ */ __name(() => logsInOrOut(annotate(new Command("start"), {
|
|
1948
|
-
effects: FETCH,
|
|
1949
|
-
lifetime: "interactive",
|
|
1950
|
-
mcp: false,
|
|
1951
|
-
examples: [
|
|
1952
|
-
`${AMO} work session start --host https://example.amocrm.ru`,
|
|
1953
|
-
`${AMO} work session start --host https://example.kommo.com --json`,
|
|
1954
|
-
`${AMO} work session start --host https://example.amocrm.ru --client-id 0123abcd-4567-89ef-0123-456789abcdef`
|
|
1955
|
-
]
|
|
1956
|
-
})).summary("sign in to amoCRM or Kommo with 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}. 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("--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) {
|
|
1957
|
-
const { env, profile, tokens, keyring } = contextOf(this);
|
|
1958
|
-
refuseCommandName(profile, commandWords(rootOf(this)), AMO);
|
|
1959
|
-
refuseOffline(this, "the amoCRM account");
|
|
1960
|
-
const origin = accountOrigin(args.host);
|
|
1961
|
-
if (args.clientId !== void 0 || env[CLIENT_ID])
|
|
1962
|
-
return answer(this, await startWithApp(this, args, origin));
|
|
1963
|
-
const token = (await readSecret("amoCRM long-lived token: ", secretInputOf(this))).trim();
|
|
1964
|
-
if (!token)
|
|
1965
|
-
throw new CliError("validation_error", "no token was given");
|
|
1966
|
-
const { who, signIn, account: account2 } = await checkedToken(this, origin, token);
|
|
1967
|
-
const storedIn = tokens.write(profile, signIn, args.credentialStorage);
|
|
1968
|
-
keepHost(this, origin);
|
|
1969
|
-
appStorage(env, profile, keyring).remove();
|
|
1970
|
-
rememberAccount(IDENTITY, profile, account2, env);
|
|
1971
|
-
answer(this, { profile, state: "saved", kind: "token", stored_in: storedIn, verified: true, ...who });
|
|
1972
|
-
}), "startCommand");
|
|
1973
|
-
var statusCommand = /* @__PURE__ */ __name(() => annotate(new Command("status"), {
|
|
1974
|
-
effects: REMOTE_READ,
|
|
1975
|
-
examples: [`${AMO} work session status`, `${AMO} work session status --check --json`]
|
|
1976
|
-
}).summary("show how this profile signs in, and with --check as whom it acts").description(`show which account this profile signs in to, with a long-lived token or an integration, and where that comes from: ${IDENTITY.envPrefix}_TOKEN, the keyring or a file; never a token or the secret key`).option("--check", "ask the account whether the sign-in still works and whose it is: the account, the user and admin").action(async function(args) {
|
|
1977
|
-
const { env, profile, tokens, keyring } = contextOf(this);
|
|
1978
|
-
const saved = tokens.read(profile);
|
|
1979
|
-
const app = saved?.source === "environment" ? void 0 : appAuthFor(this);
|
|
1980
|
-
const signIn = storedSignIn(this);
|
|
1981
|
-
const status = {
|
|
1982
|
-
profile,
|
|
1983
|
-
state: signIn ? "saved" : "missing",
|
|
1984
|
-
kind: app ? "app" : signIn ? "token" : null,
|
|
1985
|
-
token_from: app ? appSourceOf(env, profile, keyring) ?? null : saved?.source ?? null,
|
|
1986
|
-
account: signIn ? new URL(signIn.origin).host : null
|
|
1987
|
-
};
|
|
1988
|
-
if (!args.check || !signIn)
|
|
1989
|
-
return answer(this, { ...status, verified: false });
|
|
1990
|
-
answer(this, { ...status, verified: true, ...await withAccount(this, accountUser) });
|
|
1991
|
-
}), "statusCommand");
|
|
1992
|
-
var endCommand = /* @__PURE__ */ __name(() => logsInOrOut(annotate(new Command("end"), {
|
|
1993
|
-
effects: LOCAL_WRITE,
|
|
1994
|
-
mcp: false,
|
|
1995
|
-
examples: [`${AMO} work session end`]
|
|
1996
|
-
})).summary("forget this profile's sign-in on this computer").description("forget this profile's long-lived token, or its integration's secret key and tokens, and the account address on this computer; amoCRM has no call that revokes a token: revoke it on the integration's Keys and scopes tab, or switch the integration off").action(function() {
|
|
1997
|
-
refuseUnderReadOnly(this, "session end");
|
|
1998
|
-
const { env, profile, tokens, keyring } = contextOf(this);
|
|
1999
|
-
const ended = [...tokens.remove(profile), ...appStorage(env, profile, keyring).remove()];
|
|
2000
|
-
answer(this, { profile, ended: [...new Set(ended)] });
|
|
2001
|
-
}), "endCommand");
|
|
2002
|
-
var listCommand = /* @__PURE__ */ __name(() => profileFree(annotate(new Command("list"), {
|
|
2003
|
-
effects: LOCAL_READ,
|
|
2004
|
-
examples: [`${AMO} session list`, `${AMO} session list --json`]
|
|
2005
|
-
})).summary("list the profiles here and whether each is signed in").description("list the profiles on this computer, whether each has a token and for which account; picks none").action(function() {
|
|
2006
|
-
const environment = environmentOf(this);
|
|
2007
|
-
const env = environment.env ?? process.env;
|
|
2008
|
-
const { configuredProfiles } = configuration.resolveSettings({}, { env, needsProfile: false });
|
|
2009
|
-
const tokens = tokensHere(env, environment.keyring);
|
|
2010
|
-
const items = profilesHere(IDENTITY, configuredProfiles, env).map((profile) => {
|
|
2011
|
-
try {
|
|
2012
|
-
const saved = tokens.read(profile);
|
|
2013
|
-
const app = saved ? void 0 : appStorage(env, profile, environment.keyring).read()?.account;
|
|
2014
|
-
const host = app ? new URL(app.host).host : saved && saved.source !== "environment" ? new URL(decodeSignIn(saved.secret).origin).host : null;
|
|
2015
|
-
const from = saved?.source ?? (app ? appSourceOf(env, profile, environment.keyring) : void 0);
|
|
2016
|
-
return { profile, signed_in: from !== void 0, token_from: from ?? null, account: host };
|
|
2017
|
-
} catch (error) {
|
|
2018
|
-
if (!(error instanceof CliError))
|
|
2019
|
-
throw error;
|
|
2020
|
-
return { profile, signed_in: null, token_from: null, account: null, error: error.message };
|
|
2021
|
-
}
|
|
2022
|
-
});
|
|
2023
|
-
renderAnswer(this, outputFor(this), listOf("session list", { items, limit: Math.max(1, items.length), has_more: false }));
|
|
2024
|
-
}), "listCommand");
|
|
2025
|
-
var sessionCommand = /* @__PURE__ */ __name(() => annotate(new Command("session"), { effects: LOCAL_READ }).description("keep this profile's amoCRM sign-in and account address in the OS keyring").addCommand(startCommand()).addCommand(statusCommand()).addCommand(endCommand()).addCommand(listCommand()), "sessionCommand");
|
|
2026
|
-
|
|
2027
|
-
// dist/commands/account.js
|
|
2028
|
-
var rememberedOf = /* @__PURE__ */ __name((env, profile) => {
|
|
2029
|
-
try {
|
|
2030
|
-
const { account: account2 } = JSON.parse(readFileSync(accountFileFor(IDENTITY, profile, env), "utf8"));
|
|
2031
|
-
const parts = typeof account2 === "string" ? /^(.+):(\d+)$/.exec(account2) : null;
|
|
2032
|
-
return parts?.[1] && parts[2] ? { host: parts[1], userId: parts[2] } : void 0;
|
|
2033
|
-
} catch {
|
|
2034
|
-
return void 0;
|
|
2035
|
-
}
|
|
2036
|
-
}, "rememberedOf");
|
|
2037
|
-
var hostOf = /* @__PURE__ */ __name((env, keyring, profile) => {
|
|
2038
|
-
try {
|
|
2039
|
-
return (signedInAs(env, keyring, profile) ?? rememberedOf(env, profile))?.host;
|
|
2040
|
-
} catch {
|
|
2041
|
-
return rememberedOf(env, profile)?.host;
|
|
2042
|
-
}
|
|
2043
|
-
}, "hostOf");
|
|
2044
|
-
var removal = {
|
|
2045
|
-
// amoCRM has no call that revokes a long-lived token or an integration's tokens; the integration's card does.
|
|
2046
|
-
signOut: /* @__PURE__ */ __name(async (profile) => ({
|
|
2047
|
-
revoked: null,
|
|
2048
|
-
removed: [`the sign-in of ${profile} (the integration and its keys stay in amoCRM)`]
|
|
2049
|
-
}), "signOut"),
|
|
2050
|
-
account: /* @__PURE__ */ __name((profile, { env, keyring }) => {
|
|
2051
|
-
const host = hostOf(env, keyring, profile);
|
|
2052
|
-
return host ? { provider: PROVIDER.name, account: host } : void 0;
|
|
2053
|
-
}, "account"),
|
|
2054
|
-
secrets: /* @__PURE__ */ __name((profile, { env, keyring }) => [
|
|
2055
|
-
{
|
|
2056
|
-
credentials: {
|
|
2057
|
-
configDir: resolvePaths({ appName: IDENTITY.appName, prefix: IDENTITY.envPrefix, env }).config,
|
|
2058
|
-
service: IDENTITY.appName,
|
|
2059
|
-
envVar: `${IDENTITY.envPrefix}_TOKEN`,
|
|
2060
|
-
env,
|
|
2061
|
-
...keyring ? { keyring } : {}
|
|
2062
|
-
},
|
|
2063
|
-
accounts: [`token:${profile}`, oauthAccount(PROVIDER2, profile)]
|
|
2064
|
-
}
|
|
2065
|
-
], "secrets"),
|
|
2066
|
-
stateFiles: /* @__PURE__ */ __name((profile, { env }) => [
|
|
2067
|
-
join2(resolvePaths({ appName: IDENTITY.appName, prefix: IDENTITY.envPrefix, env }).state, "crm", profile)
|
|
2068
|
-
], "stateFiles")
|
|
2069
|
-
};
|
|
2070
|
-
var refuseSharedDelete = /* @__PURE__ */ __name((command) => {
|
|
2071
|
-
if (command.opts().deleteData !== true)
|
|
2072
|
-
return;
|
|
2073
|
-
const { env, keyring, profile, renderer } = contextOf(command);
|
|
2074
|
-
const own = hostOf(env, keyring, profile);
|
|
2075
|
-
if (!own)
|
|
2076
|
-
return;
|
|
2077
|
-
const { configuredProfiles } = configuration.resolveSettings({}, { env, needsProfile: false });
|
|
2078
|
-
const sharing = profilesHere(IDENTITY, configuredProfiles, env).filter((one) => one !== profile && hostOf(env, keyring, one) === own);
|
|
2079
|
-
if (sharing.length === 0)
|
|
2080
|
-
return;
|
|
2081
|
-
const names = sharing.join(", ");
|
|
2082
|
-
if (command.opts().dryRun === true) {
|
|
2083
|
-
renderer.warn(`without --dry-run this refuses: ${names} also read${sharing.length === 1 ? "s" : ""} ${own}`);
|
|
2084
|
-
return;
|
|
2085
|
-
}
|
|
2086
|
-
throw new CliError("conflict", `${names} also read${sharing.length === 1 ? "s" : ""} ${own}, and the store keeps one copy of an account: --delete-data would delete their deals, contacts and companies too. Use --keep-data, or remove ${names} first`, { reason: "account-remove.account-shared", profiles: sharing, account: own });
|
|
2087
|
-
}, "refuseSharedDelete");
|
|
2088
|
-
var accountCommand = /* @__PURE__ */ __name(() => annotate(new Command("account"), { effects: LOCAL_READ }).description("this profile on this computer").addCommand(annotate(accountRemoveCommand(IDENTITY, removal, { resolveSettings: configuration.resolveSettings }), {
|
|
2089
|
-
effects: LOCAL_WRITE
|
|
2090
|
-
}).hook("preAction", (_, action) => refuseSharedDelete(action))), "accountCommand");
|
|
2091
|
-
|
|
2092
|
-
// dist/commands/write.js
|
|
2093
|
-
var write = /* @__PURE__ */ __name(async (command, { key, extra = [], act }) => {
|
|
2094
|
-
const defaults = permissions.defaults;
|
|
2095
|
-
const { env, settings, run: run3 } = contextOf(command);
|
|
2096
|
-
const lock = readOnlyLockOf(IDENTITY, env);
|
|
2097
|
-
if (lock)
|
|
2098
|
-
throw readOnlyRefusal(lock, "change the amoCRM account");
|
|
2099
|
-
const operationId = newOperationId();
|
|
2100
|
-
const levelOf = /* @__PURE__ */ __name((one) => levelFor(settings.permissions, one, defaults).level, "levelOf");
|
|
2101
|
-
const guard = keyedGuard((ask) => guardFor(
|
|
2102
|
-
IDENTITY,
|
|
2103
|
-
// amoCRM limits its own rate; the guard is here for the levels and the journal, not a send limit.
|
|
2104
|
-
{ ...settings, sendsPerHour: Number.MAX_SAFE_INTEGER, permissionDefaults: defaults },
|
|
2105
|
-
outputFor(command).renderer.warn,
|
|
2106
|
-
environmentOf(command).env ?? process.env,
|
|
2107
|
-
ask
|
|
2108
|
-
), terminalAsker(command), levelOf, extra);
|
|
2109
|
-
const request = { chatId: null, kind: "edit", key, operationId };
|
|
2110
|
-
guard.refuse(request);
|
|
2111
|
-
const signIn = signInOf(command);
|
|
2112
|
-
let done;
|
|
2113
|
-
try {
|
|
2114
|
-
done = await guardedWrite(guard, request, () => run3((events) => act(transportFor(command, signIn, events), operationId)));
|
|
2115
|
-
} catch (error) {
|
|
2116
|
-
if (error instanceof CliError && error.code === "outcome_unknown")
|
|
2117
|
-
throw new CliError("outcome_unknown", `${error.message} \u2014 check the account before you write it again: amoCRM has no idempotency key and would make it a second time`, { ...error.details, operation_id: operationId });
|
|
2118
|
-
throw error;
|
|
2119
|
-
}
|
|
2120
|
-
renderAnswer(command, outputFor(command), itemOf({ operation_id: operationId, ...done }));
|
|
2121
|
-
}, "write");
|
|
2122
|
-
|
|
2123
|
-
// dist/commands/api.js
|
|
2124
|
-
var AMO2 = IDENTITY.command;
|
|
2125
1232
|
var API_OPERATION_QUERY = {
|
|
2126
1233
|
entity: "api_operation",
|
|
2127
1234
|
backend: "native",
|
|
@@ -2151,10 +1258,10 @@ var scalar = /* @__PURE__ */ __name((value) => {
|
|
|
2151
1258
|
return String(value.value);
|
|
2152
1259
|
return void 0;
|
|
2153
1260
|
}, "scalar");
|
|
2154
|
-
var
|
|
2155
|
-
if (
|
|
1261
|
+
var queryOf = /* @__PURE__ */ __name((text3) => {
|
|
1262
|
+
if (text3 === void 0)
|
|
2156
1263
|
return {};
|
|
2157
|
-
const parsed = parseApiJson(
|
|
1264
|
+
const parsed = parseApiJson(text3);
|
|
2158
1265
|
if (typeof parsed !== "object" || parsed === null || Array.isArray(parsed))
|
|
2159
1266
|
throw refused("--params takes a JSON object of parameter names and values", "--params");
|
|
2160
1267
|
return Object.fromEntries(Object.entries(parsed).map(([name, value]) => {
|
|
@@ -2164,16 +1271,16 @@ var queryOf2 = /* @__PURE__ */ __name((text4) => {
|
|
|
2164
1271
|
return [name, Array.isArray(value) ? values : values[0]];
|
|
2165
1272
|
}));
|
|
2166
1273
|
}, "queryOf");
|
|
2167
|
-
var bodyOf = /* @__PURE__ */ __name((operation,
|
|
2168
|
-
if (
|
|
1274
|
+
var bodyOf = /* @__PURE__ */ __name((operation, text3) => {
|
|
1275
|
+
if (text3 === void 0)
|
|
2169
1276
|
return void 0;
|
|
2170
1277
|
if (!operation.body)
|
|
2171
1278
|
throw refused(`${operation.name} takes no body`, "--body");
|
|
2172
|
-
return parseApiJson(
|
|
1279
|
+
return parseApiJson(text3);
|
|
2173
1280
|
}, "bodyOf");
|
|
2174
|
-
var
|
|
1281
|
+
var listCommand = /* @__PURE__ */ __name(() => withQuery(answerEntity(annotate(new Command("list"), {
|
|
2175
1282
|
effects: NO_EFFECTS,
|
|
2176
|
-
examples: [`${
|
|
1283
|
+
examples: [`${AMO} work api list`, `${AMO} work api list family:leads effect:write`]
|
|
2177
1284
|
}).summary("list the amoCRM API operations, with their permissions").description("list every operation of the Kommo API reference (amoCRM's API v4) that amo may call, with its permission key, default level and the page it comes from"), "api_operation", strictObject({
|
|
2178
1285
|
name: string(),
|
|
2179
1286
|
effect: string(),
|
|
@@ -2190,7 +1297,7 @@ var listCommand2 = /* @__PURE__ */ __name(() => withQuery(answerEntity(annotate(
|
|
|
2190
1297
|
}), "listCommand");
|
|
2191
1298
|
var showCommand = /* @__PURE__ */ __name(() => annotate(new Command("show"), {
|
|
2192
1299
|
effects: NO_EFFECTS,
|
|
2193
|
-
examples: [`${
|
|
1300
|
+
examples: [`${AMO} work api show "PATCH /api/v4/leads/{id}" --json`, `${AMO} work api show "GET /api/v4/leads/42"`]
|
|
2194
1301
|
}).summary("show an operation's permissions and source; calls nothing").description("show what an operation does, the permissions it checks and its reference page; calls nothing").argument("<method>", 'the HTTP verb and path, such as "GET /api/v4/leads", as api list prints it').action(function(raw) {
|
|
2195
1302
|
renderAnswer(this, outputFor(this), itemOf(described(matchOperation(raw).operation)));
|
|
2196
1303
|
}), "showCommand");
|
|
@@ -2257,13 +1364,13 @@ var callCommand = /* @__PURE__ */ __name(() => annotate(new Command("call"), {
|
|
|
2257
1364
|
effects: REMOTE_WRITE,
|
|
2258
1365
|
offline: false,
|
|
2259
1366
|
examples: [
|
|
2260
|
-
`${
|
|
2261
|
-
`${
|
|
1367
|
+
`${AMO} work api call "GET /api/v4/leads" --params '{"limit":5,"with":"loss_reason"}'`,
|
|
1368
|
+
`${AMO} work api call "PATCH /api/v4/leads/42" --body '{"price":1000}' --dry-run`
|
|
2262
1369
|
]
|
|
2263
1370
|
}).summary("call one amoCRM API operation with JSON parameters").description("call one operation of the Kommo API reference on the signed-in account; it checks api.<path>.<verb>, and the key of the command that reads or writes the same records").argument("<method>", 'the HTTP verb and path, such as "GET /api/v4/leads/42", as api list prints it').option("--params <json>", 'the query parameters as a JSON object, named as the reference does: {"filter[id][]":[1,2]}').option("--body <json>", "the request body as JSON, an array of records for most writes").option("--dry-run", "show every permission this call checks, with its level, and call nothing").action(async function(raw, options) {
|
|
2264
1371
|
const matched = withEveryId(matchOperation(raw));
|
|
2265
1372
|
const { operation } = matched;
|
|
2266
|
-
const query =
|
|
1373
|
+
const query = queryOf(options.params);
|
|
2267
1374
|
const body = bodyOf(operation, options.body);
|
|
2268
1375
|
if (options.dryRun)
|
|
2269
1376
|
return preview(this, matched, body, query);
|
|
@@ -2297,9 +1404,9 @@ var callCommand = /* @__PURE__ */ __name(() => annotate(new Command("call"), {
|
|
|
2297
1404
|
});
|
|
2298
1405
|
renderAnswer(this, outputFor(this), itemOf(shown(answer2)));
|
|
2299
1406
|
}), "callCommand");
|
|
2300
|
-
var apiCommand = /* @__PURE__ */ __name(() => annotate(new Command("api"), { effects: LOCAL_READ }).description("see and call the amoCRM API v4 operations directly").addCommand(
|
|
1407
|
+
var apiCommand = /* @__PURE__ */ __name(() => annotate(new Command("api"), { effects: LOCAL_READ }).description("see and call the amoCRM API v4 operations directly").addCommand(listCommand()).addCommand(showCommand()).addCommand(callCommand()), "apiCommand");
|
|
2301
1408
|
|
|
2302
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
1409
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.722.0_@wirecat+cli-base@0.127.0_commander@15.0.0_esbuild@0.28.2_typ_d2bed0cfbe6b4358c89d465b9e07afcb/node_modules/@wirecat/cli-core/dist/crm/stage-tasks.js
|
|
2303
1410
|
var DAY = 864e5;
|
|
2304
1411
|
var openStageTasks = /* @__PURE__ */ __name(async (store, account2, now, { history = false } = {}) => {
|
|
2305
1412
|
const rules = await store.crm.stageTasks(account2);
|
|
@@ -2336,8 +1443,115 @@ var openStageTasks = /* @__PURE__ */ __name(async (store, account2, now, { histo
|
|
|
2336
1443
|
return opened;
|
|
2337
1444
|
}, "openStageTasks");
|
|
2338
1445
|
|
|
2339
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
1446
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.722.0_@wirecat+cli-base@0.127.0_commander@15.0.0_esbuild@0.28.2_typ_d2bed0cfbe6b4358c89d465b9e07afcb/node_modules/@wirecat/cli-core/dist/crm/cli/account.js
|
|
1447
|
+
import { join } from "node:path";
|
|
1448
|
+
var SHARED = new Set(Object.values(CRM_SHARED_FOLDERS));
|
|
1449
|
+
var isShared = /* @__PURE__ */ __name((profile) => SHARED.has(profile.toLowerCase()), "isShared");
|
|
1450
|
+
var accountBy = /* @__PURE__ */ __name((app, options) => (profile, context) => options.held ? options.held(profile, context)?.account : recalledAccount(app, options.provider, profile, context.env)?.account, "accountBy");
|
|
1451
|
+
var signedInBy = /* @__PURE__ */ __name((app, options, tokens) => (profile, context) => {
|
|
1452
|
+
try {
|
|
1453
|
+
if (options.held)
|
|
1454
|
+
return options.held(profile, context);
|
|
1455
|
+
const account2 = recalledAccount(app, options.provider, profile, context.env)?.account;
|
|
1456
|
+
if (account2 === void 0)
|
|
1457
|
+
return void 0;
|
|
1458
|
+
const saved = (tokens ?? new ProfileTokenStore({ app, ...context, warn: /* @__PURE__ */ __name(() => {
|
|
1459
|
+
}, "warn") })).read(profile);
|
|
1460
|
+
return { account: account2, signedIn: saved !== void 0 && saved.source !== "environment" };
|
|
1461
|
+
} catch {
|
|
1462
|
+
return void 0;
|
|
1463
|
+
}
|
|
1464
|
+
}, "signedInBy");
|
|
1465
|
+
var also = /* @__PURE__ */ __name((names) => `${names.join(", ")} also read${names.length === 1 ? "s" : ""}`, "also");
|
|
1466
|
+
var refuseTakenCrmAccount = /* @__PURE__ */ __name((app, options, { profile, profiles = [], tokens, ...context }, at2) => {
|
|
1467
|
+
if (isShared(profile))
|
|
1468
|
+
throw new CliError("validation_error", `"${profile}" names a folder every account shares, where this profile's own files would land. Pick another name than ${Object.values(CRM_SHARED_FOLDERS).join(" or ")}`, { reason: "profile.reserved", profile });
|
|
1469
|
+
const held = signedInBy(app, options, tokens);
|
|
1470
|
+
const other = profilesHere(app, profiles, context.env).find((one) => {
|
|
1471
|
+
if (one === profile)
|
|
1472
|
+
return false;
|
|
1473
|
+
const found = held(one, context);
|
|
1474
|
+
return found?.signedIn === true && found.account === at2.account && found.user === at2.user;
|
|
1475
|
+
});
|
|
1476
|
+
if (!other)
|
|
1477
|
+
return;
|
|
1478
|
+
const command = app.command;
|
|
1479
|
+
throw new CliError("conflict", `profile ${other} already signs in to ${options.service} account ${at2.account}${at2.user === void 0 ? "" : ` as user ${at2.user}`}. Use \`${command} ${other}\`, ` + // Another user's token on the account is a second sign-in only where the account has users.
|
|
1480
|
+
(at2.user === void 0 ? "" : `sign it in again with \`${command} ${other} session start\`, `) + `or end it with \`${command} ${other} session end\` first`, { reason: "session.duplicate", profile: other, account: at2.account });
|
|
1481
|
+
}, "refuseTakenCrmAccount");
|
|
1482
|
+
var refuseSharedDelete = /* @__PURE__ */ __name((app, options, command) => {
|
|
1483
|
+
const given = command.opts();
|
|
1484
|
+
if (given.deleteData !== true)
|
|
1485
|
+
return;
|
|
1486
|
+
const resolveSettings = options.resolveSettings ?? environmentOf(command).resolveSettings;
|
|
1487
|
+
if (!resolveSettings)
|
|
1488
|
+
return;
|
|
1489
|
+
const { env, keyring, settings, renderer } = baseContext(command, resolveSettings);
|
|
1490
|
+
const context = { env, ...keyring ? { keyring } : {} };
|
|
1491
|
+
const accountOf = accountBy(app, options);
|
|
1492
|
+
const read = /* @__PURE__ */ __name((profile) => {
|
|
1493
|
+
try {
|
|
1494
|
+
return accountOf(profile, context);
|
|
1495
|
+
} catch {
|
|
1496
|
+
throw new CliError("conflict", `${app.command} could not tell which ${options.service} account ${profile} holds, so --delete-data could delete a copy ${profile} still reads. Fix ${profile}'s sign-in, or use --keep-data`, { reason: "account-remove.account-unknown", profile });
|
|
1497
|
+
}
|
|
1498
|
+
}, "read");
|
|
1499
|
+
const own = read(settings.profile);
|
|
1500
|
+
if (own === void 0)
|
|
1501
|
+
return;
|
|
1502
|
+
const sharing = settings.profilesHere.filter((one) => one !== settings.profile && read(one) === own);
|
|
1503
|
+
if (sharing.length === 0)
|
|
1504
|
+
return;
|
|
1505
|
+
if (given.dryRun === true) {
|
|
1506
|
+
renderer.warn(`without --dry-run this refuses: ${also(sharing)} ${options.service} account ${own}`);
|
|
1507
|
+
return;
|
|
1508
|
+
}
|
|
1509
|
+
const names = sharing.join(", ");
|
|
1510
|
+
throw new CliError("conflict", `${also(sharing)} ${options.service} account ${own}, and the store keeps one copy of an account: --delete-data would delete their deals, contacts and companies too. Use --keep-data, or remove ${names} first`, { reason: "account-remove.account-shared", profiles: sharing, account: own });
|
|
1511
|
+
}, "refuseSharedDelete");
|
|
1512
|
+
var removalOf = /* @__PURE__ */ __name((app, options) => {
|
|
1513
|
+
const accountOf = accountBy(app, options);
|
|
1514
|
+
const folders = /* @__PURE__ */ __name((env) => resolvePaths({ appName: app.appName, prefix: app.envPrefix, env }), "folders");
|
|
1515
|
+
return {
|
|
1516
|
+
// A CRM's API token has no call that revokes it; the CRM's own settings do.
|
|
1517
|
+
signOut: /* @__PURE__ */ __name(async (profile) => ({
|
|
1518
|
+
revoked: null,
|
|
1519
|
+
removed: [
|
|
1520
|
+
options.signedOut?.(profile) ?? `the sign-in of ${profile} (the token stays valid in ${options.service} until you delete it there)`
|
|
1521
|
+
]
|
|
1522
|
+
}), "signOut"),
|
|
1523
|
+
account: /* @__PURE__ */ __name((profile, context) => {
|
|
1524
|
+
try {
|
|
1525
|
+
const account2 = accountOf(profile, context);
|
|
1526
|
+
return account2 === void 0 ? void 0 : { provider: options.provider, account: account2 };
|
|
1527
|
+
} catch {
|
|
1528
|
+
return void 0;
|
|
1529
|
+
}
|
|
1530
|
+
}, "account"),
|
|
1531
|
+
secrets: /* @__PURE__ */ __name((profile, { env, keyring }) => [
|
|
1532
|
+
{
|
|
1533
|
+
credentials: {
|
|
1534
|
+
configDir: folders(env).config,
|
|
1535
|
+
service: app.appName,
|
|
1536
|
+
envVar: `${app.envPrefix}_TOKEN`,
|
|
1537
|
+
env,
|
|
1538
|
+
...keyring ? { keyring } : {}
|
|
1539
|
+
},
|
|
1540
|
+
// An OAuth sign-in's entry; removing a missing one is fine.
|
|
1541
|
+
accounts: [`token:${profile}`, oauthAccount(options.provider, profile)]
|
|
1542
|
+
}
|
|
1543
|
+
], "secrets"),
|
|
1544
|
+
// A profile named after a folder every account shares has no folder of its own there.
|
|
1545
|
+
stateFiles: /* @__PURE__ */ __name((profile, { env }) => isShared(profile) ? [] : [join(folders(env).state, "crm", profile)], "stateFiles")
|
|
1546
|
+
};
|
|
1547
|
+
}, "removalOf");
|
|
1548
|
+
var crmAccountCommand = /* @__PURE__ */ __name((app, options) => annotate(new Command("account"), { effects: LOCAL_READ }).description("this profile on this computer").addCommand(annotate(accountRemoveCommand(app, removalOf(app, options), {
|
|
1549
|
+
...options.resolveSettings ? { resolveSettings: options.resolveSettings } : {}
|
|
1550
|
+
}), { effects: LOCAL_WRITE }).hook("preAction", (_, action) => refuseSharedDelete(app, options, action))), "crmAccountCommand");
|
|
1551
|
+
|
|
1552
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.722.0_@wirecat+cli-base@0.127.0_commander@15.0.0_esbuild@0.28.2_typ_d2bed0cfbe6b4358c89d465b9e07afcb/node_modules/@wirecat/cli-core/dist/crm/digest.js
|
|
2340
1553
|
var HOUR = 36e5;
|
|
1554
|
+
var SHOWN = 7;
|
|
2341
1555
|
var STALE_HOURS = 24;
|
|
2342
1556
|
var WORDS = {
|
|
2343
1557
|
en: {
|
|
@@ -2373,7 +1587,7 @@ var endOfDay = /* @__PURE__ */ __name((now, zone) => {
|
|
|
2373
1587
|
var crmDigest = /* @__PURE__ */ __name(async (store, account2, options) => {
|
|
2374
1588
|
const { since, until, now, zone, viewer } = options;
|
|
2375
1589
|
const words = WORDS[options.language] ?? WORDS.en;
|
|
2376
|
-
const cap =
|
|
1590
|
+
const cap = SHOWN;
|
|
2377
1591
|
const window = { since, until, ...viewer ? { viewer } : {} };
|
|
2378
1592
|
const counts = await store.crm.changeCounts(account2, window);
|
|
2379
1593
|
const changesOf = /* @__PURE__ */ __name(async (kind) => counts[kind] ? (await store.crm.changes(account2, { ...window, changes: [kind], limit: cap, offset: 0 })).items : [], "changesOf");
|
|
@@ -2456,7 +1670,7 @@ var crmDigest = /* @__PURE__ */ __name(async (store, account2, options) => {
|
|
|
2456
1670
|
}, "crmDigest");
|
|
2457
1671
|
var EMAIL = /[\p{L}\p{N}._%+-]+@[\p{L}\p{N}-]+(?:\.[\p{L}\p{N}-]+)+/gu;
|
|
2458
1672
|
var PHONE = /\+?\d[\d\s().-]{5,}\d/g;
|
|
2459
|
-
var maskText = /* @__PURE__ */ __name((
|
|
1673
|
+
var maskText = /* @__PURE__ */ __name((text3) => text3.replace(EMAIL, "[e-mail]").replace(PHONE, (found) => {
|
|
2460
1674
|
const digits = found.replace(/\D/g, "").length;
|
|
2461
1675
|
return digits >= 9 || found.startsWith("+") && digits >= 7 ? "[phone]" : found;
|
|
2462
1676
|
}), "maskText");
|
|
@@ -2479,7 +1693,7 @@ var healthOf = /* @__PURE__ */ __name(async (store, account2, { now, profile })
|
|
|
2479
1693
|
return stale > STALE_HOURS ? [{ ...named, stale_hours: Math.floor(stale) }] : [];
|
|
2480
1694
|
}, "healthOf");
|
|
2481
1695
|
|
|
2482
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
1696
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.722.0_@wirecat+cli-base@0.127.0_commander@15.0.0_esbuild@0.28.2_typ_d2bed0cfbe6b4358c89d465b9e07afcb/node_modules/@wirecat/cli-core/dist/crm/cli/csv.js
|
|
2483
1697
|
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");
|
|
2484
1698
|
var DEAL_CSV_COLUMNS = [
|
|
2485
1699
|
"ref",
|
|
@@ -2601,7 +1815,7 @@ var renderCsv = /* @__PURE__ */ __name((command, open2, read, defaults = DEAL_CS
|
|
|
2601
1815
|
});
|
|
2602
1816
|
}, "renderCsv");
|
|
2603
1817
|
|
|
2604
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
1818
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.722.0_@wirecat+cli-base@0.127.0_commander@15.0.0_esbuild@0.28.2_typ_d2bed0cfbe6b4358c89d465b9e07afcb/node_modules/@wirecat/cli-core/dist/crm/cli/records.js
|
|
2605
1819
|
var time2 = nullable(isoTime);
|
|
2606
1820
|
var metadata = optional(record(string(), strictObject({
|
|
2607
1821
|
label: nullable(string()),
|
|
@@ -2776,13 +1990,16 @@ var addCrmRecordCommands = /* @__PURE__ */ __name((program, options) => {
|
|
|
2776
1990
|
const stored = await run3.store.crm.fields(run3.account, kind);
|
|
2777
1991
|
return stored.length ? stored : await run3.source().fields?.(kind) ?? [];
|
|
2778
1992
|
}, "liveFields");
|
|
1993
|
+
const words = options.liveQuery === "words";
|
|
2779
1994
|
const records = /* @__PURE__ */ __name((noun) => {
|
|
2780
1995
|
const group = annotate(program.command(noun.noun), { effects: REMOTE_READ }).description(`the CRM's ${noun.what}, read live: the copy holds only your own`);
|
|
2781
|
-
|
|
1996
|
+
const query = words ? { ...noun.query, fields: noun.query.fields.filter(({ name }) => name === "name") } : noun.query;
|
|
1997
|
+
const list = answerEntity(annotate(group.command("list"), { effects: REMOTE_READ, offline: false }), noun.entity, noun.schema);
|
|
1998
|
+
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) => {
|
|
2782
1999
|
const csv = opts.format === "csv";
|
|
2783
2000
|
const path = commandPath(command);
|
|
2784
|
-
const
|
|
2785
|
-
const names = customNames(
|
|
2001
|
+
const text3 = typedQuery(words2);
|
|
2002
|
+
const names = customNames(text3, query, path, "name");
|
|
2786
2003
|
const columns = command.optsWithGlobals().fields;
|
|
2787
2004
|
const wanted = csv && columns === void 0 ? "all" : wantedCodes(columns);
|
|
2788
2005
|
const read = /* @__PURE__ */ __name(async (run3) => {
|
|
@@ -2790,7 +2007,7 @@ var addCrmRecordCommands = /* @__PURE__ */ __name((program, options) => {
|
|
|
2790
2007
|
const fields = names.length || wanted !== void 0 || csv ? await liveFields(run3, noun.kind) : [];
|
|
2791
2008
|
const chosen = filterableFields(fields, names);
|
|
2792
2009
|
selectedCodes(fields, wanted);
|
|
2793
|
-
const terms = nativeTerms(listQuery(
|
|
2010
|
+
const terms = nativeTerms(listQuery(text3, withCustomFields(query, chosen), path, { defaultField: "name" }), path);
|
|
2794
2011
|
const custom = customConditions(terms, chosen);
|
|
2795
2012
|
const name = searchText(terms.get("name"));
|
|
2796
2013
|
terms.delete("name");
|
|
@@ -2815,7 +2032,7 @@ var addCrmRecordCommands = /* @__PURE__ */ __name((program, options) => {
|
|
|
2815
2032
|
limit: opts.limit,
|
|
2816
2033
|
page: opts.page,
|
|
2817
2034
|
has_more: found.hasMore,
|
|
2818
|
-
...
|
|
2035
|
+
...words2.length ? { args: { query: words2 } } : {}
|
|
2819
2036
|
});
|
|
2820
2037
|
});
|
|
2821
2038
|
});
|
|
@@ -2834,9 +2051,18 @@ var addCrmRecordCommands = /* @__PURE__ */ __name((program, options) => {
|
|
|
2834
2051
|
if (options.live.includes("user"))
|
|
2835
2052
|
users(program, options);
|
|
2836
2053
|
}, "addCrmRecordCommands");
|
|
2054
|
+
var byIdOrNone = /* @__PURE__ */ __name(async (run3, noun, id) => {
|
|
2055
|
+
try {
|
|
2056
|
+
return await sourceWith(run3, "get", noun.what).get(noun.kind, id);
|
|
2057
|
+
} catch (error) {
|
|
2058
|
+
if (isCliError(error) && error.code === "validation_error")
|
|
2059
|
+
return null;
|
|
2060
|
+
throw error;
|
|
2061
|
+
}
|
|
2062
|
+
}, "byIdOrNone");
|
|
2837
2063
|
var recordNamed = /* @__PURE__ */ __name(async (run3, noun, given) => {
|
|
2838
2064
|
const id = given.trim();
|
|
2839
|
-
const byId = RECORD_ID.test(id) ? await
|
|
2065
|
+
const byId = RECORD_ID.test(id) ? await byIdOrNone(run3, noun, id) : null;
|
|
2840
2066
|
if (byId)
|
|
2841
2067
|
return byId;
|
|
2842
2068
|
const want = foldName(id);
|
|
@@ -2970,7 +2196,7 @@ var addRecordWrites = /* @__PURE__ */ __name((group, noun, { within, example, wr
|
|
|
2970
2196
|
}, "addRecordWrites");
|
|
2971
2197
|
var idOf = /* @__PURE__ */ __name((opts) => opts.operationId === void 0 ? {} : { operationId: opts.operationId }, "idOf");
|
|
2972
2198
|
|
|
2973
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
2199
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.722.0_@wirecat+cli-base@0.127.0_commander@15.0.0_esbuild@0.28.2_typ_d2bed0cfbe6b4358c89d465b9e07afcb/node_modules/@wirecat/cli-core/dist/crm/cli/activities.js
|
|
2974
2200
|
var MOST2 = 500;
|
|
2975
2201
|
var nullableText = nullable(text);
|
|
2976
2202
|
var REFS = ["deal", "lead", "person", "organization"];
|
|
@@ -3083,7 +2309,7 @@ var addCrmActivityCommands = /* @__PURE__ */ __name((program, options) => {
|
|
|
3083
2309
|
}, "addCrmActivityCommands");
|
|
3084
2310
|
var refOf = /* @__PURE__ */ __name((kind, value) => value.includes(":") ? value : `${kind}:${value}`, "refOf");
|
|
3085
2311
|
|
|
3086
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
2312
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.722.0_@wirecat+cli-base@0.127.0_commander@15.0.0_esbuild@0.28.2_typ_d2bed0cfbe6b4358c89d465b9e07afcb/node_modules/@wirecat/cli-core/dist/crm/cli/changes.js
|
|
3087
2313
|
var MOST3 = 500;
|
|
3088
2314
|
var DAY2 = 864e5;
|
|
3089
2315
|
var nullableText2 = nullable(text);
|
|
@@ -3187,10 +2413,11 @@ var positionOf = /* @__PURE__ */ __name((cursor) => {
|
|
|
3187
2413
|
var digestState = /* @__PURE__ */ __name((schedule) => `crm:digest:${schedule}`, "digestState");
|
|
3188
2414
|
var addCrmChangeCommands = /* @__PURE__ */ __name((program, options) => {
|
|
3189
2415
|
const { within, example, now, ownerOf: ownerOf2, pathOf: pathOf3 } = options;
|
|
2416
|
+
const deals = options.leads === false ? "deals" : "deals and leads";
|
|
3190
2417
|
if (options.activities)
|
|
3191
2418
|
addCrmActivityCommands(program, { within, example, now, ownerOf: ownerOf2, pathOf: pathOf3 });
|
|
3192
|
-
const group = annotate(program.command("changes"), { effects: NO_EFFECTS }).description(
|
|
3193
|
-
example(withQuery(answerEntity(annotate(group.command("list"), { effects: LOCAL_READ }), "crm_change", crmChange).description(
|
|
2419
|
+
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`);
|
|
2420
|
+
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) => {
|
|
3194
2421
|
const name = "changes list";
|
|
3195
2422
|
const terms = queryTerms(words, CHANGES_QUERY, name, ["at"]);
|
|
3196
2423
|
const zone = timezoneOf();
|
|
@@ -3302,11 +2529,11 @@ var pipelineOf2 = /* @__PURE__ */ __name(async (run3, value) => {
|
|
|
3302
2529
|
}) : new CliError("not_found", `no pipeline ${value} in this account`, { reason: "pipeline.not-found" });
|
|
3303
2530
|
}, "pipelineOf");
|
|
3304
2531
|
|
|
3305
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
3306
|
-
import { createHash
|
|
3307
|
-
import { chmodSync, constants, copyFileSync, existsSync, linkSync, mkdirSync, readFileSync
|
|
2532
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.722.0_@wirecat+cli-base@0.127.0_commander@15.0.0_esbuild@0.28.2_typ_d2bed0cfbe6b4358c89d465b9e07afcb/node_modules/@wirecat/cli-core/dist/crm/cli/files.js
|
|
2533
|
+
import { createHash } from "node:crypto";
|
|
2534
|
+
import { chmodSync, constants, copyFileSync, existsSync, linkSync, mkdirSync, readFileSync, renameSync, rmSync } from "node:fs";
|
|
3308
2535
|
import { open } from "node:fs/promises";
|
|
3309
|
-
import { join as
|
|
2536
|
+
import { join as join2, resolve, sep } from "node:path";
|
|
3310
2537
|
var MB = 1024 * 1024;
|
|
3311
2538
|
var PAGE = 500;
|
|
3312
2539
|
var DAY3 = 24 * 60 * 60 * 1e3;
|
|
@@ -3355,8 +2582,8 @@ var OWNER_FLAGS = [
|
|
|
3355
2582
|
["organization", "--organization <id>"]
|
|
3356
2583
|
];
|
|
3357
2584
|
var iso4 = /* @__PURE__ */ __name((ms) => ms === null ? null : new Date(ms).toISOString(), "iso");
|
|
3358
|
-
var segment = /* @__PURE__ */ __name((
|
|
3359
|
-
var accountFolder = /* @__PURE__ */ __name((app, run3) =>
|
|
2585
|
+
var segment = /* @__PURE__ */ __name((text3) => text3.replace(/[^\w.-]+/gu, "_"), "segment");
|
|
2586
|
+
var accountFolder = /* @__PURE__ */ __name((app, run3) => join2(resolvePaths({ appName: app.appName, prefix: app.envPrefix, env: run3.env ?? process.env }).state, "crm", CRM_SHARED_FOLDERS.files, segment(`${run3.account.provider}-${run3.account.account}`)), "accountFolder");
|
|
3360
2587
|
var ownFolder = /* @__PURE__ */ __name((top, folder) => {
|
|
3361
2588
|
mkdirSync(folder, { recursive: true, mode: 448 });
|
|
3362
2589
|
for (let at2 = resolve(folder); at2.startsWith(resolve(top)); at2 = resolve(at2, "..")) {
|
|
@@ -3395,7 +2622,7 @@ var placeNew = /* @__PURE__ */ __name((part, target) => {
|
|
|
3395
2622
|
var saveStream = /* @__PURE__ */ __name(async (stream, target, { cap, signal, exclusive }) => {
|
|
3396
2623
|
const part = `${target}.part-${process.pid}`;
|
|
3397
2624
|
const handle = await open(part, "wx", 384);
|
|
3398
|
-
const hash =
|
|
2625
|
+
const hash = createHash("sha256");
|
|
3399
2626
|
const reader = stream.getReader();
|
|
3400
2627
|
let bytes = 0;
|
|
3401
2628
|
try {
|
|
@@ -3473,12 +2700,12 @@ var targetOf = /* @__PURE__ */ __name((folder, file, earlier, held, capped) => {
|
|
|
3473
2700
|
const providerId = segment(parseCrmFileId(file.id).providerId);
|
|
3474
2701
|
const name = safeName(file.name) ?? `file-${providerId}`;
|
|
3475
2702
|
const free = /* @__PURE__ */ __name((path) => path === earlier || !held.has(path) && !existsSync(path), "free");
|
|
3476
|
-
for (const candidate of [
|
|
2703
|
+
for (const candidate of [join2(folder, name), join2(folder, `${providerId}-${name}`)])
|
|
3477
2704
|
if (free(candidate))
|
|
3478
2705
|
return candidate;
|
|
3479
2706
|
if (capped)
|
|
3480
2707
|
for (let at2 = 2; ; at2 += 1) {
|
|
3481
|
-
const candidate =
|
|
2708
|
+
const candidate = join2(folder, `${providerId}-${at2}-${name}`);
|
|
3482
2709
|
if (free(candidate))
|
|
3483
2710
|
return candidate;
|
|
3484
2711
|
}
|
|
@@ -3492,14 +2719,14 @@ var downloadCrmFile = /* @__PURE__ */ __name(async (context, file, assignee, { c
|
|
|
3492
2719
|
if (file.size !== null && file.size > capBytes)
|
|
3493
2720
|
throw tooLarge(file.id, file.size, capMb, flag);
|
|
3494
2721
|
const top = accountFolder(app, run3);
|
|
3495
|
-
const folder = dir ? resolve(dir) :
|
|
2722
|
+
const folder = dir ? resolve(dir) : join2(top, segment(`${file.owner.kind}-${file.owner.id}`));
|
|
3496
2723
|
const setting = `crm.${run3.account.provider}:${run3.account.account}.files.max_total_mb`;
|
|
3497
2724
|
const capped = dir === void 0;
|
|
3498
2725
|
const room = /* @__PURE__ */ __name((need, target2, drop) => roomFor(context, top, { need, capBytes: limits.max_total_mb * MB, own: file.id, target: target2, drop }), "room");
|
|
3499
2726
|
if (capped && !await room(file.size ?? 0, null, false))
|
|
3500
2727
|
throw diskFull(limits, top, setting);
|
|
3501
2728
|
if (capped)
|
|
3502
|
-
ownFolder(
|
|
2729
|
+
ownFolder(join2(top, ".."), folder);
|
|
3503
2730
|
else
|
|
3504
2731
|
mkdirSync(folder, { recursive: true, mode: 448 });
|
|
3505
2732
|
const earlier = await run3.store.crmFiles.get(run3.account, file.id);
|
|
@@ -3537,7 +2764,7 @@ var downloadCrmFile = /* @__PURE__ */ __name(async (context, file, assignee, { c
|
|
|
3537
2764
|
}
|
|
3538
2765
|
let bytes;
|
|
3539
2766
|
try {
|
|
3540
|
-
bytes =
|
|
2767
|
+
bytes = readFileSync(target);
|
|
3541
2768
|
} catch {
|
|
3542
2769
|
await discard();
|
|
3543
2770
|
throw new CliError("not_found", `the saved copy of ${file.id} was removed before its text was read; run it again`, {
|
|
@@ -3662,13 +2889,13 @@ var addCrmFileCommands = /* @__PURE__ */ __name((program, options) => {
|
|
|
3662
2889
|
limits: await run3.store.crmFiles.limits(run3.account),
|
|
3663
2890
|
...opts.dir === void 0 ? {} : { dir: opts.dir }
|
|
3664
2891
|
});
|
|
3665
|
-
const
|
|
2892
|
+
const text3 = done.row.text;
|
|
3666
2893
|
return itemOf({
|
|
3667
2894
|
...itemOfFile(file, done.row),
|
|
3668
2895
|
size: done.row.size,
|
|
3669
2896
|
text_status: done.textStatus,
|
|
3670
|
-
text:
|
|
3671
|
-
text_truncated:
|
|
2897
|
+
text: text3 === null ? null : text3.slice(0, SHOWN_TEXT),
|
|
2898
|
+
text_truncated: text3 !== null && text3.length > SHOWN_TEXT,
|
|
3672
2899
|
untrusted: ["name", "mime", "path", "text"]
|
|
3673
2900
|
});
|
|
3674
2901
|
});
|
|
@@ -3839,7 +3066,7 @@ var syncFiles = /* @__PURE__ */ __name(async (context, outOfTime, deadline = (ms
|
|
|
3839
3066
|
return report;
|
|
3840
3067
|
}, "syncFiles");
|
|
3841
3068
|
|
|
3842
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
3069
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.722.0_@wirecat+cli-base@0.127.0_commander@15.0.0_esbuild@0.28.2_typ_d2bed0cfbe6b4358c89d465b9e07afcb/node_modules/@wirecat/cli-core/dist/crm/cli/pipeline-view.js
|
|
3843
3070
|
var sumOf = /* @__PURE__ */ __name((amounts) => amounts.map(({ amount, currency }) => `${groupDigits(amount)} ${currency}`).join(", ") || "\u2014", "sumOf");
|
|
3844
3071
|
var percent = /* @__PURE__ */ __name((share) => share === null ? "\u2014" : `${Math.round(share * 100)}%`, "percent");
|
|
3845
3072
|
var openStages = /* @__PURE__ */ __name((stages) => {
|
|
@@ -3885,11 +3112,12 @@ ${outcomes.join("\n")}`
|
|
|
3885
3112
|
].join("\n\n");
|
|
3886
3113
|
}, "pipelineView");
|
|
3887
3114
|
|
|
3888
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
3115
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.722.0_@wirecat+cli-base@0.127.0_commander@15.0.0_esbuild@0.28.2_typ_d2bed0cfbe6b4358c89d465b9e07afcb/node_modules/@wirecat/cli-core/dist/crm/cli/search-all.js
|
|
3889
3116
|
var SEARCHED = ["crm", ...SOURCE_SEARCHED];
|
|
3890
3117
|
var DEFAULT_LIMIT = 20;
|
|
3891
|
-
var addCrmSearchAll = /* @__PURE__ */ __name((searches, { within, app, example, viewerOf: viewerOf2 }) => {
|
|
3892
|
-
const
|
|
3118
|
+
var addCrmSearchAll = /* @__PURE__ */ __name((searches, { within, app, example, viewerOf: viewerOf2, leads = true }) => {
|
|
3119
|
+
const deals = leads ? "deals and leads" : "deals";
|
|
3120
|
+
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);
|
|
3893
3121
|
searches.addCommand(searchAllOptions(all, SEARCHED));
|
|
3894
3122
|
example(all, "search all Example LLC", "search all website --only crm --json");
|
|
3895
3123
|
all.action(async (words, _opts, leaf) => {
|
|
@@ -3932,7 +3160,7 @@ var addCrmSearchAll = /* @__PURE__ */ __name((searches, { within, app, example,
|
|
|
3932
3160
|
...opts.source === void 0 ? {} : { source: opts.source },
|
|
3933
3161
|
...alone ? { scope: { crm: [run3.account] } } : {}
|
|
3934
3162
|
}, { app, hintCommand: commandAt(rootOf2(leaf), "models download") ? app.command : null }, void 0, meaningLane({ env, messenger: { app }, store: /* @__PURE__ */ __name(async () => run3.store, "store") }));
|
|
3935
|
-
const note = /* @__PURE__ */ __name((
|
|
3163
|
+
const note = /* @__PURE__ */ __name((text3) => outputFor(leaf).renderer.note(text3), "note");
|
|
3936
3164
|
for (const { why } of denied)
|
|
3937
3165
|
note(why);
|
|
3938
3166
|
for (const { resource, source, reason } of found.skipped)
|
|
@@ -3951,11 +3179,11 @@ var addCrmSearchAll = /* @__PURE__ */ __name((searches, { within, app, example,
|
|
|
3951
3179
|
});
|
|
3952
3180
|
}, "addCrmSearchAll");
|
|
3953
3181
|
|
|
3954
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
3182
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.722.0_@wirecat+cli-base@0.127.0_commander@15.0.0_esbuild@0.28.2_typ_d2bed0cfbe6b4358c89d465b9e07afcb/node_modules/@wirecat/cli-core/dist/cli/profile-store.js
|
|
3955
3183
|
import { mkdtempSync, rmSync as rmSync2 } from "node:fs";
|
|
3956
3184
|
import { tmpdir } from "node:os";
|
|
3957
|
-
import { join as
|
|
3958
|
-
var
|
|
3185
|
+
import { join as join3 } from "node:path";
|
|
3186
|
+
var openProfileStore = /* @__PURE__ */ __name(async (options) => {
|
|
3959
3187
|
const { app, env, profile, readOnly, open: open2 } = options;
|
|
3960
3188
|
const locked = readOnly && readOnlyLockOf(app, env) !== void 0;
|
|
3961
3189
|
if (readOnly) {
|
|
@@ -3973,10 +3201,10 @@ var openCrmStore = /* @__PURE__ */ __name(async (options) => {
|
|
|
3973
3201
|
}
|
|
3974
3202
|
if (!locked)
|
|
3975
3203
|
return withProfile(options, env, options.account());
|
|
3976
|
-
const folder = mkdtempSync(
|
|
3204
|
+
const folder = mkdtempSync(join3(tmpdir(), `${app.command}-empty-`));
|
|
3977
3205
|
const removing = /* @__PURE__ */ __name(() => rmSync2(folder, { recursive: true, force: true }), "removing");
|
|
3978
3206
|
try {
|
|
3979
|
-
const empty = await withProfile(options, { ...env, MESSAGING_STORE:
|
|
3207
|
+
const empty = await withProfile(options, { ...env, MESSAGING_STORE: join3(folder, "wirecat.db") }, {
|
|
3980
3208
|
provider: options.provider,
|
|
3981
3209
|
account: profile
|
|
3982
3210
|
});
|
|
@@ -3987,7 +3215,7 @@ var openCrmStore = /* @__PURE__ */ __name(async (options) => {
|
|
|
3987
3215
|
removing();
|
|
3988
3216
|
throw error;
|
|
3989
3217
|
}
|
|
3990
|
-
}, "
|
|
3218
|
+
}, "openProfileStore");
|
|
3991
3219
|
var withProfile = /* @__PURE__ */ __name(async ({ app, profile, open: open2 }, env, account2) => {
|
|
3992
3220
|
const store = await open2(env);
|
|
3993
3221
|
try {
|
|
@@ -4000,7 +3228,10 @@ var withProfile = /* @__PURE__ */ __name(async ({ app, profile, open: open2 }, e
|
|
|
4000
3228
|
}
|
|
4001
3229
|
}, "withProfile");
|
|
4002
3230
|
|
|
4003
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
3231
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.722.0_@wirecat+cli-base@0.127.0_commander@15.0.0_esbuild@0.28.2_typ_d2bed0cfbe6b4358c89d465b9e07afcb/node_modules/@wirecat/cli-core/dist/crm/cli/store.js
|
|
3232
|
+
var openCrmStore = openProfileStore;
|
|
3233
|
+
|
|
3234
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.722.0_@wirecat+cli-base@0.127.0_commander@15.0.0_esbuild@0.28.2_typ_d2bed0cfbe6b4358c89d465b9e07afcb/node_modules/@wirecat/cli-core/dist/crm/cli/index.js
|
|
4004
3235
|
var MOST4 = 500;
|
|
4005
3236
|
var STAGE_REF = /^stage:\d+$/;
|
|
4006
3237
|
var timeField = /* @__PURE__ */ __name((name, example, relation) => nativeField({ name, type: "time", operators: ["term", "range"], example, relation }), "timeField");
|
|
@@ -4022,7 +3253,7 @@ var LEADS_QUERY = { entity: "lead", backend: "native", fields: DEAL_FIELDS };
|
|
|
4022
3253
|
var PIPELINES_QUERY = {
|
|
4023
3254
|
entity: "pipeline",
|
|
4024
3255
|
backend: "native",
|
|
4025
|
-
fields: [termField("kind", "enum", "kind:
|
|
3256
|
+
fields: [termField("kind", "enum", "kind:deal", { values: DEAL_KINDS })]
|
|
4026
3257
|
};
|
|
4027
3258
|
var STAGES_QUERY = {
|
|
4028
3259
|
entity: "stage",
|
|
@@ -4168,7 +3399,10 @@ var addCrmCommandsDefinition = /* @__PURE__ */ __name((program, options) => {
|
|
|
4168
3399
|
renderAnswer(command, outputFor(command), body, view);
|
|
4169
3400
|
}), "within");
|
|
4170
3401
|
const example = /* @__PURE__ */ __name((command, ...lines) => annotate(command, { examples: lines.map((line) => `${options.app.command} work ${line}`) }), "example");
|
|
4171
|
-
|
|
3402
|
+
const hasLeads = options.leads !== false;
|
|
3403
|
+
const dealsAndLeads = hasLeads ? "deals and leads" : "deals";
|
|
3404
|
+
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", `
|
|
3405
|
+
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) => {
|
|
4172
3406
|
const { signal } = environmentOf(command);
|
|
4173
3407
|
await within(command, async (run3) => {
|
|
4174
3408
|
const source = run3.source();
|
|
@@ -4225,7 +3459,7 @@ var addCrmCommandsDefinition = /* @__PURE__ */ __name((program, options) => {
|
|
|
4225
3459
|
await within(command, async (run3) => {
|
|
4226
3460
|
const status = await crmStatus(run3.store, run3.account, { profile: run3.profile, now: now() });
|
|
4227
3461
|
if (await viewerOf(run3))
|
|
4228
|
-
outputFor(command).renderer.note(
|
|
3462
|
+
outputFor(command).renderer.note(`stored counts the whole copy, more than the ${dealsAndLeads} you may read`);
|
|
4229
3463
|
return listOf(pathOf2(command).join(" "), {
|
|
4230
3464
|
items: status.items,
|
|
4231
3465
|
limit: status.limit,
|
|
@@ -4234,7 +3468,7 @@ var addCrmCommandsDefinition = /* @__PURE__ */ __name((program, options) => {
|
|
|
4234
3468
|
});
|
|
4235
3469
|
});
|
|
4236
3470
|
});
|
|
4237
|
-
example(answerEntity(annotate(store.command("apply"), { effects: LOCAL_WRITE }), "crm_contacts_removed", crmContactsApplied).description(
|
|
3471
|
+
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) => {
|
|
4238
3472
|
const yes = opts.yes === true;
|
|
4239
3473
|
await within(command, async (run3) => {
|
|
4240
3474
|
const scope = crmSettingKey(run3.account, "scope");
|
|
@@ -4409,7 +3643,7 @@ var addCrmCommandsDefinition = /* @__PURE__ */ __name((program, options) => {
|
|
|
4409
3643
|
const run3 = /* @__PURE__ */ __name((command, work) => within(command, (opened) => work(contextOf3(opened, command))), "run");
|
|
4410
3644
|
const create = write2("create", "create", `make a ${kind} in the CRM, then store the CRM's copy of it`);
|
|
4411
3645
|
if (create)
|
|
4412
|
-
example(fields2(create), `${plural} create --title "Example kitchen" --amount 15000 --currency EUR`, `${plural} create --title "Example office" --pipeline Sales --stage "Quote sent" --field
|
|
3646
|
+
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) => {
|
|
4413
3647
|
await run3(command, async (context) => {
|
|
4414
3648
|
const done = await createCrmItem(context, kind, inputOf(opts), idOf2(opts));
|
|
4415
3649
|
return answered(done.operationId, done.item);
|
|
@@ -4417,7 +3651,7 @@ var addCrmCommandsDefinition = /* @__PURE__ */ __name((program, options) => {
|
|
|
4417
3651
|
});
|
|
4418
3652
|
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`);
|
|
4419
3653
|
if (update2)
|
|
4420
|
-
example(fields2(reference(update2)), `${plural} update ${kind}:12 --amount 18000`, `${plural} update ${kind}:12 --field
|
|
3654
|
+
example(fields2(reference(update2)), `${plural} update ${kind}:12 --amount 18000`, `${plural} update ${kind}:12 --field Source=`).action(async (ref, opts, command) => {
|
|
4421
3655
|
await run3(command, async (context) => {
|
|
4422
3656
|
const done = await updateCrmItem(context, kind, ref, inputOf(opts), idOf2(opts));
|
|
4423
3657
|
return answered(done.operationId, done.item);
|
|
@@ -4460,7 +3694,7 @@ var addCrmCommandsDefinition = /* @__PURE__ */ __name((program, options) => {
|
|
|
4460
3694
|
if (options.leads !== false)
|
|
4461
3695
|
items("lead");
|
|
4462
3696
|
const pipelines = annotate(program.command("pipelines"), { effects: NO_EFFECTS }).description("the CRM's pipelines and their stages, as last synced");
|
|
4463
|
-
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) => {
|
|
3697
|
+
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) => {
|
|
4464
3698
|
const terms = queryTerms(words, PIPELINES_QUERY, "pipelines list");
|
|
4465
3699
|
await within(command, async (run3) => {
|
|
4466
3700
|
const found = await run3.store.deals.pipelines({
|
|
@@ -4495,7 +3729,7 @@ var addCrmCommandsDefinition = /* @__PURE__ */ __name((program, options) => {
|
|
|
4495
3729
|
}, (body) => pipelineView(body, outputFor(command).color));
|
|
4496
3730
|
});
|
|
4497
3731
|
const stages = annotate(program.command("stages"), { effects: NO_EFFECTS }).description("the stages of the CRM's pipelines, as last synced");
|
|
4498
|
-
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) => {
|
|
3732
|
+
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) => {
|
|
4499
3733
|
const terms = queryTerms(words, STAGES_QUERY, "stages list");
|
|
4500
3734
|
await within(command, async (run3) => {
|
|
4501
3735
|
const kind = terms.has("kind") ? terms.get("kind") : void 0;
|
|
@@ -4538,6 +3772,7 @@ var addCrmCommandsDefinition = /* @__PURE__ */ __name((program, options) => {
|
|
|
4538
3772
|
open: options.open,
|
|
4539
3773
|
app: options.app,
|
|
4540
3774
|
live: options.live ?? [],
|
|
3775
|
+
...options.liveQuery ? { liveQuery: options.liveQuery } : {},
|
|
4541
3776
|
...writes ? { writes } : {},
|
|
4542
3777
|
now
|
|
4543
3778
|
});
|
|
@@ -4545,7 +3780,7 @@ var addCrmCommandsDefinition = /* @__PURE__ */ __name((program, options) => {
|
|
|
4545
3780
|
if (options.files)
|
|
4546
3781
|
addCrmFileCommands(program, { ...options, within, example, now });
|
|
4547
3782
|
const fieldKinds = Object.keys(FIELD_KINDS).filter((word) => word !== "leads" || options.leads !== false);
|
|
4548
|
-
const fields = annotate(program.command("fields"), { effects: NO_EFFECTS }).description(
|
|
3783
|
+
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`);
|
|
4549
3784
|
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) => {
|
|
4550
3785
|
if (!fieldKinds.includes(kind))
|
|
4551
3786
|
throw new CliError("validation_error", `fields are listed for ${fieldKinds.join(", ")}; got ${kind}`, {
|
|
@@ -4568,10 +3803,49 @@ var addCrmCommandsDefinition = /* @__PURE__ */ __name((program, options) => {
|
|
|
4568
3803
|
});
|
|
4569
3804
|
});
|
|
4570
3805
|
const search = program.commands.find((one) => one.name() === "search") ?? annotate(program.command("search"), { effects: NO_EFFECTS }).description("search what the local store holds");
|
|
4571
|
-
addCrmSearchAll(search, { within, app: options.app, example, viewerOf });
|
|
3806
|
+
addCrmSearchAll(search, { within, app: options.app, example, viewerOf, leads: hasLeads });
|
|
3807
|
+
if (options.account)
|
|
3808
|
+
program.addCommand(crmAccountCommand(options.app, options.account));
|
|
4572
3809
|
}, "addCrmCommandsDefinition");
|
|
4573
3810
|
var addCrmCommands = honoursDryRun(sharedCommand(addCrmCommandsDefinition));
|
|
4574
3811
|
|
|
3812
|
+
// dist/commands/account.js
|
|
3813
|
+
var rememberedOf = /* @__PURE__ */ __name((profile, env) => {
|
|
3814
|
+
const parts = /^(.+):(\d+)$/.exec(recalledAccount(IDENTITY, PROVIDER.name, profile, env)?.account ?? "");
|
|
3815
|
+
return parts?.[1] && parts[2] ? { account: parts[1], user: parts[2] } : void 0;
|
|
3816
|
+
}, "rememberedOf");
|
|
3817
|
+
var signedInAs = /* @__PURE__ */ __name((profile, env, keyring) => {
|
|
3818
|
+
const tokens = new ProfileTokenStore({ app: IDENTITY, env, ...keyring ? { keyring } : {}, warn: /* @__PURE__ */ __name(() => {
|
|
3819
|
+
}, "warn") });
|
|
3820
|
+
const app = withoutKeyring(() => appStorage(env, profile, keyring).read()?.account, () => tokens.read(profile));
|
|
3821
|
+
if (app)
|
|
3822
|
+
return { account: new URL(app.host).host, user: app.userId };
|
|
3823
|
+
const saved = tokens.read(profile);
|
|
3824
|
+
if (!saved || saved.source === "environment")
|
|
3825
|
+
return void 0;
|
|
3826
|
+
const signIn = decodeSignIn(saved.secret);
|
|
3827
|
+
return { account: new URL(signIn.origin).host, user: signIn.userId };
|
|
3828
|
+
}, "signedInAs");
|
|
3829
|
+
var AMO_ACCOUNT = {
|
|
3830
|
+
provider: PROVIDER.name,
|
|
3831
|
+
service: "amoCRM",
|
|
3832
|
+
held: /* @__PURE__ */ __name((profile, { env, keyring }) => {
|
|
3833
|
+
const remembered = rememberedOf(profile, env);
|
|
3834
|
+
try {
|
|
3835
|
+
const saved = signedInAs(profile, env, keyring);
|
|
3836
|
+
if (saved)
|
|
3837
|
+
return { ...saved, signedIn: true };
|
|
3838
|
+
} catch (error) {
|
|
3839
|
+
if (!remembered)
|
|
3840
|
+
throw error;
|
|
3841
|
+
}
|
|
3842
|
+
return remembered && { ...remembered, signedIn: false };
|
|
3843
|
+
}, "held"),
|
|
3844
|
+
// amoCRM has no call that revokes a long-lived token or an integration's tokens; the integration's card does.
|
|
3845
|
+
signedOut: /* @__PURE__ */ __name((profile) => `the sign-in of ${profile} (the integration and its keys stay in amoCRM)`, "signedOut"),
|
|
3846
|
+
resolveSettings: configuration.resolveSettings
|
|
3847
|
+
};
|
|
3848
|
+
|
|
4575
3849
|
// dist/commands/crm-shared.js
|
|
4576
3850
|
var userOf = /* @__PURE__ */ __name(async (command, amo) => {
|
|
4577
3851
|
let signIn;
|
|
@@ -4593,9 +3867,9 @@ var userOf = /* @__PURE__ */ __name(async (command, amo) => {
|
|
|
4593
3867
|
var openProfile = /* @__PURE__ */ __name(async (command, { readOnly }) => {
|
|
4594
3868
|
const { env, profile } = contextOf(command);
|
|
4595
3869
|
const [{ openAmoStore, PROVIDER: PROVIDER3 }, { amoCrmSource: amoCrmSource2 }, { amoCrmWriter }] = await Promise.all([
|
|
4596
|
-
import("./store-
|
|
4597
|
-
import("./source-
|
|
4598
|
-
import("./writer-
|
|
3870
|
+
import("./store-SNW6U32Y.js"),
|
|
3871
|
+
import("./source-Z7GH7T4B.js"),
|
|
3872
|
+
import("./writer-BJDQMKUV.js")
|
|
4599
3873
|
]);
|
|
4600
3874
|
const accountOf = /* @__PURE__ */ __name(() => {
|
|
4601
3875
|
const signIn = storedSignIn(command) ?? signInOf(command);
|
|
@@ -4614,7 +3888,7 @@ var openProfile = /* @__PURE__ */ __name(async (command, { readOnly }) => {
|
|
|
4614
3888
|
const amo = /* @__PURE__ */ __name(() => transport ??= transportFor(command, signInOf(command)), "amo");
|
|
4615
3889
|
let source;
|
|
4616
3890
|
const asked = /* @__PURE__ */ __name(async () => {
|
|
4617
|
-
const { crmSettingKey: crmSettingKey2 } = await import("./store-
|
|
3891
|
+
const { crmSettingKey: crmSettingKey2 } = await import("./store-OSOUXBYL.js");
|
|
4618
3892
|
const scope = await store.crm.scope(account2);
|
|
4619
3893
|
return {
|
|
4620
3894
|
mode: scope.mode,
|
|
@@ -4656,7 +3930,8 @@ var crmSharedCommands = /* @__PURE__ */ __name(() => {
|
|
|
4656
3930
|
leads: false,
|
|
4657
3931
|
writes: AMO_WRITES,
|
|
4658
3932
|
live: ["person", "organization", "user"],
|
|
4659
|
-
activities: true
|
|
3933
|
+
activities: true,
|
|
3934
|
+
account: AMO_ACCOUNT
|
|
4660
3935
|
});
|
|
4661
3936
|
return [...holder.commands];
|
|
4662
3937
|
}, "crmSharedCommands");
|
|
@@ -4668,6 +3943,441 @@ var contextOf2 = /* @__PURE__ */ __name((command, resolving) => {
|
|
|
4668
3943
|
}, "contextOf");
|
|
4669
3944
|
var scheduleCommand = /* @__PURE__ */ __name(() => scheduleCommandFor({ app: IDENTITY, context: contextOf2 }), "scheduleCommand");
|
|
4670
3945
|
|
|
3946
|
+
// dist/amo/button.js
|
|
3947
|
+
import { randomBytes } from "node:crypto";
|
|
3948
|
+
import { createServer } from "node:http";
|
|
3949
|
+
var CONNECT_VARIABLE = `${IDENTITY.envPrefix}_CONNECT_URL`;
|
|
3950
|
+
var CALLBACK_MS = 6e5;
|
|
3951
|
+
var CLAIM_MS = 6e4;
|
|
3952
|
+
var CLAIM_PAUSES_MS = [500, 1e3, 2e3, 4e3];
|
|
3953
|
+
var REQUEST_MS2 = 3e4;
|
|
3954
|
+
var AMOCRM_HOST = /^[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?\.amocrm\.ru$/;
|
|
3955
|
+
var connectUrls = /* @__PURE__ */ __name((env) => {
|
|
3956
|
+
const given = env[CONNECT_VARIABLE]?.trim();
|
|
3957
|
+
if (!given)
|
|
3958
|
+
return { page: CONNECT_PAGE_URL, claim: CLAIM_URL };
|
|
3959
|
+
let url;
|
|
3960
|
+
try {
|
|
3961
|
+
url = new URL(given);
|
|
3962
|
+
} catch {
|
|
3963
|
+
url = void 0;
|
|
3964
|
+
}
|
|
3965
|
+
if (url?.protocol !== "https:" || url.username || url.password)
|
|
3966
|
+
throw new CliError("configuration_error", `${CONNECT_VARIABLE} must be an https address, such as https://connect.wirecat.dev`, {
|
|
3967
|
+
reason: "connect.url-invalid"
|
|
3968
|
+
});
|
|
3969
|
+
const { origin } = url;
|
|
3970
|
+
const moved = /* @__PURE__ */ __name((address) => `${origin}${new URL(address).pathname}`, "moved");
|
|
3971
|
+
return { page: moved(CONNECT_PAGE_URL), claim: moved(CLAIM_URL) };
|
|
3972
|
+
}, "connectUrls");
|
|
3973
|
+
var refuseKommo = /* @__PURE__ */ __name((origin) => {
|
|
3974
|
+
if (AMOCRM_HOST.test(new URL(origin).hostname))
|
|
3975
|
+
return;
|
|
3976
|
+
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" });
|
|
3977
|
+
}, "refuseKommo");
|
|
3978
|
+
var queryOf2 = /* @__PURE__ */ __name((text3) => {
|
|
3979
|
+
const trimmed = text3.trim();
|
|
3980
|
+
const start = trimmed.indexOf("?");
|
|
3981
|
+
return new URLSearchParams(start >= 0 ? trimmed.slice(start + 1).split("#")[0] : trimmed);
|
|
3982
|
+
}, "queryOf");
|
|
3983
|
+
var awaitRedirect = /* @__PURE__ */ __name(async (open2, steps, signal) => {
|
|
3984
|
+
if (signal?.aborted)
|
|
3985
|
+
throw new CliError("cancelled", "the amoCRM sign-in was cancelled");
|
|
3986
|
+
const paste = new AbortController();
|
|
3987
|
+
let state = "";
|
|
3988
|
+
let settled = false;
|
|
3989
|
+
let accept = /* @__PURE__ */ __name(() => {
|
|
3990
|
+
}, "accept");
|
|
3991
|
+
let fail = /* @__PURE__ */ __name(() => {
|
|
3992
|
+
}, "fail");
|
|
3993
|
+
const redirect = new Promise((resolve2, reject) => {
|
|
3994
|
+
accept = /* @__PURE__ */ __name((query) => {
|
|
3995
|
+
settled = true;
|
|
3996
|
+
resolve2(query);
|
|
3997
|
+
}, "accept");
|
|
3998
|
+
fail = /* @__PURE__ */ __name((error) => {
|
|
3999
|
+
settled = true;
|
|
4000
|
+
reject(error);
|
|
4001
|
+
}, "fail");
|
|
4002
|
+
});
|
|
4003
|
+
void redirect.catch(() => {
|
|
4004
|
+
});
|
|
4005
|
+
const handler = /* @__PURE__ */ __name((request, response) => {
|
|
4006
|
+
const url = new URL(request.url ?? "/", "http://localhost");
|
|
4007
|
+
if (request.method !== "GET" || url.pathname !== "/callback")
|
|
4008
|
+
return void response.writeHead(404).end();
|
|
4009
|
+
if (settled || !state || url.searchParams.get("state") !== state)
|
|
4010
|
+
return void response.writeHead(400).end("This sign-in link does not belong to the waiting sign-in");
|
|
4011
|
+
response.end("Sign-in received; you can close this tab");
|
|
4012
|
+
accept(url.searchParams);
|
|
4013
|
+
}, "handler");
|
|
4014
|
+
const server = createServer(handler);
|
|
4015
|
+
const onAbort = /* @__PURE__ */ __name(() => fail(new CliError("cancelled", "the amoCRM sign-in was cancelled")), "onAbort");
|
|
4016
|
+
signal?.addEventListener("abort", onAbort, { once: true });
|
|
4017
|
+
const timer = setTimeout(() => fail(new CliError("timeout", "the amoCRM sign-in timed out", { reason: "oauth.timeout" })), CALLBACK_MS);
|
|
4018
|
+
timer.unref();
|
|
4019
|
+
try {
|
|
4020
|
+
await new Promise((resolve2, reject) => {
|
|
4021
|
+
server.once("error", reject);
|
|
4022
|
+
server.listen(0, "127.0.0.1", resolve2);
|
|
4023
|
+
});
|
|
4024
|
+
const address = server.address();
|
|
4025
|
+
if (!address || typeof address === "string")
|
|
4026
|
+
throw new CliError("configuration_error", "could not start the local sign-in listener");
|
|
4027
|
+
state = `${address.port}.${randomBytes(32).toString("base64url")}`;
|
|
4028
|
+
const url = open2(state);
|
|
4029
|
+
steps.showUrl(url);
|
|
4030
|
+
steps.readPaste?.(paste.signal).then((text3) => {
|
|
4031
|
+
if (settled)
|
|
4032
|
+
return;
|
|
4033
|
+
const query = queryOf2(text3);
|
|
4034
|
+
if (query.get("state") !== state)
|
|
4035
|
+
fail(new CliError("authentication_error", "the pasted sign-in result does not match this sign-in", {
|
|
4036
|
+
reason: "oauth.mismatch"
|
|
4037
|
+
}));
|
|
4038
|
+
else
|
|
4039
|
+
accept(query);
|
|
4040
|
+
}).catch(() => {
|
|
4041
|
+
});
|
|
4042
|
+
void Promise.resolve().then(() => steps.openBrowser(url)).catch(() => {
|
|
4043
|
+
});
|
|
4044
|
+
return { state, query: await redirect };
|
|
4045
|
+
} finally {
|
|
4046
|
+
clearTimeout(timer);
|
|
4047
|
+
signal?.removeEventListener("abort", onAbort);
|
|
4048
|
+
paste.abort();
|
|
4049
|
+
server.closeAllConnections();
|
|
4050
|
+
if (server.listening)
|
|
4051
|
+
await new Promise((resolve2) => server.close(() => resolve2()));
|
|
4052
|
+
}
|
|
4053
|
+
}, "awaitRedirect");
|
|
4054
|
+
var refuseOtherAccount = /* @__PURE__ */ __name((origin, query) => {
|
|
4055
|
+
const given = (query.get("referer") ?? "").trim().toLowerCase();
|
|
4056
|
+
const host = given.replace(/^https?:\/\//, "").replace(/\/.*$/, "");
|
|
4057
|
+
const expected = new URL(origin).hostname;
|
|
4058
|
+
if (host === expected)
|
|
4059
|
+
return;
|
|
4060
|
+
const named = AMOCRM_HOST.test(host) ? host : void 0;
|
|
4061
|
+
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 } : {} });
|
|
4062
|
+
}, "refuseOtherAccount");
|
|
4063
|
+
var claimKeys = /* @__PURE__ */ __name(async (options) => {
|
|
4064
|
+
const host = new URL(options.claim).hostname;
|
|
4065
|
+
const request = hostFetch({
|
|
4066
|
+
hosts: [host],
|
|
4067
|
+
timeoutMs: REQUEST_MS2,
|
|
4068
|
+
...options.fetch ? { fetch: options.fetch } : {}
|
|
4069
|
+
});
|
|
4070
|
+
const again = "start the browser sign-in again";
|
|
4071
|
+
const deadline = options.now() + CLAIM_MS;
|
|
4072
|
+
for (let attempt = 0; ; attempt += 1) {
|
|
4073
|
+
let response;
|
|
4074
|
+
try {
|
|
4075
|
+
response = await request(options.claim, {
|
|
4076
|
+
method: "POST",
|
|
4077
|
+
headers: { accept: "application/json", "content-type": "application/json" },
|
|
4078
|
+
body: JSON.stringify({ state: options.state }),
|
|
4079
|
+
redirect: "error",
|
|
4080
|
+
...options.signal ? { signal: options.signal } : {}
|
|
4081
|
+
});
|
|
4082
|
+
} catch (error) {
|
|
4083
|
+
if (options.signal?.aborted)
|
|
4084
|
+
throw new CliError("cancelled", "the amoCRM sign-in was cancelled");
|
|
4085
|
+
if (isCliError(error))
|
|
4086
|
+
throw error;
|
|
4087
|
+
throw new CliError("provider_unavailable", `could not reach ${host} for the integration's keys; ${again}`, {
|
|
4088
|
+
retryable: true,
|
|
4089
|
+
reason: "oauth.unavailable"
|
|
4090
|
+
});
|
|
4091
|
+
}
|
|
4092
|
+
const answer2 = await response.json().catch(() => void 0);
|
|
4093
|
+
if (response.ok) {
|
|
4094
|
+
const id = isRecord(answer2) ? answer2.client_id : void 0;
|
|
4095
|
+
const secret = isRecord(answer2) ? answer2.client_secret : void 0;
|
|
4096
|
+
if (typeof id !== "string" || !id || typeof secret !== "string" || !secret)
|
|
4097
|
+
throw new CliError("invalid_response", `${host} returned keys amo cannot use; ${again}`, {
|
|
4098
|
+
reason: "oauth.invalid-response"
|
|
4099
|
+
});
|
|
4100
|
+
return { clientId: id, clientSecret: secret };
|
|
4101
|
+
}
|
|
4102
|
+
const notReady = response.status === 404 && isRecord(answer2) && answer2.error === "not_ready";
|
|
4103
|
+
if (!notReady)
|
|
4104
|
+
throw new CliError("provider_unavailable", `${host} did not hand over the integration's keys (HTTP ${response.status}); ${again}`, { status: response.status, reason: "oauth.unavailable" });
|
|
4105
|
+
if (options.now() >= deadline)
|
|
4106
|
+
throw new CliError("timeout", `amoCRM did not send the integration's keys to ${host} within a minute; ${again}`, {
|
|
4107
|
+
reason: "oauth.timeout"
|
|
4108
|
+
});
|
|
4109
|
+
await options.sleep(CLAIM_PAUSES_MS[Math.min(attempt, CLAIM_PAUSES_MS.length - 1)] ?? 4e3, options.signal, "retry");
|
|
4110
|
+
}
|
|
4111
|
+
}, "claimKeys");
|
|
4112
|
+
var browserSignIn = /* @__PURE__ */ __name(async (options) => {
|
|
4113
|
+
const { origin } = options;
|
|
4114
|
+
refuseKommo(origin);
|
|
4115
|
+
const connect = connectUrls(options.env);
|
|
4116
|
+
const storage = appStorage(options.env, options.profile, options.keyring, options.storage === "file" ? "file" : "auto");
|
|
4117
|
+
storage.probe();
|
|
4118
|
+
const { state, query } = await awaitRedirect((made) => `${connect.page}#state=${made}`, options.steps, options.signal);
|
|
4119
|
+
if (!query.get("code"))
|
|
4120
|
+
throw new CliError("authentication_error", "amoCRM sign-in was declined", { reason: "oauth.declined" });
|
|
4121
|
+
refuseOtherAccount(origin, query);
|
|
4122
|
+
const client = await claimKeys({
|
|
4123
|
+
claim: connect.claim,
|
|
4124
|
+
state,
|
|
4125
|
+
fetch: options.fetch,
|
|
4126
|
+
sleep: options.sleep,
|
|
4127
|
+
now: options.now,
|
|
4128
|
+
signal: options.signal
|
|
4129
|
+
});
|
|
4130
|
+
const signInCommand = `${IDENTITY.command} ${options.profile} session start --host ${origin} --one-click`;
|
|
4131
|
+
const provider = appProvider(origin, client, BUTTON_RELAY_URL);
|
|
4132
|
+
const fetch = fetchFor(origin, options.fetch);
|
|
4133
|
+
const tokens = await provider.exchange?.({ grant_type: "authorization_code", code: query.get("code") ?? "" }, { fetch, client, now: Date.now, signInCommand, ...options.signal ? { signal: options.signal } : {} });
|
|
4134
|
+
if (!tokens)
|
|
4135
|
+
throw new CliError("authentication_error", "amoCRM did not answer the sign-in");
|
|
4136
|
+
const access = tokens.accessToken ?? "";
|
|
4137
|
+
const user = await options.check({ origin, userId: "", accessToken: /* @__PURE__ */ __name(async () => access, "accessToken") });
|
|
4138
|
+
storage.remove();
|
|
4139
|
+
await tokenKeeper({ provider, storage, lockDir: lockDirOf(options.env), fetch, signInCommand }).save(tokens, {
|
|
4140
|
+
host: origin,
|
|
4141
|
+
userId: user.id,
|
|
4142
|
+
redirectUri: BUTTON_RELAY_URL,
|
|
4143
|
+
browser: true
|
|
4144
|
+
});
|
|
4145
|
+
return user;
|
|
4146
|
+
}, "browserSignIn");
|
|
4147
|
+
|
|
4148
|
+
// dist/commands/session.js
|
|
4149
|
+
var AMO2 = IDENTITY.command;
|
|
4150
|
+
var answer = /* @__PURE__ */ __name((command, item) => renderAnswer(command, outputFor(command), itemOf(item)), "answer");
|
|
4151
|
+
var storageOf = /* @__PURE__ */ __name((raw) => {
|
|
4152
|
+
if (raw === "keyring" || raw === "file")
|
|
4153
|
+
return raw;
|
|
4154
|
+
throw new CliError("validation_error", `--credential-storage takes keyring or file; got ${raw}`);
|
|
4155
|
+
}, "storageOf");
|
|
4156
|
+
var tokensHere = /* @__PURE__ */ __name((env, keyring) => new ProfileTokenStore({ app: IDENTITY, env, ...keyring ? { keyring } : {} }), "tokensHere");
|
|
4157
|
+
var refuseTaken = /* @__PURE__ */ __name((command, at2) => {
|
|
4158
|
+
const { env, profile, keyring, settings } = contextOf(command);
|
|
4159
|
+
refuseTakenCrmAccount(IDENTITY, AMO_ACCOUNT, { env, profile, profiles: settings.configuredProfiles, ...keyring ? { keyring } : {} }, at2);
|
|
4160
|
+
}, "refuseTaken");
|
|
4161
|
+
var checkedToken = /* @__PURE__ */ __name(async (command, origin, token) => {
|
|
4162
|
+
const { run: run3 } = contextOf(command);
|
|
4163
|
+
const who = await run3((events) => accountUser(transportFor(command, { origin, token }, events)));
|
|
4164
|
+
refuseTaken(command, { account: who.account, user: who.user.id });
|
|
4165
|
+
return {
|
|
4166
|
+
who,
|
|
4167
|
+
signIn: encodeSignIn({ origin, token, userId: who.user.id }),
|
|
4168
|
+
account: `${who.account}:${who.user.id}`
|
|
4169
|
+
};
|
|
4170
|
+
}, "checkedToken");
|
|
4171
|
+
var keepHost = /* @__PURE__ */ __name((command, origin) => {
|
|
4172
|
+
const { profile, settings } = contextOf(command);
|
|
4173
|
+
configuration.changeSetting(settings.configPath, { profile, setting: "host", value: JSON.stringify(origin) });
|
|
4174
|
+
}, "keepHost");
|
|
4175
|
+
var PASTE = "If the browser did not come back here, paste the address it ended on: ";
|
|
4176
|
+
var browserStepsOf = /* @__PURE__ */ __name((command, steps, purpose) => {
|
|
4177
|
+
const { env, environment } = contextOf(command);
|
|
4178
|
+
const flags = command.optsWithGlobals();
|
|
4179
|
+
const machine = flags.json === true || flags.jsonl === true;
|
|
4180
|
+
const person = !machine && flags.input !== false && !env.CI && (environment.tty ?? process.stdout.isTTY) === true;
|
|
4181
|
+
const { streams } = outputFor(command);
|
|
4182
|
+
const input = secretInputOf(command).input ?? process.stdin;
|
|
4183
|
+
const given = environment.answer;
|
|
4184
|
+
return {
|
|
4185
|
+
openBrowser: /* @__PURE__ */ __name(async (url) => {
|
|
4186
|
+
if (environment.openBrowser)
|
|
4187
|
+
return environment.openBrowser(url);
|
|
4188
|
+
if (person)
|
|
4189
|
+
await openBrowser(url);
|
|
4190
|
+
}, "openBrowser"),
|
|
4191
|
+
showUrl: /* @__PURE__ */ __name((url) => {
|
|
4192
|
+
steps.openUrl(url, purpose);
|
|
4193
|
+
streams.diagnostic(`Open the amoCRM sign-in: ${url}
|
|
4194
|
+
`);
|
|
4195
|
+
}, "showUrl"),
|
|
4196
|
+
// A pipe was the secret, and an empty answer would end the sign-in before the browser came back.
|
|
4197
|
+
...given ? {
|
|
4198
|
+
readPaste: /* @__PURE__ */ __name(async () => {
|
|
4199
|
+
const text3 = await given(PASTE);
|
|
4200
|
+
if (text3 === null)
|
|
4201
|
+
throw new CliError("cancelled", "nobody is at a terminal to paste");
|
|
4202
|
+
return text3;
|
|
4203
|
+
}, "readPaste")
|
|
4204
|
+
} : input.isTTY && !machine ? {
|
|
4205
|
+
readPaste: /* @__PURE__ */ __name((signal) => readSecret(PASTE, { ...secretInputOf(command), echo: true, signal }), "readPaste")
|
|
4206
|
+
} : {}
|
|
4207
|
+
};
|
|
4208
|
+
}, "browserStepsOf");
|
|
4209
|
+
var stepsOf = /* @__PURE__ */ __name((command) => {
|
|
4210
|
+
const { environment } = contextOf(command);
|
|
4211
|
+
const flags = command.optsWithGlobals();
|
|
4212
|
+
const machine = flags.json === true || flags.jsonl === true;
|
|
4213
|
+
const { streams } = outputFor(command);
|
|
4214
|
+
return signInSteps({
|
|
4215
|
+
diagnostic: /* @__PURE__ */ __name((line) => streams.diagnostic(`${line}
|
|
4216
|
+
`), "diagnostic"),
|
|
4217
|
+
json: machine || environment.tty === false,
|
|
4218
|
+
answers: false
|
|
4219
|
+
});
|
|
4220
|
+
}, "stepsOf");
|
|
4221
|
+
var checkedUser = /* @__PURE__ */ __name((command, events) => async (auth) => {
|
|
4222
|
+
const found = await accountUser(transportFor(command, auth, events));
|
|
4223
|
+
refuseTaken(command, { account: found.account, user: found.user.id });
|
|
4224
|
+
return { ...found, id: found.user.id };
|
|
4225
|
+
}, "checkedUser");
|
|
4226
|
+
var signInWithButton = /* @__PURE__ */ __name(async (command, origin, steps, storage = "keyring") => {
|
|
4227
|
+
const { env, profile, tokens, keyring, run: run3, environment } = contextOf(command);
|
|
4228
|
+
refuseKommo(origin);
|
|
4229
|
+
const who = await run3((events) => browserSignIn({
|
|
4230
|
+
env,
|
|
4231
|
+
profile,
|
|
4232
|
+
origin,
|
|
4233
|
+
storage,
|
|
4234
|
+
keyring,
|
|
4235
|
+
fetch: environment.fetch,
|
|
4236
|
+
sleep: environment.sleep ?? realSleep,
|
|
4237
|
+
now: environment.now ?? monotonic,
|
|
4238
|
+
signal: environment.signal,
|
|
4239
|
+
steps: browserStepsOf(command, steps, "Choose the amoCRM account and allow WireCat's integration"),
|
|
4240
|
+
check: checkedUser(command, events)
|
|
4241
|
+
}));
|
|
4242
|
+
tokens.remove(profile);
|
|
4243
|
+
rememberAccount(IDENTITY, profile, `${who.account}:${who.user.id}`, env);
|
|
4244
|
+
const { id: _id, ...found } = who;
|
|
4245
|
+
return { found, storedIn: appSourceOf(env, profile, keyring) ?? storage };
|
|
4246
|
+
}, "signInWithButton");
|
|
4247
|
+
var startWithApp = /* @__PURE__ */ __name(async (command, args, origin) => {
|
|
4248
|
+
const { env, profile, tokens, keyring, run: run3, environment } = contextOf(command);
|
|
4249
|
+
const clientId = (args.clientId ?? env[CLIENT_ID] ?? "").trim();
|
|
4250
|
+
const clientSecret = env[CLIENT_SECRET]?.trim() || (await readSecret("amoCRM integration secret key: ", secretInputOf(command))).trim();
|
|
4251
|
+
if (!clientSecret)
|
|
4252
|
+
throw new CliError("validation_error", "no secret key was given");
|
|
4253
|
+
const signInCommand = `${AMO2} ${profile} session start --host ${origin} --client-id ${clientId}`;
|
|
4254
|
+
const who = await run3((events) => appSignIn({
|
|
4255
|
+
env,
|
|
4256
|
+
profile,
|
|
4257
|
+
origin,
|
|
4258
|
+
client: { clientId, clientSecret },
|
|
4259
|
+
storage: args.credentialStorage,
|
|
4260
|
+
keyring,
|
|
4261
|
+
fetch: environment.fetch,
|
|
4262
|
+
signal: environment.signal,
|
|
4263
|
+
signInCommand,
|
|
4264
|
+
steps: browserStepsOf(command, stepsOf(command), "Sign in to amoCRM and allow the integration"),
|
|
4265
|
+
check: checkedUser(command, events)
|
|
4266
|
+
}));
|
|
4267
|
+
tokens.remove(profile);
|
|
4268
|
+
keepHost(command, origin);
|
|
4269
|
+
rememberAccount(IDENTITY, profile, `${who.account}:${who.user.id}`, env);
|
|
4270
|
+
const { id: _id, ...found } = who;
|
|
4271
|
+
return {
|
|
4272
|
+
profile,
|
|
4273
|
+
state: "saved",
|
|
4274
|
+
kind: "app",
|
|
4275
|
+
stored_in: appSourceOf(env, profile, keyring) ?? args.credentialStorage,
|
|
4276
|
+
verified: true,
|
|
4277
|
+
...found
|
|
4278
|
+
};
|
|
4279
|
+
}, "startWithApp");
|
|
4280
|
+
var startWithButton = /* @__PURE__ */ __name(async (command, args, origin) => {
|
|
4281
|
+
const { found, storedIn } = await signInWithButton(command, origin, stepsOf(command), args.credentialStorage);
|
|
4282
|
+
keepHost(command, origin);
|
|
4283
|
+
return {
|
|
4284
|
+
profile: contextOf(command).profile,
|
|
4285
|
+
state: "saved",
|
|
4286
|
+
kind: "app",
|
|
4287
|
+
stored_in: storedIn,
|
|
4288
|
+
verified: true,
|
|
4289
|
+
...found
|
|
4290
|
+
};
|
|
4291
|
+
}, "startWithButton");
|
|
4292
|
+
var CLIENT_ID = `${IDENTITY.envPrefix}_AMOCRM_CLIENT_ID`;
|
|
4293
|
+
var CLIENT_SECRET = `${IDENTITY.envPrefix}_AMOCRM_CLIENT_SECRET`;
|
|
4294
|
+
var startCommand = /* @__PURE__ */ __name(() => logsInOrOut(annotate(new Command("start"), {
|
|
4295
|
+
effects: FETCH,
|
|
4296
|
+
lifetime: "interactive",
|
|
4297
|
+
mcp: false,
|
|
4298
|
+
examples: [
|
|
4299
|
+
`${AMO2} work session start --host https://example.amocrm.ru`,
|
|
4300
|
+
`${AMO2} work session start --host https://example.amocrm.ru --one-click`,
|
|
4301
|
+
`${AMO2} work session start --host https://example.amocrm.ru --client-id 0123abcd-4567-89ef-0123-456789abcdef`
|
|
4302
|
+
]
|
|
4303
|
+
})).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) {
|
|
4304
|
+
const { env, profile, tokens, keyring } = contextOf(this);
|
|
4305
|
+
refuseCommandName(profile, commandWords(rootOf(this)), AMO2);
|
|
4306
|
+
refuseOffline(this, "the amoCRM account");
|
|
4307
|
+
const origin = accountOrigin(args.host);
|
|
4308
|
+
if (args.oneClick) {
|
|
4309
|
+
if (args.clientId !== void 0)
|
|
4310
|
+
throw new CliError("validation_error", "--one-click makes its own integration; leave out --client-id", {
|
|
4311
|
+
param: "--client-id"
|
|
4312
|
+
});
|
|
4313
|
+
return answer(this, await startWithButton(this, args, origin));
|
|
4314
|
+
}
|
|
4315
|
+
if (args.clientId !== void 0 || env[CLIENT_ID])
|
|
4316
|
+
return answer(this, await startWithApp(this, args, origin));
|
|
4317
|
+
const token = (await readSecret("amoCRM long-lived token: ", secretInputOf(this))).trim();
|
|
4318
|
+
if (!token)
|
|
4319
|
+
throw new CliError("validation_error", "no token was given");
|
|
4320
|
+
const { who, signIn, account: account2 } = await checkedToken(this, origin, token);
|
|
4321
|
+
const storedIn = tokens.write(profile, signIn, args.credentialStorage);
|
|
4322
|
+
keepHost(this, origin);
|
|
4323
|
+
appStorage(env, profile, keyring).remove();
|
|
4324
|
+
rememberAccount(IDENTITY, profile, account2, env);
|
|
4325
|
+
answer(this, { profile, state: "saved", kind: "token", stored_in: storedIn, verified: true, ...who });
|
|
4326
|
+
}), "startCommand");
|
|
4327
|
+
var statusCommand = /* @__PURE__ */ __name(() => annotate(new Command("status"), {
|
|
4328
|
+
effects: REMOTE_READ,
|
|
4329
|
+
examples: [`${AMO2} work session status`, `${AMO2} work session status --check --json`]
|
|
4330
|
+
}).summary("show how this profile signs in, and with --check as whom it acts").description(`show which account this profile signs in to, with a long-lived token or an integration, and where that comes from: ${IDENTITY.envPrefix}_TOKEN, the keyring or a file; never a token or the secret key`).option("--check", "ask the account whether the sign-in still works and whose it is: the account, the user and admin").action(async function(args) {
|
|
4331
|
+
const { env, profile, tokens, keyring } = contextOf(this);
|
|
4332
|
+
const saved = tokens.read(profile);
|
|
4333
|
+
const app = saved?.source === "environment" ? void 0 : appAuthFor(this);
|
|
4334
|
+
const signIn = storedSignIn(this);
|
|
4335
|
+
const status = {
|
|
4336
|
+
profile,
|
|
4337
|
+
state: signIn ? "saved" : "missing",
|
|
4338
|
+
kind: app ? "app" : signIn ? "token" : null,
|
|
4339
|
+
token_from: app ? appSourceOf(env, profile, keyring) ?? null : saved?.source ?? null,
|
|
4340
|
+
account: signIn ? new URL(signIn.origin).host : null
|
|
4341
|
+
};
|
|
4342
|
+
if (!args.check || !signIn)
|
|
4343
|
+
return answer(this, { ...status, verified: false });
|
|
4344
|
+
answer(this, { ...status, verified: true, ...await withAccount(this, accountUser) });
|
|
4345
|
+
}), "statusCommand");
|
|
4346
|
+
var endCommand = /* @__PURE__ */ __name(() => logsInOrOut(annotate(new Command("end"), {
|
|
4347
|
+
effects: LOCAL_WRITE,
|
|
4348
|
+
mcp: false,
|
|
4349
|
+
examples: [`${AMO2} work session end`]
|
|
4350
|
+
})).summary("forget this profile's sign-in on this computer").description("forget this profile's long-lived token, or its integration's secret key and tokens, and the account address on this computer; amoCRM has no call that revokes a token: revoke it on the integration's Keys and scopes tab, or switch the integration off").action(function() {
|
|
4351
|
+
refuseUnderReadOnly(this, "session end");
|
|
4352
|
+
const { env, profile, tokens, keyring } = contextOf(this);
|
|
4353
|
+
const ended = [...tokens.remove(profile), ...appStorage(env, profile, keyring).remove()];
|
|
4354
|
+
answer(this, { profile, ended: [...new Set(ended)] });
|
|
4355
|
+
}), "endCommand");
|
|
4356
|
+
var listCommand2 = /* @__PURE__ */ __name(() => profileFree(annotate(new Command("list"), {
|
|
4357
|
+
effects: LOCAL_READ,
|
|
4358
|
+
examples: [`${AMO2} session list`, `${AMO2} session list --json`]
|
|
4359
|
+
})).summary("list the profiles here and whether each is signed in").description("list the profiles on this computer, whether each has a token and for which account; picks none").action(function() {
|
|
4360
|
+
const environment = environmentOf(this);
|
|
4361
|
+
const env = environment.env ?? process.env;
|
|
4362
|
+
const { configuredProfiles } = configuration.resolveSettings({}, { env, needsProfile: false });
|
|
4363
|
+
const tokens = tokensHere(env, environment.keyring);
|
|
4364
|
+
const items = profilesHere(IDENTITY, configuredProfiles, env).map((profile) => {
|
|
4365
|
+
try {
|
|
4366
|
+
const saved = tokens.read(profile);
|
|
4367
|
+
const app = saved ? void 0 : appStorage(env, profile, environment.keyring).read()?.account;
|
|
4368
|
+
const host = app ? new URL(app.host).host : saved && saved.source !== "environment" ? new URL(decodeSignIn(saved.secret).origin).host : null;
|
|
4369
|
+
const from = saved?.source ?? (app ? appSourceOf(env, profile, environment.keyring) : void 0);
|
|
4370
|
+
return { profile, signed_in: from !== void 0, token_from: from ?? null, account: host };
|
|
4371
|
+
} catch (error) {
|
|
4372
|
+
if (!(error instanceof CliError))
|
|
4373
|
+
throw error;
|
|
4374
|
+
return { profile, signed_in: null, token_from: null, account: null, error: error.message };
|
|
4375
|
+
}
|
|
4376
|
+
});
|
|
4377
|
+
renderAnswer(this, outputFor(this), listOf("session list", { items, limit: Math.max(1, items.length), has_more: false }));
|
|
4378
|
+
}), "listCommand");
|
|
4379
|
+
var sessionCommand = /* @__PURE__ */ __name(() => annotate(new Command("session"), { effects: LOCAL_READ }).description("keep this profile's amoCRM sign-in and account address in the OS keyring").addCommand(startCommand()).addCommand(statusCommand()).addCommand(endCommand()).addCommand(listCommand2()), "sessionCommand");
|
|
4380
|
+
|
|
4671
4381
|
// dist/setup/texts.en.json
|
|
4672
4382
|
var texts_en_default = {
|
|
4673
4383
|
"account.title": "Which account?",
|
|
@@ -4692,7 +4402,28 @@ var texts_en_default = {
|
|
|
4692
4402
|
"done.title": "Connected",
|
|
4693
4403
|
"done.body": "The profile is ready. Copy your deals and their clients into WireCat, then list the open ones:",
|
|
4694
4404
|
"done.oauth.title": "Advanced: sign in through the integration instead",
|
|
4695
|
-
"done.oauth": "
|
|
4405
|
+
"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:",
|
|
4406
|
+
"role.title": "Are you an administrator of this account?",
|
|
4407
|
+
"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.",
|
|
4408
|
+
"role.admin": "Yes, I am an administrator",
|
|
4409
|
+
"role.admin.hint": "You see \u0430\u043C\u043E\u041C\u0430\u0440\u043A\u0435\u0442 in the menu on the left and can create integrations.",
|
|
4410
|
+
"role.member": "No, I am a user",
|
|
4411
|
+
"role.member.hint": "There is no \u0430\u043C\u043E\u041C\u0430\u0440\u043A\u0435\u0442 in your menu. An administrator sends you the token.",
|
|
4412
|
+
"ask.title": "Ask an administrator for the token",
|
|
4413
|
+
"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.",
|
|
4414
|
+
"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.",
|
|
4415
|
+
"ask.later": "When you have the token, go on to the next step and paste it.",
|
|
4416
|
+
"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.",
|
|
4417
|
+
"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.",
|
|
4418
|
+
"method.title": "How do you want to sign in?",
|
|
4419
|
+
"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.",
|
|
4420
|
+
"method.browser": "Sign in with amoCRM",
|
|
4421
|
+
"method.browser.hint": "amoCRM creates a WireCat integration in the account, and amo renews the sign-in itself.",
|
|
4422
|
+
"method.token": "With a long-lived token",
|
|
4423
|
+
"method.token.hint": "You create a private integration and paste its token here.",
|
|
4424
|
+
"connect.title": "Allow access in amoCRM",
|
|
4425
|
+
"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.",
|
|
4426
|
+
"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."
|
|
4696
4427
|
};
|
|
4697
4428
|
|
|
4698
4429
|
// dist/setup/texts.es.json
|
|
@@ -4719,7 +4450,28 @@ var texts_es_default = {
|
|
|
4719
4450
|
"done.title": "Conectado",
|
|
4720
4451
|
"done.body": "El perfil est\xE1 listo. Copia tus negocios y sus clientes a WireCat y luego muestra los abiertos:",
|
|
4721
4452
|
"done.oauth.title": "Avanzado: entrar con la integraci\xF3n",
|
|
4722
|
-
"done.oauth": "
|
|
4453
|
+
"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:",
|
|
4454
|
+
"role.title": "\xBFEres administrador de esta cuenta?",
|
|
4455
|
+
"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.",
|
|
4456
|
+
"role.admin": "S\xED, soy administrador",
|
|
4457
|
+
"role.admin.hint": "Ves \u0430\u043C\u043E\u041C\u0430\u0440\u043A\u0435\u0442 en el men\xFA de la izquierda y puedes crear integraciones.",
|
|
4458
|
+
"role.member": "No, soy usuario",
|
|
4459
|
+
"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.",
|
|
4460
|
+
"ask.title": "Pide el token a un administrador",
|
|
4461
|
+
"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.",
|
|
4462
|
+
"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.",
|
|
4463
|
+
"ask.later": "Cuando tengas el token, pasa al siguiente paso y p\xE9galo.",
|
|
4464
|
+
"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.",
|
|
4465
|
+
"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.",
|
|
4466
|
+
"method.title": "\xBFC\xF3mo quieres entrar?",
|
|
4467
|
+
"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.",
|
|
4468
|
+
"method.browser": "Entrar con amoCRM",
|
|
4469
|
+
"method.browser.hint": "amoCRM crea una integraci\xF3n de WireCat en la cuenta, y amo renueva el acceso por s\xED mismo.",
|
|
4470
|
+
"method.token": "Con un token de larga duraci\xF3n",
|
|
4471
|
+
"method.token.hint": "Creas una integraci\xF3n privada y pegas aqu\xED su token.",
|
|
4472
|
+
"connect.title": "Permite el acceso en amoCRM",
|
|
4473
|
+
"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.",
|
|
4474
|
+
"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."
|
|
4723
4475
|
};
|
|
4724
4476
|
|
|
4725
4477
|
// dist/setup/texts.ru.json
|
|
@@ -4746,14 +4498,39 @@ var texts_ru_default = {
|
|
|
4746
4498
|
"done.title": "\u041F\u043E\u0434\u043A\u043B\u044E\u0447\u0435\u043D\u043E",
|
|
4747
4499
|
"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:",
|
|
4748
4500
|
"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",
|
|
4749
|
-
"done.oauth": "\
|
|
4501
|
+
"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:",
|
|
4502
|
+
"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?",
|
|
4503
|
+
"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.",
|
|
4504
|
+
"role.admin": "\u0414\u0430, \u044F \u0430\u0434\u043C\u0438\u043D\u0438\u0441\u0442\u0440\u0430\u0442\u043E\u0440",
|
|
4505
|
+
"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.",
|
|
4506
|
+
"role.member": "\u041D\u0435\u0442, \u044F \u0441\u043E\u0442\u0440\u0443\u0434\u043D\u0438\u043A",
|
|
4507
|
+
"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.",
|
|
4508
|
+
"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",
|
|
4509
|
+
"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.",
|
|
4510
|
+
"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.",
|
|
4511
|
+
"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.",
|
|
4512
|
+
"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.",
|
|
4513
|
+
"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.",
|
|
4514
|
+
"method.title": "\u041A\u0430\u043A \u0432\u043E\u0439\u0442\u0438?",
|
|
4515
|
+
"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.",
|
|
4516
|
+
"method.browser": "\u0412\u043E\u0439\u0442\u0438 \u0447\u0435\u0440\u0435\u0437 amoCRM",
|
|
4517
|
+
"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.",
|
|
4518
|
+
"method.token": "\u0414\u043E\u043B\u0433\u043E\u0441\u0440\u043E\u0447\u043D\u044B\u043C \u0442\u043E\u043A\u0435\u043D\u043E\u043C",
|
|
4519
|
+
"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.",
|
|
4520
|
+
"connect.title": "\u0420\u0430\u0437\u0440\u0435\u0448\u0438\u0442\u0435 \u0434\u043E\u0441\u0442\u0443\u043F \u0432 amoCRM",
|
|
4521
|
+
"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.",
|
|
4522
|
+
"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."
|
|
4750
4523
|
};
|
|
4751
4524
|
|
|
4752
4525
|
// dist/setup/flow.js
|
|
4753
|
-
var check2 = /* @__PURE__ */ __name(async ({ command, settings, secrets }) => {
|
|
4526
|
+
var check2 = /* @__PURE__ */ __name(async ({ command, settings, secrets, answers, steps }) => {
|
|
4754
4527
|
refuseCommandName(contextOf(command).profile, commandWords(rootOf(command)), IDENTITY.command);
|
|
4755
4528
|
refuseOffline(command, "the amoCRM account");
|
|
4756
4529
|
const origin = accountOrigin(String(settings.configured.host ?? ""));
|
|
4530
|
+
if (answers.method === "browser") {
|
|
4531
|
+
const { found } = await signInWithButton(command, origin, steps);
|
|
4532
|
+
return { ...found, keep: { account: `${found.account}:${found.user.id}` } };
|
|
4533
|
+
}
|
|
4757
4534
|
const typed = secrets.token?.trim();
|
|
4758
4535
|
if (typed) {
|
|
4759
4536
|
const { who: who2, signIn, account: account2 } = await checkedToken(command, origin, typed);
|
|
@@ -4771,6 +4548,9 @@ var check2 = /* @__PURE__ */ __name(async ({ command, settings, secrets }) => {
|
|
|
4771
4548
|
const who = await withAccount(command, accountUser);
|
|
4772
4549
|
return { ...who, keep: { account: `${who.account}:${who.user.id}` } };
|
|
4773
4550
|
}, "check");
|
|
4551
|
+
var MEMBER = { field: "role", is: "member" };
|
|
4552
|
+
var BROWSER = { field: "method", is: "browser" };
|
|
4553
|
+
var OWN_DEALS = "amo <profile> users list\namo <profile> config set crm.amocrm:example.amocrm.ru.unassigned 7001";
|
|
4774
4554
|
var OAUTH_COMMAND = "amo <profile> session start --host https://<subdomain>.amocrm.ru --client-id <integration ID>";
|
|
4775
4555
|
var amoSetup = defineSetup({
|
|
4776
4556
|
app: IDENTITY,
|
|
@@ -4792,7 +4572,66 @@ var amoSetup = defineSetup({
|
|
|
4792
4572
|
placeholder: "account.host.placeholder"
|
|
4793
4573
|
}
|
|
4794
4574
|
],
|
|
4795
|
-
next: "
|
|
4575
|
+
next: "role"
|
|
4576
|
+
},
|
|
4577
|
+
role: {
|
|
4578
|
+
title: "role.title",
|
|
4579
|
+
blocks: [
|
|
4580
|
+
{ type: "text", text: "role.intro" },
|
|
4581
|
+
{
|
|
4582
|
+
type: "choice",
|
|
4583
|
+
id: "role",
|
|
4584
|
+
optional: true,
|
|
4585
|
+
options: [
|
|
4586
|
+
{ value: "admin", label: "role.admin", hint: "role.admin.hint" },
|
|
4587
|
+
{ value: "member", label: "role.member", hint: "role.member.hint" }
|
|
4588
|
+
]
|
|
4589
|
+
}
|
|
4590
|
+
],
|
|
4591
|
+
next: [{ when: MEMBER, to: "ask-admin" }, { to: "method" }]
|
|
4592
|
+
},
|
|
4593
|
+
method: {
|
|
4594
|
+
title: "method.title",
|
|
4595
|
+
blocks: [
|
|
4596
|
+
{ type: "text", text: "method.intro" },
|
|
4597
|
+
{
|
|
4598
|
+
type: "choice",
|
|
4599
|
+
id: "method",
|
|
4600
|
+
optional: true,
|
|
4601
|
+
options: [
|
|
4602
|
+
{ value: "browser", label: "method.browser", hint: "method.browser.hint" },
|
|
4603
|
+
{ value: "token", label: "method.token", hint: "method.token.hint" }
|
|
4604
|
+
]
|
|
4605
|
+
}
|
|
4606
|
+
],
|
|
4607
|
+
next: [{ when: BROWSER, to: "connect" }, { to: "integration" }]
|
|
4608
|
+
},
|
|
4609
|
+
connect: {
|
|
4610
|
+
kind: "run",
|
|
4611
|
+
title: "connect.title",
|
|
4612
|
+
action: "apply",
|
|
4613
|
+
blocks: [
|
|
4614
|
+
{ type: "text", text: "connect.body" },
|
|
4615
|
+
{ type: "note", role: "warning", text: "connect.admin" }
|
|
4616
|
+
],
|
|
4617
|
+
next: [
|
|
4618
|
+
{ when: { result: "connect", is: "ok" }, to: "done" },
|
|
4619
|
+
{ when: { result: "connect", error: "conflict" }, to: "account" },
|
|
4620
|
+
{ when: { result: "connect", error: "authentication_error" }, to: "method" },
|
|
4621
|
+
{ when: { result: "connect", error: "validation_error" }, to: "method" },
|
|
4622
|
+
{ when: { result: "connect", error: "timeout" }, to: "method" },
|
|
4623
|
+
{ to: "failed" }
|
|
4624
|
+
],
|
|
4625
|
+
back: false
|
|
4626
|
+
},
|
|
4627
|
+
"ask-admin": {
|
|
4628
|
+
title: "ask.title",
|
|
4629
|
+
blocks: [
|
|
4630
|
+
{ type: "text", text: "ask.body" },
|
|
4631
|
+
{ type: "note", role: "warning", text: "ask.rights" },
|
|
4632
|
+
{ type: "text", text: "ask.later" }
|
|
4633
|
+
],
|
|
4634
|
+
next: "token"
|
|
4796
4635
|
},
|
|
4797
4636
|
integration: {
|
|
4798
4637
|
title: "integration.title",
|
|
@@ -4811,7 +4650,8 @@ var amoSetup = defineSetup({
|
|
|
4811
4650
|
token: {
|
|
4812
4651
|
title: "token.title",
|
|
4813
4652
|
blocks: [
|
|
4814
|
-
{ type: "text", text: "token.where" },
|
|
4653
|
+
{ type: "text", text: "token.where", when: { not: MEMBER } },
|
|
4654
|
+
{ type: "text", text: "token.member", when: MEMBER },
|
|
4815
4655
|
{ type: "input", id: "token", secret: "token", input: "password", label: "token.label", hint: "token.hint" },
|
|
4816
4656
|
{ type: "note", role: "tip", text: "token.rights" }
|
|
4817
4657
|
],
|
|
@@ -4841,10 +4681,13 @@ var amoSetup = defineSetup({
|
|
|
4841
4681
|
kind: "done",
|
|
4842
4682
|
title: "done.title",
|
|
4843
4683
|
blocks: [
|
|
4684
|
+
{ type: "text", text: "done.own", when: MEMBER },
|
|
4685
|
+
{ type: "code", code: OWN_DEALS, copy: true, when: MEMBER },
|
|
4844
4686
|
{ type: "text", text: "done.body" },
|
|
4845
4687
|
{ type: "code", code: "amo <profile> sync\namo <profile> deals list status:open", copy: true },
|
|
4846
4688
|
{
|
|
4847
4689
|
type: "group",
|
|
4690
|
+
when: { all: [{ not: MEMBER }, { not: BROWSER }] },
|
|
4848
4691
|
role: "details",
|
|
4849
4692
|
title: "done.oauth.title",
|
|
4850
4693
|
blocks: [
|
|
@@ -4864,7 +4707,7 @@ var update = appUpdate({
|
|
|
4864
4707
|
command: IDENTITY.command,
|
|
4865
4708
|
version: IDENTITY.version,
|
|
4866
4709
|
entry: new URL("../program.js", import.meta.url).href,
|
|
4867
|
-
statePath: /* @__PURE__ */ __name((env) =>
|
|
4710
|
+
statePath: /* @__PURE__ */ __name((env) => join4(resolvePaths({ appName: IDENTITY.appName, prefix: IDENTITY.envPrefix, env }).state, "update-check.json"), "statePath"),
|
|
4868
4711
|
// biome-ignore lint/plugin/no-own-settings: the update check runs before any command exists to give baseContext
|
|
4869
4712
|
enabled: /* @__PURE__ */ __name((env) => configuration.resolveSettings({}, { env, needsProfile: false }).updateCheck, "enabled"),
|
|
4870
4713
|
offVariables: [`${IDENTITY.envPrefix}_NO_UPDATE_CHECK`]
|
|
@@ -4915,7 +4758,6 @@ var definition = /* @__PURE__ */ __name(() => ({
|
|
|
4915
4758
|
commands: /* @__PURE__ */ __name(() => [
|
|
4916
4759
|
commandsCommand(IDENTITY),
|
|
4917
4760
|
sessionCommand(),
|
|
4918
|
-
accountCommand(),
|
|
4919
4761
|
...crmSharedCommands(),
|
|
4920
4762
|
apiCommand(),
|
|
4921
4763
|
scheduleCommand(),
|