@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,27 +1,23 @@
|
|
|
1
1
|
import { createRequire as __bundleRequire } from "node:module";
|
|
2
2
|
const require = __bundleRequire(import.meta.url);
|
|
3
3
|
import {
|
|
4
|
-
|
|
5
|
-
|
|
4
|
+
LIST_QUERY_GUIDE,
|
|
5
|
+
timeBounds
|
|
6
|
+
} from "./chunk-ABMPZL2P.js";
|
|
7
|
+
import {
|
|
6
8
|
MESSENGER_CHANGE_REFUSAL,
|
|
7
|
-
Option,
|
|
8
|
-
annotate,
|
|
9
|
-
annotateOption,
|
|
10
9
|
envName,
|
|
11
10
|
guardedWrite,
|
|
12
|
-
listOf,
|
|
13
11
|
progressLine,
|
|
14
12
|
progressOf,
|
|
15
13
|
readOnlyRefusal,
|
|
16
|
-
runBudget
|
|
17
|
-
|
|
18
|
-
} from "./chunk-PM77PRB6.js";
|
|
14
|
+
runBudget
|
|
15
|
+
} from "./chunk-NKYWQTS2.js";
|
|
19
16
|
import {
|
|
20
17
|
crmIdentityId,
|
|
21
18
|
crmSettingKey,
|
|
22
|
-
readMoment,
|
|
23
19
|
seenBy
|
|
24
|
-
} from "./chunk-
|
|
20
|
+
} from "./chunk-TEGQVVCZ.js";
|
|
25
21
|
import {
|
|
26
22
|
LOG_ATTRIBUTES,
|
|
27
23
|
accountsOfList,
|
|
@@ -35,10 +31,10 @@ import {
|
|
|
35
31
|
logAttributes,
|
|
36
32
|
sameAs,
|
|
37
33
|
sourceOf3 as sourceOf
|
|
38
|
-
} from "./chunk-
|
|
34
|
+
} from "./chunk-M33XHJTM.js";
|
|
39
35
|
import {
|
|
40
36
|
isCliFailure
|
|
41
|
-
} from "./chunk-
|
|
37
|
+
} from "./chunk-ELAKOEIO.js";
|
|
42
38
|
import {
|
|
43
39
|
CEILING_KEY,
|
|
44
40
|
DEFAULT_PERMISSIONS,
|
|
@@ -47,15 +43,16 @@ import {
|
|
|
47
43
|
levelFor,
|
|
48
44
|
skipFlagFor,
|
|
49
45
|
stops
|
|
50
|
-
} from "./chunk-
|
|
46
|
+
} from "./chunk-KBAOJISR.js";
|
|
51
47
|
import {
|
|
52
48
|
e164Of,
|
|
53
49
|
foldName
|
|
54
|
-
} from "./chunk-
|
|
50
|
+
} from "./chunk-SHOSFYI7.js";
|
|
55
51
|
import {
|
|
56
52
|
CRM_KINDS,
|
|
57
53
|
DEAL_KINDS,
|
|
58
54
|
INTERNAL_NOTES,
|
|
55
|
+
STAGE_OUTCOMES,
|
|
59
56
|
currencyOf,
|
|
60
57
|
holdsKindOf,
|
|
61
58
|
isCrmUserId,
|
|
@@ -66,706 +63,1245 @@ import {
|
|
|
66
63
|
minorUnits,
|
|
67
64
|
normalCrmUserId,
|
|
68
65
|
providerNamed
|
|
69
|
-
} from "./chunk-
|
|
66
|
+
} from "./chunk-S6DTLAOB.js";
|
|
70
67
|
import {
|
|
71
|
-
BACKENDS,
|
|
72
|
-
EVENT_QUERY,
|
|
73
|
-
MEETING_FIELDS,
|
|
74
|
-
MEETING_FIELD_KEYS,
|
|
75
|
-
MEETING_PROJECT_EVIDENCE_QUERY,
|
|
76
|
-
MEETING_QUERY,
|
|
77
|
-
MEETING_QUERY_GUIDE,
|
|
78
|
-
MeetingError,
|
|
79
|
-
OPERATORS_BY_TYPE,
|
|
80
|
-
QUERY_LIMITS,
|
|
81
|
-
SAVE_HELP,
|
|
82
|
-
SNAKE_CASE,
|
|
83
|
-
dateRange,
|
|
84
|
-
defineQuery,
|
|
85
|
-
eventItem,
|
|
86
|
-
exportMeeting,
|
|
87
|
-
fieldsHelp,
|
|
88
|
-
fieldsNamed,
|
|
89
|
-
importFiles,
|
|
90
|
-
listed,
|
|
91
|
-
markedPassage,
|
|
92
|
-
meetingDetailsBody,
|
|
93
|
-
meetingFieldFlag,
|
|
94
|
-
meetingHitsList,
|
|
95
|
-
meetingPeople,
|
|
96
|
-
meetingShowThrough,
|
|
97
|
-
meetingSummaryAnswer,
|
|
98
|
-
meetingTranscriptAnswer,
|
|
99
|
-
meetingsListThrough,
|
|
100
|
-
meetingsQuery,
|
|
101
68
|
parseLucene,
|
|
102
|
-
pull,
|
|
103
|
-
queryDescription,
|
|
104
|
-
queryError,
|
|
105
|
-
queryFieldsOf,
|
|
106
|
-
readMeetingProjectEvidence,
|
|
107
|
-
timezoneOf,
|
|
108
|
-
validateMeetingHitSearch,
|
|
109
|
-
validateMeetingPassage,
|
|
110
|
-
validateQuery,
|
|
111
69
|
walkQuery
|
|
112
|
-
} from "./chunk-
|
|
70
|
+
} from "./chunk-GMHRPX5M.js";
|
|
113
71
|
import {
|
|
114
72
|
backoffMs,
|
|
115
73
|
logRecordOf,
|
|
116
74
|
realSleep,
|
|
117
75
|
resolvePaths,
|
|
118
76
|
writeSecurely
|
|
119
|
-
} from "./chunk-
|
|
77
|
+
} from "./chunk-SCMB4LI6.js";
|
|
120
78
|
import {
|
|
121
|
-
|
|
122
|
-
|
|
79
|
+
array,
|
|
80
|
+
boolean,
|
|
81
|
+
function_,
|
|
82
|
+
getDotPath,
|
|
83
|
+
integer,
|
|
84
|
+
literal,
|
|
85
|
+
minLength,
|
|
86
|
+
minValue,
|
|
87
|
+
number,
|
|
123
88
|
optional,
|
|
89
|
+
picklist,
|
|
124
90
|
pipe,
|
|
125
|
-
|
|
126
|
-
|
|
91
|
+
record,
|
|
92
|
+
regex,
|
|
93
|
+
safeParse,
|
|
94
|
+
strictObject,
|
|
95
|
+
string,
|
|
96
|
+
union,
|
|
97
|
+
unknown
|
|
98
|
+
} from "./chunk-7OVTUADG.js";
|
|
127
99
|
import {
|
|
128
100
|
CliError,
|
|
129
101
|
isCliError
|
|
130
|
-
} from "./chunk-
|
|
102
|
+
} from "./chunk-AP3CWDRK.js";
|
|
131
103
|
import {
|
|
132
104
|
__export,
|
|
133
105
|
__name
|
|
134
106
|
} from "./chunk-ZVVMGPBJ.js";
|
|
135
107
|
|
|
136
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
137
|
-
var
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
...since === void 0 ? {} : { since: new Date(since).toISOString() },
|
|
153
|
-
...until === void 0 ? {} : { until: new Date(until).toISOString() }
|
|
154
|
-
};
|
|
155
|
-
return {
|
|
156
|
-
...since === void 0 ? {} : { since },
|
|
157
|
-
...until === void 0 ? {} : { until },
|
|
158
|
-
meta: {
|
|
159
|
-
...readInZone ? { timezone: timezoneOf(zone) } : {},
|
|
160
|
-
...since === void 0 && until === void 0 ? {} : { window }
|
|
161
|
-
}
|
|
162
|
-
};
|
|
163
|
-
}, "dateWindow");
|
|
108
|
+
// 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/values.js
|
|
109
|
+
var values_exports = {};
|
|
110
|
+
__export(values_exports, {
|
|
111
|
+
amountOf: () => amountOf,
|
|
112
|
+
crmValuesOf: () => crmValuesOf,
|
|
113
|
+
epoch: () => epoch,
|
|
114
|
+
fieldOf: () => fieldOf,
|
|
115
|
+
fullName: () => fullName,
|
|
116
|
+
id: () => id,
|
|
117
|
+
ids: () => ids,
|
|
118
|
+
isRaw: () => isRaw,
|
|
119
|
+
number: () => number2,
|
|
120
|
+
rawsOf: () => rawsOf,
|
|
121
|
+
text: () => text,
|
|
122
|
+
time: () => time
|
|
123
|
+
});
|
|
164
124
|
|
|
165
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
166
|
-
var
|
|
167
|
-
var REMOTE_WRITE = { remote: "write", local: "write" };
|
|
168
|
-
var minutes = /* @__PURE__ */ __name((text2) => {
|
|
169
|
-
if (!/^[1-9]\d*$/.test(text2))
|
|
170
|
-
throw new InvalidArgumentError("expected whole minutes");
|
|
171
|
-
return Number(text2);
|
|
172
|
-
}, "minutes");
|
|
173
|
-
var setting = /* @__PURE__ */ __name((text2, previous = []) => {
|
|
174
|
-
const at = text2.indexOf("=");
|
|
175
|
-
const name = text2.slice(0, at);
|
|
176
|
-
if (at < 1 || !SNAKE_CASE.test(name))
|
|
177
|
-
throw new InvalidArgumentError("expected name=value with a snake_case name, such as access_type=trusted");
|
|
178
|
-
return [...previous, [name, text2.slice(at + 1)]];
|
|
179
|
-
}, "setting");
|
|
180
|
-
var valuesOf = /* @__PURE__ */ __name((one) => one.type === "choice" ? one.values.join("|") : one.type === "boolean" ? "true|false" : "<text>", "valuesOf");
|
|
181
|
-
var changeOptions = /* @__PURE__ */ __name((command, declared, create) => {
|
|
182
|
-
const settings = declared.settings.length ? declared.settings.map((one) => `${one.name}=${valuesOf(one)}`).join(", ") : "this service has none";
|
|
183
|
-
const takes = declared.fields.map(meetingFieldFlag).join(", ") || "none of the options above";
|
|
184
|
-
const schedules = declared.fields.includes("startTime");
|
|
185
|
-
const start = !create ? "" : !schedules ? "; this service takes none, its meetings start now" : declared.fields.includes("kind") ? "; for a meeting that starts now, give --kind instant instead" : "";
|
|
186
|
-
return command.option("--title <title>", "the meeting's title").addOption(new Option("--kind <kind>", "an instant or a scheduled meeting").choices(["instant", "scheduled"])).option("--start-time <time>", `when it starts: an ISO time with its offset, 2026-11-20T10:00:00+01:00${start}`).option("--duration-minutes <minutes>", "how long it lasts, 1\u20131440", minutes).option("--timezone <zone>", "its IANA time zone, Europe/Madrid").option("--agenda <text>", "its agenda").option("--setting <name=value>", `a setting of this service; repeat it for more: ${settings}`, setting).addHelpText("after", [
|
|
187
|
-
"",
|
|
188
|
-
`This service takes ${takes}.`,
|
|
189
|
-
...declared.settings.length ? ["Its settings:", ...declared.settings.map((one) => ` ${one.name}=${valuesOf(one)} ${one.description}`)] : []
|
|
190
|
-
].join("\n"));
|
|
191
|
-
}, "changeOptions");
|
|
192
|
-
var changeOf = /* @__PURE__ */ __name((flags) => {
|
|
193
|
-
const change = Object.fromEntries(MEETING_FIELDS.flatMap((key) => flags[key] === void 0 ? [] : [[key, flags[key]]]));
|
|
194
|
-
if (!flags.setting)
|
|
195
|
-
return change;
|
|
196
|
-
const settings = /* @__PURE__ */ new Map();
|
|
197
|
-
for (const [name, value] of flags.setting) {
|
|
198
|
-
if (settings.has(name))
|
|
199
|
-
throw new CliError("validation_error", `--setting ${name} is given twice`);
|
|
200
|
-
settings.set(name, value);
|
|
201
|
-
}
|
|
202
|
-
return { ...change, settings: Object.fromEntries(settings) };
|
|
203
|
-
}, "changeOf");
|
|
204
|
-
var meetingOf = /* @__PURE__ */ __name((one) => ({
|
|
205
|
-
id: one.id,
|
|
206
|
-
title: one.title,
|
|
207
|
-
kind: one.kind,
|
|
208
|
-
start_time: one.startTime,
|
|
209
|
-
duration_minutes: one.durationMinutes,
|
|
210
|
-
timezone: one.timezone,
|
|
211
|
-
agenda: one.agenda,
|
|
212
|
-
join_url: one.joinUrl
|
|
213
|
-
}), "meetingOf");
|
|
214
|
-
var receiptItem = /* @__PURE__ */ __name((receipt) => {
|
|
215
|
-
const { change } = receipt;
|
|
216
|
-
return {
|
|
217
|
-
action: receipt.action,
|
|
218
|
-
provider: receipt.scope.provider,
|
|
219
|
-
account: receipt.scope.account,
|
|
220
|
-
...receipt.id === void 0 ? {} : { id: receipt.id },
|
|
221
|
-
...receipt.occurrenceId === void 0 ? {} : { occurrence_id: receipt.occurrenceId },
|
|
222
|
-
...change ? {
|
|
223
|
-
change: {
|
|
224
|
-
...Object.fromEntries(MEETING_FIELDS.flatMap((key) => change[key] === void 0 ? [] : [[MEETING_FIELD_KEYS[key], change[key]]])),
|
|
225
|
-
...change.settings === void 0 ? {} : { settings: { ...change.settings } }
|
|
226
|
-
}
|
|
227
|
-
} : {},
|
|
228
|
-
applied: receipt.applied,
|
|
229
|
-
...receipt.meeting ? { meeting: meetingOf(receipt.meeting), untrusted: ["meeting.title", "meeting.agenda", "meeting.join_url"] } : {}
|
|
230
|
-
};
|
|
231
|
-
}, "receiptItem");
|
|
232
|
-
var addMeetingManagementCommands = /* @__PURE__ */ __name((group, deps) => {
|
|
233
|
-
const { management, print, output, inRun, askFirst } = deps;
|
|
234
|
-
const signalled = /* @__PURE__ */ __name(() => {
|
|
235
|
-
const signal = deps.signal?.();
|
|
236
|
-
return signal ? { signal } : {};
|
|
237
|
-
}, "signalled");
|
|
238
|
-
const has = /* @__PURE__ */ __name((name) => management.capabilities.includes(name), "has");
|
|
239
|
-
const mutation = /* @__PURE__ */ __name((command) => ({
|
|
240
|
-
apply: true,
|
|
241
|
-
dryRun: command.optsWithGlobals().dryRun === true,
|
|
242
|
-
...signalled(),
|
|
243
|
-
confirm: /* @__PURE__ */ __name(async () => {
|
|
244
|
-
if (!askFirst)
|
|
245
|
-
throw new CliError("configuration_error", "this tool cannot ask before it changes a meeting on the service");
|
|
246
|
-
await askFirst(command);
|
|
247
|
-
}, "confirm")
|
|
248
|
-
}), "mutation");
|
|
249
|
-
const write = /* @__PURE__ */ __name((name) => annotate(group.command(name), { effects: REMOTE_WRITE, offline: false, output: { entity: "meeting_change" } }), "write");
|
|
250
|
-
const target = /* @__PURE__ */ __name((command) => command.argument("<meeting>", "the service's id of the meeting"), "target");
|
|
251
|
-
if (has("create"))
|
|
252
|
-
output(changeOptions(write("create").description("create a meeting on the service"), management.fields.create, true)).action(async (flags, command) => inRun(command, async () => print({ item: receiptItem(await management.create(changeOf(flags), mutation(command))) }, command)));
|
|
253
|
-
if (has("update"))
|
|
254
|
-
output(changeOptions(target(write("update").description("change a meeting on the service")), management.fields.update, false)).action(async (id2, flags, command) => inRun(command, async () => print({ item: receiptItem(await management.update(id2, changeOf(flags), mutation(command))) }, command)));
|
|
255
|
-
if (has("cancel"))
|
|
256
|
-
output(target(write("cancel").description("cancel a meeting on the service")).option("--occurrence-id <id>", "cancel only this occurrence of a repeating meeting")).action(async (id2, flags, command) => inRun(command, async () => print({
|
|
257
|
-
item: receiptItem(await management.cancel(id2, {
|
|
258
|
-
...mutation(command),
|
|
259
|
-
...flags.occurrenceId === void 0 ? {} : { occurrenceId: flags.occurrenceId }
|
|
260
|
-
}))
|
|
261
|
-
}, command)));
|
|
262
|
-
if (has("invitation"))
|
|
263
|
-
output(target(annotate(group.command("invitation"), {
|
|
264
|
-
effects: REMOTE_READ,
|
|
265
|
-
offline: false,
|
|
266
|
-
output: { entity: "meeting_invitation" }
|
|
267
|
-
}).description("the invitation text the service writes for a meeting"))).action(async (id2, _flags, command) => inRun(command, async () => print({ item: { ...await management.invitation(id2, signalled()), untrusted: ["invitation"] } }, command)));
|
|
268
|
-
}, "addMeetingManagementCommands");
|
|
125
|
+
// 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/source.js
|
|
126
|
+
var CRM_FILE_SOURCES = ["record", "field", "document", "activity", "comment"];
|
|
269
127
|
|
|
270
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
271
|
-
var
|
|
272
|
-
|
|
273
|
-
const
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
128
|
+
// 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/files.js
|
|
129
|
+
var parseCrmFileId = /* @__PURE__ */ __name((id2) => {
|
|
130
|
+
const [kind2 = "", owner = "", source = "", ...rest] = id2.trim().split(":");
|
|
131
|
+
const providerId = rest.join(":");
|
|
132
|
+
if (!CRM_KINDS.includes(kind2) || !/^[\w.-]+$/u.test(owner) || !CRM_FILE_SOURCES.includes(source) || !providerId)
|
|
133
|
+
throw new CliError("validation_error", "a file id is <owner kind>:<owner id>:<source>:<id>, as files list prints it, such as deal:12:record:345", { reason: "ref.malformed" });
|
|
134
|
+
return { owner: { kind: kind2, id: owner }, source, providerId };
|
|
135
|
+
}, "parseCrmFileId");
|
|
136
|
+
var foldKey = /* @__PURE__ */ __name((key) => key.replaceAll("_", "").toLowerCase(), "foldKey");
|
|
137
|
+
var DOWNLOAD_KEYS = new Set(["DOWNLOAD_URL", "downloadUrl", "fileUrl", "CALL_RECORD_URL", "archiveLink", "publicUrl"].map(foldKey));
|
|
138
|
+
var isDownloadKey = /* @__PURE__ */ __name((key) => DOWNLOAD_KEYS.has(foldKey(key)) || foldKey(key).endsWith("machine"), "isDownloadKey");
|
|
139
|
+
var WEBHOOK = /\/rest\/\d+\/[^/\s"'?#]+\//iu;
|
|
140
|
+
var PORTAL_PATH = /\/rest\/|show_file\.php/iu;
|
|
141
|
+
var TOKEN_QUERY = /(?:[?&]|&)(?:auth|token|access_token)=[^&#\s]/iu;
|
|
142
|
+
var CREDENTIAL = /(?:[?&]|&)(?:auth|access_token|api_token|x-amz-signature)=[^&#\s]/iu;
|
|
143
|
+
var isTokened = /* @__PURE__ */ __name((value) => WEBHOOK.test(value) || CREDENTIAL.test(value) || PORTAL_PATH.test(value) && TOKEN_QUERY.test(value), "isTokened");
|
|
144
|
+
var LINK_REMOVED = "[link removed]";
|
|
145
|
+
var withoutFileLinks = /* @__PURE__ */ __name((body) => {
|
|
146
|
+
const walk2 = /* @__PURE__ */ __name((value, key) => {
|
|
147
|
+
if (typeof value === "string")
|
|
148
|
+
return isTokened(value) ? LINK_REMOVED : value;
|
|
149
|
+
if (Array.isArray(value))
|
|
150
|
+
return value.map((one) => walk2(one));
|
|
151
|
+
if (value === null || typeof value !== "object")
|
|
152
|
+
return value;
|
|
153
|
+
return Object.fromEntries(Object.entries(value).map(([name, one]) => [
|
|
154
|
+
name,
|
|
155
|
+
(isDownloadKey(name) || key === "_links" && name === "download") && one !== null && one !== "" ? LINK_REMOVED : walk2(one, name)
|
|
156
|
+
]));
|
|
157
|
+
}, "walk");
|
|
158
|
+
return walk2(body);
|
|
159
|
+
}, "withoutFileLinks");
|
|
289
160
|
|
|
290
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
291
|
-
var
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
const
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
if (
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
const
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
161
|
+
// 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/values.js
|
|
162
|
+
var isRaw = /* @__PURE__ */ __name((value) => typeof value === "object" && value !== null && !Array.isArray(value), "isRaw");
|
|
163
|
+
var fieldOf = /* @__PURE__ */ __name((value, key) => isRaw(value) ? value[key] : void 0, "fieldOf");
|
|
164
|
+
var rawsOf = /* @__PURE__ */ __name((value) => Array.isArray(value) ? value.filter(isRaw) : [], "rawsOf");
|
|
165
|
+
var text = /* @__PURE__ */ __name((value) => {
|
|
166
|
+
if (typeof value !== "string" && typeof value !== "number")
|
|
167
|
+
return null;
|
|
168
|
+
const trimmed = String(value).trim();
|
|
169
|
+
return trimmed === "" ? null : trimmed;
|
|
170
|
+
}, "text");
|
|
171
|
+
var id = /* @__PURE__ */ __name((value) => {
|
|
172
|
+
const found = text(value);
|
|
173
|
+
return found === null || found === "0" ? null : found;
|
|
174
|
+
}, "id");
|
|
175
|
+
var ids = /* @__PURE__ */ __name((value) => Array.isArray(value) ? value.map(id).filter((one) => one !== null) : [], "ids");
|
|
176
|
+
var number2 = /* @__PURE__ */ __name((value) => {
|
|
177
|
+
if (value === null || value === void 0 || value === "")
|
|
178
|
+
return null;
|
|
179
|
+
const found = Number(value);
|
|
180
|
+
return Number.isFinite(found) ? found : null;
|
|
181
|
+
}, "number");
|
|
182
|
+
var time = /* @__PURE__ */ __name((value) => {
|
|
183
|
+
if (typeof value === "number") {
|
|
184
|
+
if (!Number.isFinite(value) || value <= 0)
|
|
185
|
+
return null;
|
|
186
|
+
return new Date(value > 1e11 ? value : value * 1e3).toISOString();
|
|
187
|
+
}
|
|
188
|
+
const found = text(value);
|
|
189
|
+
if (found === null)
|
|
190
|
+
return null;
|
|
191
|
+
const parsed = new Date(found);
|
|
192
|
+
return Number.isNaN(parsed.getTime()) ? null : parsed.toISOString();
|
|
193
|
+
}, "time");
|
|
194
|
+
var epoch = /* @__PURE__ */ __name((value) => {
|
|
195
|
+
const found = time(value);
|
|
196
|
+
return found === null ? null : Date.parse(found);
|
|
197
|
+
}, "epoch");
|
|
198
|
+
var amountOf = /* @__PURE__ */ __name((value, currency) => {
|
|
199
|
+
const found = number2(value);
|
|
200
|
+
const code = text(currency)?.toUpperCase() ?? null;
|
|
201
|
+
if (found === null || found <= 0 || code === null)
|
|
202
|
+
return { amount: null, currency: null };
|
|
203
|
+
return { amount: typeof value === "string" ? value.trim() : String(found), currency: code };
|
|
204
|
+
}, "amountOf");
|
|
205
|
+
var fullName = /* @__PURE__ */ __name((...parts) => parts.map(text).filter((part) => part !== null).join(" ") || null, "fullName");
|
|
206
|
+
var optionLabel = /* @__PURE__ */ __name((field, option) => field.options?.find(({ id: id2 }) => id2 === String(option))?.label ?? String(option), "optionLabel");
|
|
207
|
+
var crmValuesOf = /* @__PURE__ */ __name((values, fields2) => {
|
|
208
|
+
const byCode = new Map(fields2.map((field) => [field.code, field]));
|
|
209
|
+
return Object.fromEntries(Object.entries(values).map(([code, value]) => {
|
|
210
|
+
const field = byCode.get(code);
|
|
211
|
+
const label = field?.label ?? null;
|
|
212
|
+
if (!field?.options)
|
|
213
|
+
return [code, { label, value: withoutFileLinks(value) }];
|
|
214
|
+
if (Array.isArray(value))
|
|
215
|
+
return [code, { label, value: value.map((one) => optionLabel(field, one)), option_id: value.map(String) }];
|
|
216
|
+
return [code, { label, value: optionLabel(field, value), option_id: String(value) }];
|
|
217
|
+
}));
|
|
218
|
+
}, "crmValuesOf");
|
|
331
219
|
|
|
332
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
333
|
-
|
|
334
|
-
if (!/^[1-9]\d*$/.test(value) || !Number.isSafeInteger(Number(value)))
|
|
335
|
-
throw new CliError("validation_error", "expected a positive safe integer");
|
|
336
|
-
return Number(value);
|
|
337
|
-
}, "integer");
|
|
338
|
-
var addMeetingProjectEvidenceCommandDefinition = /* @__PURE__ */ __name((program, deps) => {
|
|
339
|
-
const group = program.commands.find((command) => command.name() === "meetings");
|
|
340
|
-
if (!group)
|
|
341
|
-
throw new CliError("configuration_error", "meeting command group is unavailable");
|
|
342
|
-
const projects = group.commands.find((command) => command.name() === "projects") ?? group.command("projects").description("project-name evidence in stored meetings");
|
|
343
|
-
return annotate(queryWordsAfterOptions(projects.command("evidence").description("find cited project-name and alias evidence in the local meeting index; does not refresh it or confirm membership")).argument("<project>", "existing project name, key or explicit alias").argument("[query...]", "exact ID fields and a UTC started_at range, joined by AND").addHelpText("after", `
|
|
344
|
-
${fieldsHelp(MEETING_PROJECT_EVIDENCE_QUERY)}`).option("--limit <n>", "hits in one name page, 1 through 1000 (default 100)", integer).option("--cursor <cursor>", "continue with the same project and frozen selection from next").option("--max-read-bytes <bytes>", "word-read byte budget, at most 67108864 (default 4194304)", integer).action(async (project, words, options) => {
|
|
345
|
-
deps.output(await readMeetingProjectEvidence(deps.read, project, { ...options, query: words.join(" "), signal: deps.signal() }, deps.now?.()));
|
|
346
|
-
}), {
|
|
347
|
-
origin: "handwritten",
|
|
348
|
-
effects: { remote: "none", local: "read" },
|
|
349
|
-
query: MEETING_PROJECT_EVIDENCE_QUERY,
|
|
350
|
-
output: { entity: "meeting_project_evidence" }
|
|
351
|
-
});
|
|
352
|
-
}, "addMeetingProjectEvidenceCommandDefinition");
|
|
353
|
-
var addMeetingProjectEvidenceCommand = sharedCommand(addMeetingProjectEvidenceCommandDefinition);
|
|
220
|
+
// 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/bot/api-input.js
|
|
221
|
+
import { readFileSync } from "node:fs";
|
|
354
222
|
|
|
355
|
-
// node_modules/.pnpm/@wirecat+cli-
|
|
356
|
-
var
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
tag: options.tag,
|
|
391
|
-
topic: options.topicName ?? options.topic,
|
|
392
|
-
since: options.sinceTime,
|
|
393
|
-
until: options.untilTime,
|
|
394
|
-
limit: options.limit ?? limit,
|
|
395
|
-
after: options.cursor,
|
|
396
|
-
maxReadBytes: options.maxReadBytes,
|
|
397
|
-
signal
|
|
398
|
-
};
|
|
399
|
-
validateMeetingHitSearch(query, request);
|
|
400
|
-
signal?.throwIfAborted();
|
|
401
|
-
return request;
|
|
402
|
-
}, "meetingHitSearchRequest");
|
|
403
|
-
var meetingSearchArguments = /* @__PURE__ */ __name((query, options) => Object.fromEntries(Object.entries({
|
|
404
|
-
query,
|
|
405
|
-
meeting_id: options.meetingId?.toString(),
|
|
406
|
-
identity_id: options.identityId?.toString(),
|
|
407
|
-
person_id: options.personId?.toString(),
|
|
408
|
-
event_id: options.eventId?.toString(),
|
|
409
|
-
series_id: options.seriesId?.toString(),
|
|
410
|
-
project: options.project,
|
|
411
|
-
tag: options.tag,
|
|
412
|
-
topic_name: options.topicName ?? options.topic,
|
|
413
|
-
since_time: options.sinceTime === void 0 ? void 0 : new Date(options.sinceTime).toISOString(),
|
|
414
|
-
until_time: options.untilTime === void 0 ? void 0 : new Date(options.untilTime).toISOString(),
|
|
415
|
-
max_read_bytes: options.maxReadBytes ?? 4194304
|
|
416
|
-
}).filter(([, value]) => value !== void 0)), "meetingSearchArguments");
|
|
417
|
-
var meetingSearchMeta = /* @__PURE__ */ __name((options) => {
|
|
418
|
-
const window = {
|
|
419
|
-
...options.sinceTime === void 0 ? {} : { since: new Date(options.sinceTime).toISOString() },
|
|
420
|
-
...options.untilTime === void 0 ? {} : { until: new Date(options.untilTime).toISOString() }
|
|
421
|
-
};
|
|
422
|
-
return {
|
|
423
|
-
...options.timesReadIn === void 0 ? {} : { timezone: options.timesReadIn },
|
|
424
|
-
...Object.keys(window).length === 0 ? {} : { window }
|
|
425
|
-
};
|
|
426
|
-
}, "meetingSearchMeta");
|
|
427
|
-
var addMeetingSearchCommandDefinition = /* @__PURE__ */ __name((program, deps) => createMeetingSearchCommand(program).action(async (query, options, command) => {
|
|
428
|
-
const request = meetingHitSearchRequest(query, options, deps.pagingOf(command).limit, deps.signal());
|
|
429
|
-
deps.output(meetingHitsList(await deps.search(query, request, options), request.limit, "search meetings", meetingSearchArguments(query, options), meetingSearchMeta(options)));
|
|
430
|
-
}), "addMeetingSearchCommandDefinition");
|
|
431
|
-
var createMeetingSearchCommand = sharedCommand(createMeetingSearchCommandDefinition);
|
|
432
|
-
var addMeetingSearchCommand = sharedCommand(addMeetingSearchCommandDefinition);
|
|
223
|
+
// node_modules/.pnpm/@wirecat+cli-base@0.127.0_commander@15.0.0_esbuild@0.28.2_typescript@7.0.2_vitest@5.0.5/node_modules/@wirecat/cli-base/dist/codegen/names.js
|
|
224
|
+
var pascal = /* @__PURE__ */ __name((text2) => text2.split(/[^A-Za-z0-9]+/).filter(Boolean).map((word) => word[0]?.toUpperCase() + word.slice(1)).join(""), "pascal");
|
|
225
|
+
var GLOBALS = /* @__PURE__ */ new Set([
|
|
226
|
+
"Array",
|
|
227
|
+
"BigInt",
|
|
228
|
+
"Boolean",
|
|
229
|
+
"Date",
|
|
230
|
+
"Error",
|
|
231
|
+
"Function",
|
|
232
|
+
"Intl",
|
|
233
|
+
"JSON",
|
|
234
|
+
"Map",
|
|
235
|
+
"Math",
|
|
236
|
+
"Number",
|
|
237
|
+
"Object",
|
|
238
|
+
"Partial",
|
|
239
|
+
"Promise",
|
|
240
|
+
"Proxy",
|
|
241
|
+
"Record",
|
|
242
|
+
"Reflect",
|
|
243
|
+
"RegExp",
|
|
244
|
+
"Required",
|
|
245
|
+
"Set",
|
|
246
|
+
"String",
|
|
247
|
+
"Symbol",
|
|
248
|
+
"URL",
|
|
249
|
+
"WeakMap",
|
|
250
|
+
"WeakSet"
|
|
251
|
+
]);
|
|
252
|
+
var identifier = /* @__PURE__ */ __name((id2) => {
|
|
253
|
+
const name = pascal(id2);
|
|
254
|
+
if (!/^[A-Za-z]/.test(name))
|
|
255
|
+
return `Schema${name}`;
|
|
256
|
+
return GLOBALS.has(name) ? `Api${name}` : name;
|
|
257
|
+
}, "identifier");
|
|
433
258
|
|
|
434
|
-
// node_modules/.pnpm/@wirecat+cli-
|
|
435
|
-
var
|
|
436
|
-
var
|
|
437
|
-
if (
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
}, "integer");
|
|
441
|
-
var lookbackDays = /* @__PURE__ */ __name((text2) => {
|
|
442
|
-
if (!/^(0|[1-9]\d*)$/.test(text2) || Number(text2) > 31)
|
|
443
|
-
throw new InvalidArgumentError("expected an integer from 0 through 31 days");
|
|
444
|
-
return Number(text2);
|
|
445
|
-
}, "lookbackDays");
|
|
446
|
-
var LOCAL_READ = { remote: "none", local: "read" };
|
|
447
|
-
var REMOTE_READ2 = { remote: "read", local: "read" };
|
|
448
|
-
var backendOf = /* @__PURE__ */ __name((value) => {
|
|
449
|
-
if (!BACKENDS.includes(value))
|
|
450
|
-
throw new InvalidArgumentError("expected archive, server or both");
|
|
451
|
-
return value;
|
|
452
|
-
}, "backendOf");
|
|
453
|
-
var backendOption = /* @__PURE__ */ __name((command) => command.option("--backend <archive|server|both>", "where to read: the store (archive), the service (server), or both, kept in the store (default: both)", backendOf), "backendOption");
|
|
454
|
-
var BACKEND_HELP = "--backend both asks the service with the part of the query it can filter, keeps what it returns, then runs the whole query over the store; each item says found_in archive, server or both. --offline reads the store only.";
|
|
455
|
-
var LOCAL_WRITE = { remote: "none", local: "write" };
|
|
456
|
-
var FETCH = { remote: "read", local: "write" };
|
|
457
|
-
var addMeetingCommandsDefinition = /* @__PURE__ */ __name((program, deps) => {
|
|
458
|
-
const group = annotate(program.command("meetings").description("stored meetings and their records"), {
|
|
459
|
-
effects: { remote: "none", local: "none" }
|
|
460
|
-
});
|
|
461
|
-
const output = /* @__PURE__ */ __name((command) => command, "output");
|
|
462
|
-
const print = /* @__PURE__ */ __name((value, command) => {
|
|
463
|
-
const opts = command.optsWithGlobals();
|
|
464
|
-
deps.write(value, opts.json ? "json" : opts.jsonl ? "jsonl" : "text", command);
|
|
465
|
-
}, "print");
|
|
466
|
-
const access = /* @__PURE__ */ __name((command, backend) => {
|
|
467
|
-
const signal = deps.signal?.();
|
|
259
|
+
// node_modules/.pnpm/@wirecat+cli-base@0.127.0_commander@15.0.0_esbuild@0.28.2_typescript@7.0.2_vitest@5.0.5/node_modules/@wirecat/cli-base/dist/codegen/sign-in.js
|
|
260
|
+
var BEARER = { in: "header", name: "authorization", value: /* @__PURE__ */ __name((token) => `Bearer ${token}`, "value") };
|
|
261
|
+
var signInPlace = /* @__PURE__ */ __name((scheme) => {
|
|
262
|
+
if (scheme.type === "apiKey") {
|
|
263
|
+
if (!scheme.name || scheme.in !== "header" && scheme.in !== "query")
|
|
264
|
+
return void 0;
|
|
468
265
|
return {
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
...deps.now ? { now: deps.now() } : {},
|
|
473
|
-
...signal ? { signal } : {}
|
|
266
|
+
in: scheme.in,
|
|
267
|
+
name: scheme.in === "header" ? scheme.name.toLowerCase() : scheme.name,
|
|
268
|
+
value: /* @__PURE__ */ __name((token) => token, "value")
|
|
474
269
|
};
|
|
475
|
-
}
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
});
|
|
497
|
-
});
|
|
498
|
-
backendOption(output(annotate(group.command("show"), { effects: REMOTE_READ2, partial: true, output: { entity: "meeting_details" } }).description("show a meeting, read again from the service with its people, transcript and documents").argument("<meeting>", "the stored meeting's number, its meeting: ref, or the service's id (provider_id)").addHelpText("after", `${SAVE_HELP}
|
|
499
|
-
${BACKEND_HELP}`))).action(async (meeting, opts, command) => {
|
|
500
|
-
await deps.inRun(command, async () => {
|
|
501
|
-
const shown = await meetingShowThrough(deps.source, deps.store, deps.accountId, meeting, access(command, opts.backend));
|
|
502
|
-
const { item } = await meetingDetailsBody(deps.store, shown.details);
|
|
503
|
-
print({
|
|
504
|
-
item: shown.foundIn ? { ...item, found_in: shown.foundIn } : item,
|
|
505
|
-
...shown.missing ? { missing: shown.missing } : {},
|
|
506
|
-
...shown.meta ? { meta: shown.meta } : {}
|
|
507
|
-
}, command);
|
|
508
|
-
});
|
|
509
|
-
});
|
|
510
|
-
output(annotate(group.command("transcript"), { effects: LOCAL_READ, output: { entity: "meeting_transcript" } }).description("show current meeting transcripts").argument("<meeting>", "stored meeting id", integer3).option("--history", "include superseded transcript versions").addHelpText("after", SAVE_HELP)).action(async (id2, opts, command) => {
|
|
511
|
-
print(await meetingTranscriptAnswer(deps.store, id2, deps.accountId, { history: opts.history }), command);
|
|
512
|
-
});
|
|
513
|
-
output(annotate(group.command("summary"), { effects: LOCAL_READ, output: { entity: "meeting_summary" } }).description("show stored meeting summaries").argument("<meeting>", "stored meeting id", integer3)).action(async (id2, _opts, command) => {
|
|
514
|
-
print(await meetingSummaryAnswer(deps.store, id2, deps.accountId), command);
|
|
515
|
-
});
|
|
516
|
-
const exporter = output(annotate(group.command("export"), { effects: LOCAL_WRITE, output: { entity: "meeting_export" } }).description("export a meeting as Markdown or one transcript as WebVTT").argument("<meeting>", "stored meeting id", integer3).addOption(new Option("--format <format>", "export format").choices(["markdown", "vtt"]).default("markdown")).option("--transcript-id <id>", "export a specific transcript version", integer3).addOption(
|
|
517
|
-
// Not over MCP: an agent would choose where on the owner's disk to write; it gets the content in the answer.
|
|
518
|
-
annotateOption(new Option("--output <file>", "write content to a new file through the host's writer"), {
|
|
519
|
-
mcp: false
|
|
520
|
-
})
|
|
521
|
-
));
|
|
522
|
-
deps.newFileOutput?.(exporter, "output");
|
|
523
|
-
exporter.action(async (id2, opts, command) => {
|
|
524
|
-
if (opts.output !== void 0 && !opts.output.trim())
|
|
525
|
-
throw new MeetingError("validation_error", "output path must not be empty");
|
|
526
|
-
if (opts.output !== void 0 && !deps.writeFile)
|
|
527
|
-
throw new MeetingError("configuration_error", "the host has no export file writer");
|
|
528
|
-
const result = await exportMeeting(deps.store, id2, {
|
|
529
|
-
accountId: deps.accountId,
|
|
530
|
-
format: opts.format,
|
|
531
|
-
transcriptId: opts.transcriptId
|
|
532
|
-
});
|
|
533
|
-
if (opts.output !== void 0) {
|
|
534
|
-
await deps.writeFile?.(opts.output, result.content);
|
|
535
|
-
print({ meetingId: result.meetingId, format: result.format, output: opts.output }, command);
|
|
536
|
-
} else
|
|
537
|
-
print(result, command);
|
|
538
|
-
});
|
|
539
|
-
output(annotate(group.command("people"), { effects: LOCAL_READ, output: { entity: "meeting_participants" } }).description("find meeting participants by name or email").argument("<query>", "a name or an email address")).option("--limit <n>", "most matching observations per page, 1\u20131000 (default 50)", integer3).option("--scan-limit <n>", "most participant observations to inspect, 1\u201310000 (default 1000)", integer3).option("--max-read-bytes <bytes>", "most stored name and email bytes to read (default 1048576)", integer3).option("--cursor <cursor>", "continue with the same name query and selected account").action(async (query, opts, command) => {
|
|
540
|
-
const found = await meetingPeople(deps.store, query, deps.accountId, {
|
|
541
|
-
limit: opts.limit,
|
|
542
|
-
scanLimit: opts.scanLimit,
|
|
543
|
-
maxReadBytes: opts.maxReadBytes,
|
|
544
|
-
cursor: opts.cursor
|
|
545
|
-
});
|
|
546
|
-
print(found, command);
|
|
547
|
-
});
|
|
548
|
-
output(annotate(group.command("sync"), {
|
|
549
|
-
effects: FETCH,
|
|
550
|
-
offline: false,
|
|
551
|
-
output: { entity: "meeting_ingestion" },
|
|
552
|
-
// Only a sync that stops itself at its budget may outlive the one-shot deadline.
|
|
553
|
-
...deps.budgetOf ? { cooperative: true, partial: true } : {}
|
|
554
|
-
}).description("bring the stored meetings up to date from the connected account, oldest first; a run that stops before its deadline keeps what it saved and the next one goes on from there")).option("--since-time <time>", "fetch meetings starting at or after this ISO 8601 date or time, or 30m, 2h, 7d ago", (text2) => dateWindow({ sinceTime: text2, ...deps.timezone ? { zone: deps.timezone } : {}, now: deps.now?.() }).since).option("--lookback-days <days>", "revisit recent occurrences for late transcripts (0\u201331)", lookbackDays).option("--rescan", "read the last 30 days again, not only what came after the last sync").action(async (opts, command) => {
|
|
555
|
-
const source = deps.source;
|
|
556
|
-
if (!source)
|
|
557
|
-
throw new MeetingError("configuration_error", "meeting source is unavailable");
|
|
558
|
-
await deps.inRun(command, async () => print(await pull(source, deps.store, {
|
|
559
|
-
accountId: deps.accountId,
|
|
560
|
-
since: opts.sinceTime === void 0 ? void 0 : new Date(opts.sinceTime).toISOString(),
|
|
561
|
-
now: deps.now?.(),
|
|
562
|
-
...opts.lookbackDays === void 0 ? {} : { lookbackMs: opts.lookbackDays * 864e5 },
|
|
563
|
-
...opts.rescan ? { rescan: true } : {},
|
|
564
|
-
...deps.budgetOf ? { budget: deps.budgetOf(command) } : {}
|
|
565
|
-
}), command));
|
|
566
|
-
});
|
|
567
|
-
const importCommand = annotate(group.command("import"), {
|
|
568
|
-
effects: LOCAL_WRITE,
|
|
569
|
-
output: { entity: "meeting_ingestion" }
|
|
570
|
-
}).description("import downloaded meeting transcripts").argument("<folder>", "folder of transcripts downloaded from the provider");
|
|
571
|
-
if (deps.importHelp)
|
|
572
|
-
importCommand.addHelpText("after", `
|
|
573
|
-
${deps.importHelp}`);
|
|
574
|
-
output(importCommand).action(async (folder, _opts, command) => {
|
|
575
|
-
if (!deps.readFiles)
|
|
576
|
-
throw new MeetingError("configuration_error", "file reader is unavailable");
|
|
577
|
-
const files = await deps.readFiles(folder);
|
|
578
|
-
if (files.some((file) => file.meeting.accountId !== deps.accountId))
|
|
579
|
-
throw new MeetingError("validation_error", "file account differs from selected account");
|
|
580
|
-
print(await importFiles(files, deps.store, deps.now?.()), command);
|
|
581
|
-
});
|
|
582
|
-
output(annotate(group.command("repair"), {
|
|
583
|
-
effects: LOCAL_WRITE,
|
|
584
|
-
output: { entity: "meeting_repair" }
|
|
585
|
-
}).description("preview filling in what older builds left out of stored transcripts (their language); --yes stores it")).option("--yes", "store the detected languages; otherwise only preview").action(async (opts, command) => {
|
|
586
|
-
if (!deps.store.fillTranscriptLanguages)
|
|
587
|
-
throw new MeetingError("configuration_error", "this store cannot fill transcript languages");
|
|
588
|
-
print(await deps.store.fillTranscriptLanguages({
|
|
589
|
-
accountId: deps.accountId,
|
|
590
|
-
apply: opts.yes === true,
|
|
591
|
-
now: deps.now?.() ?? Date.now()
|
|
592
|
-
}), command);
|
|
593
|
-
});
|
|
594
|
-
if (deps.management)
|
|
595
|
-
addMeetingManagementCommands(group, {
|
|
596
|
-
management: deps.management,
|
|
597
|
-
print,
|
|
598
|
-
output,
|
|
599
|
-
inRun: deps.inRun,
|
|
600
|
-
...deps.askFirst ? { askFirst: deps.askFirst } : {},
|
|
601
|
-
...deps.signal ? { signal: deps.signal } : {}
|
|
602
|
-
});
|
|
603
|
-
const eventList = queryWordsAfterOptions(annotate(program.command("events").description("the owner's stored events"), {
|
|
604
|
-
effects: { remote: "none", local: "none" }
|
|
605
|
-
}).command("list")).description("list stored events").argument("[query...]", "event id, origin or time fields that narrow the list").addHelpText("after", `
|
|
606
|
-
${fieldsHelp(EVENT_QUERY, MEETING_QUERY_GUIDE)}`);
|
|
607
|
-
annotate(eventList, { effects: LOCAL_READ, output: { entity: "event" }, query: EVENT_QUERY });
|
|
608
|
-
output(eventList).action(async (words, _opts, command) => {
|
|
609
|
-
const query = words.length ? parseLucene(words.join(" "), { defaultField: "none", command: "events list" }) : void 0;
|
|
610
|
-
if (query)
|
|
611
|
-
validateQuery(query, EVENT_QUERY, { command: "events list" });
|
|
612
|
-
if (query && !deps.store.queryEvents)
|
|
613
|
-
throw new MeetingError("validation_error", "this store cannot filter events");
|
|
614
|
-
const events = query ? await deps.store.queryEvents?.(query) : await deps.store.events();
|
|
615
|
-
print(listed((events ?? []).map((one) => ({ ...eventItem(one), untrusted: [...EVENT_UNTRUSTED] }))), command);
|
|
616
|
-
});
|
|
617
|
-
}, "addMeetingCommandsDefinition");
|
|
618
|
-
var addMeetingCommands = sharedCommand(addMeetingCommandsDefinition);
|
|
270
|
+
}
|
|
271
|
+
if (scheme.type === "http") {
|
|
272
|
+
if (!scheme.scheme || /^bearer$/i.test(scheme.scheme))
|
|
273
|
+
return BEARER;
|
|
274
|
+
if (/^basic$/i.test(scheme.scheme))
|
|
275
|
+
return {
|
|
276
|
+
in: "header",
|
|
277
|
+
name: "authorization",
|
|
278
|
+
value: /* @__PURE__ */ __name((token) => `Basic ${Buffer.from(token).toString("base64")}`, "value"),
|
|
279
|
+
basic: true
|
|
280
|
+
};
|
|
281
|
+
if (/^digest$/i.test(scheme.scheme))
|
|
282
|
+
return void 0;
|
|
283
|
+
return { in: "header", name: "authorization", value: /* @__PURE__ */ __name((token) => `${scheme.scheme} ${token}`, "value") };
|
|
284
|
+
}
|
|
285
|
+
return scheme.type === "oauth2" || scheme.type === "openIdConnect" ? BEARER : void 0;
|
|
286
|
+
}, "signInPlace");
|
|
287
|
+
var signInRequirements = /* @__PURE__ */ __name((operation, document) => {
|
|
288
|
+
const requirements = operation.security ?? document;
|
|
289
|
+
return requirements?.some((one) => Object.keys(one).length > 0) ? requirements : void 0;
|
|
290
|
+
}, "signInRequirements");
|
|
619
291
|
|
|
620
|
-
// node_modules/.pnpm/@wirecat+cli-
|
|
621
|
-
var
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
const
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
const
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
292
|
+
// node_modules/.pnpm/@wirecat+cli-base@0.127.0_commander@15.0.0_esbuild@0.28.2_typescript@7.0.2_vitest@5.0.5/node_modules/@wirecat/cli-base/dist/codegen/graphql.js
|
|
293
|
+
var graphqlDocument = /* @__PURE__ */ __name((binding, selection = binding.selection) => {
|
|
294
|
+
const variables = Object.entries(binding.variables);
|
|
295
|
+
const declared = variables.length ? `(${variables.map(([name, type]) => `$${name}: ${type}`).join(", ")})` : "";
|
|
296
|
+
const passed = variables.length ? `(${variables.map(([name]) => `${name}: $${name}`).join(", ")})` : "";
|
|
297
|
+
const inner = selection.trim() ? ` { ${selection.trim()} }` : "";
|
|
298
|
+
return `${binding.operation} ${binding.field[0]?.toUpperCase()}${binding.field.slice(1)}${declared} { ${binding.field}${passed}${inner} }`;
|
|
299
|
+
}, "graphqlDocument");
|
|
300
|
+
|
|
301
|
+
// node_modules/.pnpm/@wirecat+cli-base@0.127.0_commander@15.0.0_esbuild@0.28.2_typescript@7.0.2_vitest@5.0.5/node_modules/@wirecat/cli-base/dist/codegen/runtime.js
|
|
302
|
+
var INT64_MIN = -(2n ** 63n);
|
|
303
|
+
var INT64_MAX = 2n ** 63n - 1n;
|
|
304
|
+
|
|
305
|
+
// node_modules/.pnpm/@wirecat+cli-base@0.127.0_commander@15.0.0_esbuild@0.28.2_typescript@7.0.2_vitest@5.0.5/node_modules/@wirecat/cli-base/dist/codegen/openapi.js
|
|
306
|
+
var IGNORED = /* @__PURE__ */ new Set([
|
|
307
|
+
"readOnly",
|
|
308
|
+
"example",
|
|
309
|
+
"examples",
|
|
310
|
+
"externalDocs",
|
|
311
|
+
"title",
|
|
312
|
+
"xml",
|
|
313
|
+
"writeOnly",
|
|
314
|
+
"not",
|
|
315
|
+
"minProperties",
|
|
316
|
+
"maxProperties"
|
|
317
|
+
]);
|
|
318
|
+
var KNOWN = /* @__PURE__ */ new Set([
|
|
319
|
+
...IGNORED,
|
|
320
|
+
"type",
|
|
321
|
+
"format",
|
|
322
|
+
"description",
|
|
323
|
+
"nullable",
|
|
324
|
+
"deprecated",
|
|
325
|
+
"default",
|
|
326
|
+
"enum",
|
|
327
|
+
"const",
|
|
328
|
+
"minLength",
|
|
329
|
+
"maxLength",
|
|
330
|
+
"pattern",
|
|
331
|
+
"minimum",
|
|
332
|
+
"maximum",
|
|
333
|
+
"items",
|
|
334
|
+
"prefixItems",
|
|
335
|
+
"minItems",
|
|
336
|
+
"maxItems",
|
|
337
|
+
"uniqueItems",
|
|
338
|
+
"properties",
|
|
339
|
+
"required",
|
|
340
|
+
"additionalProperties",
|
|
341
|
+
"allOf",
|
|
342
|
+
"oneOf",
|
|
343
|
+
"anyOf",
|
|
344
|
+
"$ref",
|
|
345
|
+
"discriminator"
|
|
346
|
+
]);
|
|
347
|
+
var LARGEST_EXAMPLE = 8 * 1024;
|
|
348
|
+
|
|
349
|
+
// node_modules/.pnpm/lossless-json@4.3.3/node_modules/lossless-json/lib/esm/utils.js
|
|
350
|
+
function isInteger(value) {
|
|
351
|
+
return INTEGER_REGEX.test(value);
|
|
352
|
+
}
|
|
353
|
+
__name(isInteger, "isInteger");
|
|
354
|
+
var INTEGER_REGEX = /^-?[0-9]+$/;
|
|
355
|
+
function isNumber(value) {
|
|
356
|
+
return NUMBER_REGEX.test(value);
|
|
357
|
+
}
|
|
358
|
+
__name(isNumber, "isNumber");
|
|
359
|
+
var NUMBER_REGEX = /^-?(?:0|[1-9]\d*)(?:\.\d+)?(?:[eE][+-]?\d+)?$/;
|
|
360
|
+
function isSafeNumber(value, config2) {
|
|
361
|
+
if (isInteger(value)) {
|
|
362
|
+
return Number.isSafeInteger(Number.parseInt(value, 10));
|
|
363
|
+
}
|
|
364
|
+
const num = Number.parseFloat(value);
|
|
365
|
+
if (Number.isInteger(num) && !Number.isSafeInteger(num)) {
|
|
366
|
+
return false;
|
|
367
|
+
}
|
|
368
|
+
const parsed = String(num);
|
|
369
|
+
if (value === parsed) {
|
|
370
|
+
return true;
|
|
371
|
+
}
|
|
372
|
+
const valueDigits = extractSignificantDigits(value);
|
|
373
|
+
const parsedDigits = extractSignificantDigits(parsed);
|
|
374
|
+
if (valueDigits === parsedDigits) {
|
|
375
|
+
return true;
|
|
376
|
+
}
|
|
377
|
+
if (config2?.approx === true) {
|
|
378
|
+
const requiredDigits = 14;
|
|
379
|
+
if (parsedDigits.length >= requiredDigits && valueDigits.startsWith(parsedDigits.substring(0, requiredDigits))) {
|
|
380
|
+
return true;
|
|
381
|
+
}
|
|
382
|
+
}
|
|
383
|
+
return false;
|
|
384
|
+
}
|
|
385
|
+
__name(isSafeNumber, "isSafeNumber");
|
|
386
|
+
var UnsafeNumberReason = /* @__PURE__ */ (function(UnsafeNumberReason2) {
|
|
387
|
+
UnsafeNumberReason2["underflow"] = "underflow";
|
|
388
|
+
UnsafeNumberReason2["overflow"] = "overflow";
|
|
389
|
+
UnsafeNumberReason2["truncate_integer"] = "truncate_integer";
|
|
390
|
+
UnsafeNumberReason2["truncate_float"] = "truncate_float";
|
|
391
|
+
return UnsafeNumberReason2;
|
|
392
|
+
})({});
|
|
393
|
+
function getUnsafeNumberReason(value) {
|
|
394
|
+
if (isSafeNumber(value, {
|
|
395
|
+
approx: false
|
|
396
|
+
})) {
|
|
664
397
|
return void 0;
|
|
665
|
-
|
|
666
|
-
|
|
398
|
+
}
|
|
399
|
+
if (isInteger(value)) {
|
|
400
|
+
return UnsafeNumberReason.truncate_integer;
|
|
401
|
+
}
|
|
402
|
+
const num = Number.parseFloat(value);
|
|
403
|
+
if (!Number.isFinite(num)) {
|
|
404
|
+
return UnsafeNumberReason.overflow;
|
|
405
|
+
}
|
|
406
|
+
if (num === 0) {
|
|
407
|
+
return UnsafeNumberReason.underflow;
|
|
408
|
+
}
|
|
409
|
+
return UnsafeNumberReason.truncate_float;
|
|
410
|
+
}
|
|
411
|
+
__name(getUnsafeNumberReason, "getUnsafeNumberReason");
|
|
412
|
+
function extractSignificantDigits(value) {
|
|
413
|
+
const {
|
|
414
|
+
start,
|
|
415
|
+
end
|
|
416
|
+
} = getSignificantDigitRange(value);
|
|
417
|
+
const digits = value.substring(start, end);
|
|
418
|
+
const dot = digits.indexOf(".");
|
|
419
|
+
if (dot === -1) {
|
|
420
|
+
return digits;
|
|
421
|
+
}
|
|
422
|
+
return digits.substring(0, dot) + digits.substring(dot + 1);
|
|
423
|
+
}
|
|
424
|
+
__name(extractSignificantDigits, "extractSignificantDigits");
|
|
425
|
+
function getSignificantDigitRange(value) {
|
|
426
|
+
let start = 0;
|
|
427
|
+
if (value[0] === "-") {
|
|
428
|
+
start++;
|
|
429
|
+
}
|
|
430
|
+
while (value[start] === "0" || value[start] === ".") {
|
|
431
|
+
start++;
|
|
432
|
+
}
|
|
433
|
+
let end = value.lastIndexOf("e");
|
|
434
|
+
if (end === -1) {
|
|
435
|
+
end = value.lastIndexOf("E");
|
|
436
|
+
}
|
|
437
|
+
if (end === -1) {
|
|
438
|
+
end = value.length;
|
|
439
|
+
}
|
|
440
|
+
while ((value[end - 1] === "0" || value[end - 1] === ".") && end > start) {
|
|
441
|
+
end--;
|
|
442
|
+
}
|
|
667
443
|
return {
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
root: {
|
|
671
|
-
kind: "boolean",
|
|
672
|
-
clauses: roots.map((node) => ({ occur: "must", node })),
|
|
673
|
-
span: { start: 0, end: text2.length }
|
|
674
|
-
}
|
|
444
|
+
start,
|
|
445
|
+
end
|
|
675
446
|
};
|
|
676
|
-
}
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
var
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
447
|
+
}
|
|
448
|
+
__name(getSignificantDigitRange, "getSignificantDigitRange");
|
|
449
|
+
|
|
450
|
+
// node_modules/.pnpm/lossless-json@4.3.3/node_modules/lossless-json/lib/esm/LosslessNumber.js
|
|
451
|
+
var losslessNumberMarker = /* @__PURE__ */ Symbol.for("lossless-json.LosslessNumber");
|
|
452
|
+
var LosslessNumber = class {
|
|
453
|
+
static {
|
|
454
|
+
__name(this, "LosslessNumber");
|
|
455
|
+
}
|
|
456
|
+
// numeric value as string
|
|
457
|
+
value;
|
|
458
|
+
/**
|
|
459
|
+
* @deprecated Use the isLosslessNumber(value) function instead.
|
|
460
|
+
*
|
|
461
|
+
* Ordinary objects may also have an isLosslessNumber property, so this
|
|
462
|
+
* field cannot reliably identify lossless numbers.
|
|
463
|
+
*/
|
|
464
|
+
isLosslessNumber = true;
|
|
465
|
+
get [losslessNumberMarker]() {
|
|
466
|
+
return true;
|
|
467
|
+
}
|
|
468
|
+
constructor(value) {
|
|
469
|
+
if (!isNumber(value)) {
|
|
470
|
+
throw new Error(`Invalid number (value: "${value}")`);
|
|
471
|
+
}
|
|
472
|
+
this.value = value;
|
|
473
|
+
}
|
|
474
|
+
/**
|
|
475
|
+
* Get the value of the LosslessNumber as number or bigint.
|
|
476
|
+
*
|
|
477
|
+
* - a number is returned for safe numbers and decimal values that only lose some insignificant digits
|
|
478
|
+
* - a bigint is returned for big integer numbers
|
|
479
|
+
* - an Error is thrown for values that will overflow or underflow
|
|
480
|
+
*
|
|
481
|
+
* Note that you can implement your own strategy for conversion by just getting the value as string
|
|
482
|
+
* via .toString(), and using util functions like isInteger, isSafeNumber, getUnsafeNumberReason,
|
|
483
|
+
* and toSafeNumberOrThrow to convert it to a numeric value.
|
|
484
|
+
*/
|
|
485
|
+
valueOf() {
|
|
486
|
+
const unsafeReason = getUnsafeNumberReason(this.value);
|
|
487
|
+
if (unsafeReason === void 0 || unsafeReason === UnsafeNumberReason.truncate_float) {
|
|
488
|
+
return Number.parseFloat(this.value);
|
|
489
|
+
}
|
|
490
|
+
if (isInteger(this.value)) {
|
|
491
|
+
return BigInt(this.value);
|
|
492
|
+
}
|
|
493
|
+
throw new Error(`Cannot safely convert to number: the value '${this.value}' would ${unsafeReason} and become ${Number.parseFloat(this.value)}`);
|
|
494
|
+
}
|
|
495
|
+
/**
|
|
496
|
+
* Get the value of the LosslessNumber as string.
|
|
497
|
+
*/
|
|
498
|
+
toString() {
|
|
499
|
+
return this.value;
|
|
500
|
+
}
|
|
501
|
+
// Note: we do NOT implement a .toJSON() method, and you should not implement
|
|
502
|
+
// or use that, it cannot safely turn the numeric value in the string into
|
|
503
|
+
// stringified JSON since it has to be parsed into a number first.
|
|
504
|
+
};
|
|
505
|
+
function isLosslessNumber(value) {
|
|
506
|
+
return value !== null && typeof value === "object" && value[losslessNumberMarker] === true;
|
|
507
|
+
}
|
|
508
|
+
__name(isLosslessNumber, "isLosslessNumber");
|
|
509
|
+
|
|
510
|
+
// node_modules/.pnpm/lossless-json@4.3.3/node_modules/lossless-json/lib/esm/numberParsers.js
|
|
511
|
+
function parseLosslessNumber(value) {
|
|
512
|
+
return new LosslessNumber(value);
|
|
513
|
+
}
|
|
514
|
+
__name(parseLosslessNumber, "parseLosslessNumber");
|
|
515
|
+
|
|
516
|
+
// node_modules/.pnpm/lossless-json@4.3.3/node_modules/lossless-json/lib/esm/revive.js
|
|
517
|
+
function revive(json, reviver) {
|
|
518
|
+
return reviveValue({
|
|
519
|
+
"": json
|
|
520
|
+
}, "", json, reviver);
|
|
521
|
+
}
|
|
522
|
+
__name(revive, "revive");
|
|
523
|
+
function reviveValue(context, key, value, reviver) {
|
|
524
|
+
if (Array.isArray(value)) {
|
|
525
|
+
return reviver.call(context, key, reviveArray(value, reviver));
|
|
526
|
+
}
|
|
527
|
+
if (value && typeof value === "object" && !isLosslessNumber(value)) {
|
|
528
|
+
return reviver.call(context, key, reviveObject(value, reviver));
|
|
529
|
+
}
|
|
530
|
+
return reviver.call(context, key, value);
|
|
531
|
+
}
|
|
532
|
+
__name(reviveValue, "reviveValue");
|
|
533
|
+
function reviveObject(object, reviver) {
|
|
534
|
+
for (const key of Object.keys(object)) {
|
|
535
|
+
const value = reviveValue(object, key, object[key], reviver);
|
|
536
|
+
if (value !== void 0) {
|
|
537
|
+
object[key] = value;
|
|
538
|
+
} else {
|
|
539
|
+
delete object[key];
|
|
540
|
+
}
|
|
541
|
+
}
|
|
542
|
+
return object;
|
|
543
|
+
}
|
|
544
|
+
__name(reviveObject, "reviveObject");
|
|
545
|
+
function reviveArray(array2, reviver) {
|
|
546
|
+
for (let i = 0; i < array2.length; i++) {
|
|
547
|
+
const value = reviveValue(array2, String(i), array2[i], reviver);
|
|
548
|
+
if (value === void 0) {
|
|
549
|
+
delete array2[i];
|
|
550
|
+
} else {
|
|
551
|
+
array2[i] = value;
|
|
552
|
+
}
|
|
553
|
+
}
|
|
554
|
+
return array2;
|
|
555
|
+
}
|
|
556
|
+
__name(reviveArray, "reviveArray");
|
|
557
|
+
|
|
558
|
+
// node_modules/.pnpm/lossless-json@4.3.3/node_modules/lossless-json/lib/esm/parse.js
|
|
559
|
+
function parse(text2, reviver, options) {
|
|
560
|
+
const optionsObj = typeof options === "function" ? {
|
|
561
|
+
parseNumber: options
|
|
562
|
+
} : options;
|
|
563
|
+
const parseNumber = optionsObj?.parseNumber ?? parseLosslessNumber;
|
|
564
|
+
const onDuplicateKey = optionsObj?.onDuplicateKey ?? throwDuplicateKey;
|
|
565
|
+
let i = 0;
|
|
566
|
+
const value = parseValue();
|
|
567
|
+
expectValue(value);
|
|
568
|
+
expectEndOfInput();
|
|
569
|
+
return reviver ? revive(value, reviver) : value;
|
|
570
|
+
function parseObject() {
|
|
571
|
+
if (text2.charCodeAt(i) === codeOpeningBrace) {
|
|
572
|
+
i++;
|
|
573
|
+
skipWhitespace();
|
|
574
|
+
const object = {};
|
|
575
|
+
let initial = true;
|
|
576
|
+
while (i < text2.length && text2.charCodeAt(i) !== codeClosingBrace) {
|
|
577
|
+
if (!initial) {
|
|
578
|
+
eatComma();
|
|
579
|
+
skipWhitespace();
|
|
580
|
+
} else {
|
|
581
|
+
initial = false;
|
|
582
|
+
}
|
|
583
|
+
const start = i;
|
|
584
|
+
const key = parseString();
|
|
585
|
+
if (key === void 0) {
|
|
586
|
+
throwObjectKeyExpected();
|
|
587
|
+
return;
|
|
588
|
+
}
|
|
589
|
+
skipWhitespace();
|
|
590
|
+
eatColon();
|
|
591
|
+
const value2 = parseValue();
|
|
592
|
+
if (value2 === void 0) {
|
|
593
|
+
throwObjectValueExpected();
|
|
594
|
+
return;
|
|
595
|
+
}
|
|
596
|
+
if (Object.prototype.hasOwnProperty.call(object, key) && !isDeepEqual(value2, object[key])) {
|
|
597
|
+
const returnedValue = onDuplicateKey({
|
|
598
|
+
key,
|
|
599
|
+
position: start + 1,
|
|
600
|
+
oldValue: object[key],
|
|
601
|
+
newValue: value2
|
|
602
|
+
});
|
|
603
|
+
if (returnedValue !== void 0) {
|
|
604
|
+
setObjectKey(object, key, returnedValue);
|
|
605
|
+
}
|
|
606
|
+
} else {
|
|
607
|
+
setObjectKey(object, key, value2);
|
|
608
|
+
}
|
|
609
|
+
}
|
|
610
|
+
if (text2.charCodeAt(i) !== codeClosingBrace) {
|
|
611
|
+
throwObjectKeyOrEndExpected();
|
|
612
|
+
}
|
|
613
|
+
i++;
|
|
614
|
+
return object;
|
|
615
|
+
}
|
|
616
|
+
}
|
|
617
|
+
__name(parseObject, "parseObject");
|
|
618
|
+
function parseArray() {
|
|
619
|
+
if (text2.charCodeAt(i) === codeOpeningBracket) {
|
|
620
|
+
i++;
|
|
621
|
+
skipWhitespace();
|
|
622
|
+
const array2 = [];
|
|
623
|
+
let initial = true;
|
|
624
|
+
while (i < text2.length && text2.charCodeAt(i) !== codeClosingBracket) {
|
|
625
|
+
if (!initial) {
|
|
626
|
+
eatComma();
|
|
627
|
+
} else {
|
|
628
|
+
initial = false;
|
|
629
|
+
}
|
|
630
|
+
const value2 = parseValue();
|
|
631
|
+
expectArrayItem(value2);
|
|
632
|
+
array2.push(value2);
|
|
633
|
+
}
|
|
634
|
+
if (text2.charCodeAt(i) !== codeClosingBracket) {
|
|
635
|
+
throwArrayItemOrEndExpected();
|
|
636
|
+
}
|
|
637
|
+
i++;
|
|
638
|
+
return array2;
|
|
639
|
+
}
|
|
640
|
+
}
|
|
641
|
+
__name(parseArray, "parseArray");
|
|
642
|
+
function parseValue() {
|
|
643
|
+
skipWhitespace();
|
|
644
|
+
const value2 = parseString() ?? parseNumeric() ?? parseObject() ?? parseArray() ?? parseKeyword("true", true) ?? parseKeyword("false", false) ?? parseKeyword("null", null);
|
|
645
|
+
skipWhitespace();
|
|
646
|
+
return value2;
|
|
647
|
+
}
|
|
648
|
+
__name(parseValue, "parseValue");
|
|
649
|
+
function parseKeyword(name, value2) {
|
|
650
|
+
if (text2.slice(i, i + name.length) === name) {
|
|
651
|
+
i += name.length;
|
|
652
|
+
return value2;
|
|
653
|
+
}
|
|
654
|
+
}
|
|
655
|
+
__name(parseKeyword, "parseKeyword");
|
|
656
|
+
function skipWhitespace() {
|
|
657
|
+
while (isWhitespace(text2.charCodeAt(i))) {
|
|
658
|
+
i++;
|
|
659
|
+
}
|
|
660
|
+
}
|
|
661
|
+
__name(skipWhitespace, "skipWhitespace");
|
|
662
|
+
function parseString() {
|
|
663
|
+
if (text2.charCodeAt(i) === codeDoubleQuote) {
|
|
664
|
+
i++;
|
|
665
|
+
let result = "";
|
|
666
|
+
while (i < text2.length && text2.charCodeAt(i) !== codeDoubleQuote) {
|
|
667
|
+
if (text2.charCodeAt(i) === codeBackslash) {
|
|
668
|
+
const char = text2[i + 1];
|
|
669
|
+
const escapeChar = escapeCharacters[char];
|
|
670
|
+
if (escapeChar !== void 0) {
|
|
671
|
+
result += escapeChar;
|
|
672
|
+
i++;
|
|
673
|
+
} else if (char === "u") {
|
|
674
|
+
if (isHex(text2.charCodeAt(i + 2)) && isHex(text2.charCodeAt(i + 3)) && isHex(text2.charCodeAt(i + 4)) && isHex(text2.charCodeAt(i + 5))) {
|
|
675
|
+
result += String.fromCharCode(Number.parseInt(text2.slice(i + 2, i + 6), 16));
|
|
676
|
+
i += 5;
|
|
677
|
+
} else {
|
|
678
|
+
throwInvalidUnicodeCharacter(i);
|
|
679
|
+
}
|
|
680
|
+
} else {
|
|
681
|
+
throwInvalidEscapeCharacter(i);
|
|
682
|
+
}
|
|
683
|
+
} else {
|
|
684
|
+
if (isValidStringCharacter(text2.charCodeAt(i))) {
|
|
685
|
+
result += text2[i];
|
|
686
|
+
} else {
|
|
687
|
+
throwInvalidCharacter(text2[i]);
|
|
688
|
+
}
|
|
689
|
+
}
|
|
690
|
+
i++;
|
|
691
|
+
}
|
|
692
|
+
expectEndOfString();
|
|
693
|
+
i++;
|
|
694
|
+
return result;
|
|
695
|
+
}
|
|
696
|
+
}
|
|
697
|
+
__name(parseString, "parseString");
|
|
698
|
+
function parseNumeric() {
|
|
699
|
+
const start = i;
|
|
700
|
+
if (text2.charCodeAt(i) === codeMinus) {
|
|
701
|
+
i++;
|
|
702
|
+
expectDigit(start);
|
|
703
|
+
}
|
|
704
|
+
if (text2.charCodeAt(i) === codeZero) {
|
|
705
|
+
i++;
|
|
706
|
+
} else if (isNonZeroDigit(text2.charCodeAt(i))) {
|
|
707
|
+
i++;
|
|
708
|
+
while (isDigit(text2.charCodeAt(i))) {
|
|
709
|
+
i++;
|
|
710
|
+
}
|
|
711
|
+
} else {
|
|
712
|
+
return void 0;
|
|
713
|
+
}
|
|
714
|
+
if (text2.charCodeAt(i) === codeDot) {
|
|
715
|
+
i++;
|
|
716
|
+
expectDigit(start);
|
|
717
|
+
while (isDigit(text2.charCodeAt(i))) {
|
|
718
|
+
i++;
|
|
719
|
+
}
|
|
720
|
+
}
|
|
721
|
+
if (text2.charCodeAt(i) === codeLowercaseE || text2.charCodeAt(i) === codeUppercaseE) {
|
|
722
|
+
i++;
|
|
723
|
+
if (text2.charCodeAt(i) === codeMinus || text2.charCodeAt(i) === codePlus) {
|
|
724
|
+
i++;
|
|
725
|
+
}
|
|
726
|
+
expectDigit(start);
|
|
727
|
+
while (isDigit(text2.charCodeAt(i))) {
|
|
728
|
+
i++;
|
|
729
|
+
}
|
|
730
|
+
}
|
|
731
|
+
if (i > start) {
|
|
732
|
+
return parseNumber(text2.slice(start, i));
|
|
733
|
+
}
|
|
734
|
+
}
|
|
735
|
+
__name(parseNumeric, "parseNumeric");
|
|
736
|
+
function eatComma() {
|
|
737
|
+
if (text2.charCodeAt(i) !== codeComma) {
|
|
738
|
+
throw new SyntaxError(`Comma ',' expected after value ${gotAt()}`);
|
|
739
|
+
}
|
|
740
|
+
i++;
|
|
741
|
+
}
|
|
742
|
+
__name(eatComma, "eatComma");
|
|
743
|
+
function eatColon() {
|
|
744
|
+
if (text2.charCodeAt(i) !== codeColon) {
|
|
745
|
+
throw new SyntaxError(`Colon ':' expected after property name ${gotAt()}`);
|
|
746
|
+
}
|
|
747
|
+
i++;
|
|
748
|
+
}
|
|
749
|
+
__name(eatColon, "eatColon");
|
|
750
|
+
function expectValue(value2) {
|
|
751
|
+
if (value2 === void 0) {
|
|
752
|
+
throw new SyntaxError(`JSON value expected ${gotAt()}`);
|
|
753
|
+
}
|
|
754
|
+
}
|
|
755
|
+
__name(expectValue, "expectValue");
|
|
756
|
+
function expectArrayItem(value2) {
|
|
757
|
+
if (value2 === void 0) {
|
|
758
|
+
throw new SyntaxError(`Array item expected ${gotAt()}`);
|
|
759
|
+
}
|
|
760
|
+
}
|
|
761
|
+
__name(expectArrayItem, "expectArrayItem");
|
|
762
|
+
function expectEndOfInput() {
|
|
763
|
+
if (i < text2.length) {
|
|
764
|
+
throw new SyntaxError(`Expected end of input ${gotAt()}`);
|
|
765
|
+
}
|
|
766
|
+
}
|
|
767
|
+
__name(expectEndOfInput, "expectEndOfInput");
|
|
768
|
+
function expectDigit(start) {
|
|
769
|
+
if (!isDigit(text2.charCodeAt(i))) {
|
|
770
|
+
const numSoFar = text2.slice(start, i);
|
|
771
|
+
throw new SyntaxError(`Invalid number '${numSoFar}', expecting a digit ${gotAt()}`);
|
|
772
|
+
}
|
|
773
|
+
}
|
|
774
|
+
__name(expectDigit, "expectDigit");
|
|
775
|
+
function expectEndOfString() {
|
|
776
|
+
if (text2.charCodeAt(i) !== codeDoubleQuote) {
|
|
777
|
+
throw new SyntaxError(`End of string '"' expected ${gotAt()}`);
|
|
778
|
+
}
|
|
779
|
+
}
|
|
780
|
+
__name(expectEndOfString, "expectEndOfString");
|
|
781
|
+
function throwObjectKeyExpected() {
|
|
782
|
+
throw new SyntaxError(`Quoted object key expected ${gotAt()}`);
|
|
783
|
+
}
|
|
784
|
+
__name(throwObjectKeyExpected, "throwObjectKeyExpected");
|
|
785
|
+
function throwDuplicateKey({
|
|
786
|
+
key,
|
|
787
|
+
position
|
|
788
|
+
}) {
|
|
789
|
+
throw new SyntaxError(`Duplicate key '${key}' encountered at position ${position}`);
|
|
790
|
+
}
|
|
791
|
+
__name(throwDuplicateKey, "throwDuplicateKey");
|
|
792
|
+
function throwObjectKeyOrEndExpected() {
|
|
793
|
+
throw new SyntaxError(`Quoted object key or end of object '}' expected ${gotAt()}`);
|
|
794
|
+
}
|
|
795
|
+
__name(throwObjectKeyOrEndExpected, "throwObjectKeyOrEndExpected");
|
|
796
|
+
function throwArrayItemOrEndExpected() {
|
|
797
|
+
throw new SyntaxError(`Array item or end of array ']' expected ${gotAt()}`);
|
|
798
|
+
}
|
|
799
|
+
__name(throwArrayItemOrEndExpected, "throwArrayItemOrEndExpected");
|
|
800
|
+
function throwInvalidCharacter(char) {
|
|
801
|
+
throw new SyntaxError(`Invalid character '${char}' ${pos()}`);
|
|
802
|
+
}
|
|
803
|
+
__name(throwInvalidCharacter, "throwInvalidCharacter");
|
|
804
|
+
function throwInvalidEscapeCharacter(start) {
|
|
805
|
+
const chars = text2.slice(start, start + 2);
|
|
806
|
+
throw new SyntaxError(`Invalid escape character '${chars}' ${pos()}`);
|
|
807
|
+
}
|
|
808
|
+
__name(throwInvalidEscapeCharacter, "throwInvalidEscapeCharacter");
|
|
809
|
+
function throwObjectValueExpected() {
|
|
810
|
+
throw new SyntaxError(`Object value expected after ':' ${pos()}`);
|
|
811
|
+
}
|
|
812
|
+
__name(throwObjectValueExpected, "throwObjectValueExpected");
|
|
813
|
+
function throwInvalidUnicodeCharacter(start) {
|
|
814
|
+
const chars = text2.slice(start, start + 6);
|
|
815
|
+
throw new SyntaxError(`Invalid unicode character '${chars}' ${pos()}`);
|
|
816
|
+
}
|
|
817
|
+
__name(throwInvalidUnicodeCharacter, "throwInvalidUnicodeCharacter");
|
|
818
|
+
function pos() {
|
|
819
|
+
return `at position ${i}`;
|
|
820
|
+
}
|
|
821
|
+
__name(pos, "pos");
|
|
822
|
+
function got() {
|
|
823
|
+
return i < text2.length ? `but got '${text2[i]}'` : "but reached end of input";
|
|
824
|
+
}
|
|
825
|
+
__name(got, "got");
|
|
826
|
+
function gotAt() {
|
|
827
|
+
return `${got()} ${pos()}`;
|
|
828
|
+
}
|
|
829
|
+
__name(gotAt, "gotAt");
|
|
830
|
+
}
|
|
831
|
+
__name(parse, "parse");
|
|
832
|
+
function setObjectKey(object, key, value) {
|
|
833
|
+
if (key === "__proto__") {
|
|
834
|
+
Object.defineProperty(object, key, {
|
|
835
|
+
value,
|
|
836
|
+
writable: true,
|
|
837
|
+
enumerable: true,
|
|
838
|
+
configurable: true
|
|
839
|
+
});
|
|
840
|
+
} else {
|
|
841
|
+
object[key] = value;
|
|
842
|
+
}
|
|
843
|
+
}
|
|
844
|
+
__name(setObjectKey, "setObjectKey");
|
|
845
|
+
function isWhitespace(code) {
|
|
846
|
+
return code === codeSpace || code === codeNewline || code === codeTab || code === codeReturn;
|
|
847
|
+
}
|
|
848
|
+
__name(isWhitespace, "isWhitespace");
|
|
849
|
+
function isHex(code) {
|
|
850
|
+
return code >= codeZero && code <= codeNine || code >= codeUppercaseA && code <= codeUppercaseF || code >= codeLowercaseA && code <= codeLowercaseF;
|
|
851
|
+
}
|
|
852
|
+
__name(isHex, "isHex");
|
|
853
|
+
function isDigit(code) {
|
|
854
|
+
return code >= codeZero && code <= codeNine;
|
|
855
|
+
}
|
|
856
|
+
__name(isDigit, "isDigit");
|
|
857
|
+
function isNonZeroDigit(code) {
|
|
858
|
+
return code >= codeOne && code <= codeNine;
|
|
859
|
+
}
|
|
860
|
+
__name(isNonZeroDigit, "isNonZeroDigit");
|
|
861
|
+
function isValidStringCharacter(code) {
|
|
862
|
+
return code >= 32 && code <= 1114111;
|
|
863
|
+
}
|
|
864
|
+
__name(isValidStringCharacter, "isValidStringCharacter");
|
|
865
|
+
function isDeepEqual(a, b) {
|
|
866
|
+
if (a === b) {
|
|
867
|
+
return true;
|
|
868
|
+
}
|
|
869
|
+
if (Array.isArray(a) && Array.isArray(b)) {
|
|
870
|
+
return a.length === b.length && a.every((item, index) => isDeepEqual(item, b[index]));
|
|
871
|
+
}
|
|
872
|
+
if (isObject2(a) && isObject2(b)) {
|
|
873
|
+
const keys = [.../* @__PURE__ */ new Set([...Object.keys(a), ...Object.keys(b)])];
|
|
874
|
+
return keys.every((key) => isDeepEqual(a[key], b[key]));
|
|
875
|
+
}
|
|
876
|
+
return false;
|
|
877
|
+
}
|
|
878
|
+
__name(isDeepEqual, "isDeepEqual");
|
|
879
|
+
function isObject2(value) {
|
|
880
|
+
return typeof value === "object" && value !== null;
|
|
881
|
+
}
|
|
882
|
+
__name(isObject2, "isObject");
|
|
883
|
+
var escapeCharacters = {
|
|
884
|
+
'"': '"',
|
|
885
|
+
"\\": "\\",
|
|
886
|
+
"/": "/",
|
|
887
|
+
b: "\b",
|
|
888
|
+
f: "\f",
|
|
889
|
+
n: "\n",
|
|
890
|
+
r: "\r",
|
|
891
|
+
t: " "
|
|
892
|
+
// note that \u is handled separately in parseString()
|
|
893
|
+
};
|
|
894
|
+
var codeBackslash = 92;
|
|
895
|
+
var codeOpeningBrace = 123;
|
|
896
|
+
var codeClosingBrace = 125;
|
|
897
|
+
var codeOpeningBracket = 91;
|
|
898
|
+
var codeClosingBracket = 93;
|
|
899
|
+
var codeSpace = 32;
|
|
900
|
+
var codeNewline = 10;
|
|
901
|
+
var codeTab = 9;
|
|
902
|
+
var codeReturn = 13;
|
|
903
|
+
var codeDoubleQuote = 34;
|
|
904
|
+
var codePlus = 43;
|
|
905
|
+
var codeMinus = 45;
|
|
906
|
+
var codeZero = 48;
|
|
907
|
+
var codeOne = 49;
|
|
908
|
+
var codeNine = 57;
|
|
909
|
+
var codeComma = 44;
|
|
910
|
+
var codeDot = 46;
|
|
911
|
+
var codeColon = 58;
|
|
912
|
+
var codeUppercaseA = 65;
|
|
913
|
+
var codeLowercaseA = 97;
|
|
914
|
+
var codeUppercaseE = 69;
|
|
915
|
+
var codeLowercaseE = 101;
|
|
916
|
+
var codeUppercaseF = 70;
|
|
917
|
+
var codeLowercaseF = 102;
|
|
918
|
+
|
|
919
|
+
// node_modules/.pnpm/lossless-json@4.3.3/node_modules/lossless-json/lib/esm/stringify.js
|
|
920
|
+
function stringify(value, replacer, space, numberStringifiers) {
|
|
921
|
+
const resolvedSpace = resolveSpace(space);
|
|
922
|
+
const replacedValue = typeof replacer === "function" ? replacer.call({
|
|
923
|
+
"": value
|
|
924
|
+
}, "", value) : value;
|
|
925
|
+
return stringifyValue(replacedValue, "");
|
|
926
|
+
function stringifyValue(value2, indent) {
|
|
927
|
+
if (Array.isArray(numberStringifiers)) {
|
|
928
|
+
const stringifier = numberStringifiers.find((item) => item.test(value2));
|
|
929
|
+
if (stringifier) {
|
|
930
|
+
const str = stringifier.stringify(value2);
|
|
931
|
+
if (typeof str !== "string" || !isNumber(str)) {
|
|
932
|
+
throw new Error(`Invalid JSON number: output of a number stringifier must be a string containing a JSON number (output: ${str})`);
|
|
933
|
+
}
|
|
934
|
+
return str;
|
|
935
|
+
}
|
|
936
|
+
}
|
|
937
|
+
if (typeof value2 === "boolean" || typeof value2 === "number" || typeof value2 === "string" || value2 === null || value2 instanceof Date || value2 instanceof Boolean || value2 instanceof Number || value2 instanceof String) {
|
|
938
|
+
return JSON.stringify(value2);
|
|
939
|
+
}
|
|
940
|
+
if (isLosslessNumber(value2)) {
|
|
941
|
+
return value2.toString();
|
|
942
|
+
}
|
|
943
|
+
if (typeof value2 === "bigint") {
|
|
944
|
+
return value2.toString();
|
|
945
|
+
}
|
|
946
|
+
if (Array.isArray(value2)) {
|
|
947
|
+
return stringifyArray(value2, indent);
|
|
948
|
+
}
|
|
949
|
+
if (value2 && typeof value2 === "object") {
|
|
950
|
+
return stringifyObject(value2, indent);
|
|
951
|
+
}
|
|
952
|
+
return void 0;
|
|
953
|
+
}
|
|
954
|
+
__name(stringifyValue, "stringifyValue");
|
|
955
|
+
function stringifyArray(array2, indent) {
|
|
956
|
+
if (array2.length === 0) {
|
|
957
|
+
return "[]";
|
|
958
|
+
}
|
|
959
|
+
const childIndent = resolvedSpace ? indent + resolvedSpace : void 0;
|
|
960
|
+
let str = resolvedSpace ? "[\n" : "[";
|
|
961
|
+
for (let i = 0; i < array2.length; i++) {
|
|
962
|
+
const item = typeof replacer === "function" ? replacer.call(array2, String(i), array2[i]) : array2[i];
|
|
963
|
+
if (resolvedSpace) {
|
|
964
|
+
str += childIndent;
|
|
965
|
+
}
|
|
966
|
+
if (typeof item !== "undefined" && typeof item !== "function") {
|
|
967
|
+
const serialized = stringifyValue(item, childIndent);
|
|
968
|
+
str += serialized === void 0 ? "null" : serialized;
|
|
969
|
+
} else {
|
|
970
|
+
str += "null";
|
|
971
|
+
}
|
|
972
|
+
if (i < array2.length - 1) {
|
|
973
|
+
str += resolvedSpace ? ",\n" : ",";
|
|
974
|
+
}
|
|
975
|
+
}
|
|
976
|
+
str += resolvedSpace ? `
|
|
977
|
+
${indent}]` : "]";
|
|
978
|
+
return str;
|
|
979
|
+
}
|
|
980
|
+
__name(stringifyArray, "stringifyArray");
|
|
981
|
+
function stringifyObject(object, indent) {
|
|
982
|
+
if (typeof object.toJSON === "function") {
|
|
983
|
+
return stringifyValue(object.toJSON(), indent);
|
|
984
|
+
}
|
|
985
|
+
const keys = Array.isArray(replacer) ? [...new Set(replacer.map(String))] : Object.keys(object);
|
|
986
|
+
if (keys.length === 0) {
|
|
987
|
+
return "{}";
|
|
988
|
+
}
|
|
989
|
+
const childIndent = resolvedSpace ? indent + resolvedSpace : void 0;
|
|
990
|
+
let first = true;
|
|
991
|
+
let str = resolvedSpace ? "{\n" : "{";
|
|
992
|
+
for (const key of keys) {
|
|
993
|
+
const value2 = typeof replacer === "function" ? replacer.call(object, key, object[key]) : object[key];
|
|
994
|
+
if (includeProperty(key, value2)) {
|
|
995
|
+
const serialized = stringifyValue(value2, childIndent);
|
|
996
|
+
if (serialized === void 0) {
|
|
703
997
|
continue;
|
|
704
998
|
}
|
|
705
|
-
if (
|
|
706
|
-
|
|
707
|
-
|
|
999
|
+
if (first) {
|
|
1000
|
+
first = false;
|
|
1001
|
+
} else {
|
|
1002
|
+
str += resolvedSpace ? ",\n" : ",";
|
|
1003
|
+
}
|
|
1004
|
+
const keyStr = JSON.stringify(key);
|
|
1005
|
+
str += resolvedSpace ? `${childIndent + keyStr}: ` : `${keyStr}:`;
|
|
1006
|
+
str += serialized;
|
|
708
1007
|
}
|
|
709
|
-
return;
|
|
710
1008
|
}
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
}
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
1009
|
+
str += resolvedSpace ? `
|
|
1010
|
+
${indent}}` : "}";
|
|
1011
|
+
return str;
|
|
1012
|
+
}
|
|
1013
|
+
__name(stringifyObject, "stringifyObject");
|
|
1014
|
+
function includeProperty(_key, value2) {
|
|
1015
|
+
return typeof value2 !== "undefined" && typeof value2 !== "function" && typeof value2 !== "symbol";
|
|
1016
|
+
}
|
|
1017
|
+
__name(includeProperty, "includeProperty");
|
|
1018
|
+
}
|
|
1019
|
+
__name(stringify, "stringify");
|
|
1020
|
+
var MAX_SPACE_LENGTH = 10;
|
|
1021
|
+
function resolveSpace(space) {
|
|
1022
|
+
if (typeof space === "number") {
|
|
1023
|
+
const count = Math.min(Math.trunc(space), MAX_SPACE_LENGTH);
|
|
1024
|
+
return count >= 1 ? " ".repeat(count) : void 0;
|
|
1025
|
+
}
|
|
1026
|
+
if (typeof space === "string" && space !== "") {
|
|
1027
|
+
return space.slice(0, MAX_SPACE_LENGTH);
|
|
1028
|
+
}
|
|
1029
|
+
return void 0;
|
|
1030
|
+
}
|
|
1031
|
+
__name(resolveSpace, "resolveSpace");
|
|
1032
|
+
|
|
1033
|
+
// 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/bot/api-input.js
|
|
1034
|
+
var RENAMED = { timeout: "poll-timeout" };
|
|
1035
|
+
var apiFlagOf = /* @__PURE__ */ __name((name) => RENAMED[name] ?? name.replace(/_/g, "-").replace(/([a-z0-9])([A-Z])/g, "$1-$2").toLowerCase(), "apiFlagOf");
|
|
1036
|
+
var apiOptionKey = /* @__PURE__ */ __name((name) => apiFlagOf(name).replace(/-([a-z0-9])/g, (_, letter) => letter.toUpperCase()), "apiOptionKey");
|
|
1037
|
+
var DIGITS = /^-?\d+$/;
|
|
1038
|
+
var coerce = /* @__PURE__ */ __name((raw) => {
|
|
1039
|
+
if (DIGITS.test(raw))
|
|
1040
|
+
return new LosslessNumber(raw);
|
|
1041
|
+
if (raw === "true" || raw === "false")
|
|
1042
|
+
return raw === "true";
|
|
1043
|
+
return raw;
|
|
1044
|
+
}, "coerce");
|
|
1045
|
+
var checkApiParameter = /* @__PURE__ */ __name((name, node, raw, schemas) => {
|
|
1046
|
+
switch (node.type) {
|
|
1047
|
+
case "ref": {
|
|
1048
|
+
const schema2 = schemas[identifier(node.ref)];
|
|
1049
|
+
return schema2 && !safeParse(schema2, coerce(raw)).success ? `--${apiFlagOf(name)} is not a valid ${node.ref}` : void 0;
|
|
1050
|
+
}
|
|
1051
|
+
case "union":
|
|
1052
|
+
return node.of.some((member) => checkApiParameter(name, member, raw, schemas) === void 0) ? void 0 : `--${apiFlagOf(name)} does not match any allowed type`;
|
|
1053
|
+
case "integer":
|
|
1054
|
+
if (!DIGITS.test(raw))
|
|
1055
|
+
return `--${apiFlagOf(name)} takes an integer`;
|
|
1056
|
+
if (node.minimum !== void 0 && BigInt(raw) < BigInt(node.minimum))
|
|
1057
|
+
return `--${apiFlagOf(name)} is at least ${node.minimum}`;
|
|
1058
|
+
if (node.maximum !== void 0 && BigInt(raw) > BigInt(node.maximum))
|
|
1059
|
+
return `--${apiFlagOf(name)} is at most ${node.maximum}`;
|
|
1060
|
+
return void 0;
|
|
1061
|
+
case "boolean":
|
|
1062
|
+
return raw === "true" || raw === "false" ? void 0 : `--${apiFlagOf(name)} takes true or false`;
|
|
1063
|
+
case "string":
|
|
1064
|
+
return node.enum && !node.enum.includes(raw) ? `--${apiFlagOf(name)} is one of ${node.enum.join(", ")}` : void 0;
|
|
1065
|
+
case "array":
|
|
1066
|
+
return raw.split(",").map((item) => checkApiParameter(name, node.items, item.trim(), schemas)).find((problem) => problem !== void 0);
|
|
1067
|
+
default:
|
|
1068
|
+
return void 0;
|
|
1069
|
+
}
|
|
1070
|
+
}, "checkApiParameter");
|
|
1071
|
+
var JSON_BODY = /[/+]json\s*(;|$)/i;
|
|
1072
|
+
var FORM_BODY = /^(multipart\/form-data|application\/x-www-form-urlencoded)\s*(;|$)/i;
|
|
1073
|
+
var sendsBytes = /* @__PURE__ */ __name((operation) => {
|
|
1074
|
+
const type = operation.request?.contentType;
|
|
1075
|
+
return type !== void 0 && !JSON_BODY.test(type) && !FORM_BODY.test(type);
|
|
1076
|
+
}, "sendsBytes");
|
|
1077
|
+
var readApiBytes = /* @__PURE__ */ __name((path2, read = (from) => new Uint8Array(readFileSync(from))) => read(path2 === "-" ? 0 : path2), "readApiBytes");
|
|
1078
|
+
var readApiBody = /* @__PURE__ */ __name((options, read = (path2) => readFileSync(path2, "utf8")) => {
|
|
1079
|
+
if (options.body !== void 0 && options.bodyFile !== void 0) {
|
|
1080
|
+
throw new CliError("validation_error", "--body and --body-file both given; pick one");
|
|
1081
|
+
}
|
|
1082
|
+
if (options.bodyFile !== void 0)
|
|
1083
|
+
return read(options.bodyFile === "-" ? 0 : options.bodyFile);
|
|
1084
|
+
if (options.body === "-")
|
|
1085
|
+
return read(0);
|
|
1086
|
+
return options.body;
|
|
1087
|
+
}, "readApiBody");
|
|
1088
|
+
var checkApiBody = /* @__PURE__ */ __name((operation, text2, schemas) => {
|
|
1089
|
+
if (text2 === void 0 || text2.trim() === "") {
|
|
1090
|
+
if (operation.request?.required) {
|
|
1091
|
+
throw new CliError("validation_error", `${operation.command} needs a JSON body: --body '<json>', --body -, or --body-file`);
|
|
1092
|
+
}
|
|
1093
|
+
return void 0;
|
|
1094
|
+
}
|
|
1095
|
+
let value;
|
|
1096
|
+
try {
|
|
1097
|
+
value = parse(text2);
|
|
1098
|
+
} catch {
|
|
1099
|
+
throw new CliError("validation_error", "the body is not valid JSON");
|
|
1100
|
+
}
|
|
1101
|
+
const schema2 = operation.request?.schema ? schemas[operation.request.schema] : void 0;
|
|
1102
|
+
if (schema2) {
|
|
1103
|
+
const result = safeParse(schema2, value);
|
|
1104
|
+
if (!result.success) {
|
|
1105
|
+
const where = result.issues.map((issue) => `${getDotPath(issue) ?? "(body)"} expects ${issue.expected ?? issue.kind}`);
|
|
1106
|
+
throw new CliError("validation_error", `the body does not match ${operation.request?.schema}: ${where.join("; ")}`);
|
|
1107
|
+
}
|
|
1108
|
+
}
|
|
1109
|
+
return text2;
|
|
1110
|
+
}, "checkApiBody");
|
|
1111
|
+
var parseApiJson = /* @__PURE__ */ __name((text2) => {
|
|
1112
|
+
try {
|
|
1113
|
+
return parse(text2);
|
|
1114
|
+
} catch {
|
|
1115
|
+
throw new CliError("validation_error", "the body is not valid JSON");
|
|
1116
|
+
}
|
|
1117
|
+
}, "parseApiJson");
|
|
1118
|
+
var finite = /* @__PURE__ */ __name((key, value) => {
|
|
1119
|
+
if (typeof value === "number" && !Number.isFinite(value))
|
|
1120
|
+
throw new CliError("validation_error", `${key === "" ? "the body" : key} is ${value}, which a request cannot carry; nothing was sent`, { sent: false });
|
|
1121
|
+
return value;
|
|
1122
|
+
}, "finite");
|
|
1123
|
+
var apiJson = /* @__PURE__ */ __name((value) => stringify(value, finite) ?? "null", "apiJson");
|
|
1124
|
+
var apiPlainJson = /* @__PURE__ */ __name((value) => JSON.parse(stringify(value, (key, inner) => isLosslessNumber(inner) && !isSafeNumber(inner.value) ? inner.toString() : finite(key, inner)) ?? "null"), "apiPlainJson");
|
|
1125
|
+
var isVariables = /* @__PURE__ */ __name((value) => value !== null && typeof value === "object" && !Array.isArray(value) && !isLosslessNumber(value), "isVariables");
|
|
1126
|
+
var graphqlVariables = /* @__PURE__ */ __name((operation, body, fields2) => {
|
|
1127
|
+
const { binding } = operation;
|
|
1128
|
+
if (binding.kind !== "graphql")
|
|
1129
|
+
throw new CliError("configuration_error", `${operation.command} is not a GraphQL operation`);
|
|
1130
|
+
const given = body?.trim() ? parseApiJson(body) : {};
|
|
1131
|
+
if (!isVariables(given))
|
|
1132
|
+
throw new CliError("validation_error", `${operation.command} takes its variables as one JSON object`, {
|
|
1133
|
+
sent: false
|
|
1134
|
+
});
|
|
1135
|
+
const variables = { ...given };
|
|
1136
|
+
for (const [name, raw] of Object.entries(fields2)) {
|
|
1137
|
+
const schema2 = operation.parameters.find((one) => one.in === "body" && one.name === name)?.schema;
|
|
1138
|
+
variables[name] = flagValue(operation, name, raw, schema2?.type);
|
|
1139
|
+
}
|
|
1140
|
+
const unknown2 = Object.keys(variables).filter((name) => !(name in binding.variables));
|
|
1141
|
+
if (unknown2.length > 0)
|
|
1142
|
+
throw new CliError("validation_error", `${operation.command} has no variable ${unknown2.join(", ")}`, {
|
|
1143
|
+
sent: false
|
|
1144
|
+
});
|
|
1145
|
+
const missing = Object.entries(binding.variables).filter(([name, type]) => type.endsWith("!") && variables[name] == null).map(([name]) => `--${apiFlagOf(name)}`);
|
|
1146
|
+
if (missing.length > 0)
|
|
1147
|
+
throw new CliError("validation_error", `${operation.command} needs ${missing.join(", ")}`, { sent: false });
|
|
1148
|
+
return variables;
|
|
1149
|
+
}, "graphqlVariables");
|
|
1150
|
+
var DECIMAL = /^-?\d+(\.\d+)?$/;
|
|
1151
|
+
var flagValue = /* @__PURE__ */ __name((operation, name, raw, type) => {
|
|
1152
|
+
const flag = `--${apiFlagOf(name)} of ${operation.command}`;
|
|
1153
|
+
if (type === "integer" || type === "number") {
|
|
1154
|
+
if (!(type === "integer" ? DIGITS : DECIMAL).test(raw.trim()))
|
|
1155
|
+
throw new CliError("validation_error", `${flag} takes ${type === "integer" ? "a whole number" : "a number"}`, {
|
|
1156
|
+
sent: false
|
|
728
1157
|
});
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
return
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
1158
|
+
return new LosslessNumber(raw.trim());
|
|
1159
|
+
}
|
|
1160
|
+
if (type === "boolean") {
|
|
1161
|
+
if (raw !== "true" && raw !== "false")
|
|
1162
|
+
throw new CliError("validation_error", `${flag} takes true or false`, { sent: false });
|
|
1163
|
+
return raw === "true";
|
|
1164
|
+
}
|
|
1165
|
+
if (type === "object" || type === "array" || type === "unknown")
|
|
1166
|
+
return parseApiJson(raw);
|
|
1167
|
+
if (type === "ref" && /^\s*[{["]/.test(raw))
|
|
1168
|
+
return parseApiJson(raw);
|
|
1169
|
+
return raw;
|
|
1170
|
+
}, "flagValue");
|
|
1171
|
+
|
|
1172
|
+
// 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/service-api-manifest.js
|
|
1173
|
+
var manifestBaseUrl = /* @__PURE__ */ __name((manifest, given, variables = {}) => {
|
|
1174
|
+
const server = manifest.servers?.[0];
|
|
1175
|
+
if (given === void 0 && !server)
|
|
1176
|
+
throw new CliError("configuration_error", "the manifest names no server; give the api a baseUrl");
|
|
1177
|
+
const url = given ?? server.url.replace(/\{([^}]+)\}/g, (_, name) => {
|
|
1178
|
+
const value = variables[name];
|
|
1179
|
+
if (value !== void 0)
|
|
1180
|
+
return wholeHost(server, name) ? serverValue(name, value) : labelValue(name, value);
|
|
1181
|
+
const variable = server?.variables?.[name];
|
|
1182
|
+
if (variable?.default === void 0 || !variable.enum?.includes(variable.default))
|
|
1183
|
+
throw new CliError("configuration_error", `the server's {${name}} is the owner's own; sign in with session start --${name}, or give the api a baseUrl`);
|
|
1184
|
+
return variable.default;
|
|
1185
|
+
});
|
|
1186
|
+
if (!/^https:\/\//.test(url))
|
|
1187
|
+
throw new CliError("configuration_error", `the api's server ${url} is not https`);
|
|
1188
|
+
if (!URL.canParse(url) || new URL(url).username || new URL(url).password)
|
|
1189
|
+
throw new CliError("configuration_error", `the api's server ${url} is not a URL without a user name`);
|
|
1190
|
+
return url;
|
|
1191
|
+
}, "manifestBaseUrl");
|
|
1192
|
+
var siteValue = /* @__PURE__ */ __name((raw) => {
|
|
1193
|
+
const text2 = raw.trim().replace(/^https:\/\//i, "").replace(/\/+$/, "");
|
|
1194
|
+
if (/^[a-z][a-z0-9+.-]*:\/\//i.test(text2))
|
|
1195
|
+
throw new CliError("validation_error", `--site takes an https address or a host, not ${JSON.stringify(raw)}`);
|
|
1196
|
+
const [host = "", ...path2] = serverValue("site", text2, "validation_error").split("/");
|
|
1197
|
+
const site = [host.toLowerCase(), ...path2].join("/");
|
|
1198
|
+
const url = URL.canParse(`https://${site}`) ? new URL(`https://${site}`) : void 0;
|
|
1199
|
+
if (!url || url.host !== site.split("/")[0] || url.pathname.replace(/\/$/, "") !== site.slice(site.split("/")[0]?.length))
|
|
1200
|
+
throw new CliError("validation_error", `--site ${JSON.stringify(raw)} is not a plain https address`);
|
|
1201
|
+
return site;
|
|
1202
|
+
}, "siteValue");
|
|
1203
|
+
var wholeHost = /* @__PURE__ */ __name((server, name) => server.url === `https://{${name}}` || server.url.startsWith(`https://{${name}}/`), "wholeHost");
|
|
1204
|
+
var labelValue = /* @__PURE__ */ __name((name, value) => {
|
|
1205
|
+
if (!/^[A-Za-z0-9](?:[A-Za-z0-9-]*[A-Za-z0-9])?$/.test(value))
|
|
1206
|
+
throw new CliError("configuration_error", `{${name}} ${JSON.stringify(value)} is not one name without dots`);
|
|
1207
|
+
return value;
|
|
1208
|
+
}, "labelValue");
|
|
1209
|
+
var serverValue = /* @__PURE__ */ __name((name, value, code = "configuration_error") => {
|
|
1210
|
+
if (!/^[A-Za-z0-9-]+(\.[A-Za-z0-9-]+)*(:\d+)?(\/[A-Za-z0-9._~%-]+)*$/.test(value))
|
|
1211
|
+
throw new CliError(code, `{${name}} ${JSON.stringify(value)} is not a host, with a port or a path if any`);
|
|
1212
|
+
return value;
|
|
1213
|
+
}, "serverValue");
|
|
1214
|
+
var isBasic = /* @__PURE__ */ __name((scheme) => scheme.type === "http" && /^basic$/i.test(scheme.scheme ?? ""), "isBasic");
|
|
1215
|
+
var BASIC = {
|
|
1216
|
+
in: "header",
|
|
1217
|
+
name: "authorization",
|
|
1218
|
+
value: /* @__PURE__ */ __name((token) => {
|
|
1219
|
+
if (!token.includes(":"))
|
|
1220
|
+
throw new CliError("authentication_error", "this service signs in with a user name and a password: run session start --login <name>");
|
|
1221
|
+
return `Basic ${Buffer.from(token).toString("base64")}`;
|
|
1222
|
+
}, "value")
|
|
1223
|
+
};
|
|
1224
|
+
var authOf = /* @__PURE__ */ __name((manifest, operation) => {
|
|
1225
|
+
const requirements = signInRequirements(operation, manifest.security);
|
|
1226
|
+
if (!requirements)
|
|
1227
|
+
return void 0;
|
|
1228
|
+
const names = requirements.flatMap((one) => Object.keys(one));
|
|
1229
|
+
const sendable = names.flatMap((name) => {
|
|
1230
|
+
const scheme = manifest.securitySchemes?.[name];
|
|
1231
|
+
if (!scheme)
|
|
1232
|
+
return [];
|
|
1233
|
+
const basic = isBasic(scheme);
|
|
1234
|
+
const place = basic ? BASIC : signInPlace(scheme);
|
|
1235
|
+
return place ? [{ place, basic }] : [];
|
|
1236
|
+
});
|
|
1237
|
+
const auth = (sendable.find((one) => one.place.in === "header" && !one.basic) ?? sendable.find((one) => !one.basic) ?? sendable[0])?.place;
|
|
1238
|
+
if (auth)
|
|
1239
|
+
return auth;
|
|
1240
|
+
throw new CliError("configuration_error", `${operation.command} signs in by ${names.join(" or ")}, which the api cannot send`);
|
|
1241
|
+
}, "authOf");
|
|
1242
|
+
var signRequest = /* @__PURE__ */ __name(async (manifest, operation, request, token) => {
|
|
1243
|
+
if (!token)
|
|
1244
|
+
return;
|
|
1245
|
+
const auth = authOf(manifest, operation);
|
|
1246
|
+
if (!auth)
|
|
1247
|
+
return;
|
|
1248
|
+
const value = auth.value(await token());
|
|
1249
|
+
if (auth.in === "query")
|
|
1250
|
+
request.url.searchParams.set(auth.name, value);
|
|
1251
|
+
else
|
|
1252
|
+
request.headers.set(auth.name, value);
|
|
1253
|
+
if (auth.in === "query" || auth.name !== "authorization")
|
|
1254
|
+
request.redirect = "manual";
|
|
1255
|
+
}, "signRequest");
|
|
1256
|
+
var underBase = /* @__PURE__ */ __name((url, baseUrl) => {
|
|
1257
|
+
const base = new URL(baseUrl);
|
|
1258
|
+
const prefix = base.pathname.endsWith("/") ? base.pathname : `${base.pathname}/`;
|
|
1259
|
+
return url.origin === base.origin && (url.pathname === base.pathname || url.pathname.startsWith(prefix));
|
|
1260
|
+
}, "underBase");
|
|
1261
|
+
var answerAt = /* @__PURE__ */ __name((value, path2) => path2 === "" ? value : path2.split(".").reduce((inner, key) => inner && typeof inner === "object" ? inner[key] : void 0, value), "answerAt");
|
|
1262
|
+
var numberOf = /* @__PURE__ */ __name((value) => {
|
|
1263
|
+
const number3 = typeof value === "number" ? value : typeof value === "string" ? Number(value) : Number(String(value));
|
|
1264
|
+
return Number.isFinite(number3) ? number3 : void 0;
|
|
1265
|
+
}, "numberOf");
|
|
1266
|
+
var parameterValue = /* @__PURE__ */ __name((input, parameter) => parameter.in === "query" ? input.query[parameter.name] : input.fields[parameter.name] ?? (input.body === void 0 ? void 0 : parseApiJson(input.body)?.[parameter.name]), "parameterValue");
|
|
1267
|
+
var withValue = /* @__PURE__ */ __name((input, parameter, value) => {
|
|
1268
|
+
if (parameter.in === "query")
|
|
1269
|
+
return { ...input, query: { ...input.query, [parameter.name]: String(value) } };
|
|
1270
|
+
const body = input.body === void 0 ? {} : parseApiJson(input.body);
|
|
1271
|
+
const { [parameter.name]: _, ...fields2 } = input.fields;
|
|
1272
|
+
return { ...input, fields: fields2, body: apiJson({ ...body, [parameter.name]: value }) };
|
|
1273
|
+
}, "withValue");
|
|
1274
|
+
var nextPage = /* @__PURE__ */ __name((pagination, input, answer, headers) => {
|
|
1275
|
+
const listed2 = pagination.items === void 0 ? [answer] : answerAt(answer, pagination.items);
|
|
1276
|
+
const items = Array.isArray(listed2) ? listed2 : [];
|
|
1277
|
+
switch (pagination.style) {
|
|
1278
|
+
case "cursor": {
|
|
1279
|
+
const cursor = answerAt(answer, pagination.next);
|
|
1280
|
+
const more = pagination.hasMore === void 0 || answerAt(answer, pagination.hasMore) !== false;
|
|
1281
|
+
return more && typeof cursor === "string" && cursor !== "" ? { items, next: { input: withValue(input, pagination.cursor, cursor) } } : { items };
|
|
749
1282
|
}
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
1283
|
+
case "offset":
|
|
1284
|
+
case "page": {
|
|
1285
|
+
const parameter = pagination.style === "offset" ? pagination.offset : pagination.page;
|
|
1286
|
+
const total = pagination.total === void 0 ? void 0 : numberOf(answerAt(answer, pagination.total));
|
|
1287
|
+
const current = numberOf(parameterValue(input, parameter)) ?? (pagination.style === "offset" ? 0 : pagination.start ?? 1);
|
|
1288
|
+
const next = pagination.style === "offset" ? current + items.length : current + 1;
|
|
1289
|
+
const pages = pagination.style === "page" && pagination.pagesHeader !== void 0 ? numberOf(headers?.get(pagination.pagesHeader) ?? void 0) : void 0;
|
|
1290
|
+
const last = items.length === 0 || total !== void 0 && pagination.style === "offset" && next >= total || pages !== void 0 && current >= pages;
|
|
1291
|
+
return last ? { items } : { items, next: { input: withValue(input, parameter, next) } };
|
|
1292
|
+
}
|
|
1293
|
+
case "link": {
|
|
1294
|
+
const url = answerAt(answer, pagination.next);
|
|
1295
|
+
return typeof url === "string" && url !== "" ? { items, next: { url } } : { items };
|
|
1296
|
+
}
|
|
1297
|
+
}
|
|
1298
|
+
}, "nextPage");
|
|
763
1299
|
|
|
764
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
1300
|
+
// 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/sends/guard.js
|
|
765
1301
|
import { randomUUID } from "node:crypto";
|
|
766
1302
|
|
|
767
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
768
|
-
import { mkdirSync, readFileSync, renameSync, writeFileSync } from "node:fs";
|
|
1303
|
+
// 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/sends/flood.js
|
|
1304
|
+
import { mkdirSync, readFileSync as readFileSync2, renameSync, writeFileSync } from "node:fs";
|
|
769
1305
|
import { dirname, join } from "node:path";
|
|
770
1306
|
var MOST_DEADLINES = 50;
|
|
771
1307
|
var LIMITED_HOLD_MS = 60 * 60 * 1e3;
|
|
@@ -779,8 +1315,8 @@ var FloodMemory = class {
|
|
|
779
1315
|
}
|
|
780
1316
|
path;
|
|
781
1317
|
now;
|
|
782
|
-
constructor(
|
|
783
|
-
this.path =
|
|
1318
|
+
constructor(path2, now = Date.now) {
|
|
1319
|
+
this.path = path2;
|
|
784
1320
|
this.now = now;
|
|
785
1321
|
}
|
|
786
1322
|
/** What is still in force; anything expired is left out. */
|
|
@@ -788,7 +1324,7 @@ var FloodMemory = class {
|
|
|
788
1324
|
const now = this.now();
|
|
789
1325
|
let raw;
|
|
790
1326
|
try {
|
|
791
|
-
raw = JSON.parse(
|
|
1327
|
+
raw = JSON.parse(readFileSync2(this.path, "utf8"));
|
|
792
1328
|
} catch {
|
|
793
1329
|
return { deadlines: [] };
|
|
794
1330
|
}
|
|
@@ -848,19 +1384,19 @@ var FloodMemory = class {
|
|
|
848
1384
|
}
|
|
849
1385
|
};
|
|
850
1386
|
|
|
851
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
852
|
-
import { appendFileSync, mkdirSync as mkdirSync3, readFileSync as
|
|
1387
|
+
// 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/sends/journal.js
|
|
1388
|
+
import { appendFileSync, mkdirSync as mkdirSync3, readFileSync as readFileSync3 } from "node:fs";
|
|
853
1389
|
import { dirname as dirname3, join as join2 } from "node:path";
|
|
854
1390
|
|
|
855
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
1391
|
+
// 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/sends/file-lock.js
|
|
856
1392
|
import { closeSync, mkdirSync as mkdirSync2, openSync, statSync, unlinkSync } from "node:fs";
|
|
857
1393
|
import { dirname as dirname2 } from "node:path";
|
|
858
1394
|
var LOCK_WAIT_MS = 5e3;
|
|
859
1395
|
var LOCK_STALE_MS = 3e4;
|
|
860
1396
|
var RETRY_MS = 20;
|
|
861
1397
|
var pause = new Int32Array(new SharedArrayBuffer(4));
|
|
862
|
-
var withFileLock = /* @__PURE__ */ __name((
|
|
863
|
-
const lock = lockFor(
|
|
1398
|
+
var withFileLock = /* @__PURE__ */ __name((path2, what, body, waitMs = LOCK_WAIT_MS) => {
|
|
1399
|
+
const lock = lockFor(path2);
|
|
864
1400
|
const deadline = Date.now() + waitMs;
|
|
865
1401
|
while (!taken(lock)) {
|
|
866
1402
|
if (Date.now() >= deadline)
|
|
@@ -869,8 +1405,8 @@ var withFileLock = /* @__PURE__ */ __name((path, what, body, waitMs = LOCK_WAIT_
|
|
|
869
1405
|
}
|
|
870
1406
|
return holding(lock, body);
|
|
871
1407
|
}, "withFileLock");
|
|
872
|
-
var withFileLockAsync = /* @__PURE__ */ __name(async (
|
|
873
|
-
const lock = lockFor(
|
|
1408
|
+
var withFileLockAsync = /* @__PURE__ */ __name(async (path2, what, body, waitMs = LOCK_WAIT_MS, sleep = realSleep) => {
|
|
1409
|
+
const lock = lockFor(path2);
|
|
874
1410
|
const deadline = Date.now() + waitMs;
|
|
875
1411
|
while (!taken(lock)) {
|
|
876
1412
|
if (Date.now() >= deadline)
|
|
@@ -879,9 +1415,9 @@ var withFileLockAsync = /* @__PURE__ */ __name(async (path, what, body, waitMs =
|
|
|
879
1415
|
}
|
|
880
1416
|
return holding(lock, body);
|
|
881
1417
|
}, "withFileLockAsync");
|
|
882
|
-
var lockFor = /* @__PURE__ */ __name((
|
|
883
|
-
mkdirSync2(dirname2(
|
|
884
|
-
return `${
|
|
1418
|
+
var lockFor = /* @__PURE__ */ __name((path2) => {
|
|
1419
|
+
mkdirSync2(dirname2(path2), { recursive: true, mode: 448 });
|
|
1420
|
+
return `${path2}.lock`;
|
|
885
1421
|
}, "lockFor");
|
|
886
1422
|
var taken = /* @__PURE__ */ __name((lock) => {
|
|
887
1423
|
for (; ; ) {
|
|
@@ -919,7 +1455,7 @@ var lockTime = /* @__PURE__ */ __name((lock) => {
|
|
|
919
1455
|
}
|
|
920
1456
|
}, "lockTime");
|
|
921
1457
|
|
|
922
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
1458
|
+
// 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/sends/journal.js
|
|
923
1459
|
var sendsPathFor = /* @__PURE__ */ __name((app, profile, env = process.env) => join2(resolvePaths({ appName: app.appName, prefix: app.envPrefix, env }).state, "sends", `${profile}.jsonl`), "sendsPathFor");
|
|
924
1460
|
var SendJournal = class {
|
|
925
1461
|
static {
|
|
@@ -927,8 +1463,8 @@ var SendJournal = class {
|
|
|
927
1463
|
}
|
|
928
1464
|
path;
|
|
929
1465
|
resource;
|
|
930
|
-
constructor(
|
|
931
|
-
this.path =
|
|
1466
|
+
constructor(path2, resource = { service: "unknown", version: "unknown" }) {
|
|
1467
|
+
this.path = path2;
|
|
932
1468
|
this.resource = resource;
|
|
933
1469
|
}
|
|
934
1470
|
/**
|
|
@@ -943,12 +1479,12 @@ var SendJournal = class {
|
|
|
943
1479
|
return withFileLockAsync(this.path, "the send journal", body);
|
|
944
1480
|
}
|
|
945
1481
|
append(entry) {
|
|
946
|
-
const { at, ...attributes } = entry;
|
|
1482
|
+
const { at: at2, ...attributes } = entry;
|
|
947
1483
|
const { runId, command, traceId } = currentRun();
|
|
948
|
-
const
|
|
1484
|
+
const record2 = logRecordOf({
|
|
949
1485
|
severity: entry.outcome === "sent" || entry.outcome === "reserved" ? "info" : "warn",
|
|
950
1486
|
event: logAttributes({ event: "send.recorded", ...attributes }),
|
|
951
|
-
time:
|
|
1487
|
+
time: at2,
|
|
952
1488
|
runId,
|
|
953
1489
|
...traceId === void 0 ? {} : { traceId },
|
|
954
1490
|
command,
|
|
@@ -956,7 +1492,7 @@ var SendJournal = class {
|
|
|
956
1492
|
allow: LOG_ATTRIBUTES
|
|
957
1493
|
});
|
|
958
1494
|
mkdirSync3(dirname3(this.path), { recursive: true, mode: 448 });
|
|
959
|
-
appendFileSync(this.path, `${JSON.stringify(
|
|
1495
|
+
appendFileSync(this.path, `${JSON.stringify(record2)}
|
|
960
1496
|
`, { mode: 384 });
|
|
961
1497
|
}
|
|
962
1498
|
/**
|
|
@@ -972,7 +1508,7 @@ var SendJournal = class {
|
|
|
972
1508
|
#lines() {
|
|
973
1509
|
let text2;
|
|
974
1510
|
try {
|
|
975
|
-
text2 =
|
|
1511
|
+
text2 = readFileSync3(this.path, "utf8");
|
|
976
1512
|
} catch {
|
|
977
1513
|
return [];
|
|
978
1514
|
}
|
|
@@ -996,8 +1532,8 @@ var withSendId = /* @__PURE__ */ __name((entry) => {
|
|
|
996
1532
|
return cid === void 0 || rest.sendId !== void 0 ? rest : { ...rest, sendId: String(cid) };
|
|
997
1533
|
}, "withSendId");
|
|
998
1534
|
|
|
999
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
1000
|
-
import { existsSync, readFileSync as
|
|
1535
|
+
// 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/sends/recipients.js
|
|
1536
|
+
import { existsSync, readFileSync as readFileSync4, rmSync } from "node:fs";
|
|
1001
1537
|
import { join as join3 } from "node:path";
|
|
1002
1538
|
var recipientsPathFor = /* @__PURE__ */ __name((app, profile, env = process.env) => join3(resolvePaths({ appName: app.appName, prefix: app.envPrefix, env }).state, "profiles", `${profile}.recipients.json`), "recipientsPathFor");
|
|
1003
1539
|
var RecipientList = class {
|
|
@@ -1008,8 +1544,8 @@ var RecipientList = class {
|
|
|
1008
1544
|
command;
|
|
1009
1545
|
lockWaitMs;
|
|
1010
1546
|
/** `command` names the program in the hint that turns the list off. */
|
|
1011
|
-
constructor(
|
|
1012
|
-
this.path =
|
|
1547
|
+
constructor(path2, command, lockWaitMs) {
|
|
1548
|
+
this.path = path2;
|
|
1013
1549
|
this.command = command;
|
|
1014
1550
|
this.lockWaitMs = lockWaitMs;
|
|
1015
1551
|
}
|
|
@@ -1018,7 +1554,7 @@ var RecipientList = class {
|
|
|
1018
1554
|
if (!existsSync(this.path))
|
|
1019
1555
|
return void 0;
|
|
1020
1556
|
try {
|
|
1021
|
-
const parsed = JSON.parse(
|
|
1557
|
+
const parsed = JSON.parse(readFileSync4(this.path, "utf8"));
|
|
1022
1558
|
if (!Array.isArray(parsed.chats))
|
|
1023
1559
|
throw new Error("no `chats` array");
|
|
1024
1560
|
return parsed.chats;
|
|
@@ -1108,10 +1644,10 @@ var RecipientList = class {
|
|
|
1108
1644
|
}
|
|
1109
1645
|
};
|
|
1110
1646
|
|
|
1111
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
1647
|
+
// 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/sends/guard.js
|
|
1112
1648
|
var HOUR_MS = 60 * 60 * 1e3;
|
|
1113
|
-
var countsTowardLimit = /* @__PURE__ */ __name(({ kind = "message", action, notify }) =>
|
|
1114
|
-
var weightOf = /* @__PURE__ */ __name(({ kind = "message", action, count
|
|
1649
|
+
var countsTowardLimit = /* @__PURE__ */ __name(({ kind: kind2 = "message", action, notify }) => kind2 === "message" || kind2 === "forward" || kind2 === "edit" || kind2 === "delete" || kind2 === "pin" && notify === true || action === "create" || action === "members.add" || action === "requests.accept" || action === "join" || action === "contact-import", "countsTowardLimit");
|
|
1650
|
+
var weightOf = /* @__PURE__ */ __name(({ kind: kind2 = "message", action, count, people }) => kind2 === "delete" || kind2 === "message" && action === void 0 ? Math.max(1, count ?? 1) : action === "create" || action === "members.add" || action === "requests.accept" || action === "contact-import" ? Math.max(1, people ?? count ?? 1) : 1, "weightOf");
|
|
1115
1651
|
var timeOf = /* @__PURE__ */ __name((entry) => {
|
|
1116
1652
|
const scheduled = entry.scheduledFor === void 0 ? Number.NaN : Date.parse(entry.scheduledFor);
|
|
1117
1653
|
return Number.isNaN(scheduled) ? Date.parse(entry.at) : scheduled;
|
|
@@ -1137,11 +1673,11 @@ var sendGuard = /* @__PURE__ */ __name(({ profile, recipients, command = recipie
|
|
|
1137
1673
|
throw new CliError("permission_error", `profile ${profile} holds its writes ${holdEnd(block)}: ${block.hint} \u2014 reads still work; do not retry: the owner checks the account with \`${command} ${profile} doctor --online\`, and lifts the hold with \`${command} ${profile} flood clear\` once it is over`, { sendBlock: block, standing: { state: block.state, hint: block.hint } });
|
|
1138
1674
|
}, "refuseHeld");
|
|
1139
1675
|
const permitted = /* @__PURE__ */ __name((request) => {
|
|
1140
|
-
const { chatId, kind = "message", action, personIds } = request;
|
|
1676
|
+
const { chatId, kind: kind2 = "message", action, personIds } = request;
|
|
1141
1677
|
refuseReadOnly(request);
|
|
1142
1678
|
const levels = currentPermissions();
|
|
1143
1679
|
if (levels !== void 0) {
|
|
1144
|
-
const key = request.key ?? keyForWrite(
|
|
1680
|
+
const key = request.key ?? keyForWrite(kind2, action);
|
|
1145
1681
|
const { level, key: named2 } = levelFor(levels, key, permissionDefaults);
|
|
1146
1682
|
if (stops(level, key))
|
|
1147
1683
|
throw levelRefusal({ profile, command, key, level, named: named2, permissionSources }, permissionFix?.(request, key));
|
|
@@ -1161,14 +1697,14 @@ var sendGuard = /* @__PURE__ */ __name(({ profile, recipients, command = recipie
|
|
|
1161
1697
|
const withinLimit = /* @__PURE__ */ __name((request, entries) => {
|
|
1162
1698
|
const { chatId, sendId } = request;
|
|
1163
1699
|
const asked = { ...request, people: request.personIds?.length ?? request.count };
|
|
1164
|
-
const
|
|
1165
|
-
if (
|
|
1166
|
-
throw new CliError("rate_limited", `${
|
|
1700
|
+
const count = weightOf(asked);
|
|
1701
|
+
if (count > sendsPerHour) {
|
|
1702
|
+
throw new CliError("rate_limited", `${count} at once is more than the hourly limit of profile ${profile} (sendsPerHour ${sendsPerHour}) \u2014 do fewer at a time`);
|
|
1167
1703
|
}
|
|
1168
|
-
const
|
|
1169
|
-
if (Number.isNaN(
|
|
1704
|
+
const at2 = request.scheduledFor ? Date.parse(request.scheduledFor) : now().getTime();
|
|
1705
|
+
if (Number.isNaN(at2))
|
|
1170
1706
|
throw new CliError("validation_error", `"${request.scheduledFor}" is not a time to send at \u2014 use ISO 8601`);
|
|
1171
|
-
const counted = entries.filter(countsTowardLimit).filter((entry) => entry.outcome === "sent" || entry.outcome === "outcome_unknown" || entry.outcome === "reserved").filter((entry) => Math.abs(timeOf(entry) -
|
|
1707
|
+
const counted = entries.filter(countsTowardLimit).filter((entry) => entry.outcome === "sent" || entry.outcome === "outcome_unknown" || entry.outcome === "reserved").filter((entry) => Math.abs(timeOf(entry) - at2) < HOUR_MS);
|
|
1172
1708
|
const unsure = /* @__PURE__ */ __name((entry) => entry.outcome === "outcome_unknown", "unsure");
|
|
1173
1709
|
const same = /* @__PURE__ */ __name((a, b) => a.sendId !== void 0 && a.sendId === b.sendId && a.chatId === b.chatId, "same");
|
|
1174
1710
|
const last = [...counted].reverse().find((entry) => same(entry, { chatId, sendId }));
|
|
@@ -1180,15 +1716,15 @@ var sendGuard = /* @__PURE__ */ __name(({ profile, recipients, command = recipie
|
|
|
1180
1716
|
}
|
|
1181
1717
|
const recent = counted.filter((entry, index) => !(unsure(entry) && counted.slice(index + 1).some((later) => same(later, entry)))).map((entry) => ({ time: timeOf(entry), weight: weightOf(entry) })).sort((a, b) => a.time - b.time);
|
|
1182
1718
|
const used = recent.reduce((sum, { weight }) => sum + weight, 0);
|
|
1183
|
-
if (used +
|
|
1719
|
+
if (used + count > sendsPerHour) {
|
|
1184
1720
|
let freed = 0;
|
|
1185
1721
|
const opening = recent.find(({ weight }) => {
|
|
1186
1722
|
freed += weight;
|
|
1187
|
-
return used - freed +
|
|
1723
|
+
return used - freed + count <= sendsPerHour;
|
|
1188
1724
|
});
|
|
1189
1725
|
const nextMs = (opening?.time ?? 0) + HOUR_MS;
|
|
1190
1726
|
const next = new Date(nextMs).toISOString();
|
|
1191
|
-
throw new CliError("rate_limited", `profile ${profile} has sent ${used} messages in the hour around ${new Date(
|
|
1727
|
+
throw new CliError("rate_limited", `profile ${profile} has sent ${used} messages in the hour around ${new Date(at2).toISOString()}, and its limit is ${sendsPerHour} (sendsPerHour) \u2014 the next send is possible at ${next}`, { retry_after_ms: nextMs - now().getTime(), retry_at: next });
|
|
1192
1728
|
}
|
|
1193
1729
|
return true;
|
|
1194
1730
|
}, "withinLimit");
|
|
@@ -1213,16 +1749,16 @@ var sendGuard = /* @__PURE__ */ __name(({ profile, recipients, command = recipie
|
|
|
1213
1749
|
if (!checked(journal.entries()))
|
|
1214
1750
|
return;
|
|
1215
1751
|
const id2 = randomUUID();
|
|
1216
|
-
const { chatId, kind, action, sendId, operationId, scheduledFor, notify } = request;
|
|
1752
|
+
const { chatId, kind: kind2, action, sendId, operationId, scheduledFor, notify } = request;
|
|
1217
1753
|
journal.append({
|
|
1218
1754
|
at: now().toISOString(),
|
|
1219
1755
|
profile,
|
|
1220
1756
|
chatId,
|
|
1221
1757
|
outcome: "reserved",
|
|
1222
1758
|
reservation: id2,
|
|
1223
|
-
...
|
|
1759
|
+
...kind2 ? { kind: kind2 } : {},
|
|
1224
1760
|
...action ? { action } : {},
|
|
1225
|
-
...asked.people === void 0 ? {} :
|
|
1761
|
+
...asked.people === void 0 ? {} : kind2 === "delete" || kind2 === "message" || kind2 === void 0 ? { count: asked.people } : { people: asked.people },
|
|
1226
1762
|
...sendId === void 0 ? {} : { sendId },
|
|
1227
1763
|
...operationId === void 0 ? {} : { operationId },
|
|
1228
1764
|
...scheduledFor ? { scheduledFor } : {},
|
|
@@ -1296,7 +1832,7 @@ var guardFor = /* @__PURE__ */ __name((app, settings, warn, env = process.env, a
|
|
|
1296
1832
|
}), "guardFor");
|
|
1297
1833
|
var journalFailure = /* @__PURE__ */ __name((error) => error?.code ?? (error instanceof Error ? error.name : "error"), "journalFailure");
|
|
1298
1834
|
|
|
1299
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
1835
|
+
// 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/sends/keyed-guard.js
|
|
1300
1836
|
var keyedGuard = /* @__PURE__ */ __name((build, ask, levelOf, extra) => {
|
|
1301
1837
|
let question;
|
|
1302
1838
|
let answered = false;
|
|
@@ -1339,32 +1875,37 @@ var keyedGuard = /* @__PURE__ */ __name((build, ask, levelOf, extra) => {
|
|
|
1339
1875
|
};
|
|
1340
1876
|
}, "keyedGuard");
|
|
1341
1877
|
|
|
1342
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
1878
|
+
// 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/sends/send-id.js
|
|
1343
1879
|
import { randomBytes } from "node:crypto";
|
|
1344
1880
|
var newSendId = /* @__PURE__ */ __name(() => randomBytes(8).readBigInt64BE().toString(), "newSendId");
|
|
1345
1881
|
var newOperationId = newSendId;
|
|
1346
1882
|
|
|
1347
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
1348
|
-
import { readFileSync as
|
|
1883
|
+
// 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/foreign-contacts.js
|
|
1884
|
+
import { readFileSync as readFileSync5 } from "node:fs";
|
|
1349
1885
|
import { join as join4 } from "node:path";
|
|
1886
|
+
|
|
1887
|
+
// 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/state-folders.js
|
|
1888
|
+
var CRM_SHARED_FOLDERS = { files: "files", foreignContacts: "foreign-contacts" };
|
|
1889
|
+
|
|
1890
|
+
// 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/foreign-contacts.js
|
|
1350
1891
|
var DAILY_FOREIGN_CONTACTS = 100;
|
|
1351
|
-
var foreignContactsPathFor = /* @__PURE__ */ __name((app, account, env = process.env, user) => join4(resolvePaths({ appName: app.appName, prefix: app.envPrefix, env }).state, "crm",
|
|
1892
|
+
var foreignContactsPathFor = /* @__PURE__ */ __name((app, account, env = process.env, user) => join4(resolvePaths({ appName: app.appName, prefix: app.envPrefix, env }).state, "crm", CRM_SHARED_FOLDERS.foreignContacts, `${[account.provider, account.account, ...user ? [user] : []].join("-").replace(/[^\w.-]+/gu, "_")}.json`), "foreignContactsPathFor");
|
|
1352
1893
|
var shownIn = /* @__PURE__ */ __name((file, day) => {
|
|
1353
1894
|
try {
|
|
1354
|
-
const found = JSON.parse(
|
|
1895
|
+
const found = JSON.parse(readFileSync5(file, "utf8"));
|
|
1355
1896
|
return found.day === day && Array.isArray(found.seen) ? { day, seen: found.seen.map(String) } : { day, seen: [] };
|
|
1356
1897
|
} catch {
|
|
1357
1898
|
return { day, seen: [] };
|
|
1358
1899
|
}
|
|
1359
1900
|
}, "shownIn");
|
|
1360
|
-
var stripped = /* @__PURE__ */ __name((
|
|
1361
|
-
const { phones, emails, email, phone, contactTypes: _types, ...rest } =
|
|
1901
|
+
var stripped = /* @__PURE__ */ __name((record2, fields2) => {
|
|
1902
|
+
const { phones, emails, email, phone, contactTypes: _types, ...rest } = record2;
|
|
1362
1903
|
const own = new Set([...phones ?? [], ...emails ?? [], email, phone].filter((one) => !!one));
|
|
1363
|
-
const holding2 = new Set(
|
|
1904
|
+
const holding2 = new Set(fields2.filter((field) => field.holds).map((field) => field.code));
|
|
1364
1905
|
const repeats = /* @__PURE__ */ __name((value) => (Array.isArray(value) ? value : [value]).some((one) => typeof one === "string" && own.has(one.trim())), "repeats");
|
|
1365
1906
|
const metadata = rest.metadata;
|
|
1366
1907
|
if (metadata)
|
|
1367
|
-
rest.metadata =
|
|
1908
|
+
rest.metadata = fields2.length ? Object.fromEntries(Object.entries(metadata).filter(([code, one]) => !holding2.has(code) && !repeats(one.value))) : {};
|
|
1368
1909
|
return rest;
|
|
1369
1910
|
}, "stripped");
|
|
1370
1911
|
var foreignContacts = /* @__PURE__ */ __name((source, file, options = {}) => {
|
|
@@ -1376,44 +1917,44 @@ var foreignContacts = /* @__PURE__ */ __name((source, file, options = {}) => {
|
|
|
1376
1917
|
admin ??= source.isAdmin();
|
|
1377
1918
|
return !await admin;
|
|
1378
1919
|
}, "limited");
|
|
1379
|
-
const own = /* @__PURE__ */ __name(async (
|
|
1920
|
+
const own = /* @__PURE__ */ __name(async (kind2, records) => {
|
|
1380
1921
|
const self = source.self ? String(await source.self()) : void 0;
|
|
1381
1922
|
const mine = new Set(records.filter((one) => self && one.assignee === self).map((one) => one.externalId));
|
|
1382
1923
|
const rest = records.filter((one) => !mine.has(one.externalId)).map((one) => one.externalId);
|
|
1383
|
-
if (rest.length && source.ownClients && (
|
|
1384
|
-
for (const id2 of await source.ownClients(
|
|
1924
|
+
if (rest.length && source.ownClients && (kind2 === "person" || kind2 === "organization"))
|
|
1925
|
+
for (const id2 of await source.ownClients(kind2, rest))
|
|
1385
1926
|
mine.add(id2);
|
|
1386
1927
|
return mine;
|
|
1387
1928
|
}, "own");
|
|
1388
1929
|
return {
|
|
1389
|
-
async strip(
|
|
1930
|
+
async strip(kind2, records) {
|
|
1390
1931
|
if (!await limited() || records.length === 0)
|
|
1391
1932
|
return records;
|
|
1392
|
-
const mine = await own(
|
|
1933
|
+
const mine = await own(kind2, records);
|
|
1393
1934
|
if (records.every((one) => mine.has(one.externalId)))
|
|
1394
1935
|
return records;
|
|
1395
|
-
definitions[
|
|
1396
|
-
const
|
|
1397
|
-
return records.map((one) => mine.has(one.externalId) ? one : stripped(one,
|
|
1936
|
+
definitions[kind2] ??= Promise.resolve(source.fields?.(kind2)).then((found) => found ?? []);
|
|
1937
|
+
const fields2 = await definitions[kind2];
|
|
1938
|
+
return records.map((one) => mine.has(one.externalId) ? one : stripped(one, fields2));
|
|
1398
1939
|
},
|
|
1399
|
-
async own(
|
|
1400
|
-
return !await limited() || (await own(
|
|
1940
|
+
async own(kind2, record2) {
|
|
1941
|
+
return !await limited() || (await own(kind2, [record2])).has(record2.externalId);
|
|
1401
1942
|
},
|
|
1402
|
-
async spend(
|
|
1403
|
-
if (!await limited() || (await own(
|
|
1943
|
+
async spend(kind2, record2) {
|
|
1944
|
+
if (!await limited() || (await own(kind2, [record2])).has(record2.externalId))
|
|
1404
1945
|
return;
|
|
1405
|
-
const key = `${
|
|
1946
|
+
const key = `${kind2}:${record2.externalId}`;
|
|
1406
1947
|
if (!file)
|
|
1407
1948
|
throw new Error("foreignContacts: spend needs the count file");
|
|
1408
|
-
const
|
|
1949
|
+
const path2 = await file();
|
|
1409
1950
|
const day = new Date(options.now?.() ?? Date.now()).toISOString().slice(0, 10);
|
|
1410
|
-
await withFileLockAsync(
|
|
1411
|
-
const shown = shownIn(
|
|
1951
|
+
await withFileLockAsync(path2, "the day's count of foreign contacts", () => {
|
|
1952
|
+
const shown = shownIn(path2, day);
|
|
1412
1953
|
if (shown.seen.includes(key))
|
|
1413
1954
|
return;
|
|
1414
1955
|
if (shown.seen.length >= DAILY_FOREIGN_CONTACTS)
|
|
1415
1956
|
throw new CliError("permission_error", `${DAILY_FOREIGN_CONTACTS} records that are not yours (contacts, companies, or the files of deals, leads, contacts and companies) were read today, the most a day; your own records are not counted, and the CRM's administrator has no limit`, { reason: "crm.foreign-contacts-spent", limit: DAILY_FOREIGN_CONTACTS });
|
|
1416
|
-
writeSecurely(
|
|
1957
|
+
writeSecurely(path2, JSON.stringify({ day, seen: [...shown.seen, key] }), 384);
|
|
1417
1958
|
}, options.lockWaitMs);
|
|
1418
1959
|
}
|
|
1419
1960
|
};
|
|
@@ -1424,7 +1965,7 @@ var refuseForeignClientReads = /* @__PURE__ */ __name(async (source, readsClient
|
|
|
1424
1965
|
throw new CliError("permission_error", `${method} reads contacts or companies, which only the CRM's administrator reads through api call: your clients come with sync, and another one with people show or organizations show, ${DAILY_FOREIGN_CONTACTS} a day`, { reason: "crm.client-reads-admin-only", sent: false });
|
|
1425
1966
|
}, "refuseForeignClientReads");
|
|
1426
1967
|
|
|
1427
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
1968
|
+
// 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/writer.js
|
|
1428
1969
|
var CRM_ASSIGN_OTHERS_KEY = "crm.assign-others";
|
|
1429
1970
|
var CRM_WRITE_KEYS = [CRM_ASSIGN_OTHERS_KEY];
|
|
1430
1971
|
var PLURALS = {
|
|
@@ -1440,16 +1981,16 @@ var VERB_OF = {
|
|
|
1440
1981
|
close: "close",
|
|
1441
1982
|
delete: "remove"
|
|
1442
1983
|
};
|
|
1443
|
-
var crmAlsoChecks = /* @__PURE__ */ __name((also) => (
|
|
1444
|
-
const [noun, command] =
|
|
1445
|
-
const
|
|
1984
|
+
var crmAlsoChecks = /* @__PURE__ */ __name((also) => (path2) => {
|
|
1985
|
+
const [noun, command] = path2;
|
|
1986
|
+
const kind2 = noun === void 0 ? void 0 : PLURALS[noun];
|
|
1446
1987
|
const verb = command === void 0 ? void 0 : VERB_OF[command];
|
|
1447
|
-
if (
|
|
1988
|
+
if (path2.length !== 2 || kind2 === void 0 || verb === void 0)
|
|
1448
1989
|
return [];
|
|
1449
1990
|
const close = { key: `${noun}.close`, when: "a won or lost stage" };
|
|
1450
1991
|
const assign = { key: CRM_ASSIGN_OTHERS_KEY, when: "--owner other than the sign-in's user" };
|
|
1451
|
-
const implied =
|
|
1452
|
-
return [...implied, ...also?.(
|
|
1992
|
+
const implied = kind2 === "person" || kind2 === "organization" ? verb === "create" || verb === "update" ? [assign] : [] : verb === "create" || verb === "update" ? [{ key: `${noun}.move`, when: "--stage" }, close, assign] : verb === "move" ? [close] : [];
|
|
1993
|
+
return [...implied, ...also?.(kind2, verb) ?? []];
|
|
1453
1994
|
}, "crmAlsoChecks");
|
|
1454
1995
|
var CRM_WRITE_DEFAULTS = {
|
|
1455
1996
|
"deals.delete": "ask",
|
|
@@ -1457,7 +1998,7 @@ var CRM_WRITE_DEFAULTS = {
|
|
|
1457
1998
|
[CRM_ASSIGN_OTHERS_KEY]: "deny"
|
|
1458
1999
|
};
|
|
1459
2000
|
|
|
1460
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
2001
|
+
// 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/writes.js
|
|
1461
2002
|
var moneyChecked = /* @__PURE__ */ __name((check, param) => {
|
|
1462
2003
|
try {
|
|
1463
2004
|
check();
|
|
@@ -1480,17 +2021,17 @@ var COMMAND = {
|
|
|
1480
2021
|
close: "close",
|
|
1481
2022
|
remove: "delete"
|
|
1482
2023
|
};
|
|
1483
|
-
var keyOf2 = /* @__PURE__ */ __name((
|
|
2024
|
+
var keyOf2 = /* @__PURE__ */ __name((kind2, verb) => `${PLURAL[kind2]}.${COMMAND[verb]}`, "keyOf");
|
|
1484
2025
|
var OPERATION_ID = /^[\x21-\x7e]{1,255}$/u;
|
|
1485
|
-
var
|
|
2026
|
+
var DECIMAL2 = /^\d{1,16}(\.\d{1,6})?$/u;
|
|
1486
2027
|
var CURRENCY = /^[A-Z]{3}$/u;
|
|
1487
2028
|
var DAY = /^\d{4}-\d{2}-\d{2}$/u;
|
|
1488
2029
|
var FIELD_CODE = /^[A-Za-z][\w.-]{0,99}$/u;
|
|
1489
2030
|
var invalid = /* @__PURE__ */ __name((message, param) => new CliError("validation_error", message, { reason: "deal.field", ...param ? { param } : {} }), "invalid");
|
|
1490
|
-
var supported = /* @__PURE__ */ __name((writer,
|
|
2031
|
+
var supported = /* @__PURE__ */ __name((writer, kind2, verb) => {
|
|
1491
2032
|
const { kinds, verbs } = writer.capabilities;
|
|
1492
|
-
if (!kinds.includes(
|
|
1493
|
-
throw new CliError("validation_error", `this CRM does not take a ${COMMAND[verb]} of ${PLURAL[
|
|
2033
|
+
if (!kinds.includes(kind2) || !verbs.includes(verb))
|
|
2034
|
+
throw new CliError("validation_error", `this CRM does not take a ${COMMAND[verb]} of ${PLURAL[kind2]}`, {
|
|
1494
2035
|
reason: "crm.write-unsupported",
|
|
1495
2036
|
sent: false
|
|
1496
2037
|
});
|
|
@@ -1507,9 +2048,9 @@ var operationOf = /* @__PURE__ */ __name((context, given) => {
|
|
|
1507
2048
|
});
|
|
1508
2049
|
return given;
|
|
1509
2050
|
}, "operationOf");
|
|
1510
|
-
var copyOf = /* @__PURE__ */ __name(async (context,
|
|
1511
|
-
if (!reference.startsWith(`${
|
|
1512
|
-
throw new CliError("validation_error", `name the ${
|
|
2051
|
+
var copyOf = /* @__PURE__ */ __name(async (context, kind2, reference) => {
|
|
2052
|
+
if (!reference.startsWith(`${kind2}:`))
|
|
2053
|
+
throw new CliError("validation_error", `name the ${kind2} as ${kind2}:<id>, as a list shows it`, {
|
|
1513
2054
|
reason: "ref.malformed"
|
|
1514
2055
|
});
|
|
1515
2056
|
const found = await context.store.deals.get(reference);
|
|
@@ -1518,8 +2059,8 @@ var copyOf = /* @__PURE__ */ __name(async (context, kind, reference) => {
|
|
|
1518
2059
|
throw new CliError("not_found", `${reference} is not a copy from this profile's CRM account`);
|
|
1519
2060
|
return found;
|
|
1520
2061
|
}, "copyOf");
|
|
1521
|
-
var pipelineOf = /* @__PURE__ */ __name(async (context,
|
|
1522
|
-
const scope = { ...window, ...
|
|
2062
|
+
var pipelineOf = /* @__PURE__ */ __name(async (context, kind2, reference, param = "--pipeline", window = {}) => {
|
|
2063
|
+
const scope = { ...window, ...kind2 ? { kind: kind2 } : {}, account: context.account };
|
|
1523
2064
|
if (reference !== void 0) {
|
|
1524
2065
|
const found = await context.store.deals.pipeline(reference, scope);
|
|
1525
2066
|
if (found.externalId === null)
|
|
@@ -1529,7 +2070,7 @@ var pipelineOf = /* @__PURE__ */ __name(async (context, kind, reference, param =
|
|
|
1529
2070
|
const all = await context.store.deals.pipelines(scope);
|
|
1530
2071
|
if (all.length === 1)
|
|
1531
2072
|
return context.store.deals.pipeline(all[0].ref, scope);
|
|
1532
|
-
const what =
|
|
2073
|
+
const what = kind2 ? `${kind2} pipeline` : "pipeline";
|
|
1533
2074
|
throw new CliError("validation_error", all.length === 0 ? `no ${what} of this CRM is stored; run sync first` : `this CRM has ${all.length} ${what}s; name one${param.startsWith("--") ? ` with ${param}` : ""}: ` + all.map(({ name, ref }) => `${name} (${ref})`).join(", "), { reason: "crm.pipeline-required", param, allowed: all.map(({ ref }) => ref) });
|
|
1534
2075
|
}, "pipelineOf");
|
|
1535
2076
|
var stageOf = /* @__PURE__ */ __name((pipeline, given) => {
|
|
@@ -1547,58 +2088,58 @@ var validDay = /* @__PURE__ */ __name((text2) => {
|
|
|
1547
2088
|
return DAY.test(text2) && !Number.isNaN(date.getTime()) && date.toISOString().startsWith(text2);
|
|
1548
2089
|
}, "validDay");
|
|
1549
2090
|
var fieldsOf = /* @__PURE__ */ __name((input, pipeline, currency) => {
|
|
1550
|
-
const
|
|
2091
|
+
const fields2 = {};
|
|
1551
2092
|
if (input.title !== void 0) {
|
|
1552
2093
|
if (!input.title.trim())
|
|
1553
2094
|
throw invalid("a title is never empty", "--title");
|
|
1554
|
-
|
|
2095
|
+
fields2.title = input.title.trim();
|
|
1555
2096
|
}
|
|
1556
2097
|
if (pipeline && input.pipeline !== void 0)
|
|
1557
|
-
|
|
2098
|
+
fields2.pipeline = pipeline.externalId;
|
|
1558
2099
|
const stage = pipeline && input.stage !== void 0 ? stageOf(pipeline, input.stage) : void 0;
|
|
1559
2100
|
if (stage)
|
|
1560
|
-
|
|
2101
|
+
fields2.stage = stage.externalId;
|
|
1561
2102
|
if (input.amount !== void 0 || input.currency !== void 0) {
|
|
1562
2103
|
const code = (input.currency ?? currency ?? "").toUpperCase();
|
|
1563
2104
|
if (input.amount === void 0)
|
|
1564
2105
|
throw invalid("--currency goes with --amount", "--amount");
|
|
1565
|
-
if (!
|
|
2106
|
+
if (!DECIMAL2.test(input.amount))
|
|
1566
2107
|
throw invalid("--amount is a decimal such as 1500.50", "--amount");
|
|
1567
2108
|
if (!CURRENCY.test(code))
|
|
1568
2109
|
throw invalid("--amount needs --currency, an ISO 4217 code such as EUR", "--currency");
|
|
1569
2110
|
moneyChecked(() => currencyOf(code), "--currency");
|
|
1570
2111
|
moneyChecked(() => minorUnits(input.amount, code, "--amount"), "--amount");
|
|
1571
|
-
|
|
1572
|
-
|
|
2112
|
+
fields2.amount = input.amount;
|
|
2113
|
+
fields2.currency = code;
|
|
1573
2114
|
}
|
|
1574
2115
|
if (input.closeDate !== void 0) {
|
|
1575
2116
|
if (!validDay(input.closeDate))
|
|
1576
2117
|
throw invalid("--close-date is a day, YYYY-MM-DD", "--close-date");
|
|
1577
|
-
|
|
2118
|
+
fields2.closeDate = input.closeDate;
|
|
1578
2119
|
}
|
|
1579
2120
|
if (input.owner !== void 0) {
|
|
1580
2121
|
if (!input.owner.trim())
|
|
1581
2122
|
throw invalid("--owner is the CRM user's id", "--owner");
|
|
1582
|
-
|
|
2123
|
+
fields2.owner = input.owner.trim();
|
|
1583
2124
|
}
|
|
1584
|
-
return { fields, stage };
|
|
2125
|
+
return { fields: fields2, stage };
|
|
1585
2126
|
}, "fieldsOf");
|
|
1586
2127
|
var foldFieldName = /* @__PURE__ */ __name((name) => foldName(name.trim()).replace(/[\s_]+/gu, " "), "foldFieldName");
|
|
1587
2128
|
var named = /* @__PURE__ */ __name(({ code, label }) => ({ code, label }), "named");
|
|
1588
|
-
var unknownField = /* @__PURE__ */ __name((
|
|
2129
|
+
var unknownField = /* @__PURE__ */ __name((fields2, name, param = "--field") => {
|
|
1589
2130
|
const want = foldFieldName(name);
|
|
1590
|
-
const close =
|
|
2131
|
+
const close = fields2.filter((field) => [field.code, field.label ?? ""].some((one) => {
|
|
1591
2132
|
const other = foldFieldName(one);
|
|
1592
2133
|
return other !== "" && (other.includes(want) || want.includes(other));
|
|
1593
2134
|
}));
|
|
1594
2135
|
return new CliError("validation_error", `no custom field is named ${name}${close.length ? "; close ones are in candidates" : ""} \u2014 \`fields list\` lists them`, { reason: "field.unknown", param, candidates: close.map(named) });
|
|
1595
2136
|
}, "unknownField");
|
|
1596
|
-
var fieldNamed = /* @__PURE__ */ __name((
|
|
2137
|
+
var fieldNamed = /* @__PURE__ */ __name((fields2, name, param = "--field") => {
|
|
1597
2138
|
const want = foldFieldName(name);
|
|
1598
|
-
const byCode =
|
|
2139
|
+
const byCode = fields2.find((field) => foldFieldName(field.code) === want);
|
|
1599
2140
|
if (byCode)
|
|
1600
2141
|
return byCode;
|
|
1601
|
-
const labelled =
|
|
2142
|
+
const labelled = fields2.filter((field) => field.label !== null && foldFieldName(field.label) === want);
|
|
1602
2143
|
if (labelled.length === 1)
|
|
1603
2144
|
return labelled[0];
|
|
1604
2145
|
if (labelled.length > 1)
|
|
@@ -1607,7 +2148,7 @@ var fieldNamed = /* @__PURE__ */ __name((fields, name, param = "--field") => {
|
|
|
1607
2148
|
param,
|
|
1608
2149
|
candidates: labelled.map(named)
|
|
1609
2150
|
});
|
|
1610
|
-
throw unknownField(
|
|
2151
|
+
throw unknownField(fields2, name, param);
|
|
1611
2152
|
}, "fieldNamed");
|
|
1612
2153
|
var optionOf = /* @__PURE__ */ __name((field, value, param = "--field") => {
|
|
1613
2154
|
if (!field.options)
|
|
@@ -1633,15 +2174,15 @@ var optionOf = /* @__PURE__ */ __name((field, value, param = "--field") => {
|
|
|
1633
2174
|
return found.id;
|
|
1634
2175
|
}, "optionOf");
|
|
1635
2176
|
var fieldPairsOf = /* @__PURE__ */ __name((typed) => typed.map((one) => {
|
|
1636
|
-
const
|
|
1637
|
-
if (
|
|
2177
|
+
const at2 = one.indexOf("=");
|
|
2178
|
+
if (at2 <= 0 || one.slice(0, at2).trim() === "")
|
|
1638
2179
|
throw new CliError("validation_error", `--field takes <key>=<value>; got ${one}`, { param: "--field" });
|
|
1639
|
-
return [one.slice(0,
|
|
2180
|
+
return [one.slice(0, at2), one.slice(at2 + 1)];
|
|
1640
2181
|
}), "fieldPairsOf");
|
|
1641
|
-
var crmCustomValues = /* @__PURE__ */ __name((
|
|
2182
|
+
var crmCustomValues = /* @__PURE__ */ __name((fields2, pairs) => {
|
|
1642
2183
|
const values = /* @__PURE__ */ new Map();
|
|
1643
2184
|
for (const [name, value] of pairs) {
|
|
1644
|
-
const field =
|
|
2185
|
+
const field = fields2.length ? fieldNamed(fields2, name) : null;
|
|
1645
2186
|
const code = field?.code ?? name.trim();
|
|
1646
2187
|
if (!field && !FIELD_CODE.test(code))
|
|
1647
2188
|
throw invalid(`${name} is not a field code`, "--field");
|
|
@@ -1662,16 +2203,16 @@ var crmCustomValues = /* @__PURE__ */ __name((fields, pairs) => {
|
|
|
1662
2203
|
return [code, all[0] ?? null];
|
|
1663
2204
|
}));
|
|
1664
2205
|
}, "crmCustomValues");
|
|
1665
|
-
var customOf = /* @__PURE__ */ __name(async (context,
|
|
1666
|
-
var keysOf = /* @__PURE__ */ __name((context,
|
|
2206
|
+
var customOf = /* @__PURE__ */ __name(async (context, kind2, pairs) => pairs?.length ? crmCustomValues(await context.store.crm.fields(context.account, kind2), pairs) : void 0, "customOf");
|
|
2207
|
+
var keysOf = /* @__PURE__ */ __name((context, kind2, verb, { stage, owner }) => {
|
|
1667
2208
|
const extra = [];
|
|
1668
2209
|
if (stage && verb !== "move")
|
|
1669
|
-
extra.push(keyOf2(
|
|
2210
|
+
extra.push(keyOf2(kind2, "move"));
|
|
1670
2211
|
if (stage && stage.outcome !== "open")
|
|
1671
|
-
extra.push(keyOf2(
|
|
2212
|
+
extra.push(keyOf2(kind2, "close"));
|
|
1672
2213
|
if (owner != null && owner !== context.writes.self)
|
|
1673
2214
|
extra.push(CRM_ASSIGN_OTHERS_KEY);
|
|
1674
|
-
return { key: keyOf2(
|
|
2215
|
+
return { key: keyOf2(kind2, verb), extra: [...extra, ...context.writes.alsoChecks?.(kind2, verb) ?? []] };
|
|
1675
2216
|
}, "keysOf");
|
|
1676
2217
|
var guardOf = /* @__PURE__ */ __name((context, extra) => {
|
|
1677
2218
|
const settings = context.writes.settings();
|
|
@@ -1700,18 +2241,18 @@ var written = /* @__PURE__ */ __name(async (context, { key, extra }, operationId
|
|
|
1700
2241
|
throw new CliError("outcome_unknown", context.writes.writer.capabilities.idempotent ? `${error.message} \u2014 repeat it with ${name} ${operationId}: the CRM answers a repeat from its record instead of doing it again` : `${error.message} \u2014 sync and look at the CRM before writing again: this CRM would do it a second time`, { ...error.details, operation_id: operationId });
|
|
1701
2242
|
}
|
|
1702
2243
|
}, "written");
|
|
1703
|
-
var kept = /* @__PURE__ */ __name(async (context,
|
|
1704
|
-
const fail = /* @__PURE__ */ __name((why, details = {}) => new CliError("invalid_response", `the CRM wrote ${
|
|
2244
|
+
var kept = /* @__PURE__ */ __name(async (context, kind2, item, operationId) => {
|
|
2245
|
+
const fail = /* @__PURE__ */ __name((why, details = {}) => new CliError("invalid_response", `the CRM wrote ${kind2} ${item.externalId}, but the local store did not keep it (${why}); sync to store it \u2014 do not write it again`, { ...details, operation_id: operationId, external_id: item.externalId, sent: true }), "fail");
|
|
1705
2246
|
try {
|
|
1706
|
-
let saved = await context.store.crm.saveItems(context.account,
|
|
2247
|
+
let saved = await context.store.crm.saveItems(context.account, kind2, [item]);
|
|
1707
2248
|
if (saved.skipped[0]?.reason === "crm.stage-unknown" && context.source) {
|
|
1708
|
-
await context.store.crm.savePipelines(context.account,
|
|
1709
|
-
saved = await context.store.crm.saveItems(context.account,
|
|
2249
|
+
await context.store.crm.savePipelines(context.account, kind2, await context.source().pipelines(kind2));
|
|
2250
|
+
saved = await context.store.crm.saveItems(context.account, kind2, [item]);
|
|
1710
2251
|
}
|
|
1711
2252
|
const [skipped] = saved.skipped;
|
|
1712
2253
|
if (skipped)
|
|
1713
2254
|
throw fail(skipped.message, { reason: skipped.reason });
|
|
1714
|
-
const reference = await context.store.crm.refOf(context.account,
|
|
2255
|
+
const reference = await context.store.crm.refOf(context.account, kind2, item.externalId);
|
|
1715
2256
|
if (reference === null)
|
|
1716
2257
|
throw fail("it is not found after the save");
|
|
1717
2258
|
return await context.store.deals.get(reference);
|
|
@@ -1721,66 +2262,66 @@ var kept = /* @__PURE__ */ __name(async (context, kind, item, operationId) => {
|
|
|
1721
2262
|
throw fail(error instanceof Error ? error.message : String(error), isCliError(error) ? error.details : {});
|
|
1722
2263
|
}
|
|
1723
2264
|
}, "kept");
|
|
1724
|
-
var createCrmItem = /* @__PURE__ */ __name(async (context,
|
|
2265
|
+
var createCrmItem = /* @__PURE__ */ __name(async (context, kind2, input, options = {}) => {
|
|
1725
2266
|
const { writer } = context.writes;
|
|
1726
|
-
supported(writer,
|
|
2267
|
+
supported(writer, kind2, "create");
|
|
1727
2268
|
if (input.title === void 0)
|
|
1728
|
-
throw invalid(`a new ${
|
|
1729
|
-
const pipeline = await pipelineOf(context,
|
|
1730
|
-
const { fields, stage } = fieldsOf({ ...input, pipeline: pipeline.ref }, pipeline, null);
|
|
1731
|
-
const custom = await customOf(context,
|
|
2269
|
+
throw invalid(`a new ${kind2} needs --title`, "--title");
|
|
2270
|
+
const pipeline = await pipelineOf(context, kind2, input.pipeline);
|
|
2271
|
+
const { fields: fields2, stage } = fieldsOf({ ...input, pipeline: pipeline.ref }, pipeline, null);
|
|
2272
|
+
const custom = await customOf(context, kind2, input.custom);
|
|
1732
2273
|
if (custom)
|
|
1733
|
-
|
|
2274
|
+
fields2.custom = custom;
|
|
1734
2275
|
const operationId = operationOf(context, options.operationId);
|
|
1735
|
-
const item = await written(context, keysOf(context,
|
|
1736
|
-
return { operationId, item: await kept(context,
|
|
2276
|
+
const item = await written(context, keysOf(context, kind2, "create", { stage, owner: fields2.owner }), operationId, () => writer.create(kind2, fields2, { operationId }));
|
|
2277
|
+
return { operationId, item: await kept(context, kind2, item, operationId) };
|
|
1737
2278
|
}, "createCrmItem");
|
|
1738
|
-
var updateCrmItem = /* @__PURE__ */ __name(async (context,
|
|
2279
|
+
var updateCrmItem = /* @__PURE__ */ __name(async (context, kind2, reference, input, options = {}) => {
|
|
1739
2280
|
const { writer } = context.writes;
|
|
1740
|
-
supported(writer,
|
|
1741
|
-
const copy = await copyOf(context,
|
|
2281
|
+
supported(writer, kind2, "update");
|
|
2282
|
+
const copy = await copyOf(context, kind2, reference);
|
|
1742
2283
|
if (input.pipeline !== void 0 && input.stage === void 0)
|
|
1743
2284
|
throw invalid("a new --pipeline needs the --stage it goes to there", "--stage");
|
|
1744
|
-
const pipeline = input.stage === void 0 ? void 0 : await pipelineOf(context,
|
|
1745
|
-
const { fields, stage } = fieldsOf(input, pipeline, copy.currency);
|
|
1746
|
-
const custom = await customOf(context,
|
|
2285
|
+
const pipeline = input.stage === void 0 ? void 0 : await pipelineOf(context, kind2, input.pipeline === void 0 ? copy.pipeline : input.pipeline);
|
|
2286
|
+
const { fields: fields2, stage } = fieldsOf(input, pipeline, copy.currency);
|
|
2287
|
+
const custom = await customOf(context, kind2, input.custom);
|
|
1747
2288
|
if (custom)
|
|
1748
|
-
|
|
1749
|
-
if (Object.keys(
|
|
2289
|
+
fields2.custom = custom;
|
|
2290
|
+
if (Object.keys(fields2).length === 0)
|
|
1750
2291
|
throw invalid("nothing to change: name a field");
|
|
1751
2292
|
const operationId = operationOf(context, options.operationId);
|
|
1752
|
-
const item = await written(context, keysOf(context,
|
|
1753
|
-
return { operationId, item: await kept(context,
|
|
2293
|
+
const item = await written(context, keysOf(context, kind2, "update", { stage, owner: fields2.owner }), operationId, () => writer.update(kind2, copy.externalId, fields2, { operationId }));
|
|
2294
|
+
return { operationId, item: await kept(context, kind2, item, operationId) };
|
|
1754
2295
|
}, "updateCrmItem");
|
|
1755
|
-
var moveCrmItem = /* @__PURE__ */ __name(async (context,
|
|
2296
|
+
var moveCrmItem = /* @__PURE__ */ __name(async (context, kind2, reference, stageName, options = {}) => {
|
|
1756
2297
|
const { writer } = context.writes;
|
|
1757
|
-
supported(writer,
|
|
1758
|
-
const copy = await copyOf(context,
|
|
1759
|
-
const stage = stageOf(await pipelineOf(context,
|
|
2298
|
+
supported(writer, kind2, "move");
|
|
2299
|
+
const copy = await copyOf(context, kind2, reference);
|
|
2300
|
+
const stage = stageOf(await pipelineOf(context, kind2, copy.pipeline), stageName);
|
|
1760
2301
|
const operationId = operationOf(context, options.operationId);
|
|
1761
|
-
const item = await written(context, keysOf(context,
|
|
1762
|
-
return { operationId, item: await kept(context,
|
|
2302
|
+
const item = await written(context, keysOf(context, kind2, "move", { stage }), operationId, () => writer.move(kind2, copy.externalId, stage.externalId, { operationId }));
|
|
2303
|
+
return { operationId, item: await kept(context, kind2, item, operationId) };
|
|
1763
2304
|
}, "moveCrmItem");
|
|
1764
|
-
var closeCrmItem = /* @__PURE__ */ __name(async (context,
|
|
2305
|
+
var closeCrmItem = /* @__PURE__ */ __name(async (context, kind2, reference, outcome, options = {}) => {
|
|
1765
2306
|
const { writer } = context.writes;
|
|
1766
|
-
supported(writer,
|
|
2307
|
+
supported(writer, kind2, "close");
|
|
1767
2308
|
if (outcome !== "won" && outcome !== "lost")
|
|
1768
2309
|
throw invalid("a close is won or lost");
|
|
1769
|
-
const copy = await copyOf(context,
|
|
2310
|
+
const copy = await copyOf(context, kind2, reference);
|
|
1770
2311
|
const reason = options.reason?.trim();
|
|
1771
2312
|
if (reason !== void 0 && (reason === "" || reason.length > 2e3))
|
|
1772
2313
|
throw invalid("--reason is 1 to 2000 characters", "--reason");
|
|
1773
2314
|
const operationId = operationOf(context, options.operationId);
|
|
1774
|
-
const item = await written(context, keysOf(context,
|
|
1775
|
-
return { operationId, item: await kept(context,
|
|
2315
|
+
const item = await written(context, keysOf(context, kind2, "close", {}), operationId, () => writer.close(kind2, copy.externalId, outcome, { operationId, ...reason ? { reason } : {} }));
|
|
2316
|
+
return { operationId, item: await kept(context, kind2, item, operationId) };
|
|
1776
2317
|
}, "closeCrmItem");
|
|
1777
|
-
var removeCrmItem = /* @__PURE__ */ __name(async (context,
|
|
2318
|
+
var removeCrmItem = /* @__PURE__ */ __name(async (context, kind2, reference, options = {}) => {
|
|
1778
2319
|
const { writer } = context.writes;
|
|
1779
|
-
supported(writer,
|
|
1780
|
-
const copy = await copyOf(context,
|
|
2320
|
+
supported(writer, kind2, "remove");
|
|
2321
|
+
const copy = await copyOf(context, kind2, reference);
|
|
1781
2322
|
const operationId = operationOf(context, options.operationId);
|
|
1782
|
-
await written(context, keysOf(context,
|
|
1783
|
-
const removed = await context.store.crm.remove(context.account,
|
|
2323
|
+
await written(context, keysOf(context, kind2, "remove", {}), operationId, () => writer.remove(kind2, copy.externalId, { operationId }));
|
|
2324
|
+
const removed = await context.store.crm.remove(context.account, kind2, [copy.externalId]);
|
|
1784
2325
|
return { operationId, ref: copy.ref, removed };
|
|
1785
2326
|
}, "removeCrmItem");
|
|
1786
2327
|
var EMAIL = /^[^\s@]{1,64}@[^\s@]{1,255}$/u;
|
|
@@ -1788,7 +2329,7 @@ var RECORD_ID = /^[\w.:-]{1,100}$/u;
|
|
|
1788
2329
|
var PERSON_ONLY = ["firstName", "lastName", "position"];
|
|
1789
2330
|
var recordInvalid = /* @__PURE__ */ __name((message, param) => new CliError("validation_error", message, { reason: "crm.record-field", ...param ? { param } : {} }), "recordInvalid");
|
|
1790
2331
|
var cleared = /* @__PURE__ */ __name((value) => value === void 0 ? void 0 : value.trim() || null, "cleared");
|
|
1791
|
-
var
|
|
2332
|
+
var listed = /* @__PURE__ */ __name((values, param, valid) => {
|
|
1792
2333
|
if (values === void 0)
|
|
1793
2334
|
return void 0;
|
|
1794
2335
|
const all = values.map((one) => one.trim());
|
|
@@ -1799,73 +2340,73 @@ var listed2 = /* @__PURE__ */ __name((values, param, valid) => {
|
|
|
1799
2340
|
throw recordInvalid(`${param} got ${one}`, param);
|
|
1800
2341
|
return all;
|
|
1801
2342
|
}, "listed");
|
|
1802
|
-
var recordFieldsOf = /* @__PURE__ */ __name((
|
|
1803
|
-
if (
|
|
2343
|
+
var recordFieldsOf = /* @__PURE__ */ __name((kind2, input) => {
|
|
2344
|
+
if (kind2 === "organization") {
|
|
1804
2345
|
const given = PERSON_ONLY.find((one) => input[one] !== void 0);
|
|
1805
2346
|
if (given)
|
|
1806
2347
|
throw recordInvalid(`a company has no ${given}`);
|
|
1807
2348
|
}
|
|
1808
|
-
const
|
|
2349
|
+
const fields2 = {};
|
|
1809
2350
|
if (input.name !== void 0) {
|
|
1810
2351
|
if (!input.name.trim())
|
|
1811
2352
|
throw recordInvalid("--name is never empty", "--name");
|
|
1812
|
-
|
|
2353
|
+
fields2.name = input.name.trim();
|
|
1813
2354
|
}
|
|
1814
2355
|
const parts = { firstName: cleared(input.firstName), lastName: cleared(input.lastName) };
|
|
1815
2356
|
const position = cleared(input.position);
|
|
1816
2357
|
if (parts.firstName !== void 0)
|
|
1817
|
-
|
|
2358
|
+
fields2.firstName = parts.firstName;
|
|
1818
2359
|
if (parts.lastName !== void 0)
|
|
1819
|
-
|
|
2360
|
+
fields2.lastName = parts.lastName;
|
|
1820
2361
|
if (position !== void 0)
|
|
1821
|
-
|
|
1822
|
-
const emails =
|
|
1823
|
-
const phones =
|
|
2362
|
+
fields2.position = position;
|
|
2363
|
+
const emails = listed(input.emails, "--email", EMAIL);
|
|
2364
|
+
const phones = listed(input.phones, "--phone")?.map((phone) => {
|
|
1824
2365
|
const international = e164Of(phone, void 0);
|
|
1825
2366
|
if (typeof international !== "string")
|
|
1826
2367
|
throw recordInvalid(`--phone takes a number in international form, starting with +: not ${phone}`, "--phone");
|
|
1827
2368
|
return international;
|
|
1828
2369
|
});
|
|
1829
2370
|
if (emails)
|
|
1830
|
-
|
|
2371
|
+
fields2.emails = emails;
|
|
1831
2372
|
if (phones)
|
|
1832
|
-
|
|
2373
|
+
fields2.phones = phones;
|
|
1833
2374
|
if (input.owner !== void 0) {
|
|
1834
2375
|
if (!input.owner.trim())
|
|
1835
2376
|
throw recordInvalid("--owner is the CRM user's id", "--owner");
|
|
1836
|
-
|
|
2377
|
+
fields2.owner = input.owner.trim();
|
|
1837
2378
|
}
|
|
1838
|
-
return
|
|
2379
|
+
return fields2;
|
|
1839
2380
|
}, "recordFieldsOf");
|
|
1840
|
-
var keptRecord = /* @__PURE__ */ __name(async (context,
|
|
2381
|
+
var keptRecord = /* @__PURE__ */ __name(async (context, kind2, record2) => {
|
|
1841
2382
|
try {
|
|
1842
|
-
const saved =
|
|
2383
|
+
const saved = kind2 === "person" ? await context.store.crm.savePeople(context.account, [record2]) : await context.store.crm.saveOrganizations(context.account, [record2]);
|
|
1843
2384
|
const [skipped] = saved.skipped;
|
|
1844
2385
|
if (skipped)
|
|
1845
2386
|
throw new Error(skipped.message);
|
|
1846
2387
|
} catch (error) {
|
|
1847
|
-
throw new CliError("invalid_response", `the CRM wrote ${
|
|
2388
|
+
throw new CliError("invalid_response", `the CRM wrote ${kind2} ${record2.externalId}, but the local store did not keep it (${error instanceof Error ? error.message : String(error)}); sync to store it \u2014 do not write it again`, { external_id: record2.externalId, sent: true });
|
|
1848
2389
|
}
|
|
1849
2390
|
}, "keptRecord");
|
|
1850
|
-
var forgotten = /* @__PURE__ */ __name(async (context,
|
|
1851
|
-
var writeRecord = /* @__PURE__ */ __name(async (context,
|
|
2391
|
+
var forgotten = /* @__PURE__ */ __name(async (context, kind2, record2) => (kind2 === "organization" ? await context.store.crm.remove(context.account, kind2, [record2.externalId]) : (await context.store.crm.removeContact(context.account, record2.externalId)).contacts) > 0, "forgotten");
|
|
2392
|
+
var writeRecord = /* @__PURE__ */ __name(async (context, kind2, verb, fields2, operationId, act) => {
|
|
1852
2393
|
if (!context.source)
|
|
1853
2394
|
throw new CliError("configuration_error", "a contact or company write needs the CRM source to tell your clients");
|
|
1854
|
-
const
|
|
1855
|
-
const
|
|
1856
|
-
const stored = await
|
|
2395
|
+
const rule2 = foreignContacts(context.source(), void 0);
|
|
2396
|
+
const record2 = await written(context, keysOf(context, kind2, verb, { owner: fields2.owner }), operationId, act);
|
|
2397
|
+
const stored = await rule2.own(kind2, record2);
|
|
1857
2398
|
let removed;
|
|
1858
2399
|
try {
|
|
1859
2400
|
if (stored)
|
|
1860
|
-
await keptRecord(context,
|
|
2401
|
+
await keptRecord(context, kind2, record2);
|
|
1861
2402
|
else if (verb === "update")
|
|
1862
|
-
removed = await forgotten(context,
|
|
2403
|
+
removed = await forgotten(context, kind2, record2);
|
|
1863
2404
|
} catch (error) {
|
|
1864
2405
|
if (isCliError(error))
|
|
1865
2406
|
throw new CliError(error.code, error.message, { ...error.details, operation_id: operationId });
|
|
1866
2407
|
throw error;
|
|
1867
2408
|
}
|
|
1868
|
-
const [shown] = stored ? [
|
|
2409
|
+
const [shown] = stored ? [record2] : await rule2.strip(kind2, [record2]);
|
|
1869
2410
|
return {
|
|
1870
2411
|
operationId,
|
|
1871
2412
|
record: shown,
|
|
@@ -1873,154 +2414,191 @@ var writeRecord = /* @__PURE__ */ __name(async (context, kind, verb, fields, ope
|
|
|
1873
2414
|
...removed === void 0 ? {} : { removed }
|
|
1874
2415
|
};
|
|
1875
2416
|
}, "writeRecord");
|
|
1876
|
-
var createCrmRecord = /* @__PURE__ */ __name(async (context,
|
|
2417
|
+
var createCrmRecord = /* @__PURE__ */ __name(async (context, kind2, input, options = {}) => {
|
|
1877
2418
|
const { writer } = context.writes;
|
|
1878
|
-
supported(writer,
|
|
1879
|
-
const
|
|
1880
|
-
if (
|
|
2419
|
+
supported(writer, kind2, "create");
|
|
2420
|
+
const fields2 = recordFieldsOf(kind2, input);
|
|
2421
|
+
if (kind2 === "organization" && fields2.name === void 0)
|
|
1881
2422
|
throw recordInvalid("a new company needs --name", "--name");
|
|
1882
|
-
if (
|
|
2423
|
+
if (kind2 === "person" && !fields2.name && !fields2.firstName && !fields2.lastName)
|
|
1883
2424
|
throw recordInvalid("a new contact needs --name, --first-name or --last-name", "--name");
|
|
1884
|
-
const custom = await customOf(context,
|
|
2425
|
+
const custom = await customOf(context, kind2, input.custom);
|
|
1885
2426
|
if (custom)
|
|
1886
|
-
|
|
2427
|
+
fields2.custom = custom;
|
|
1887
2428
|
const operationId = operationOf(context, options.operationId);
|
|
1888
|
-
return writeRecord(context,
|
|
2429
|
+
return writeRecord(context, kind2, "create", fields2, operationId, () => writer.create(kind2, fields2, { operationId }));
|
|
1889
2430
|
}, "createCrmRecord");
|
|
1890
|
-
var updateCrmRecord = /* @__PURE__ */ __name(async (context,
|
|
2431
|
+
var updateCrmRecord = /* @__PURE__ */ __name(async (context, kind2, externalId, input, options = {}) => {
|
|
1891
2432
|
const { writer } = context.writes;
|
|
1892
|
-
supported(writer,
|
|
2433
|
+
supported(writer, kind2, "update");
|
|
1893
2434
|
if (!RECORD_ID.test(externalId))
|
|
1894
|
-
throw new CliError("validation_error", `name the ${
|
|
2435
|
+
throw new CliError("validation_error", `name the ${kind2} by the CRM's id, as a list prints it`, {
|
|
1895
2436
|
reason: "ref.malformed"
|
|
1896
2437
|
});
|
|
1897
|
-
const
|
|
1898
|
-
const custom = await customOf(context,
|
|
2438
|
+
const fields2 = recordFieldsOf(kind2, input);
|
|
2439
|
+
const custom = await customOf(context, kind2, input.custom);
|
|
1899
2440
|
if (custom)
|
|
1900
|
-
|
|
1901
|
-
if (Object.keys(
|
|
2441
|
+
fields2.custom = custom;
|
|
2442
|
+
if (Object.keys(fields2).length === 0)
|
|
1902
2443
|
throw recordInvalid("nothing to change: name a field");
|
|
1903
2444
|
const operationId = operationOf(context, options.operationId);
|
|
1904
|
-
return writeRecord(context,
|
|
2445
|
+
return writeRecord(context, kind2, "update", fields2, operationId, () => writer.update(kind2, externalId, fields2, { operationId }));
|
|
1905
2446
|
}, "updateCrmRecord");
|
|
1906
2447
|
|
|
1907
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
1908
|
-
var
|
|
1909
|
-
__export(values_exports, {
|
|
1910
|
-
amountOf: () => amountOf,
|
|
1911
|
-
crmValuesOf: () => crmValuesOf,
|
|
1912
|
-
epoch: () => epoch,
|
|
1913
|
-
fieldOf: () => fieldOf,
|
|
1914
|
-
fullName: () => fullName,
|
|
1915
|
-
id: () => id,
|
|
1916
|
-
ids: () => ids,
|
|
1917
|
-
isRaw: () => isRaw,
|
|
1918
|
-
number: () => number,
|
|
1919
|
-
rawsOf: () => rawsOf,
|
|
1920
|
-
text: () => text,
|
|
1921
|
-
time: () => time
|
|
1922
|
-
});
|
|
1923
|
-
|
|
1924
|
-
// 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/crm/source.js
|
|
1925
|
-
var CRM_FILE_SOURCES = ["record", "field", "document", "activity", "comment"];
|
|
2448
|
+
// 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/file-fetch.js
|
|
2449
|
+
var EXCHANGE_MS = 60 * 60 * 1e3;
|
|
1926
2450
|
|
|
1927
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
1928
|
-
var
|
|
1929
|
-
|
|
1930
|
-
|
|
1931
|
-
|
|
1932
|
-
|
|
1933
|
-
|
|
1934
|
-
|
|
1935
|
-
|
|
1936
|
-
|
|
1937
|
-
|
|
1938
|
-
|
|
1939
|
-
|
|
1940
|
-
|
|
1941
|
-
|
|
1942
|
-
|
|
1943
|
-
|
|
1944
|
-
|
|
1945
|
-
|
|
1946
|
-
|
|
1947
|
-
|
|
1948
|
-
|
|
1949
|
-
|
|
1950
|
-
|
|
1951
|
-
|
|
1952
|
-
|
|
1953
|
-
|
|
1954
|
-
|
|
1955
|
-
|
|
1956
|
-
|
|
1957
|
-
|
|
1958
|
-
|
|
2451
|
+
// 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/manifest/map.js
|
|
2452
|
+
var at = /* @__PURE__ */ __name((value, path2) => path2 === "." ? value : path2.split(".").reduce((inner, key) => inner === null ? null : Array.isArray(inner) && /^\d+$/.test(key) ? inner[Number(key)] ?? null : isRaw(inner) ? inner[key] : void 0, value), "at");
|
|
2453
|
+
var TIMES = { createdAt: "epoch", updatedAt: "epoch" };
|
|
2454
|
+
var ITEM = {
|
|
2455
|
+
externalId: "id",
|
|
2456
|
+
title: "text",
|
|
2457
|
+
pipeline: "text",
|
|
2458
|
+
stage: "text",
|
|
2459
|
+
status: "status",
|
|
2460
|
+
closeDate: "day",
|
|
2461
|
+
closedDate: "day",
|
|
2462
|
+
closedReason: "text",
|
|
2463
|
+
organization: "id",
|
|
2464
|
+
contactName: "text",
|
|
2465
|
+
companyName: "text",
|
|
2466
|
+
people: "people",
|
|
2467
|
+
deal: "id",
|
|
2468
|
+
url: "text",
|
|
2469
|
+
assignee: "id",
|
|
2470
|
+
...TIMES
|
|
2471
|
+
};
|
|
2472
|
+
var FIELDS = {
|
|
2473
|
+
person: {
|
|
2474
|
+
externalId: "id",
|
|
2475
|
+
name: "text",
|
|
2476
|
+
firstName: "text",
|
|
2477
|
+
lastName: "text",
|
|
2478
|
+
email: "text",
|
|
2479
|
+
phone: "text",
|
|
2480
|
+
emails: "texts",
|
|
2481
|
+
phones: "texts",
|
|
2482
|
+
position: "text",
|
|
2483
|
+
organizations: "organizations",
|
|
2484
|
+
assignee: "id",
|
|
2485
|
+
url: "text",
|
|
2486
|
+
...TIMES
|
|
2487
|
+
},
|
|
2488
|
+
organization: {
|
|
2489
|
+
externalId: "id",
|
|
2490
|
+
name: "text",
|
|
2491
|
+
url: "text",
|
|
2492
|
+
type: "text",
|
|
2493
|
+
own: "bool",
|
|
2494
|
+
phones: "texts",
|
|
2495
|
+
emails: "texts",
|
|
2496
|
+
people: "ids",
|
|
2497
|
+
assignee: "id",
|
|
2498
|
+
...TIMES
|
|
2499
|
+
},
|
|
2500
|
+
deal: ITEM,
|
|
2501
|
+
lead: ITEM
|
|
2502
|
+
};
|
|
1959
2503
|
|
|
1960
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
1961
|
-
var
|
|
1962
|
-
var
|
|
1963
|
-
var
|
|
1964
|
-
|
|
1965
|
-
|
|
1966
|
-
|
|
1967
|
-
|
|
1968
|
-
|
|
1969
|
-
|
|
1970
|
-
|
|
1971
|
-
|
|
1972
|
-
|
|
1973
|
-
|
|
1974
|
-
|
|
1975
|
-
var
|
|
1976
|
-
|
|
1977
|
-
|
|
1978
|
-
|
|
1979
|
-
|
|
1980
|
-
|
|
1981
|
-
|
|
1982
|
-
|
|
1983
|
-
|
|
1984
|
-
|
|
1985
|
-
|
|
1986
|
-
|
|
1987
|
-
|
|
1988
|
-
|
|
1989
|
-
|
|
1990
|
-
|
|
1991
|
-
|
|
1992
|
-
|
|
1993
|
-
|
|
1994
|
-
|
|
1995
|
-
|
|
1996
|
-
|
|
1997
|
-
|
|
1998
|
-
|
|
1999
|
-
|
|
2000
|
-
|
|
2001
|
-
|
|
2002
|
-
|
|
2003
|
-
},
|
|
2004
|
-
|
|
2005
|
-
|
|
2006
|
-
|
|
2007
|
-
|
|
2008
|
-
|
|
2009
|
-
|
|
2010
|
-
|
|
2011
|
-
|
|
2012
|
-
|
|
2013
|
-
|
|
2014
|
-
|
|
2015
|
-
|
|
2016
|
-
|
|
2017
|
-
|
|
2504
|
+
// 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/manifest/manifest.js
|
|
2505
|
+
var path = pipe(string(), regex(/^[^.\s]+(\.[^.\s]+)*$/, "a dotted path such as properties.name"));
|
|
2506
|
+
var paths = pipe(array(path), minLength(1));
|
|
2507
|
+
var crmRuleSchema = union([
|
|
2508
|
+
path,
|
|
2509
|
+
strictObject({ first: paths }),
|
|
2510
|
+
strictObject({ join: paths }),
|
|
2511
|
+
strictObject({ all: paths, split: optional(string()) }),
|
|
2512
|
+
strictObject({ path, split: optional(string()) }),
|
|
2513
|
+
strictObject({ path, map: record(string(), unknown()) }),
|
|
2514
|
+
strictObject({ each: path, id: path, primary: optional(path) }),
|
|
2515
|
+
strictObject({ each: path, value: path }),
|
|
2516
|
+
strictObject({ value: unknown() }),
|
|
2517
|
+
function_()
|
|
2518
|
+
], "a path, one of first, join, all, path, each, value, or a function");
|
|
2519
|
+
var rule = crmRuleSchema;
|
|
2520
|
+
var call = strictObject({
|
|
2521
|
+
operation: pipe(string(), minLength(1)),
|
|
2522
|
+
path: optional(record(string(), string())),
|
|
2523
|
+
query: optional(record(string(), union([string(), number(), boolean()]))),
|
|
2524
|
+
body: optional(unknown()),
|
|
2525
|
+
items: optional(path)
|
|
2526
|
+
});
|
|
2527
|
+
var entity = strictObject({
|
|
2528
|
+
list: call,
|
|
2529
|
+
changes: optional(strictObject({
|
|
2530
|
+
...call.entries,
|
|
2531
|
+
since: picklist(["ms", "seconds", "iso", "datetime"]),
|
|
2532
|
+
keyset: optional(strictObject({ field: path, cap: optional(pipe(number(), integer(), minValue(1))) }))
|
|
2533
|
+
})),
|
|
2534
|
+
ids: optional(call),
|
|
2535
|
+
get: optional(call),
|
|
2536
|
+
search: optional(call),
|
|
2537
|
+
select: optional(strictObject({
|
|
2538
|
+
from: path,
|
|
2539
|
+
also: optional(array(string())),
|
|
2540
|
+
max: optional(pipe(number(), integer(), minValue(1)))
|
|
2541
|
+
})),
|
|
2542
|
+
map: record(string(), rule),
|
|
2543
|
+
custom: optional(strictObject({
|
|
2544
|
+
from: path,
|
|
2545
|
+
split: optional(string()),
|
|
2546
|
+
typed: optional(strictObject({ by: path, current: optional(path), paths: optional(record(string(), path)) }))
|
|
2547
|
+
})),
|
|
2548
|
+
optional: optional(strictObject({ message: pipe(string(), minLength(1)), scope: optional(string()) })),
|
|
2549
|
+
linked: optional(literal(true))
|
|
2550
|
+
});
|
|
2551
|
+
var pipelines = strictObject({
|
|
2552
|
+
call,
|
|
2553
|
+
map: strictObject({ externalId: rule, name: rule }),
|
|
2554
|
+
stages: strictObject({
|
|
2555
|
+
each: union([literal("."), path]),
|
|
2556
|
+
pipeline: optional(path),
|
|
2557
|
+
map: strictObject({ externalId: rule, name: rule, position: optional(rule) }),
|
|
2558
|
+
outcome: union([
|
|
2559
|
+
strictObject({ path, won: optional(array(string())), lost: optional(array(string())) }),
|
|
2560
|
+
strictObject({ value: picklist(STAGE_OUTCOMES) }),
|
|
2561
|
+
function_()
|
|
2562
|
+
])
|
|
2563
|
+
})
|
|
2564
|
+
});
|
|
2565
|
+
var fields = strictObject({
|
|
2566
|
+
call,
|
|
2567
|
+
map: strictObject({
|
|
2568
|
+
code: rule,
|
|
2569
|
+
label: optional(rule),
|
|
2570
|
+
type: optional(rule),
|
|
2571
|
+
multiple: optional(rule),
|
|
2572
|
+
filterable: optional(rule),
|
|
2573
|
+
options: optional(union([strictObject({ each: path, id: path, label: path }), function_()]))
|
|
2574
|
+
}),
|
|
2575
|
+
keep: optional(union([strictObject({ path, is: unknown() }), function_()]))
|
|
2576
|
+
});
|
|
2577
|
+
var kind = picklist(CRM_KINDS);
|
|
2578
|
+
var schema = strictObject({
|
|
2579
|
+
provider: pipe(string(), regex(/^[a-z][a-z0-9-]*$/, "a registry name such as hubspot")),
|
|
2580
|
+
kinds: pipe(array(kind), minLength(1)),
|
|
2581
|
+
overlapMs: optional(pipe(number(), integer(), minValue(0))),
|
|
2582
|
+
entities: record(kind, optional(entity)),
|
|
2583
|
+
pipelines: optional(record(picklist(DEAL_KINDS), optional(pipelines))),
|
|
2584
|
+
fields: optional(record(kind, optional(fields))),
|
|
2585
|
+
users: optional(strictObject({
|
|
2586
|
+
call,
|
|
2587
|
+
map: strictObject({
|
|
2588
|
+
externalId: rule,
|
|
2589
|
+
name: optional(rule),
|
|
2590
|
+
email: optional(rule),
|
|
2591
|
+
position: optional(rule),
|
|
2592
|
+
active: optional(rule)
|
|
2593
|
+
})
|
|
2594
|
+
}))
|
|
2595
|
+
});
|
|
2018
2596
|
|
|
2019
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
2020
|
-
var
|
|
2597
|
+
// 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/manifest/source.js
|
|
2598
|
+
var OVERLAP_MS = 10 * 6e4;
|
|
2021
2599
|
|
|
2022
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
2023
|
-
import { readFileSync as
|
|
2600
|
+
// 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/sends/pace.js
|
|
2601
|
+
import { readFileSync as readFileSync6, renameSync as renameSync2, writeFileSync as writeFileSync2 } from "node:fs";
|
|
2024
2602
|
import { join as join5 } from "node:path";
|
|
2025
2603
|
var DEFAULT_PACE = { perMinute: 60, burst: 20 };
|
|
2026
2604
|
var pacePathFor = /* @__PURE__ */ __name((app, profile, env = process.env) => join5(resolvePaths({ appName: app.appName, prefix: app.envPrefix, env }).state, "pace", `${profile}.json`), "pacePathFor");
|
|
@@ -2031,8 +2609,8 @@ var Pacer = class {
|
|
|
2031
2609
|
path;
|
|
2032
2610
|
rate;
|
|
2033
2611
|
now;
|
|
2034
|
-
constructor(
|
|
2035
|
-
this.path =
|
|
2612
|
+
constructor(path2, rate, now = Date.now) {
|
|
2613
|
+
this.path = path2;
|
|
2036
2614
|
this.rate = rate;
|
|
2037
2615
|
this.now = now;
|
|
2038
2616
|
}
|
|
@@ -2066,19 +2644,19 @@ var Pacer = class {
|
|
|
2066
2644
|
}
|
|
2067
2645
|
read(now) {
|
|
2068
2646
|
try {
|
|
2069
|
-
const file = JSON.parse(
|
|
2647
|
+
const file = JSON.parse(readFileSync6(this.path, "utf8"));
|
|
2070
2648
|
const tat = Number(file.tat);
|
|
2071
2649
|
if (!Number.isFinite(tat))
|
|
2072
2650
|
return 0;
|
|
2073
|
-
const
|
|
2074
|
-
return Number.isFinite(
|
|
2651
|
+
const at2 = Number(file.at);
|
|
2652
|
+
return Number.isFinite(at2) && at2 > now ? now + Math.max(0, tat - at2) : tat;
|
|
2075
2653
|
} catch {
|
|
2076
2654
|
return 0;
|
|
2077
2655
|
}
|
|
2078
2656
|
}
|
|
2079
|
-
write(tat,
|
|
2657
|
+
write(tat, at2) {
|
|
2080
2658
|
const temporary = `${this.path}.${process.pid}.tmp`;
|
|
2081
|
-
writeFileSync2(temporary, JSON.stringify({ tat, at }), { mode: 384 });
|
|
2659
|
+
writeFileSync2(temporary, JSON.stringify({ tat, at: at2 }), { mode: 384 });
|
|
2082
2660
|
renameSync2(temporary, this.path);
|
|
2083
2661
|
}
|
|
2084
2662
|
};
|
|
@@ -2087,9 +2665,9 @@ var LONGEST_PACE_WAIT_MS = 5 * 6e4;
|
|
|
2087
2665
|
var waitForTurn = /* @__PURE__ */ __name(async (pacer, options) => {
|
|
2088
2666
|
const { name, operation, warn } = options;
|
|
2089
2667
|
const now = options.now ?? Date.now;
|
|
2090
|
-
let
|
|
2668
|
+
let at2 = now();
|
|
2091
2669
|
try {
|
|
2092
|
-
|
|
2670
|
+
at2 = await pacer.reserve();
|
|
2093
2671
|
} catch (error) {
|
|
2094
2672
|
warn?.(`could not remember ${name}'s wait (${error instanceof Error ? error.message : String(error)})`, {
|
|
2095
2673
|
event: "warning",
|
|
@@ -2097,11 +2675,11 @@ var waitForTurn = /* @__PURE__ */ __name(async (pacer, options) => {
|
|
|
2097
2675
|
operation
|
|
2098
2676
|
});
|
|
2099
2677
|
}
|
|
2100
|
-
const waitMs =
|
|
2678
|
+
const waitMs = at2 - now();
|
|
2101
2679
|
if (waitMs <= 0)
|
|
2102
2680
|
return;
|
|
2103
2681
|
if (waitMs > (options.longestWaitMs ?? LONGEST_PACE_WAIT_MS))
|
|
2104
|
-
throw new CliError("rate_limited", `this profile's next request to ${name} has to wait ${Math.ceil(waitMs / 1e3)} s more \u2014 nothing was sent to ${name}`, { retry_after_ms: waitMs, retry_at: new Date(
|
|
2682
|
+
throw new CliError("rate_limited", `this profile's next request to ${name} has to wait ${Math.ceil(waitMs / 1e3)} s more \u2014 nothing was sent to ${name}`, { retry_after_ms: waitMs, retry_at: new Date(at2).toISOString(), remembered: true });
|
|
2105
2683
|
if (waitMs >= ANNOUNCE_WAIT_MS) {
|
|
2106
2684
|
const seconds = Math.ceil(waitMs / 1e3);
|
|
2107
2685
|
warn?.(`waiting ${seconds} s to keep this profile's pace with ${name}`, {
|
|
@@ -2114,7 +2692,7 @@ var waitForTurn = /* @__PURE__ */ __name(async (pacer, options) => {
|
|
|
2114
2692
|
await (options.sleep ?? ((ms) => new Promise((resolve) => setTimeout(resolve, ms))))(waitMs);
|
|
2115
2693
|
}, "waitForTurn");
|
|
2116
2694
|
|
|
2117
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
2695
|
+
// 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/provider-call.js
|
|
2118
2696
|
var RETRY = { retries: 3, baseDelayMs: 1e3, maxDelayMs: 1e4, maxRetryAfterMs: 3e4 };
|
|
2119
2697
|
var UNANSWERED = /* @__PURE__ */ new Set(["timeout", "network_error", "provider_unavailable", "cancelled", "invalid_response"]);
|
|
2120
2698
|
var unanswered = /* @__PURE__ */ __name((error) => !isCliError(error) || UNANSWERED.has(error.code) && error.details.sent !== false, "unanswered");
|
|
@@ -2150,14 +2728,14 @@ var providerCall = /* @__PURE__ */ __name(async (options) => {
|
|
|
2150
2728
|
}
|
|
2151
2729
|
}, "providerCall");
|
|
2152
2730
|
|
|
2153
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
2154
|
-
var valueFor = /* @__PURE__ */ __name((
|
|
2155
|
-
if (
|
|
2731
|
+
// 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/query.js
|
|
2732
|
+
var valueFor = /* @__PURE__ */ __name((kind2, raw, name) => {
|
|
2733
|
+
if (kind2 === "id") {
|
|
2156
2734
|
if (!/^[\w.:-]{1,100}$/u.test(raw))
|
|
2157
2735
|
throw new CliError("validation_error", `${name} takes an id; got ${raw}`, { reason: "query.bad-value" });
|
|
2158
2736
|
return raw;
|
|
2159
2737
|
}
|
|
2160
|
-
if (
|
|
2738
|
+
if (kind2 !== "number")
|
|
2161
2739
|
return raw;
|
|
2162
2740
|
const found = Number(raw);
|
|
2163
2741
|
if (raw.trim() === "" || !Number.isFinite(found))
|
|
@@ -2180,16 +2758,16 @@ var range = /* @__PURE__ */ __name((node, map, name) => [
|
|
|
2180
2758
|
}
|
|
2181
2759
|
]
|
|
2182
2760
|
], "range");
|
|
2183
|
-
var conditionsOf = /* @__PURE__ */ __name((terms,
|
|
2184
|
-
const map =
|
|
2761
|
+
var conditionsOf = /* @__PURE__ */ __name((terms, fields2, hooks = {}) => [...terms].flatMap(([name, node]) => {
|
|
2762
|
+
const map = fields2[name];
|
|
2185
2763
|
if (!map)
|
|
2186
2764
|
throw new CliError("validation_error", `the CRM cannot filter by ${name}`, { reason: "query.unsupported-field" });
|
|
2187
2765
|
if (map.kind === "time") {
|
|
2188
|
-
const
|
|
2766
|
+
const at2 = hooks.time ?? ((ms) => ms);
|
|
2189
2767
|
const { since, until } = timeBounds(node);
|
|
2190
2768
|
return [
|
|
2191
|
-
...since === void 0 ? [] : [{ field: map.field, op: ">=", value:
|
|
2192
|
-
...until === void 0 ? [] : [{ field: map.field, op: "<=", value:
|
|
2769
|
+
...since === void 0 ? [] : [{ field: map.field, op: ">=", value: at2(since) }],
|
|
2770
|
+
...until === void 0 ? [] : [{ field: map.field, op: "<=", value: at2(until) }]
|
|
2193
2771
|
];
|
|
2194
2772
|
}
|
|
2195
2773
|
if (node.operator === "range")
|
|
@@ -2203,8 +2781,8 @@ var customNames = /* @__PURE__ */ __name((text2, registry, command, defaultField
|
|
|
2203
2781
|
const named2 = walkQuery(parseLucene(text2, { defaultField, command, guide: LIST_QUERY_GUIDE }).root).filter((term) => !term.implicit).map((term) => term.field);
|
|
2204
2782
|
return [...new Set(named2.filter((name) => !known.has(name)))];
|
|
2205
2783
|
}, "customNames");
|
|
2206
|
-
var filterableFields = /* @__PURE__ */ __name((
|
|
2207
|
-
const field = fieldNamed(
|
|
2784
|
+
var filterableFields = /* @__PURE__ */ __name((fields2, names) => names.map((name) => {
|
|
2785
|
+
const field = fieldNamed(fields2, name, "--query");
|
|
2208
2786
|
if (!field.filterable)
|
|
2209
2787
|
throw new CliError("validation_error", `the CRM cannot filter a list by ${field.label ?? field.code}`, {
|
|
2210
2788
|
reason: "field.not-filterable",
|
|
@@ -2221,37 +2799,37 @@ var withCustomFields = /* @__PURE__ */ __name((registry, chosen) => ({
|
|
|
2221
2799
|
}), "withCustomFields");
|
|
2222
2800
|
var customValue = /* @__PURE__ */ __name((field, typed, hooks) => {
|
|
2223
2801
|
const value = field.options ? optionOf(field, typed, "--query") : typed;
|
|
2224
|
-
const
|
|
2225
|
-
return hooks.numeric?.(field) && value.trim() !== "" && Number.isFinite(
|
|
2802
|
+
const number3 = Number(value);
|
|
2803
|
+
return hooks.numeric?.(field) && value.trim() !== "" && Number.isFinite(number3) ? number3 : value;
|
|
2226
2804
|
}, "customValue");
|
|
2227
2805
|
var customConditions = /* @__PURE__ */ __name((terms, chosen, hooks = {}) => chosen.flatMap(([name, field]) => {
|
|
2228
2806
|
const term = terms.get(name);
|
|
2229
2807
|
terms.delete(name);
|
|
2230
2808
|
return term ? [{ field: field.code, op: "=", value: customValue(field, term.value, hooks) }] : [];
|
|
2231
2809
|
}), "customConditions");
|
|
2232
|
-
var wantedCodes = /* @__PURE__ */ __name((
|
|
2233
|
-
if (!
|
|
2810
|
+
var wantedCodes = /* @__PURE__ */ __name((paths2) => {
|
|
2811
|
+
if (!paths2)
|
|
2234
2812
|
return void 0;
|
|
2235
|
-
const parts =
|
|
2813
|
+
const parts = paths2.split(",").map((path2) => path2.trim().replace(/^items\./, "").split("."));
|
|
2236
2814
|
const metadata = parts.filter(([top]) => top === "provider_metadata");
|
|
2237
2815
|
if (metadata.some((part) => part.length === 1))
|
|
2238
2816
|
return "all";
|
|
2239
2817
|
const codes = metadata.flatMap(([, code]) => code ? [code] : []);
|
|
2240
2818
|
return codes.length ? [...new Set(codes)] : void 0;
|
|
2241
2819
|
}, "wantedCodes");
|
|
2242
|
-
var selectedCodes = /* @__PURE__ */ __name((
|
|
2820
|
+
var selectedCodes = /* @__PURE__ */ __name((fields2, wanted) => {
|
|
2243
2821
|
if (wanted === void 0)
|
|
2244
2822
|
return [];
|
|
2245
2823
|
if (wanted === "all")
|
|
2246
|
-
return
|
|
2824
|
+
return fields2.map((field) => field.code);
|
|
2247
2825
|
return wanted.map((code) => {
|
|
2248
|
-
if (!
|
|
2249
|
-
throw unknownField(
|
|
2826
|
+
if (!fields2.some((field) => field.code === code))
|
|
2827
|
+
throw unknownField(fields2, code, "--json");
|
|
2250
2828
|
return code;
|
|
2251
2829
|
});
|
|
2252
2830
|
}, "selectedCodes");
|
|
2253
2831
|
|
|
2254
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
2832
|
+
// 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/search/groups.js
|
|
2255
2833
|
var ALL = "all";
|
|
2256
2834
|
var OWNER_NOTES = { provider: "notes", account: INTERNAL_NOTES };
|
|
2257
2835
|
var NOT_GROUP_NAMES = /* @__PURE__ */ new Set([ALL, "bots"]);
|
|
@@ -2323,7 +2901,7 @@ var groupEntries = /* @__PURE__ */ __name((saved) => ({
|
|
|
2323
2901
|
[ALL]: [ALL]
|
|
2324
2902
|
}), "groupEntries");
|
|
2325
2903
|
|
|
2326
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
2904
|
+
// 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/services/search-kind.js
|
|
2327
2905
|
var NO_MAIL = "no_mail";
|
|
2328
2906
|
var MAIL = "email";
|
|
2329
2907
|
var groupLockOf = /* @__PURE__ */ __name((app, env) => {
|
|
@@ -2362,7 +2940,7 @@ var listContextOf = /* @__PURE__ */ __name(async (store, account, app, stored, e
|
|
|
2362
2940
|
only
|
|
2363
2941
|
};
|
|
2364
2942
|
}, "listContextOf");
|
|
2365
|
-
var listedAccounts = /* @__PURE__ */ __name(async (store, account, source, app,
|
|
2943
|
+
var listedAccounts = /* @__PURE__ */ __name(async (store, account, source, app, kind2, env) => {
|
|
2366
2944
|
const lock = groupLockOf(app, env);
|
|
2367
2945
|
if (source === void 0 && lock === void 0)
|
|
2368
2946
|
return void 0;
|
|
@@ -2371,21 +2949,21 @@ var listedAccounts = /* @__PURE__ */ __name(async (store, account, source, app,
|
|
|
2371
2949
|
if (lock === void 0 && source !== void 0 && !isAccountList(source) && !registered)
|
|
2372
2950
|
return void 0;
|
|
2373
2951
|
const entries = entriesOfList(source ?? `group:${lock}`, await listContextOf(store, account, app, stored, env));
|
|
2374
|
-
return fitting(entries,
|
|
2952
|
+
return fitting(entries, kind2 ? [kind2] : ["messages", "mail"], `${app ? `${app.command} ` : ""}search ${kind2 ?? "messages"}`);
|
|
2375
2953
|
}, "listedAccounts");
|
|
2376
|
-
var accountsOfKind = /* @__PURE__ */ __name((
|
|
2377
|
-
if (mailAccount !== void 0 &&
|
|
2954
|
+
var accountsOfKind = /* @__PURE__ */ __name((kind2, chosen, held, explicit, command = void 0, mailAccount, listed2 = false) => {
|
|
2955
|
+
if (mailAccount !== void 0 && kind2 !== "mail")
|
|
2378
2956
|
throw new CliError("validation_error", "--account names a mail account \u2014 memo search mail reads it");
|
|
2379
|
-
if (
|
|
2957
|
+
if (kind2 === void 0)
|
|
2380
2958
|
return chosen;
|
|
2381
|
-
if (
|
|
2959
|
+
if (kind2 === "messages") {
|
|
2382
2960
|
if (explicit === MAIL)
|
|
2383
2961
|
throw new CliError("validation_error", "mail is searched with `memo search mail`, not search messages");
|
|
2384
2962
|
return chosen.filter(({ provider }) => holdsKindOf(provider, "messages"));
|
|
2385
2963
|
}
|
|
2386
2964
|
if (explicit !== void 0 && explicit !== MAIL && explicit !== "all")
|
|
2387
2965
|
throw new CliError("validation_error", `search mail reads mail only \u2014 \`${command === void 0 ? "" : `${command} `}search messages\` searches ${explicit}`);
|
|
2388
|
-
const mail = (
|
|
2966
|
+
const mail = (listed2 ? chosen : held).filter(({ provider }) => holdsKindOf(provider, "mail"));
|
|
2389
2967
|
if (mail.length === 0)
|
|
2390
2968
|
throw new CliError("not_found", "no mail in the store yet \u2014 `memo sync --only mail --since-time <time>` imports it", {
|
|
2391
2969
|
reason: NO_MAIL
|
|
@@ -2397,7 +2975,7 @@ var accountsOfKind = /* @__PURE__ */ __name((kind, chosen, held, explicit, comma
|
|
|
2397
2975
|
return chosenMail.map(({ provider, account }) => ({ provider, account }));
|
|
2398
2976
|
}, "accountsOfKind");
|
|
2399
2977
|
|
|
2400
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
2978
|
+
// 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/group-hint.js
|
|
2401
2979
|
var workGroupHint = /* @__PURE__ */ __name((key) => `add it to a work group: \`memo groups add work ${key.provider}:${key.account}\``, "workGroupHint");
|
|
2402
2980
|
var ungroupedHint = /* @__PURE__ */ __name(async (store, key) => {
|
|
2403
2981
|
const { groups } = (await listContextOf(store, key, void 0)).membership;
|
|
@@ -2405,7 +2983,7 @@ var ungroupedHint = /* @__PURE__ */ __name(async (store, key) => {
|
|
|
2405
2983
|
return grouped ? void 0 : workGroupHint(key);
|
|
2406
2984
|
}, "ungroupedHint");
|
|
2407
2985
|
|
|
2408
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
2986
|
+
// 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/viewer.js
|
|
2409
2987
|
var VIEWERS = "crm:viewers";
|
|
2410
2988
|
var viewersOf = /* @__PURE__ */ __name(async (store, account) => {
|
|
2411
2989
|
try {
|
|
@@ -2480,7 +3058,7 @@ var ownerOf = /* @__PURE__ */ __name(async (run, owner) => {
|
|
|
2480
3058
|
return crmIdentityId(run.account, normalCrmUserId(owner), "user");
|
|
2481
3059
|
}, "ownerOf");
|
|
2482
3060
|
|
|
2483
|
-
// node_modules/.pnpm/@wirecat+cli-core@0.
|
|
3061
|
+
// 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/sync.js
|
|
2484
3062
|
var DAY2 = 864e5;
|
|
2485
3063
|
var CLOCK_MARGIN = 60 * 6e4;
|
|
2486
3064
|
var MOST_UNLISTED = 0.5;
|
|
@@ -2514,7 +3092,7 @@ var parseCrmCursor = /* @__PURE__ */ __name((value) => {
|
|
|
2514
3092
|
return null;
|
|
2515
3093
|
}
|
|
2516
3094
|
}, "parseCrmCursor");
|
|
2517
|
-
var cursorName = /* @__PURE__ */ __name((
|
|
3095
|
+
var cursorName = /* @__PURE__ */ __name((kind2) => `crm:${kind2}`, "cursorName");
|
|
2518
3096
|
var CONTINUE = "run sync again to continue";
|
|
2519
3097
|
var fresh = /* @__PURE__ */ __name(() => ({ v: 1, token: null, round: null, done: 0, updatedAt: null, pass: null, passAt: 0 }), "fresh");
|
|
2520
3098
|
var GAPS = "crm:gaps";
|
|
@@ -2532,26 +3110,26 @@ var scopeOf = /* @__PURE__ */ __name((error) => {
|
|
|
2532
3110
|
const scope = error instanceof CliError ? error.details?.scope : void 0;
|
|
2533
3111
|
return typeof scope === "string" && scope ? scope : void 0;
|
|
2534
3112
|
}, "scopeOf");
|
|
2535
|
-
var refusal = /* @__PURE__ */ __name((
|
|
3113
|
+
var refusal = /* @__PURE__ */ __name((kind2, consequence, error, provider) => {
|
|
2536
3114
|
const code = error instanceof CliError ? error.code : "error";
|
|
2537
3115
|
const scope = scopeOf(error);
|
|
2538
|
-
const message = scope ? `${scope} scope missing: ${consequence}` : `${provider} did not list ${
|
|
2539
|
-
return { kind, reason: "refused", code, ...scope ? { scope } : {}, message };
|
|
3116
|
+
const message = scope ? `${scope} scope missing: ${consequence}` : `${provider} did not list ${kind2} (${code}): ${consequence}`;
|
|
3117
|
+
return { kind: kind2, reason: "refused", code, ...scope ? { scope } : {}, message };
|
|
2540
3118
|
}, "refusal");
|
|
2541
|
-
var readPipelines = /* @__PURE__ */ __name(async (run,
|
|
3119
|
+
var readPipelines = /* @__PURE__ */ __name(async (run, kind2) => {
|
|
2542
3120
|
const why = run.budget.take();
|
|
2543
3121
|
if (why)
|
|
2544
3122
|
return why;
|
|
2545
|
-
const
|
|
2546
|
-
const { saved, skipped } = await run.store.crm.savePipelines(run.account,
|
|
3123
|
+
const pipelines2 = await run.source.pipelines(kind2, run.context);
|
|
3124
|
+
const { saved, skipped } = await run.store.crm.savePipelines(run.account, kind2, pipelines2);
|
|
2547
3125
|
run.report.pipelines += saved;
|
|
2548
3126
|
for (const one of skipped)
|
|
2549
|
-
run.report.issues.push({ kind, ...one });
|
|
3127
|
+
run.report.issues.push({ kind: kind2, ...one });
|
|
2550
3128
|
return null;
|
|
2551
3129
|
}, "readPipelines");
|
|
2552
|
-
var noted = /* @__PURE__ */ __name((run,
|
|
3130
|
+
var noted = /* @__PURE__ */ __name((run, kind2, saved) => {
|
|
2553
3131
|
for (const { externalId, ...one } of saved.issues ?? [])
|
|
2554
|
-
run.report.issues.push({ kind, ...one, ...externalId ? { externalId } : {} });
|
|
3132
|
+
run.report.issues.push({ kind: kind2, ...one, ...externalId ? { externalId } : {} });
|
|
2555
3133
|
run.report.skippedOwnerRejected += saved.skippedOwnerRejected ?? 0;
|
|
2556
3134
|
run.unlistedUsers += saved.unlistedUsers ?? 0;
|
|
2557
3135
|
run.droppedPending += saved.droppedPending ?? 0;
|
|
@@ -2619,8 +3197,8 @@ var readActivities = /* @__PURE__ */ __name(async (run) => {
|
|
|
2619
3197
|
const { source, store, account } = run;
|
|
2620
3198
|
if (!source.activities || !await store.crm.activitiesOn(account))
|
|
2621
3199
|
return null;
|
|
2622
|
-
const
|
|
2623
|
-
run.report.activities =
|
|
3200
|
+
const read = { saved: 0, outOfScope: 0, state: "partial" };
|
|
3201
|
+
run.report.activities = read;
|
|
2624
3202
|
const saved = activityCursor((await store.sync.syncState(account, ACTIVITIES))?.value);
|
|
2625
3203
|
const cursor = saved ?? { since: run.now - ACTIVITY_DAYS * DAY2, newest: 0 };
|
|
2626
3204
|
for (; ; ) {
|
|
@@ -2639,8 +3217,8 @@ var readActivities = /* @__PURE__ */ __name(async (run) => {
|
|
|
2639
3217
|
return null;
|
|
2640
3218
|
}
|
|
2641
3219
|
const done = await store.crm.saveActivities(account, page.items);
|
|
2642
|
-
|
|
2643
|
-
|
|
3220
|
+
read.saved += done.saved;
|
|
3221
|
+
read.outOfScope += done.outOfScope;
|
|
2644
3222
|
cursor.newest = Math.max(cursor.newest, ...page.items.map((one) => one.updatedAt));
|
|
2645
3223
|
run.moved();
|
|
2646
3224
|
if (page.hasMore && page.nextCursor !== void 0) {
|
|
@@ -2652,7 +3230,7 @@ var readActivities = /* @__PURE__ */ __name(async (run) => {
|
|
|
2652
3230
|
}
|
|
2653
3231
|
const next = page.cursor != null ? Number(page.cursor) : cursor.newest || cursor.since;
|
|
2654
3232
|
await store.sync.setSyncState(account, ACTIVITIES, JSON.stringify({ since: next, newest: 0 }));
|
|
2655
|
-
|
|
3233
|
+
read.state = "complete";
|
|
2656
3234
|
return null;
|
|
2657
3235
|
}
|
|
2658
3236
|
}, "readActivities");
|
|
@@ -2663,14 +3241,14 @@ var readStageHistory = /* @__PURE__ */ __name(async (run) => {
|
|
|
2663
3241
|
if (!source.stageHistory)
|
|
2664
3242
|
return null;
|
|
2665
3243
|
const since = run.now - HISTORY_DAYS * DAY2;
|
|
2666
|
-
for (const
|
|
2667
|
-
const key = `${STAGE_HISTORY}${
|
|
3244
|
+
for (const kind2 of DEAL_KINDS.filter((one) => source.traits.kinds.includes(one))) {
|
|
3245
|
+
const key = `${STAGE_HISTORY}${kind2}`;
|
|
2668
3246
|
let after = (await store.sync.syncState(account, key))?.value;
|
|
2669
3247
|
for (; ; ) {
|
|
2670
3248
|
const why = run.budget.take();
|
|
2671
3249
|
if (why)
|
|
2672
3250
|
return why;
|
|
2673
|
-
const page = await source.stageHistory.call(source,
|
|
3251
|
+
const page = await source.stageHistory.call(source, kind2, since, after, run.context);
|
|
2674
3252
|
await store.crm.saveStageEntries(account, page.items);
|
|
2675
3253
|
run.moved();
|
|
2676
3254
|
const next = page.hasMore ? page.nextCursor : page.cursor ?? after;
|
|
@@ -2696,42 +3274,42 @@ var stopping = /* @__PURE__ */ __name(async (step) => {
|
|
|
2696
3274
|
throw error;
|
|
2697
3275
|
}
|
|
2698
3276
|
}, "stopping");
|
|
2699
|
-
var readFields = /* @__PURE__ */ __name(async (run,
|
|
3277
|
+
var readFields = /* @__PURE__ */ __name(async (run, kind2) => {
|
|
2700
3278
|
const why = run.budget.take();
|
|
2701
3279
|
if (why)
|
|
2702
3280
|
return why;
|
|
2703
|
-
const
|
|
2704
|
-
const { skipped } = await run.store.crm.saveFields(run.account,
|
|
3281
|
+
const fields2 = await run.source.fields.call(run.source, kind2, run.context);
|
|
3282
|
+
const { skipped } = await run.store.crm.saveFields(run.account, kind2, fields2);
|
|
2705
3283
|
for (const one of skipped)
|
|
2706
|
-
run.report.issues.push({ kind, ...one });
|
|
3284
|
+
run.report.issues.push({ kind: kind2, ...one });
|
|
2707
3285
|
return null;
|
|
2708
3286
|
}, "readFields");
|
|
2709
|
-
var savePage = /* @__PURE__ */ __name(async (run,
|
|
3287
|
+
var savePage = /* @__PURE__ */ __name(async (run, kind2, page) => {
|
|
2710
3288
|
const { store, account } = run;
|
|
2711
|
-
if (!isItemKind(
|
|
2712
|
-
const saved2 =
|
|
2713
|
-
noted(run,
|
|
3289
|
+
if (!isItemKind(kind2)) {
|
|
3290
|
+
const saved2 = kind2 === "person" ? await store.crm.savePeople(account, page.items) : await store.crm.saveOrganizations(account, page.items);
|
|
3291
|
+
noted(run, kind2, saved2);
|
|
2714
3292
|
return { saved: saved2.saved, stop: null };
|
|
2715
3293
|
}
|
|
2716
3294
|
const items = page.items;
|
|
2717
3295
|
const users = { users: run.source.users !== void 0 };
|
|
2718
|
-
const first = await store.crm.saveItems(account,
|
|
2719
|
-
noted(run,
|
|
3296
|
+
const first = await store.crm.saveItems(account, kind2, items, users);
|
|
3297
|
+
noted(run, kind2, first);
|
|
2720
3298
|
let { saved, skipped } = first;
|
|
2721
3299
|
let stop = null;
|
|
2722
|
-
if (skipped.some(({ reason }) => reason === "crm.stage-unknown") && !run.pipelinesReread.has(
|
|
2723
|
-
run.pipelinesReread.add(
|
|
2724
|
-
stop = await readPipelines(run,
|
|
3300
|
+
if (skipped.some(({ reason }) => reason === "crm.stage-unknown") && !run.pipelinesReread.has(kind2)) {
|
|
3301
|
+
run.pipelinesReread.add(kind2);
|
|
3302
|
+
stop = await readPipelines(run, kind2);
|
|
2725
3303
|
if (!stop) {
|
|
2726
3304
|
const again = new Set(skipped.filter(({ reason }) => reason === "crm.stage-unknown").map(({ externalId }) => externalId));
|
|
2727
|
-
const retried = await store.crm.saveItems(account,
|
|
2728
|
-
noted(run,
|
|
3305
|
+
const retried = await store.crm.saveItems(account, kind2, items.filter(({ externalId }) => again.has(externalId)), users);
|
|
3306
|
+
noted(run, kind2, retried);
|
|
2729
3307
|
saved += retried.saved;
|
|
2730
3308
|
skipped = [...skipped.filter(({ reason }) => reason !== "crm.stage-unknown"), ...retried.skipped];
|
|
2731
3309
|
}
|
|
2732
3310
|
}
|
|
2733
3311
|
for (const one of skipped)
|
|
2734
|
-
run.report.issues.push({ kind, ...one });
|
|
3312
|
+
run.report.issues.push({ kind: kind2, ...one });
|
|
2735
3313
|
return { saved, stop };
|
|
2736
3314
|
}, "savePage");
|
|
2737
3315
|
var scopeIds = /* @__PURE__ */ __name((scope) => scope.mode === "all" ? null : [...new Set(scope.also.length ? scope.also : [scope.self])].sort(), "scopeIds");
|
|
@@ -2748,31 +3326,31 @@ var appliedScope = /* @__PURE__ */ __name((cursor) => {
|
|
|
2748
3326
|
}, "appliedScope");
|
|
2749
3327
|
var inScope = /* @__PURE__ */ __name((ids2, item) => ids2 === null || item.assignee == null || ids2.includes(item.assignee), "inScope");
|
|
2750
3328
|
var normalAssignee = /* @__PURE__ */ __name((item) => item.assignee == null ? item : { ...item, assignee: normalCrmUserId(item.assignee) }, "normalAssignee");
|
|
2751
|
-
var syncKind = /* @__PURE__ */ __name(async (run,
|
|
3329
|
+
var syncKind = /* @__PURE__ */ __name(async (run, kind2, options, result) => {
|
|
2752
3330
|
const { source, store, account, now, budget, signal } = run;
|
|
2753
|
-
const name = cursorName(
|
|
3331
|
+
const name = cursorName(kind2);
|
|
2754
3332
|
let cursor = parseCrmCursor((await store.sync.syncState(account, name))?.value) ?? fresh();
|
|
2755
3333
|
if (options.rescan)
|
|
2756
3334
|
cursor = { ...cursor, round: { from: null, page: null, reset: false }, done: 0, pass: null, passAt: 0 };
|
|
2757
3335
|
const scope = scopeKey(run.scope);
|
|
2758
|
-
const ids2 = isItemKind(
|
|
3336
|
+
const ids2 = isItemKind(kind2) ? scopeIds(run.scope) : null;
|
|
2759
3337
|
const listedUnder = cursor.scope ?? "all";
|
|
2760
3338
|
const before = idsOfKey(listedUnder);
|
|
2761
|
-
const changed = isItemKind(
|
|
3339
|
+
const changed = isItemKind(kind2) && listedUnder !== scope;
|
|
2762
3340
|
let held = false;
|
|
2763
|
-
if (isItemKind(
|
|
2764
|
-
const leaving = await store.crm.removeOutOfScope(account,
|
|
2765
|
-
const stored = await store.crm.count(account,
|
|
3341
|
+
if (isItemKind(kind2) && ids2 && (cursor.narrowing === true || changed && (before === null || before.some((id2) => !ids2.includes(id2))))) {
|
|
3342
|
+
const leaving = await store.crm.removeOutOfScope(account, kind2, ids2, { dryRun: true });
|
|
3343
|
+
const stored = await store.crm.count(account, kind2);
|
|
2766
3344
|
held = !run.scopeSet && leaving > stored * MOST_UNLISTED;
|
|
2767
3345
|
if (held) {
|
|
2768
3346
|
result.held = true;
|
|
2769
3347
|
run.report.issues.push({
|
|
2770
|
-
kind,
|
|
3348
|
+
kind: kind2,
|
|
2771
3349
|
reason: "crm.narrowing-held",
|
|
2772
|
-
message: `scope mine keeps the ${
|
|
3350
|
+
message: `scope mine keeps the ${kind2}s of user ${ids2.join(", ")}: ${leaving} of the ${stored} stored would be marked deleted; none was, and none will be until the owner sets ${crmSettingKey(account, "scope")} to mine or all`
|
|
2773
3351
|
});
|
|
2774
3352
|
} else
|
|
2775
|
-
result.outOfScope += await store.crm.removeOutOfScope(account,
|
|
3353
|
+
result.outOfScope += await store.crm.removeOutOfScope(account, kind2, ids2);
|
|
2776
3354
|
}
|
|
2777
3355
|
if (changed || cursor.narrowing) {
|
|
2778
3356
|
const widened = changed && before !== null && (ids2 === null || ids2.some((id2) => !before.includes(id2)));
|
|
@@ -2787,11 +3365,11 @@ var syncKind = /* @__PURE__ */ __name(async (run, kind, options, result) => {
|
|
|
2787
3365
|
let round = cursor.round ?? { from: cursor.token, page: null, reset: false };
|
|
2788
3366
|
if (cursor.round === null)
|
|
2789
3367
|
cursor = { ...cursor, done: 0 };
|
|
2790
|
-
let
|
|
3368
|
+
let listed2 = false;
|
|
2791
3369
|
const show = /* @__PURE__ */ __name(() => Object.assign(result, { round: round.from === null ? "full" : "changes", reset: round.reset }), "show");
|
|
2792
3370
|
show();
|
|
2793
3371
|
const save = /* @__PURE__ */ __name(async (patch = {}) => {
|
|
2794
|
-
cursor = { ...cursor, round:
|
|
3372
|
+
cursor = { ...cursor, round: listed2 ? null : round, updatedAt: now, ...patch };
|
|
2795
3373
|
await store.sync.setSyncState(account, name, JSON.stringify(cursor));
|
|
2796
3374
|
}, "save");
|
|
2797
3375
|
let restarted = false;
|
|
@@ -2800,7 +3378,7 @@ var syncKind = /* @__PURE__ */ __name(async (run, kind, options, result) => {
|
|
|
2800
3378
|
const why = budget.take();
|
|
2801
3379
|
if (why)
|
|
2802
3380
|
return why;
|
|
2803
|
-
const page = await source.changes(
|
|
3381
|
+
const page = await source.changes(kind2, round.from, round.page ?? void 0, run.context);
|
|
2804
3382
|
if (signal?.aborted)
|
|
2805
3383
|
return "cancelled";
|
|
2806
3384
|
if ("reset" in page) {
|
|
@@ -2816,15 +3394,15 @@ var syncKind = /* @__PURE__ */ __name(async (run, kind, options, result) => {
|
|
|
2816
3394
|
await save();
|
|
2817
3395
|
continue;
|
|
2818
3396
|
}
|
|
2819
|
-
const items = isItemKind(
|
|
2820
|
-
const kept2 = isItemKind(
|
|
2821
|
-
const { saved, stop } = await savePage(run,
|
|
3397
|
+
const items = isItemKind(kind2) ? page.items.map(normalAssignee) : page.items;
|
|
3398
|
+
const kept2 = isItemKind(kind2) ? items.filter((item) => inScope(ids2, item)) : items;
|
|
3399
|
+
const { saved, stop } = await savePage(run, kind2, { ...page, items: kept2 });
|
|
2822
3400
|
result.saved += saved;
|
|
2823
3401
|
if (page.removed?.length)
|
|
2824
|
-
result.removed += await store.crm.remove(account,
|
|
3402
|
+
result.removed += await store.crm.remove(account, kind2, page.removed);
|
|
2825
3403
|
if (kept2.length < items.length && !held) {
|
|
2826
3404
|
const left = items.filter((item) => !inScope(ids2, item)).map(({ externalId }) => externalId);
|
|
2827
|
-
result.outOfScope += await store.crm.remove(account,
|
|
3405
|
+
result.outOfScope += await store.crm.remove(account, kind2, left);
|
|
2828
3406
|
}
|
|
2829
3407
|
run.moved();
|
|
2830
3408
|
if (stop) {
|
|
@@ -2833,7 +3411,7 @@ var syncKind = /* @__PURE__ */ __name(async (run, kind, options, result) => {
|
|
|
2833
3411
|
}
|
|
2834
3412
|
cursor = { ...cursor, done: cursor.done + saved };
|
|
2835
3413
|
if (!page.hasMore) {
|
|
2836
|
-
|
|
3414
|
+
listed2 = true;
|
|
2837
3415
|
await save({ token: page.cursor ?? null });
|
|
2838
3416
|
break;
|
|
2839
3417
|
}
|
|
@@ -2845,7 +3423,7 @@ var syncKind = /* @__PURE__ */ __name(async (run, kind, options, result) => {
|
|
|
2845
3423
|
round = { ...round, page: page.nextCursor };
|
|
2846
3424
|
await save();
|
|
2847
3425
|
}
|
|
2848
|
-
const passes = source.ids && !source.traits.removedInChanges &&
|
|
3426
|
+
const passes = source.ids && !source.traits.removedInChanges && kind2 !== "person";
|
|
2849
3427
|
const due = cursor.pass !== null || now - cursor.passAt >= (options.passEvery ?? DAY2);
|
|
2850
3428
|
const listedOf = held && ids2 ? { users: ids2 } : {};
|
|
2851
3429
|
if (passes && due) {
|
|
@@ -2858,7 +3436,7 @@ var syncKind = /* @__PURE__ */ __name(async (run, kind, options, result) => {
|
|
|
2858
3436
|
await save({ pass });
|
|
2859
3437
|
return why;
|
|
2860
3438
|
}
|
|
2861
|
-
const page = await ids3.call(source,
|
|
3439
|
+
const page = await ids3.call(source, kind2, pass.page ?? void 0, run.context);
|
|
2862
3440
|
if (signal?.aborted)
|
|
2863
3441
|
return "cancelled";
|
|
2864
3442
|
if (page.hasMore && page.nextCursor === void 0)
|
|
@@ -2870,18 +3448,18 @@ var syncKind = /* @__PURE__ */ __name(async (run, kind, options, result) => {
|
|
|
2870
3448
|
await save({ pass });
|
|
2871
3449
|
}
|
|
2872
3450
|
const before2 = pass.startedAt - CLOCK_MARGIN;
|
|
2873
|
-
const stored = await store.crm.count(account,
|
|
2874
|
-
const unlisted = await store.crm.removeUnlisted(account,
|
|
3451
|
+
const stored = await store.crm.count(account, kind2);
|
|
3452
|
+
const unlisted = await store.crm.removeUnlisted(account, kind2, pass.seen, before2, { ...listedOf, dryRun: true });
|
|
2875
3453
|
const emptied = pass.seen.length === 0 && unlisted > 0;
|
|
2876
3454
|
if (!options.rescan && (emptied || stored >= GUARDED_FROM && unlisted > stored * MOST_UNLISTED)) {
|
|
2877
3455
|
result.pass = "held";
|
|
2878
3456
|
run.report.issues.push({
|
|
2879
|
-
kind,
|
|
3457
|
+
kind: kind2,
|
|
2880
3458
|
reason: "crm.unlisted-held",
|
|
2881
|
-
message: `${source.provider} listed ${pass.seen.length} ${
|
|
3459
|
+
message: `${source.provider} listed ${pass.seen.length} ${kind2} ids, so ${unlisted} of the ${stored} stored would be marked deleted; nothing was \u2014 check the sign-in's rights, then run sync --rescan to let it through`
|
|
2882
3460
|
});
|
|
2883
3461
|
} else {
|
|
2884
|
-
result.unlisted = await store.crm.removeUnlisted(account,
|
|
3462
|
+
result.unlisted = await store.crm.removeUnlisted(account, kind2, pass.seen, before2, listedOf);
|
|
2885
3463
|
result.pass = "complete";
|
|
2886
3464
|
}
|
|
2887
3465
|
await save({ pass: null, passAt: pass.startedAt });
|
|
@@ -2892,7 +3470,7 @@ var syncKind = /* @__PURE__ */ __name(async (run, kind, options, result) => {
|
|
|
2892
3470
|
var syncCrm = /* @__PURE__ */ __name(async (source, store, account, options = {}) => {
|
|
2893
3471
|
const now = options.now ?? Date.now();
|
|
2894
3472
|
const budget = options.budget ?? runBudget();
|
|
2895
|
-
const
|
|
3473
|
+
const setting = await store.crm.scope(account);
|
|
2896
3474
|
const self = source.self ? normalCrmUserId(await source.self()) : void 0;
|
|
2897
3475
|
if (self !== void 0 && !isCrmUserId(self))
|
|
2898
3476
|
throw new CliError("invalid_response", `${source.provider} named its sign-in's user as "${self}", not a user id`);
|
|
@@ -2902,14 +3480,14 @@ var syncCrm = /* @__PURE__ */ __name(async (source, store, account, options = {}
|
|
|
2902
3480
|
if (owner === void 0)
|
|
2903
3481
|
await store.crm.saveOwnUser(account, self);
|
|
2904
3482
|
else if (owner !== self) {
|
|
2905
|
-
const
|
|
2906
|
-
throw new CliError("validation_error", `this account's copy is user ${owner}'s, and this sign-in is user ${self}: one copy holds one user's deals, under scope all too, since ${
|
|
3483
|
+
const setting2 = crmSettingKey(account, "self");
|
|
3484
|
+
throw new CliError("validation_error", `this account's copy is user ${owner}'s, and this sign-in is user ${self}: one copy holds one user's deals, under scope all too, since ${setting2} decides whose deals a later scope mine keeps; "config unset ${setting2}" gives the copy to this sign-in`, { setting: setting2 });
|
|
2907
3485
|
}
|
|
2908
3486
|
}
|
|
2909
|
-
const
|
|
2910
|
-
const allowed = self !== void 0 && source.unassigned &&
|
|
2911
|
-
const dropped =
|
|
2912
|
-
const scope = self !== void 0 &&
|
|
3487
|
+
const listed2 = setting.mode === "mine" ? setting.also.map(normalCrmUserId) : [];
|
|
3488
|
+
const allowed = self !== void 0 && source.unassigned && listed2.length && listed2.every(isCrmUserId) ? await source.unassigned(listed2) : { kept: listed2 };
|
|
3489
|
+
const dropped = listed2.filter((id2) => !allowed.kept.includes(id2));
|
|
3490
|
+
const scope = self !== void 0 && setting.mode === "mine" ? { mode: "mine", self, also: listed2.filter((id2) => !dropped.includes(id2)) } : { mode: "all" };
|
|
2913
3491
|
const report = {
|
|
2914
3492
|
provider: source.provider,
|
|
2915
3493
|
account: account.account,
|
|
@@ -2932,7 +3510,7 @@ var syncCrm = /* @__PURE__ */ __name(async (source, store, account, options = {}
|
|
|
2932
3510
|
const run = {
|
|
2933
3511
|
source,
|
|
2934
3512
|
scope,
|
|
2935
|
-
scopeSet:
|
|
3513
|
+
scopeSet: setting.mode === "mine" && setting.explicit,
|
|
2936
3514
|
store,
|
|
2937
3515
|
account,
|
|
2938
3516
|
now,
|
|
@@ -2943,10 +3521,10 @@ var syncCrm = /* @__PURE__ */ __name(async (source, store, account, options = {}
|
|
|
2943
3521
|
moved: /* @__PURE__ */ __name(() => {
|
|
2944
3522
|
steps += 1;
|
|
2945
3523
|
}, "moved"),
|
|
2946
|
-
gaps: CRM_KINDS.filter((
|
|
2947
|
-
kind,
|
|
3524
|
+
gaps: CRM_KINDS.filter((kind2) => !source.traits.kinds.includes(kind2)).map((kind2) => ({
|
|
3525
|
+
kind: kind2,
|
|
2948
3526
|
reason: "not-listed",
|
|
2949
|
-
message: `${source.provider} has no ${
|
|
3527
|
+
message: `${source.provider} has no ${kind2}s`
|
|
2950
3528
|
})),
|
|
2951
3529
|
context: {
|
|
2952
3530
|
spend: /* @__PURE__ */ __name(() => {
|
|
@@ -2954,40 +3532,40 @@ var syncCrm = /* @__PURE__ */ __name(async (source, store, account, options = {}
|
|
|
2954
3532
|
if (why)
|
|
2955
3533
|
throw new BudgetSpent(why);
|
|
2956
3534
|
}, "spend"),
|
|
2957
|
-
gap: /* @__PURE__ */ __name(({ kind, message, scope: scope2 }) => run.gaps.push({ kind, reason: "partial", message, ...scope2 ? { scope: scope2 } : {} }), "gap"),
|
|
3535
|
+
gap: /* @__PURE__ */ __name(({ kind: kind2, message, scope: scope2 }) => run.gaps.push({ kind: kind2, reason: "partial", message, ...scope2 ? { scope: scope2 } : {} }), "gap"),
|
|
2958
3536
|
scope
|
|
2959
3537
|
},
|
|
2960
3538
|
unlistedUsers: 0,
|
|
2961
3539
|
droppedPending: 0
|
|
2962
3540
|
};
|
|
2963
|
-
const kinds = CRM_KINDS.filter((
|
|
2964
|
-
const cursors = await Promise.all(kinds.map((
|
|
3541
|
+
const kinds = CRM_KINDS.filter((kind2) => source.traits.kinds.includes(kind2));
|
|
3542
|
+
const cursors = await Promise.all(kinds.map((kind2) => store.sync.syncState(account, cursorName(kind2))));
|
|
2965
3543
|
const first = cursors.every((cursor) => cursor === void 0);
|
|
2966
|
-
const malformed = scope.mode === "mine" &&
|
|
3544
|
+
const malformed = scope.mode === "mine" && setting.mode === "mine" ? setting.also.find((id2) => !isCrmUserId(id2)) : void 0;
|
|
2967
3545
|
let stopped = null;
|
|
2968
|
-
for (const
|
|
2969
|
-
if (!stopped && kinds.includes(
|
|
2970
|
-
stopped = await stopping(() => readPipelines(run,
|
|
3546
|
+
for (const kind2 of DEAL_KINDS)
|
|
3547
|
+
if (!stopped && kinds.includes(kind2)) {
|
|
3548
|
+
stopped = await stopping(() => readPipelines(run, kind2));
|
|
2971
3549
|
if (options.signal?.aborted)
|
|
2972
3550
|
stopped = "cancelled";
|
|
2973
3551
|
}
|
|
2974
3552
|
if (run.source.fields) {
|
|
2975
|
-
for (const
|
|
3553
|
+
for (const kind2 of kinds)
|
|
2976
3554
|
if (!stopped) {
|
|
2977
|
-
stopped = await stopping(() => readFields(run,
|
|
3555
|
+
stopped = await stopping(() => readFields(run, kind2));
|
|
2978
3556
|
if (options.signal?.aborted)
|
|
2979
3557
|
stopped = "cancelled";
|
|
2980
3558
|
}
|
|
2981
3559
|
}
|
|
2982
3560
|
let usersRead = false;
|
|
2983
|
-
for (const
|
|
2984
|
-
if (!usersRead && isItemKind(
|
|
3561
|
+
for (const kind2 of kinds) {
|
|
3562
|
+
if (!usersRead && isItemKind(kind2)) {
|
|
2985
3563
|
usersRead = true;
|
|
2986
3564
|
if (!stopped)
|
|
2987
3565
|
stopped = await stopping(() => readUsers(run));
|
|
2988
3566
|
}
|
|
2989
3567
|
const result = {
|
|
2990
|
-
kind,
|
|
3568
|
+
kind: kind2,
|
|
2991
3569
|
round: "changes",
|
|
2992
3570
|
reset: false,
|
|
2993
3571
|
state: "partial",
|
|
@@ -2999,17 +3577,17 @@ var syncCrm = /* @__PURE__ */ __name(async (source, store, account, options = {}
|
|
|
2999
3577
|
report.synced.push(result);
|
|
3000
3578
|
if (stopped)
|
|
3001
3579
|
continue;
|
|
3002
|
-
if (malformed !== void 0 && isItemKind(
|
|
3580
|
+
if (malformed !== void 0 && isItemKind(kind2)) {
|
|
3003
3581
|
Object.assign(result, {
|
|
3004
|
-
error: `unassigned holds "${malformed}", not a numeric user id: no ${
|
|
3582
|
+
error: `unassigned holds "${malformed}", not a numeric user id: no ${kind2} was read`,
|
|
3005
3583
|
setting: crmSettingKey(account, "unassigned")
|
|
3006
3584
|
});
|
|
3007
3585
|
continue;
|
|
3008
3586
|
}
|
|
3009
3587
|
try {
|
|
3010
|
-
stopped = await syncKind(run,
|
|
3011
|
-
if (
|
|
3012
|
-
noted(run,
|
|
3588
|
+
stopped = await syncKind(run, kind2, options, result);
|
|
3589
|
+
if (kind2 === "organization")
|
|
3590
|
+
noted(run, kind2, await store.crm.saveCompanyTypes(account));
|
|
3013
3591
|
} catch (error) {
|
|
3014
3592
|
if (options.signal?.aborted) {
|
|
3015
3593
|
stopped = "cancelled";
|
|
@@ -3020,8 +3598,8 @@ var syncCrm = /* @__PURE__ */ __name(async (source, store, account, options = {}
|
|
|
3020
3598
|
continue;
|
|
3021
3599
|
}
|
|
3022
3600
|
if (scopeOf(error))
|
|
3023
|
-
run.gaps.push(refusal(
|
|
3024
|
-
result.error = isCliFailure(error) ? error.message : `the ${
|
|
3601
|
+
run.gaps.push(refusal(kind2, `no ${kind2} was read`, error, source.provider));
|
|
3602
|
+
result.error = isCliFailure(error) ? error.message : `the ${kind2} copy could not be synced`;
|
|
3025
3603
|
}
|
|
3026
3604
|
}
|
|
3027
3605
|
run.droppedPending += (await store.crm.retryPending(account)).dropped;
|
|
@@ -3093,28 +3671,28 @@ var SYNC_FAILED = "crm:sync-failed";
|
|
|
3093
3671
|
var SYNCED_FROM = "crm:synced-from";
|
|
3094
3672
|
var syncRecorded = /* @__PURE__ */ __name(async (...args) => {
|
|
3095
3673
|
const [, store, account, options] = args;
|
|
3096
|
-
const
|
|
3097
|
-
const
|
|
3674
|
+
const at2 = options?.now ?? Date.now();
|
|
3675
|
+
const record2 = /* @__PURE__ */ __name((kinds) => store.sync.setSyncState(account, SYNC_FAILED, kinds.length ? JSON.stringify({ at: at2, kinds }) : "").catch(() => void 0), "record");
|
|
3098
3676
|
try {
|
|
3099
3677
|
const report = await syncCrm(...args);
|
|
3100
3678
|
const failed = report.synced.filter((one) => one.error !== void 0).map((one) => one.kind);
|
|
3101
|
-
await
|
|
3679
|
+
await record2(failed);
|
|
3102
3680
|
if (report.state === "complete" && !failed.length)
|
|
3103
|
-
await store.sync.setSyncState(account, SYNCED_FROM, String(
|
|
3681
|
+
await store.sync.setSyncState(account, SYNCED_FROM, String(at2));
|
|
3104
3682
|
return report;
|
|
3105
3683
|
} catch (error) {
|
|
3106
|
-
await
|
|
3684
|
+
await record2(["all"]);
|
|
3107
3685
|
throw error;
|
|
3108
3686
|
}
|
|
3109
3687
|
}, "syncRecorded");
|
|
3110
3688
|
var crmStatus = /* @__PURE__ */ __name(async (store, account, { profile, now, kinds = CRM_KINDS }) => {
|
|
3111
3689
|
const saved = await store.crm.scope(account);
|
|
3112
|
-
const
|
|
3690
|
+
const setting = { setting: saved.mode, explicit: saved.mode === "all" || saved.explicit };
|
|
3113
3691
|
const items = [];
|
|
3114
|
-
for (const
|
|
3115
|
-
const cursor = parseCrmCursor((await store.sync.syncState(account, cursorName(
|
|
3692
|
+
for (const kind2 of kinds) {
|
|
3693
|
+
const cursor = parseCrmCursor((await store.sync.syncState(account, cursorName(kind2)))?.value);
|
|
3116
3694
|
const progress = progressOf({
|
|
3117
|
-
job: `crm ${
|
|
3695
|
+
job: `crm ${kind2}`,
|
|
3118
3696
|
profile,
|
|
3119
3697
|
done: cursor?.done ?? 0,
|
|
3120
3698
|
complete: cursor !== null && cursor.round === null && cursor.pass === null,
|
|
@@ -3122,11 +3700,11 @@ var crmStatus = /* @__PURE__ */ __name(async (store, account, { profile, now, ki
|
|
|
3122
3700
|
now: new Date(now)
|
|
3123
3701
|
});
|
|
3124
3702
|
items.push({
|
|
3125
|
-
kind,
|
|
3703
|
+
kind: kind2,
|
|
3126
3704
|
round: cursor?.round ? cursor.round.from === null ? "full" : "changes" : null,
|
|
3127
3705
|
id_pass: cursor?.pass ? "partial" : cursor?.passAt ? new Date(cursor.passAt).toISOString() : null,
|
|
3128
|
-
stored: await store.crm.count(account,
|
|
3129
|
-
...isItemKind(
|
|
3706
|
+
stored: await store.crm.count(account, kind2),
|
|
3707
|
+
...isItemKind(kind2) ? { scope: { ...setting, applied: appliedScope(cursor), ...cursor?.narrowing ? { held: true } : {} } } : {},
|
|
3130
3708
|
...progress,
|
|
3131
3709
|
line: progressLine(progress)
|
|
3132
3710
|
});
|
|
@@ -3145,44 +3723,40 @@ export {
|
|
|
3145
3723
|
listContextOf,
|
|
3146
3724
|
listedAccounts,
|
|
3147
3725
|
accountsOfKind,
|
|
3148
|
-
momentOf,
|
|
3149
|
-
dateWindow,
|
|
3150
3726
|
parseCrmFileId,
|
|
3151
3727
|
withoutFileLinks,
|
|
3728
|
+
CRM_SHARED_FOLDERS,
|
|
3152
3729
|
foreignContactsPathFor,
|
|
3153
3730
|
foreignContacts,
|
|
3154
3731
|
refuseForeignClientReads,
|
|
3732
|
+
values_exports,
|
|
3733
|
+
at,
|
|
3734
|
+
identifier,
|
|
3735
|
+
graphqlDocument,
|
|
3736
|
+
LosslessNumber,
|
|
3737
|
+
isLosslessNumber,
|
|
3738
|
+
apiFlagOf,
|
|
3739
|
+
apiOptionKey,
|
|
3740
|
+
checkApiParameter,
|
|
3741
|
+
sendsBytes,
|
|
3742
|
+
readApiBytes,
|
|
3743
|
+
readApiBody,
|
|
3744
|
+
checkApiBody,
|
|
3745
|
+
parseApiJson,
|
|
3746
|
+
apiJson,
|
|
3747
|
+
apiPlainJson,
|
|
3748
|
+
graphqlVariables,
|
|
3749
|
+
manifestBaseUrl,
|
|
3750
|
+
siteValue,
|
|
3751
|
+
signRequest,
|
|
3752
|
+
underBase,
|
|
3753
|
+
parameterValue,
|
|
3754
|
+
nextPage,
|
|
3155
3755
|
DEFAULT_PACE,
|
|
3156
3756
|
pacePathFor,
|
|
3157
3757
|
Pacer,
|
|
3158
3758
|
waitForTurn,
|
|
3159
3759
|
providerCall,
|
|
3160
|
-
meetingPassageRequest,
|
|
3161
|
-
createMeetingPassageCommand,
|
|
3162
|
-
meetingHitSearchRequest,
|
|
3163
|
-
meetingSearchArguments,
|
|
3164
|
-
meetingSearchMeta,
|
|
3165
|
-
createMeetingSearchCommand,
|
|
3166
|
-
addMeetingCommands,
|
|
3167
|
-
LIST_QUERY_GUIDE,
|
|
3168
|
-
QUERY_ARGUMENT,
|
|
3169
|
-
withQuery,
|
|
3170
|
-
unfilteredQuery,
|
|
3171
|
-
commandPath,
|
|
3172
|
-
listQuery,
|
|
3173
|
-
typedQuery,
|
|
3174
|
-
pageOf,
|
|
3175
|
-
pagedList,
|
|
3176
|
-
queryArgument,
|
|
3177
|
-
negatableOf,
|
|
3178
|
-
nativeTerms,
|
|
3179
|
-
nativeTermLists,
|
|
3180
|
-
queryTerms,
|
|
3181
|
-
timeBounds,
|
|
3182
|
-
searchText,
|
|
3183
|
-
nativeField,
|
|
3184
|
-
termField,
|
|
3185
|
-
queryHelp,
|
|
3186
3760
|
holdEnd,
|
|
3187
3761
|
floodPathFor,
|
|
3188
3762
|
FloodMemory,
|
|
@@ -3227,6 +3801,5 @@ export {
|
|
|
3227
3801
|
SYNC_FAILED,
|
|
3228
3802
|
SYNCED_FROM,
|
|
3229
3803
|
syncRecorded,
|
|
3230
|
-
crmStatus
|
|
3231
|
-
values_exports
|
|
3804
|
+
crmStatus
|
|
3232
3805
|
};
|