@wirecat/notion-cli 0.5.0 → 0.7.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 +5 -0
- package/contracts/wirecat.json +55 -2
- package/dist/bin/notion.js +2 -2
- package/dist/bundle/agent-AILW4JPO.js +42 -0
- package/dist/bundle/{all-profiles-V37KCXH3.js → all-profiles-CKOACXTW.js} +64 -21
- package/dist/bundle/{anthropic-Q4S3BYXD.js → anthropic-DWBBVTU3.js} +6 -6
- package/dist/bundle/{app-server-43SR3ACI.js → app-server-BHFYNCDE.js} +86 -65
- package/dist/bundle/{bun-M3J2QTR3.js → bun-ICK2XT7J.js} +2 -2
- package/dist/bundle/{bun-sqlite-EJ3W2PSV.js → bun-sqlite-LU5V5Y4A.js} +7 -7
- package/dist/bundle/{chunk-KHWOLBHQ.js → chunk-2OZVCNU5.js} +2 -2
- package/dist/bundle/{chunk-O5YB7FQD.js → chunk-2RNJ2JP3.js} +4 -4
- package/dist/bundle/{chunk-TP7GDWVF.js → chunk-364ET7LV.js} +1 -1
- package/dist/bundle/{chunk-TDNURSU6.js → chunk-3AKMIKND.js} +19 -19
- package/dist/bundle/{chunk-O3DYRCIT.js → chunk-3DGHBXH2.js} +1 -1
- package/dist/bundle/chunk-3KOJNZH3.js +80 -0
- package/dist/bundle/{chunk-DSP36YHQ.js → chunk-3T3OAYL4.js} +2 -2
- package/dist/bundle/{chunk-W7HM2VGO.js → chunk-3YXYA6HB.js} +1 -1
- package/dist/bundle/chunk-3ZSUVFR7.js +398 -0
- package/dist/bundle/{chunk-GCZ6MAEN.js → chunk-46JBCXLI.js} +43 -64
- package/dist/bundle/{chunk-DB2XKHI4.js → chunk-4FHKSSXQ.js} +2 -2
- package/dist/bundle/chunk-4HP6KGBI.js +32 -0
- package/dist/bundle/chunk-4ZAQMDLD.js +1308 -0
- package/dist/bundle/chunk-4ZTB7LS3.js +87 -0
- package/dist/bundle/{chunk-BNEE35WD.js → chunk-5NFIUY2P.js} +4 -4
- package/dist/bundle/{chunk-E5WLE7BM.js → chunk-63SW4UXG.js} +3 -4
- package/dist/bundle/{chunk-NHHJHXMQ.js → chunk-64IK7JFO.js} +2 -2
- package/dist/bundle/{chunk-HZRQLAHO.js → chunk-6MQSBWWF.js} +1 -1
- package/dist/bundle/{chunk-2FJNMADN.js → chunk-6UZ5D2WP.js} +10 -10
- package/dist/bundle/chunk-6VPC5Z56.js +2145 -0
- package/dist/bundle/chunk-7COTHS6G.js +388 -0
- package/dist/bundle/{chunk-TOSCB4SO.js → chunk-A3RJ6FD5.js} +29 -10
- package/dist/bundle/chunk-ADCAWRRX.js +2366 -0
- package/dist/bundle/{chunk-PPHBRESD.js → chunk-ALAPDLCP.js} +2 -2
- package/dist/bundle/{chunk-ONZVPE24.js → chunk-B6DJQBZI.js} +6 -6
- package/dist/bundle/{chunk-N2XADGL4.js → chunk-BFCRGLOF.js} +4 -4
- package/dist/bundle/{chunk-5P5TXU2K.js → chunk-BFHPT67P.js} +9581 -10764
- package/dist/bundle/{chunk-NA6QLHBZ.js → chunk-BQ6CXCLP.js} +10 -8
- package/dist/bundle/{chunk-JCKWQGCD.js → chunk-BXXHUO7Y.js} +110 -862
- package/dist/bundle/chunk-DCSPCOPB.js +221 -0
- package/dist/bundle/chunk-DQSOYH6N.js +20 -0
- package/dist/bundle/chunk-ECYOTDJM.js +14 -0
- package/dist/bundle/chunk-EMIJVLOA.js +30 -0
- package/dist/bundle/{chunk-DFCHHR5M.js → chunk-EUF5JNPG.js} +1 -1
- package/dist/bundle/{chunk-RIGE67FR.js → chunk-EWXMIKZN.js} +43 -33
- package/dist/bundle/chunk-F4BX7TH2.js +15 -0
- package/dist/bundle/{chunk-QYXWRKNA.js → chunk-FHYV4VWY.js} +16 -9
- package/dist/bundle/{chunk-WE4UFASG.js → chunk-FNESLLZS.js} +29 -1
- package/dist/bundle/chunk-FO3XY2Y2.js +108 -0
- package/dist/bundle/chunk-HJDQTM3T.js +353 -0
- package/dist/bundle/chunk-HOO53OYK.js +561 -0
- package/dist/bundle/{chunk-KHZ2RGXI.js → chunk-HSVKU4OJ.js} +153 -572
- package/dist/bundle/{chunk-CDK5E45T.js → chunk-IEY7KS6Q.js} +2 -100
- package/dist/bundle/{chunk-RJMQGG3P.js → chunk-ITW26OBI.js} +65 -49
- package/dist/bundle/{chunk-FBZI4Z3Z.js → chunk-ITWINZ6R.js} +13 -26
- package/dist/bundle/{chunk-J3NKZ6MO.js → chunk-IYZWHCZJ.js} +155 -435
- package/dist/bundle/{chunk-W53EJOFQ.js → chunk-J3DZVB67.js} +1 -1
- package/dist/bundle/{chunk-FKA7DOCK.js → chunk-JEZJFQQW.js} +1 -1
- package/dist/bundle/chunk-JPGN473W.js +50 -0
- package/dist/bundle/{chunk-NTG657MI.js → chunk-JVRBW5LH.js} +7 -64
- package/dist/bundle/chunk-KBY42GKW.js +785 -0
- package/dist/bundle/{chunk-DO7BLXO3.js → chunk-KWBLDSRV.js} +16 -3
- package/dist/bundle/chunk-L7P3LUDQ.js +286 -0
- package/dist/bundle/{chunk-PWRRDDMZ.js → chunk-LBRTLZHI.js} +249 -555
- package/dist/bundle/{chunk-B3FSLAIU.js → chunk-LEPPRULN.js} +20 -6
- package/dist/bundle/{chunk-WPP76PSX.js → chunk-LVAFTQ45.js} +32 -24
- package/dist/bundle/{chunk-PAW6RRCW.js → chunk-MB4HXDBT.js} +8 -210
- package/dist/bundle/chunk-MEYYH47C.js +25 -0
- package/dist/bundle/{chunk-UZSBGECU.js → chunk-N3NJPHZB.js} +1 -65
- package/dist/bundle/{chunk-BWLBSQSU.js → chunk-NCCRLAAI.js} +4 -4
- package/dist/bundle/chunk-NMQRSEZM.js +37 -0
- package/dist/bundle/{chunk-H3E2PZ5Y.js → chunk-NV7NNL5T.js} +7 -7
- package/dist/bundle/chunk-OALFRUMI.js +67 -0
- package/dist/bundle/{chunk-CWXOXIWS.js → chunk-OCGNOJYD.js} +1 -1
- package/dist/bundle/chunk-OFMCU3BH.js +72 -0
- package/dist/bundle/{chunk-MGUEZYFA.js → chunk-OLAGFJDM.js} +13 -2143
- package/dist/bundle/{chunk-E2AFUJDR.js → chunk-OP2BH55P.js} +3 -3
- package/dist/bundle/{chunk-P5BHKKBI.js → chunk-OS4WPXPZ.js} +4 -4
- package/dist/bundle/{chunk-XUPN2EHR.js → chunk-OW5HW3TD.js} +23 -7
- package/dist/bundle/{chunk-ECC2UX7X.js → chunk-PDVXG3T3.js} +6 -6
- package/dist/bundle/{chunk-5D4AEUVA.js → chunk-PL5P7UKW.js} +434 -1
- package/dist/bundle/{chunk-G2MJYXZG.js → chunk-PSMRUOII.js} +4 -4
- package/dist/bundle/{chunk-DBEQI5YM.js → chunk-QK52ARAU.js} +3 -3
- package/dist/bundle/{chunk-QWYMXFKM.js → chunk-QMNEDK7Z.js} +3 -3
- package/dist/bundle/chunk-R4JV3VLU.js +714 -0
- package/dist/bundle/{chunk-C32AKHTY.js → chunk-REOBWSGV.js} +35 -12
- package/dist/bundle/{chunk-X2M6NIQG.js → chunk-RNVYNPXT.js} +1 -1
- package/dist/bundle/{chunk-HHVFIXDO.js → chunk-RXGX2CZX.js} +399 -399
- package/dist/bundle/{chunk-W5JZMXGW.js → chunk-S35UJBFZ.js} +75 -75
- package/dist/bundle/{chunk-MVA5HVKL.js → chunk-S4UUN6LD.js} +18 -0
- package/dist/bundle/chunk-S5P7THM5.js +72 -0
- package/dist/bundle/{chunk-NE43YXKL.js → chunk-SRVTGI3M.js} +3 -3
- package/dist/bundle/chunk-TRYYWV7J.js +291 -0
- package/dist/bundle/chunk-TWY543BS.js +39 -0
- package/dist/bundle/{chunk-KFVDL2QS.js → chunk-UC7JLE6J.js} +1 -89
- package/dist/bundle/{chunk-3RL2MIUF.js → chunk-UO4O6WQ4.js} +8 -8
- package/dist/bundle/chunk-UPL474OW.js +94 -0
- package/dist/bundle/chunk-UQVUXG7H.js +594 -0
- package/dist/bundle/chunk-UYEDQGMI.js +340 -0
- package/dist/bundle/chunk-VNWF4I7E.js +34 -0
- package/dist/bundle/{chunk-FPUGMDJV.js → chunk-VRBEYOJL.js} +1 -1
- package/dist/bundle/{chunk-BBSFQ3PU.js → chunk-VXKD533R.js} +1646 -1337
- package/dist/bundle/{chunk-ECEZOLOD.js → chunk-VYZ2J7DT.js} +4 -4
- package/dist/bundle/{chunk-TD2JZ25O.js → chunk-WJFQMOVM.js} +113 -80
- package/dist/bundle/{chunk-MNRMKWCN.js → chunk-WUNEJRLJ.js} +6 -6
- package/dist/bundle/chunk-WVN2KTNS.js +52 -0
- package/dist/bundle/{chunk-GTY6N5KZ.js → chunk-X5LUHN62.js} +2 -2
- package/dist/bundle/{chunk-LBYGJKXW.js → chunk-X737FHZP.js} +4 -4
- package/dist/bundle/chunk-YHWFF6DN.js +39 -0
- package/dist/bundle/chunk-YSF5JBRA.js +36 -0
- package/dist/bundle/{chunk-QIG55MZH.js → chunk-ZGUUP2T3.js} +12 -12
- package/dist/bundle/{chunk-AT5I34AN.js → chunk-ZMKAI3F3.js} +3 -3
- package/dist/bundle/command-contract-C2CF4QAH.js +41 -0
- package/dist/bundle/{command-server-entry-LJ627ZUA.js → command-server-entry-F3B2KSPO.js} +30 -27
- package/dist/bundle/{decode-PX2LZ5Y2.js → decode-FDHFF7GC.js} +6 -6
- package/dist/bundle/{definitions-M3U4UYHN.js → definitions-MB65223J.js} +72 -18
- package/dist/bundle/{dispatch-KOISQ5QJ.js → dispatch-IXKG5Z5Y.js} +8 -8
- package/dist/bundle/dist-PAKDDIBT.js +191 -0
- package/dist/bundle/{echarts-FVTUDXDU.js → echarts-PGJPVPA4.js} +2 -2
- package/dist/bundle/{embed-CCSDK43I.js → embed-U6X7CNNK.js} +7 -7
- package/dist/bundle/{embedder-VHI4DHB7.js → embedder-3ROL6ROQ.js} +10 -10
- package/dist/bundle/{failure-FZ6VYKEQ.js → failure-IYMRXM2X.js} +3 -3
- package/dist/bundle/first-run-PNVNHGR7.js +29 -0
- package/dist/bundle/first-screen-DEDD64YH.js +41 -0
- package/dist/bundle/hast-util-from-html-X2DCPS3T.js +10531 -0
- package/dist/bundle/hast-util-to-html-IIFHILP5.js +998 -0
- package/dist/bundle/hast-util-to-mdast-3CSMIWK2.js +2272 -0
- package/dist/bundle/{instructions-HET7BCYK.js → instructions-MJQWRI2D.js} +1 -1
- package/dist/bundle/{mcp-RGNRW77S.js → mcp-JNHOSK4L.js} +2 -2
- package/dist/bundle/{mdast-util-from-markdown-R66F4HZA.js → mdast-util-from-markdown-XCR5KW5S.js} +138 -195
- package/dist/bundle/{mdast-util-gfm-LN2ELINH.js → mdast-util-gfm-JO7PHUIB.js} +28 -357
- package/dist/bundle/mdast-util-to-hast-AYJV7KAE.js +879 -0
- package/dist/bundle/mdast-util-to-markdown-DOXGHRI7.js +1854 -0
- package/dist/bundle/meeting-combined-HEC25QPY.js +25 -0
- package/dist/bundle/meeting-model-R7QPDNZZ.js +27 -0
- package/dist/bundle/{meeting-semantic-UD26T37N.js → meeting-semantic-7WPLMBNT.js} +7 -7
- package/dist/bundle/{micromark-extension-gfm-5X7YT43T.js → micromark-extension-gfm-PQ7DWZM7.js} +12 -78
- package/dist/bundle/{node-CXZIFHZC.js → node-3UXNV3CD.js} +2 -2
- package/dist/bundle/{node-sqlite-ME7KMORI.js → node-sqlite-ULWDWM3I.js} +8 -8
- package/dist/bundle/notes-search-7PE3E3C7.js +64 -0
- package/dist/bundle/notion.js +14 -14
- package/dist/bundle/oauth-LNUZMA72.js +20 -0
- package/dist/bundle/{open-HA6D3SXR.js → open-HGHC35M4.js} +6 -6
- package/dist/bundle/{openai-H5AJPZBX.js → openai-ISSP57MV.js} +21 -18
- package/dist/bundle/{process-5RUXWGYS.js → process-PB2WCOR2.js} +1 -1
- package/dist/bundle/{program-F3NBTZ7J.js → program-GASBJRMG.js} +7574 -7047
- package/dist/bundle/{prompt-6XSUOLHK.js → prompt-3VGQVX2B.js} +6 -6
- package/dist/bundle/{recognize-2Y7AUVGG.js → recognize-7Q2P3NME.js} +5 -5
- package/dist/bundle/{remote-KCABPXQ3.js → remote-BBAWKVIT.js} +12 -11
- package/dist/bundle/{rerank-BTN7LUVA.js → rerank-H4PUS4HV.js} +8 -8
- package/dist/bundle/{schemas-VVLTLMXS.js → schemas-TTVUADHT.js} +39 -60
- package/dist/bundle/{serve-CYEMVRFC.js → serve-FZNSKY7R.js} +11 -11
- package/dist/bundle/{server-WFIICGMI.js → server-BRRNDW6L.js} +78 -56
- package/dist/bundle/server-CQJ4LKAZ.js +90 -0
- package/dist/bundle/{services-L4W6ZWDG.js → services-PEU557KZ.js} +103 -88
- package/dist/bundle/{sqlite-runtime-IKMYLRQC.js → sqlite-runtime-4IZJ4YUM.js} +7 -7
- package/dist/bundle/{state-LMUP636P.js → state-MX3JVT5Q.js} +7 -7
- package/dist/bundle/{store-W2JC2JP4.js → store-JUT34REM.js} +24 -20
- package/dist/bundle/{store-A2QZFBOX.js → store-PP4BPADZ.js} +30 -18
- package/dist/bundle/store-maintenance-command-GRFTJBSB.js +77 -0
- package/dist/bundle/surface-FPWES3NY.js +76 -0
- package/dist/commands/account.d.ts +3 -0
- package/dist/commands/account.d.ts.map +1 -0
- package/dist/commands/account.js +22 -0
- package/dist/commands/account.js.map +1 -0
- package/dist/commands/api.d.ts +7 -2
- package/dist/commands/api.d.ts.map +1 -1
- package/dist/commands/api.js +19 -141
- package/dist/commands/api.js.map +1 -1
- package/dist/commands/library.d.ts.map +1 -1
- package/dist/commands/library.js +14 -6
- package/dist/commands/library.js.map +1 -1
- package/dist/config.d.ts +11 -13
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +63 -54
- package/dist/config.js.map +1 -1
- package/dist/context.d.ts +11 -3
- package/dist/context.d.ts.map +1 -1
- package/dist/context.js +20 -7
- package/dist/context.js.map +1 -1
- package/dist/generated/definitions.d.ts.map +1 -1
- package/dist/generated/definitions.js +72 -18
- package/dist/generated/definitions.js.map +1 -1
- package/dist/generated/manifest.d.ts.map +1 -1
- package/dist/generated/manifest.js +49 -0
- package/dist/generated/manifest.js.map +1 -1
- package/dist/generated/schemas.d.ts.map +1 -1
- package/dist/generated/schemas.js +32 -32
- package/dist/generated/schemas.js.map +1 -1
- package/dist/generated/types.d.ts +125 -25
- package/dist/generated/types.d.ts.map +1 -1
- package/dist/generated/wirecat-config.d.ts +13 -0
- package/dist/generated/wirecat-config.d.ts.map +1 -0
- package/dist/generated/wirecat-config.js +82 -0
- package/dist/generated/wirecat-config.js.map +1 -0
- package/dist/library.d.ts +3 -0
- package/dist/library.d.ts.map +1 -1
- package/dist/library.js +11 -1
- package/dist/library.js.map +1 -1
- package/dist/notion/client.d.ts +2 -6
- package/dist/notion/client.d.ts.map +1 -1
- package/dist/notion/client.js +7 -8
- package/dist/notion/client.js.map +1 -1
- package/dist/notion/errors.d.ts +5 -0
- package/dist/notion/errors.d.ts.map +1 -1
- package/dist/notion/errors.js +21 -1
- package/dist/notion/errors.js.map +1 -1
- package/dist/notion/port.d.ts +10 -0
- package/dist/notion/port.d.ts.map +1 -1
- package/dist/notion/port.js +19 -0
- package/dist/notion/port.js.map +1 -1
- package/dist/program.d.ts.map +1 -1
- package/dist/program.js +2 -0
- package/dist/program.js.map +1 -1
- package/dist/sync/files.d.ts +12 -0
- package/dist/sync/files.d.ts.map +1 -1
- package/dist/sync/files.js.map +1 -1
- package/dist/sync/from-config.d.ts +13 -0
- package/dist/sync/from-config.d.ts.map +1 -0
- package/dist/sync/from-config.js +32 -0
- package/dist/sync/from-config.js.map +1 -0
- package/dist/sync/source.d.ts +2 -1
- package/dist/sync/source.d.ts.map +1 -1
- package/dist/sync/source.js +48 -48
- package/dist/sync/source.js.map +1 -1
- package/dist/sync/users.d.ts +4 -1
- package/dist/sync/users.d.ts.map +1 -1
- package/dist/sync/users.js +3 -1
- package/dist/sync/users.js.map +1 -1
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +8 -8
- package/dist/bundle/chunk-6EOZTUHT.js +0 -726
- package/dist/bundle/command-contract-TVRFW2IX.js +0 -38
- package/dist/bundle/first-run-7JKE5AHN.js +0 -29
- package/dist/bundle/first-screen-ZROHOEYJ.js +0 -38
- package/dist/bundle/meeting-combined-SSTOJUIJ.js +0 -24
- package/dist/bundle/meeting-model-K7TPS4S5.js +0 -26
- package/dist/bundle/oauth-XBTROXHB.js +0 -20
- package/dist/bundle/server-UC2FNNXX.js +0 -72
- package/dist/bundle/store-maintenance-command-LRGQJPSZ.js +0 -63
|
@@ -0,0 +1,594 @@
|
|
|
1
|
+
import { createRequire as __bundleRequire } from "node:module";
|
|
2
|
+
const require = __bundleRequire(import.meta.url);
|
|
3
|
+
import {
|
|
4
|
+
looksLikeReference,
|
|
5
|
+
parseReference,
|
|
6
|
+
providerLabel,
|
|
7
|
+
providerNamed
|
|
8
|
+
} from "./chunk-BXXHUO7Y.js";
|
|
9
|
+
import {
|
|
10
|
+
QUERY_LIMITS,
|
|
11
|
+
exhausted,
|
|
12
|
+
searchError
|
|
13
|
+
} from "./chunk-FHYV4VWY.js";
|
|
14
|
+
import {
|
|
15
|
+
fold
|
|
16
|
+
} from "./chunk-6MQSBWWF.js";
|
|
17
|
+
import {
|
|
18
|
+
CliError,
|
|
19
|
+
singleLine
|
|
20
|
+
} from "./chunk-4FHKSSXQ.js";
|
|
21
|
+
import {
|
|
22
|
+
__name
|
|
23
|
+
} from "./chunk-ZVVMGPBJ.js";
|
|
24
|
+
|
|
25
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.718.0_@wirecat+cli-base@0.125.0_commander@15.0.0_esbuild@0.28.2_typ_cfff6f86942c54bd7564e982a7834a83/node_modules/@wirecat/cli-core/dist/search/lucene/resolved.js
|
|
26
|
+
var hasText = /* @__PURE__ */ __name((node) => node.kind === "predicate" ? node.field === "text" || node.field === "exact" : node.clauses.some(({ node: node2 }) => hasText(node2)), "hasText");
|
|
27
|
+
var isStemmed = /* @__PURE__ */ __name((node) => node.field === "text" && (node.operator === "term" || node.operator === "phrase") && node.value !== "", "isStemmed");
|
|
28
|
+
var hasStems = /* @__PURE__ */ __name((node) => node.kind === "predicate" ? isStemmed(node) : node.clauses.some(({ node: node2 }) => hasStems(node2)), "hasStems");
|
|
29
|
+
|
|
30
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.718.0_@wirecat+cli-base@0.125.0_commander@15.0.0_esbuild@0.28.2_typ_cfff6f86942c54bd7564e982a7834a83/node_modules/@wirecat/cli-core/dist/domain/ref-summaries.js
|
|
31
|
+
var profilesOn = /* @__PURE__ */ __name((profiles, app, key) => Object.entries(profiles[app] ?? {}).filter(([, saved]) => saved.provider === key.provider && saved.account === key.account).map(([name]) => name), "profilesOn");
|
|
32
|
+
var oneLine = /* @__PURE__ */ __name((text) => singleLine(text.replace(/\s+/g, " ").trim()), "oneLine");
|
|
33
|
+
|
|
34
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.718.0_@wirecat+cli-base@0.125.0_commander@15.0.0_esbuild@0.28.2_typ_cfff6f86942c54bd7564e982a7834a83/node_modules/@wirecat/cli-core/dist/search/lucene/automaton.js
|
|
35
|
+
var any = { kind: "char", ranges: [[0, 1114111]], negate: false };
|
|
36
|
+
var literal = /* @__PURE__ */ __name((c) => ({
|
|
37
|
+
kind: "char",
|
|
38
|
+
ranges: [[c.codePointAt(0) ?? 0, c.codePointAt(0) ?? 0]],
|
|
39
|
+
negate: false
|
|
40
|
+
}), "literal");
|
|
41
|
+
var compileAutomaton = /* @__PURE__ */ __name((pattern, span = { start: 0, end: pattern.length }) => {
|
|
42
|
+
if (pattern.length > QUERY_LIMITS.pattern * 2)
|
|
43
|
+
exhausted("pattern");
|
|
44
|
+
const chars = [...pattern];
|
|
45
|
+
if (chars.length > QUERY_LIMITS.pattern)
|
|
46
|
+
exhausted("pattern");
|
|
47
|
+
let at = 0, depth = 0;
|
|
48
|
+
const failure = /* @__PURE__ */ __name(() => searchError("query.invalid-regex", span, "use the supported Lucene regex subset"), "failure");
|
|
49
|
+
const character = /* @__PURE__ */ __name(() => {
|
|
50
|
+
if (at >= chars.length)
|
|
51
|
+
return failure();
|
|
52
|
+
return chars[at++];
|
|
53
|
+
}, "character");
|
|
54
|
+
const predefined = /* @__PURE__ */ __name(() => {
|
|
55
|
+
if (chars[at] !== "\\")
|
|
56
|
+
return void 0;
|
|
57
|
+
const name = chars[at + 1] ?? "";
|
|
58
|
+
let ranges;
|
|
59
|
+
if (name.toLowerCase() === "d")
|
|
60
|
+
ranges = [[48, 57]];
|
|
61
|
+
if (name.toLowerCase() === "w")
|
|
62
|
+
ranges = [
|
|
63
|
+
[48, 57],
|
|
64
|
+
[65, 90],
|
|
65
|
+
[95, 95],
|
|
66
|
+
[97, 122]
|
|
67
|
+
];
|
|
68
|
+
if (name.toLowerCase() === "s")
|
|
69
|
+
ranges = [
|
|
70
|
+
[9, 10],
|
|
71
|
+
[13, 13],
|
|
72
|
+
[32, 32]
|
|
73
|
+
];
|
|
74
|
+
if (ranges) {
|
|
75
|
+
at += 2;
|
|
76
|
+
return { kind: "char", ranges, negate: name === name.toUpperCase() };
|
|
77
|
+
}
|
|
78
|
+
if (/^[a-zA-Z]$/u.test(name))
|
|
79
|
+
return failure();
|
|
80
|
+
return void 0;
|
|
81
|
+
}, "predefined");
|
|
82
|
+
const escaped = /* @__PURE__ */ __name(() => {
|
|
83
|
+
if (chars[at] === "\\")
|
|
84
|
+
at++;
|
|
85
|
+
return character();
|
|
86
|
+
}, "escaped");
|
|
87
|
+
const union = /* @__PURE__ */ __name(() => {
|
|
88
|
+
if (++depth > QUERY_LIMITS.depth)
|
|
89
|
+
exhausted("pattern depth");
|
|
90
|
+
const children = [concat()];
|
|
91
|
+
while (chars[at] === "|") {
|
|
92
|
+
at++;
|
|
93
|
+
children.push(concat());
|
|
94
|
+
}
|
|
95
|
+
depth--;
|
|
96
|
+
return children.length === 1 ? children[0] : { kind: "union", children };
|
|
97
|
+
}, "union");
|
|
98
|
+
const concat = /* @__PURE__ */ __name(() => {
|
|
99
|
+
const children = [];
|
|
100
|
+
do {
|
|
101
|
+
children.push(repeat());
|
|
102
|
+
} while (at < chars.length && ![")", "|", "&"].includes(chars[at] ?? ""));
|
|
103
|
+
if (chars[at] === "&")
|
|
104
|
+
searchError("query.unsupported-regex", span, "automaton intersection is not supported");
|
|
105
|
+
return children.length === 1 ? children[0] : { kind: "concat", children };
|
|
106
|
+
}, "concat");
|
|
107
|
+
const repeat = /* @__PURE__ */ __name(() => {
|
|
108
|
+
let child = simple();
|
|
109
|
+
while (["?", "*", "+", "{"].includes(chars[at] ?? "")) {
|
|
110
|
+
const op = character();
|
|
111
|
+
let min = op === "+" ? 1 : 0, max = op === "?" ? 1 : null;
|
|
112
|
+
if (op === "{") {
|
|
113
|
+
const number = /* @__PURE__ */ __name(() => {
|
|
114
|
+
const start2 = at;
|
|
115
|
+
while (/^[0-9]$/u.test(chars[at] ?? ""))
|
|
116
|
+
at++;
|
|
117
|
+
if (at === start2)
|
|
118
|
+
return failure();
|
|
119
|
+
return Number(chars.slice(start2, at).join(""));
|
|
120
|
+
}, "number");
|
|
121
|
+
min = number();
|
|
122
|
+
max = min;
|
|
123
|
+
if (chars[at] === ",") {
|
|
124
|
+
at++;
|
|
125
|
+
max = chars[at] === "}" ? null : number();
|
|
126
|
+
}
|
|
127
|
+
if (character() !== "}" || max !== null && max < min)
|
|
128
|
+
return failure();
|
|
129
|
+
}
|
|
130
|
+
if (min > QUERY_LIMITS.states || max !== null && max > QUERY_LIMITS.states)
|
|
131
|
+
exhausted("automaton states");
|
|
132
|
+
child = { kind: "repeat", child, min, max };
|
|
133
|
+
}
|
|
134
|
+
return child;
|
|
135
|
+
}, "repeat");
|
|
136
|
+
const simple = /* @__PURE__ */ __name(() => {
|
|
137
|
+
const predefinedAtom = predefined();
|
|
138
|
+
if (predefinedAtom)
|
|
139
|
+
return predefinedAtom;
|
|
140
|
+
const c = character();
|
|
141
|
+
if (c === "~" || c === "<")
|
|
142
|
+
searchError("query.unsupported-regex", span, "complement, named automata and numeric intervals are not supported");
|
|
143
|
+
if (c === ".")
|
|
144
|
+
return any;
|
|
145
|
+
if (c === "#")
|
|
146
|
+
return { kind: "empty" };
|
|
147
|
+
if (c === "@")
|
|
148
|
+
return { kind: "repeat", child: any, min: 0, max: null };
|
|
149
|
+
if (c === '"') {
|
|
150
|
+
const children = [];
|
|
151
|
+
while (chars[at] !== '"')
|
|
152
|
+
children.push(literal(character()));
|
|
153
|
+
at++;
|
|
154
|
+
return { kind: "concat", children };
|
|
155
|
+
}
|
|
156
|
+
if (c === "(") {
|
|
157
|
+
if (chars[at] === ")") {
|
|
158
|
+
at++;
|
|
159
|
+
return { kind: "epsilon" };
|
|
160
|
+
}
|
|
161
|
+
if (chars[at] === "?")
|
|
162
|
+
searchError("query.unsupported-regex", span, "JavaScript groups and lookaround are not Lucene operators");
|
|
163
|
+
const child = union();
|
|
164
|
+
if (character() !== ")")
|
|
165
|
+
return failure();
|
|
166
|
+
return child;
|
|
167
|
+
}
|
|
168
|
+
if (c === "[") {
|
|
169
|
+
const negate = chars[at] === "^";
|
|
170
|
+
if (negate)
|
|
171
|
+
at++;
|
|
172
|
+
const choices = [];
|
|
173
|
+
do {
|
|
174
|
+
const pre = predefined();
|
|
175
|
+
if (pre) {
|
|
176
|
+
choices.push(pre);
|
|
177
|
+
continue;
|
|
178
|
+
}
|
|
179
|
+
const lo = escaped().codePointAt(0) ?? 0;
|
|
180
|
+
let hi = lo;
|
|
181
|
+
if (chars[at] === "-") {
|
|
182
|
+
at++;
|
|
183
|
+
hi = escaped().codePointAt(0) ?? 0;
|
|
184
|
+
}
|
|
185
|
+
if (hi < lo)
|
|
186
|
+
return failure();
|
|
187
|
+
choices.push({ kind: "char", ranges: [[lo, hi]], negate: false });
|
|
188
|
+
} while (at < chars.length && chars[at] !== "]");
|
|
189
|
+
if (character() !== "]")
|
|
190
|
+
return failure();
|
|
191
|
+
if (!negate)
|
|
192
|
+
return { kind: "union", children: choices };
|
|
193
|
+
const ranges = [];
|
|
194
|
+
for (const choice of choices) {
|
|
195
|
+
if (choice.kind !== "char" || choice.negate)
|
|
196
|
+
searchError("query.unsupported-regex", span, "negative predefined classes inside a negated class are not supported");
|
|
197
|
+
ranges.push(...choice.ranges);
|
|
198
|
+
}
|
|
199
|
+
return { kind: "char", ranges, negate: true };
|
|
200
|
+
}
|
|
201
|
+
if (c === "\\")
|
|
202
|
+
return literal(character());
|
|
203
|
+
return literal(c);
|
|
204
|
+
}, "simple");
|
|
205
|
+
const expression = chars.length === 0 ? { kind: "epsilon" } : union();
|
|
206
|
+
if (at !== chars.length)
|
|
207
|
+
return failure();
|
|
208
|
+
const states = [];
|
|
209
|
+
const state = /* @__PURE__ */ __name(() => {
|
|
210
|
+
if (states.length >= QUERY_LIMITS.states)
|
|
211
|
+
exhausted("automaton states");
|
|
212
|
+
states.push({ epsilon: [], edges: [] });
|
|
213
|
+
return states.length - 1;
|
|
214
|
+
}, "state");
|
|
215
|
+
const epsilon = /* @__PURE__ */ __name((from, to) => {
|
|
216
|
+
;
|
|
217
|
+
states[from].epsilon.push(to);
|
|
218
|
+
}, "epsilon");
|
|
219
|
+
const build = /* @__PURE__ */ __name((node, from, to) => {
|
|
220
|
+
if (node.kind === "char") {
|
|
221
|
+
;
|
|
222
|
+
states[from].edges.push({ to, atom: node });
|
|
223
|
+
return;
|
|
224
|
+
}
|
|
225
|
+
if (node.kind === "empty")
|
|
226
|
+
return;
|
|
227
|
+
if (node.kind === "epsilon") {
|
|
228
|
+
epsilon(from, to);
|
|
229
|
+
return;
|
|
230
|
+
}
|
|
231
|
+
if (node.kind === "union") {
|
|
232
|
+
for (const child of node.children)
|
|
233
|
+
build(child, from, to);
|
|
234
|
+
return;
|
|
235
|
+
}
|
|
236
|
+
if (node.kind === "concat") {
|
|
237
|
+
let current2 = from;
|
|
238
|
+
node.children.forEach((child, index) => {
|
|
239
|
+
const next = index === node.children.length - 1 ? to : state();
|
|
240
|
+
build(child, current2, next);
|
|
241
|
+
current2 = next;
|
|
242
|
+
});
|
|
243
|
+
if (node.children.length === 0)
|
|
244
|
+
epsilon(from, to);
|
|
245
|
+
return;
|
|
246
|
+
}
|
|
247
|
+
let current = from;
|
|
248
|
+
for (let i = 0; i < node.min; i++) {
|
|
249
|
+
const next = state();
|
|
250
|
+
build(node.child, current, next);
|
|
251
|
+
current = next;
|
|
252
|
+
}
|
|
253
|
+
if (node.max === null) {
|
|
254
|
+
epsilon(current, to);
|
|
255
|
+
const end2 = state();
|
|
256
|
+
build(node.child, current, end2);
|
|
257
|
+
epsilon(end2, current);
|
|
258
|
+
} else {
|
|
259
|
+
for (let i = node.min; i < node.max; i++) {
|
|
260
|
+
epsilon(current, to);
|
|
261
|
+
const next = state();
|
|
262
|
+
build(node.child, current, next);
|
|
263
|
+
current = next;
|
|
264
|
+
}
|
|
265
|
+
epsilon(current, to);
|
|
266
|
+
}
|
|
267
|
+
}, "build");
|
|
268
|
+
const start = state(), end = state();
|
|
269
|
+
build(expression, start, end);
|
|
270
|
+
return {
|
|
271
|
+
states: states.length,
|
|
272
|
+
test: /* @__PURE__ */ __name((text, budget = { work: 0 }) => {
|
|
273
|
+
const spend = /* @__PURE__ */ __name(() => {
|
|
274
|
+
if (++budget.work > (budget.maxWork ?? QUERY_LIMITS.work))
|
|
275
|
+
exhausted("automaton work");
|
|
276
|
+
}, "spend");
|
|
277
|
+
const closure = /* @__PURE__ */ __name((initial) => {
|
|
278
|
+
const stack = [...initial];
|
|
279
|
+
while (stack.length) {
|
|
280
|
+
const id = stack.pop();
|
|
281
|
+
for (const next of states[id].epsilon) {
|
|
282
|
+
spend();
|
|
283
|
+
if (!initial.has(next)) {
|
|
284
|
+
initial.add(next);
|
|
285
|
+
stack.push(next);
|
|
286
|
+
}
|
|
287
|
+
}
|
|
288
|
+
}
|
|
289
|
+
return initial;
|
|
290
|
+
}, "closure");
|
|
291
|
+
let current = closure(/* @__PURE__ */ new Set([start]));
|
|
292
|
+
for (const c of text) {
|
|
293
|
+
const point = c.codePointAt(0) ?? 0;
|
|
294
|
+
const next = /* @__PURE__ */ new Set();
|
|
295
|
+
for (const id of current)
|
|
296
|
+
for (const edge of states[id].edges) {
|
|
297
|
+
spend();
|
|
298
|
+
const inside = edge.atom.ranges.some(([lo, hi]) => point >= lo && point <= hi);
|
|
299
|
+
if (inside !== edge.atom.negate)
|
|
300
|
+
next.add(edge.to);
|
|
301
|
+
}
|
|
302
|
+
current = closure(next);
|
|
303
|
+
if (current.size === 0)
|
|
304
|
+
return false;
|
|
305
|
+
}
|
|
306
|
+
return current.has(end);
|
|
307
|
+
}, "test")
|
|
308
|
+
};
|
|
309
|
+
}, "compileAutomaton");
|
|
310
|
+
var wildcardPattern = /* @__PURE__ */ __name((value) => {
|
|
311
|
+
const chars = [...value];
|
|
312
|
+
let pattern = "";
|
|
313
|
+
for (let at = 0; at < chars.length; at++) {
|
|
314
|
+
const c = chars[at];
|
|
315
|
+
if (c === "\\") {
|
|
316
|
+
const escaped = chars[++at];
|
|
317
|
+
if (escaped === void 0)
|
|
318
|
+
searchError("query.invalid-escape", { start: 0, end: value.length });
|
|
319
|
+
pattern += /[|&?*+(){}[\].#@<>"~\\]/u.test(escaped) ? `\\${escaped}` : escaped;
|
|
320
|
+
} else
|
|
321
|
+
pattern += c === "*" ? ".*" : c === "?" ? "." : /[|&?*+(){}[\].#@<>"~\\]/u.test(c) ? `\\${c}` : c;
|
|
322
|
+
}
|
|
323
|
+
return pattern;
|
|
324
|
+
}, "wildcardPattern");
|
|
325
|
+
var FOLD_RANGE = 4096;
|
|
326
|
+
var unfoldable = /* @__PURE__ */ __name((span, what) => searchError("query.unsupported-regex", span, `${what} has no single lowercase form without accents, which is what text: words are \u2014 write it that way, or use body:/\u2026/ to match the original text`), "unfoldable");
|
|
327
|
+
var classChar = /* @__PURE__ */ __name((point) => {
|
|
328
|
+
const c = String.fromCodePoint(point);
|
|
329
|
+
return /[\p{L}\p{N}]/u.test(c) ? c : `\\${c}`;
|
|
330
|
+
}, "classChar");
|
|
331
|
+
var foldRegex = /* @__PURE__ */ __name((pattern, span) => {
|
|
332
|
+
const chars = [...pattern.normalize("NFC")];
|
|
333
|
+
let out = "";
|
|
334
|
+
let at = 0;
|
|
335
|
+
const literal2 = /* @__PURE__ */ __name((c) => {
|
|
336
|
+
if (!/[\p{L}\p{N}\p{M}]/u.test(c))
|
|
337
|
+
return c;
|
|
338
|
+
const folded = fold(c);
|
|
339
|
+
if (folded === "")
|
|
340
|
+
return unfoldable(span, `"${c}"`);
|
|
341
|
+
if ([...folded].length === 1 && /[\p{L}\p{N}]/u.test(folded))
|
|
342
|
+
return folded;
|
|
343
|
+
if (folded.includes('"'))
|
|
344
|
+
return unfoldable(span, `"${c}"`);
|
|
345
|
+
return `"${folded}"`;
|
|
346
|
+
}, "literal");
|
|
347
|
+
const characterClass = /* @__PURE__ */ __name(() => {
|
|
348
|
+
const begin = at - 1;
|
|
349
|
+
let negate = "";
|
|
350
|
+
if (chars[at] === "^") {
|
|
351
|
+
negate = "^";
|
|
352
|
+
at++;
|
|
353
|
+
}
|
|
354
|
+
const kept = [];
|
|
355
|
+
const points = /* @__PURE__ */ new Set();
|
|
356
|
+
do {
|
|
357
|
+
const start = at;
|
|
358
|
+
if (chars[at] === "\\" && /^[a-zA-Z]$/u.test(chars[at + 1] ?? "")) {
|
|
359
|
+
kept.push(`\\${chars[at + 1]}`);
|
|
360
|
+
at += 2;
|
|
361
|
+
continue;
|
|
362
|
+
}
|
|
363
|
+
const escaped = /* @__PURE__ */ __name(() => {
|
|
364
|
+
if (chars[at] === "\\")
|
|
365
|
+
at++;
|
|
366
|
+
return (chars[at++] ?? "").codePointAt(0) ?? 0;
|
|
367
|
+
}, "escaped");
|
|
368
|
+
const lo = escaped();
|
|
369
|
+
let hi = lo;
|
|
370
|
+
if (chars[at] === "-") {
|
|
371
|
+
at++;
|
|
372
|
+
hi = escaped();
|
|
373
|
+
}
|
|
374
|
+
if (at > chars.length) {
|
|
375
|
+
out += chars.slice(begin).join("");
|
|
376
|
+
return;
|
|
377
|
+
}
|
|
378
|
+
const single = /* @__PURE__ */ __name((point) => [...fold(String.fromCodePoint(point))], "single");
|
|
379
|
+
if (hi < lo)
|
|
380
|
+
kept.push(chars.slice(start, at).join(""));
|
|
381
|
+
else if (hi - lo >= FOLD_RANGE) {
|
|
382
|
+
if (single(lo).join("") !== String.fromCodePoint(lo) || single(hi).join("") !== String.fromCodePoint(hi))
|
|
383
|
+
unfoldable(span, `the range ${chars.slice(start, at).join("")}`);
|
|
384
|
+
kept.push(chars.slice(start, at).join(""));
|
|
385
|
+
} else
|
|
386
|
+
for (let point = lo; point <= hi; point++) {
|
|
387
|
+
const folded = single(point);
|
|
388
|
+
if (folded.length === 1)
|
|
389
|
+
points.add(folded[0]?.codePointAt(0) ?? 0);
|
|
390
|
+
else if (lo === hi)
|
|
391
|
+
unfoldable(span, `"${String.fromCodePoint(point)}"`);
|
|
392
|
+
}
|
|
393
|
+
} while (at < chars.length && chars[at] !== "]");
|
|
394
|
+
const sorted = [...points].sort((a, b) => a - b);
|
|
395
|
+
const ranges = [];
|
|
396
|
+
for (let i = 0; i < sorted.length; i++) {
|
|
397
|
+
const first = sorted[i];
|
|
398
|
+
while (sorted[i + 1] === sorted[i] + 1)
|
|
399
|
+
i++;
|
|
400
|
+
const last = sorted[i];
|
|
401
|
+
ranges.push(last === first ? classChar(first) : `${classChar(first)}-${classChar(last)}`);
|
|
402
|
+
}
|
|
403
|
+
if (!kept.length && !ranges.length)
|
|
404
|
+
unfoldable(span, "the class");
|
|
405
|
+
out += `[${negate}${kept.join("")}${ranges.join("")}`;
|
|
406
|
+
}, "characterClass");
|
|
407
|
+
while (at < chars.length) {
|
|
408
|
+
const c = chars[at++];
|
|
409
|
+
if (c === "\\") {
|
|
410
|
+
const next = chars[at++];
|
|
411
|
+
if (next === void 0)
|
|
412
|
+
out += c;
|
|
413
|
+
else
|
|
414
|
+
out += (next.codePointAt(0) ?? 0) < 128 ? `${c}${next}` : literal2(next);
|
|
415
|
+
} else if (c === '"') {
|
|
416
|
+
const end = chars.indexOf('"', at);
|
|
417
|
+
if (end < 0) {
|
|
418
|
+
out += chars.slice(at - 1).join("");
|
|
419
|
+
break;
|
|
420
|
+
}
|
|
421
|
+
const folded = fold(chars.slice(at, end).join(""));
|
|
422
|
+
if (folded.includes('"'))
|
|
423
|
+
unfoldable(span, `"${chars.slice(at, end).join("")}"`);
|
|
424
|
+
out += `"${folded}"`;
|
|
425
|
+
at = end + 1;
|
|
426
|
+
} else if (c === "[")
|
|
427
|
+
characterClass();
|
|
428
|
+
else
|
|
429
|
+
out += literal2(c);
|
|
430
|
+
}
|
|
431
|
+
return out;
|
|
432
|
+
}, "foldRegex");
|
|
433
|
+
|
|
434
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.718.0_@wirecat+cli-base@0.125.0_commander@15.0.0_esbuild@0.28.2_typ_cfff6f86942c54bd7564e982a7834a83/node_modules/@wirecat/cli-core/dist/domain/ref-arguments.js
|
|
435
|
+
var TAKES = {
|
|
436
|
+
chat: "a chat: chat:<provider>/<account>/<chat>, its id or its title",
|
|
437
|
+
message: "a message: msg:<provider>/<account>/<chat>/<message>, or a chat and the message's id"
|
|
438
|
+
};
|
|
439
|
+
var article = /* @__PURE__ */ __name((word) => /^[aeiou]/.test(word) ? "an" : "a", "article");
|
|
440
|
+
var wrongKind = /* @__PURE__ */ __name((text, kind, takes) => new CliError("validation_error", `${text} names ${article(kind)} ${kind}; this takes ${TAKES[takes]}`, {
|
|
441
|
+
reason: "ref.wrong-kind"
|
|
442
|
+
}), "wrongKind");
|
|
443
|
+
var wrongProvider = /* @__PURE__ */ __name((text, provider, kind) => {
|
|
444
|
+
const entry = providerNamed(provider);
|
|
445
|
+
const command = entry?.command;
|
|
446
|
+
const opens = kind === "entity" ? void 0 : entry?.opens?.[kind];
|
|
447
|
+
const how = command && opens ? `open it with ${command} <profile> ${opens} ${text}` : "open it with its own CLI";
|
|
448
|
+
const label = providerLabel(provider);
|
|
449
|
+
return new CliError("validation_error", `${text} is ${article(label.toLowerCase())} ${label} ${kind}; ${how}`, {
|
|
450
|
+
reason: "ref.wrong-provider"
|
|
451
|
+
});
|
|
452
|
+
}, "wrongProvider");
|
|
453
|
+
var chatReferenceOf = /* @__PURE__ */ __name((text, provider, takes = "chat") => {
|
|
454
|
+
const trimmed = text.trim();
|
|
455
|
+
if (!looksLikeReference(trimmed))
|
|
456
|
+
return void 0;
|
|
457
|
+
const reference = parseReference(trimmed);
|
|
458
|
+
if (reference.type !== "chat" && reference.type !== "message")
|
|
459
|
+
throw wrongKind(trimmed, reference.type, takes);
|
|
460
|
+
if (reference.provider !== provider)
|
|
461
|
+
throw wrongProvider(trimmed, reference.provider, reference.type);
|
|
462
|
+
const found = {
|
|
463
|
+
text: trimmed,
|
|
464
|
+
provider: reference.provider,
|
|
465
|
+
account: reference.account,
|
|
466
|
+
chat: reference.chat,
|
|
467
|
+
...reference.type === "message" ? { message: reference.message } : {}
|
|
468
|
+
};
|
|
469
|
+
return found;
|
|
470
|
+
}, "chatReferenceOf");
|
|
471
|
+
var contactReferenceOf = /* @__PURE__ */ __name((text, provider) => {
|
|
472
|
+
const trimmed = text.trim();
|
|
473
|
+
if (!trimmed.startsWith("contact:"))
|
|
474
|
+
return void 0;
|
|
475
|
+
const reference = parseReference(trimmed);
|
|
476
|
+
if (reference.type !== "contact")
|
|
477
|
+
return void 0;
|
|
478
|
+
if (provider !== void 0 && reference.provider !== provider)
|
|
479
|
+
throw wrongProvider(trimmed, reference.provider, reference.type);
|
|
480
|
+
return reference.id;
|
|
481
|
+
}, "contactReferenceOf");
|
|
482
|
+
var wrongAccount = /* @__PURE__ */ __name((reference, scope, profiles) => {
|
|
483
|
+
const here = scope.account === void 0 ? "the account of this profile is not known yet" : `${scope.profile === void 0 ? "this profile" : `profile ${scope.profile}`} is account ${scope.account}`;
|
|
484
|
+
const others = profiles === void 0 ? "" : `. Profiles signed in to ${reference.account}: ${profiles.length > 0 ? profiles.join(", ") : "none here"}`;
|
|
485
|
+
return new CliError("validation_error", `${reference.text} belongs to account ${reference.account}; ${here}${others}`, { reason: "ref.wrong-account" });
|
|
486
|
+
}, "wrongAccount");
|
|
487
|
+
var ensureAccount = /* @__PURE__ */ __name(async (reference, scope, profilesOn2) => {
|
|
488
|
+
if (scope.account !== void 0 && scope.account === reference.account)
|
|
489
|
+
return;
|
|
490
|
+
const profiles = await profilesOn2?.(reference.account).catch(() => void 0);
|
|
491
|
+
throw wrongAccount(reference, scope, profiles);
|
|
492
|
+
}, "ensureAccount");
|
|
493
|
+
|
|
494
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.718.0_@wirecat+cli-base@0.125.0_commander@15.0.0_esbuild@0.28.2_typ_cfff6f86942c54bd7564e982a7834a83/node_modules/@wirecat/cli-core/dist/search/trigrams.js
|
|
495
|
+
var trigrams = /* @__PURE__ */ __name((term) => {
|
|
496
|
+
const padded = ` ${term} `;
|
|
497
|
+
const pieces = /* @__PURE__ */ new Set();
|
|
498
|
+
for (let at = 0; at + 3 <= padded.length; at++)
|
|
499
|
+
pieces.add(padded.slice(at, at + 3));
|
|
500
|
+
return [...pieces];
|
|
501
|
+
}, "trigrams");
|
|
502
|
+
|
|
503
|
+
// node_modules/.pnpm/@wirecat+cli-core@0.718.0_@wirecat+cli-base@0.125.0_commander@15.0.0_esbuild@0.28.2_typ_cfff6f86942c54bd7564e982a7834a83/node_modules/@wirecat/cli-core/dist/resolve.js
|
|
504
|
+
var isId = /* @__PURE__ */ __name((reference) => /^-?\d+$/.test(reference.trim()), "isId");
|
|
505
|
+
var foldName = /* @__PURE__ */ __name((name) => name.normalize("NFC").replace(/[\uFE0E\uFE0F\u200D]/g, "").toLowerCase().replaceAll("\u0451", "\u0435"), "foldName");
|
|
506
|
+
var pickChat = /* @__PURE__ */ __name((reference, chats) => {
|
|
507
|
+
const wanted = foldName(reference.trim());
|
|
508
|
+
const matches = chats.filter((chat) => chat.title !== null && foldName(chat.title).includes(wanted));
|
|
509
|
+
if (matches.length === 1 && matches[0])
|
|
510
|
+
return matches[0];
|
|
511
|
+
if (matches.length === 0)
|
|
512
|
+
throw new CliError("not_found", `no chat matches "${reference}"`);
|
|
513
|
+
throw ambiguous(reference, "chats", matches.map((chat) => ({ id: chat.id, title: chat.title })), ({ title }) => singleLine(String(title)));
|
|
514
|
+
}, "pickChat");
|
|
515
|
+
var pickPerson = /* @__PURE__ */ __name((reference, people) => {
|
|
516
|
+
const trimmed = reference.trim();
|
|
517
|
+
const contact = contactReferenceOf(trimmed, people.provider);
|
|
518
|
+
if (contact !== void 0) {
|
|
519
|
+
const named = people.get(contact);
|
|
520
|
+
if (named)
|
|
521
|
+
return named;
|
|
522
|
+
throw new CliError("not_found", `no person ${contact} in what this account has seen`);
|
|
523
|
+
}
|
|
524
|
+
const known = people.get(trimmed);
|
|
525
|
+
if (known)
|
|
526
|
+
return known;
|
|
527
|
+
if (isId(trimmed))
|
|
528
|
+
throw new CliError("not_found", `no person ${trimmed} in what this account has seen`);
|
|
529
|
+
const wanted = foldName(trimmed.replace(/^@/, ""));
|
|
530
|
+
const everyone = people.all().toSorted((a, b) => (a.name ?? "").localeCompare(b.name ?? ""));
|
|
531
|
+
const exact = everyone.filter((person) => namesOf(person).includes(wanted));
|
|
532
|
+
const containing = everyone.filter((person) => namesOf(person).some((one) => one.includes(wanted)));
|
|
533
|
+
if (exact.length === 1 && exact[0])
|
|
534
|
+
return exact[0];
|
|
535
|
+
if (containing.length === 1 && containing[0])
|
|
536
|
+
return containing[0];
|
|
537
|
+
if (containing.length === 0)
|
|
538
|
+
throw new CliError("not_found", `nobody matches "${reference}"`);
|
|
539
|
+
const matches = exact.length > 0 ? [...exact, ...containing.filter((person) => !exact.includes(person))] : containing;
|
|
540
|
+
throw ambiguous(reference, "people", matches.map(({ id, name, username }) => ({ id, name, username })), ({ name, username }) => singleLine([name, username && `@${username}`].filter(isPresent).join(" ")));
|
|
541
|
+
}, "pickPerson");
|
|
542
|
+
var namesOf = /* @__PURE__ */ __name((person, byAddress = false) => [person.alias, person.name, person.username, byAddress ? person.id : void 0].filter(isPresent).map(foldName), "namesOf");
|
|
543
|
+
var chatNamesOf = /* @__PURE__ */ __name((chat) => [chat.title, chat.providerMetadata?.username].filter((one) => typeof one === "string" && one !== "").map(foldName), "chatNamesOf");
|
|
544
|
+
var namePattern = /* @__PURE__ */ __name((pattern) => {
|
|
545
|
+
const automaton = compileAutomaton(wildcardPattern(foldName(pattern.trim().replace(/^@/, ""))));
|
|
546
|
+
return (names) => names.some((one) => automaton.test(one));
|
|
547
|
+
}, "namePattern");
|
|
548
|
+
var peopleMatching = /* @__PURE__ */ __name((pattern, people, { byAddress = false } = {}) => {
|
|
549
|
+
const fits = namePattern(pattern);
|
|
550
|
+
return people.filter((person) => fits(namesOf(person, byAddress)));
|
|
551
|
+
}, "peopleMatching");
|
|
552
|
+
var chatsMatching = /* @__PURE__ */ __name((pattern, chats) => {
|
|
553
|
+
const fits = namePattern(pattern);
|
|
554
|
+
return chats.filter((chat) => fits(chatNamesOf(chat)));
|
|
555
|
+
}, "chatsMatching");
|
|
556
|
+
var nearest = /* @__PURE__ */ __name((pattern, items, names, most = 5) => {
|
|
557
|
+
const pieces = /* @__PURE__ */ __name((text) => foldName(text).split(/\s+/u).flatMap(trigrams), "pieces");
|
|
558
|
+
const wanted = new Set(pieces(pattern.replace(/\\(.)/gu, "$1").replace(/[*?@]/gu, " ").trim()));
|
|
559
|
+
if (wanted.size === 0)
|
|
560
|
+
return [];
|
|
561
|
+
return items.map((item) => ({
|
|
562
|
+
item,
|
|
563
|
+
score: names(item).flatMap(pieces).filter((piece) => wanted.has(piece)).length
|
|
564
|
+
})).filter(({ score }) => score > 1).toSorted((a, b) => b.score - a.score).slice(0, most).map(({ item }) => item);
|
|
565
|
+
}, "nearest");
|
|
566
|
+
var ambiguous = /* @__PURE__ */ __name((reference, what, candidates, label) => {
|
|
567
|
+
const width = Math.max(...candidates.map(({ id }) => id.length));
|
|
568
|
+
const lines = candidates.map((candidate) => ` ${candidate.id.padEnd(width)} ${label(candidate)}`).join("\n");
|
|
569
|
+
return new CliError("validation_error", `"${singleLine(reference)}" matches ${candidates.length} ${what} \u2014 name one by its id:
|
|
570
|
+
${lines}`, { candidates });
|
|
571
|
+
}, "ambiguous");
|
|
572
|
+
var isPresent = /* @__PURE__ */ __name((value) => value !== null && value !== void 0, "isPresent");
|
|
573
|
+
|
|
574
|
+
export {
|
|
575
|
+
profilesOn,
|
|
576
|
+
oneLine,
|
|
577
|
+
compileAutomaton,
|
|
578
|
+
wildcardPattern,
|
|
579
|
+
foldRegex,
|
|
580
|
+
hasText,
|
|
581
|
+
isStemmed,
|
|
582
|
+
hasStems,
|
|
583
|
+
chatReferenceOf,
|
|
584
|
+
wrongAccount,
|
|
585
|
+
ensureAccount,
|
|
586
|
+
trigrams,
|
|
587
|
+
isId,
|
|
588
|
+
foldName,
|
|
589
|
+
pickChat,
|
|
590
|
+
pickPerson,
|
|
591
|
+
peopleMatching,
|
|
592
|
+
chatsMatching,
|
|
593
|
+
nearest
|
|
594
|
+
};
|